Something went wrong. Try again.
[READ-ONLY] Mirror of https://github.com/wojtekmaj/async-array-utils. A collection of array-related async utilities.
array array-methods async promise utils
Something went wrong. Try again.
760 B · 21 lines
JavaScript
at yarn-2
12345678910111213141516171819202122import asyncReduce from './reduce';
describe('asyncReduce()', () => { it.skip('assertions below are valid for synchronous .reduce()', () => { const mapper = jest.fn().mockImplementation((temp, cur, idx) => [...temp, `${idx}:${cur}`]);
const result = ['a', 'b', 'c'].reduce(mapper, ['start']);
expect(mapper).toHaveBeenCalledTimes(3); expect(result).toEqual(['start', '0:a', '1:b', '2:c']); });
it('reduces an array properly', async () => { const mapper = jest.fn().mockImplementation(async (temp, cur, idx) => [...temp, `${idx}:${cur}`]);
const result = await asyncReduce(['a', 'b', 'c'], mapper, ['start']);
expect(mapper).toHaveBeenCalledTimes(3); expect(result).toEqual(['start', '0:a', '1:b', '2:c']); });});