mirror of
https://github.com/tenrok/vue-meta.git
synced 2026-06-24 01:00:33 +03:00
test: prevent plugin install twice
This commit is contained in:
@@ -13,7 +13,6 @@ function install(Vue, options = {}) {
|
|||||||
if (Vue.__vuemeta_installed) {
|
if (Vue.__vuemeta_installed) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
Vue.__vuemeta_installed = true
|
Vue.__vuemeta_installed = true
|
||||||
|
|
||||||
options = setOptions(options)
|
options = setOptions(options)
|
||||||
|
|||||||
@@ -12,7 +12,6 @@ function install(Vue, options = {}) {
|
|||||||
if (Vue.__vuemeta_installed) {
|
if (Vue.__vuemeta_installed) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
Vue.__vuemeta_installed = true
|
Vue.__vuemeta_installed = true
|
||||||
|
|
||||||
options = setOptions(options)
|
options = setOptions(options)
|
||||||
|
|||||||
@@ -65,6 +65,18 @@ describe('plugin', () => {
|
|||||||
expect(VueMetaBrowserPlugin.version).toBe('test-version')
|
expect(VueMetaBrowserPlugin.version).toBe('test-version')
|
||||||
})
|
})
|
||||||
|
|
||||||
|
test('plugin isnt be installed twice', () => {
|
||||||
|
expect(Vue.__vuemeta_installed).toBe(true)
|
||||||
|
|
||||||
|
Vue.prototype.$meta = undefined
|
||||||
|
Vue.use({ ...VueMetaBrowserPlugin })
|
||||||
|
|
||||||
|
expect(Vue.prototype.$meta).toBeUndefined()
|
||||||
|
|
||||||
|
// reset Vue
|
||||||
|
Vue = loadVueMetaPlugin(true)
|
||||||
|
})
|
||||||
|
|
||||||
test('updates can be paused and resumed', async () => {
|
test('updates can be paused and resumed', async () => {
|
||||||
const { batchUpdate: _batchUpdate } = jest.requireActual('../../src/client/update')
|
const { batchUpdate: _batchUpdate } = jest.requireActual('../../src/client/update')
|
||||||
const batchUpdateSpy = batchUpdate.mockImplementation(_batchUpdate)
|
const batchUpdateSpy = batchUpdate.mockImplementation(_batchUpdate)
|
||||||
|
|||||||
@@ -63,6 +63,18 @@ describe('plugin', () => {
|
|||||||
expect(VueMetaServerPlugin.version).toBe('test-version')
|
expect(VueMetaServerPlugin.version).toBe('test-version')
|
||||||
})
|
})
|
||||||
|
|
||||||
|
test('plugin isnt be installed twice', () => {
|
||||||
|
expect(Vue.__vuemeta_installed).toBe(true)
|
||||||
|
|
||||||
|
Vue.prototype.$meta = undefined
|
||||||
|
Vue.use({ ...VueMetaServerPlugin })
|
||||||
|
|
||||||
|
expect(Vue.prototype.$meta).toBeUndefined()
|
||||||
|
|
||||||
|
// reset Vue
|
||||||
|
Vue = loadVueMetaPlugin(true)
|
||||||
|
})
|
||||||
|
|
||||||
test('prints deprecation warning once when using _hasMetaInfo', () => {
|
test('prints deprecation warning once when using _hasMetaInfo', () => {
|
||||||
const warn = jest.spyOn(console, 'warn').mockImplementation(() => {})
|
const warn = jest.spyOn(console, 'warn').mockImplementation(() => {})
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user