2020-09-26 09:05:55 +08:00
|
|
|
module.exports = () => {
|
2024-07-31 04:09:42 +08:00
|
|
|
const warnings = [];
|
2020-09-26 09:05:55 +08:00
|
|
|
let oldWarn;
|
|
|
|
|
|
|
|
beforeEach(done => {
|
|
|
|
oldWarn = console.warn;
|
|
|
|
console.warn = m => warnings.push(m);
|
|
|
|
done();
|
|
|
|
});
|
|
|
|
|
|
|
|
afterEach(done => {
|
|
|
|
expectWarning();
|
|
|
|
console.warn = oldWarn;
|
|
|
|
done();
|
|
|
|
});
|
|
|
|
|
2020-09-27 17:26:32 +08:00
|
|
|
const expectWarning = (...regexp) => {
|
|
|
|
expect(warnings).toEqual(regexp.map(r => expect.stringMatching(r)));
|
2020-09-26 09:05:55 +08:00
|
|
|
warnings.length = 0;
|
|
|
|
};
|
|
|
|
|
|
|
|
return expectWarning;
|
|
|
|
};
|