From 95c3b7d4e8f9863c31e3a81265b66953dc8e264a Mon Sep 17 00:00:00 2001 From: pimlie Date: Tue, 5 Mar 2019 14:06:21 +0100 Subject: [PATCH] feat: use named exports to export helper functions --- src/browser.js | 11 ++++++----- src/index.js | 9 +++++---- test/plugin-server.test.js | 4 +++- test/utils/index.js | 5 ++--- 4 files changed, 16 insertions(+), 13 deletions(-) diff --git a/src/browser.js b/src/browser.js index 8839c059..700d8a6b 100644 --- a/src/browser.js +++ b/src/browser.js @@ -9,7 +9,7 @@ export { hasMetaInfo } from './shared/hasMetaInfo' * Plugin install function. * @param {Function} Vue - the Vue constructor. */ -function VueMeta(Vue, options = {}) { +function install(Vue, options = {}) { options = setOptions(options) Vue.prototype.$meta = $meta(options) @@ -17,12 +17,13 @@ function VueMeta(Vue, options = {}) { Vue.mixin(createMixin(Vue, options)) } -VueMeta.version = version - // automatic install if (!isUndefined(window) && !isUndefined(window.Vue)) { /* istanbul ignore next */ - Vue.use(VueMeta) + install(window.Vue) } -export default VueMeta +export { + version, + install +} diff --git a/src/index.js b/src/index.js index cb378840..819246d5 100644 --- a/src/index.js +++ b/src/index.js @@ -8,7 +8,7 @@ export { hasMetaInfo } from './shared/hasMetaInfo' * Plugin install function. * @param {Function} Vue - the Vue constructor. */ -function VueMeta(Vue, options = {}) { +function install(Vue, options = {}) { options = setOptions(options) Vue.prototype.$meta = $meta(options) @@ -16,6 +16,7 @@ function VueMeta(Vue, options = {}) { Vue.mixin(createMixin(Vue, options)) } -VueMeta.version = version - -export default VueMeta +export { + version, + install +} diff --git a/test/plugin-server.test.js b/test/plugin-server.test.js index 85c445ca..2eaa8b3d 100644 --- a/test/plugin-server.test.js +++ b/test/plugin-server.test.js @@ -1,4 +1,6 @@ -import { mount, defaultOptions, hasMetaInfo, VueMetaServerPlugin, loadVueMetaPlugin } from './utils' +import { mount, defaultOptions, VueMetaServerPlugin, loadVueMetaPlugin } from './utils' + +const { hasMetaInfo } = VueMetaServerPlugin jest.mock('../package.json', () => ({ version: 'test-version' diff --git a/test/utils/index.js b/test/utils/index.js index b4f4fccf..123d9936 100644 --- a/test/utils/index.js +++ b/test/utils/index.js @@ -1,7 +1,7 @@ import { mount, createLocalVue } from '@vue/test-utils' import { renderToString } from '@vue/server-test-utils' -import VueMetaBrowserPlugin from '../../src/browser' -import VueMetaServerPlugin, { hasMetaInfo } from '../../src' +import * as VueMetaBrowserPlugin from '../../src/browser' +import * as VueMetaServerPlugin from '../../src' import { keyName, @@ -15,7 +15,6 @@ import { export { mount, renderToString, - hasMetaInfo, VueMetaBrowserPlugin, VueMetaServerPlugin }