-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathspec.js
49 lines (41 loc) · 973 Bytes
/
spec.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
const stubs = {};
let handle;
describe('handle-rejection', async() => {
const on = process.on;
const consoleerror = console.error;
beforeEach(() => {
process.on = (...args) => stubs.on(...args);
console.error = (...args) => stubs.console(...args);
stubs.on = () => null;
delete require.cache[require.resolve('.')];
handle = require('.');
});
after(() => {
delete require.cache[require.resolve('.')];
process.on = on;
console.error = consoleerror;
});
it('Should call on multiple handlers', async() => {
let consoled = false;
let called = false;
stubs.console = () => {
consoled = true;
};
function custom() {
called = true;
}
stubs.on = (name, fn) => fn();
handle('console', custom);
expect(called).to.be.true;
expect(consoled).to.be.true;
});
[
'collect',
'console',
'exit',
'throw',
].forEach(fn => it(
`Should expose built in function ${fn}`,
() => expect(handle[fn]).to.be.a('function'),
));
});