Commit e287f845 authored by winniehell's avatar winniehell

Use global Vue instance in Jest (approvals)

parent 8464faa7
import { GlButton, GlForm, GlLoadingIcon, GlLink } from '@gitlab/ui'; import { GlButton, GlForm, GlLoadingIcon, GlLink } from '@gitlab/ui';
import { createLocalVue, shallowMount } from '@vue/test-utils'; import { shallowMount } from '@vue/test-utils';
import Vue from 'vue';
import Vuex from 'vuex'; import Vuex from 'vuex';
import ApprovalSettings from 'ee/approvals/components/approval_settings.vue'; import ApprovalSettings from 'ee/approvals/components/approval_settings.vue';
...@@ -16,8 +17,7 @@ import waitForPromises from 'helpers/wait_for_promises'; ...@@ -16,8 +17,7 @@ import waitForPromises from 'helpers/wait_for_promises';
import { sprintf } from '~/locale'; import { sprintf } from '~/locale';
import { createGroupApprovalsPayload, createGroupApprovalsState } from '../mocks'; import { createGroupApprovalsPayload, createGroupApprovalsState } from '../mocks';
const localVue = createLocalVue(); Vue.use(Vuex);
localVue.use(Vuex);
describe('ApprovalSettings', () => { describe('ApprovalSettings', () => {
let wrapper; let wrapper;
...@@ -44,7 +44,6 @@ describe('ApprovalSettings', () => { ...@@ -44,7 +44,6 @@ describe('ApprovalSettings', () => {
const createWrapper = (props = {}) => { const createWrapper = (props = {}) => {
wrapper = extendedWrapper( wrapper = extendedWrapper(
shallowMount(ApprovalSettings, { shallowMount(ApprovalSettings, {
localVue,
store, store,
propsData: { propsData: {
approvalSettingsPath, approvalSettingsPath,
......
import { createLocalVue, shallowMount } from '@vue/test-utils'; import { shallowMount } from '@vue/test-utils';
import $ from 'jquery'; import $ from 'jquery';
import 'select2/select2'; import 'select2/select2';
import Api from 'ee/api'; import Api from 'ee/api';
...@@ -24,8 +24,6 @@ const TEST_USERS = [ ...@@ -24,8 +24,6 @@ const TEST_USERS = [
{ id: 3, name: 'Sit', username: 'sit', avatar_url: TEST_USER_AVATAR }, { id: 3, name: 'Sit', username: 'sit', avatar_url: TEST_USER_AVATAR },
]; ];
const localVue = createLocalVue();
const waitForEvent = ($input, event) => new Promise((resolve) => $input.one(event, resolve)); const waitForEvent = ($input, event) => new Promise((resolve) => $input.one(event, resolve));
const parseAvatar = (element) => const parseAvatar = (element) =>
element.classList.contains('identicon') ? null : element.getAttribute('src'); element.classList.contains('identicon') ? null : element.getAttribute('src');
...@@ -62,7 +60,6 @@ describe('Approvals ApproversSelect', () => { ...@@ -62,7 +60,6 @@ describe('Approvals ApproversSelect', () => {
wrapper = await shallowMount(ApproversSelect, { wrapper = await shallowMount(ApproversSelect, {
...options, ...options,
propsData, propsData,
localVue,
attachTo: document.body, attachTo: document.body,
}); });
......
import { GlSprintf, GlLink } from '@gitlab/ui'; import { GlSprintf, GlLink } from '@gitlab/ui';
import { createLocalVue, shallowMount } from '@vue/test-utils'; import { shallowMount } from '@vue/test-utils';
import axios from 'axios'; import axios from 'axios';
import MockAdapter from 'axios-mock-adapter'; import MockAdapter from 'axios-mock-adapter';
import Vue from 'vue';
import Vuex from 'vuex'; import Vuex from 'vuex';
import ApprovalSettings from 'ee/approvals/components/approval_settings.vue'; import ApprovalSettings from 'ee/approvals/components/approval_settings.vue';
...@@ -13,8 +14,7 @@ import approvalSettingsModule from 'ee/approvals/stores/modules/approval_setting ...@@ -13,8 +14,7 @@ import approvalSettingsModule from 'ee/approvals/stores/modules/approval_setting
import { extendedWrapper } from 'helpers/vue_test_utils_helper'; import { extendedWrapper } from 'helpers/vue_test_utils_helper';
import SettingsBlock from '~/vue_shared/components/settings/settings_block.vue'; import SettingsBlock from '~/vue_shared/components/settings/settings_block.vue';
const localVue = createLocalVue(); Vue.use(Vuex);
localVue.use(Vuex);
describe('EE Approvals Group Settings App', () => { describe('EE Approvals Group Settings App', () => {
let wrapper; let wrapper;
...@@ -27,7 +27,6 @@ describe('EE Approvals Group Settings App', () => { ...@@ -27,7 +27,6 @@ describe('EE Approvals Group Settings App', () => {
const createWrapper = () => { const createWrapper = () => {
wrapper = extendedWrapper( wrapper = extendedWrapper(
shallowMount(GroupSettingsApp, { shallowMount(GroupSettingsApp, {
localVue,
store: new Vuex.Store(store), store: new Vuex.Store(store),
propsData: { propsData: {
defaultExpanded, defaultExpanded,
......
import { GlIcon } from '@gitlab/ui'; import { GlIcon } from '@gitlab/ui';
import { mount, createLocalVue } from '@vue/test-utils'; import { mount } from '@vue/test-utils';
import Vue from 'vue';
import Vuex from 'vuex'; import Vuex from 'vuex';
import LicenseComplianceApprovals from 'ee/approvals/components/license_compliance/index.vue'; import LicenseComplianceApprovals from 'ee/approvals/components/license_compliance/index.vue';
import approvalsLicenceComplianceModule, { import approvalsLicenceComplianceModule, {
...@@ -8,8 +9,7 @@ import approvalsLicenceComplianceModule, { ...@@ -8,8 +9,7 @@ import approvalsLicenceComplianceModule, {
} from 'ee/approvals/stores/modules/license_compliance'; } from 'ee/approvals/stores/modules/license_compliance';
import modalModule from '~/vuex_shared/modules/modal'; import modalModule from '~/vuex_shared/modules/modal';
const localVue = createLocalVue(); Vue.use(Vuex);
localVue.use(Vuex);
const TEST_APPROVALS_DOCUMENTATION_PATH = 'http://foo.bar'; const TEST_APPROVALS_DOCUMENTATION_PATH = 'http://foo.bar';
const TEST_LOCKED_APPROVALS_RULE_NAME = 'License-Check'; const TEST_LOCKED_APPROVALS_RULE_NAME = 'License-Check';
...@@ -35,7 +35,6 @@ describe('EE Approvals LicenseCompliance', () => { ...@@ -35,7 +35,6 @@ describe('EE Approvals LicenseCompliance', () => {
const createWrapper = () => { const createWrapper = () => {
wrapper = mount(LicenseComplianceApprovals, { wrapper = mount(LicenseComplianceApprovals, {
localVue,
store: new Vuex.Store(store), store: new Vuex.Store(store),
stubs: { stubs: {
'rule-form': true, 'rule-form': true,
......
import { GlSprintf, GlModal } from '@gitlab/ui'; import { GlSprintf, GlModal } from '@gitlab/ui';
import { shallowMount, createLocalVue } from '@vue/test-utils'; import { shallowMount } from '@vue/test-utils';
import Vue from 'vue';
import Vuex from 'vuex'; import Vuex from 'vuex';
import LicenseComplianceModal from 'ee/approvals/components/license_compliance/modal.vue'; import LicenseComplianceModal from 'ee/approvals/components/license_compliance/modal.vue';
import { APPROVALS_MODAL } from 'ee/approvals/stores/modules/license_compliance'; import { APPROVALS_MODAL } from 'ee/approvals/stores/modules/license_compliance';
import GlModalVuex from '~/vue_shared/components/gl_modal_vuex.vue'; import GlModalVuex from '~/vue_shared/components/gl_modal_vuex.vue';
const localVue = createLocalVue(); Vue.use(Vuex);
localVue.use(Vuex);
describe('EE Approvals LicenseCompliance Modal', () => { describe('EE Approvals LicenseCompliance Modal', () => {
let wrapper; let wrapper;
...@@ -52,7 +52,6 @@ describe('EE Approvals LicenseCompliance Modal', () => { ...@@ -52,7 +52,6 @@ describe('EE Approvals LicenseCompliance Modal', () => {
const createWrapper = () => { const createWrapper = () => {
wrapper = shallowMount(LicenseComplianceModal, { wrapper = shallowMount(LicenseComplianceModal, {
localVue,
store, store,
stubs: { stubs: {
GlModalVuex, GlModalVuex,
......
import { GlSprintf } from '@gitlab/ui'; import { GlSprintf } from '@gitlab/ui';
import { shallowMount, createLocalVue } from '@vue/test-utils'; import { shallowMount } from '@vue/test-utils';
import Vue from 'vue';
import Vuex from 'vuex'; import Vuex from 'vuex';
import ModalRuleRemove from 'ee/approvals/components/modal_rule_remove.vue'; import ModalRuleRemove from 'ee/approvals/components/modal_rule_remove.vue';
import { stubComponent } from 'helpers/stub_component'; import { stubComponent } from 'helpers/stub_component';
...@@ -19,8 +20,7 @@ const SINGLE_APPROVER = { ...@@ -19,8 +20,7 @@ const SINGLE_APPROVER = {
approvers: [{ id: 1 }], approvers: [{ id: 1 }],
}; };
const localVue = createLocalVue(); Vue.use(Vuex);
localVue.use(Vuex);
describe('Approvals ModalRuleRemove', () => { describe('Approvals ModalRuleRemove', () => {
let wrapper; let wrapper;
...@@ -47,7 +47,6 @@ describe('Approvals ModalRuleRemove', () => { ...@@ -47,7 +47,6 @@ describe('Approvals ModalRuleRemove', () => {
wrapper = shallowMount(ModalRuleRemove, { wrapper = shallowMount(ModalRuleRemove, {
...options, ...options,
localVue,
store, store,
propsData, propsData,
stubs: { stubs: {
......
import { mount, createLocalVue } from '@vue/test-utils'; import { mount } from '@vue/test-utils';
import axios from 'axios'; import axios from 'axios';
import MockAdapter from 'axios-mock-adapter'; import MockAdapter from 'axios-mock-adapter';
import Vue from 'vue';
import Vuex from 'vuex'; import Vuex from 'vuex';
import MREditApp from 'ee/approvals/components/mr_edit/app.vue'; import MREditApp from 'ee/approvals/components/mr_edit/app.vue';
import MRRules from 'ee/approvals/components/mr_edit/mr_rules.vue'; import MRRules from 'ee/approvals/components/mr_edit/mr_rules.vue';
...@@ -8,8 +9,7 @@ import MRRulesHiddenInputs from 'ee/approvals/components/mr_edit/mr_rules_hidden ...@@ -8,8 +9,7 @@ import MRRulesHiddenInputs from 'ee/approvals/components/mr_edit/mr_rules_hidden
import { createStoreOptions } from 'ee/approvals/stores'; import { createStoreOptions } from 'ee/approvals/stores';
import MREditModule from 'ee/approvals/stores/modules/mr_edit'; import MREditModule from 'ee/approvals/stores/modules/mr_edit';
const localVue = createLocalVue(); Vue.use(Vuex);
localVue.use(Vuex);
describe('EE Approvals MREditApp', () => { describe('EE Approvals MREditApp', () => {
let wrapper; let wrapper;
...@@ -18,7 +18,6 @@ describe('EE Approvals MREditApp', () => { ...@@ -18,7 +18,6 @@ describe('EE Approvals MREditApp', () => {
const factory = (mrCollapsedApprovalRules = false) => { const factory = (mrCollapsedApprovalRules = false) => {
wrapper = mount(MREditApp, { wrapper = mount(MREditApp, {
localVue,
store: new Vuex.Store(store), store: new Vuex.Store(store),
provide: { provide: {
glFeatures: { glFeatures: {
......
import { shallowMount, createLocalVue } from '@vue/test-utils'; import { shallowMount } from '@vue/test-utils';
import Vue from 'vue';
import Vuex from 'vuex'; import Vuex from 'vuex';
import RuleInput from 'ee/approvals/components/mr_edit/rule_input.vue'; import RuleInput from 'ee/approvals/components/mr_edit/rule_input.vue';
import { createStoreOptions } from 'ee/approvals/stores'; import { createStoreOptions } from 'ee/approvals/stores';
import MREditModule from 'ee/approvals/stores/modules/mr_edit'; import MREditModule from 'ee/approvals/stores/modules/mr_edit';
const localVue = createLocalVue(); Vue.use(Vuex);
localVue.use(Vuex);
describe('Rule Input', () => { describe('Rule Input', () => {
let wrapper; let wrapper;
...@@ -20,7 +20,6 @@ describe('Rule Input', () => { ...@@ -20,7 +20,6 @@ describe('Rule Input', () => {
}, },
...props, ...props,
}, },
localVue,
store: new Vuex.Store(store), store: new Vuex.Store(store),
}); });
}; };
......
import { GlLink, GlPopover, GlIcon } from '@gitlab/ui'; import { GlLink, GlPopover, GlIcon } from '@gitlab/ui';
import { shallowMount, createLocalVue } from '@vue/test-utils'; import { shallowMount } from '@vue/test-utils';
import Vue from 'vue';
import Vuex from 'vuex'; import Vuex from 'vuex';
import RuleName from 'ee/approvals/components/rule_name.vue'; import RuleName from 'ee/approvals/components/rule_name.vue';
const localVue = createLocalVue(); Vue.use(Vuex);
localVue.use(Vuex);
describe('RuleName component', () => { describe('RuleName component', () => {
let wrapper; let wrapper;
const createWrapper = (props = {}) => { const createWrapper = (props = {}) => {
wrapper = shallowMount(RuleName, { wrapper = shallowMount(RuleName, {
localVue,
propsData: { propsData: {
...props, ...props,
}, },
......
import { GlSprintf, GlButton } from '@gitlab/ui'; import { GlSprintf, GlButton } from '@gitlab/ui';
import { mount, createLocalVue } from '@vue/test-utils'; import { mount } from '@vue/test-utils';
import Vue from 'vue';
import Vuex from 'vuex'; import Vuex from 'vuex';
import UnconfiguredSecurityRule from 'ee/approvals/components/security_configuration/unconfigured_security_rule.vue'; import UnconfiguredSecurityRule from 'ee/approvals/components/security_configuration/unconfigured_security_rule.vue';
import { import {
...@@ -8,8 +9,7 @@ import { ...@@ -8,8 +9,7 @@ import {
COVERAGE_CHECK_NAME, COVERAGE_CHECK_NAME,
} from 'ee/approvals/constants'; } from 'ee/approvals/constants';
const localVue = createLocalVue(); Vue.use(Vuex);
localVue.use(Vuex);
describe('UnconfiguredSecurityRule component', () => { describe('UnconfiguredSecurityRule component', () => {
let wrapper; let wrapper;
...@@ -38,7 +38,6 @@ describe('UnconfiguredSecurityRule component', () => { ...@@ -38,7 +38,6 @@ describe('UnconfiguredSecurityRule component', () => {
const createWrapper = (props = {}, options = {}) => { const createWrapper = (props = {}, options = {}) => {
wrapper = mount(UnconfiguredSecurityRule, { wrapper = mount(UnconfiguredSecurityRule, {
localVue,
propsData: { propsData: {
...props, ...props,
}, },
......
import { GlDeprecatedSkeletonLoading as GlSkeletonLoading } from '@gitlab/ui'; import { GlDeprecatedSkeletonLoading as GlSkeletonLoading } from '@gitlab/ui';
import { shallowMount, createLocalVue } from '@vue/test-utils'; import { shallowMount } from '@vue/test-utils';
import Vue from 'vue';
import Vuex from 'vuex'; import Vuex from 'vuex';
import UnconfiguredSecurityRule from 'ee/approvals/components/security_configuration/unconfigured_security_rule.vue'; import UnconfiguredSecurityRule from 'ee/approvals/components/security_configuration/unconfigured_security_rule.vue';
import UnconfiguredSecurityRules from 'ee/approvals/components/security_configuration/unconfigured_security_rules.vue'; import UnconfiguredSecurityRules from 'ee/approvals/components/security_configuration/unconfigured_security_rules.vue';
import { createStoreOptions } from 'ee/approvals/stores'; import { createStoreOptions } from 'ee/approvals/stores';
import projectSettingsModule from 'ee/approvals/stores/modules/project_settings'; import projectSettingsModule from 'ee/approvals/stores/modules/project_settings';
const localVue = createLocalVue(); Vue.use(Vuex);
localVue.use(Vuex);
describe('UnconfiguredSecurityRules component', () => { describe('UnconfiguredSecurityRules component', () => {
let wrapper; let wrapper;
...@@ -17,7 +17,6 @@ describe('UnconfiguredSecurityRules component', () => { ...@@ -17,7 +17,6 @@ describe('UnconfiguredSecurityRules component', () => {
const createWrapper = (props = {}) => { const createWrapper = (props = {}) => {
wrapper = shallowMount(UnconfiguredSecurityRules, { wrapper = shallowMount(UnconfiguredSecurityRules, {
localVue,
store, store,
propsData: { propsData: {
...props, ...props,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment