Commit 8969affd authored by 🕺 Winnie 🕺's avatar 🕺 Winnie 🕺 Committed by Natalia Tepluhina

Use global Vue instance in Jest (vue_shared)

parent c60c6ed3
import { createLocalVue, shallowMount } from '@vue/test-utils';
import { nextTick } from 'vue';
import { shallowMount } from '@vue/test-utils';
import Vue, { nextTick } from 'vue';
import VueApollo from 'vue-apollo';
import getIncidentStateQuery from 'ee/graphql_shared/queries/get_incident_state.query.graphql';
import ServiceLevelAgreementCell from 'ee/vue_shared/components/incidents/service_level_agreement.vue';
import createMockApollo from 'helpers/mock_apollo_helper';
import { calculateRemainingMilliseconds, formatTime } from '~/lib/utils/datetime_utility';
const localVue = createLocalVue();
const formatTimeActual = jest.requireActual('~/lib/utils/datetime_utility').formatTime;
jest.mock('~/lib/utils/datetime_utility', () => ({
......@@ -39,7 +37,7 @@ describe('Service Level Agreement', () => {
};
function createMockApolloProvider(issueState) {
localVue.use(VueApollo);
Vue.use(VueApollo);
const requestHandlers = [
[getIncidentStateQuery, jest.fn().mockResolvedValue(issueStateResponse(issueState))],
......@@ -50,7 +48,6 @@ describe('Service Level Agreement', () => {
function mountComponent({ mockApollo, props } = {}) {
wrapper = shallowMount(ServiceLevelAgreementCell, {
localVue,
apolloProvider: mockApollo,
propsData: {
...props,
......
import { GlModal, 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 Component from 'ee/vue_shared/license_compliance/components/delete_confirmation_modal.vue';
import { approvedLicense } from '../mock_data';
const localVue = createLocalVue();
localVue.use(Vuex);
Vue.use(Vuex);
describe('DeleteConfirmationModal', () => {
let store;
......@@ -36,7 +36,6 @@ describe('DeleteConfirmationModal', () => {
store = createStore(initialState);
wrapper = shallowMount(Component, {
localVue,
store,
stubs: {
GlModal,
......
import { shallowMount, createLocalVue } from '@vue/test-utils';
import { shallowMount } from '@vue/test-utils';
import Vue from 'vue';
import Vuex from 'vuex';
import LicenseManagement from 'ee/vue_shared/license_compliance/mr_widget_license_report.vue';
import { stubComponent } from 'helpers/stub_component';
......@@ -13,8 +14,7 @@ import {
generateReportGroup,
} from './mock_data';
const localVue = createLocalVue();
localVue.use(Vuex);
Vue.use(Vuex);
describe('License Report MR Widget', () => {
const apiUrl = `${TEST_HOST}/license_management`;
......@@ -82,7 +82,6 @@ describe('License Report MR Widget', () => {
},
});
wrapper = shallowMount(LicenseManagement, {
localVue,
propsData: props,
store,
stubs,
......
import { mount, createLocalVue } from '@vue/test-utils';
import { mount } from '@vue/test-utils';
import Vue from 'vue';
import Vuex from 'vuex';
import MetricsReportsIssueBody from 'ee/vue_shared/metrics_reports/components/metrics_reports_issue_body.vue';
import GroupedMetricsReportsApp from 'ee/vue_shared/metrics_reports/grouped_metrics_reports_app.vue';
......@@ -7,8 +8,7 @@ import Api from '~/api';
jest.mock('~/api.js');
const localVue = createLocalVue();
localVue.use(Vuex);
Vue.use(Vuex);
describe('Grouped metrics reports app', () => {
let wrapper;
......@@ -19,7 +19,6 @@ describe('Grouped metrics reports app', () => {
const mountComponent = (glFeatures = {}) => {
wrapper = mount(GroupedMetricsReportsApp, {
store: mockStore,
localVue,
propsData: {
endpoint: 'metrics.json',
},
......
import { createLocalVue } from '@vue/test-utils';
import { merge } from 'lodash';
import Vue from 'vue';
import VueApollo from 'vue-apollo';
import {
mockParsedNamespaces,
......@@ -14,8 +14,7 @@ import { createMockApolloProvider } from 'ee_jest/vue_shared/purchase_flow/spec_
import Zuora from 'ee/vue_shared/purchase_flow/components/checkout/zuora.vue';
import { mountExtended } from 'helpers/vue_test_utils_helper';
const localVue = createLocalVue();
localVue.use(VueApollo);
Vue.use(VueApollo);
describe('Payment Method', () => {
let wrapper;
......@@ -36,7 +35,6 @@ describe('Payment Method', () => {
});
return mountExtended(PaymentMethod, {
localVue,
apolloProvider,
});
};
......
import { GlLoadingIcon } from '@gitlab/ui';
import { shallowMount, createLocalVue } from '@vue/test-utils';
import { shallowMount } from '@vue/test-utils';
import AxiosMockAdapter from 'axios-mock-adapter';
import { merge } from 'lodash';
import Vue from 'vue';
import VueApollo from 'vue-apollo';
import { resolvers } from 'ee/subscriptions/buy_addons_shared/graphql/resolvers';
import { STEPS } from 'ee/subscriptions/constants';
......@@ -12,8 +13,7 @@ import { createMockApolloProvider } from 'ee_jest/vue_shared/purchase_flow/spec_
import axios from '~/lib/utils/axios_utils';
import flushPromises from 'helpers/flush_promises';
const localVue = createLocalVue();
localVue.use(VueApollo);
Vue.use(VueApollo);
describe('Zuora', () => {
let axiosMock;
......@@ -36,7 +36,6 @@ describe('Zuora', () => {
data() {
return { ...data };
},
localVue,
});
};
......
import { GlButton, GlFormGroup } from '@gitlab/ui';
import { shallowMount, createLocalVue } from '@vue/test-utils';
import { shallowMount } from '@vue/test-utils';
import Vue from 'vue';
import VueApollo from 'vue-apollo';
import Step from 'ee/vue_shared/purchase_flow/components/step.vue';
import StepSummary from 'ee/vue_shared/purchase_flow/components/step_summary.vue';
......@@ -10,8 +11,7 @@ import flash from '~/flash';
import { STEPS } from '../mock_data';
import { createMockApolloProvider } from '../spec_helper';
const localVue = createLocalVue();
localVue.use(VueApollo);
Vue.use(VueApollo);
jest.mock('~/flash');
......@@ -34,7 +34,6 @@ describe('Step', () => {
function createComponent(options = {}) {
const { apolloProvider, propsData } = options;
return shallowMount(Step, {
localVue,
propsData: { ...initialProps, ...propsData },
apolloProvider,
stubs: {
......
import { GlButton } from '@gitlab/ui';
import { createLocalVue, mount } from '@vue/test-utils';
import { mount } from '@vue/test-utils';
import Vue from 'vue';
import VueApollo from 'vue-apollo';
import Component, { i18n } from 'ee/vue_shared/security_reports/components/create_jira_issue.vue';
import vulnerabilityExternalIssueLinkCreate from 'ee/vue_shared/security_reports/graphql/vulnerabilityExternalIssueLinkCreate.mutation.graphql';
......@@ -7,8 +8,6 @@ import createMockApollo from 'helpers/mock_apollo_helper';
import waitForPromises from 'helpers/wait_for_promises';
import { vulnerabilityExternalIssueLinkCreateMockFactory } from './apollo_mocks';
const localVue = createLocalVue();
describe('create_jira_issue', () => {
let wrapper;
......@@ -34,7 +33,7 @@ describe('create_jira_issue', () => {
const pendingHandler = jest.fn().mockReturnValue(new Promise(() => {}));
function createMockApolloProvider(handler) {
localVue.use(VueApollo);
Vue.use(VueApollo);
const requestHandlers = [[vulnerabilityExternalIssueLinkCreate, handler]];
return createMockApollo(requestHandlers);
......@@ -42,7 +41,6 @@ describe('create_jira_issue', () => {
const createComponent = (options = {}) => {
wrapper = mount(Component, {
localVue,
apolloProvider: options.mockApollo,
propsData: {
...defaultProps,
......
import { createLocalVue } from '@vue/test-utils';
import Vue from 'vue';
import Vuex from 'vuex';
import { createMockDirective, getBinding } from 'helpers/vue_mock_directive';
import { shallowMountExtended } from 'helpers/vue_test_utils_helper';
......@@ -9,8 +9,7 @@ import IssuableHeaderWarnings from '~/issuable/components/issuable_header_warnin
const ISSUABLE_TYPE_ISSUE = 'issue';
const ISSUABLE_TYPE_MR = 'merge request';
const localVue = createLocalVue();
localVue.use(Vuex);
Vue.use(Vuex);
describe('IssuableHeaderWarnings', () => {
let wrapper;
......@@ -24,7 +23,6 @@ describe('IssuableHeaderWarnings', () => {
const createComponent = ({ store, provide }) => {
wrapper = shallowMountExtended(IssuableHeaderWarnings, {
store,
localVue,
provide,
directives: {
GlTooltip: createMockDirective(),
......
import { createLocalVue, shallowMount, mount } from '@vue/test-utils';
import { shallowMount, mount } from '@vue/test-utils';
import Vue from 'vue';
import Vuex from 'vuex';
import {
TRANSITION_LOAD_START,
......@@ -11,15 +12,13 @@ import {
} from '~/diffs/constants';
import Renamed from '~/vue_shared/components/diff_viewer/viewers/renamed.vue';
const localVue = createLocalVue();
localVue.use(Vuex);
Vue.use(Vuex);
function createRenamedComponent({ props = {}, store = new Vuex.Store({}), deep = false }) {
const mnt = deep ? mount : shallowMount;
return mnt(Renamed, {
propsData: { ...props },
localVue,
store,
});
}
......
import { 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 { BV_SHOW_MODAL, BV_HIDE_MODAL } from '~/lib/utils/constants';
import GlModalVuex from '~/vue_shared/components/gl_modal_vuex.vue';
import createState from '~/vuex_shared/modules/modal/state';
const localVue = createLocalVue();
localVue.use(Vuex);
Vue.use(Vuex);
const TEST_SLOT = 'Lorem ipsum modal dolar sit.';
const TEST_MODAL_ID = 'my-modal-id';
......@@ -36,7 +36,6 @@ describe('GlModalVuex', () => {
wrapper = shallowMount(GlModalVuex, {
...options,
localVue,
store,
propsData,
stubs: {
......
import { shallowMount, createLocalVue } from '@vue/test-utils';
import { shallowMount } from '@vue/test-utils';
import Vue from 'vue';
import Vuex from 'vuex';
import IssuePlaceholderNote from '~/vue_shared/components/notes/placeholder_note.vue';
import { userDataMock } from '../../../notes/mock_data';
const localVue = createLocalVue();
localVue.use(Vuex);
Vue.use(Vuex);
const getters = {
getUserData: () => userDataMock,
......@@ -17,7 +17,6 @@ describe('Issue placeholder note component', () => {
const createComponent = (isIndividual = false) => {
wrapper = shallowMount(IssuePlaceholderNote, {
localVue,
store: new Vuex.Store({
getters,
}),
......
import { shallowMount, createLocalVue } from '@vue/test-utils';
import { shallowMount } from '@vue/test-utils';
import Vue from 'vue';
import mockProjects from 'test_fixtures_static/projects.json';
import { trimText } from 'helpers/text_helper';
import ProjectAvatar from '~/vue_shared/components/deprecated_project_avatar/default.vue';
import ProjectListItem from '~/vue_shared/components/project_selector/project_list_item.vue';
const localVue = createLocalVue();
describe('ProjectListItem component', () => {
const Component = localVue.extend(ProjectListItem);
const Component = Vue.extend(ProjectListItem);
let wrapper;
let vm;
let options;
......@@ -20,7 +19,6 @@ describe('ProjectListItem component', () => {
project,
selected: false,
},
localVue,
};
});
......
import { GlSearchBoxByType, GlInfiniteScroll } from '@gitlab/ui';
import { mount, createLocalVue } from '@vue/test-utils';
import { mount } from '@vue/test-utils';
import { head } from 'lodash';
import Vue from 'vue';
import mockProjects from 'test_fixtures_static/projects.json';
......@@ -7,8 +7,6 @@ import { trimText } from 'helpers/text_helper';
import ProjectListItem from '~/vue_shared/components/project_selector/project_list_item.vue';
import ProjectSelector from '~/vue_shared/components/project_selector/project_selector.vue';
const localVue = createLocalVue();
describe('ProjectSelector component', () => {
let wrapper;
let vm;
......@@ -28,7 +26,6 @@ describe('ProjectSelector component', () => {
beforeEach(() => {
wrapper = mount(Vue.extend(ProjectSelector), {
localVue,
propsData: {
projectSearchResults: searchResults,
selectedProjects: selected,
......
import { GlAlert, GlModal, GlButton, GlLoadingIcon, GlSkeletonLoader } from '@gitlab/ui';
import { GlBreakpointInstance as bp } from '@gitlab/ui/dist/utils';
import { shallowMount, createLocalVue } from '@vue/test-utils';
import { nextTick } from 'vue';
import { shallowMount } from '@vue/test-utils';
import Vue, { nextTick } from 'vue';
import VueApollo from 'vue-apollo';
import createMockApollo from 'helpers/mock_apollo_helper';
import { extendedWrapper } from 'helpers/vue_test_utils_helper';
......@@ -16,8 +16,7 @@ import {
mockGraphqlInstructionsWindows,
} from './mock_data';
const localVue = createLocalVue();
localVue.use(VueApollo);
Vue.use(VueApollo);
let resizeCallback;
const MockResizeObserver = {
......@@ -33,7 +32,7 @@ const MockResizeObserver = {
},
};
localVue.directive('gl-resize-observer', MockResizeObserver);
Vue.directive('gl-resize-observer', MockResizeObserver);
jest.mock('@gitlab/ui/dist/utils');
......@@ -67,7 +66,6 @@ describe('RunnerInstructionsModal component', () => {
registrationToken: 'MY_TOKEN',
...props,
},
localVue,
apolloProvider: fakeApollo,
...options,
}),
......
import { GlIcon, GlButton } 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 DropdownButton from '~/vue_shared/components/sidebar/labels_select_vue/dropdown_button.vue';
......@@ -9,8 +10,7 @@ import labelSelectModule from '~/vue_shared/components/sidebar/labels_select_vue
import { mockConfig } from './mock_data';
let store;
const localVue = createLocalVue();
localVue.use(Vuex);
Vue.use(Vuex);
const createComponent = (initialState = mockConfig) => {
store = new Vuex.Store(labelSelectModule());
......@@ -18,7 +18,6 @@ const createComponent = (initialState = mockConfig) => {
store.dispatch('setInitialState', initialState);
return shallowMount(DropdownButton, {
localVue,
store,
});
};
......
import { GlButton, GlFormInput, GlLink, GlLoadingIcon } 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 DropdownContentsCreateView from '~/vue_shared/components/sidebar/labels_select_vue/dropdown_contents_create_view.vue';
......@@ -8,8 +9,7 @@ import labelSelectModule from '~/vue_shared/components/sidebar/labels_select_vue
import { mockConfig, mockSuggestedColors } from './mock_data';
const localVue = createLocalVue();
localVue.use(Vuex);
Vue.use(Vuex);
const createComponent = (initialState = mockConfig) => {
const store = new Vuex.Store(labelSelectModule());
......@@ -17,7 +17,6 @@ const createComponent = (initialState = mockConfig) => {
store.dispatch('setInitialState', initialState);
return shallowMount(DropdownContentsCreateView, {
localVue,
store,
});
};
......
......@@ -5,7 +5,8 @@ import {
GlSearchBoxByType,
GlLink,
} 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 { UP_KEY_CODE, DOWN_KEY_CODE, ENTER_KEY_CODE, ESC_KEY_CODE } from '~/lib/utils/keycodes';
import DropdownContentsLabelsView from '~/vue_shared/components/sidebar/labels_select_vue/dropdown_contents_labels_view.vue';
......@@ -18,8 +19,7 @@ import defaultState from '~/vue_shared/components/sidebar/labels_select_vue/stor
import { mockConfig, mockLabels, mockRegularLabel } from './mock_data';
const localVue = createLocalVue();
localVue.use(Vuex);
Vue.use(Vuex);
describe('DropdownContentsLabelsView', () => {
let wrapper;
......@@ -43,7 +43,6 @@ describe('DropdownContentsLabelsView', () => {
store.dispatch('receiveLabelsSuccess', mockLabels);
wrapper = shallowMount(DropdownContentsLabelsView, {
localVue,
store,
});
};
......
import { shallowMount, createLocalVue } from '@vue/test-utils';
import { shallowMount } from '@vue/test-utils';
import Vue from 'vue';
import Vuex from 'vuex';
import { DropdownVariant } from '~/vue_shared/components/sidebar/labels_select_vue/constants';
......@@ -7,8 +8,7 @@ import labelsSelectModule from '~/vue_shared/components/sidebar/labels_select_vu
import { mockConfig } from './mock_data';
const localVue = createLocalVue();
localVue.use(Vuex);
Vue.use(Vuex);
const createComponent = (initialState = mockConfig, propsData = {}) => {
const store = new Vuex.Store(labelsSelectModule());
......@@ -17,7 +17,6 @@ const createComponent = (initialState = mockConfig, propsData = {}) => {
return shallowMount(DropdownContents, {
propsData,
localVue,
store,
});
};
......
import { GlButton, GlLoadingIcon } 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 DropdownTitle from '~/vue_shared/components/sidebar/labels_select_vue/dropdown_title.vue';
......@@ -8,8 +9,7 @@ import labelsSelectModule from '~/vue_shared/components/sidebar/labels_select_vu
import { mockConfig } from './mock_data';
const localVue = createLocalVue();
localVue.use(Vuex);
Vue.use(Vuex);
const createComponent = (initialState = mockConfig) => {
const store = new Vuex.Store(labelsSelectModule());
......@@ -17,7 +17,6 @@ const createComponent = (initialState = mockConfig) => {
store.dispatch('setInitialState', initialState);
return shallowMount(DropdownTitle, {
localVue,
store,
propsData: {
labelsSelectInProgress: false,
......
import { GlLabel } 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 DropdownValue from '~/vue_shared/components/sidebar/labels_select_vue/dropdown_value.vue';
......@@ -8,8 +9,7 @@ import labelsSelectModule from '~/vue_shared/components/sidebar/labels_select_vu
import { mockConfig, mockLabels, mockRegularLabel, mockScopedLabel } from './mock_data';
const localVue = createLocalVue();
localVue.use(Vuex);
Vue.use(Vuex);
describe('DropdownValue', () => {
let wrapper;
......@@ -23,7 +23,6 @@ describe('DropdownValue', () => {
store.dispatch('setInitialState', { ...mockConfig, ...initialState });
wrapper = shallowMount(DropdownValue, {
localVue,
store,
slots,
});
......
import { shallowMount, createLocalVue } from '@vue/test-utils';
import { shallowMount } from '@vue/test-utils';
import Vue from 'vue';
import Vuex from 'vuex';
import { isInViewport } from '~/lib/utils/common_utils';
......@@ -18,8 +19,7 @@ jest.mock('~/lib/utils/common_utils', () => ({
isInViewport: jest.fn().mockReturnValue(true),
}));
const localVue = createLocalVue();
localVue.use(Vuex);
Vue.use(Vuex);
describe('LabelsSelectRoot', () => {
let wrapper;
......@@ -27,7 +27,6 @@ describe('LabelsSelectRoot', () => {
const createComponent = (config = mockConfig, slots = {}) => {
wrapper = shallowMount(LabelsSelectRoot, {
localVue,
slots,
store,
propsData: config,
......
import { GlLoadingIcon, GlLink } from '@gitlab/ui';
import { shallowMount, createLocalVue } from '@vue/test-utils';
import { nextTick } from 'vue';
import { shallowMount } from '@vue/test-utils';
import Vue, { nextTick } from 'vue';
import VueApollo from 'vue-apollo';
import createMockApollo from 'helpers/mock_apollo_helper';
import waitForPromises from 'helpers/wait_for_promises';
......@@ -18,8 +18,7 @@ jest.mock('~/flash');
const colors = Object.keys(mockSuggestedColors);
const localVue = createLocalVue();
localVue.use(VueApollo);
Vue.use(VueApollo);
const userRecoverableError = {
...createLabelSuccessfulResponse,
......@@ -63,7 +62,6 @@ describe('DropdownContentsCreateView', () => {
});
wrapper = shallowMount(DropdownContentsCreateView, {
localVue,
apolloProvider: mockApollo,
propsData: {
fullPath: '',
......
......@@ -4,8 +4,8 @@ import {
GlDropdownItem,
GlIntersectionObserver,
} from '@gitlab/ui';
import { shallowMount, createLocalVue } from '@vue/test-utils';
import { nextTick } from 'vue';
import { shallowMount } from '@vue/test-utils';
import Vue, { nextTick } from 'vue';
import VueApollo from 'vue-apollo';
import createMockApollo from 'helpers/mock_apollo_helper';
import waitForPromises from 'helpers/wait_for_promises';
......@@ -19,8 +19,7 @@ import { mockConfig, workspaceLabelsQueryResponse } from './mock_data';
jest.mock('~/flash');
const localVue = createLocalVue();
localVue.use(VueApollo);
Vue.use(VueApollo);
const localSelectedLabels = [
{
......@@ -47,7 +46,6 @@ describe('DropdownContentsLabelsView', () => {
const mockApollo = createMockApollo([[projectLabelsQuery, queryHandler]]);
wrapper = shallowMount(DropdownContentsLabelsView, {
localVue,
apolloProvider: mockApollo,
provide: {
variant: DropdownVariant.Sidebar,
......
import { GlSearchBoxByType, GlDropdown } from '@gitlab/ui';
import { shallowMount, createLocalVue } from '@vue/test-utils';
import { shallowMount } from '@vue/test-utils';
import { cloneDeep } from 'lodash';
import { nextTick } from 'vue';
import Vue, { nextTick } from 'vue';
import VueApollo from 'vue-apollo';
import createMockApollo from 'helpers/mock_apollo_helper';
import waitForPromises from 'helpers/wait_for_promises';
......@@ -33,8 +33,7 @@ const waitForSearch = async () => {
await waitForPromises();
};
const localVue = createLocalVue();
localVue.use(VueApollo);
Vue.use(VueApollo);
describe('User select dropdown', () => {
let wrapper;
......@@ -62,7 +61,6 @@ describe('User select dropdown', () => {
[getIssueParticipantsQuery, participantsQueryHandler],
]);
wrapper = shallowMount(UserSelect, {
localVue,
apolloProvider: fakeApollo,
propsData: {
headerText: 'test',
......
import { mount, createLocalVue } from '@vue/test-utils';
import { mount } from '@vue/test-utils';
import Vue from 'vue';
import VueApollo from 'vue-apollo';
import VuexModuleProvider from '~/vue_shared/components/vuex_module_provider.vue';
......@@ -38,10 +38,9 @@ describe('~/vue_shared/components/vuex_module_provider', () => {
it('does not blow up when used with vue-apollo', () => {
// See https://github.com/vuejs/vue-apollo/pull/1153 for details
const localVue = createLocalVue();
localVue.use(VueApollo);
Vue.use(VueApollo);
createComponent({ localVue });
createComponent();
expect(findProvidedVuexModule()).toBe(TEST_VUEX_MODULE);
});
});
import { createLocalVue, shallowMount } from '@vue/test-utils';
import { shallowMount } from '@vue/test-utils';
import Vue from 'vue';
import GlFeatureFlags from '~/vue_shared/gl_feature_flags_plugin';
import glFeatureFlagsMixin from '~/vue_shared/mixins/gl_feature_flags_mixin';
const localVue = createLocalVue();
describe('GitLab Feature Flags Plugin', () => {
beforeEach(() => {
window.gon = {
......@@ -17,7 +16,7 @@ describe('GitLab Feature Flags Plugin', () => {
},
};
localVue.use(GlFeatureFlags);
Vue.use(GlFeatureFlags);
});
it('should provide glFeatures to components', () => {
......@@ -25,7 +24,7 @@ describe('GitLab Feature Flags Plugin', () => {
template: `<span></span>`,
inject: ['glFeatures'],
};
const wrapper = shallowMount(component, { localVue });
const wrapper = shallowMount(component);
expect(wrapper.vm.glFeatures).toEqual({
aFeature: true,
bFeature: false,
......@@ -39,7 +38,7 @@ describe('GitLab Feature Flags Plugin', () => {
template: `<span></span>`,
mixins: [glFeatureFlagsMixin()],
};
const wrapper = shallowMount(component, { localVue });
const wrapper = shallowMount(component);
expect(wrapper.vm.glFeatures).toEqual({
aFeature: true,
bFeature: false,
......
import { mount, createLocalVue } from '@vue/test-utils';
import { mount } from '@vue/test-utils';
import Vue from 'vue';
import locale from '~/locale';
import Translate from '~/vue_shared/translate';
const localVue = createLocalVue();
localVue.use(Translate);
Vue.use(Translate);
describe('Vue translate filter', () => {
const createTranslationMock = (key, ...translations) => {
......@@ -26,16 +26,13 @@ describe('Vue translate filter', () => {
const translation = 'singular_translated';
createTranslationMock(key, translation);
const wrapper = mount(
{
const wrapper = mount({
template: `
<span>
{{ __('${key}') }}
</span>
`,
},
{ localVue },
);
});
expect(wrapper.text()).toBe(translation);
});
......@@ -45,16 +42,13 @@ describe('Vue translate filter', () => {
const translationPlural = 'plural_multiple translation';
createTranslationMock(key, 'plural_singular translation', translationPlural);
const wrapper = mount(
{
const wrapper = mount({
template: `
<span>
{{ n__('${key}', 'plurals', 2) }}
</span>
`,
},
{ localVue },
);
});
expect(wrapper.text()).toBe(translationPlural);
});
......@@ -67,31 +61,25 @@ describe('Vue translate filter', () => {
});
it('and n === 1', () => {
const wrapper = mount(
{
const wrapper = mount({
template: `
<span>
{{ n__('${key}', '%d days', 1) }}
</span>
`,
},
{ localVue },
);
});
expect(wrapper.text()).toBe('1 singular translated');
});
it('and n > 1', () => {
const wrapper = mount(
{
const wrapper = mount({
template: `
<span>
{{ n__('${key}', '%d days', 2) }}
</span>
`,
},
{ localVue },
);
});
expect(wrapper.text()).toBe('2 plural translated');
});
......@@ -107,31 +95,25 @@ describe('Vue translate filter', () => {
});
it('and using two parameters', () => {
const wrapper = mount(
{
const wrapper = mount({
template: `
<span>
{{ s__('Context', 'Foobar') }}
</span>
`,
},
{ localVue },
);
});
expect(wrapper.text()).toBe(expectation);
});
it('and using the pipe syntax', () => {
const wrapper = mount(
{
const wrapper = mount({
template: `
<span>
{{ s__('${key}') }}
</span>
`,
},
{ localVue },
);
});
expect(wrapper.text()).toBe(expectation);
});
......@@ -141,8 +123,7 @@ describe('Vue translate filter', () => {
const translation = 'multiline string translated';
createTranslationMock('multiline string', translation);
const wrapper = mount(
{
const wrapper = mount({
template: `
<span>
{{ __(\`
......@@ -151,9 +132,7 @@ describe('Vue translate filter', () => {
\`) }}
</span>
`,
},
{ localVue },
);
});
expect(wrapper.text()).toBe(translation);
});
......@@ -163,8 +142,7 @@ describe('Vue translate filter', () => {
createTranslationMock('multiline string', 'multiline string singular', translation);
const wrapper = mount(
{
const wrapper = mount({
template: `
<span>
{{ n__(
......@@ -180,9 +158,7 @@ describe('Vue translate filter', () => {
) }}
</span>
`,
},
{ localVue },
);
});
expect(wrapper.text()).toBe(translation);
});
......@@ -192,8 +168,7 @@ describe('Vue translate filter', () => {
createTranslationMock('Context| multiline string', translation);
const wrapper = mount(
{
const wrapper = mount({
template: `
<span>
{{ s__(
......@@ -205,9 +180,7 @@ describe('Vue translate filter', () => {
) }}
</span>
`,
},
{ localVue },
);
});
expect(wrapper.text()).toBe(translation);
});
......
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