Skip to content

Commit

Permalink
♻️ refactor(tests): Test each error individually.
Browse files Browse the repository at this point in the history
  • Loading branch information
make-github-pseudonymous-again committed Mar 15, 2021
1 parent 9f791b2 commit 1c84899
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions test/src/error.js
Expand Up @@ -22,19 +22,19 @@ const errors = [
StopIteration ,
] ;

function willThrow ( SpecificError ) {
return function () { throw new SpecificError(); } ;
}

test( 'error' , t => {
const macro = (t, SpecificError) => {

const r = Math.random();
const s = r.toString();

for ( const SpecificError of errors ) {
t.truthy( new SpecificError( ) ) ;
t.is( ( new SpecificError( r ) ).message , s ) ;
t.throws( willThrow(SpecificError) , { instanceOf: SpecificError } ) ;
}
t.truthy( new SpecificError( ) ) ;
t.is( ( new SpecificError( r ) ).message , s ) ;
t.throws( () => { throw new SpecificError() ; } , { instanceOf: SpecificError } ) ;

};

}) ;
macro.title = (title, SpecificError) => title || (new SpecificError()).name;

for (const error of errors) {
test(macro, error);
}

0 comments on commit 1c84899

Please sign in to comment.