-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
zetxx
committed
Jun 4, 2021
1 parent
684cae6
commit 333fbd7
Showing
4 changed files
with
40 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
const tap = require('tap'); | ||
const CustomError = require('../../../lib/error'); | ||
|
||
const A = CustomError({code: 'A', message: 'msg-a'}); | ||
const B = CustomError({code: 'B', parent: A, message: 'msg-b'}); | ||
|
||
tap.test('Error', (t) => { | ||
t.type(CustomError, 'function', 'should be function'); | ||
t.type(A, 'function', 'should be function'); | ||
t.type(B, 'function', 'should be function'); | ||
const a1 = new A(); | ||
const a2 = new A('msg-a-2'); | ||
const a3 = new A('msg-a-3', {state: {a: 3}}); | ||
const b1 = new B(); | ||
t.equal(a1.message, 'msg-a', 'message should match'); | ||
t.equal(a1.state, null, 'state should be null'); | ||
t.equal(a2.message, 'msg-a-2', 'message should match'); | ||
t.equal(a3.message, 'msg-a-3', 'message should match'); | ||
t.same(a3.state, {a: 3}, 'state should match'); | ||
t.equal(a1.code, 'A', 'code should match'); | ||
t.equal(b1.code, 'A.B', 'code should match'); | ||
t.end(); | ||
}); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
require('./method/test.index'); | ||
require('./error/test.error'); | ||
require('./method/test.method'); | ||
// require('./all/test.index'); |
File renamed without changes.