2019-07-17 17:47:39 +00:00
|
|
|
import $ from 'jquery';
|
|
|
|
import axios from '~/lib/utils/axios_utils';
|
|
|
|
|
|
|
|
describe('Mock auto-injection', () => {
|
|
|
|
describe('mocks', () => {
|
2019-08-15 18:04:43 +00:00
|
|
|
let failMock;
|
|
|
|
beforeEach(() => {
|
|
|
|
failMock = jest.spyOn(global, 'fail').mockImplementation();
|
|
|
|
});
|
|
|
|
|
2022-02-14 21:12:27 +00:00
|
|
|
it('~/lib/utils/axios_utils', async () => {
|
|
|
|
await expect(axios.get('http://gitlab.com')).rejects.toThrow('Unexpected unmocked request');
|
|
|
|
|
|
|
|
expect(failMock).toHaveBeenCalledTimes(1);
|
2019-08-15 18:04:43 +00:00
|
|
|
});
|
2019-07-17 17:47:39 +00:00
|
|
|
|
|
|
|
it('jQuery.ajax()', () => {
|
|
|
|
expect($.ajax).toThrow('Unexpected unmocked');
|
2019-08-15 18:04:43 +00:00
|
|
|
expect(failMock).toHaveBeenCalledTimes(1);
|
2019-07-17 17:47:39 +00:00
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|