describe('App.vue', () => { it('renders correctly', () => { Vue.use(vueRouter); const wrapper = shallowMount(App); expect(wrapper.vm).toBeDefined(); expect(wrapper.element).toBeDefined(); }); });
export function createApp(store) { let app = new Vue({ data: store, render: h => h(App) }); if (isBrowser()) { // const eruda = require('eruda'); // eruda.init(); const VueAwesomeSwiper = require('vue-awesome-swiper/dist/ssr') Vue.use(VueAwesomeSwiper) } return { store, app, App} }
// const i18nStore = new Vuex.Store({ // strict: debug // }) Vue.use(vuexI18n.plugin, store, { onTranslationNotFound: function (locale, key) { if (debug) { /* eslint-disable-next-line no-console */ console.warn(`vuex-i18n :: Key '${key}' not found for locale '${locale}'`) } }, })
init(options = {}) { Vue.use(Vuex) Vue.use(Styleguide) Vue.use(Filters) Vue.use(IziToast) Vue.use(Directives) Vue.use(vuexI18n.plugin, helpers.store) locales.forEach(({ code }) => { Vue.i18n.add(code, require(`~/locales/${code}.json`)) }) Vue.i18n.set('en') Vue.i18n.fallback('en') const { plugins = [] } = options plugins.forEach((plugin) => Vue.use(plugin)) }
describe('Global API: use', () => { const def = {} const options = {} const pluginStub = { install: (Vue, opts) => { Vue.directive('plugin-test', def) expect(opts).toBe(options) } } it('should apply Object plugin', () => { Vue.use(pluginStub, options) expect(Vue.options.directives['plugin-test']).toBe(def) delete Vue.options.directives['plugin-test'] }) it('should apply Function plugin', () => { Vue.use(pluginStub.install, options) expect(Vue.options.directives['plugin-test']).toBe(def) delete Vue.options.directives['plugin-test'] }) })
Vue.use(ElementUI, { i18n: (key, value) => i18n.t(key, value) })
export function createValidation() { // http://vee-validate.logaretm.com/#configuration const config = { errorBagName: 'errors', // change if property conflicts fieldsBagName: 'fields', delay: 0, locale: 'en', dictionary: null, strict: true, classes: true, // * Default : false classNames: { touched: 'touched', // the control has been blurred untouched: 'untouched', // the control hasn't been blurred valid: 'valid', // model is valid invalid: 'invalid', // model is invalid pristine: 'pristine', // control has not been interacted with dirty: 'dirty' // control has been interacted with }, events: 'input|blur', inject: true, validity: false, aria: true, i18n: null, // the vue-i18n plugin instance, i18nRootKey: 'validations' // the nested key under which the validation messsages will be located }; Vue.use(VeeValidate, config); }
export function createApp(store) { let app = new Vue({ data: store, render: h => h(App) }); if (isBrowser()) { // const eruda = require('eruda'); // eruda.init(); const VueAwesomeSwiper = require('vue-awesome-swiper/dist/ssr') Vue.use(VueAwesomeSwiper) } return { store, app, App} }
describe('Global API: use', () => { const def = {} const options = {} const pluginStub = { install: (Vue, opts) => { Vue.directive('plugin-test', def) expect(opts).toBe(options) } } it('should apply Object plugin', () => { Vue.use(pluginStub, options) expect(Vue.options.directives['plugin-test']).toBe(def) delete Vue.options.directives['plugin-test'] }) it('should apply Function plugin', () => { Vue.use(pluginStub.install, options) expect(Vue.options.directives['plugin-test']).toBe(def) delete Vue.options.directives['plugin-test'] }) })