This repository was archived by the owner on Sep 20, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 17
Expand file tree
/
Copy pathutils.js
More file actions
38 lines (29 loc) · 1.33 KB
/
Copy pathutils.js
File metadata and controls
38 lines (29 loc) · 1.33 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
26
27
28
29
30
31
32
33
34
35
36
37
38
'use strict';
const ExtendableError = require('../lib/utils').ExtendableError;
describe('lib/utils', () => {
describe('Error', () => {
it('should be an Error inheritor', () => {
const error = new ExtendableError('msg');
assert.isTrue(error instanceof Error);
});
it('should create regular error if only message specified', () => {
const error = new ExtendableError('msg');
assert.equal(error.message, 'msg');
assert.match(error.stack, /^Error: msg\n/);
assert.notInclude(error.stack, '\nCaused by:\n');
});
it('should create regular error if cause exception has no stack', () => {
const error = new ExtendableError('msg', {});
assert.equal(error.message, 'msg');
assert.match(error.stack, /^Error: msg\n/);
assert.notInclude(error.stack, '\nCaused by:\n');
});
it('should create error with extended stack if cause exception has stack', () => {
const error = new ExtendableError('msg', {stack: 'Custom stack'});
assert.equal(error.message, 'msg');
assert.match(error.stack, /^Error: msg\n/);
assert.include(error.stack, '\nCaused by:\n');
assert.include(error.stack, '\nCustom stack');
});
});
});