Skip to content

Commit

Permalink
Merge branch 'next' into deprecate/location/zipCode/format
Browse files Browse the repository at this point in the history
  • Loading branch information
ST-DDT authored Oct 29, 2024
2 parents 3634ec2 + c02beea commit 832892d
Show file tree
Hide file tree
Showing 8 changed files with 277 additions and 198 deletions.
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,6 @@
"typescript": "5.6.3",
"typescript-eslint": "8.11.0",
"validator": "13.12.0",
"vite": "5.4.10",
"vitepress": "1.4.1",
"vitest": "2.1.3",
"vue": "3.5.12",
Expand Down
397 changes: 201 additions & 196 deletions pnpm-lock.yaml

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions src/definitions/animal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,5 @@ export type AnimalDefinition = LocaleEntry<{
rodent: string[];
snake: string[];
type: string[];
pet_name: string[];
}>;
2 changes: 2 additions & 0 deletions src/locales/en/animal/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import fish from './fish';
import horse from './horse';
import insect from './insect';
import lion from './lion';
import pet_name from './pet_name';
import rabbit from './rabbit';
import rodent from './rodent';
import snake from './snake';
Expand All @@ -31,6 +32,7 @@ const animal: AnimalDefinition = {
horse,
insect,
lion,
pet_name,
rabbit,
rodent,
snake,
Expand Down
44 changes: 44 additions & 0 deletions src/locales/en/animal/pet_name.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
export default [
'Ace',
'Archie',
'Bailey',
'Bandit',
'Bella',
'Bentley',
'Bruno',
'Buddy',
'Charlie',
'Coco',
'Cookie',
'Cooper',
'Daisy',
'Dixie',
'Finn',
'Ginger',
'Gracie',
'Gus',
'Hank',
'Jack',
'Jax',
'Joey',
'Kobe',
'Leo',
'Lola',
'Louie',
'Lucy',
'Maggie',
'Max',
'Mia',
'Milo',
'Molly',
'Murphey',
'Nala',
'Nova',
'Ollie',
'Oreo',
'Rosie',
'Scout',
'Stella',
'Teddy',
'Tuffy',
];
14 changes: 14 additions & 0 deletions src/modules/animal/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -201,4 +201,18 @@ export class AnimalModule extends ModuleBase {
type(): string {
return this.faker.helpers.arrayElement(this.faker.definitions.animal.type);
}

/**
* Returns a random pet name.
*
* @example
* faker.animal.petName() // 'Coco'
*
* @since 9.2.0
*/
petName(): string {
return this.faker.helpers.arrayElement(
this.faker.definitions.animal.pet_name
);
}
}
6 changes: 6 additions & 0 deletions test/modules/__snapshots__/animal.spec.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ exports[`animal > 42 > insect 1`] = `"Gouty oak gall"`;

exports[`animal > 42 > lion 1`] = `"Cape lion"`;

exports[`animal > 42 > petName 1`] = `"Ginger"`;

exports[`animal > 42 > rabbit 1`] = `"English Spot"`;

exports[`animal > 42 > rodent 1`] = `"Famatina chinchilla rat"`;
Expand Down Expand Up @@ -52,6 +54,8 @@ exports[`animal > 1211 > insect 1`] = `"Western paper wasp"`;

exports[`animal > 1211 > lion 1`] = `"West African Lion"`;

exports[`animal > 1211 > petName 1`] = `"Scout"`;

exports[`animal > 1211 > rabbit 1`] = `"Silver Marten"`;

exports[`animal > 1211 > rodent 1`] = `"Strong tuco-tuco"`;
Expand Down Expand Up @@ -82,6 +86,8 @@ exports[`animal > 1337 > insect 1`] = `"Erythrina gall wasp"`;

exports[`animal > 1337 > lion 1`] = `"Barbary Lion"`;

exports[`animal > 1337 > petName 1`] = `"Cooper"`;

exports[`animal > 1337 > rabbit 1`] = `"Cinnamon"`;

exports[`animal > 1337 > rodent 1`] = `"Crested porcupine"`;
Expand Down
10 changes: 9 additions & 1 deletion test/modules/animal.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ describe('animal', () => {
'rabbit',
'rodent',
'snake',
'type'
'type',
'petName'
);
});

Expand Down Expand Up @@ -133,6 +134,13 @@ describe('animal', () => {
expect(faker.definitions.animal.type).toContain(actual);
});
});

describe('petName()', () => {
it('should return random value from pet name array', () => {
const actual = faker.animal.petName();
expect(faker.definitions.animal.pet_name).toContain(actual);
});
});
}
);
});

0 comments on commit 832892d

Please sign in to comment.