provide test, skip it since mocking provide doesnt work

This commit is contained in:
Ulf Gebhardt 2024-01-09 07:02:00 +01:00
parent e46ed489ca
commit d0f9ece25e
Signed by: ulfgebhardt
GPG Key ID: DA6B843E748679C9

View File

@ -0,0 +1,36 @@
import { mount } from '@vue/test-utils'
import { navigate } from 'vike/client/router'
import { describe, it, expect, beforeEach, vi } from 'vitest'
import VikeBtn from './VikeBtn.vue'
vi.mock('vike/client/router')
vi.mocked(navigate).mockResolvedValue()
describe.skip('VikeBtn', () => {
const Wrapper = () => {
return mount(VikeBtn, {
global: { provide: { [Symbol('pageContext')]: { urlPathname: 'some-url' } } },
attrs: { href: '/some-path' },
})
}
let wrapper: ReturnType<typeof Wrapper>
beforeEach(() => {
wrapper = Wrapper()
})
it('renders', () => {
expect(wrapper.find('.v-btn').exists()).toBeTruthy()
})
it('icon is hidden', () => {
expect(wrapper.find('.v-icon').exists()).toBe(false)
})
describe('click on button', () => {
it('calls navigate method with given href', async () => {
await wrapper.find('.v-btn').trigger('click')
expect(navigate).toHaveBeenCalledWith('/some-path')
})
})
})