Skip to content

Commit fc066db

Browse files
🔍 test: Fix t.throws calls.
1 parent 7287358 commit fc066db

File tree

2 files changed

+14
-12
lines changed

2 files changed

+14
-12
lines changed

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 === 'ascii' ) ;
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 , 'ascii' ) ;
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 '${JSON.stringify
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 === 'ascii' ) ;
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 , 'ascii' ) ;
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)