Skip to content

Commit 44af2d9

Browse files
🐛 fix: Upgrade @aureooms/js-codec to make tests pass.
Thrown errors now inherit from Error.
1 parent c3ceb3b commit 44af2d9

File tree

4 files changed

+36
-226
lines changed

4 files changed

+36
-226
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
"url": "https://github.com/aureooms/js-codec-base16/issues"
2828
},
2929
"dependencies": {
30-
"@aureooms/js-codec": "^2.0.0",
30+
"@aureooms/js-codec": "^3.0.0",
3131
"@aureooms/js-itertools": "^3.4.0"
3232
},
3333
"devDependencies": {

test/src/decode.js

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,13 @@ success.title = ( _ , bytes , options , expected ) => `decode '${bytes}' succeed
1616

1717
function failure ( t , bytes , options , ExpectedError , position ) {
1818

19-
t.throws( ( ) => decode( bytes ) , CodecError ) ;
20-
t.throws( ( ) => decode( bytes ) , ExpectedError ) ;
21-
t.throws( ( ) => decode( bytes ) , ( error ) => error.encoding === 'base16' ) ;
22-
t.throws( ( ) => decode( bytes ) , ( error ) => error.object === bytes ) ;
23-
t.throws( ( ) => decode( bytes ) , ( error ) => error.position.start === position.start ) ;
24-
t.throws( ( ) => decode( bytes ) , ( error ) => error.position.end === position.end ) ;
19+
const error = t.throws( ( ) => decode( bytes ) ) ;
20+
t.true( error instanceof CodecError ) ;
21+
t.true( error instanceof ExpectedError ) ;
22+
t.is( error.encoding , 'base16' ) ;
23+
t.is( error.object , bytes ) ;
24+
t.is( error.position.start , position.start ) ;
25+
t.is( error.position.end , position.end ) ;
2526

2627
}
2728

test/src/encode.js

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,13 @@ success.title = ( _ , string , options , expected ) => `encode '${string}' shoul
1616

1717
function failure ( t , string , options , ExpectedError , position ) {
1818

19-
t.throws( ( ) => encode( string ) , CodecError ) ;
20-
t.throws( ( ) => encode( string ) , ExpectedError ) ;
21-
t.throws( ( ) => encode( string ) , ( error ) => error.encoding === 'base16' ) ;
22-
t.throws( ( ) => encode( string ) , ( error ) => error.object === string ) ;
23-
t.throws( ( ) => encode( string ) , ( error ) => error.position.start === position.start ) ;
24-
t.throws( ( ) => encode( string ) , ( error ) => error.position.end === position.end ) ;
19+
const error = t.throws( ( ) => encode( string ) ) ;
20+
t.true( error instanceof CodecError ) ;
21+
t.true( error instanceof ExpectedError ) ;
22+
t.is( error.encoding , 'base16' ) ;
23+
t.is( error.object , string ) ;
24+
t.is( error.position.start , position.start ) ;
25+
t.is( error.position.end , position.end ) ;
2526

2627
}
2728

0 commit comments

Comments
 (0)