mirror of
https://github.com/IT4Change/boilerplate-frontend.git
synced 2025-12-13 07:35:53 +00:00
global vikePageContext
This commit is contained in:
parent
e3633865b0
commit
7d88532aaf
8
scripts/tests/mock.vikePageContext.ts
Normal file
8
scripts/tests/mock.vikePageContext.ts
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
import { config } from '@vue/test-utils'
|
||||||
|
|
||||||
|
import { vikePageContext } from '#context/usePageContext'
|
||||||
|
|
||||||
|
config.global.provide = {
|
||||||
|
...config.global.provide,
|
||||||
|
[vikePageContext as symbol]: { urlPathname: '/some-url' },
|
||||||
|
}
|
||||||
@ -2,8 +2,6 @@ import { mount } from '@vue/test-utils'
|
|||||||
import { navigate } from 'vike/client/router'
|
import { navigate } from 'vike/client/router'
|
||||||
import { describe, it, expect, beforeEach, vi } from 'vitest'
|
import { describe, it, expect, beforeEach, vi } from 'vitest'
|
||||||
|
|
||||||
import { vikePageContext } from '#context/usePageContext'
|
|
||||||
|
|
||||||
import VikeBtn from './VikeBtn.vue'
|
import VikeBtn from './VikeBtn.vue'
|
||||||
|
|
||||||
vi.mock('vike/client/router')
|
vi.mock('vike/client/router')
|
||||||
@ -12,7 +10,6 @@ vi.mocked(navigate).mockResolvedValue()
|
|||||||
describe('VikeBtn', () => {
|
describe('VikeBtn', () => {
|
||||||
const Wrapper = () => {
|
const Wrapper = () => {
|
||||||
return mount(VikeBtn, {
|
return mount(VikeBtn, {
|
||||||
global: { provide: { [vikePageContext as symbol]: { urlPathname: '/some-url' } } },
|
|
||||||
attrs: { href: '/some-path' },
|
attrs: { href: '/some-path' },
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@ -8,7 +8,7 @@ export default mergeConfig(
|
|||||||
test: {
|
test: {
|
||||||
globals: true,
|
globals: true,
|
||||||
environment: 'happy-dom',
|
environment: 'happy-dom',
|
||||||
setupFiles: ['scripts/tests/mock.$t.ts', 'scripts/tests/plugin.vuetify.ts'],
|
setupFiles: ['scripts/tests/mock.$t.ts', 'scripts/tests/mock.vikePageContext.ts', 'scripts/tests/plugin.vuetify.ts'],
|
||||||
coverage: {
|
coverage: {
|
||||||
all: true,
|
all: true,
|
||||||
include: ['src/**/*.{js,jsx,ts,tsx,vue}'],
|
include: ['src/**/*.{js,jsx,ts,tsx,vue}'],
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user