-
-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathtest.js
28 lines (26 loc) · 791 Bytes
/
test.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
import assert from 'assert';
import test from 'ava';
import isErrorConstructor from './index.js';
class CustomError extends RangeError {
constructor() {
super();
this.name = 'CustomError';
}
}
test('main', t => {
t.true(isErrorConstructor(Error));
t.true(isErrorConstructor(RangeError));
t.true(isErrorConstructor(SyntaxError));
t.true(isErrorConstructor(assert.AssertionError));
t.true(isErrorConstructor(CustomError));
t.false(isErrorConstructor(() => {}));
t.false(isErrorConstructor({}));
t.false(isErrorConstructor(''));
t.false(isErrorConstructor(new Error())); // eslint-disable-line unicorn/error-message
t.false(isErrorConstructor(new assert.AssertionError({
actual: '',
expected: '',
operator: ''
})));
t.false(isErrorConstructor(new CustomError()));
});