mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-27 08:02:01 +00:00
test: add test for inject in context (#7252)
This commit is contained in:
parent
67b8020c11
commit
76c40e3ffd
@ -35,6 +35,14 @@ describe('with-config', () => {
|
||||
// inject('injectedProperty', '')
|
||||
await expect(nuxt.renderRoute('/?injectValue=empty')).resolves.not.toThrowError()
|
||||
})
|
||||
test('inject should add to context and prototypes', async () => {
|
||||
const window = await nuxt.server.renderAndGetWindow(url('/?injectValue=foo'))
|
||||
// inject('injectedProperty', 'bar')
|
||||
await expect(window.$nuxt.$injectedProperty).toBe('bar')
|
||||
await expect(window.$nuxt.context.$injectedProperty).toBe('bar')
|
||||
await expect(window.$nuxt.context.app.$injectedProperty).toBe('bar')
|
||||
await expect(window.$nuxt.$store.$injectedProperty).toBe('bar')
|
||||
})
|
||||
|
||||
// Close server and ask nuxt to stop listening to file changes
|
||||
afterAll(async () => {
|
||||
|
3
test/fixtures/basic/plugins/inject.js
vendored
3
test/fixtures/basic/plugins/inject.js
vendored
@ -9,7 +9,8 @@ export default ({ route, params }, inject) => {
|
||||
null: null,
|
||||
false: false,
|
||||
0: 0,
|
||||
empty: ''
|
||||
empty: '',
|
||||
foo: 'bar'
|
||||
}
|
||||
const value = map[injectValue]
|
||||
inject(key, value)
|
||||
|
Loading…
Reference in New Issue
Block a user