Skip to content

Commit afa3cf8

Browse files
refactor(string): rename alphaNumeric to alphanumeric
1 parent a7a2611 commit afa3cf8

File tree

5 files changed

+24
-24
lines changed

5 files changed

+24
-24
lines changed

src/modules/random/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -194,11 +194,11 @@ export class Random {
194194
): string {
195195
deprecated({
196196
deprecated: 'faker.random.alphaNumeric()',
197-
proposed: 'faker.string.alphaNumeric()',
197+
proposed: 'faker.string.alphanumeric()',
198198
since: '8.0',
199199
until: '9.0',
200200
});
201-
return this.faker.string.alphaNumeric({
201+
return this.faker.string.alphanumeric({
202202
bannedChars: options.bannedChars,
203203
casing: options.casing,
204204
count,

src/modules/string/index.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -200,11 +200,11 @@ export class StringModule {
200200
* @param options.bannedChars An array of characters and digits which should be banned in the generated string. Defaults to `[]`.
201201
*
202202
* @example
203-
* faker.string.alphaNumeric() // '2'
204-
* faker.string.alphaNumeric(5) // '3e5v7'
205-
* faker.string.alphaNumeric(5, { bannedChars: ["a"] }) // 'xszlm'
203+
* faker.string.alphanumeric() // '2'
204+
* faker.string.alphanumeric(5) // '3e5v7'
205+
* faker.string.alphanumeric(5, { bannedChars: ["a"] }) // 'xszlm'
206206
*/
207-
alphaNumeric(
207+
alphanumeric(
208208
options:
209209
| number
210210
| {

src/modules/vehicle/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,15 +76,15 @@ export class Vehicle {
7676
*/
7777
vin(): string {
7878
const bannedChars = ['o', 'i', 'q', 'O', 'I', 'Q'];
79-
return `${this.faker.string.alphaNumeric({
79+
return `${this.faker.string.alphanumeric({
8080
count: 10,
8181
casing: 'upper',
8282
bannedChars,
8383
})}${this.faker.string.alpha({
8484
count: 1,
8585
casing: 'upper',
8686
bannedChars,
87-
})}${this.faker.string.alphaNumeric({
87+
})}${this.faker.string.alphanumeric({
8888
count: 1,
8989
casing: 'upper',
9090
bannedChars,

test/__snapshots__/string.spec.ts.snap

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ exports[`string > random() > should return a deterministic string of given lengt
88
99
exports[`string > seed: 42 > alpha() 1`] = `"t"`;
1010
11-
exports[`string > seed: 42 > alphaNumeric() 1`] = `"n"`;
11+
exports[`string > seed: 42 > alphanumeric() 1`] = `"n"`;
1212
1313
exports[`string > seed: 42 > hexadecimal() > should return a deterministic hex of given length 1`] = `"8BE4ABdd39321aD7d3fe01FfCE404F4d6db0906bd8"`;
1414
@@ -22,7 +22,7 @@ exports[`string > seed: 42 > uuid() 1`] = `"5cf2bc99-2721-407d-992b-a00fbdf302f2
2222
2323
exports[`string > seed: 1211 > alpha() 1`] = `"W"`;
2424
25-
exports[`string > seed: 1211 > alphaNumeric() 1`] = `"V"`;
25+
exports[`string > seed: 1211 > alphanumeric() 1`] = `"V"`;
2626
2727
exports[`string > seed: 1211 > hexadecimal() > should return a deterministic hex of given length 1`] = `"EaDB42F0e3f4A973fAB0AeefCE96DFCF49cD438dF9"`;
2828
@@ -36,7 +36,7 @@ exports[`string > seed: 1211 > uuid() 1`] = `"e7ec32f0-a2a3-4c65-abbd-0caabde64d
3636
3737
exports[`string > seed: 1337 > alpha() 1`] = `"n"`;
3838
39-
exports[`string > seed: 1337 > alphaNumeric() 1`] = `"g"`;
39+
exports[`string > seed: 1337 > alphanumeric() 1`] = `"g"`;
4040
4141
exports[`string > seed: 1337 > hexadecimal() > should return a deterministic hex of given length 1`] = `"5c346ba075bd57F5A62B82d72AF39CBBB07a98cbA8"`;
4242

test/string.spec.ts

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ const functionNames: (keyof StringModule)[] = [
1111
'hexadecimal',
1212
'random',
1313
'alpha',
14-
'alphaNumeric',
14+
'alphanumeric',
1515
'numeric',
1616
];
1717

@@ -212,7 +212,7 @@ describe('string', () => {
212212

213213
describe('alphaNumeric', () => {
214214
it('should generate single character when no additional argument was provided', () => {
215-
const actual = faker.string.alphaNumeric();
215+
const actual = faker.string.alphanumeric();
216216

217217
expect(actual).toHaveLength(1);
218218
});
@@ -222,28 +222,28 @@ describe('string', () => {
222222
['lower', /^[a-z0-9]{250}$/],
223223
['mixed', /^[a-zA-Z0-9]{250}$/],
224224
] as const)('should return %s-case', (casing, pattern) => {
225-
const actual = faker.string.alphaNumeric({ count: 250, casing });
225+
const actual = faker.string.alphanumeric({ count: 250, casing });
226226
expect(actual).toMatch(pattern);
227227
});
228228

229229
it('should generate many random characters', () => {
230-
const actual = faker.string.alphaNumeric(5);
230+
const actual = faker.string.alphanumeric(5);
231231

232232
expect(actual).toHaveLength(5);
233233
});
234234

235235
it.each([0, -1, -100])(
236236
'should return empty string when length is <= 0',
237237
(length) => {
238-
const actual = faker.string.alphaNumeric(length);
238+
const actual = faker.string.alphanumeric(length);
239239

240240
expect(actual).toBe('');
241241
}
242242
);
243243

244244
it('should be able to ban all alphabetic characters', () => {
245245
const bannedChars = 'abcdefghijklmnopqrstuvwxyz'.split('');
246-
const alphaText = faker.string.alphaNumeric({
246+
const alphaText = faker.string.alphanumeric({
247247
count: 5,
248248
bannedChars,
249249
casing: 'lower',
@@ -257,7 +257,7 @@ describe('string', () => {
257257

258258
it('should be able to ban all alphabetic characters via string', () => {
259259
const bannedChars = 'abcdefghijklmnopqrstuvwxyz';
260-
const alphaText = faker.string.alphaNumeric({
260+
const alphaText = faker.string.alphanumeric({
261261
count: 5,
262262
bannedChars,
263263
casing: 'lower',
@@ -271,7 +271,7 @@ describe('string', () => {
271271

272272
it('should be able to ban all numeric characters', () => {
273273
const bannedChars = '0123456789'.split('');
274-
const alphaText = faker.string.alphaNumeric({
274+
const alphaText = faker.string.alphanumeric({
275275
count: 5,
276276
bannedChars,
277277
});
@@ -284,7 +284,7 @@ describe('string', () => {
284284

285285
it('should be able to ban all numeric characters via string', () => {
286286
const bannedChars = '0123456789';
287-
const alphaText = faker.string.alphaNumeric({
287+
const alphaText = faker.string.alphanumeric({
288288
count: 5,
289289
bannedChars,
290290
});
@@ -296,7 +296,7 @@ describe('string', () => {
296296
});
297297

298298
it('should be able to handle mistake in banned characters array', () => {
299-
const alphaText = faker.string.alphaNumeric({
299+
const alphaText = faker.string.alphanumeric({
300300
count: 5,
301301
bannedChars: ['a', 'p', 'a'],
302302
casing: 'lower',
@@ -309,7 +309,7 @@ describe('string', () => {
309309
it('should throw if all possible characters being banned', () => {
310310
const bannedChars = 'abcdefghijklmnopqrstuvwxyz0123456789'.split('');
311311
expect(() =>
312-
faker.string.alphaNumeric({
312+
faker.string.alphanumeric({
313313
count: 5,
314314
bannedChars,
315315
casing: 'lower',
@@ -324,7 +324,7 @@ describe('string', () => {
324324
it('should throw if all possible characters being banned via string', () => {
325325
const bannedChars = 'abcdefghijklmnopqrstuvwxyz0123456789';
326326
expect(() =>
327-
faker.string.alphaNumeric({
327+
faker.string.alphanumeric({
328328
count: 5,
329329
bannedChars,
330330
casing: 'lower',
@@ -341,7 +341,7 @@ describe('string', () => {
341341
count: 5,
342342
});
343343

344-
expect(() => faker.string.alphaNumeric(input)).not.toThrow();
344+
expect(() => faker.string.alphanumeric(input)).not.toThrow();
345345
expect(input.bannedChars).toEqual(['a', '0', '%']);
346346
});
347347
});

0 commit comments

Comments
 (0)