Skip to content

Commit ce1e1ca

Browse files
🔍 test: Fix t.throws calls.
1 parent 2baf1b5 commit ce1e1ca

File tree

2 files changed

+12
-14
lines changed

2 files changed

+12
-14
lines changed

test/src/decode.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,14 @@ from_ascii.title = success.title ;
2525

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

28-
t.throws( ( ) => decode( bytes , options ) , ExpectedError ) ;
28+
const error = t.throws( ( ) => decode( bytes , options ) , { instanceOf: ExpectedError } ) ;
2929

3030
if ( position ) {
31-
t.throws( ( ) => decode( bytes , options ) , CodecError ) ;
32-
t.throws( ( ) => decode( bytes , options ) , ( error ) => error.encoding === 'base64' ) ;
33-
t.throws( ( ) => decode( bytes , options ) , ( error ) => error.object === bytes ) ;
34-
t.throws( ( ) => decode( bytes , options ) , ( error ) => error.position.start === position.start ) ;
35-
t.throws( ( ) => decode( bytes , options ) , ( error ) => error.position.end === position.end ) ;
31+
t.true( error instanceof CodecError ) ;
32+
t.is( error.encoding , 'base64' ) ;
33+
t.is( error.object , bytes ) ;
34+
t.is( error.position.start , position.start ) ;
35+
t.is( error.position.end , position.end ) ;
3636
}
3737

3838
}

test/src/encode.js

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,16 +25,14 @@ from_ascii.title = success.title ;
2525

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

28-
t.throws( ( ) => encode( string , options ) , ExpectedError ) ;
28+
const error = t.throws( ( ) => encode( string , options ) , { instanceOf: ExpectedError } ) ;
2929

3030
if ( position ) {
31-
32-
t.throws( ( ) => encode( string , options ) , CodecError ) ;
33-
t.throws( ( ) => encode( string , options ) , ( error ) => error.encoding === 'base64' ) ;
34-
t.throws( ( ) => encode( string , options ) , ( error ) => error.object === string ) ;
35-
t.throws( ( ) => encode( string , options ) , ( error ) => error.position.start === position.start ) ;
36-
t.throws( ( ) => encode( string , options ) , ( error ) => error.position.end === position.end ) ;
37-
31+
t.true( error instanceof CodecError ) ;
32+
t.is( error.encoding , 'base64' ) ;
33+
t.is( error.object , string ) ;
34+
t.is( error.position.start , position.start ) ;
35+
t.is( error.position.end , position.end ) ;
3836
}
3937

4038
}

0 commit comments

Comments
 (0)