Skip to content

Commit

Permalink
🐛 fix: Upgrade @aureooms/js-codec to make tests pass.
Browse files Browse the repository at this point in the history
Thrown errors now inherit from Error.
  • Loading branch information
make-github-pseudonymous-again committed Apr 28, 2020
1 parent c3ceb3b commit 44af2d9
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 226 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
"url": "https://github.com/aureooms/js-codec-base16/issues"
},
"dependencies": {
"@aureooms/js-codec": "^2.0.0",
"@aureooms/js-codec": "^3.0.0",
"@aureooms/js-itertools": "^3.4.0"
},
"devDependencies": {
Expand Down
13 changes: 7 additions & 6 deletions test/src/decode.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,13 @@ success.title = ( _ , bytes , options , expected ) => `decode '${bytes}' succeed

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

t.throws( ( ) => decode( bytes ) , CodecError ) ;
t.throws( ( ) => decode( bytes ) , ExpectedError ) ;
t.throws( ( ) => decode( bytes ) , ( error ) => error.encoding === 'base16' ) ;
t.throws( ( ) => decode( bytes ) , ( error ) => error.object === bytes ) ;
t.throws( ( ) => decode( bytes ) , ( error ) => error.position.start === position.start ) ;
t.throws( ( ) => decode( bytes ) , ( error ) => error.position.end === position.end ) ;
const error = t.throws( ( ) => decode( bytes ) ) ;
t.true( error instanceof CodecError ) ;
t.true( error instanceof ExpectedError ) ;
t.is( error.encoding , 'base16' ) ;
t.is( error.object , bytes ) ;
t.is( error.position.start , position.start ) ;
t.is( error.position.end , position.end ) ;

}

Expand Down
13 changes: 7 additions & 6 deletions test/src/encode.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,13 @@ success.title = ( _ , string , options , expected ) => `encode '${string}' shoul

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

t.throws( ( ) => encode( string ) , CodecError ) ;
t.throws( ( ) => encode( string ) , ExpectedError ) ;
t.throws( ( ) => encode( string ) , ( error ) => error.encoding === 'base16' ) ;
t.throws( ( ) => encode( string ) , ( error ) => error.object === string ) ;
t.throws( ( ) => encode( string ) , ( error ) => error.position.start === position.start ) ;
t.throws( ( ) => encode( string ) , ( error ) => error.position.end === position.end ) ;
const error = t.throws( ( ) => encode( string ) ) ;
t.true( error instanceof CodecError ) ;
t.true( error instanceof ExpectedError ) ;
t.is( error.encoding , 'base16' ) ;
t.is( error.object , string ) ;
t.is( error.position.start , position.start ) ;
t.is( error.position.end , position.end ) ;

}

Expand Down
Loading

0 comments on commit 44af2d9

Please sign in to comment.