debian-mirror-gitlab/spec/frontend/mocks/node/jquery.js

16 lines
342 B
JavaScript
Raw Normal View History

2019-09-30 21:07:59 +05:30
/* eslint-disable import/no-commonjs */
const $ = jest.requireActual('jquery');
// Fail tests for unmocked requests
$.ajax = () => {
2019-12-04 20:38:33 +05:30
const err = new Error(
2019-09-30 21:07:59 +05:30
'Unexpected unmocked jQuery.ajax() call! Make sure to mock jQuery.ajax() in tests.',
);
2019-12-04 20:38:33 +05:30
global.fail(err);
throw err;
2019-09-30 21:07:59 +05:30
};
// jquery is not an ES6 module
module.exports = $;