Skip to content

Commit

Permalink
changed implementation of catch function
Browse files Browse the repository at this point in the history
  • Loading branch information
elshor committed Mar 11, 2018
1 parent 5d47b35 commit e6d6f14
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions test/test-catch.js
Expand Up @@ -3,8 +3,10 @@ const ds = require('..');
const Collection = ds.Collection;

t.test('test catch',(t)=>{
t.plan(1);
t.plan(2);
Collection(Promise.reject({message:'exception'})).catch((e)=>t.ok(e,'Caught single exception'));
Collection(Promise.resolve([1,2,3]))
.forEach((item)=>{if(item===2)throw new Error("Can't be 2");})
.catch((e)=>console.log('got',e));
.forEach((item)=>{
if(item===2)return Promise.reject("Can't be 2");
}).catch((e)=>console.log('got',e)||t.ok(e,'Caught exception in group'));
});

0 comments on commit e6d6f14

Please sign in to comment.