-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patherrors.test.js
More file actions
25 lines (21 loc) · 1.04 KB
/
errors.test.js
File metadata and controls
25 lines (21 loc) · 1.04 KB
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
import { assert } from './test-utils/deps-node.js';
import { HDSLibError } from '../ts/errors.ts';
describe('[ERRX] HDSLibError', () => {
it('[ERRS] HDSLibError.toString() without inner message', async () => {
const error = new HDSLibError('Hello');
assert.equal(error.message, 'Hello');
assert.equal('' + error, 'Error: Hello\nInner Object:\n{}');
});
it('[ERRM] HDSLibError.toString() with inner message', async () => {
const innerObject = { message: 'Bob', dummy: 'Dummy' };
const error = new HDSLibError('Hello', innerObject);
assert.equal(error.message, 'Hello >> Bob');
assert.equal('' + error, 'Error: Hello >> Bob\nInner Object:\n{\n "message": "Bob",\n "dummy": "Dummy"\n}');
assert.deepEqual(error.innerObject, innerObject);
});
it('[ERRO] HDSLibError.toString() with bject without message', async () => {
const error = new HDSLibError('Hello', { dummy: 'Dummy' });
assert.equal(error.message, 'Hello');
assert.equal('' + error, 'Error: Hello\nInner Object:\n{\n "dummy": "Dummy"\n}');
});
});