refactor(collection): reduce reduce's code (#9581)

* refactor(collection): reduce `reduce`'s code

* fix: resolved bug in tests

---------

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
This commit is contained in:
Aura Román
2023-05-18 23:05:48 +02:00
committed by GitHub
parent 3535321b98
commit b85a3f2dde
2 changed files with 16 additions and 21 deletions

View File

@@ -700,12 +700,17 @@ describe('reduce() tests', () => {
test('reduce collection into a single value with initial value', () => {
const sum = coll.reduce((a, x) => a + x, 0);
expect(sum).toStrictEqual(6);
expect<number>(sum).toStrictEqual(6);
});
test('reduce collection into a single value without initial value', () => {
const sum = coll.reduce<number>((a, x) => a + x);
expect(sum).toStrictEqual(6);
const sum = coll.reduce((a, x) => a + x);
expect<number>(sum).toStrictEqual(6);
});
test('reduce empty collection with initial value', () => {
const coll = createCollection();
expect(coll.reduce((a, x) => a + x, 0)).toStrictEqual(0);
});
test('reduce empty collection without initial value', () => {