Commit 3112fdb6 authored by Natalia Tepluhina's avatar Natalia Tepluhina

Merge branch 'vs/ee-remove-jest-test-callback' into 'master'

Remove Jest test callback in EE specs

See merge request gitlab-org/gitlab!84181
parents 25be580b a0cc00ea
--- ---
extends: ../../../spec/frontend/.eslintrc.yml extends: ../../../spec/frontend/.eslintrc.yml
rules:
jest/no-test-callback: error
...@@ -91,8 +91,8 @@ describe('Code review analytics mergeRequests actions', () => { ...@@ -91,8 +91,8 @@ describe('Code review analytics mergeRequests actions', () => {
mock.onGet(/api\/(.*)\/analytics\/code_review/).replyOnce(500); mock.onGet(/api\/(.*)\/analytics\/code_review/).replyOnce(500);
}); });
it('dispatches error', (done) => { it('dispatches error', async () => {
testAction( await testAction(
actions.fetchMergeRequests, actions.fetchMergeRequests,
null, null,
state, state,
...@@ -104,11 +104,9 @@ describe('Code review analytics mergeRequests actions', () => { ...@@ -104,11 +104,9 @@ describe('Code review analytics mergeRequests actions', () => {
}, },
], ],
[], [],
() => {
expect(createFlash).toHaveBeenCalled();
done();
},
); );
expect(createFlash).toHaveBeenCalled();
}); });
}); });
}); });
......
...@@ -5,7 +5,7 @@ import testAction from 'helpers/vuex_action_helper'; ...@@ -5,7 +5,7 @@ import testAction from 'helpers/vuex_action_helper';
describe('Productivity analytics actions', () => { describe('Productivity analytics actions', () => {
describe('setEndpoint', () => { describe('setEndpoint', () => {
it('commits the SET_ENDPOINT mutation', (done) => it('commits the SET_ENDPOINT mutation', async () =>
testAction( testAction(
actions.setEndpoint, actions.setEndpoint,
'endpoint.json', 'endpoint.json',
...@@ -17,7 +17,6 @@ describe('Productivity analytics actions', () => { ...@@ -17,7 +17,6 @@ describe('Productivity analytics actions', () => {
}, },
], ],
[], [],
done,
)); ));
}); });
}); });
...@@ -72,7 +72,7 @@ describe('Productivity analytics chart actions', () => { ...@@ -72,7 +72,7 @@ describe('Productivity analytics chart actions', () => {
expect(axios.get).toHaveBeenCalledWith(mockedState.endpoint, { params: globalParams }); expect(axios.get).toHaveBeenCalledWith(mockedState.endpoint, { params: globalParams });
}); });
it('dispatches success with received data', (done) => it('dispatches success with received data', async () =>
testAction( testAction(
actions.fetchChartData, actions.fetchChartData,
chartKey, chartKey,
...@@ -85,7 +85,6 @@ describe('Productivity analytics chart actions', () => { ...@@ -85,7 +85,6 @@ describe('Productivity analytics chart actions', () => {
payload: expect.objectContaining({ chartKey, data: mockHistogramData }), payload: expect.objectContaining({ chartKey, data: mockHistogramData }),
}, },
], ],
done,
)); ));
}); });
...@@ -94,8 +93,8 @@ describe('Productivity analytics chart actions', () => { ...@@ -94,8 +93,8 @@ describe('Productivity analytics chart actions', () => {
mock.onGet(mockedState.endpoint).replyOnce(200, mockScatterplotData); mock.onGet(mockedState.endpoint).replyOnce(200, mockScatterplotData);
}); });
it('dispatches success with received data and transformedData', (done) => { it('dispatches success with received data and transformedData', async () => {
testAction( await testAction(
actions.fetchChartData, actions.fetchChartData,
chartKeys.scatterplot, chartKeys.scatterplot,
mockedState, mockedState,
...@@ -111,7 +110,6 @@ describe('Productivity analytics chart actions', () => { ...@@ -111,7 +110,6 @@ describe('Productivity analytics chart actions', () => {
}, },
}, },
], ],
done,
); );
}); });
}); });
...@@ -122,8 +120,8 @@ describe('Productivity analytics chart actions', () => { ...@@ -122,8 +120,8 @@ describe('Productivity analytics chart actions', () => {
mock.onGet(mockedState.endpoint).replyOnce(500); mock.onGet(mockedState.endpoint).replyOnce(500);
}); });
it('dispatches error', (done) => { it('dispatches error', async () => {
testAction( await testAction(
actions.fetchChartData, actions.fetchChartData,
chartKey, chartKey,
mockedState, mockedState,
...@@ -141,7 +139,6 @@ describe('Productivity analytics chart actions', () => { ...@@ -141,7 +139,6 @@ describe('Productivity analytics chart actions', () => {
}, },
}, },
], ],
done,
); );
}); });
}); });
...@@ -149,14 +146,13 @@ describe('Productivity analytics chart actions', () => { ...@@ -149,14 +146,13 @@ describe('Productivity analytics chart actions', () => {
}); });
describe('requestChartData', () => { describe('requestChartData', () => {
it('should commit the request mutation', (done) => { it('should commit the request mutation', async () => {
testAction( await testAction(
actions.requestChartData, actions.requestChartData,
chartKey, chartKey,
mockedContext.state, mockedContext.state,
[{ type: types.REQUEST_CHART_DATA, payload: chartKey }], [{ type: types.REQUEST_CHART_DATA, payload: chartKey }],
[], [],
done,
); );
}); });
...@@ -167,8 +163,8 @@ describe('Productivity analytics chart actions', () => { ...@@ -167,8 +163,8 @@ describe('Productivity analytics chart actions', () => {
mockedState.charts[disabledChartKey].enabled = false; mockedState.charts[disabledChartKey].enabled = false;
}); });
it('does not dispatch the requestChartData action', (done) => { it('does not dispatch the requestChartData action', async () => {
testAction(actions.fetchChartData, disabledChartKey, mockedState, [], [], done); await testAction(actions.fetchChartData, disabledChartKey, mockedState, [], []);
}); });
it('does not call the API', () => { it('does not call the API', () => {
...@@ -180,8 +176,8 @@ describe('Productivity analytics chart actions', () => { ...@@ -180,8 +176,8 @@ describe('Productivity analytics chart actions', () => {
}); });
describe('receiveChartDataSuccess', () => { describe('receiveChartDataSuccess', () => {
it('should commit received data', (done) => { it('should commit received data', async () => {
testAction( await testAction(
actions.receiveChartDataSuccess, actions.receiveChartDataSuccess,
{ chartKey, data: mockHistogramData }, { chartKey, data: mockHistogramData },
mockedContext.state, mockedContext.state,
...@@ -192,15 +188,14 @@ describe('Productivity analytics chart actions', () => { ...@@ -192,15 +188,14 @@ describe('Productivity analytics chart actions', () => {
}, },
], ],
[], [],
done,
); );
}); });
}); });
describe('receiveChartDataError', () => { describe('receiveChartDataError', () => {
it('should commit error', (done) => { it('should commit error', async () => {
const error = { response: { status: 500 } }; const error = { response: { status: 500 } };
testAction( await testAction(
actions.receiveChartDataError, actions.receiveChartDataError,
{ chartKey, error }, { chartKey, error },
mockedContext.state, mockedContext.state,
...@@ -214,14 +209,13 @@ describe('Productivity analytics chart actions', () => { ...@@ -214,14 +209,13 @@ describe('Productivity analytics chart actions', () => {
}, },
], ],
[], [],
done,
); );
}); });
}); });
describe('fetchSecondaryChartData', () => { describe('fetchSecondaryChartData', () => {
it('dispatches fetchChartData for all chart types except for the main chart', (done) => { it('dispatches fetchChartData for all chart types except for the main chart', async () => {
testAction( await testAction(
actions.fetchSecondaryChartData, actions.fetchSecondaryChartData,
null, null,
mockedContext.state, mockedContext.state,
...@@ -231,7 +225,6 @@ describe('Productivity analytics chart actions', () => { ...@@ -231,7 +225,6 @@ describe('Productivity analytics chart actions', () => {
{ type: 'fetchChartData', payload: chartKeys.commitBasedHistogram }, { type: 'fetchChartData', payload: chartKeys.commitBasedHistogram },
{ type: 'fetchChartData', payload: chartKeys.scatterplot }, { type: 'fetchChartData', payload: chartKeys.scatterplot },
], ],
done,
); );
}); });
}); });
...@@ -239,48 +232,45 @@ describe('Productivity analytics chart actions', () => { ...@@ -239,48 +232,45 @@ describe('Productivity analytics chart actions', () => {
describe('setMetricType', () => { describe('setMetricType', () => {
const metricType = 'time_to_merge'; const metricType = 'time_to_merge';
it('should commit metricType', (done) => { it('should commit metricType', async () => {
testAction( await testAction(
actions.setMetricType, actions.setMetricType,
{ chartKey, metricType }, { chartKey, metricType },
mockedContext.state, mockedContext.state,
[{ type: types.SET_METRIC_TYPE, payload: { chartKey, metricType } }], [{ type: types.SET_METRIC_TYPE, payload: { chartKey, metricType } }],
[{ type: 'fetchChartData', payload: chartKey }], [{ type: 'fetchChartData', payload: chartKey }],
done,
); );
}); });
}); });
describe('updateSelectedItems', () => { describe('updateSelectedItems', () => {
it('should commit selected chart item and dispatch fetchSecondaryChartData and setPage', (done) => { it('should commit selected chart item and dispatch fetchSecondaryChartData and setPage', async () => {
testAction( await testAction(
actions.updateSelectedItems, actions.updateSelectedItems,
{ chartKey, item: 5 }, { chartKey, item: 5 },
mockedContext.state, mockedContext.state,
[{ type: types.UPDATE_SELECTED_CHART_ITEMS, payload: { chartKey, item: 5 } }], [{ type: types.UPDATE_SELECTED_CHART_ITEMS, payload: { chartKey, item: 5 } }],
[{ type: 'fetchSecondaryChartData' }, { type: 'table/setPage', payload: 0 }], [{ type: 'fetchSecondaryChartData' }, { type: 'table/setPage', payload: 0 }],
done,
); );
}); });
}); });
describe('resetMainChartSelection', () => { describe('resetMainChartSelection', () => {
describe('when skipReload is false (by default)', () => { describe('when skipReload is false (by default)', () => {
it('should commit selected chart item and dispatch fetchSecondaryChartData and setPage', (done) => { it('should commit selected chart item and dispatch fetchSecondaryChartData and setPage', async () => {
testAction( await testAction(
actions.resetMainChartSelection, actions.resetMainChartSelection,
null, null,
mockedContext.state, mockedContext.state,
[{ type: types.UPDATE_SELECTED_CHART_ITEMS, payload: { chartKey, item: null } }], [{ type: types.UPDATE_SELECTED_CHART_ITEMS, payload: { chartKey, item: null } }],
[{ type: 'fetchSecondaryChartData' }, { type: 'table/setPage', payload: 0 }], [{ type: 'fetchSecondaryChartData' }, { type: 'table/setPage', payload: 0 }],
done,
); );
}); });
}); });
describe('when skipReload is true', () => { describe('when skipReload is true', () => {
it('should commit selected chart and it should not dispatch any further actions', (done) => { it('should commit selected chart and it should not dispatch any further actions', async () => {
testAction( await testAction(
actions.resetMainChartSelection, actions.resetMainChartSelection,
true, true,
mockedContext.state, mockedContext.state,
...@@ -291,15 +281,14 @@ describe('Productivity analytics chart actions', () => { ...@@ -291,15 +281,14 @@ describe('Productivity analytics chart actions', () => {
}, },
], ],
[], [],
done,
); );
}); });
}); });
}); });
describe('setChartEnabled', () => { describe('setChartEnabled', () => {
it('should commit enabled state', (done) => { it('should commit enabled state', async () => {
testAction( await testAction(
actions.setChartEnabled, actions.setChartEnabled,
{ chartKey: chartKeys.scatterplot, isEnabled: false }, { chartKey: chartKeys.scatterplot, isEnabled: false },
mockedContext.state, mockedContext.state,
...@@ -310,7 +299,6 @@ describe('Productivity analytics chart actions', () => { ...@@ -310,7 +299,6 @@ describe('Productivity analytics chart actions', () => {
}, },
], ],
[], [],
done,
); );
}); });
}); });
......
...@@ -30,10 +30,8 @@ describe('Productivity analytics filter actions', () => { ...@@ -30,10 +30,8 @@ describe('Productivity analytics filter actions', () => {
}); });
describe('setInitialData', () => { describe('setInitialData', () => {
it('commits the SET_INITIAL_DATA mutation and fetches data by default', (done) => { it('commits the SET_INITIAL_DATA mutation and fetches data by default', async () => {
actions await actions.setInitialData(store, { data: initialData });
.setInitialData(store, { data: initialData })
.then(() => {
expect(store.commit).toHaveBeenCalledWith(types.SET_INITIAL_DATA, initialData); expect(store.commit).toHaveBeenCalledWith(types.SET_INITIAL_DATA, initialData);
expect(store.dispatch.mock.calls[0]).toEqual([ expect(store.dispatch.mock.calls[0]).toEqual([
...@@ -49,12 +47,9 @@ describe('Productivity analytics filter actions', () => { ...@@ -49,12 +47,9 @@ describe('Productivity analytics filter actions', () => {
]); ]);
expect(store.dispatch.mock.calls[2]).toEqual(['table/setPage', 0, { root: true }]); expect(store.dispatch.mock.calls[2]).toEqual(['table/setPage', 0, { root: true }]);
})
.then(done)
.catch(done.fail);
}); });
it("commits the SET_INITIAL_DATA mutation and doesn't fetch data when skipFetch=true", (done) => it("commits the SET_INITIAL_DATA mutation and doesn't fetch data when skipFetch=true", async () =>
testAction( testAction(
actions.setInitialData, actions.setInitialData,
{ skipFetch: true, data: initialData }, { skipFetch: true, data: initialData },
...@@ -66,15 +61,12 @@ describe('Productivity analytics filter actions', () => { ...@@ -66,15 +61,12 @@ describe('Productivity analytics filter actions', () => {
}, },
], ],
[], [],
done,
)); ));
}); });
describe('setGroupNamespace', () => { describe('setGroupNamespace', () => {
it('commits the SET_GROUP_NAMESPACE mutation', (done) => { it('commits the SET_GROUP_NAMESPACE mutation', async () => {
actions await actions.setGroupNamespace(store, groupNamespace);
.setGroupNamespace(store, groupNamespace)
.then(() => {
expect(store.commit).toHaveBeenCalledWith(types.SET_GROUP_NAMESPACE, groupNamespace); expect(store.commit).toHaveBeenCalledWith(types.SET_GROUP_NAMESPACE, groupNamespace);
expect(store.dispatch.mock.calls[0]).toEqual([ expect(store.dispatch.mock.calls[0]).toEqual([
...@@ -96,17 +88,12 @@ describe('Productivity analytics filter actions', () => { ...@@ -96,17 +88,12 @@ describe('Productivity analytics filter actions', () => {
]); ]);
expect(store.dispatch.mock.calls[3]).toEqual(['table/setPage', 0, { root: true }]); expect(store.dispatch.mock.calls[3]).toEqual(['table/setPage', 0, { root: true }]);
})
.then(done)
.catch(done.fail);
}); });
}); });
describe('setProjectPath', () => { describe('setProjectPath', () => {
it('commits the SET_PROJECT_PATH mutation', (done) => { it('commits the SET_PROJECT_PATH mutation', async () => {
actions await actions.setProjectPath(store, projectPath);
.setProjectPath(store, projectPath)
.then(() => {
expect(store.commit).toHaveBeenCalledWith(types.SET_PROJECT_PATH, projectPath); expect(store.commit).toHaveBeenCalledWith(types.SET_PROJECT_PATH, projectPath);
expect(store.dispatch.mock.calls[0]).toEqual([ expect(store.dispatch.mock.calls[0]).toEqual([
...@@ -128,17 +115,12 @@ describe('Productivity analytics filter actions', () => { ...@@ -128,17 +115,12 @@ describe('Productivity analytics filter actions', () => {
]); ]);
expect(store.dispatch.mock.calls[3]).toEqual(['table/setPage', 0, { root: true }]); expect(store.dispatch.mock.calls[3]).toEqual(['table/setPage', 0, { root: true }]);
})
.then(done)
.catch(done.fail);
}); });
}); });
describe('setFilters', () => { describe('setFilters', () => {
it('commits the SET_FILTERS mutation', (done) => { it('commits the SET_FILTERS mutation', async () => {
actions await actions.setFilters(store, { author_username: 'root' });
.setFilters(store, { author_username: 'root' })
.then(() => {
expect(store.commit).toHaveBeenCalledWith(types.SET_FILTERS, { authorUsername: 'root' }); expect(store.commit).toHaveBeenCalledWith(types.SET_FILTERS, { authorUsername: 'root' });
expect(store.dispatch.mock.calls[0]).toEqual([ expect(store.dispatch.mock.calls[0]).toEqual([
...@@ -160,17 +142,12 @@ describe('Productivity analytics filter actions', () => { ...@@ -160,17 +142,12 @@ describe('Productivity analytics filter actions', () => {
]); ]);
expect(store.dispatch.mock.calls[3]).toEqual(['table/setPage', 0, { root: true }]); expect(store.dispatch.mock.calls[3]).toEqual(['table/setPage', 0, { root: true }]);
})
.then(done)
.catch(done.fail);
}); });
}); });
describe('setDateRange', () => { describe('setDateRange', () => {
it('commits the SET_DATE_RANGE mutation', (done) => { it('commits the SET_DATE_RANGE mutation', async () => {
actions await actions.setDateRange(store, { startDate, endDate });
.setDateRange(store, { startDate, endDate })
.then(() => {
expect(store.commit).toHaveBeenCalledWith(types.SET_DATE_RANGE, { startDate, endDate }); expect(store.commit).toHaveBeenCalledWith(types.SET_DATE_RANGE, { startDate, endDate });
expect(store.dispatch.mock.calls[0]).toEqual([ expect(store.dispatch.mock.calls[0]).toEqual([
...@@ -192,9 +169,6 @@ describe('Productivity analytics filter actions', () => { ...@@ -192,9 +169,6 @@ describe('Productivity analytics filter actions', () => {
]); ]);
expect(store.dispatch.mock.calls[3]).toEqual(['table/setPage', 0, { root: true }]); expect(store.dispatch.mock.calls[3]).toEqual(['table/setPage', 0, { root: true }]);
})
.then(done)
.catch(done.fail);
}); });
}); });
}); });
...@@ -104,7 +104,7 @@ describe('Productivity analytics table actions', () => { ...@@ -104,7 +104,7 @@ describe('Productivity analytics table actions', () => {
}); });
}); });
it('dispatches success with received data', (done) => it('dispatches success with received data', async () =>
testAction( testAction(
actions.fetchMergeRequests, actions.fetchMergeRequests,
null, null,
...@@ -117,7 +117,6 @@ describe('Productivity analytics table actions', () => { ...@@ -117,7 +117,6 @@ describe('Productivity analytics table actions', () => {
payload: { data: mockMergeRequests, headers }, payload: { data: mockMergeRequests, headers },
}, },
], ],
done,
)); ));
}); });
...@@ -126,8 +125,8 @@ describe('Productivity analytics table actions', () => { ...@@ -126,8 +125,8 @@ describe('Productivity analytics table actions', () => {
mock.onGet(mockedState.endpoint).replyOnce(500); mock.onGet(mockedState.endpoint).replyOnce(500);
}); });
it('dispatches error', (done) => { it('dispatches error', async () => {
testAction( await testAction(
actions.fetchMergeRequests, actions.fetchMergeRequests,
null, null,
mockedState, mockedState,
...@@ -139,26 +138,24 @@ describe('Productivity analytics table actions', () => { ...@@ -139,26 +138,24 @@ describe('Productivity analytics table actions', () => {
payload: new Error('Request failed with status code 500'), payload: new Error('Request failed with status code 500'),
}, },
], ],
done,
); );
}); });
}); });
}); });
describe('requestMergeRequests', () => { describe('requestMergeRequests', () => {
it('should commit the request mutation', (done) => it('should commit the request mutation', async () =>
testAction( testAction(
actions.requestMergeRequests, actions.requestMergeRequests,
null, null,
mockedContext.state, mockedContext.state,
[{ type: types.REQUEST_MERGE_REQUESTS }], [{ type: types.REQUEST_MERGE_REQUESTS }],
[], [],
done,
)); ));
}); });
describe('receiveMergeRequestsSuccess', () => { describe('receiveMergeRequestsSuccess', () => {
it('should commit received data', (done) => it('should commit received data', async () =>
testAction( testAction(
actions.receiveMergeRequestsSuccess, actions.receiveMergeRequestsSuccess,
{ headers, data: mockMergeRequests }, { headers, data: mockMergeRequests },
...@@ -170,24 +167,22 @@ describe('Productivity analytics table actions', () => { ...@@ -170,24 +167,22 @@ describe('Productivity analytics table actions', () => {
}, },
], ],
[], [],
done,
)); ));
}); });
describe('receiveMergeRequestsError', () => { describe('receiveMergeRequestsError', () => {
it('should commit error', (done) => it('should commit error', async () =>
testAction( testAction(
actions.receiveMergeRequestsError, actions.receiveMergeRequestsError,
{ response: { status: 500 } }, { response: { status: 500 } },
mockedContext.state, mockedContext.state,
[{ type: types.RECEIVE_MERGE_REQUESTS_ERROR, payload: 500 }], [{ type: types.RECEIVE_MERGE_REQUESTS_ERROR, payload: 500 }],
[], [],
done,
)); ));
}); });
describe('setSortField', () => { describe('setSortField', () => {
it('should commit setSortField', (done) => it('should commit setSortField', async () =>
testAction( testAction(
actions.setSortField, actions.setSortField,
'time_to_last_commit', 'time_to_last_commit',
...@@ -197,53 +192,48 @@ describe('Productivity analytics table actions', () => { ...@@ -197,53 +192,48 @@ describe('Productivity analytics table actions', () => {
{ type: 'setColumnMetric', payload: 'time_to_last_commit' }, { type: 'setColumnMetric', payload: 'time_to_last_commit' },
{ type: 'fetchMergeRequests' }, { type: 'fetchMergeRequests' },
], ],
done,
)); ));
it('should not dispatch setColumnMetric when metric is "days_to_merge"', (done) => it('should not dispatch setColumnMetric when metric is "days_to_merge"', async () =>
testAction( testAction(
actions.setSortField, actions.setSortField,
'days_to_merge', 'days_to_merge',
mockedContext.state, mockedContext.state,
[{ type: types.SET_SORT_FIELD, payload: 'days_to_merge' }], [{ type: types.SET_SORT_FIELD, payload: 'days_to_merge' }],
[{ type: 'fetchMergeRequests' }], [{ type: 'fetchMergeRequests' }],
done,
)); ));
}); });
describe('toggleSortOrder', () => { describe('toggleSortOrder', () => {
it('should commit toggleSortOrder', (done) => it('should commit toggleSortOrder', async () =>
testAction( testAction(
actions.toggleSortOrder, actions.toggleSortOrder,
null, null,
mockedContext.state, mockedContext.state,
[{ type: types.TOGGLE_SORT_ORDER }], [{ type: types.TOGGLE_SORT_ORDER }],
[{ type: 'fetchMergeRequests' }], [{ type: 'fetchMergeRequests' }],
done,
)); ));
}); });
describe('setColumnMetric', () => { describe('setColumnMetric', () => {
it('should commit setColumnMetric', (done) => it('should commit setColumnMetric', async () =>
testAction( testAction(
actions.setColumnMetric, actions.setColumnMetric,
'time_to_first_comment', 'time_to_first_comment',
mockedContext.state, mockedContext.state,
[{ type: types.SET_COLUMN_METRIC, payload: 'time_to_first_comment' }], [{ type: types.SET_COLUMN_METRIC, payload: 'time_to_first_comment' }],
[], [],
done,
)); ));
}); });
describe('setPage', () => { describe('setPage', () => {
it('should commit setPage', (done) => it('should commit setPage', async () =>
testAction( testAction(
actions.setPage, actions.setPage,
2, 2,
mockedContext.state, mockedContext.state,
[{ type: types.SET_PAGE, payload: 2 }], [{ type: types.SET_PAGE, payload: 2 }],
[{ type: 'fetchMergeRequests' }], [{ type: 'fetchMergeRequests' }],
done,
)); ));
}); });
}); });
This diff is collapsed.
...@@ -70,6 +70,7 @@ describe('Approvals ApproversSelect', () => { ...@@ -70,6 +70,7 @@ describe('Approvals ApproversSelect', () => {
$input = $(wrapper.vm.$refs.input); $input = $(wrapper.vm.$refs.input);
}; };
const search = (term = '') => { const search = (term = '') => {
$input.select2('search', term); $input.select2('search', term);
jest.runOnlyPendingTimers(); jest.runOnlyPendingTimers();
...@@ -93,37 +94,30 @@ describe('Approvals ApproversSelect', () => { ...@@ -93,37 +94,30 @@ describe('Approvals ApproversSelect', () => {
expect(select2Container()).not.toBe(null); expect(select2Container()).not.toBe(null);
}); });
it('queries and displays groups and users', async (done) => { it('queries and displays groups and users', async () => {
await factory(); await factory();
const expected = TEST_GROUPS.concat(TEST_USERS) const expected = TEST_GROUPS.concat(TEST_USERS)
.map(({ id, ...obj }) => obj) .map(({ id, ...obj }) => obj)
.map(({ username, ...obj }) => (!username ? obj : { ...obj, username: `@${username}` })); .map(({ username, ...obj }) => (!username ? obj : { ...obj, username: `@${username}` }));
waitForEvent($input, 'select2-loaded') search();
.then(() => {
await waitForEvent($input, 'select2-loaded');
const items = select2DropdownItems(); const items = select2DropdownItems();
expect(items).toEqual(expected); expect(items).toEqual(expected);
})
.then(done)
.catch(done.fail);
search();
}); });
describe('with search term', () => { describe('with search term', () => {
const term = 'lorem'; const term = 'lorem';
beforeEach(async (done) => { beforeEach(async () => {
await factory(); await factory();
waitForEvent($input, 'select2-loaded')
.then(jest.runOnlyPendingTimers)
.then(done)
.catch(done.fail);
search(term); search(term);
await waitForEvent($input, 'select2-loaded');
}); });
it('fetches all available groups', () => { it('fetches all available groups', () => {
...@@ -151,14 +145,11 @@ describe('Approvals ApproversSelect', () => { ...@@ -151,14 +145,11 @@ describe('Approvals ApproversSelect', () => {
}); });
}); });
it('fetches all available groups including non-visible shared groups', async (done) => { it('fetches all available groups including non-visible shared groups', async () => {
waitForEvent($input, 'select2-loaded')
.then(jest.runOnlyPendingTimers)
.then(done)
.catch(done.fail);
search(); search();
await waitForEvent($input, 'select2-loaded');
expect(Api.projectGroups).toHaveBeenCalledWith(TEST_PROJECT_ID, { expect(Api.projectGroups).toHaveBeenCalledWith(TEST_PROJECT_ID, {
skip_groups: [], skip_groups: [],
with_shared: true, with_shared: true,
...@@ -172,7 +163,7 @@ describe('Approvals ApproversSelect', () => { ...@@ -172,7 +163,7 @@ describe('Approvals ApproversSelect', () => {
const skipGroupIds = [7, 8]; const skipGroupIds = [7, 8];
const skipUserIds = [9, 10]; const skipUserIds = [9, 10];
beforeEach(async (done) => { beforeEach(async () => {
await factory({ await factory({
propsData: { propsData: {
skipGroupIds, skipGroupIds,
...@@ -180,12 +171,10 @@ describe('Approvals ApproversSelect', () => { ...@@ -180,12 +171,10 @@ describe('Approvals ApproversSelect', () => {
}, },
}); });
waitForEvent($input, 'select2-loaded')
.then(jest.runOnlyPendingTimers)
.then(done)
.catch(done.fail);
search(); search();
await waitForEvent($input, 'select2-loaded');
jest.runOnlyPendingTimers();
}); });
it('skips groups and does not fetch all available', () => { it('skips groups and does not fetch all available', () => {
...@@ -202,7 +191,7 @@ describe('Approvals ApproversSelect', () => { ...@@ -202,7 +191,7 @@ describe('Approvals ApproversSelect', () => {
}); });
}); });
it('emits input when data changes', async (done) => { it('emits input when data changes', async () => {
await factory(); await factory();
const expectedFinal = [ const expectedFinal = [
...@@ -211,24 +200,14 @@ describe('Approvals ApproversSelect', () => { ...@@ -211,24 +200,14 @@ describe('Approvals ApproversSelect', () => {
]; ];
const expected = expectedFinal.map((x, idx) => [expectedFinal.slice(0, idx + 1)]); const expected = expectedFinal.map((x, idx) => [expectedFinal.slice(0, idx + 1)]);
waitForEvent($input, 'select2-loaded') search();
.then(() => {
await waitForPromises();
const options = select2DropdownOptions(); const options = select2DropdownOptions();
$(options[TEST_GROUPS.length]).trigger('mouseup'); $(options[TEST_GROUPS.length]).trigger('mouseup');
$(options[0]).trigger('mouseup'); $(options[0]).trigger('mouseup');
})
.then(jest.runOnlyPendingTimers)
.then(done)
.catch(done.fail);
waitForEvent($input, 'change')
.then(jest.runOnlyPendingTimers)
.then(() => {
expect(wrapper.emitted().input).toEqual(expected);
})
.then(done)
.catch(done.fail);
search(); await waitForPromises();
expect(wrapper.emitted().input).toEqual(expected);
}); });
}); });
...@@ -82,7 +82,7 @@ describe('EE approvals license-compliance actions', () => { ...@@ -82,7 +82,7 @@ describe('EE approvals license-compliance actions', () => {
}); });
describe('postRule', () => { describe('postRule', () => {
it('posts correct data and dispatches "fetchRules" when request is successful', () => { it('posts correct data and dispatches "fetchRules" when request is successful', async () => {
const rule = { const rule = {
name: 'Foo', name: 'Foo',
approvalsRequired: 1, approvalsRequired: 1,
...@@ -91,7 +91,7 @@ describe('EE approvals license-compliance actions', () => { ...@@ -91,7 +91,7 @@ describe('EE approvals license-compliance actions', () => {
}; };
axiosMock.onPost(mocks.state.rulesPath).replyOnce(200); axiosMock.onPost(mocks.state.rulesPath).replyOnce(200);
return testAction( await testAction(
actions.postRule, actions.postRule,
rule, rule,
state, state,
...@@ -101,12 +101,10 @@ describe('EE approvals license-compliance actions', () => { ...@@ -101,12 +101,10 @@ describe('EE approvals license-compliance actions', () => {
type: 'fetchRules', type: 'fetchRules',
}, },
], ],
() => { );
expect(axiosMock.history.post[0].data).toBe( expect(axiosMock.history.post[0].data).toBe(
'{"name":"Foo","approvals_required":1,"users":[8,9],"groups":[7]}', '{"name":"Foo","approvals_required":1,"users":[8,9],"groups":[7]}',
); );
},
);
}); });
it('creates a flash error if the request is not successful', async () => { it('creates a flash error if the request is not successful', async () => {
...@@ -122,7 +120,7 @@ describe('EE approvals license-compliance actions', () => { ...@@ -122,7 +120,7 @@ describe('EE approvals license-compliance actions', () => {
const id = 4; const id = 4;
const putUrl = `${mocks.state.rulesPath}/${4}`; const putUrl = `${mocks.state.rulesPath}/${4}`;
it('puts correct data and dispatches "fetchRules" when request is successful', () => { it('puts correct data and dispatches "fetchRules" when request is successful', async () => {
const payload = { const payload = {
id, id,
name: 'Foo', name: 'Foo',
...@@ -132,7 +130,7 @@ describe('EE approvals license-compliance actions', () => { ...@@ -132,7 +130,7 @@ describe('EE approvals license-compliance actions', () => {
}; };
axiosMock.onPut(putUrl).replyOnce(200); axiosMock.onPut(putUrl).replyOnce(200);
return testAction( await testAction(
actions.putRule, actions.putRule,
payload, payload,
state, state,
...@@ -142,12 +140,10 @@ describe('EE approvals license-compliance actions', () => { ...@@ -142,12 +140,10 @@ describe('EE approvals license-compliance actions', () => {
type: 'fetchRules', type: 'fetchRules',
}, },
], ],
() => { );
expect(axiosMock.history.put[0].data).toBe( expect(axiosMock.history.put[0].data).toBe(
'{"name":"Foo","approvals_required":1,"users":[8,9],"groups":[7]}', '{"name":"Foo","approvals_required":1,"users":[8,9],"groups":[7]}',
); );
},
);
}); });
it('creates a flash error if the request is not successful', async () => { it('creates a flash error if the request is not successful', async () => {
......
...@@ -4,21 +4,20 @@ import testAction from 'helpers/vuex_action_helper'; ...@@ -4,21 +4,20 @@ import testAction from 'helpers/vuex_action_helper';
describe('Approval MR edit module actions', () => { describe('Approval MR edit module actions', () => {
describe('setTargetBranch', () => { describe('setTargetBranch', () => {
it('commits SET_TARGET_BRANCH', (done) => { it('commits SET_TARGET_BRANCH', async () => {
testAction( await testAction(
actions.setTargetBranch, actions.setTargetBranch,
'main', 'main',
{}, {},
[{ type: types.SET_TARGET_BRANCH, payload: 'main' }], [{ type: types.SET_TARGET_BRANCH, payload: 'main' }],
[], [],
done,
); );
}); });
}); });
describe('undoRulesChange', () => { describe('undoRulesChange', () => {
it('commits UNDO_RULES', (done) => { it('commits UNDO_RULES', async () => {
testAction(actions.undoRulesChange, null, {}, [{ type: types.UNDO_RULES }], [], done); await testAction(actions.undoRulesChange, null, {}, [{ type: types.UNDO_RULES }], []);
}); });
}); });
}); });
...@@ -239,10 +239,10 @@ describe('fetchEpicsSwimlanes', () => { ...@@ -239,10 +239,10 @@ describe('fetchEpicsSwimlanes', () => {
}, },
}; };
it('should commit mutation RECEIVE_EPICS_SUCCESS on success', (done) => { it('should commit mutation RECEIVE_EPICS_SUCCESS on success', async () => {
jest.spyOn(gqlClient, 'query').mockResolvedValue(queryResponse); jest.spyOn(gqlClient, 'query').mockResolvedValue(queryResponse);
testAction( await testAction(
actions.fetchEpicsSwimlanes, actions.fetchEpicsSwimlanes,
{}, {},
state, state,
...@@ -253,14 +253,13 @@ describe('fetchEpicsSwimlanes', () => { ...@@ -253,14 +253,13 @@ describe('fetchEpicsSwimlanes', () => {
}, },
], ],
[], [],
done,
); );
}); });
it('should commit mutation REQUEST_MORE_EPICS when fetchNext is true', (done) => { it('should commit mutation REQUEST_MORE_EPICS when fetchNext is true', async () => {
jest.spyOn(gqlClient, 'query').mockResolvedValue(queryResponse); jest.spyOn(gqlClient, 'query').mockResolvedValue(queryResponse);
testAction( await testAction(
actions.fetchEpicsSwimlanes, actions.fetchEpicsSwimlanes,
{ fetchNext: true }, { fetchNext: true },
state, state,
...@@ -272,14 +271,13 @@ describe('fetchEpicsSwimlanes', () => { ...@@ -272,14 +271,13 @@ describe('fetchEpicsSwimlanes', () => {
}, },
], ],
[], [],
done,
); );
}); });
it('should commit mutation RECEIVE_EPICS_SUCCESS on success with hasMoreEpics when hasNextPage', (done) => { it('should commit mutation RECEIVE_EPICS_SUCCESS on success with hasMoreEpics when hasNextPage', async () => {
jest.spyOn(gqlClient, 'query').mockResolvedValue(queryResponseWithNextPage); jest.spyOn(gqlClient, 'query').mockResolvedValue(queryResponseWithNextPage);
testAction( await testAction(
actions.fetchEpicsSwimlanes, actions.fetchEpicsSwimlanes,
{}, {},
state, state,
...@@ -294,20 +292,18 @@ describe('fetchEpicsSwimlanes', () => { ...@@ -294,20 +292,18 @@ describe('fetchEpicsSwimlanes', () => {
}, },
], ],
[], [],
done,
); );
}); });
it('should commit mutation RECEIVE_SWIMLANES_FAILURE on failure', (done) => { it('should commit mutation RECEIVE_SWIMLANES_FAILURE on failure', async () => {
jest.spyOn(gqlClient, 'query').mockResolvedValue(Promise.reject()); jest.spyOn(gqlClient, 'query').mockResolvedValue(Promise.reject());
testAction( await testAction(
actions.fetchEpicsSwimlanes, actions.fetchEpicsSwimlanes,
{}, {},
state, state,
[{ type: types.RECEIVE_SWIMLANES_FAILURE }], [{ type: types.RECEIVE_SWIMLANES_FAILURE }],
[], [],
done,
); );
}); });
}); });
...@@ -368,14 +364,14 @@ describe('fetchItemsForList', () => { ...@@ -368,14 +364,14 @@ describe('fetchItemsForList', () => {
}); });
}); });
it('add epicWildcardId with NONE as value when noEpicIssues is true', () => { it('add epicWildcardId with NONE as value when noEpicIssues is true', async () => {
state = { state = {
...state, ...state,
isShowingEpicsSwimlanes: true, isShowingEpicsSwimlanes: true,
}; };
jest.spyOn(gqlClient, 'query').mockResolvedValue(queryResponse); jest.spyOn(gqlClient, 'query').mockResolvedValue(queryResponse);
testAction( await testAction(
actions.fetchItemsForList, actions.fetchItemsForList,
{ listId, noEpicIssues: true }, { listId, noEpicIssues: true },
state, state,
...@@ -390,7 +386,7 @@ describe('fetchItemsForList', () => { ...@@ -390,7 +386,7 @@ describe('fetchItemsForList', () => {
}, },
], ],
[], [],
() => { );
expect(gqlClient.query).toHaveBeenCalledWith({ expect(gqlClient.query).toHaveBeenCalledWith({
query: listsIssuesQuery, query: listsIssuesQuery,
variables: { variables: {
...@@ -409,8 +405,6 @@ describe('fetchItemsForList', () => { ...@@ -409,8 +405,6 @@ describe('fetchItemsForList', () => {
isSingleRequest: true, isSingleRequest: true,
}, },
}); });
},
);
}); });
}); });
...@@ -428,11 +422,11 @@ describe('updateBoardEpicUserPreferences', () => { ...@@ -428,11 +422,11 @@ describe('updateBoardEpicUserPreferences', () => {
}, },
}); });
it('should send mutation', (done) => { it('should send mutation', async () => {
const collapsed = true; const collapsed = true;
jest.spyOn(gqlClient, 'mutate').mockResolvedValue(queryResponse(collapsed)); jest.spyOn(gqlClient, 'mutate').mockResolvedValue(queryResponse(collapsed));
testAction( await testAction(
actions.updateBoardEpicUserPreferences, actions.updateBoardEpicUserPreferences,
{ epicId: mockEpic.id, collapsed }, { epicId: mockEpic.id, collapsed },
state, state,
...@@ -448,24 +442,22 @@ describe('updateBoardEpicUserPreferences', () => { ...@@ -448,24 +442,22 @@ describe('updateBoardEpicUserPreferences', () => {
}, },
], ],
[], [],
done,
); );
}); });
}); });
describe('setShowLabels', () => { describe('setShowLabels', () => {
it('should commit mutation SET_SHOW_LABELS', (done) => { it('should commit mutation SET_SHOW_LABELS', async () => {
const state = { const state = {
isShowingLabels: true, isShowingLabels: true,
}; };
testAction( await testAction(
actions.setShowLabels, actions.setShowLabels,
false, false,
state, state,
[{ type: types.SET_SHOW_LABELS, payload: false }], [{ type: types.SET_SHOW_LABELS, payload: false }],
[], [],
done,
); );
}); });
}); });
...@@ -561,10 +553,10 @@ describe('fetchIssuesForEpic', () => { ...@@ -561,10 +553,10 @@ describe('fetchIssuesForEpic', () => {
const formattedIssues = formatListIssues(queryResponse.data.group.board.lists); const formattedIssues = formatListIssues(queryResponse.data.group.board.lists);
it('should commit mutations REQUEST_ISSUES_FOR_EPIC and RECEIVE_ITEMS_FOR_LIST_SUCCESS on success', (done) => { it('should commit mutations REQUEST_ISSUES_FOR_EPIC and RECEIVE_ITEMS_FOR_LIST_SUCCESS on success', async () => {
jest.spyOn(gqlClient, 'query').mockResolvedValue(queryResponse); jest.spyOn(gqlClient, 'query').mockResolvedValue(queryResponse);
testAction( await testAction(
actions.fetchIssuesForEpic, actions.fetchIssuesForEpic,
epicId, epicId,
state, state,
...@@ -573,14 +565,13 @@ describe('fetchIssuesForEpic', () => { ...@@ -573,14 +565,13 @@ describe('fetchIssuesForEpic', () => {
{ type: types.RECEIVE_ISSUES_FOR_EPIC_SUCCESS, payload: { ...formattedIssues, epicId } }, { type: types.RECEIVE_ISSUES_FOR_EPIC_SUCCESS, payload: { ...formattedIssues, epicId } },
], ],
[], [],
done,
); );
}); });
it('should commit mutations REQUEST_ISSUES_FOR_EPIC and RECEIVE_ITEMS_FOR_LIST_FAILURE on failure', (done) => { it('should commit mutations REQUEST_ISSUES_FOR_EPIC and RECEIVE_ITEMS_FOR_LIST_FAILURE on failure', async () => {
jest.spyOn(gqlClient, 'query').mockResolvedValue(Promise.reject()); jest.spyOn(gqlClient, 'query').mockResolvedValue(Promise.reject());
testAction( await testAction(
actions.fetchIssuesForEpic, actions.fetchIssuesForEpic,
epicId, epicId,
state, state,
...@@ -589,13 +580,12 @@ describe('fetchIssuesForEpic', () => { ...@@ -589,13 +580,12 @@ describe('fetchIssuesForEpic', () => {
{ type: types.RECEIVE_ISSUES_FOR_EPIC_FAILURE, payload: epicId }, { type: types.RECEIVE_ISSUES_FOR_EPIC_FAILURE, payload: epicId },
], ],
[], [],
done,
); );
}); });
}); });
describe('toggleEpicSwimlanes', () => { describe('toggleEpicSwimlanes', () => {
it('should commit mutation TOGGLE_EPICS_SWIMLANES', () => { it('should commit mutation TOGGLE_EPICS_SWIMLANES', async () => {
const startURl = `${TEST_HOST}/groups/gitlab-org/-/boards/1?group_by=epic`; const startURl = `${TEST_HOST}/groups/gitlab-org/-/boards/1?group_by=epic`;
setWindowLocation(startURl); setWindowLocation(startURl);
...@@ -687,14 +677,14 @@ describe('setActiveItemWeight', () => { ...@@ -687,14 +677,14 @@ describe('setActiveItemWeight', () => {
const testWeight = mockIssue.weight + 1; const testWeight = mockIssue.weight + 1;
const input = { weight: testWeight, id: mockIssue.id }; const input = { weight: testWeight, id: mockIssue.id };
it('should commit weight', (done) => { it('should commit weight', async () => {
const payload = { const payload = {
itemId: getters.activeBoardItem.id, itemId: getters.activeBoardItem.id,
prop: 'weight', prop: 'weight',
value: testWeight, value: testWeight,
}; };
testAction( await testAction(
actions.setActiveItemWeight, actions.setActiveItemWeight,
input, input,
{ ...state, ...getters }, { ...state, ...getters },
...@@ -705,7 +695,6 @@ describe('setActiveItemWeight', () => { ...@@ -705,7 +695,6 @@ describe('setActiveItemWeight', () => {
}, },
], ],
[], [],
done,
); );
}); });
...@@ -1280,10 +1269,10 @@ describe('fetchSubGroups', () => { ...@@ -1280,10 +1269,10 @@ describe('fetchSubGroups', () => {
}, },
}; };
it('should commit mutations REQUEST_SUB_GROUPS, RECEIVE_SUB_GROUPS_SUCCESS, and SET_SELECTED_GROUP on success', (done) => { it('should commit mutations REQUEST_SUB_GROUPS, RECEIVE_SUB_GROUPS_SUCCESS, and SET_SELECTED_GROUP on success', async () => {
jest.spyOn(gqlClient, 'query').mockResolvedValue(queryResponse); jest.spyOn(gqlClient, 'query').mockResolvedValue(queryResponse);
testAction( await testAction(
actions.fetchSubGroups, actions.fetchSubGroups,
{}, {},
state, state,
...@@ -1302,14 +1291,13 @@ describe('fetchSubGroups', () => { ...@@ -1302,14 +1291,13 @@ describe('fetchSubGroups', () => {
}, },
], ],
[], [],
done,
); );
}); });
it('should commit mutations REQUEST_SUB_GROUPS and RECEIVE_SUB_GROUPS_FAILURE on failure', (done) => { it('should commit mutations REQUEST_SUB_GROUPS and RECEIVE_SUB_GROUPS_FAILURE on failure', async () => {
jest.spyOn(gqlClient, 'query').mockRejectedValue(); jest.spyOn(gqlClient, 'query').mockRejectedValue();
testAction( await testAction(
actions.fetchSubGroups, actions.fetchSubGroups,
{}, {},
state, state,
...@@ -1323,14 +1311,13 @@ describe('fetchSubGroups', () => { ...@@ -1323,14 +1311,13 @@ describe('fetchSubGroups', () => {
}, },
], ],
[], [],
done,
); );
}); });
}); });
describe('setSelectedGroup', () => { describe('setSelectedGroup', () => {
it('should commit mutation SET_SELECTED_GROUP', (done) => { it('should commit mutation SET_SELECTED_GROUP', async () => {
testAction( await testAction(
actions.setSelectedGroup, actions.setSelectedGroup,
mockGroup0, mockGroup0,
{}, {},
...@@ -1341,7 +1328,6 @@ describe('setSelectedGroup', () => { ...@@ -1341,7 +1328,6 @@ describe('setSelectedGroup', () => {
}, },
], ],
[], [],
done,
); );
}); });
}); });
......
...@@ -34,21 +34,14 @@ describe('Codequality report actions', () => { ...@@ -34,21 +34,14 @@ describe('Codequality report actions', () => {
}); });
describe('setPage', () => { describe('setPage', () => {
it('sets the page number', (done) => { it('sets the page number', async () => {
return testAction( await testAction(actions.setPage, 12, state, [{ type: types.SET_PAGE, payload: 12 }], []);
actions.setPage,
12,
state,
[{ type: types.SET_PAGE, payload: 12 }],
[],
done,
);
}); });
}); });
describe('requestReport', () => { describe('requestReport', () => {
it('sets the loading flag', (done) => { it('sets the loading flag', async () => {
testAction(actions.requestReport, null, state, [{ type: types.REQUEST_REPORT }], [], done); await testAction(actions.requestReport, null, state, [{ type: types.REQUEST_REPORT }], []);
}); });
it('tracks a service ping event', () => { it('tracks a service ping event', () => {
...@@ -59,27 +52,25 @@ describe('Codequality report actions', () => { ...@@ -59,27 +52,25 @@ describe('Codequality report actions', () => {
}); });
describe('receiveReportSuccess', () => { describe('receiveReportSuccess', () => {
it('parses the list of issues from the report', (done) => { it('parses the list of issues from the report', async () => {
return testAction( await testAction(
actions.receiveReportSuccess, actions.receiveReportSuccess,
unparsedIssues, unparsedIssues,
{ blobPath: '/root/test-codequality/blob/feature-branch', ...state }, { blobPath: '/root/test-codequality/blob/feature-branch', ...state },
[{ type: types.RECEIVE_REPORT_SUCCESS, payload: parsedIssues }], [{ type: types.RECEIVE_REPORT_SUCCESS, payload: parsedIssues }],
[], [],
done,
); );
}); });
}); });
describe('receiveReportError', () => { describe('receiveReportError', () => {
it('accepts a report error', (done) => { it('accepts a report error', async () => {
testAction( await testAction(
actions.receiveReportError, actions.receiveReportError,
'error', 'error',
state, state,
[{ type: types.RECEIVE_REPORT_ERROR, payload: 'error' }], [{ type: types.RECEIVE_REPORT_ERROR, payload: 'error' }],
[], [],
done,
); );
}); });
}); });
...@@ -89,47 +80,40 @@ describe('Codequality report actions', () => { ...@@ -89,47 +80,40 @@ describe('Codequality report actions', () => {
mock.onGet(endpoint).replyOnce(200, unparsedIssues); mock.onGet(endpoint).replyOnce(200, unparsedIssues);
}); });
it('fetches the report', (done) => { it('fetches the report', async () => {
return testAction( await testAction(
actions.fetchReport, actions.fetchReport,
null, null,
{ blobPath: 'blah', ...state }, { blobPath: 'blah', ...state },
[], [],
[{ type: 'requestReport' }, { type: 'receiveReportSuccess', payload: unparsedIssues }], [{ type: 'requestReport' }, { type: 'receiveReportSuccess', payload: unparsedIssues }],
done,
); );
}); });
it('shows a flash message when there is an error', (done) => { it('shows a flash message when there is an error', async () => {
testAction( await testAction(
actions.fetchReport, actions.fetchReport,
'error', 'error',
state, state,
[], [],
[{ type: 'requestReport' }, { type: 'receiveReportError', payload: expect.any(Error) }], [{ type: 'requestReport' }, { type: 'receiveReportError', payload: expect.any(Error) }],
() => { );
expect(createFlash).toHaveBeenCalledWith({ expect(createFlash).toHaveBeenCalledWith({
message: 'There was an error fetching the codequality report.', message: 'There was an error fetching the codequality report.',
}); });
done();
},
);
}); });
it('shows an error when blob path is missing', (done) => { it('shows an error when blob path is missing', async () => {
testAction( await testAction(
actions.fetchReport, actions.fetchReport,
null, null,
state, state,
[], [],
[{ type: 'requestReport' }, { type: 'receiveReportError', payload: expect.any(Error) }], [{ type: 'requestReport' }, { type: 'receiveReportError', payload: expect.any(Error) }],
() => { );
expect(createFlash).toHaveBeenCalledWith({ expect(createFlash).toHaveBeenCalledWith({
message: 'There was an error fetching the codequality report.', message: 'There was an error fetching the codequality report.',
}); });
done();
},
);
}); });
}); });
}); });
...@@ -17,16 +17,15 @@ jest.mock('~/flash'); ...@@ -17,16 +17,15 @@ jest.mock('~/flash');
describe('EE DiffsStoreActions', () => { describe('EE DiffsStoreActions', () => {
describe('setCodequalityEndpoint', () => { describe('setCodequalityEndpoint', () => {
it('should set given endpoint', (done) => { it('should set given endpoint', async () => {
const endpoint = '/codequality_mr_diff.json'; const endpoint = '/codequality_mr_diff.json';
testAction( await testAction(
setCodequalityEndpoint, setCodequalityEndpoint,
{ endpoint }, { endpoint },
{}, {},
[{ type: types.SET_CODEQUALITY_ENDPOINT, payload: { endpoint } }], [{ type: types.SET_CODEQUALITY_ENDPOINT, payload: { endpoint } }],
[], [],
done,
); );
}); });
}); });
...@@ -44,20 +43,19 @@ describe('EE DiffsStoreActions', () => { ...@@ -44,20 +43,19 @@ describe('EE DiffsStoreActions', () => {
clearCodequalityPoll(); clearCodequalityPoll();
}); });
it('should commit SET_CODEQUALITY_DATA with received response and stop polling', (done) => { it('should commit SET_CODEQUALITY_DATA with received response and stop polling', async () => {
const data = { const data = {
files: { 'app.js': [{ line: 1, description: 'Unexpected alert.', severity: 'minor' }] }, files: { 'app.js': [{ line: 1, description: 'Unexpected alert.', severity: 'minor' }] },
}; };
mock.onGet(endpointCodequality).reply(200, { data }); mock.onGet(endpointCodequality).reply(200, { data });
testAction( await testAction(
fetchCodequality, fetchCodequality,
{}, {},
{ endpointCodequality }, { endpointCodequality },
[{ type: types.SET_CODEQUALITY_DATA, payload: { data } }], [{ type: types.SET_CODEQUALITY_DATA, payload: { data } }],
[{ type: 'stopCodequalityPolling' }], [{ type: 'stopCodequalityPolling' }],
done,
); );
}); });
...@@ -72,21 +70,21 @@ describe('EE DiffsStoreActions', () => { ...@@ -72,21 +70,21 @@ describe('EE DiffsStoreActions', () => {
mock.onGet(endpointCodequality).reply(400); mock.onGet(endpointCodequality).reply(400);
}); });
it('should not show a flash message', (done) => { it('should not show a flash message', async () => {
testAction(fetchCodequality, {}, { endpointCodequality }, [], [], () => { await testAction(fetchCodequality, {}, { endpointCodequality }, [], []);
expect(createFlash).not.toHaveBeenCalled(); expect(createFlash).not.toHaveBeenCalled();
done();
});
}); });
it('should retry five times with a delay, then stop polling', (done) => { it('should retry five times with a delay, then stop polling', async () => {
testAction(fetchCodequality, {}, { endpointCodequality }, [], [], () => { await testAction(fetchCodequality, {}, { endpointCodequality }, [], []);
expect(pollDelayedRequest).toHaveBeenCalledTimes(1); expect(pollDelayedRequest).toHaveBeenCalledTimes(1);
expect(pollStop).toHaveBeenCalledTimes(0); expect(pollStop).toHaveBeenCalledTimes(0);
jest.advanceTimersByTime(RETRY_DELAY); jest.advanceTimersByTime(RETRY_DELAY);
waitForPromises() return waitForPromises()
.then(() => { .then(() => {
expect(pollDelayedRequest).toHaveBeenCalledTimes(2); expect(pollDelayedRequest).toHaveBeenCalledTimes(2);
...@@ -105,30 +103,24 @@ describe('EE DiffsStoreActions', () => { ...@@ -105,30 +103,24 @@ describe('EE DiffsStoreActions', () => {
.then(() => waitForPromises()) .then(() => waitForPromises())
.then(() => { .then(() => {
expect(pollStop).toHaveBeenCalledTimes(1); expect(pollStop).toHaveBeenCalledTimes(1);
})
.then(done)
.catch(done.fail);
}); });
}); });
}); });
it('with unexpected error should stop polling and show a flash message', (done) => { it('with unexpected error should stop polling and show a flash message', async () => {
mock.onGet(endpointCodequality).reply(500); mock.onGet(endpointCodequality).reply(500);
testAction( await testAction(
fetchCodequality, fetchCodequality,
{}, {},
{ endpointCodequality }, { endpointCodequality },
[], [],
[{ type: 'stopCodequalityPolling' }], [{ type: 'stopCodequalityPolling' }],
() => { );
expect(createFlash).toHaveBeenCalledTimes(1); expect(createFlash).toHaveBeenCalledTimes(1);
expect(createFlash).toHaveBeenCalledWith({ expect(createFlash).toHaveBeenCalledWith({
message: 'An unexpected error occurred while loading the code quality diff.', message: 'An unexpected error occurred while loading the code quality diff.',
}); });
done();
},
);
}); });
}); });
}); });
This diff is collapsed.
...@@ -41,21 +41,20 @@ describe('GeoReplicable Store Actions', () => { ...@@ -41,21 +41,20 @@ describe('GeoReplicable Store Actions', () => {
}); });
describe('requestReplicableItems', () => { describe('requestReplicableItems', () => {
it('should commit mutation REQUEST_REPLICABLE_ITEMS', (done) => { it('should commit mutation REQUEST_REPLICABLE_ITEMS', async () => {
testAction( await testAction(
actions.requestReplicableItems, actions.requestReplicableItems,
null, null,
state, state,
[{ type: types.REQUEST_REPLICABLE_ITEMS }], [{ type: types.REQUEST_REPLICABLE_ITEMS }],
[], [],
done,
); );
}); });
}); });
describe('receiveReplicableItemsSuccess', () => { describe('receiveReplicableItemsSuccess', () => {
it('should commit mutation RECEIVE_REPLICABLE_ITEMS_SUCCESS', (done) => { it('should commit mutation RECEIVE_REPLICABLE_ITEMS_SUCCESS', async () => {
testAction( await testAction(
actions.receiveReplicableItemsSuccess, actions.receiveReplicableItemsSuccess,
{ data: MOCK_BASIC_FETCH_DATA_MAP, pagination: MOCK_RESTFUL_PAGINATION_DATA }, { data: MOCK_BASIC_FETCH_DATA_MAP, pagination: MOCK_RESTFUL_PAGINATION_DATA },
state, state,
...@@ -66,14 +65,13 @@ describe('GeoReplicable Store Actions', () => { ...@@ -66,14 +65,13 @@ describe('GeoReplicable Store Actions', () => {
}, },
], ],
[], [],
done,
); );
}); });
}); });
describe('receiveReplicableItemsError', () => { describe('receiveReplicableItemsError', () => {
it('should commit mutation RECEIVE_REPLICABLE_ITEMS_ERROR', () => { it('should commit mutation RECEIVE_REPLICABLE_ITEMS_ERROR', async () => {
testAction( await testAction(
actions.receiveReplicableItemsError, actions.receiveReplicableItemsError,
null, null,
state, state,
...@@ -92,8 +90,8 @@ describe('GeoReplicable Store Actions', () => { ...@@ -92,8 +90,8 @@ describe('GeoReplicable Store Actions', () => {
state.useGraphQl = true; state.useGraphQl = true;
}); });
it('calls fetchReplicableItemsGraphQl', (done) => { it('calls fetchReplicableItemsGraphQl', async () => {
testAction( await testAction(
actions.fetchReplicableItems, actions.fetchReplicableItems,
null, null,
state, state,
...@@ -102,7 +100,6 @@ describe('GeoReplicable Store Actions', () => { ...@@ -102,7 +100,6 @@ describe('GeoReplicable Store Actions', () => {
{ type: 'requestReplicableItems' }, { type: 'requestReplicableItems' },
{ type: 'fetchReplicableItemsGraphQl', payload: null }, { type: 'fetchReplicableItemsGraphQl', payload: null },
], ],
done,
); );
}); });
}); });
...@@ -112,14 +109,13 @@ describe('GeoReplicable Store Actions', () => { ...@@ -112,14 +109,13 @@ describe('GeoReplicable Store Actions', () => {
state.useGraphQl = false; state.useGraphQl = false;
}); });
it('calls fetchReplicableItemsRestful', (done) => { it('calls fetchReplicableItemsRestful', async () => {
testAction( await testAction(
actions.fetchReplicableItems, actions.fetchReplicableItems,
null, null,
state, state,
[], [],
[{ type: 'requestReplicableItems' }, { type: 'fetchReplicableItemsRestful' }], [{ type: 'requestReplicableItems' }, { type: 'fetchReplicableItemsRestful' }],
done,
); );
}); });
}); });
...@@ -278,14 +274,13 @@ describe('GeoReplicable Store Actions', () => { ...@@ -278,14 +274,13 @@ describe('GeoReplicable Store Actions', () => {
jest.spyOn(mockGeoGqClient, 'query').mockRejectedValue(); jest.spyOn(mockGeoGqClient, 'query').mockRejectedValue();
}); });
it('should dispatch the request and error actions', (done) => { it('should dispatch the request and error actions', async () => {
testAction( await testAction(
actions.fetchReplicableItemsGraphQl, actions.fetchReplicableItemsGraphQl,
null, null,
state, state,
[], [],
[{ type: 'receiveReplicableItemsError' }], [{ type: 'receiveReplicableItemsError' }],
done,
); );
}); });
}); });
...@@ -366,35 +361,33 @@ describe('GeoReplicable Store Actions', () => { ...@@ -366,35 +361,33 @@ describe('GeoReplicable Store Actions', () => {
jest.spyOn(Api, 'getGeoReplicableItems').mockRejectedValue(new Error(500)); jest.spyOn(Api, 'getGeoReplicableItems').mockRejectedValue(new Error(500));
}); });
it('should dispatch the request and error actions', (done) => { it('should dispatch the request and error actions', async () => {
testAction( await testAction(
actions.fetchReplicableItemsRestful, actions.fetchReplicableItemsRestful,
{}, {},
state, state,
[], [],
[{ type: 'receiveReplicableItemsError' }], [{ type: 'receiveReplicableItemsError' }],
done,
); );
}); });
}); });
}); });
describe('requestInitiateAllReplicableSyncs', () => { describe('requestInitiateAllReplicableSyncs', () => {
it('should commit mutation REQUEST_INITIATE_ALL_REPLICABLE_SYNCS', (done) => { it('should commit mutation REQUEST_INITIATE_ALL_REPLICABLE_SYNCS', async () => {
testAction( await testAction(
actions.requestInitiateAllReplicableSyncs, actions.requestInitiateAllReplicableSyncs,
null, null,
state, state,
[{ type: types.REQUEST_INITIATE_ALL_REPLICABLE_SYNCS }], [{ type: types.REQUEST_INITIATE_ALL_REPLICABLE_SYNCS }],
[], [],
done,
); );
}); });
}); });
describe('receiveInitiateAllReplicableSyncsSuccess', () => { describe('receiveInitiateAllReplicableSyncsSuccess', () => {
it('should commit mutation RECEIVE_INITIATE_ALL_REPLICABLE_SYNCS_SUCCESS and call fetchReplicableItems and toast', () => { it('should commit mutation RECEIVE_INITIATE_ALL_REPLICABLE_SYNCS_SUCCESS and call fetchReplicableItems and toast', async () => {
testAction( await testAction(
actions.receiveInitiateAllReplicableSyncsSuccess, actions.receiveInitiateAllReplicableSyncsSuccess,
{ action: ACTION_TYPES.RESYNC }, { action: ACTION_TYPES.RESYNC },
state, state,
...@@ -460,8 +453,8 @@ describe('GeoReplicable Store Actions', () => { ...@@ -460,8 +453,8 @@ describe('GeoReplicable Store Actions', () => {
jest.spyOn(Api, 'initiateAllGeoReplicableSyncs').mockRejectedValue(new Error(500)); jest.spyOn(Api, 'initiateAllGeoReplicableSyncs').mockRejectedValue(new Error(500));
}); });
it('should dispatch the request and error actions', (done) => { it('should dispatch the request and error actions', async () => {
testAction( await testAction(
actions.initiateAllReplicableSyncs, actions.initiateAllReplicableSyncs,
action, action,
state, state,
...@@ -470,53 +463,47 @@ describe('GeoReplicable Store Actions', () => { ...@@ -470,53 +463,47 @@ describe('GeoReplicable Store Actions', () => {
{ type: 'requestInitiateAllReplicableSyncs' }, { type: 'requestInitiateAllReplicableSyncs' },
{ type: 'receiveInitiateAllReplicableSyncsError' }, { type: 'receiveInitiateAllReplicableSyncsError' },
], ],
done,
); );
}); });
}); });
}); });
describe('requestInitiateReplicableSync', () => { describe('requestInitiateReplicableSync', () => {
it('should commit mutation REQUEST_INITIATE_REPLICABLE_SYNC', (done) => { it('should commit mutation REQUEST_INITIATE_REPLICABLE_SYNC', async () => {
testAction( await testAction(
actions.requestInitiateReplicableSync, actions.requestInitiateReplicableSync,
null, null,
state, state,
[{ type: types.REQUEST_INITIATE_REPLICABLE_SYNC }], [{ type: types.REQUEST_INITIATE_REPLICABLE_SYNC }],
[], [],
done,
); );
}); });
}); });
describe('receiveInitiateReplicableSyncSuccess', () => { describe('receiveInitiateReplicableSyncSuccess', () => {
it('should commit mutation RECEIVE_INITIATE_REPLICABLE_SYNC_SUCCESS and call fetchReplicableItems and toast', () => { it('should commit mutation RECEIVE_INITIATE_REPLICABLE_SYNC_SUCCESS and call fetchReplicableItems and toast', async () => {
testAction( await testAction(
actions.receiveInitiateReplicableSyncSuccess, actions.receiveInitiateReplicableSyncSuccess,
{ action: ACTION_TYPES.RESYNC, projectName: 'test' }, { action: ACTION_TYPES.RESYNC, projectName: 'test' },
state, state,
[{ type: types.RECEIVE_INITIATE_REPLICABLE_SYNC_SUCCESS }], [{ type: types.RECEIVE_INITIATE_REPLICABLE_SYNC_SUCCESS }],
[{ type: 'fetchReplicableItems' }], [{ type: 'fetchReplicableItems' }],
() => { );
expect(toast).toHaveBeenCalledTimes(1); expect(toast).toHaveBeenCalledTimes(1);
toast.mockClear(); toast.mockClear();
},
);
}); });
}); });
describe('receiveInitiateReplicableSyncError', () => { describe('receiveInitiateReplicableSyncError', () => {
it('should commit mutation RECEIVE_INITIATE_REPLICABLE_SYNC_ERROR', () => { it('should commit mutation RECEIVE_INITIATE_REPLICABLE_SYNC_ERROR', async () => {
testAction( await testAction(
actions.receiveInitiateReplicableSyncError, actions.receiveInitiateReplicableSyncError,
{ action: ACTION_TYPES.RESYNC, projectId: 1, projectName: 'test' }, { action: ACTION_TYPES.RESYNC, projectId: 1, projectName: 'test' },
state, state,
[{ type: types.RECEIVE_INITIATE_REPLICABLE_SYNC_ERROR }], [{ type: types.RECEIVE_INITIATE_REPLICABLE_SYNC_ERROR }],
[], [],
() => {
expect(createFlash).toHaveBeenCalledTimes(1);
},
); );
expect(createFlash).toHaveBeenCalledTimes(1);
}); });
}); });
...@@ -543,13 +530,11 @@ describe('GeoReplicable Store Actions', () => { ...@@ -543,13 +530,11 @@ describe('GeoReplicable Store Actions', () => {
{ type: 'requestInitiateReplicableSync' }, { type: 'requestInitiateReplicableSync' },
{ type: 'receiveInitiateReplicableSyncSuccess', payload: { name, action } }, { type: 'receiveInitiateReplicableSyncSuccess', payload: { name, action } },
], ],
() => { );
expect(Api.initiateGeoReplicableSync).toHaveBeenCalledWith(MOCK_REPLICABLE_TYPE, { expect(Api.initiateGeoReplicableSync).toHaveBeenCalledWith(MOCK_REPLICABLE_TYPE, {
projectId, projectId,
action, action,
}); });
},
);
}); });
}); });
...@@ -561,8 +546,8 @@ describe('GeoReplicable Store Actions', () => { ...@@ -561,8 +546,8 @@ describe('GeoReplicable Store Actions', () => {
jest.spyOn(Api, 'initiateGeoReplicableSync').mockRejectedValue(new Error(500)); jest.spyOn(Api, 'initiateGeoReplicableSync').mockRejectedValue(new Error(500));
}); });
it('should dispatch the request and error actions', (done) => { it('should dispatch the request and error actions', async () => {
testAction( await testAction(
actions.initiateReplicableSync, actions.initiateReplicableSync,
{ projectId, name, action }, { projectId, name, action },
state, state,
...@@ -574,55 +559,51 @@ describe('GeoReplicable Store Actions', () => { ...@@ -574,55 +559,51 @@ describe('GeoReplicable Store Actions', () => {
payload: { name: 'test' }, payload: { name: 'test' },
}, },
], ],
done,
); );
}); });
}); });
}); });
describe('setFilter', () => { describe('setFilter', () => {
it('should commit mutation SET_FILTER', (done) => { it('should commit mutation SET_FILTER', async () => {
const testValue = 1; const testValue = 1;
testAction( await testAction(
actions.setFilter, actions.setFilter,
testValue, testValue,
state, state,
[{ type: types.SET_FILTER, payload: testValue }], [{ type: types.SET_FILTER, payload: testValue }],
[], [],
done,
); );
}); });
}); });
describe('setSearch', () => { describe('setSearch', () => {
it('should commit mutation SET_SEARCH', (done) => { it('should commit mutation SET_SEARCH', async () => {
const testValue = 'Test Search'; const testValue = 'Test Search';
testAction( await testAction(
actions.setSearch, actions.setSearch,
testValue, testValue,
state, state,
[{ type: types.SET_SEARCH, payload: testValue }], [{ type: types.SET_SEARCH, payload: testValue }],
[], [],
done,
); );
}); });
}); });
describe('setPage', () => { describe('setPage', () => {
it('should commit mutation SET_PAGE', (done) => { it('should commit mutation SET_PAGE', async () => {
state.paginationData.page = 1; state.paginationData.page = 1;
const testValue = 2; const testValue = 2;
testAction( await testAction(
actions.setPage, actions.setPage,
testValue, testValue,
state, state,
[{ type: types.SET_PAGE, payload: testValue }], [{ type: types.SET_PAGE, payload: testValue }],
[], [],
done,
); );
}); });
}); });
......
...@@ -70,41 +70,29 @@ describe('GroupMemberStore', () => { ...@@ -70,41 +70,29 @@ describe('GroupMemberStore', () => {
mock.restore(); mock.restore();
}); });
it('calls service.getContributedMembers and sets response to the store on success', (done) => { it('calls service.getContributedMembers and sets response to the store on success', async () => {
mock.onGet(contributionsPath).reply(200, rawMembers); mock.onGet(contributionsPath).reply(200, rawMembers);
jest.spyOn(store, 'setColumns').mockImplementation(() => {}); jest.spyOn(store, 'setColumns').mockImplementation(() => {});
jest.spyOn(store, 'setMembers').mockImplementation(() => {}); jest.spyOn(store, 'setMembers').mockImplementation(() => {});
store expect(store.isLoading).toBe(true);
.fetchContributedMembers() await store.fetchContributedMembers();
.then(() => {
expect(store.isLoading).toBe(false); expect(store.isLoading).toBe(false);
expect(store.setColumns).toHaveBeenCalledWith(expect.any(Object)); expect(store.setColumns).toHaveBeenCalledWith(expect.any(Object));
expect(store.setMembers).toHaveBeenCalledWith(rawMembers); expect(store.setMembers).toHaveBeenCalledWith(rawMembers);
done();
})
.catch(done.fail);
expect(store.isLoading).toBe(true);
}); });
it('calls service.getContributedMembers and sets `isLoading` to false and shows flash message if request failed', (done) => { it('calls service.getContributedMembers and sets `isLoading` to false and shows flash message if request failed', async () => {
mock.onGet(contributionsPath).reply(500, {}); mock.onGet(contributionsPath).reply(500, {});
store await expect(store.fetchContributedMembers()).rejects.toEqual(
.fetchContributedMembers() new Error('Request failed with status code 500'),
.then(() => done.fail('Expected error to be thrown!')) );
.catch((e) => {
expect(e.message).toBe('Request failed with status code 500');
expect(store.isLoading).toBe(false); expect(store.isLoading).toBe(false);
expect(createFlash).toHaveBeenCalledWith({ expect(createFlash).toHaveBeenCalledWith({
message: 'Something went wrong while fetching group member contributions', message: 'Something went wrong while fetching group member contributions',
}); });
})
.then(done)
.catch(done.fail);
expect(store.isLoading).toBe(true);
}); });
}); });
}); });
...@@ -23,7 +23,7 @@ describe('saml_members actions', () => { ...@@ -23,7 +23,7 @@ describe('saml_members actions', () => {
}); });
describe('fetchPage', () => { describe('fetchPage', () => {
it('should commit RECEIVE_SAML_MEMBERS_SUCCESS mutation on correct data', (done) => { it('should commit RECEIVE_SAML_MEMBERS_SUCCESS mutation on correct data', async () => {
const members = [ const members = [
{ id: 1, name: 'user 1', group_saml_identity: null }, { id: 1, name: 'user 1', group_saml_identity: null },
{ id: 2, name: 'user 2', group_saml_identity: { extern_uid: 'a' } }, { id: 2, name: 'user 2', group_saml_identity: { extern_uid: 'a' } },
...@@ -57,7 +57,7 @@ describe('saml_members actions', () => { ...@@ -57,7 +57,7 @@ describe('saml_members actions', () => {
previousPage: 1, previousPage: 1,
}; };
testAction( await testAction(
fetchPage, fetchPage,
undefined, undefined,
state, state,
...@@ -68,16 +68,14 @@ describe('saml_members actions', () => { ...@@ -68,16 +68,14 @@ describe('saml_members actions', () => {
}, },
], ],
[], [],
done,
); );
}); });
it('should show flash on wrong data', (done) => { it('should show flash on wrong data', async () => {
Api.groupMembers.mockReturnValue(Promise.reject(new Error())); Api.groupMembers.mockReturnValue(Promise.reject(new Error()));
testAction(fetchPage, undefined, state, [], [], () => { await testAction(fetchPage, undefined, state, [], []);
expect(createFlash).toHaveBeenCalledTimes(1); expect(createFlash).toHaveBeenCalledTimes(1);
done();
});
}); });
}); });
}); });
...@@ -1648,15 +1648,12 @@ describe('RelatedItemTree', () => { ...@@ -1648,15 +1648,12 @@ describe('RelatedItemTree', () => {
requestSpy.mockReturnValue([500, '']); requestSpy.mockReturnValue([500, '']);
}); });
it('fails and shows flash message', (done) => { it('fails and shows flash message', async () => {
return actions await expect(actions.createNewIssue(context, payload)).rejects.toEqual(
.createNewIssue(context, payload) new Error('Request failed with status code 500'),
.then(() => done.fail('expected action to throw error!')) );
.catch(() => {
expect(requestSpy).toHaveBeenCalledWith(expectedRequest); expect(requestSpy).toHaveBeenCalledWith(expectedRequest);
expect(context.dispatch).toHaveBeenCalledWith('receiveCreateIssueFailure'); expect(context.dispatch).toHaveBeenCalledWith('receiveCreateIssueFailure');
done();
});
}); });
}); });
}); });
......
...@@ -17,8 +17,8 @@ describe('pipeling jobs actions', () => { ...@@ -17,8 +17,8 @@ describe('pipeling jobs actions', () => {
describe('setPipelineJobsPath', () => { describe('setPipelineJobsPath', () => {
const pipelineJobsPath = 123; const pipelineJobsPath = 123;
it('should commit the SET_PIPELINE_JOBS_PATH mutation', (done) => { it('should commit the SET_PIPELINE_JOBS_PATH mutation', async () => {
testAction( await testAction(
actions.setPipelineJobsPath, actions.setPipelineJobsPath,
pipelineJobsPath, pipelineJobsPath,
state, state,
...@@ -29,7 +29,6 @@ describe('pipeling jobs actions', () => { ...@@ -29,7 +29,6 @@ describe('pipeling jobs actions', () => {
}, },
], ],
[], [],
done,
); );
}); });
}); });
...@@ -37,8 +36,8 @@ describe('pipeling jobs actions', () => { ...@@ -37,8 +36,8 @@ describe('pipeling jobs actions', () => {
describe('setProjectId', () => { describe('setProjectId', () => {
const projectId = 123; const projectId = 123;
it('should commit the SET_PIPELINE_JOBS_PATH mutation', (done) => { it('should commit the SET_PIPELINE_JOBS_PATH mutation', async () => {
testAction( await testAction(
actions.setProjectId, actions.setProjectId,
projectId, projectId,
state, state,
...@@ -49,7 +48,6 @@ describe('pipeling jobs actions', () => { ...@@ -49,7 +48,6 @@ describe('pipeling jobs actions', () => {
}, },
], ],
[], [],
done,
); );
}); });
}); });
...@@ -57,8 +55,8 @@ describe('pipeling jobs actions', () => { ...@@ -57,8 +55,8 @@ describe('pipeling jobs actions', () => {
describe('setPipelineId', () => { describe('setPipelineId', () => {
const pipelineId = 123; const pipelineId = 123;
it('should commit the SET_PIPELINE_ID mutation', (done) => { it('should commit the SET_PIPELINE_ID mutation', async () => {
testAction( await testAction(
actions.setPipelineId, actions.setPipelineId,
pipelineId, pipelineId,
state, state,
...@@ -69,7 +67,6 @@ describe('pipeling jobs actions', () => { ...@@ -69,7 +67,6 @@ describe('pipeling jobs actions', () => {
}, },
], ],
[], [],
done,
); );
}); });
}); });
...@@ -92,8 +89,8 @@ describe('pipeling jobs actions', () => { ...@@ -92,8 +89,8 @@ describe('pipeling jobs actions', () => {
mock.onGet(state.pipelineJobsPath).replyOnce(200, jobs); mock.onGet(state.pipelineJobsPath).replyOnce(200, jobs);
}); });
it('should commit the request and success mutations', (done) => { it('should commit the request and success mutations', async () => {
testAction( await testAction(
actions.fetchPipelineJobs, actions.fetchPipelineJobs,
{}, {},
state, state,
...@@ -105,7 +102,6 @@ describe('pipeling jobs actions', () => { ...@@ -105,7 +102,6 @@ describe('pipeling jobs actions', () => {
}, },
], ],
[], [],
done,
); );
}); });
}); });
...@@ -115,12 +111,12 @@ describe('pipeling jobs actions', () => { ...@@ -115,12 +111,12 @@ describe('pipeling jobs actions', () => {
mock.onGet('/api/undefined/projects/123/pipelines/321/jobs').replyOnce(200, jobs); mock.onGet('/api/undefined/projects/123/pipelines/321/jobs').replyOnce(200, jobs);
}); });
it('should commit the request and success mutations', (done) => { it('should commit the request and success mutations', async () => {
state.pipelineJobsPath = ''; state.pipelineJobsPath = '';
state.projectId = 123; state.projectId = 123;
state.pipelineId = 321; state.pipelineId = 321;
testAction( await testAction(
actions.fetchPipelineJobs, actions.fetchPipelineJobs,
{}, {},
state, state,
...@@ -132,7 +128,6 @@ describe('pipeling jobs actions', () => { ...@@ -132,7 +128,6 @@ describe('pipeling jobs actions', () => {
}, },
], ],
[], [],
done,
); );
}); });
}); });
...@@ -142,10 +137,10 @@ describe('pipeling jobs actions', () => { ...@@ -142,10 +137,10 @@ describe('pipeling jobs actions', () => {
mock.onGet(state.pipelineJobsPath).replyOnce(200, jobs); mock.onGet(state.pipelineJobsPath).replyOnce(200, jobs);
}); });
it('should commit RECEIVE_PIPELINE_JOBS_ERROR mutation', (done) => { it('should commit RECEIVE_PIPELINE_JOBS_ERROR mutation', async () => {
state.pipelineJobsPath = ''; state.pipelineJobsPath = '';
testAction( await testAction(
actions.fetchPipelineJobs, actions.fetchPipelineJobs,
{}, {},
state, state,
...@@ -155,7 +150,6 @@ describe('pipeling jobs actions', () => { ...@@ -155,7 +150,6 @@ describe('pipeling jobs actions', () => {
}, },
], ],
[], [],
done,
); );
}); });
}); });
...@@ -165,12 +159,12 @@ describe('pipeling jobs actions', () => { ...@@ -165,12 +159,12 @@ describe('pipeling jobs actions', () => {
mock.onGet(state.pipelineJobsPath).replyOnce(200, jobs); mock.onGet(state.pipelineJobsPath).replyOnce(200, jobs);
}); });
it('should commit RECEIVE_PIPELINE_JOBS_ERROR mutation', (done) => { it('should commit RECEIVE_PIPELINE_JOBS_ERROR mutation', async () => {
state.pipelineJobsPath = ''; state.pipelineJobsPath = '';
state.projectId = undefined; state.projectId = undefined;
state.pipelineId = undefined; state.pipelineId = undefined;
testAction( await testAction(
actions.fetchPipelineJobs, actions.fetchPipelineJobs,
{}, {},
state, state,
...@@ -180,7 +174,6 @@ describe('pipeling jobs actions', () => { ...@@ -180,7 +174,6 @@ describe('pipeling jobs actions', () => {
}, },
], ],
[], [],
done,
); );
}); });
}); });
...@@ -190,8 +183,8 @@ describe('pipeling jobs actions', () => { ...@@ -190,8 +183,8 @@ describe('pipeling jobs actions', () => {
mock.onGet(state.pipelineJobsPath).replyOnce(404); mock.onGet(state.pipelineJobsPath).replyOnce(404);
}); });
it('should commit REQUEST_PIPELINE_JOBS and RECEIVE_PIPELINE_JOBS_ERROR mutation', (done) => { it('should commit REQUEST_PIPELINE_JOBS and RECEIVE_PIPELINE_JOBS_ERROR mutation', async () => {
testAction( await testAction(
actions.fetchPipelineJobs, actions.fetchPipelineJobs,
{}, {},
state, state,
...@@ -202,7 +195,6 @@ describe('pipeling jobs actions', () => { ...@@ -202,7 +195,6 @@ describe('pipeling jobs actions', () => {
}, },
], ],
[], [],
done,
); );
}); });
}); });
......
...@@ -45,10 +45,10 @@ describe('EE projectSelector actions', () => { ...@@ -45,10 +45,10 @@ describe('EE projectSelector actions', () => {
}); });
describe('toggleSelectedProject', () => { describe('toggleSelectedProject', () => {
it('adds a project to selectedProjects if it does not already exist in the list', (done) => { it('adds a project to selectedProjects if it does not already exist in the list', async () => {
const payload = getMockProjects(1); const payload = getMockProjects(1);
testAction( await testAction(
actions.toggleSelectedProject, actions.toggleSelectedProject,
payload, payload,
state, state,
...@@ -59,15 +59,14 @@ describe('EE projectSelector actions', () => { ...@@ -59,15 +59,14 @@ describe('EE projectSelector actions', () => {
}, },
], ],
[], [],
done,
); );
}); });
it('removes a project from selectedProjects if it already exist in the list', () => { it('removes a project from selectedProjects if it already exist in the list', async () => {
const payload = getMockProjects(1)[0]; const payload = getMockProjects(1)[0];
state.selectedProjects = getMockProjects(1); state.selectedProjects = getMockProjects(1);
return testAction( await testAction(
actions.toggleSelectedProject, actions.toggleSelectedProject,
payload, payload,
state, state,
...@@ -102,12 +101,12 @@ describe('EE projectSelector actions', () => { ...@@ -102,12 +101,12 @@ describe('EE projectSelector actions', () => {
}); });
}); });
it('dispatches the correct actions when the request is successful', () => { it('dispatches the correct actions when the request is successful', async () => {
state.projectEndpoints.add = mockAddEndpoint; state.projectEndpoints.add = mockAddEndpoint;
mockAxios.onPost(mockAddEndpoint).replyOnce(200, mockResponse); mockAxios.onPost(mockAddEndpoint).replyOnce(200, mockResponse);
return testAction( await testAction(
actions.addProjects, actions.addProjects,
null, null,
state, state,
......
...@@ -43,8 +43,8 @@ describe('projects actions', () => { ...@@ -43,8 +43,8 @@ describe('projects actions', () => {
}); });
}); });
it('should dispatch the request and success actions', (done) => { it('should dispatch the request and success actions', async () => {
testAction( await testAction(
actions.fetchProjects, actions.fetchProjects,
{}, {},
state, state,
...@@ -56,7 +56,6 @@ describe('projects actions', () => { ...@@ -56,7 +56,6 @@ describe('projects actions', () => {
payload: { projects: data }, payload: { projects: data },
}, },
], ],
done,
); );
}); });
}); });
...@@ -70,8 +69,8 @@ describe('projects actions', () => { ...@@ -70,8 +69,8 @@ describe('projects actions', () => {
mock.onGet(state.projectsEndpoint, { page: '2' }).replyOnce(200, [2]); mock.onGet(state.projectsEndpoint, { page: '2' }).replyOnce(200, [2]);
}); });
it('should dispatch the request and success actions', (done) => { it('should dispatch the request and success actions', async () => {
testAction( await testAction(
actions.fetchProjects, actions.fetchProjects,
{}, {},
state, state,
...@@ -83,7 +82,6 @@ describe('projects actions', () => { ...@@ -83,7 +82,6 @@ describe('projects actions', () => {
payload: { projects: [1, 2] }, payload: { projects: [1, 2] },
}, },
], ],
done,
); );
}); });
}); });
...@@ -93,14 +91,13 @@ describe('projects actions', () => { ...@@ -93,14 +91,13 @@ describe('projects actions', () => {
mock.onGet(state.projectsEndpoint).replyOnce(404, {}); mock.onGet(state.projectsEndpoint).replyOnce(404, {});
}); });
it('should dispatch the request and error actions', (done) => { it('should dispatch the request and error actions', async () => {
testAction( await testAction(
actions.fetchProjects, actions.fetchProjects,
{}, {},
state, state,
[], [],
[{ type: 'requestProjects' }, { type: 'receiveProjectsError' }], [{ type: 'requestProjects' }, { type: 'receiveProjectsError' }],
done,
); );
}); });
}); });
...@@ -110,17 +107,17 @@ describe('projects actions', () => { ...@@ -110,17 +107,17 @@ describe('projects actions', () => {
state.projectsEndpoint = ''; state.projectsEndpoint = '';
}); });
it('should not do anything', (done) => { it('should not do anything', async () => {
testAction(actions.fetchProjects, {}, state, [], [], done); await testAction(actions.fetchProjects, {}, state, [], []);
}); });
}); });
}); });
describe('receiveProjectsSuccess', () => { describe('receiveProjectsSuccess', () => {
it('should commit the success mutation', (done) => { it('should commit the success mutation', async () => {
const state = createState(); const state = createState();
testAction( await testAction(
actions.receiveProjectsSuccess, actions.receiveProjectsSuccess,
{ projects: data }, { projects: data },
state, state,
...@@ -131,39 +128,37 @@ describe('projects actions', () => { ...@@ -131,39 +128,37 @@ describe('projects actions', () => {
}, },
], ],
[], [],
done,
); );
}); });
}); });
describe('receiveProjectsError', () => { describe('receiveProjectsError', () => {
it('should commit the error mutation', (done) => { it('should commit the error mutation', async () => {
const state = createState(); const state = createState();
testAction( await testAction(
actions.receiveProjectsError, actions.receiveProjectsError,
{}, {},
state, state,
[{ type: types.RECEIVE_PROJECTS_ERROR }], [{ type: types.RECEIVE_PROJECTS_ERROR }],
[], [],
done,
); );
}); });
}); });
describe('requestProjects', () => { describe('requestProjects', () => {
it('should commit the request mutation', (done) => { it('should commit the request mutation', async () => {
const state = createState(); const state = createState();
testAction(actions.requestProjects, {}, state, [{ type: types.REQUEST_PROJECTS }], [], done); await testAction(actions.requestProjects, {}, state, [{ type: types.REQUEST_PROJECTS }], []);
}); });
}); });
describe('setProjectsEndpoint', () => { describe('setProjectsEndpoint', () => {
it('should commit the correct mutuation', (done) => { it('should commit the correct mutuation', async () => {
const state = createState(); const state = createState();
testAction( await testAction(
actions.setProjectsEndpoint, actions.setProjectsEndpoint,
endpoint, endpoint,
state, state,
...@@ -174,7 +169,6 @@ describe('projects actions', () => { ...@@ -174,7 +169,6 @@ describe('projects actions', () => {
}, },
], ],
[], [],
done,
); );
}); });
}); });
......
...@@ -98,22 +98,20 @@ describe('Status Page actions', () => { ...@@ -98,22 +98,20 @@ describe('Status Page actions', () => {
}); });
describe('receiveStatusPageSettingsUpdateSuccess', () => { describe('receiveStatusPageSettingsUpdateSuccess', () => {
it('should handle successful settings update', (done) => { it('should handle successful settings update', async () => {
testAction(actions.receiveStatusPageSettingsUpdateSuccess, null, null, [], [], () => { await testAction(actions.receiveStatusPageSettingsUpdateSuccess, null, null, [], []);
expect(refreshCurrentPage).toHaveBeenCalledTimes(1); expect(refreshCurrentPage).toHaveBeenCalledTimes(1);
done();
});
}); });
}); });
describe('receiveStatusPageSettingsUpdateError', () => { describe('receiveStatusPageSettingsUpdateError', () => {
const error = { response: { data: { message: 'Update error' } } }; const error = { response: { data: { message: 'Update error' } } };
it('should handle error update', (done) => { it('should handle error update', async () => {
testAction(actions.receiveStatusPageSettingsUpdateError, error, null, [], [], () => { await testAction(actions.receiveStatusPageSettingsUpdateError, error, null, [], [], () => {
expect(createFlash).toHaveBeenCalledWith({ expect(createFlash).toHaveBeenCalledWith({
message: `There was an error saving your changes. ${error.response.data.message}`, message: `There was an error saving your changes. ${error.response.data.message}`,
}); });
done();
}); });
}); });
}); });
......
...@@ -4,10 +4,6 @@ import ApprovalsAuth from 'ee/vue_merge_request_widget/components/approvals/appr ...@@ -4,10 +4,6 @@ import ApprovalsAuth from 'ee/vue_merge_request_widget/components/approvals/appr
const TEST_PASSWORD = 'password'; const TEST_PASSWORD = 'password';
// For some reason, the `Promise.resolve` needs to be deferred
// or the timing doesn't work.
const waitForTick = (done) => Promise.resolve().then(done).catch(done.fail);
describe('Approval auth component', () => { describe('Approval auth component', () => {
let wrapper; let wrapper;
...@@ -22,16 +18,14 @@ describe('Approval auth component', () => { ...@@ -22,16 +18,14 @@ describe('Approval auth component', () => {
afterEach(() => { afterEach(() => {
wrapper.destroy(); wrapper.destroy();
wrapper = null;
}); });
const findInput = () => wrapper.find('input[type=password]'); const findInput = () => wrapper.find('input[type=password]');
const findErrorMessage = () => wrapper.find('.gl-field-error'); const findErrorMessage = () => wrapper.find('.gl-field-error');
describe('when created', () => { describe('when created', () => {
beforeEach((done) => { beforeEach(() => {
createComponent(); createComponent();
waitForTick(done);
}); });
it('password input control is rendered', () => { it('password input control is rendered', () => {
...@@ -54,24 +48,21 @@ describe('Approval auth component', () => { ...@@ -54,24 +48,21 @@ describe('Approval auth component', () => {
}); });
describe('when approve clicked', () => { describe('when approve clicked', () => {
beforeEach((done) => { beforeEach(() => {
createComponent(); createComponent();
waitForTick(done);
}); });
it('emits the approve event', (done) => { it('emits the approve event', async () => {
findInput().setValue(TEST_PASSWORD); findInput().setValue(TEST_PASSWORD);
wrapper.findComponent(GlModal).vm.$emit('ok', { preventDefault: () => null }); wrapper.findComponent(GlModal).vm.$emit('ok', { preventDefault: () => null });
waitForTick(done);
expect(wrapper.emitted().approve).toEqual([[TEST_PASSWORD]]); expect(wrapper.emitted().approve).toEqual([[TEST_PASSWORD]]);
}); });
}); });
describe('when isApproving is true', () => { describe('when isApproving is true', () => {
beforeEach((done) => { beforeEach(() => {
createComponent({ isApproving: true }); createComponent({ isApproving: true });
waitForTick(done);
}); });
it('disables the approve button', () => { it('disables the approve button', () => {
...@@ -82,9 +73,8 @@ describe('Approval auth component', () => { ...@@ -82,9 +73,8 @@ describe('Approval auth component', () => {
}); });
describe('when hasError is true', () => { describe('when hasError is true', () => {
beforeEach((done) => { beforeEach(() => {
createComponent({ hasError: true }); createComponent({ hasError: true });
waitForTick(done);
}); });
it('shows the invalid password message', () => { it('shows the invalid password message', () => {
......
...@@ -46,7 +46,7 @@ describe('AddLicenseFormDropdown', () => { ...@@ -46,7 +46,7 @@ describe('AddLicenseFormDropdown', () => {
expect(vm.$el.value).toContain(value); expect(vm.$el.value).toContain(value);
}); });
it('shows all defined licenses', async (done) => { it('shows all defined licenses', async () => {
await createComponent(); await createComponent();
const element = $(vm.$el); const element = $(vm.$el);
...@@ -58,7 +58,6 @@ describe('AddLicenseFormDropdown', () => { ...@@ -58,7 +58,6 @@ describe('AddLicenseFormDropdown', () => {
options.each((index, optionEl) => { options.each((index, optionEl) => {
expect(KNOWN_LICENSES).toContain($(optionEl).text()); expect(KNOWN_LICENSES).toContain($(optionEl).text());
}); });
done();
}); });
element.select2('open'); element.select2('open');
......
...@@ -25,8 +25,8 @@ describe('EE api fuzzing report actions', () => { ...@@ -25,8 +25,8 @@ describe('EE api fuzzing report actions', () => {
}); });
describe('updateVulnerability', () => { describe('updateVulnerability', () => {
it(`should commit ${types.UPDATE_VULNERABILITY} with the correct response`, (done) => { it(`should commit ${types.UPDATE_VULNERABILITY} with the correct response`, async () => {
testAction( await testAction(
actions.updateVulnerability, actions.updateVulnerability,
issue, issue,
state, state,
...@@ -37,14 +37,13 @@ describe('EE api fuzzing report actions', () => { ...@@ -37,14 +37,13 @@ describe('EE api fuzzing report actions', () => {
}, },
], ],
[], [],
done,
); );
}); });
}); });
describe('setDiffEndpoint', () => { describe('setDiffEndpoint', () => {
it(`should commit ${types.SET_DIFF_ENDPOINT} with the correct path`, (done) => { it(`should commit ${types.SET_DIFF_ENDPOINT} with the correct path`, async () => {
testAction( await testAction(
actions.setDiffEndpoint, actions.setDiffEndpoint,
diffEndpoint, diffEndpoint,
state, state,
...@@ -55,20 +54,19 @@ describe('EE api fuzzing report actions', () => { ...@@ -55,20 +54,19 @@ describe('EE api fuzzing report actions', () => {
}, },
], ],
[], [],
done,
); );
}); });
}); });
describe('requestDiff', () => { describe('requestDiff', () => {
it(`should commit ${types.REQUEST_DIFF}`, (done) => { it(`should commit ${types.REQUEST_DIFF}`, async () => {
testAction(actions.requestDiff, {}, state, [{ type: types.REQUEST_DIFF }], [], done); await testAction(actions.requestDiff, {}, state, [{ type: types.REQUEST_DIFF }], []);
}); });
}); });
describe('receiveDiffSuccess', () => { describe('receiveDiffSuccess', () => {
it(`should commit ${types.RECEIVE_DIFF_SUCCESS} with the correct response`, (done) => { it(`should commit ${types.RECEIVE_DIFF_SUCCESS} with the correct response`, async () => {
testAction( await testAction(
actions.receiveDiffSuccess, actions.receiveDiffSuccess,
reports, reports,
state, state,
...@@ -79,14 +77,13 @@ describe('EE api fuzzing report actions', () => { ...@@ -79,14 +77,13 @@ describe('EE api fuzzing report actions', () => {
}, },
], ],
[], [],
done,
); );
}); });
}); });
describe('receiveDiffError', () => { describe('receiveDiffError', () => {
it(`should commit ${types.RECEIVE_DIFF_ERROR} with the correct response`, (done) => { it(`should commit ${types.RECEIVE_DIFF_ERROR} with the correct response`, async () => {
testAction( await testAction(
actions.receiveDiffError, actions.receiveDiffError,
error, error,
state, state,
...@@ -97,7 +94,6 @@ describe('EE api fuzzing report actions', () => { ...@@ -97,7 +94,6 @@ describe('EE api fuzzing report actions', () => {
}, },
], ],
[], [],
done,
); );
}); });
}); });
...@@ -124,9 +120,9 @@ describe('EE api fuzzing report actions', () => { ...@@ -124,9 +120,9 @@ describe('EE api fuzzing report actions', () => {
.replyOnce(200, reports.enrichData); .replyOnce(200, reports.enrichData);
}); });
it('should dispatch the `receiveDiffSuccess` action', (done) => { it('should dispatch the `receiveDiffSuccess` action', async () => {
const { diff, enrichData } = reports; const { diff, enrichData } = reports;
testAction( await testAction(
actions.fetchDiff, actions.fetchDiff,
{}, {},
{ ...rootState, ...state }, { ...rootState, ...state },
...@@ -141,7 +137,6 @@ describe('EE api fuzzing report actions', () => { ...@@ -141,7 +137,6 @@ describe('EE api fuzzing report actions', () => {
}, },
}, },
], ],
done,
); );
}); });
}); });
...@@ -152,10 +147,10 @@ describe('EE api fuzzing report actions', () => { ...@@ -152,10 +147,10 @@ describe('EE api fuzzing report actions', () => {
mock.onGet(diffEndpoint).replyOnce(200, reports.diff); mock.onGet(diffEndpoint).replyOnce(200, reports.diff);
}); });
it('should dispatch the `receiveDiffSuccess` action with empty enrich data', (done) => { it('should dispatch the `receiveDiffSuccess` action with empty enrich data', async () => {
const { diff } = reports; const { diff } = reports;
const enrichData = []; const enrichData = [];
testAction( await testAction(
actions.fetchDiff, actions.fetchDiff,
{}, {},
{ ...rootState, ...state }, { ...rootState, ...state },
...@@ -170,7 +165,6 @@ describe('EE api fuzzing report actions', () => { ...@@ -170,7 +165,6 @@ describe('EE api fuzzing report actions', () => {
}, },
}, },
], ],
done,
); );
}); });
}); });
...@@ -184,14 +178,13 @@ describe('EE api fuzzing report actions', () => { ...@@ -184,14 +178,13 @@ describe('EE api fuzzing report actions', () => {
.replyOnce(404); .replyOnce(404);
}); });
it('should dispatch the `receiveError` action', (done) => { it('should dispatch the `receiveError` action', async () => {
testAction( await testAction(
actions.fetchDiff, actions.fetchDiff,
{}, {},
{ ...rootState, ...state }, { ...rootState, ...state },
[], [],
[{ type: 'requestDiff' }, { type: 'receiveDiffError' }], [{ type: 'requestDiff' }, { type: 'receiveDiffError' }],
done,
); );
}); });
}); });
...@@ -205,14 +198,13 @@ describe('EE api fuzzing report actions', () => { ...@@ -205,14 +198,13 @@ describe('EE api fuzzing report actions', () => {
.replyOnce(200, reports.enrichData); .replyOnce(200, reports.enrichData);
}); });
it('should dispatch the `receiveDiffError` action', (done) => { it('should dispatch the `receiveDiffError` action', async () => {
testAction( await testAction(
actions.fetchDiff, actions.fetchDiff,
{}, {},
{ ...rootState, ...state }, { ...rootState, ...state },
[], [],
[{ type: 'requestDiff' }, { type: 'receiveDiffError' }], [{ type: 'requestDiff' }, { type: 'receiveDiffError' }],
done,
); );
}); });
}); });
......
...@@ -14,8 +14,8 @@ describe('EE sast report actions', () => { ...@@ -14,8 +14,8 @@ describe('EE sast report actions', () => {
}); });
describe('updateVulnerability', () => { describe('updateVulnerability', () => {
it(`should commit ${types.UPDATE_VULNERABILITY} with the correct response`, (done) => { it(`should commit ${types.UPDATE_VULNERABILITY} with the correct response`, async () => {
testAction( await testAction(
actions.updateVulnerability, actions.updateVulnerability,
issue, issue,
state, state,
...@@ -26,7 +26,6 @@ describe('EE sast report actions', () => { ...@@ -26,7 +26,6 @@ describe('EE sast report actions', () => {
}, },
], ],
[], [],
done,
); );
}); });
}); });
......
...@@ -14,8 +14,8 @@ describe('EE secret detection report actions', () => { ...@@ -14,8 +14,8 @@ describe('EE secret detection report actions', () => {
}); });
describe('updateVulnerability', () => { describe('updateVulnerability', () => {
it(`should commit ${types.UPDATE_VULNERABILITY} with the correct response`, (done) => { it(`should commit ${types.UPDATE_VULNERABILITY} with the correct response`, async () => {
testAction( await testAction(
actions.updateVulnerability, actions.updateVulnerability,
issue, issue,
state, state,
...@@ -26,7 +26,6 @@ describe('EE secret detection report actions', () => { ...@@ -26,7 +26,6 @@ describe('EE secret detection report actions', () => {
}, },
], ],
[], [],
done,
); );
}); });
}); });
......
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