Skip to content

Commit 6f977f6

Browse files
authored
refactor(string): remove arbitrary limit from sample (#2497)
1 parent 6df70bc commit 6f977f6

File tree

3 files changed

+1
-18
lines changed

3 files changed

+1
-18
lines changed

src/modules/string/index.ts

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,6 @@ export type NumericChar =
7979
export type AlphaChar = LowerAlphaChar | UpperAlphaChar;
8080
export type AlphaNumericChar = AlphaChar | NumericChar;
8181

82-
const SAMPLE_MAX_LENGTH = 2 ** 20;
83-
8482
/**
8583
* Module to generate string related entries.
8684
*
@@ -621,7 +619,7 @@ export class StringModule extends SimpleModuleBase {
621619
/**
622620
* Returns a string containing UTF-16 chars between 33 and 125 (`!` to `}`).
623621
*
624-
* @param length Length of the generated string. Max length is `2^20`. Defaults to `10`.
622+
* @param length Length of the generated string. Defaults to `10`.
625623
* @param length.min The minimum number of characters to generate.
626624
* @param length.max The maximum number of characters to generate.
627625
*
@@ -647,9 +645,6 @@ export class StringModule extends SimpleModuleBase {
647645
} = 10
648646
): string {
649647
length = this.faker.helpers.rangeToNumber(length);
650-
if (length >= SAMPLE_MAX_LENGTH) {
651-
length = SAMPLE_MAX_LENGTH;
652-
}
653648

654649
const charCodeOption = {
655650
min: 33,

test/modules/datatype.spec.ts

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -330,12 +330,6 @@ describe('datatype', () => {
330330
expect(generatedString).toBe('');
331331
expect(generatedString).toHaveLength(0);
332332
});
333-
334-
it('should return string with length of 2^20 if bigger length value is passed', () => {
335-
const overMaxValue = Math.pow(2, 28);
336-
const generatedString = faker.datatype.string(overMaxValue);
337-
expect(generatedString).toHaveLength(Math.pow(2, 20));
338-
});
339333
});
340334

341335
describe('boolean', () => {

test/modules/string.spec.ts

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -724,12 +724,6 @@ describe('string', () => {
724724
expect(generatedString).toHaveLength(0);
725725
});
726726

727-
it('should return string with length of 2^20 if bigger length value is passed', () => {
728-
const overMaxValue = 2 ** 28;
729-
const generatedString = faker.string.sample(overMaxValue);
730-
expect(generatedString).toHaveLength(2 ** 20);
731-
});
732-
733727
it('should return string with a specific length', () => {
734728
const length = 1337;
735729
const generatedString = faker.string.sample(length);

0 commit comments

Comments
 (0)