Commit 422219de authored by Ezekiel Kigbo's avatar Ezekiel Kigbo

Fix broken jest specs

parent ffa2b3a8
...@@ -42,18 +42,8 @@ describe('Cycle analytics actions', () => { ...@@ -42,18 +42,8 @@ describe('Cycle analytics actions', () => {
let state; let state;
let mock; let mock;
function shouldSetUrlParams({ action, payload, result }) { function shouldFlashAMessage(msg = flashErrorMessage) {
const store = { expect(document.querySelector('.flash-container .flash-text').innerText.trim()).toBe(msg);
state,
getters,
commit: jest.fn(),
dispatch: jest.fn(() => Promise.resolve()),
};
return actions[action](store, payload).then(() => {
expect(urlUtils.setUrlParams).toHaveBeenCalledWith(result, window.location.href, true);
expect(commonUtils.historyPushState).toHaveBeenCalled();
});
} }
beforeEach(() => { beforeEach(() => {
...@@ -99,61 +89,10 @@ describe('Cycle analytics actions', () => { ...@@ -99,61 +89,10 @@ describe('Cycle analytics actions', () => {
); );
}); });
describe('setSelectedGroup', () => {
const payload = { full_path: 'someNewGroup' };
it('calls setUrlParams with the group params', () => {
actions.setSelectedGroup(
{
state,
getters: {
currentGroupPath: 'someNewGroup',
selectedProjectIds: [],
},
commit: jest.fn(),
},
payload,
);
expect(urlUtils.setUrlParams).toHaveBeenCalledWith(
{
group_id: 'someNewGroup',
'project_ids[]': [],
},
window.location.href,
true,
);
expect(commonUtils.historyPushState).toHaveBeenCalled();
});
});
describe('setSelectedProjects', () => {
const payload = [1, 2];
it('calls setUrlParams with the date params', () => {
actions.setSelectedProjects(
{
state,
getters: {
currentGroupPath: 'test-group',
selectedProjectIds: payload,
},
commit: jest.fn(),
},
payload,
);
expect(urlUtils.setUrlParams).toHaveBeenCalledWith(
{ 'project_ids[]': payload, group_id: 'test-group' },
window.location.href,
true,
);
expect(commonUtils.historyPushState).toHaveBeenCalled();
});
});
describe('setDateRange', () => { describe('setDateRange', () => {
const payload = { startDate, endDate }; const payload = { startDate, endDate };
it('sets the dates as expected and dispatches fetchCycleAnalyticsData', done => { it('dispatches the fetchCycleAnalyticsData action', done => {
testAction( testAction(
actions.setDateRange, actions.setDateRange,
payload, payload,
...@@ -163,19 +102,6 @@ describe('Cycle analytics actions', () => { ...@@ -163,19 +102,6 @@ describe('Cycle analytics actions', () => {
done, done,
); );
}); });
it('calls setUrlParams with the date params', () => {
shouldSetUrlParams({
action: 'setDateRange',
payload,
result: {
group_id: getters.currentGroupPath,
'project_ids[]': getters.selectedProjectIds,
created_after: toYmd(payload.startDate),
created_before: toYmd(payload.endDate),
},
});
});
}); });
describe('fetchStageData', () => { describe('fetchStageData', () => {
......
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