Skip to content

Commit

Permalink
chore: adds test for the .catch
Browse files Browse the repository at this point in the history
  • Loading branch information
maraisr committed Oct 23, 2023
1 parent 8403ff6 commit 645c7ec
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,22 @@ errors('rejects all promises for the same key', async () => {
assert.instance(items[2].error, Error);
});

errors('ensure the `.catch` is ran for length mismatch', async () => {
const loader = spy(async (keys: string[]) => keys.slice(0, 1));
const e = spy((e) => e);

const items = await Promise.all([
dldr.load(loader, 'a').catch(e),
dldr.load(loader, 'b').catch(e),
dldr.load(loader, 'c').catch(e)
]);

assert.equal(loader.callCount, 1);
assert.equal(loader.calls[0], [['a', 'b', 'c']]);
assert.equal(e.callCount, 3);
assert.instance(items[0], TypeError);
});

test('2 loaders nested in a .then chain', async () => {
const loader = spy(async (keys: string[]) => keys);

Expand Down

0 comments on commit 645c7ec

Please sign in to comment.