mirror of
https://github.com/IT4Change/boilerplate-frontend.git
synced 2025-12-13 07:35:53 +00:00
provide test, skip it since mocking provide doesnt work
This commit is contained in:
parent
e46ed489ca
commit
d0f9ece25e
36
src/components/VikeBtn.test.ts
Normal file
36
src/components/VikeBtn.test.ts
Normal 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')
|
||||||
|
})
|
||||||
|
})
|
||||||
|
})
|
||||||
Loading…
x
Reference in New Issue
Block a user