Ignore:
Timestamp:
01/21/25 03:08:24 (3 days ago)
Author:
stefan toskovski <stefantoska84@…>
Branches:
main
Parents:
0c6b92a
Message:

F4 Finalna Verzija

File:
1 edited

Legend:

Unmodified
Added
Removed
  • imaps-frontend/node_modules/fastq/test/promise.js

    r0c6b92a r79a0317  
    247247  process.removeListener('unhandledRejection', handleRejection)
    248248})
     249
     250test('drained should resolve after async tasks complete', async function (t) {
     251  const logs = []
     252
     253  async function processTask () {
     254    await new Promise(resolve => setTimeout(resolve, 0))
     255    logs.push('processed')
     256  }
     257
     258  const queue = buildQueue(processTask, 1)
     259  queue.drain = () => logs.push('called drain')
     260
     261  queue.drained().then(() => logs.push('drained promise resolved'))
     262
     263  await Promise.all([
     264    queue.push(),
     265    queue.push(),
     266    queue.push()
     267  ])
     268
     269  t.deepEqual(logs, [
     270    'processed',
     271    'processed',
     272    'processed',
     273    'called drain',
     274    'drained promise resolved'
     275  ], 'events happened in correct order')
     276})
     277
     278test('drained should handle undefined drain function', async function (t) {
     279  const queue = buildQueue(worker, 1)
     280
     281  async function worker (arg) {
     282    await sleep(10)
     283    return arg
     284  }
     285
     286  queue.drain = undefined
     287  queue.push(1)
     288  await queue.drained()
     289
     290  t.pass('drained resolved successfully with undefined drain')
     291})
Note: See TracChangeset for help on using the changeset viewer.