Skip to content

Commit 8532df9

Browse files
committed
test: add tests for arbitrary accumulator type
1 parent 02ec769 commit 8532df9

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

packages/collection/__tests__/collection.test.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -713,6 +713,11 @@ describe('reduce() tests', () => {
713713
expect<number>(sum).toStrictEqual(6);
714714
});
715715

716+
test('reduce collection into a single value with different accumulator type', () => {
717+
const str = coll.reduce((a, x) => a.concat(x.toString()), '');
718+
expect<string>(str).toStrictEqual('123');
719+
});
720+
716721
test('reduce empty collection with initial value', () => {
717722
const coll = createCollection();
718723
expect<number>(coll.reduce((a, x) => a + x, 0)).toStrictEqual(0);
@@ -746,6 +751,11 @@ describe('reduceRight() tests', () => {
746751
expect<number>(sum).toStrictEqual(6);
747752
});
748753

754+
test('reduce collection into a single value with different accumulator type', () => {
755+
const str = coll.reduceRight((a, x) => a.concat(x.toString()), '');
756+
expect<string>(str).toStrictEqual('321');
757+
});
758+
749759
test('reduce empty collection with initial value', () => {
750760
const coll = createCollection();
751761
expect<number>(coll.reduceRight((a, x) => a + x, 0)).toStrictEqual(0);

0 commit comments

Comments
 (0)