Commit 163c8a8c authored by Natalia Tepluhina's avatar Natalia Tepluhina

Merge branch 'vs-migrate-issue-analytics-to-jest' into 'master'

Migrate ee/issue_analytics to jest

Closes #194292

See merge request gitlab-org/gitlab!27143
parents 6b8e175b fd12733f
import MockAdapter from 'axios-mock-adapter';
import testAction from 'spec/helpers/vuex_action_helper';
import testAction from 'helpers/vuex_action_helper';
import * as actions from 'ee/issues_analytics/stores/modules/issue_analytics/actions';
import axios from '~/lib/utils/axios_utils';
describe('Issue analytics store actions', () => {
describe('setFilters', () => {
it('commits SET_FILTERS', done => {
testAction(
actions.setFilters,
null,
null,
[{ type: 'SET_FILTERS', payload: null }],
[],
done,
);
it('commits SET_FILTERS', () => {
testAction(actions.setFilters, null, null, [{ type: 'SET_FILTERS', payload: null }], []);
});
});
describe('setLoadingState', () => {
it('commits SET_LOADING_STATE', done => {
it('commits SET_LOADING_STATE', () => {
testAction(
actions.setLoadingState,
true,
null,
[{ type: 'SET_LOADING_STATE', payload: true }],
[],
done,
);
});
});
......@@ -37,8 +29,8 @@ describe('Issue analytics store actions', () => {
const chartData = { '2017-11': 0, '2017-12': 2 };
beforeEach(() => {
dispatch = jasmine.createSpy('dispatch');
commit = jasmine.createSpy('commit');
dispatch = jest.fn().mockName('dispatch');
commit = jest.fn().mockName('commit');
mock = new MockAdapter(axios);
mock.onGet().reply(200, chartData);
......@@ -48,7 +40,7 @@ describe('Issue analytics store actions', () => {
mock.restore();
});
it('commits SET_CHART_DATA with chart data', done => {
it('commits SET_CHART_DATA with chart data', () => {
const getters = { appliedFilters: '?hello=world' };
const context = {
dispatch,
......@@ -56,15 +48,11 @@ describe('Issue analytics store actions', () => {
commit,
};
actions
.fetchChartData(context, gl.TEST_HOST)
.then(() => {
expect(dispatch.calls.argsFor(0)).toEqual(['setLoadingState', true]);
return actions.fetchChartData(context, gl.TEST_HOST).then(() => {
expect(dispatch.mock.calls[0]).toEqual(['setLoadingState', true]);
expect(commit).toHaveBeenCalledWith('SET_CHART_DATA', chartData);
expect(dispatch.calls.argsFor(1)).toEqual(['setLoadingState', false]);
})
.then(done)
.catch(done.fail);
expect(dispatch.mock.calls[1]).toEqual(['setLoadingState', false]);
});
});
});
});
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