Commit 98c3321d authored by Himanshu Kapoor's avatar Himanshu Kapoor

Migrate javascripts/related_merge_requests to Jest

Migrate tests from spec/javascripts/related_merge_requests from karma
to jest.
parent dfaf03f3
......@@ -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