From 8ab63b445174e2fe0e5c28963acd6228d7d6fb41 Mon Sep 17 00:00:00 2001 From: pimlie Date: Sun, 9 Jun 2019 20:44:42 +0200 Subject: [PATCH] test: prevent plugin install twice --- src/browser.js | 1 - src/index.js | 1 - test/unit/plugin-browser.test.js | 12 ++++++++++++ test/unit/plugin-server.test.js | 12 ++++++++++++ 4 files changed, 24 insertions(+), 2 deletions(-) diff --git a/src/browser.js b/src/browser.js index 3891522..63b645e 100644 --- a/src/browser.js +++ b/src/browser.js @@ -13,7 +13,6 @@ function install(Vue, options = {}) { if (Vue.__vuemeta_installed) { return } - Vue.__vuemeta_installed = true options = setOptions(options) diff --git a/src/index.js b/src/index.js index 6ee009a..16c4a2c 100644 --- a/src/index.js +++ b/src/index.js @@ -12,7 +12,6 @@ function install(Vue, options = {}) { if (Vue.__vuemeta_installed) { return } - Vue.__vuemeta_installed = true options = setOptions(options) diff --git a/test/unit/plugin-browser.test.js b/test/unit/plugin-browser.test.js index 705b390..e5871bb 100644 --- a/test/unit/plugin-browser.test.js +++ b/test/unit/plugin-browser.test.js @@ -65,6 +65,18 @@ describe('plugin', () => { 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 () => { const { batchUpdate: _batchUpdate } = jest.requireActual('../../src/client/update') const batchUpdateSpy = batchUpdate.mockImplementation(_batchUpdate) diff --git a/test/unit/plugin-server.test.js b/test/unit/plugin-server.test.js index d4a301b..9ff4d4f 100644 --- a/test/unit/plugin-server.test.js +++ b/test/unit/plugin-server.test.js @@ -63,6 +63,18 @@ describe('plugin', () => { 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', () => { const warn = jest.spyOn(console, 'warn').mockImplementation(() => {})