aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorc0per <[email protected]>2022-05-04 17:30:58 +0800
committerGitHub <[email protected]>2022-05-04 11:30:58 +0200
commit100a1ea230cba422174a6b5103c56bc4cf9c0dc4 (patch)
tree914de99f5f9a68eb0f9b081283c9c57ec6259154 /test
parent788af82d574b5f929f805ef6305e5953981c79f2 (diff)
downloadfaker-100a1ea230cba422174a6b5103c56bc4cf9c0dc4.tar.xz
faker-100a1ea230cba422174a6b5103c56bc4cf9c0dc4.zip
fix: empty array passed into helpers.arrayElements (#921)
Diffstat (limited to 'test')
-rw-r--r--test/helpers.spec.ts12
1 files changed, 12 insertions, 0 deletions
diff --git a/test/helpers.spec.ts b/test/helpers.spec.ts
index e436e6dc..819f08a3 100644
--- a/test/helpers.spec.ts
+++ b/test/helpers.spec.ts
@@ -543,6 +543,18 @@ describe('helpers', () => {
// Check uniqueness
expect(subset).toHaveLength(new Set(subset).size);
});
+
+ it('should return an empty array when receiving an empty array', () => {
+ const result = faker.helpers.arrayElements([]);
+
+ expect(result).toHaveLength(0);
+ });
+
+ it('should return an empty array when receiving an empty array and count > 0', () => {
+ const result = faker.helpers.arrayElements([], 3);
+
+ expect(result).toHaveLength(0);
+ });
});
describe('randomize()', () => {