salix-front/tests/jest/jestHelpers.js

33 lines
866 B
JavaScript
Raw Normal View History

2022-03-25 14:14:49 +00:00
import { mount, flushPromises } from '@vue/test-utils';
import { installQuasarPlugin } from '@quasar/quasar-app-extension-testing-unit-jest';
import { i18n } from 'src/boot/i18n';
2022-12-13 11:21:12 +00:00
import { Notify, Dialog } from 'quasar';
2022-03-25 14:14:49 +00:00
import axios from 'axios';
installQuasarPlugin({
plugins: {
2022-12-13 11:21:12 +00:00
Notify,
Dialog,
},
2022-03-25 14:14:49 +00:00
});
export function createWrapper(component, options) {
2022-12-13 11:21:12 +00:00
const mountOptions = {};
if (options instanceof Object) Object.assign(mountOptions, options);
2022-12-13 11:21:12 +00:00
if (mountOptions.global && mountOptions.global.plugins) {
mountOptions.global.plugins.push(i18n);
} else {
if (!mountOptions.global) mountOptions.global = {};
mountOptions.global.plugins = [i18n];
}
const wrapper = mount(component, mountOptions);
2022-03-25 14:14:49 +00:00
const vm = wrapper.vm;
return { vm, wrapper };
}
2022-12-13 11:21:12 +00:00
export { axios, flushPromises };