Commit e7d4816c authored by Vitaly Slobodin's avatar Vitaly Slobodin

Migrate ee/roadmap to Jest

Closes https://gitlab.com/gitlab-org/gitlab/issues/194303
parent 4c84caaa
...@@ -8,7 +8,7 @@ import { ...@@ -8,7 +8,7 @@ import {
} from 'ee/roadmap/utils/roadmap_utils'; } from 'ee/roadmap/utils/roadmap_utils';
import { PRESET_TYPES } from 'ee/roadmap/constants'; import { PRESET_TYPES } from 'ee/roadmap/constants';
import { mockTimeframeInitialDate } from '../mock_data'; import { mockTimeframeInitialDate } from 'ee_jest/roadmap/mock_data';
const mockTimeframeQuarters = getTimeframeForQuartersView(mockTimeframeInitialDate); const mockTimeframeQuarters = getTimeframeForQuartersView(mockTimeframeInitialDate);
const mockTimeframeMonths = getTimeframeForMonthsView(mockTimeframeInitialDate); const mockTimeframeMonths = getTimeframeForMonthsView(mockTimeframeInitialDate);
...@@ -46,7 +46,7 @@ describe('CurrentDayIndicator', () => { ...@@ -46,7 +46,7 @@ describe('CurrentDayIndicator', () => {
describe('computed', () => { describe('computed', () => {
describe('hasToday', () => { describe('hasToday', () => {
it('returns true when presetType is QUARTERS and currentDate is within current quarter', done => { it('returns true when presetType is QUARTERS and currentDate is within current quarter', () => {
wrapper.setData({ wrapper.setData({
currentDate: mockTimeframeQuarters[0].range[1], currentDate: mockTimeframeQuarters[0].range[1],
}); });
...@@ -56,13 +56,12 @@ describe('CurrentDayIndicator', () => { ...@@ -56,13 +56,12 @@ describe('CurrentDayIndicator', () => {
timeframeItem: mockTimeframeQuarters[0], timeframeItem: mockTimeframeQuarters[0],
}); });
wrapper.vm.$nextTick(() => { return wrapper.vm.$nextTick(() => {
expect(wrapper.vm.hasToday).toBe(true); expect(wrapper.vm.hasToday).toBe(true);
done();
}); });
}); });
it('returns true when presetType is MONTHS and currentDate is within current month', done => { it('returns true when presetType is MONTHS and currentDate is within current month', () => {
wrapper.setData({ wrapper.setData({
currentDate: new Date(2020, 0, 15), currentDate: new Date(2020, 0, 15),
}); });
...@@ -72,13 +71,12 @@ describe('CurrentDayIndicator', () => { ...@@ -72,13 +71,12 @@ describe('CurrentDayIndicator', () => {
timeframeItem: new Date(2020, 0, 1), timeframeItem: new Date(2020, 0, 1),
}); });
wrapper.vm.$nextTick(() => { return wrapper.vm.$nextTick(() => {
expect(wrapper.vm.hasToday).toBe(true); expect(wrapper.vm.hasToday).toBe(true);
done();
}); });
}); });
it('returns true when presetType is WEEKS and currentDate is within current week', done => { it('returns true when presetType is WEEKS and currentDate is within current week', () => {
wrapper.setData({ wrapper.setData({
currentDate: mockTimeframeWeeks[0], currentDate: mockTimeframeWeeks[0],
}); });
...@@ -88,9 +86,8 @@ describe('CurrentDayIndicator', () => { ...@@ -88,9 +86,8 @@ describe('CurrentDayIndicator', () => {
timeframeItem: mockTimeframeWeeks[0], timeframeItem: mockTimeframeWeeks[0],
}); });
wrapper.vm.$nextTick(() => { return wrapper.vm.$nextTick(() => {
expect(wrapper.vm.hasToday).toBe(true); expect(wrapper.vm.hasToday).toBe(true);
done();
}); });
}); });
}); });
...@@ -98,7 +95,7 @@ describe('CurrentDayIndicator', () => { ...@@ -98,7 +95,7 @@ describe('CurrentDayIndicator', () => {
describe('methods', () => { describe('methods', () => {
describe('getIndicatorStyles', () => { describe('getIndicatorStyles', () => {
it('returns object containing `left` with value `34%` when presetType is QUARTERS', done => { it('returns object containing `left` with value `34%` when presetType is QUARTERS', () => {
wrapper.setData({ wrapper.setData({
currentDate: mockTimeframeQuarters[0].range[1], currentDate: mockTimeframeQuarters[0].range[1],
}); });
...@@ -108,17 +105,16 @@ describe('CurrentDayIndicator', () => { ...@@ -108,17 +105,16 @@ describe('CurrentDayIndicator', () => {
timeframeItem: mockTimeframeQuarters[0], timeframeItem: mockTimeframeQuarters[0],
}); });
wrapper.vm.$nextTick(() => { return wrapper.vm.$nextTick(() => {
expect(wrapper.vm.getIndicatorStyles()).toEqual( expect(wrapper.vm.getIndicatorStyles()).toEqual(
jasmine.objectContaining({ expect.objectContaining({
left: '34%', left: '34%',
}), }),
); );
done();
}); });
}); });
it('returns object containing `left` with value `48%` when presetType is MONTHS', done => { it('returns object containing `left` with value `48%` when presetType is MONTHS', () => {
wrapper.setData({ wrapper.setData({
currentDate: new Date(2020, 0, 15), currentDate: new Date(2020, 0, 15),
}); });
...@@ -128,17 +124,16 @@ describe('CurrentDayIndicator', () => { ...@@ -128,17 +124,16 @@ describe('CurrentDayIndicator', () => {
timeframeItem: new Date(2020, 0, 1), timeframeItem: new Date(2020, 0, 1),
}); });
wrapper.vm.$nextTick(() => { return wrapper.vm.$nextTick(() => {
expect(wrapper.vm.getIndicatorStyles()).toEqual( expect(wrapper.vm.getIndicatorStyles()).toEqual(
jasmine.objectContaining({ expect.objectContaining({
left: '48%', left: '48%',
}), }),
); );
done();
}); });
}); });
it('returns object containing `left` with value `7%` when presetType is WEEKS', done => { it('returns object containing `left` with value `7%` when presetType is WEEKS', () => {
wrapper.setData({ wrapper.setData({
currentDate: mockTimeframeWeeks[0], currentDate: mockTimeframeWeeks[0],
}); });
...@@ -148,34 +143,33 @@ describe('CurrentDayIndicator', () => { ...@@ -148,34 +143,33 @@ describe('CurrentDayIndicator', () => {
timeframeItem: mockTimeframeWeeks[0], timeframeItem: mockTimeframeWeeks[0],
}); });
wrapper.vm.$nextTick(() => { return wrapper.vm.$nextTick(() => {
expect(wrapper.vm.getIndicatorStyles()).toEqual( expect(wrapper.vm.getIndicatorStyles()).toEqual(
jasmine.objectContaining({ expect.objectContaining({
left: '7%', left: '7%',
}), }),
); );
done();
}); });
}); });
}); });
}); });
describe('template', () => { describe('template', () => {
beforeEach(done => { beforeEach(() => {
wrapper = createComponent();
wrapper.setData({ wrapper.setData({
currentDate: mockTimeframeMonths[0], currentDate: mockTimeframeMonths[0],
}); });
wrapper.vm.$nextTick(() => {
done(); return wrapper.vm.$nextTick();
});
}); });
it('renders span element containing class `current-day-indicator`', () => { it('renders span element containing class `current-day-indicator`', () => {
expect(wrapper.element.classList.contains('current-day-indicator')).toBe(true); expect(wrapper.classes('current-day-indicator')).toBe(true);
}); });
it('renders span element with style attribute containing `left: 3%;`', () => { it('renders span element with style attribute containing `left: 3%;`', () => {
expect(wrapper.element.getAttribute('style')).toBe('left: 3%;'); expect(wrapper.attributes('style')).toBe('left: 3%;');
}); });
}); });
}); });
...@@ -7,7 +7,7 @@ import { ...@@ -7,7 +7,7 @@ import {
mockFormattedEpic, mockFormattedEpic,
mockFormattedChildEpic2, mockFormattedChildEpic2,
mockFormattedChildEpic1, mockFormattedChildEpic1,
} from '../mock_data'; } from 'ee_jest/roadmap/mock_data';
const createComponent = ( const createComponent = (
epic = mockFormattedEpic, epic = mockFormattedEpic,
...@@ -159,7 +159,7 @@ describe('EpicItemDetails', () => { ...@@ -159,7 +159,7 @@ describe('EpicItemDetails', () => {
}); });
it('emits toggleIsEpicExpanded event when clicked', () => { it('emits toggleIsEpicExpanded event when clicked', () => {
spyOn(eventHub, '$emit'); jest.spyOn(eventHub, '$emit').mockImplementation(() => {});
const id = 42; const id = 42;
const epic = { const epic = {
......
...@@ -8,8 +8,8 @@ import { getTimeframeForMonthsView } from 'ee/roadmap/utils/roadmap_utils'; ...@@ -8,8 +8,8 @@ import { getTimeframeForMonthsView } from 'ee/roadmap/utils/roadmap_utils';
import { PRESET_TYPES } from 'ee/roadmap/constants'; import { PRESET_TYPES } from 'ee/roadmap/constants';
import mountComponent from 'spec/helpers/vue_mount_component_helper'; import mountComponent from 'helpers/vue_mount_component_helper';
import { mockTimeframeInitialDate, mockEpic, mockGroupId } from '../mock_data'; import { mockTimeframeInitialDate, mockEpic, mockGroupId } from 'ee_jest/roadmap/mock_data';
const mockTimeframeMonths = getTimeframeForMonthsView(mockTimeframeInitialDate); const mockTimeframeMonths = getTimeframeForMonthsView(mockTimeframeInitialDate);
...@@ -111,7 +111,7 @@ describe('EpicItemComponent', () => { ...@@ -111,7 +111,7 @@ describe('EpicItemComponent', () => {
describe('methods', () => { describe('methods', () => {
describe('removeHighlight', () => { describe('removeHighlight', () => {
it('should call _.delay after 3 seconds with a callback function which would set `epic.newEpic` to false when it is true already', done => { it('should call _.delay after 3 seconds with a callback function which would set `epic.newEpic` to false when it is true already', done => {
spyOn(_, 'delay'); jest.spyOn(_, 'delay').mockImplementation(() => {});
vm.epic.newEpic = true; vm.epic.newEpic = true;
...@@ -119,7 +119,7 @@ describe('EpicItemComponent', () => { ...@@ -119,7 +119,7 @@ describe('EpicItemComponent', () => {
vm.$nextTick() vm.$nextTick()
.then(() => { .then(() => {
expect(_.delay).toHaveBeenCalledWith(jasmine.any(Function), 3000); expect(_.delay).toHaveBeenCalledWith(expect.any(Function), 3000);
}) })
.then(done) .then(done)
.catch(done.fail); .catch(done.fail);
......
...@@ -4,7 +4,7 @@ import CurrentDayIndicator from 'ee/roadmap/components/current_day_indicator.vue ...@@ -4,7 +4,7 @@ import CurrentDayIndicator from 'ee/roadmap/components/current_day_indicator.vue
import EpicItemTimeline from 'ee/roadmap/components/epic_item_timeline.vue'; import EpicItemTimeline from 'ee/roadmap/components/epic_item_timeline.vue';
import { PRESET_TYPES } from 'ee/roadmap/constants'; import { PRESET_TYPES } from 'ee/roadmap/constants';
import { getTimeframeForMonthsView } from 'ee/roadmap/utils/roadmap_utils'; import { getTimeframeForMonthsView } from 'ee/roadmap/utils/roadmap_utils';
import { mockTimeframeInitialDate, mockFormattedEpic } from '../mock_data'; import { mockTimeframeInitialDate, mockFormattedEpic } from 'ee_jest/roadmap/mock_data';
const mockTimeframeMonths = getTimeframeForMonthsView(mockTimeframeInitialDate); const mockTimeframeMonths = getTimeframeForMonthsView(mockTimeframeInitialDate);
......
...@@ -10,8 +10,12 @@ import { ...@@ -10,8 +10,12 @@ import {
import { PRESET_TYPES } from 'ee/roadmap/constants'; import { PRESET_TYPES } from 'ee/roadmap/constants';
import mountComponent from 'spec/helpers/vue_mount_component_helper'; import mountComponent from 'helpers/vue_mount_component_helper';
import { mockTimeframeInitialDate, mockSvgPath, mockNewEpicEndpoint } from '../mock_data'; import {
mockTimeframeInitialDate,
mockSvgPath,
mockNewEpicEndpoint,
} from 'ee_jest/roadmap/mock_data';
const mockTimeframeQuarters = getTimeframeForQuartersView(mockTimeframeInitialDate); const mockTimeframeQuarters = getTimeframeForQuartersView(mockTimeframeInitialDate);
const mockTimeframeMonths = getTimeframeForMonthsView(mockTimeframeInitialDate); const mockTimeframeMonths = getTimeframeForMonthsView(mockTimeframeInitialDate);
......
import { shallowMount, createLocalVue } from '@vue/test-utils'; import { shallowMount, createLocalVue } from '@vue/test-utils';
import VirtualList from 'vue-virtual-scroll-list'; import VirtualList from 'vue-virtual-scroll-list';
import epicsListSectionComponent from 'ee/roadmap/components/epics_list_section.vue'; import EpicsListSection from 'ee/roadmap/components/epics_list_section.vue';
import EpicItem from 'ee/roadmap/components/epic_item.vue'; import EpicItem from 'ee/roadmap/components/epic_item.vue';
import createStore from 'ee/roadmap/store'; import createStore from 'ee/roadmap/store';
import { getTimeframeForMonthsView } from 'ee/roadmap/utils/roadmap_utils'; import { getTimeframeForMonthsView } from 'ee/roadmap/utils/roadmap_utils';
...@@ -18,7 +18,7 @@ import { ...@@ -18,7 +18,7 @@ import {
mockSortedBy, mockSortedBy,
basePath, basePath,
epicsPath, epicsPath,
} from '../mock_data'; } from 'ee_jest/roadmap/mock_data';
const mockTimeframeMonths = getTimeframeForMonthsView(mockTimeframeInitialDate); const mockTimeframeMonths = getTimeframeForMonthsView(mockTimeframeInitialDate);
const store = createStore(); const store = createStore();
...@@ -39,6 +39,7 @@ const mockEpics = store.state.epics; ...@@ -39,6 +39,7 @@ const mockEpics = store.state.epics;
store.state.epics[0].children = { store.state.epics[0].children = {
edges: [mockFormattedChildEpic1, mockFormattedChildEpic2], edges: [mockFormattedChildEpic1, mockFormattedChildEpic2],
}; };
const localVue = createLocalVue();
const createComponent = ({ const createComponent = ({
epics = mockEpics, epics = mockEpics,
...@@ -47,9 +48,7 @@ const createComponent = ({ ...@@ -47,9 +48,7 @@ const createComponent = ({
presetType = PRESET_TYPES.MONTHS, presetType = PRESET_TYPES.MONTHS,
roadmapBufferedRendering = true, roadmapBufferedRendering = true,
} = {}) => { } = {}) => {
const localVue = createLocalVue(); return shallowMount(EpicsListSection, {
return shallowMount(epicsListSectionComponent, {
localVue, localVue,
store, store,
stubs: { stubs: {
...@@ -82,6 +81,13 @@ describe('EpicsListSectionComponent', () => { ...@@ -82,6 +81,13 @@ describe('EpicsListSectionComponent', () => {
describe('data', () => { describe('data', () => {
it('returns default data props', () => { it('returns default data props', () => {
// Destroy the existing wrapper, and create a new one. This works around
// a race condition between how Jest runs tests and the $nextTick call in
// EpicsListSectionComponent's mounted hook.
// https://gitlab.com/gitlab-org/gitlab/-/merge_requests/27992#note_319213990
wrapper.destroy();
wrapper = createComponent();
expect(wrapper.vm.offsetLeft).toBe(0); expect(wrapper.vm.offsetLeft).toBe(0);
expect(wrapper.vm.emptyRowContainerStyles).toEqual({}); expect(wrapper.vm.emptyRowContainerStyles).toEqual({});
expect(wrapper.vm.showBottomShadow).toBe(false); expect(wrapper.vm.showBottomShadow).toBe(false);
...@@ -115,63 +121,69 @@ describe('EpicsListSectionComponent', () => { ...@@ -115,63 +121,69 @@ describe('EpicsListSectionComponent', () => {
describe('methods', () => { describe('methods', () => {
describe('initMounted', () => { describe('initMounted', () => {
beforeEach(() => {
// Destroy the existing wrapper, and create a new one. This works
// around a race condition between how Jest runs tests and the
// $nextTick call in EpicsListSectionComponent's mounted hook.
// https://gitlab.com/gitlab-org/gitlab/-/merge_requests/27992#note_319213990
wrapper.destroy();
wrapper = createComponent();
jest.spyOn(wrapper.vm, 'scrollToTodayIndicator').mockImplementation(() => {});
});
it('sets value of `roadmapShellEl` with root component element', () => { it('sets value of `roadmapShellEl` with root component element', () => {
expect(wrapper.vm.roadmapShellEl instanceof HTMLElement).toBe(true); expect(wrapper.vm.roadmapShellEl instanceof HTMLElement).toBe(true);
}); });
it('calls action `setBufferSize` with value based on window.innerHeight and component element position', () => { it('calls action `setBufferSize` with value based on window.innerHeight and component element position', () => {
expect(wrapper.vm.bufferSize).toBe(12); expect(wrapper.vm.bufferSize).toBe(16);
}); });
it('sets value of `offsetLeft` with parentElement.offsetLeft', done => { it('sets value of `offsetLeft` with parentElement.offsetLeft', () => {
wrapper.vm.$nextTick(() => { return wrapper.vm.$nextTick(() => {
// During tests, there's no `$el.parentElement` present // During tests, there's no `$el.parentElement` present
// hence offsetLeft is 0. // hence offsetLeft is 0.
expect(wrapper.vm.offsetLeft).toBe(0); expect(wrapper.vm.offsetLeft).toBe(0);
done();
}); });
}); });
it('calls `scrollToTodayIndicator` following the component render', done => { it('calls `scrollToTodayIndicator` following the component render', () => {
spyOn(wrapper.vm, 'scrollToTodayIndicator');
// Original method implementation waits for render cycle // Original method implementation waits for render cycle
// to complete at 2 levels before scrolling. // to complete at 2 levels before scrolling.
wrapper.vm.$nextTick(() => { return wrapper.vm
wrapper.vm.$nextTick(() => { .$nextTick()
.then(() => wrapper.vm.$nextTick())
.then(() => {
expect(wrapper.vm.scrollToTodayIndicator).toHaveBeenCalled(); expect(wrapper.vm.scrollToTodayIndicator).toHaveBeenCalled();
done();
}); });
});
}); });
it('sets style object to `emptyRowContainerStyles`', done => { it('sets style object to `emptyRowContainerStyles`', () => {
wrapper.vm.$nextTick(() => { return wrapper.vm.$nextTick(() => {
expect(wrapper.vm.emptyRowContainerStyles).toEqual( expect(wrapper.vm.emptyRowContainerStyles).toEqual(
jasmine.objectContaining({ expect.objectContaining({
height: '0px', height: '0px',
}), }),
); );
done();
}); });
}); });
}); });
describe('getEmptyRowContainerStyles', () => { describe('getEmptyRowContainerStyles', () => {
it('returns empty object when there are no epics available to render', done => { it('returns empty object when there are no epics available to render', () => {
wrapper.setProps({ wrapper.setProps({
epics: [], epics: [],
}); });
wrapper.vm.$nextTick(() => { return wrapper.vm.$nextTick(() => {
expect(wrapper.vm.getEmptyRowContainerStyles()).toEqual({}); expect(wrapper.vm.getEmptyRowContainerStyles()).toEqual({});
done();
}); });
}); });
it('returns object containing `height` when there epics available to render', () => { it('returns object containing `height` when there epics available to render', () => {
expect(wrapper.vm.getEmptyRowContainerStyles()).toEqual( expect(wrapper.vm.getEmptyRowContainerStyles()).toEqual(
jasmine.objectContaining({ expect.objectContaining({
height: '0px', height: '0px',
}), }),
); );
...@@ -203,7 +215,7 @@ describe('EpicsListSectionComponent', () => { ...@@ -203,7 +215,7 @@ describe('EpicsListSectionComponent', () => {
describe('getEpicItemProps', () => { describe('getEpicItemProps', () => {
it('returns an object containing props for EpicItem component', () => { it('returns an object containing props for EpicItem component', () => {
expect(wrapper.vm.getEpicItemProps(1)).toEqual( expect(wrapper.vm.getEpicItemProps(1)).toEqual(
jasmine.objectContaining({ expect.objectContaining({
key: 1, key: 1,
props: { props: {
epic: wrapper.vm.epics[1], epic: wrapper.vm.epics[1],
...@@ -219,15 +231,14 @@ describe('EpicsListSectionComponent', () => { ...@@ -219,15 +231,14 @@ describe('EpicsListSectionComponent', () => {
describe('template', () => { describe('template', () => {
it('renders component container element with class `epics-list-section`', () => { it('renders component container element with class `epics-list-section`', () => {
expect(wrapper.vm.$el.classList.contains('epics-list-section')).toBe(true); expect(wrapper.classes('epics-list-section')).toBe(true);
}); });
it('renders virtual-list when roadmapBufferedRendering is `true` and `epics.length` is more than `bufferSize`', done => { it('renders virtual-list when roadmapBufferedRendering is `true` and `epics.length` is more than `bufferSize`', () => {
wrapper.vm.setBufferSize(5); wrapper.vm.setBufferSize(5);
wrapper.vm.$nextTick(() => { return wrapper.vm.$nextTick(() => {
expect(wrapper.find(VirtualList).exists()).toBe(true); expect(wrapper.find(VirtualList).exists()).toBe(true);
done();
}); });
}); });
...@@ -267,7 +278,6 @@ describe('EpicsListSectionComponent', () => { ...@@ -267,7 +278,6 @@ describe('EpicsListSectionComponent', () => {
it('expands to show child epics when epic is toggled', done => { it('expands to show child epics when epic is toggled', done => {
const epic = mockEpics[0]; const epic = mockEpics[0];
wrapper = createComponent();
expect(wrapper.findAll(EpicItem).length).toBe(mockEpics.length); expect(wrapper.findAll(EpicItem).length).toBe(mockEpics.length);
......
...@@ -7,7 +7,7 @@ import { getTimeframeForMonthsView } from 'ee/roadmap/utils/roadmap_utils'; ...@@ -7,7 +7,7 @@ import { getTimeframeForMonthsView } from 'ee/roadmap/utils/roadmap_utils';
import { PRESET_TYPES } from 'ee/roadmap/constants'; import { PRESET_TYPES } from 'ee/roadmap/constants';
import { mount } from '@vue/test-utils'; import { mount } from '@vue/test-utils';
import { mockTimeframeInitialDate, mockMilestone2 } from '../../../javascripts/roadmap/mock_data'; import { mockTimeframeInitialDate, mockMilestone2 } from 'ee_jest/roadmap/mock_data';
const mockTimeframeMonths = getTimeframeForMonthsView(mockTimeframeInitialDate); const mockTimeframeMonths = getTimeframeForMonthsView(mockTimeframeInitialDate);
...@@ -45,29 +45,25 @@ describe('MilestoneItemComponent', () => { ...@@ -45,29 +45,25 @@ describe('MilestoneItemComponent', () => {
describe('computed', () => { describe('computed', () => {
describe('startDateValues', () => { describe('startDateValues', () => {
it('returns object containing date parts from milestone.startDate', () => { it('returns object containing date parts from milestone.startDate', () => {
expect(wrapper.vm.startDateValues).toEqual( expect(wrapper.vm.startDateValues).toMatchObject({
jasmine.objectContaining({ day: mockMilestone2.startDate.getDay(),
day: mockMilestone2.startDate.getDay(), date: mockMilestone2.startDate.getDate(),
date: mockMilestone2.startDate.getDate(), month: mockMilestone2.startDate.getMonth(),
month: mockMilestone2.startDate.getMonth(), year: mockMilestone2.startDate.getFullYear(),
year: mockMilestone2.startDate.getFullYear(), time: mockMilestone2.startDate.getTime(),
time: mockMilestone2.startDate.getTime(), });
}),
);
}); });
}); });
describe('endDateValues', () => { describe('endDateValues', () => {
it('returns object containing date parts from milestone.endDate', () => { it('returns object containing date parts from milestone.endDate', () => {
expect(wrapper.vm.endDateValues).toEqual( expect(wrapper.vm.endDateValues).toMatchObject({
jasmine.objectContaining({ day: mockMilestone2.endDate.getDay(),
day: mockMilestone2.endDate.getDay(), date: mockMilestone2.endDate.getDate(),
date: mockMilestone2.endDate.getDate(), month: mockMilestone2.endDate.getMonth(),
month: mockMilestone2.endDate.getMonth(), year: mockMilestone2.endDate.getFullYear(),
year: mockMilestone2.endDate.getFullYear(), time: mockMilestone2.endDate.getTime(),
time: mockMilestone2.endDate.getTime(), });
}),
);
}); });
}); });
......
...@@ -7,11 +7,7 @@ import { getTimeframeForMonthsView } from 'ee/roadmap/utils/roadmap_utils'; ...@@ -7,11 +7,7 @@ import { getTimeframeForMonthsView } from 'ee/roadmap/utils/roadmap_utils';
import { PRESET_TYPES } from 'ee/roadmap/constants'; import { PRESET_TYPES } from 'ee/roadmap/constants';
import { import { mockTimeframeInitialDate, mockMilestone2, mockGroupId } from 'ee_jest/roadmap/mock_data';
mockTimeframeInitialDate,
mockMilestone2,
mockGroupId,
} from '../../../javascripts/roadmap/mock_data';
const mockTimeframeMonths = getTimeframeForMonthsView(mockTimeframeInitialDate); const mockTimeframeMonths = getTimeframeForMonthsView(mockTimeframeInitialDate);
......
...@@ -8,11 +8,7 @@ import { ...@@ -8,11 +8,7 @@ import {
EPIC_DETAILS_CELL_WIDTH, EPIC_DETAILS_CELL_WIDTH,
TIMELINE_CELL_MIN_WIDTH, TIMELINE_CELL_MIN_WIDTH,
} from 'ee/roadmap/constants'; } from 'ee/roadmap/constants';
import { import { mockTimeframeInitialDate, mockGroupId, rawMilestones } from 'ee_jest/roadmap/mock_data';
mockTimeframeInitialDate,
mockGroupId,
rawMilestones,
} from '../../../javascripts/roadmap/mock_data';
const mockTimeframeMonths = getTimeframeForMonthsView(mockTimeframeInitialDate); const mockTimeframeMonths = getTimeframeForMonthsView(mockTimeframeInitialDate);
const store = createStore(); const store = createStore();
......
...@@ -3,8 +3,8 @@ import Vue from 'vue'; ...@@ -3,8 +3,8 @@ import Vue from 'vue';
import MonthsHeaderItemComponent from 'ee/roadmap/components/preset_months/months_header_item.vue'; import MonthsHeaderItemComponent from 'ee/roadmap/components/preset_months/months_header_item.vue';
import { getTimeframeForMonthsView } from 'ee/roadmap/utils/roadmap_utils'; import { getTimeframeForMonthsView } from 'ee/roadmap/utils/roadmap_utils';
import mountComponent from 'spec/helpers/vue_mount_component_helper'; import mountComponent from 'helpers/vue_mount_component_helper';
import { mockTimeframeInitialDate } from 'ee_spec/roadmap/mock_data'; import { mockTimeframeInitialDate } from '../../mock_data';
const mockTimeframeMonths = getTimeframeForMonthsView(mockTimeframeInitialDate); const mockTimeframeMonths = getTimeframeForMonthsView(mockTimeframeInitialDate);
const mockTimeframeIndex = 0; const mockTimeframeIndex = 0;
......
...@@ -4,8 +4,8 @@ import MonthsHeaderSubItemComponent from 'ee/roadmap/components/preset_months/mo ...@@ -4,8 +4,8 @@ import MonthsHeaderSubItemComponent from 'ee/roadmap/components/preset_months/mo
import { getTimeframeForMonthsView } from 'ee/roadmap/utils/roadmap_utils'; import { getTimeframeForMonthsView } from 'ee/roadmap/utils/roadmap_utils';
import { PRESET_TYPES } from 'ee/roadmap/constants'; import { PRESET_TYPES } from 'ee/roadmap/constants';
import mountComponent from 'spec/helpers/vue_mount_component_helper'; import mountComponent from 'helpers/vue_mount_component_helper';
import { mockTimeframeInitialDate } from 'ee_spec/roadmap/mock_data'; import { mockTimeframeInitialDate } from '../../mock_data';
const mockTimeframeMonths = getTimeframeForMonthsView(mockTimeframeInitialDate); const mockTimeframeMonths = getTimeframeForMonthsView(mockTimeframeInitialDate);
......
...@@ -3,8 +3,8 @@ import Vue from 'vue'; ...@@ -3,8 +3,8 @@ import Vue from 'vue';
import QuartersHeaderItemComponent from 'ee/roadmap/components/preset_quarters/quarters_header_item.vue'; import QuartersHeaderItemComponent from 'ee/roadmap/components/preset_quarters/quarters_header_item.vue';
import { getTimeframeForQuartersView } from 'ee/roadmap/utils/roadmap_utils'; import { getTimeframeForQuartersView } from 'ee/roadmap/utils/roadmap_utils';
import mountComponent from 'spec/helpers/vue_mount_component_helper'; import mountComponent from 'helpers/vue_mount_component_helper';
import { mockTimeframeInitialDate } from 'ee_spec/roadmap/mock_data'; import { mockTimeframeInitialDate } from '../../mock_data';
const mockTimeframeIndex = 0; const mockTimeframeIndex = 0;
const mockTimeframeQuarters = getTimeframeForQuartersView(mockTimeframeInitialDate); const mockTimeframeQuarters = getTimeframeForQuartersView(mockTimeframeInitialDate);
......
...@@ -4,8 +4,8 @@ import QuartersHeaderSubItemComponent from 'ee/roadmap/components/preset_quarter ...@@ -4,8 +4,8 @@ import QuartersHeaderSubItemComponent from 'ee/roadmap/components/preset_quarter
import { getTimeframeForQuartersView } from 'ee/roadmap/utils/roadmap_utils'; import { getTimeframeForQuartersView } from 'ee/roadmap/utils/roadmap_utils';
import { PRESET_TYPES } from 'ee/roadmap/constants'; import { PRESET_TYPES } from 'ee/roadmap/constants';
import mountComponent from 'spec/helpers/vue_mount_component_helper'; import mountComponent from 'helpers/vue_mount_component_helper';
import { mockTimeframeInitialDate } from 'ee_spec/roadmap/mock_data'; import { mockTimeframeInitialDate } from '../../mock_data';
const mockTimeframeQuarters = getTimeframeForQuartersView(mockTimeframeInitialDate); const mockTimeframeQuarters = getTimeframeForQuartersView(mockTimeframeInitialDate);
......
...@@ -3,8 +3,8 @@ import Vue from 'vue'; ...@@ -3,8 +3,8 @@ import Vue from 'vue';
import WeeksHeaderItemComponent from 'ee/roadmap/components/preset_weeks/weeks_header_item.vue'; import WeeksHeaderItemComponent from 'ee/roadmap/components/preset_weeks/weeks_header_item.vue';
import { getTimeframeForWeeksView } from 'ee/roadmap/utils/roadmap_utils'; import { getTimeframeForWeeksView } from 'ee/roadmap/utils/roadmap_utils';
import mountComponent from 'spec/helpers/vue_mount_component_helper'; import mountComponent from 'helpers/vue_mount_component_helper';
import { mockTimeframeInitialDate } from 'ee_spec/roadmap/mock_data'; import { mockTimeframeInitialDate } from '../../mock_data';
const mockTimeframeIndex = 0; const mockTimeframeIndex = 0;
const mockTimeframeWeeks = getTimeframeForWeeksView(mockTimeframeInitialDate); const mockTimeframeWeeks = getTimeframeForWeeksView(mockTimeframeInitialDate);
......
...@@ -4,8 +4,8 @@ import WeeksHeaderSubItemComponent from 'ee/roadmap/components/preset_weeks/week ...@@ -4,8 +4,8 @@ import WeeksHeaderSubItemComponent from 'ee/roadmap/components/preset_weeks/week
import { getTimeframeForWeeksView } from 'ee/roadmap/utils/roadmap_utils'; import { getTimeframeForWeeksView } from 'ee/roadmap/utils/roadmap_utils';
import { PRESET_TYPES } from 'ee/roadmap/constants'; import { PRESET_TYPES } from 'ee/roadmap/constants';
import mountComponent from 'spec/helpers/vue_mount_component_helper'; import mountComponent from 'helpers/vue_mount_component_helper';
import { mockTimeframeInitialDate } from 'ee_spec/roadmap/mock_data'; import { mockTimeframeInitialDate } from '../../mock_data';
const mockTimeframeWeeks = getTimeframeForWeeksView(mockTimeframeInitialDate); const mockTimeframeWeeks = getTimeframeForWeeksView(mockTimeframeInitialDate);
......
...@@ -8,7 +8,7 @@ import { getTimeframeForMonthsView } from 'ee/roadmap/utils/roadmap_utils'; ...@@ -8,7 +8,7 @@ import { getTimeframeForMonthsView } from 'ee/roadmap/utils/roadmap_utils';
import { PRESET_TYPES, EXTEND_AS } from 'ee/roadmap/constants'; import { PRESET_TYPES, EXTEND_AS } from 'ee/roadmap/constants';
import { mountComponentWithStore } from 'spec/helpers/vue_mount_component_helper'; import { mountComponentWithStore } from 'helpers/vue_mount_component_helper';
import { import {
mockTimeframeInitialDate, mockTimeframeInitialDate,
mockGroupId, mockGroupId,
...@@ -18,7 +18,7 @@ import { ...@@ -18,7 +18,7 @@ import {
mockSortedBy, mockSortedBy,
basePath, basePath,
epicsPath, epicsPath,
} from '../mock_data'; } from 'ee_jest/roadmap/mock_data';
const mockTimeframeMonths = getTimeframeForMonthsView(mockTimeframeInitialDate); const mockTimeframeMonths = getTimeframeForMonthsView(mockTimeframeInitialDate);
...@@ -115,50 +115,43 @@ describe('Roadmap AppComponent', () => { ...@@ -115,50 +115,43 @@ describe('Roadmap AppComponent', () => {
describe('methods', () => { describe('methods', () => {
describe('processExtendedTimeline', () => { describe('processExtendedTimeline', () => {
it('updates timeline by extending timeframe from the start when called with extendType as `prepend`', done => { it('updates timeline by extending timeframe from the start when called with extendType as `prepend`', () => {
vm.$store.dispatch('receiveEpicsSuccess', { rawEpics }); vm.$store.dispatch('receiveEpicsSuccess', { rawEpics });
vm.$store.state.epicsFetchInProgress = false; vm.$store.state.epicsFetchInProgress = false;
Vue.nextTick() return Vue.nextTick().then(() => {
.then(() => { const roadmapTimelineEl = vm.$el.querySelector('.roadmap-timeline-section');
const roadmapTimelineEl = vm.$el.querySelector('.roadmap-timeline-section');
spyOn(eventHub, '$emit'); jest.spyOn(eventHub, '$emit').mockImplementation(() => {});
spyOn(roadmapTimelineEl.parentElement, 'scrollBy');
vm.processExtendedTimeline({ vm.processExtendedTimeline({
extendType: EXTEND_AS.PREPEND, extendType: EXTEND_AS.PREPEND,
roadmapTimelineEl, roadmapTimelineEl,
itemsCount: 0, itemsCount: 0,
}); });
expect(eventHub.$emit).toHaveBeenCalledWith('refreshTimeline', jasmine.any(Object)); expect(eventHub.$emit).toHaveBeenCalledWith('refreshTimeline', expect.any(Object));
expect(roadmapTimelineEl.parentElement.scrollBy).toHaveBeenCalled(); expect(roadmapTimelineEl.parentElement.scrollBy).toHaveBeenCalled();
}) });
.then(done)
.catch(done.fail);
}); });
it('updates timeline by extending timeframe from the end when called with extendType as `append`', done => { it('updates timeline by extending timeframe from the end when called with extendType as `append`', () => {
vm.$store.dispatch('receiveEpicsSuccess', { rawEpics }); vm.$store.dispatch('receiveEpicsSuccess', { rawEpics });
vm.$store.state.epicsFetchInProgress = false; vm.$store.state.epicsFetchInProgress = false;
Vue.nextTick() return Vue.nextTick().then(() => {
.then(() => { const roadmapTimelineEl = vm.$el.querySelector('.roadmap-timeline-section');
const roadmapTimelineEl = vm.$el.querySelector('.roadmap-timeline-section');
spyOn(eventHub, '$emit'); jest.spyOn(eventHub, '$emit').mockImplementation(() => {});
vm.processExtendedTimeline({ vm.processExtendedTimeline({
extendType: EXTEND_AS.PREPEND, extendType: EXTEND_AS.PREPEND,
roadmapTimelineEl, roadmapTimelineEl,
itemsCount: 0, itemsCount: 0,
}); });
expect(eventHub.$emit).toHaveBeenCalledWith('refreshTimeline', jasmine.any(Object)); expect(eventHub.$emit).toHaveBeenCalledWith('refreshTimeline', expect.any(Object));
}) });
.then(done)
.catch(done.fail);
}); });
}); });
...@@ -172,10 +165,10 @@ describe('Roadmap AppComponent', () => { ...@@ -172,10 +165,10 @@ describe('Roadmap AppComponent', () => {
}); });
it('updates the store and refreshes roadmap with extended timeline based on provided extendType', () => { it('updates the store and refreshes roadmap with extended timeline based on provided extendType', () => {
spyOn(vm, 'extendTimeframe'); jest.spyOn(vm, 'extendTimeframe').mockImplementation(() => {});
spyOn(vm, 'refreshEpicDates'); jest.spyOn(vm, 'refreshEpicDates').mockImplementation(() => {});
spyOn(vm, 'refreshMilestoneDates'); jest.spyOn(vm, 'refreshMilestoneDates').mockImplementation(() => {});
spyOn(vm, 'fetchEpicsForTimeframe').and.callFake(() => new Promise(() => {})); jest.spyOn(vm, 'fetchEpicsForTimeframe').mockResolvedValue();
const extendType = EXTEND_AS.PREPEND; const extendType = EXTEND_AS.PREPEND;
...@@ -186,26 +179,23 @@ describe('Roadmap AppComponent', () => { ...@@ -186,26 +179,23 @@ describe('Roadmap AppComponent', () => {
expect(vm.refreshMilestoneDates).toHaveBeenCalled(); expect(vm.refreshMilestoneDates).toHaveBeenCalled();
}); });
it('calls `fetchEpicsForTimeframe` with extended timeframe array', done => { it('calls `fetchEpicsForTimeframe` with extended timeframe array', () => {
spyOn(vm, 'extendTimeframe').and.stub(); jest.spyOn(vm, 'extendTimeframe').mockImplementation(() => {});
spyOn(vm, 'refreshEpicDates').and.stub(); jest.spyOn(vm, 'refreshEpicDates').mockImplementation(() => {});
spyOn(vm, 'refreshMilestoneDates').and.stub(); jest.spyOn(vm, 'refreshMilestoneDates').mockImplementation(() => {});
spyOn(vm, 'fetchEpicsForTimeframe').and.callFake(() => new Promise(() => {})); jest.spyOn(vm, 'fetchEpicsForTimeframe').mockResolvedValue();
const extendType = EXTEND_AS.PREPEND; const extendType = EXTEND_AS.PREPEND;
vm.handleScrollToExtend(roadmapTimelineEl, extendType); vm.handleScrollToExtend(roadmapTimelineEl, extendType);
vm.$nextTick() return vm.$nextTick().then(() => {
.then(() => { expect(vm.fetchEpicsForTimeframe).toHaveBeenCalledWith(
expect(vm.fetchEpicsForTimeframe).toHaveBeenCalledWith( expect.objectContaining({
jasmine.objectContaining({ timeframe: vm.extendedTimeframe,
timeframe: vm.extendedTimeframe, }),
}), );
); });
})
.then(done)
.catch(done.fail);
}); });
}); });
}); });
...@@ -215,15 +205,13 @@ describe('Roadmap AppComponent', () => { ...@@ -215,15 +205,13 @@ describe('Roadmap AppComponent', () => {
expect(vm.$el.classList.contains('roadmap-container')).toBe(true); expect(vm.$el.classList.contains('roadmap-container')).toBe(true);
}); });
it('renders roadmap container with classes `roadmap-container overflow-reset` when isEpicsListEmpty prop is true', done => { it('renders roadmap container with classes `roadmap-container overflow-reset` when isEpicsListEmpty prop is true', () => {
vm.$store.state.epicsFetchResultEmpty = true; vm.$store.state.epicsFetchResultEmpty = true;
Vue.nextTick()
.then(() => { return Vue.nextTick().then(() => {
expect(vm.$el.classList.contains('roadmap-container')).toBe(true); expect(vm.$el.classList.contains('roadmap-container')).toBe(true);
expect(vm.$el.classList.contains('overflow-reset')).toBe(true); expect(vm.$el.classList.contains('overflow-reset')).toBe(true);
}) });
.then(done)
.catch(done.fail);
}); });
}); });
}); });
...@@ -7,8 +7,13 @@ import { getTimeframeForMonthsView } from 'ee/roadmap/utils/roadmap_utils'; ...@@ -7,8 +7,13 @@ import { getTimeframeForMonthsView } from 'ee/roadmap/utils/roadmap_utils';
import { PRESET_TYPES } from 'ee/roadmap/constants'; import { PRESET_TYPES } from 'ee/roadmap/constants';
import { mountComponentWithStore } from 'spec/helpers/vue_mount_component_helper'; import { mountComponentWithStore } from 'helpers/vue_mount_component_helper';
import { mockEpic, mockTimeframeInitialDate, mockGroupId, mockMilestone } from '../mock_data'; import {
mockEpic,
mockTimeframeInitialDate,
mockGroupId,
mockMilestone,
} from 'ee_jest/roadmap/mock_data';
const mockTimeframeMonths = getTimeframeForMonthsView(mockTimeframeInitialDate); const mockTimeframeMonths = getTimeframeForMonthsView(mockTimeframeInitialDate);
...@@ -73,13 +78,13 @@ describe('RoadmapShellComponent', () => { ...@@ -73,13 +78,13 @@ describe('RoadmapShellComponent', () => {
describe('handleScroll', () => { describe('handleScroll', () => {
it('emits `epicsListScrolled` event via eventHub', done => { it('emits `epicsListScrolled` event via eventHub', done => {
const vmWithParentEl = createComponent({}, document.getElementById('roadmap-shell')); const vmWithParentEl = createComponent({}, document.getElementById('roadmap-shell'));
spyOn(eventHub, '$emit'); jest.spyOn(eventHub, '$emit').mockImplementation(() => {});
Vue.nextTick() Vue.nextTick()
.then(() => { .then(() => {
vmWithParentEl.handleScroll(); vmWithParentEl.handleScroll();
expect(eventHub.$emit).toHaveBeenCalledWith('epicsListScrolled', jasmine.any(Object)); expect(eventHub.$emit).toHaveBeenCalledWith('epicsListScrolled', expect.any(Object));
vmWithParentEl.$destroy(); vmWithParentEl.$destroy();
}) })
......
...@@ -6,8 +6,8 @@ import { getTimeframeForMonthsView } from 'ee/roadmap/utils/roadmap_utils'; ...@@ -6,8 +6,8 @@ import { getTimeframeForMonthsView } from 'ee/roadmap/utils/roadmap_utils';
import { PRESET_TYPES } from 'ee/roadmap/constants'; import { PRESET_TYPES } from 'ee/roadmap/constants';
import mountComponent from 'spec/helpers/vue_mount_component_helper'; import mountComponent from 'helpers/vue_mount_component_helper';
import { mockEpic, mockTimeframeInitialDate } from '../mock_data'; import { mockEpic, mockTimeframeInitialDate } from 'ee_jest/roadmap/mock_data';
const mockTimeframeMonths = getTimeframeForMonthsView(mockTimeframeInitialDate); const mockTimeframeMonths = getTimeframeForMonthsView(mockTimeframeInitialDate);
...@@ -46,7 +46,7 @@ describe('RoadmapTimelineSectionComponent', () => { ...@@ -46,7 +46,7 @@ describe('RoadmapTimelineSectionComponent', () => {
describe('sectionContainerStyles', () => { describe('sectionContainerStyles', () => {
it('returns object containing `width` with value based on epic details cell width, timeline cell width and timeframe length', () => { it('returns object containing `width` with value based on epic details cell width, timeline cell width and timeframe length', () => {
expect(vm.sectionContainerStyles).toEqual( expect(vm.sectionContainerStyles).toEqual(
jasmine.objectContaining({ expect.objectContaining({
width: '1760px', width: '1760px',
}), }),
); );
...@@ -73,21 +73,21 @@ describe('RoadmapTimelineSectionComponent', () => { ...@@ -73,21 +73,21 @@ describe('RoadmapTimelineSectionComponent', () => {
describe('mounted', () => { describe('mounted', () => {
it('binds `epicsListScrolled` event listener via eventHub', () => { it('binds `epicsListScrolled` event listener via eventHub', () => {
spyOn(eventHub, '$on'); jest.spyOn(eventHub, '$on').mockImplementation(() => {});
const vmX = createComponent({}); const vmX = createComponent({});
expect(eventHub.$on).toHaveBeenCalledWith('epicsListScrolled', jasmine.any(Function)); expect(eventHub.$on).toHaveBeenCalledWith('epicsListScrolled', expect.any(Function));
vmX.$destroy(); vmX.$destroy();
}); });
}); });
describe('beforeDestroy', () => { describe('beforeDestroy', () => {
it('unbinds `epicsListScrolled` event listener via eventHub', () => { it('unbinds `epicsListScrolled` event listener via eventHub', () => {
spyOn(eventHub, '$off'); jest.spyOn(eventHub, '$off').mockImplementation(() => {});
const vmX = createComponent({}); const vmX = createComponent({});
vmX.$destroy(); vmX.$destroy();
expect(eventHub.$off).toHaveBeenCalledWith('epicsListScrolled', jasmine.any(Function)); expect(eventHub.$off).toHaveBeenCalledWith('epicsListScrolled', expect.any(Function));
}); });
}); });
......
...@@ -5,8 +5,8 @@ import { getTimeframeForMonthsView } from 'ee/roadmap/utils/roadmap_utils'; ...@@ -5,8 +5,8 @@ import { getTimeframeForMonthsView } from 'ee/roadmap/utils/roadmap_utils';
import { PRESET_TYPES } from 'ee/roadmap/constants'; import { PRESET_TYPES } from 'ee/roadmap/constants';
import mountComponent from 'spec/helpers/vue_mount_component_helper'; import mountComponent from 'helpers/vue_mount_component_helper';
import { mockTimeframeInitialDate, mockEpic } from '../mock_data'; import { mockTimeframeInitialDate, mockEpic } from 'ee_jest/roadmap/mock_data';
const mockTimeframeMonths = getTimeframeForMonthsView(mockTimeframeInitialDate); const mockTimeframeMonths = getTimeframeForMonthsView(mockTimeframeInitialDate);
......
...@@ -5,8 +5,8 @@ import { getTimeframeForQuartersView } from 'ee/roadmap/utils/roadmap_utils'; ...@@ -5,8 +5,8 @@ import { getTimeframeForQuartersView } from 'ee/roadmap/utils/roadmap_utils';
import { PRESET_TYPES } from 'ee/roadmap/constants'; import { PRESET_TYPES } from 'ee/roadmap/constants';
import mountComponent from 'spec/helpers/vue_mount_component_helper'; import mountComponent from 'helpers/vue_mount_component_helper';
import { mockTimeframeInitialDate, mockEpic } from '../mock_data'; import { mockTimeframeInitialDate, mockEpic } from 'ee_jest/roadmap/mock_data';
const mockTimeframeQuarters = getTimeframeForQuartersView(mockTimeframeInitialDate); const mockTimeframeQuarters = getTimeframeForQuartersView(mockTimeframeInitialDate);
......
...@@ -5,8 +5,8 @@ import { getTimeframeForWeeksView } from 'ee/roadmap/utils/roadmap_utils'; ...@@ -5,8 +5,8 @@ import { getTimeframeForWeeksView } from 'ee/roadmap/utils/roadmap_utils';
import { PRESET_TYPES } from 'ee/roadmap/constants'; import { PRESET_TYPES } from 'ee/roadmap/constants';
import mountComponent from 'spec/helpers/vue_mount_component_helper'; import mountComponent from 'helpers/vue_mount_component_helper';
import { mockTimeframeInitialDate, mockEpic } from '../mock_data'; import { mockTimeframeInitialDate, mockEpic } from 'ee_jest/roadmap/mock_data';
const mockTimeframeWeeks = getTimeframeForWeeksView(mockTimeframeInitialDate); const mockTimeframeWeeks = getTimeframeForWeeksView(mockTimeframeInitialDate);
......
...@@ -3,7 +3,7 @@ import * as types from 'ee/roadmap/store/mutation_types'; ...@@ -3,7 +3,7 @@ import * as types from 'ee/roadmap/store/mutation_types';
import defaultState from 'ee/roadmap/store/state'; import defaultState from 'ee/roadmap/store/state';
import { mockGroupId, basePath, epicsPath, mockSortedBy } from '../mock_data'; import { mockGroupId, basePath, epicsPath, mockSortedBy } from 'ee_jest/roadmap/mock_data';
const getEpic = (epicId, epics) => epics.find(e => e.id === epicId); const getEpic = (epicId, epics) => epics.find(e => e.id === epicId);
...@@ -36,7 +36,7 @@ describe('Roadmap Store Mutations', () => { ...@@ -36,7 +36,7 @@ describe('Roadmap Store Mutations', () => {
mutations[types.SET_INITIAL_DATA](state, initialData); mutations[types.SET_INITIAL_DATA](state, initialData);
expect(state).toEqual(jasmine.objectContaining(initialData)); expect(state).toEqual(expect.objectContaining(initialData));
}); });
}); });
......
...@@ -9,7 +9,7 @@ describe('extractGroupEpics', () => { ...@@ -9,7 +9,7 @@ describe('extractGroupEpics', () => {
expect(extractedEpics.length).toBe(edges.length); expect(extractedEpics.length).toBe(edges.length);
expect(extractedEpics[0]).toEqual( expect(extractedEpics[0]).toEqual(
jasmine.objectContaining({ expect.objectContaining({
...edges[0].node, ...edges[0].node,
groupName: edges[0].node.group.name, groupName: edges[0].node.group.name,
groupFullName: edges[0].node.group.fullName, groupFullName: edges[0].node.group.fullName,
......
...@@ -43,8 +43,8 @@ describe('getTimeframeForQuartersView', () => { ...@@ -43,8 +43,8 @@ describe('getTimeframeForQuartersView', () => {
it('each timeframe item has `quarterSequence`, `year` and `range` present', () => { it('each timeframe item has `quarterSequence`, `year` and `range` present', () => {
const timeframeItem = timeframe[0]; const timeframeItem = timeframe[0];
expect(timeframeItem.quarterSequence).toEqual(jasmine.any(Number)); expect(timeframeItem.quarterSequence).toEqual(expect.any(Number));
expect(timeframeItem.year).toEqual(jasmine.any(Number)); expect(timeframeItem.year).toEqual(expect.any(Number));
expect(Array.isArray(timeframeItem.range)).toBe(true); expect(Array.isArray(timeframeItem.range)).toBe(true);
}); });
...@@ -307,7 +307,7 @@ describe('getEpicsTimeframeRange', () => { ...@@ -307,7 +307,7 @@ describe('getEpicsTimeframeRange', () => {
}); });
expect(range).toEqual( expect(range).toEqual(
jasmine.objectContaining({ expect.objectContaining({
startDate: '2017-7-1', startDate: '2017-7-1',
dueDate: '2019-3-31', dueDate: '2019-3-31',
}), }),
...@@ -322,7 +322,7 @@ describe('getEpicsTimeframeRange', () => { ...@@ -322,7 +322,7 @@ describe('getEpicsTimeframeRange', () => {
}); });
expect(range).toEqual( expect(range).toEqual(
jasmine.objectContaining({ expect.objectContaining({
startDate: '2017-11-1', startDate: '2017-11-1',
dueDate: '2018-6-30', dueDate: '2018-6-30',
}), }),
...@@ -337,7 +337,7 @@ describe('getEpicsTimeframeRange', () => { ...@@ -337,7 +337,7 @@ describe('getEpicsTimeframeRange', () => {
}); });
expect(range).toEqual( expect(range).toEqual(
jasmine.objectContaining({ expect.objectContaining({
startDate: '2017-12-17', startDate: '2017-12-17',
dueDate: '2018-2-3', dueDate: '2018-2-3',
}), }),
......
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