Commit 8c7b3823 authored by Natalia Tepluhina's avatar Natalia Tepluhina

Merge branch 'himkp-jest-related-mrs' into 'master'

Migrate spec/javascripts/related_merge_requests/ to Jest

Closes #194253

See merge request gitlab-org/gitlab!32510
parents d194f3dc 98c3321d
......@@ -17,6 +17,12 @@ describe('RelatedMergeRequests', () => {
beforeEach(done => {
loadFixtures(FIXTURE_PATH);
mockData = getJSONFixture(FIXTURE_PATH);
// put the fixture in DOM as the component expects
document.body.innerHTML = `<div id="js-issuable-app-initial-data">${JSON.stringify(
mockData,
)}</div>`;
mock = new MockAdapter(axios);
mock.onGet(`${API_ENDPOINT}?per_page=100`).reply(200, mockData, { 'x-total': 2 });
......@@ -30,7 +36,7 @@ describe('RelatedMergeRequests', () => {
},
});
setTimeout(done);
setImmediate(done);
});
afterEach(() => {
......
import MockAdapter from 'axios-mock-adapter';
import testAction from 'spec/helpers/vuex_action_helper';
import createFlash from '~/flash';
import testAction from 'helpers/vuex_action_helper';
import axios from '~/lib/utils/axios_utils';
import * as types from '~/related_merge_requests/store/mutation_types';
import actionsModule, * as actions from '~/related_merge_requests/store/actions';
import * as actions from '~/related_merge_requests/store/actions';
jest.mock('~/flash');
describe('RelatedMergeRequest store actions', () => {
let state;
let flashSpy;
let mock;
beforeEach(() => {
state = {
apiEndpoint: '/api/related_merge_requests',
};
flashSpy = spyOnDependency(actionsModule, 'createFlash');
mock = new MockAdapter(axios);
});
......@@ -98,8 +99,8 @@ describe('RelatedMergeRequest store actions', () => {
[],
[{ type: 'requestData' }, { type: 'receiveDataError' }],
() => {
expect(flashSpy).toHaveBeenCalledTimes(1);
expect(flashSpy).toHaveBeenCalledWith(jasmine.stringMatching('Something went wrong'));
expect(createFlash).toHaveBeenCalledTimes(1);
expect(createFlash).toHaveBeenCalledWith(expect.stringMatching('Something went wrong'));
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