Skip to content

Commit 35aea5d

Browse files
committed
fix: 🐞 make options in toCollection optional
1 parent d62e3bd commit 35aea5d

File tree

2 files changed

+3
-6
lines changed

2 files changed

+3
-6
lines changed

β€Žpackages/falso/src/lib/collection.tsβ€Ž

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,7 @@ import { FakeOptions, fake } from './core/core';
1616

1717
export function toCollection<Collection, Options extends FakeOptions = never>(
1818
generator: () => Collection,
19-
options: Options
19+
options: Options = { length: 5 } as Options
2020
): Collection[] {
21-
return fake<Collection, Options>(() => generator(), {
22-
length: 5,
23-
...options,
24-
}) as Collection[];
21+
return fake<Collection, Options>(() => generator(), options) as Collection[];
2522
}

β€Žpackages/falso/src/tests/collection.spec.tsβ€Ž

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { randNumber } from '../lib/number';
33

44
describe('toCollection', () => {
55
it('should return an array of 5 items by default', () => {
6-
const result = toCollection(() => ({ data: 1 }), {});
6+
const result = toCollection(() => ({ data: 1 }));
77
expect(Array.isArray(result)).toBe(true);
88
expect(result).toHaveLength(5);
99
result.forEach((item) => expect(item).toEqual({ data: 1 }));

0 commit comments

Comments
Β (0)