Commit 213d5094 authored by Kushal Pandya's avatar Kushal Pandya

Merge branch '121617-frontend-move-epic-tests-to-jest' into 'master'

Move epic tests to jest

See merge request gitlab-org/gitlab!24268
parents 1ecb99f9 697c88de
...@@ -4,8 +4,8 @@ import MockAdapter from 'axios-mock-adapter'; ...@@ -4,8 +4,8 @@ import MockAdapter from 'axios-mock-adapter';
import EpicApp from 'ee/epic/components/epic_app.vue'; import EpicApp from 'ee/epic/components/epic_app.vue';
import createStore from 'ee/epic/store'; import createStore from 'ee/epic/store';
import { mountComponentWithStore } from 'spec/helpers/vue_mount_component_helper'; import { mountComponentWithStore } from 'helpers/vue_mount_component_helper';
import issueShowData from 'spec/issue_show/mock_data'; import { initialRequest } from 'jest/issue_show/mock_data';
import { TEST_HOST } from 'spec/test_constants'; import { TEST_HOST } from 'spec/test_constants';
import axios from '~/lib/utils/axios_utils'; import axios from '~/lib/utils/axios_utils';
import { mockEpicMeta, mockEpicData } from '../mock_data'; import { mockEpicMeta, mockEpicData } from '../mock_data';
...@@ -14,9 +14,9 @@ describe('EpicAppComponent', () => { ...@@ -14,9 +14,9 @@ describe('EpicAppComponent', () => {
let vm; let vm;
let mock; let mock;
beforeEach(done => { beforeEach(() => {
mock = new MockAdapter(axios); mock = new MockAdapter(axios);
mock.onGet(`${TEST_HOST}/realtime_changes`).reply(200, issueShowData.initialRequest); mock.onGet(`${TEST_HOST}/realtime_changes`).reply(200, initialRequest);
const Component = Vue.extend(EpicApp); const Component = Vue.extend(EpicApp);
const store = createStore(); const store = createStore();
...@@ -26,8 +26,6 @@ describe('EpicAppComponent', () => { ...@@ -26,8 +26,6 @@ describe('EpicAppComponent', () => {
vm = mountComponentWithStore(Component, { vm = mountComponentWithStore(Component, {
store, store,
}); });
setTimeout(done);
}); });
afterEach(() => { afterEach(() => {
......
...@@ -4,8 +4,8 @@ import MockAdapter from 'axios-mock-adapter'; ...@@ -4,8 +4,8 @@ import MockAdapter from 'axios-mock-adapter';
import EpicBody from 'ee/epic/components/epic_body.vue'; import EpicBody from 'ee/epic/components/epic_body.vue';
import createStore from 'ee/epic/store'; import createStore from 'ee/epic/store';
import { mountComponentWithStore } from 'spec/helpers/vue_mount_component_helper'; import { mountComponentWithStore } from 'helpers/vue_mount_component_helper';
import issueShowData from 'spec/issue_show/mock_data'; import { initialRequest } from 'jest/issue_show/mock_data';
import { TEST_HOST } from 'spec/test_constants'; import { TEST_HOST } from 'spec/test_constants';
import axios from '~/lib/utils/axios_utils'; import axios from '~/lib/utils/axios_utils';
import { mockEpicMeta, mockEpicData } from '../mock_data'; import { mockEpicMeta, mockEpicData } from '../mock_data';
...@@ -14,9 +14,9 @@ describe('EpicBodyComponent', () => { ...@@ -14,9 +14,9 @@ describe('EpicBodyComponent', () => {
let vm; let vm;
let mock; let mock;
beforeEach(done => { beforeEach(() => {
mock = new MockAdapter(axios); mock = new MockAdapter(axios);
mock.onGet(`${TEST_HOST}/realtime_changes`).reply(200, issueShowData.initialRequest); mock.onGet(`${TEST_HOST}/realtime_changes`).reply(200, initialRequest);
const Component = Vue.extend(EpicBody); const Component = Vue.extend(EpicBody);
const store = createStore(); const store = createStore();
...@@ -26,8 +26,6 @@ describe('EpicBodyComponent', () => { ...@@ -26,8 +26,6 @@ describe('EpicBodyComponent', () => {
vm = mountComponentWithStore(Component, { vm = mountComponentWithStore(Component, {
store, store,
}); });
setTimeout(done);
}); });
afterEach(() => { afterEach(() => {
......
...@@ -3,14 +3,14 @@ import Vue from 'vue'; ...@@ -3,14 +3,14 @@ import Vue from 'vue';
import EpicCreate from 'ee/epic/components/epic_create.vue'; import EpicCreate from 'ee/epic/components/epic_create.vue';
import createStore from 'ee/epic/store'; import createStore from 'ee/epic/store';
import { mountComponentWithStore } from 'spec/helpers/vue_mount_component_helper'; import { mountComponentWithStore } from 'helpers/vue_mount_component_helper';
import { mockEpicMeta } from '../mock_data'; import { mockEpicMeta } from '../mock_data';
describe('EpicCreateComponent', () => { describe('EpicCreateComponent', () => {
let vm; let vm;
let store; let store;
beforeEach(done => { beforeEach(() => {
const Component = Vue.extend(EpicCreate); const Component = Vue.extend(EpicCreate);
store = createStore(); store = createStore();
...@@ -19,8 +19,6 @@ describe('EpicCreateComponent', () => { ...@@ -19,8 +19,6 @@ describe('EpicCreateComponent', () => {
vm = mountComponentWithStore(Component, { vm = mountComponentWithStore(Component, {
store, store,
}); });
setTimeout(done);
}); });
afterEach(() => { afterEach(() => {
...@@ -59,7 +57,7 @@ describe('EpicCreateComponent', () => { ...@@ -59,7 +57,7 @@ describe('EpicCreateComponent', () => {
describe('epicTitle', () => { describe('epicTitle', () => {
describe('set', () => { describe('set', () => {
it('calls `setEpicCreateTitle` with param `value`', () => { it('calls `setEpicCreateTitle` with param `value`', () => {
spyOn(vm, 'setEpicCreateTitle'); jest.spyOn(vm, 'setEpicCreateTitle');
const newEpicTitle = 'foobar'; const newEpicTitle = 'foobar';
......
...@@ -4,14 +4,14 @@ import EpicHeader from 'ee/epic/components/epic_header.vue'; ...@@ -4,14 +4,14 @@ import EpicHeader from 'ee/epic/components/epic_header.vue';
import createStore from 'ee/epic/store'; import createStore from 'ee/epic/store';
import { statusType } from 'ee/epic/constants'; import { statusType } from 'ee/epic/constants';
import { mountComponentWithStore } from 'spec/helpers/vue_mount_component_helper'; import { mountComponentWithStore } from 'helpers/vue_mount_component_helper';
import { mockEpicMeta, mockEpicData } from '../mock_data'; import { mockEpicMeta, mockEpicData } from '../mock_data';
describe('EpicHeaderComponent', () => { describe('EpicHeaderComponent', () => {
let vm; let vm;
let store; let store;
beforeEach(done => { beforeEach(() => {
const Component = Vue.extend(EpicHeader); const Component = Vue.extend(EpicHeader);
store = createStore(); store = createStore();
...@@ -21,8 +21,6 @@ describe('EpicHeaderComponent', () => { ...@@ -21,8 +21,6 @@ describe('EpicHeaderComponent', () => {
vm = mountComponentWithStore(Component, { vm = mountComponentWithStore(Component, {
store, store,
}); });
setTimeout(done);
}); });
afterEach(() => { afterEach(() => {
......
...@@ -6,7 +6,7 @@ import createStore from 'ee/epic/store'; ...@@ -6,7 +6,7 @@ import createStore from 'ee/epic/store';
import epicUtils from 'ee/epic/utils/epic_utils'; import epicUtils from 'ee/epic/utils/epic_utils';
import { dateTypes } from 'ee/epic/constants'; import { dateTypes } from 'ee/epic/constants';
import { mountComponentWithStore } from 'spec/helpers/vue_mount_component_helper'; import { mountComponentWithStore } from 'helpers/vue_mount_component_helper';
import { mockEpicMeta, mockEpicData, mockAncestors } from '../mock_data'; import { mockEpicMeta, mockEpicData, mockAncestors } from '../mock_data';
describe('EpicSidebarComponent', () => { describe('EpicSidebarComponent', () => {
...@@ -14,7 +14,7 @@ describe('EpicSidebarComponent', () => { ...@@ -14,7 +14,7 @@ describe('EpicSidebarComponent', () => {
let vm; let vm;
let store; let store;
beforeEach(done => { beforeEach(() => {
const Component = Vue.extend(EpicSidebar); const Component = Vue.extend(EpicSidebar);
store = createStore(); store = createStore();
store.dispatch('setEpicMeta', mockEpicMeta); store.dispatch('setEpicMeta', mockEpicMeta);
...@@ -24,8 +24,6 @@ describe('EpicSidebarComponent', () => { ...@@ -24,8 +24,6 @@ describe('EpicSidebarComponent', () => {
vm = mountComponentWithStore(Component, { vm = mountComponentWithStore(Component, {
store, store,
}); });
setTimeout(done);
}); });
afterEach(() => { afterEach(() => {
...@@ -35,7 +33,7 @@ describe('EpicSidebarComponent', () => { ...@@ -35,7 +33,7 @@ describe('EpicSidebarComponent', () => {
describe('methods', () => { describe('methods', () => {
describe('getDateFromMilestonesTooltip', () => { describe('getDateFromMilestonesTooltip', () => {
it('calls `epicUtils.getDateFromMilestonesTooltip` with `dateType` param', () => { it('calls `epicUtils.getDateFromMilestonesTooltip` with `dateType` param', () => {
spyOn(epicUtils, 'getDateFromMilestonesTooltip'); jest.spyOn(epicUtils, 'getDateFromMilestonesTooltip');
vm.getDateFromMilestonesTooltip(dateTypes.start); vm.getDateFromMilestonesTooltip(dateTypes.start);
...@@ -49,7 +47,7 @@ describe('EpicSidebarComponent', () => { ...@@ -49,7 +47,7 @@ describe('EpicSidebarComponent', () => {
describe('changeStartDateType', () => { describe('changeStartDateType', () => {
it('calls `toggleStartDateType` on component with `dateTypeIsFixed` param', () => { it('calls `toggleStartDateType` on component with `dateTypeIsFixed` param', () => {
spyOn(vm, 'toggleStartDateType'); jest.spyOn(vm, 'toggleStartDateType');
vm.changeStartDateType(true, true); vm.changeStartDateType(true, true);
...@@ -61,7 +59,7 @@ describe('EpicSidebarComponent', () => { ...@@ -61,7 +59,7 @@ describe('EpicSidebarComponent', () => {
}); });
it('calls `saveDate` on component when `typeChangeOnEdit` param false', () => { it('calls `saveDate` on component when `typeChangeOnEdit` param false', () => {
spyOn(vm, 'saveDate'); jest.spyOn(vm, 'saveDate');
vm.changeStartDateType(true, false); vm.changeStartDateType(true, false);
...@@ -77,7 +75,7 @@ describe('EpicSidebarComponent', () => { ...@@ -77,7 +75,7 @@ describe('EpicSidebarComponent', () => {
describe('saveStartDate', () => { describe('saveStartDate', () => {
it('calls `saveDate` on component with `date` param set to `newDate`', () => { it('calls `saveDate` on component with `date` param set to `newDate`', () => {
spyOn(vm, 'saveDate'); jest.spyOn(vm, 'saveDate');
vm.saveStartDate('2018-1-1'); vm.saveStartDate('2018-1-1');
...@@ -93,7 +91,7 @@ describe('EpicSidebarComponent', () => { ...@@ -93,7 +91,7 @@ describe('EpicSidebarComponent', () => {
describe('changeDueDateType', () => { describe('changeDueDateType', () => {
it('calls `toggleDueDateType` on component with `dateTypeIsFixed` param', () => { it('calls `toggleDueDateType` on component with `dateTypeIsFixed` param', () => {
spyOn(vm, 'toggleDueDateType'); jest.spyOn(vm, 'toggleDueDateType');
vm.changeDueDateType(true, true); vm.changeDueDateType(true, true);
...@@ -105,7 +103,7 @@ describe('EpicSidebarComponent', () => { ...@@ -105,7 +103,7 @@ describe('EpicSidebarComponent', () => {
}); });
it('calls `saveDate` on component when `typeChangeOnEdit` param false', () => { it('calls `saveDate` on component when `typeChangeOnEdit` param false', () => {
spyOn(vm, 'saveDate'); jest.spyOn(vm, 'saveDate');
vm.changeDueDateType(true, false); vm.changeDueDateType(true, false);
...@@ -121,7 +119,7 @@ describe('EpicSidebarComponent', () => { ...@@ -121,7 +119,7 @@ describe('EpicSidebarComponent', () => {
describe('saveDueDate', () => { describe('saveDueDate', () => {
it('calls `saveDate` on component with `date` param set to `newDate`', () => { it('calls `saveDate` on component with `date` param set to `newDate`', () => {
spyOn(vm, 'saveDate'); jest.spyOn(vm, 'saveDate');
vm.saveDueDate('2018-1-1'); vm.saveDueDate('2018-1-1');
......
...@@ -3,14 +3,14 @@ import Vue from 'vue'; ...@@ -3,14 +3,14 @@ import Vue from 'vue';
import SidebarHeader from 'ee/epic/components/sidebar_items/sidebar_header.vue'; import SidebarHeader from 'ee/epic/components/sidebar_items/sidebar_header.vue';
import createStore from 'ee/epic/store'; import createStore from 'ee/epic/store';
import { mountComponentWithStore } from 'spec/helpers/vue_mount_component_helper'; import { mountComponentWithStore } from 'helpers/vue_mount_component_helper';
import { mockEpicMeta, mockEpicData } from '../../mock_data'; import { mockEpicMeta, mockEpicData } from '../../mock_data';
describe('SidebarHeaderComponent', () => { describe('SidebarHeaderComponent', () => {
let vm; let vm;
let store; let store;
beforeEach(done => { beforeEach(() => {
const Component = Vue.extend(SidebarHeader); const Component = Vue.extend(SidebarHeader);
store = createStore(); store = createStore();
store.dispatch('setEpicMeta', mockEpicMeta); store.dispatch('setEpicMeta', mockEpicMeta);
...@@ -20,8 +20,6 @@ describe('SidebarHeaderComponent', () => { ...@@ -20,8 +20,6 @@ describe('SidebarHeaderComponent', () => {
store, store,
props: { sidebarCollapsed: false }, props: { sidebarCollapsed: false },
}); });
setTimeout(done);
}); });
afterEach(() => { afterEach(() => {
......
...@@ -3,14 +3,14 @@ import Vue from 'vue'; ...@@ -3,14 +3,14 @@ import Vue from 'vue';
import SidebarLabels from 'ee/epic/components/sidebar_items/sidebar_labels.vue'; import SidebarLabels from 'ee/epic/components/sidebar_items/sidebar_labels.vue';
import createStore from 'ee/epic/store'; import createStore from 'ee/epic/store';
import { mountComponentWithStore } from 'spec/helpers/vue_mount_component_helper'; import { mountComponentWithStore } from 'helpers/vue_mount_component_helper';
import { mockEpicMeta, mockEpicData, mockLabels } from '../../mock_data'; import { mockEpicMeta, mockEpicData, mockLabels } from '../../mock_data';
describe('SidebarLabelsComponent', () => { describe('SidebarLabelsComponent', () => {
let vm; let vm;
let store; let store;
beforeEach(done => { beforeEach(() => {
const Component = Vue.extend(SidebarLabels); const Component = Vue.extend(SidebarLabels);
store = createStore(); store = createStore();
store.dispatch('setEpicMeta', mockEpicMeta); store.dispatch('setEpicMeta', mockEpicMeta);
...@@ -20,8 +20,6 @@ describe('SidebarLabelsComponent', () => { ...@@ -20,8 +20,6 @@ describe('SidebarLabelsComponent', () => {
store, store,
props: { canUpdate: false, sidebarCollapsed: false }, props: { canUpdate: false, sidebarCollapsed: false },
}); });
setTimeout(done);
}); });
afterEach(() => { afterEach(() => {
...@@ -45,7 +43,7 @@ describe('SidebarLabelsComponent', () => { ...@@ -45,7 +43,7 @@ describe('SidebarLabelsComponent', () => {
describe('methods', () => { describe('methods', () => {
describe('toggleSidebarRevealLabelsDropdown', () => { describe('toggleSidebarRevealLabelsDropdown', () => {
it('calls `toggleSidebar` action with param `sidebarCollapse`', () => { it('calls `toggleSidebar` action with param `sidebarCollapse`', () => {
spyOn(vm, 'toggleSidebar'); jest.spyOn(vm, 'toggleSidebar');
vm.toggleSidebarRevealLabelsDropdown(); vm.toggleSidebarRevealLabelsDropdown();
...@@ -59,7 +57,7 @@ describe('SidebarLabelsComponent', () => { ...@@ -59,7 +57,7 @@ describe('SidebarLabelsComponent', () => {
describe('handleDropdownClose', () => { describe('handleDropdownClose', () => {
it('calls `toggleSidebar` action only when `sidebarExpandedOnClick` prop is true', () => { it('calls `toggleSidebar` action only when `sidebarExpandedOnClick` prop is true', () => {
spyOn(vm, 'toggleSidebar'); jest.spyOn(vm, 'toggleSidebar');
vm.sidebarExpandedOnClick = true; vm.sidebarExpandedOnClick = true;
......
...@@ -3,14 +3,14 @@ import Vue from 'vue'; ...@@ -3,14 +3,14 @@ import Vue from 'vue';
import SidebarSubscription from 'ee/epic/components/sidebar_items/sidebar_subscription.vue'; import SidebarSubscription from 'ee/epic/components/sidebar_items/sidebar_subscription.vue';
import createStore from 'ee/epic/store'; import createStore from 'ee/epic/store';
import { mountComponentWithStore } from 'spec/helpers/vue_mount_component_helper'; import { mountComponentWithStore } from 'helpers/vue_mount_component_helper';
import { mockEpicMeta, mockEpicData } from '../../mock_data'; import { mockEpicMeta, mockEpicData } from '../../mock_data';
describe('SidebarSubscriptionComponent', () => { describe('SidebarSubscriptionComponent', () => {
let vm; let vm;
let store; let store;
beforeEach(done => { beforeEach(() => {
const Component = Vue.extend(SidebarSubscription); const Component = Vue.extend(SidebarSubscription);
store = createStore(); store = createStore();
store.dispatch('setEpicMeta', mockEpicMeta); store.dispatch('setEpicMeta', mockEpicMeta);
...@@ -20,8 +20,6 @@ describe('SidebarSubscriptionComponent', () => { ...@@ -20,8 +20,6 @@ describe('SidebarSubscriptionComponent', () => {
store, store,
props: { sidebarCollapsed: false }, props: { sidebarCollapsed: false },
}); });
setTimeout(done);
}); });
afterEach(() => { afterEach(() => {
......
...@@ -3,7 +3,7 @@ import Vue from 'vue'; ...@@ -3,7 +3,7 @@ import Vue from 'vue';
import SidebarTodo from 'ee/epic/components/sidebar_items/sidebar_todo.vue'; import SidebarTodo from 'ee/epic/components/sidebar_items/sidebar_todo.vue';
import createStore from 'ee/epic/store'; import createStore from 'ee/epic/store';
import { mountComponentWithStore } from 'spec/helpers/vue_mount_component_helper'; import { mountComponentWithStore } from 'helpers/vue_mount_component_helper';
import { mockEpicMeta, mockEpicData } from '../../mock_data'; import { mockEpicMeta, mockEpicData } from '../../mock_data';
describe('SidebarTodoComponent', () => { describe('SidebarTodoComponent', () => {
...@@ -11,7 +11,7 @@ describe('SidebarTodoComponent', () => { ...@@ -11,7 +11,7 @@ describe('SidebarTodoComponent', () => {
let vm; let vm;
let store; let store;
beforeEach(done => { beforeEach(() => {
gon.current_user_id = 1; gon.current_user_id = 1;
const Component = Vue.extend(SidebarTodo); const Component = Vue.extend(SidebarTodo);
...@@ -23,8 +23,6 @@ describe('SidebarTodoComponent', () => { ...@@ -23,8 +23,6 @@ describe('SidebarTodoComponent', () => {
store, store,
props: { sidebarCollapsed: false }, props: { sidebarCollapsed: false },
}); });
setTimeout(done);
}); });
afterEach(() => { afterEach(() => {
......
...@@ -5,7 +5,7 @@ import * as actions from 'ee/epic/store/actions'; ...@@ -5,7 +5,7 @@ import * as actions from 'ee/epic/store/actions';
import epicUtils from 'ee/epic/utils/epic_utils'; import epicUtils from 'ee/epic/utils/epic_utils';
import { statusType, dateTypes } from 'ee/epic/constants'; import { statusType, dateTypes } from 'ee/epic/constants';
import testAction from 'spec/helpers/vuex_action_helper'; import testAction from 'helpers/vuex_action_helper';
import axios from '~/lib/utils/axios_utils'; import axios from '~/lib/utils/axios_utils';
import { mockEpicMeta, mockEpicData } from '../mock_data'; import { mockEpicMeta, mockEpicData } from '../mock_data';
...@@ -96,7 +96,7 @@ describe('Epic Store Actions', () => { ...@@ -96,7 +96,7 @@ describe('Epic Store Actions', () => {
describe('triggerIssuableEvent', () => { describe('triggerIssuableEvent', () => {
it('Calls `triggerDocumentEvent` with events `issuable_vue_app:change`, `issuable:change` and passes `isEpicOpen` as param', () => { it('Calls `triggerDocumentEvent` with events `issuable_vue_app:change`, `issuable:change` and passes `isEpicOpen` as param', () => {
spyOn(epicUtils, 'triggerDocumentEvent').and.returnValue(false); jest.spyOn(epicUtils, 'triggerDocumentEvent').mockReturnValue(false);
const data = { isEpicOpen: true }; const data = { isEpicOpen: true };
actions.triggerIssuableEvent({}, data); actions.triggerIssuableEvent({}, data);
...@@ -199,8 +199,8 @@ describe('Epic Store Actions', () => { ...@@ -199,8 +199,8 @@ describe('Epic Store Actions', () => {
const sidebarCollapsed = true; const sidebarCollapsed = true;
beforeEach(() => { beforeEach(() => {
spyOn(epicUtils, 'toggleContainerClass').and.stub(); jest.spyOn(epicUtils, 'toggleContainerClass');
spyOn(epicUtils, 'setCollapsedGutter').and.stub(); jest.spyOn(epicUtils, 'setCollapsedGutter');
}); });
it('should call `epicUtils.toggleContainerClass` with classes `right-sidebar-expanded` & `right-sidebar-collapsed`', () => { it('should call `epicUtils.toggleContainerClass` with classes `right-sidebar-expanded` & `right-sidebar-collapsed`', () => {
...@@ -315,7 +315,7 @@ describe('Epic Store Actions', () => { ...@@ -315,7 +315,7 @@ describe('Epic Store Actions', () => {
describe('triggerTodoToggleEvent', () => { describe('triggerTodoToggleEvent', () => {
it('Calls `triggerDocumentEvent` with event `todo:toggle` and passes `count` as param', () => { it('Calls `triggerDocumentEvent` with event `todo:toggle` and passes `count` as param', () => {
spyOn(epicUtils, 'triggerDocumentEvent').and.returnValue(false); jest.spyOn(epicUtils, 'triggerDocumentEvent').mockReturnValue(false);
const data = { count: 5 }; const data = { count: 5 };
actions.triggerTodoToggleEvent({}, data); actions.triggerTodoToggleEvent({}, data);
...@@ -629,7 +629,7 @@ describe('Epic Store Actions', () => { ...@@ -629,7 +629,7 @@ describe('Epic Store Actions', () => {
it('dispatches requestEpicDateSave and requestEpicDateSaveSuccess when request is successful', done => { it('dispatches requestEpicDateSave and requestEpicDateSaveSuccess when request is successful', done => {
mock.onPut(/(.*)/).replyOnce(200, {}); mock.onPut(/(.*)/).replyOnce(200, {});
spyOn(epicUtils.gqClient, 'mutate').and.returnValue( jest.spyOn(epicUtils.gqClient, 'mutate').mockReturnValue(
Promise.resolve({ Promise.resolve({
data: mockUpdateEpicMutationRes, data: mockUpdateEpicMutationRes,
}), }),
...@@ -656,7 +656,7 @@ describe('Epic Store Actions', () => { ...@@ -656,7 +656,7 @@ describe('Epic Store Actions', () => {
it('dispatches requestEpicDateSave and requestEpicDateSaveFailure when request fails', done => { it('dispatches requestEpicDateSave and requestEpicDateSaveFailure when request fails', done => {
mock.onPut(/(.*)/).replyOnce(500, {}); mock.onPut(/(.*)/).replyOnce(500, {});
spyOn(epicUtils.gqClient, 'mutate').and.returnValue( jest.spyOn(epicUtils.gqClient, 'mutate').mockReturnValue(
Promise.resolve({ Promise.resolve({
data: { data: {
updateEpic: { updateEpic: {
...@@ -795,7 +795,7 @@ describe('Epic Store Actions', () => { ...@@ -795,7 +795,7 @@ describe('Epic Store Actions', () => {
describe('success', () => { describe('success', () => {
it('dispatches requestEpicSubscriptionToggle and requestEpicSubscriptionToggleSuccess with param `subscribed` when request is complete', done => { it('dispatches requestEpicSubscriptionToggle and requestEpicSubscriptionToggleSuccess with param `subscribed` when request is complete', done => {
mock.onPost(/(.*)/).replyOnce(200, {}); mock.onPost(/(.*)/).replyOnce(200, {});
spyOn(epicUtils.gqClient, 'mutate').and.returnValue( jest.spyOn(epicUtils.gqClient, 'mutate').mockReturnValue(
Promise.resolve({ Promise.resolve({
data: mockEpicSetSubscriptionRes, data: mockEpicSetSubscriptionRes,
}), }),
...@@ -837,7 +837,7 @@ describe('Epic Store Actions', () => { ...@@ -837,7 +837,7 @@ describe('Epic Store Actions', () => {
describe('failure', () => { describe('failure', () => {
it('dispatches requestEpicSubscriptionToggle and requestEpicSubscriptionToggleFailure when request fails', done => { it('dispatches requestEpicSubscriptionToggle and requestEpicSubscriptionToggleFailure when request fails', done => {
mock.onPost(/(.*)/).replyOnce(500, {}); mock.onPost(/(.*)/).replyOnce(500, {});
spyOn(epicUtils.gqClient, 'mutate').and.returnValue( jest.spyOn(epicUtils.gqClient, 'mutate').mockReturnValue(
Promise.resolve({ Promise.resolve({
data: { data: {
epicSetSubscription: { epicSetSubscription: {
......
export * from '../../frontend/epic/mock_data';
export const initialRequest = {
title: '<p>this is a title</p>',
title_text: 'this is a title',
description: '<p>this is a description!</p>',
description_text: 'this is a description',
task_status: '2 of 4 completed',
updated_at: '2015-05-15T12:31:04.428Z',
updated_by_name: 'Some User',
updated_by_path: '/some_user',
lock_version: 1,
};
export const secondRequest = {
title: '<p>2</p>',
title_text: '2',
description: '<p>42</p>',
description_text: '42',
task_status: '0 of 0 completed',
updated_at: '2016-05-15T12:31:04.428Z',
updated_by_name: 'Other User',
updated_by_path: '/other_user',
lock_version: 2,
};
...@@ -7,13 +7,13 @@ import axios from '~/lib/utils/axios_utils'; ...@@ -7,13 +7,13 @@ import axios from '~/lib/utils/axios_utils';
import '~/behaviors/markdown/render_gfm'; import '~/behaviors/markdown/render_gfm';
import issuableApp from '~/issue_show/components/app.vue'; import issuableApp from '~/issue_show/components/app.vue';
import eventHub from '~/issue_show/event_hub'; import eventHub from '~/issue_show/event_hub';
import issueShowData from '../mock_data'; import { initialRequest, secondRequest } from '../mock_data';
function formatText(text) { function formatText(text) {
return text.trim().replace(/\s\s+/g, ' '); return text.trim().replace(/\s\s+/g, ' ');
} }
const REALTIME_REQUEST_STACK = [issueShowData.initialRequest, issueShowData.secondRequest]; const REALTIME_REQUEST_STACK = [initialRequest, secondRequest];
describe('Issuable output', () => { describe('Issuable output', () => {
let mock; let mock;
......
export default { export * from '../../frontend/issue_show/mock_data';
initialRequest: {
title: '<p>this is a title</p>',
title_text: 'this is a title',
description: '<p>this is a description!</p>',
description_text: 'this is a description',
task_status: '2 of 4 completed',
updated_at: '2015-05-15T12:31:04.428Z',
updated_by_name: 'Some User',
updated_by_path: '/some_user',
lock_version: 1,
},
secondRequest: {
title: '<p>2</p>',
title_text: '2',
description: '<p>42</p>',
description_text: '42',
task_status: '0 of 0 completed',
updated_at: '2016-05-15T12:31:04.428Z',
updated_by_name: 'Other User',
updated_by_path: '/other_user',
lock_version: 2,
},
};
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