mirror: A tiny/fast dataloader implementation
0

Configure Feed

Select the types of activity you want to include in your feed.

chore: adds test for the `.catch`

Marais Rossouw (Oct 23, 2023, 10:25 AM +1000) 645c7ec7 8403ff6a

+16
+16
src/index.test.ts
··· 288 288 assert.instance(items[2].error, Error); 289 289 }); 290 290 291 + errors('ensure the `.catch` is ran for length mismatch', async () => { 292 + const loader = spy(async (keys: string[]) => keys.slice(0, 1)); 293 + const e = spy((e) => e); 294 + 295 + const items = await Promise.all([ 296 + dldr.load(loader, 'a').catch(e), 297 + dldr.load(loader, 'b').catch(e), 298 + dldr.load(loader, 'c').catch(e) 299 + ]); 300 + 301 + assert.equal(loader.callCount, 1); 302 + assert.equal(loader.calls[0], [['a', 'b', 'c']]); 303 + assert.equal(e.callCount, 3); 304 + assert.instance(items[0], TypeError); 305 + }); 306 + 291 307 test('2 loaders nested in a .then chain', async () => { 292 308 const loader = spy(async (keys: string[]) => keys); 293 309