From 99c16e40c88ae6788eb2bf942fd62c035cbc707e Mon Sep 17 00:00:00 2001 From: xDivisionByZerox Date: Fri, 14 Apr 2023 00:35:13 +0200 Subject: [PATCH] refactor(helpers): remove default value from arrayElements --- src/modules/helpers/index.ts | 4 +--- test/__snapshots__/helpers.spec.ts.snap | 21 --------------------- test/helpers.spec.ts | 3 +-- 3 files changed, 2 insertions(+), 26 deletions(-) diff --git a/src/modules/helpers/index.ts b/src/modules/helpers/index.ts index 980837dd474..9ec31f007d5 100644 --- a/src/modules/helpers/index.ts +++ b/src/modules/helpers/index.ts @@ -883,9 +883,7 @@ export class HelpersModule { * @since 6.3.0 */ arrayElements( - // TODO @Shinigami92 2022-04-30: We want to remove this default value, but currently it's not possible because some definitions could be empty - // See https://github.com/faker-js/faker/issues/893 - array: ReadonlyArray = ['a', 'b', 'c'] as unknown as ReadonlyArray, + array: ReadonlyArray, count?: | number | { diff --git a/test/__snapshots__/helpers.spec.ts.snap b/test/__snapshots__/helpers.spec.ts.snap index 19e52c4ac09..64562da72e0 100644 --- a/test/__snapshots__/helpers.spec.ts.snap +++ b/test/__snapshots__/helpers.spec.ts.snap @@ -2,13 +2,6 @@ exports[`helpers > 42 > arrayElement > with array 1`] = `"o"`; -exports[`helpers > 42 > arrayElements > noArgs 1`] = ` -[ - "b", - "c", -] -`; - exports[`helpers > 42 > arrayElements > with array 1`] = ` [ "r", @@ -226,14 +219,6 @@ exports[`helpers > 42 > weightedArrayElement > with array with percentages 1`] = exports[`helpers > 1211 > arrayElement > with array 1`] = `"!"`; -exports[`helpers > 1211 > arrayElements > noArgs 1`] = ` -[ - "a", - "c", - "b", -] -`; - exports[`helpers > 1211 > arrayElements > with array 1`] = ` [ "d", @@ -467,12 +452,6 @@ exports[`helpers > 1211 > weightedArrayElement > with array with percentages 1`] exports[`helpers > 1337 > arrayElement > with array 1`] = `"l"`; -exports[`helpers > 1337 > arrayElements > noArgs 1`] = ` -[ - "b", -] -`; - exports[`helpers > 1337 > arrayElements > with array 1`] = ` [ "l", diff --git a/test/helpers.spec.ts b/test/helpers.spec.ts index c48a1128f37..53686605bcd 100644 --- a/test/helpers.spec.ts +++ b/test/helpers.spec.ts @@ -119,8 +119,7 @@ describe('helpers', () => { }); t.describe('arrayElements', (t) => { - t.it('noArgs') - .it('with array', 'Hello World!'.split('')) + t.it('with array', 'Hello World!'.split('')) .it('with array and count', 'Hello World!'.split(''), 3) .it('with array and count range', 'Hello World!'.split(''), { min: 1,