From 298cd80535bba275cfe2a02183cf630dddd6b3ef Mon Sep 17 00:00:00 2001 From: xDivisionByZerox Date: Fri, 22 Jul 2022 00:13:12 +0200 Subject: [PATCH] refactor(string): rename alphaNumeric to alphanumeric --- src/modules/random/index.ts | 4 ++-- src/modules/string/index.ts | 8 ++++---- src/modules/vehicle/index.ts | 4 ++-- test/__snapshots__/string.spec.ts.snap | 6 +++--- test/string.spec.ts | 26 +++++++++++++------------- 5 files changed, 24 insertions(+), 24 deletions(-) diff --git a/src/modules/random/index.ts b/src/modules/random/index.ts index d7bb7defa56..d94defe5968 100644 --- a/src/modules/random/index.ts +++ b/src/modules/random/index.ts @@ -194,11 +194,11 @@ export class Random { ): string { deprecated({ deprecated: 'faker.random.alphaNumeric()', - proposed: 'faker.string.alphaNumeric()', + proposed: 'faker.string.alphanumeric()', since: '8.0', until: '9.0', }); - return this.faker.string.alphaNumeric({ + return this.faker.string.alphanumeric({ bannedChars: options.bannedChars, casing: options.casing, count, diff --git a/src/modules/string/index.ts b/src/modules/string/index.ts index aa0781d9a35..ea2d640e60d 100644 --- a/src/modules/string/index.ts +++ b/src/modules/string/index.ts @@ -200,11 +200,11 @@ export class StringModule { * @param options.bannedChars An array of characters and digits which should be banned in the generated string. Defaults to `[]`. * * @example - * faker.string.alphaNumeric() // '2' - * faker.string.alphaNumeric(5) // '3e5v7' - * faker.string.alphaNumeric(5, { bannedChars: ["a"] }) // 'xszlm' + * faker.string.alphanumeric() // '2' + * faker.string.alphanumeric(5) // '3e5v7' + * faker.string.alphanumeric(5, { bannedChars: ["a"] }) // 'xszlm' */ - alphaNumeric( + alphanumeric( options: | number | { diff --git a/src/modules/vehicle/index.ts b/src/modules/vehicle/index.ts index 3f7bca8da68..ec4b6c438fb 100644 --- a/src/modules/vehicle/index.ts +++ b/src/modules/vehicle/index.ts @@ -76,7 +76,7 @@ export class Vehicle { */ vin(): string { const bannedChars = ['o', 'i', 'q', 'O', 'I', 'Q']; - return `${this.faker.string.alphaNumeric({ + return `${this.faker.string.alphanumeric({ count: 10, casing: 'upper', bannedChars, @@ -84,7 +84,7 @@ export class Vehicle { count: 1, casing: 'upper', bannedChars, - })}${this.faker.string.alphaNumeric({ + })}${this.faker.string.alphanumeric({ count: 1, casing: 'upper', bannedChars, diff --git a/test/__snapshots__/string.spec.ts.snap b/test/__snapshots__/string.spec.ts.snap index 89b0c02994f..8e0e09e3a58 100644 --- a/test/__snapshots__/string.spec.ts.snap +++ b/test/__snapshots__/string.spec.ts.snap @@ -8,7 +8,7 @@ exports[`string > random() > should return a deterministic string of given lengt exports[`string > seed: 42 > alpha() 1`] = `"t"`; -exports[`string > seed: 42 > alphaNumeric() 1`] = `"n"`; +exports[`string > seed: 42 > alphanumeric() 1`] = `"n"`; exports[`string > seed: 42 > hexadecimal() > should return a deterministic hex of given length 1`] = `"8BE4ABdd39321aD7d3fe01FfCE404F4d6db0906bd8"`; @@ -22,7 +22,7 @@ exports[`string > seed: 42 > uuid() 1`] = `"5cf2bc99-2721-407d-992b-a00fbdf302f2 exports[`string > seed: 1211 > alpha() 1`] = `"W"`; -exports[`string > seed: 1211 > alphaNumeric() 1`] = `"V"`; +exports[`string > seed: 1211 > alphanumeric() 1`] = `"V"`; exports[`string > seed: 1211 > hexadecimal() > should return a deterministic hex of given length 1`] = `"EaDB42F0e3f4A973fAB0AeefCE96DFCF49cD438dF9"`; @@ -36,7 +36,7 @@ exports[`string > seed: 1211 > uuid() 1`] = `"e7ec32f0-a2a3-4c65-abbd-0caabde64d exports[`string > seed: 1337 > alpha() 1`] = `"n"`; -exports[`string > seed: 1337 > alphaNumeric() 1`] = `"g"`; +exports[`string > seed: 1337 > alphanumeric() 1`] = `"g"`; exports[`string > seed: 1337 > hexadecimal() > should return a deterministic hex of given length 1`] = `"5c346ba075bd57F5A62B82d72AF39CBBB07a98cbA8"`; diff --git a/test/string.spec.ts b/test/string.spec.ts index 4c61e1ca9e6..32f4cb7f831 100644 --- a/test/string.spec.ts +++ b/test/string.spec.ts @@ -11,7 +11,7 @@ const functionNames: (keyof StringModule)[] = [ 'hexadecimal', 'random', 'alpha', - 'alphaNumeric', + 'alphanumeric', 'numeric', ]; @@ -212,7 +212,7 @@ describe('string', () => { describe('alphaNumeric', () => { it('should generate single character when no additional argument was provided', () => { - const actual = faker.string.alphaNumeric(); + const actual = faker.string.alphanumeric(); expect(actual).toHaveLength(1); }); @@ -222,12 +222,12 @@ describe('string', () => { ['lower', /^[a-z0-9]{250}$/], ['mixed', /^[a-zA-Z0-9]{250}$/], ] as const)('should return %s-case', (casing, pattern) => { - const actual = faker.string.alphaNumeric({ count: 250, casing }); + const actual = faker.string.alphanumeric({ count: 250, casing }); expect(actual).toMatch(pattern); }); it('should generate many random characters', () => { - const actual = faker.string.alphaNumeric(5); + const actual = faker.string.alphanumeric(5); expect(actual).toHaveLength(5); }); @@ -235,7 +235,7 @@ describe('string', () => { it.each([0, -1, -100])( 'should return empty string when length is <= 0', (length) => { - const actual = faker.string.alphaNumeric(length); + const actual = faker.string.alphanumeric(length); expect(actual).toBe(''); } @@ -243,7 +243,7 @@ describe('string', () => { it('should be able to ban all alphabetic characters', () => { const bannedChars = 'abcdefghijklmnopqrstuvwxyz'.split(''); - const alphaText = faker.string.alphaNumeric({ + const alphaText = faker.string.alphanumeric({ count: 5, bannedChars, casing: 'lower', @@ -257,7 +257,7 @@ describe('string', () => { it('should be able to ban all alphabetic characters via string', () => { const bannedChars = 'abcdefghijklmnopqrstuvwxyz'; - const alphaText = faker.string.alphaNumeric({ + const alphaText = faker.string.alphanumeric({ count: 5, bannedChars, casing: 'lower', @@ -271,7 +271,7 @@ describe('string', () => { it('should be able to ban all numeric characters', () => { const bannedChars = '0123456789'.split(''); - const alphaText = faker.string.alphaNumeric({ + const alphaText = faker.string.alphanumeric({ count: 5, bannedChars, }); @@ -284,7 +284,7 @@ describe('string', () => { it('should be able to ban all numeric characters via string', () => { const bannedChars = '0123456789'; - const alphaText = faker.string.alphaNumeric({ + const alphaText = faker.string.alphanumeric({ count: 5, bannedChars, }); @@ -296,7 +296,7 @@ describe('string', () => { }); it('should be able to handle mistake in banned characters array', () => { - const alphaText = faker.string.alphaNumeric({ + const alphaText = faker.string.alphanumeric({ count: 5, bannedChars: ['a', 'p', 'a'], casing: 'lower', @@ -309,7 +309,7 @@ describe('string', () => { it('should throw if all possible characters being banned', () => { const bannedChars = 'abcdefghijklmnopqrstuvwxyz0123456789'.split(''); expect(() => - faker.string.alphaNumeric({ + faker.string.alphanumeric({ count: 5, bannedChars, casing: 'lower', @@ -324,7 +324,7 @@ describe('string', () => { it('should throw if all possible characters being banned via string', () => { const bannedChars = 'abcdefghijklmnopqrstuvwxyz0123456789'; expect(() => - faker.string.alphaNumeric({ + faker.string.alphanumeric({ count: 5, bannedChars, casing: 'lower', @@ -341,7 +341,7 @@ describe('string', () => { count: 5, }); - expect(() => faker.string.alphaNumeric(input)).not.toThrow(); + expect(() => faker.string.alphanumeric(input)).not.toThrow(); expect(input.bannedChars).toEqual(['a', '0', '%']); }); });