Skip to content

Commit

Permalink
🔍 test: Fix t.throws calls.
Browse files Browse the repository at this point in the history
  • Loading branch information
make-github-pseudonymous-again committed Apr 28, 2020
1 parent 7287358 commit fc066db
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 12 deletions.
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 === 'ascii' ) ;
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 , 'ascii' ) ;
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 '${JSON.stringify

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

t.throws( ( ) => encode( string ) , CodecError ) ;
t.throws( ( ) => encode( string ) , ExpectedError ) ;
t.throws( ( ) => encode( string ) , ( error ) => error.encoding === 'ascii' ) ;
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 , 'ascii' ) ;
t.is( error.object , string ) ;
t.is( error.position.start , position.start ) ;
t.is( error.position.end , position.end ) ;

}

Expand Down

0 comments on commit fc066db

Please sign in to comment.