Skip to content

Commit 8ab63b4

Browse files
committed
test: prevent plugin install twice
1 parent 8b7b991 commit 8ab63b4

File tree

4 files changed

+24
-2
lines changed

4 files changed

+24
-2
lines changed

src/browser.js

-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ function install(Vue, options = {}) {
1313
if (Vue.__vuemeta_installed) {
1414
return
1515
}
16-
1716
Vue.__vuemeta_installed = true
1817

1918
options = setOptions(options)

src/index.js

-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ function install(Vue, options = {}) {
1212
if (Vue.__vuemeta_installed) {
1313
return
1414
}
15-
1615
Vue.__vuemeta_installed = true
1716

1817
options = setOptions(options)

test/unit/plugin-browser.test.js

+12
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,18 @@ describe('plugin', () => {
6565
expect(VueMetaBrowserPlugin.version).toBe('test-version')
6666
})
6767

68+
test('plugin isnt be installed twice', () => {
69+
expect(Vue.__vuemeta_installed).toBe(true)
70+
71+
Vue.prototype.$meta = undefined
72+
Vue.use({ ...VueMetaBrowserPlugin })
73+
74+
expect(Vue.prototype.$meta).toBeUndefined()
75+
76+
// reset Vue
77+
Vue = loadVueMetaPlugin(true)
78+
})
79+
6880
test('updates can be paused and resumed', async () => {
6981
const { batchUpdate: _batchUpdate } = jest.requireActual('../../src/client/update')
7082
const batchUpdateSpy = batchUpdate.mockImplementation(_batchUpdate)

test/unit/plugin-server.test.js

+12
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,18 @@ describe('plugin', () => {
6363
expect(VueMetaServerPlugin.version).toBe('test-version')
6464
})
6565

66+
test('plugin isnt be installed twice', () => {
67+
expect(Vue.__vuemeta_installed).toBe(true)
68+
69+
Vue.prototype.$meta = undefined
70+
Vue.use({ ...VueMetaServerPlugin })
71+
72+
expect(Vue.prototype.$meta).toBeUndefined()
73+
74+
// reset Vue
75+
Vue = loadVueMetaPlugin(true)
76+
})
77+
6678
test('prints deprecation warning once when using _hasMetaInfo', () => {
6779
const warn = jest.spyOn(console, 'warn').mockImplementation(() => {})
6880

0 commit comments

Comments
 (0)