import type { AsyncHandler } from 'asynchronous-handlers'; import { StatusArrayUnionHandler } from '../../../../src/util/handlers/StatusArrayUnionHandler'; describe('A StatusArrayUnionHandler', (): void => { let handlers: jest.Mocked>[]; let handler: StatusArrayUnionHandler>; beforeEach(async(): Promise => { handlers = [ { canHandle: jest.fn(), handle: jest.fn().mockResolvedValue([ 1, 2 ]), } satisfies Partial> as any, { canHandle: jest.fn(), handle: jest.fn().mockResolvedValue([ 3, 4 ]), } satisfies Partial> as any, ]; handler = new StatusArrayUnionHandler(handlers); }); it('merges the array results.', async(): Promise => { await expect(handler.handle('input')).resolves.toEqual([ 1, 2, 3, 4 ]); expect(handlers[0].handle).toHaveBeenCalledTimes(1); expect(handlers[0].handle).toHaveBeenLastCalledWith('input'); expect(handlers[1].handle).toHaveBeenCalledTimes(1); expect(handlers[1].handle).toHaveBeenLastCalledWith('input'); }); });