Skip to content
This repository has been archived by the owner on Apr 20, 2023. It is now read-only.

Commit

Permalink
test(queued): test fail early if processOnlyOnce
Browse files Browse the repository at this point in the history
  • Loading branch information
claudiocro committed Oct 5, 2017
1 parent fd14c2d commit 2a0dd84
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions test/unit/queued.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,32 @@ describe('queued', () => {
const results = [];
const sequence = queued();

const sequencedCall1 = sequence({ processOnlyOnce: true })(delayedPromiseCall());


results.push(sequencedCall1(200).catch((error) => {
expect(error.result).to.equal(200);
return error.result;
}));


results.push(sequencedCall1(100).catch((error) => {
expect(error.result).to.equal(null);
return error.result;
}));

results.push(sequencedCall1(1).then((d) => {
expect(d).to.equal(1);
return d;
}));

return Promise.all(results);
});

it('processes only once after promise comes back', async () => {
const results = [];
const sequence = queued();

const sequencedCall1 = sequence()(delayedPromiseCall());
const sequencedCall2 = sequence({ processOnlyOnce: true })(delayedPromiseCall());
const sequencedCall3 = sequence()(delayedPromiseCall());
Expand Down

0 comments on commit 2a0dd84

Please sign in to comment.