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

Fix broken jest specs

parent ffa2b3a8
......@@ -42,18 +42,8 @@ describe('Cycle analytics actions', () => {
let state;
let mock;
function shouldSetUrlParams({ action, payload, result }) {
const store = {
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();
});
function shouldFlashAMessage(msg = flashErrorMessage) {
expect(document.querySelector('.flash-container .flash-text').innerText.trim()).toBe(msg);
}
beforeEach(() => {
......@@ -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', () => {
const payload = { startDate, endDate };
it('sets the dates as expected and dispatches fetchCycleAnalyticsData', done => {
it('dispatches the fetchCycleAnalyticsData action', done => {
testAction(
actions.setDateRange,
payload,
......@@ -163,19 +102,6 @@ describe('Cycle analytics actions', () => {
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', () => {
......
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