Commit e8416fb8 authored by Nathan Friend's avatar Nathan Friend

Merge branch...

Merge branch 'migrate_ee_spec_javascripts_vue_mr_widget_components_mr_widget_pipeline_container_spec_js' into 'master'

Migrate ee mr_widget_pipeline_container_spec to Jest

See merge request gitlab-org/gitlab!27120
parents 0321fd7f 29e0f3bc
import { mount, createLocalVue } from '@vue/test-utils'; import { mount, shallowMount } from '@vue/test-utils';
import MergeTrainPositionIndicator from 'ee/vue_merge_request_widget/components/merge_train_position_indicator.vue'; import MergeTrainPositionIndicator from 'ee/vue_merge_request_widget/components/merge_train_position_indicator.vue';
import VisualReviewAppLink from 'ee/vue_merge_request_widget/components/visual_review_app_link.vue'; import VisualReviewAppLink from 'ee/vue_merge_request_widget/components/visual_review_app_link.vue';
import { mockStore } from 'spec/vue_mr_widget/mock_data'; import { mockStore } from 'jest/vue_mr_widget/mock_data';
import MrWidgetPipelineContainer from '~/vue_merge_request_widget/components/mr_widget_pipeline_container.vue'; import MrWidgetPipelineContainer from '~/vue_merge_request_widget/components/mr_widget_pipeline_container.vue';
import { MT_MERGE_STRATEGY, MWPS_MERGE_STRATEGY } from '~/vue_merge_request_widget/constants'; import { MT_MERGE_STRATEGY, MWPS_MERGE_STRATEGY } from '~/vue_merge_request_widget/constants';
import MockAdapter from 'axios-mock-adapter';
import axios from '~/lib/utils/axios_utils';
describe('MrWidgetPipelineContainer', () => { describe('MrWidgetPipelineContainer', () => {
let wrapper; let wrapper;
let mock;
const factory = (mrUpdates = {}, provide = {}) => { beforeEach(() => {
const localVue = createLocalVue(); mock = new MockAdapter(axios);
mock.onGet().reply(200, {});
});
wrapper = mount(localVue.extend(MrWidgetPipelineContainer), { const factory = (method = shallowMount, mrUpdates = {}, provide = {}) => {
wrapper = method.call(this, MrWidgetPipelineContainer, {
propsData: { propsData: {
mr: Object.assign({}, mockStore, mrUpdates), mr: Object.assign({}, mockStore, mrUpdates),
}, },
provide: { provide: {
...provide, ...provide,
}, },
localVue,
attachToDocument: true, attachToDocument: true,
}); });
}; };
afterEach(() => { afterEach(() => {
mock.restore();
wrapper.destroy(); wrapper.destroy();
wrapper = null;
}); });
describe('merge train indicator', () => { describe('merge train indicator', () => {
it('should render the merge train indicator if the MR is open and is on the merge train', () => { it('should render the merge train indicator if the MR is open and is on the merge train', () => {
factory({ factory(shallowMount, {
isOpen: true, isOpen: true,
autoMergeStrategy: MT_MERGE_STRATEGY, autoMergeStrategy: MT_MERGE_STRATEGY,
}); });
...@@ -38,7 +45,7 @@ describe('MrWidgetPipelineContainer', () => { ...@@ -38,7 +45,7 @@ describe('MrWidgetPipelineContainer', () => {
}); });
it('should not render the merge train indicator if the MR is closed', () => { it('should not render the merge train indicator if the MR is closed', () => {
factory({ factory(shallowMount, {
isOpen: false, isOpen: false,
autoMergeStrategy: MT_MERGE_STRATEGY, autoMergeStrategy: MT_MERGE_STRATEGY,
}); });
...@@ -47,7 +54,7 @@ describe('MrWidgetPipelineContainer', () => { ...@@ -47,7 +54,7 @@ describe('MrWidgetPipelineContainer', () => {
}); });
it('should not render the merge train indicator if the MR is not on the merge train', () => { it('should not render the merge train indicator if the MR is not on the merge train', () => {
factory({ factory(shallowMount, {
isOpen: true, isOpen: true,
autoMergeStrategy: MWPS_MERGE_STRATEGY, autoMergeStrategy: MWPS_MERGE_STRATEGY,
}); });
...@@ -59,6 +66,7 @@ describe('MrWidgetPipelineContainer', () => { ...@@ -59,6 +66,7 @@ describe('MrWidgetPipelineContainer', () => {
describe('with anonymous visual review feedback feature flag enabled', () => { describe('with anonymous visual review feedback feature flag enabled', () => {
beforeEach(() => { beforeEach(() => {
factory( factory(
mount,
{ {
visualReviewAppAvailable: true, visualReviewAppAvailable: true,
appUrl: 'http://gitlab.example.com', appUrl: 'http://gitlab.example.com',
...@@ -95,6 +103,7 @@ describe('MrWidgetPipelineContainer', () => { ...@@ -95,6 +103,7 @@ describe('MrWidgetPipelineContainer', () => {
describe('with anonymous visual review feedback feature flag disabled', () => { describe('with anonymous visual review feedback feature flag disabled', () => {
beforeEach(() => { beforeEach(() => {
factory( factory(
mount,
{ {
visualReviewAppAvailable: true, visualReviewAppAvailable: true,
appUrl: 'http://gitlab.example.com', appUrl: 'http://gitlab.example.com',
......
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