File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -19,4 +19,5 @@ export type AnimalDefinition = LocaleEntry<{
1919 rodent : string [ ] ;
2020 snake : string [ ] ;
2121 type : string [ ] ;
22+ pet_name : string [ ] ;
2223} > ;
Original file line number Diff line number Diff line change @@ -14,6 +14,7 @@ import fish from './fish';
1414import horse from './horse' ;
1515import insect from './insect' ;
1616import lion from './lion' ;
17+ import pet_name from './pet_name' ;
1718import rabbit from './rabbit' ;
1819import rodent from './rodent' ;
1920import snake from './snake' ;
@@ -31,6 +32,7 @@ const animal: AnimalDefinition = {
3132 horse,
3233 insect,
3334 lion,
35+ pet_name,
3436 rabbit,
3537 rodent,
3638 snake,
Original file line number Diff line number Diff line change 1+ export default [
2+ 'Ace' ,
3+ 'Archie' ,
4+ 'Bailey' ,
5+ 'Bandit' ,
6+ 'Bella' ,
7+ 'Bentley' ,
8+ 'Bruno' ,
9+ 'Buddy' ,
10+ 'Charlie' ,
11+ 'Coco' ,
12+ 'Cookie' ,
13+ 'Cooper' ,
14+ 'Daisy' ,
15+ 'Dixie' ,
16+ 'Finn' ,
17+ 'Ginger' ,
18+ 'Gracie' ,
19+ 'Gus' ,
20+ 'Hank' ,
21+ 'Jack' ,
22+ 'Jax' ,
23+ 'Joey' ,
24+ 'Kobe' ,
25+ 'Leo' ,
26+ 'Lola' ,
27+ 'Louie' ,
28+ 'Lucy' ,
29+ 'Maggie' ,
30+ 'Max' ,
31+ 'Mia' ,
32+ 'Milo' ,
33+ 'Molly' ,
34+ 'Murphey' ,
35+ 'Nala' ,
36+ 'Nova' ,
37+ 'Ollie' ,
38+ 'Oreo' ,
39+ 'Rosie' ,
40+ 'Scout' ,
41+ 'Stella' ,
42+ 'Teddy' ,
43+ 'Tuffy' ,
44+ ] ;
Original file line number Diff line number Diff line change @@ -201,4 +201,18 @@ export class AnimalModule extends ModuleBase {
201201 type ( ) : string {
202202 return this . faker . helpers . arrayElement ( this . faker . definitions . animal . type ) ;
203203 }
204+
205+ /**
206+ * Returns a random pet name.
207+ *
208+ * @example
209+ * faker.animal.petName() // 'Coco'
210+ *
211+ * @since 9.2.0
212+ */
213+ petName ( ) : string {
214+ return this . faker . helpers . arrayElement (
215+ this . faker . definitions . animal . pet_name
216+ ) ;
217+ }
204218}
Original file line number Diff line number Diff line change @@ -22,6 +22,8 @@ exports[`animal > 42 > insect 1`] = `"Gouty oak gall"`;
2222
2323exports [` animal > 42 > lion 1` ] = ` "Cape lion"` ;
2424
25+ exports [` animal > 42 > petName 1` ] = ` "Ginger"` ;
26+
2527exports [` animal > 42 > rabbit 1` ] = ` "English Spot"` ;
2628
2729exports [` animal > 42 > rodent 1` ] = ` "Famatina chinchilla rat"` ;
@@ -52,6 +54,8 @@ exports[`animal > 1211 > insect 1`] = `"Western paper wasp"`;
5254
5355exports [` animal > 1211 > lion 1` ] = ` "West African Lion"` ;
5456
57+ exports [` animal > 1211 > petName 1` ] = ` "Scout"` ;
58+
5559exports [` animal > 1211 > rabbit 1` ] = ` "Silver Marten"` ;
5660
5761exports [` animal > 1211 > rodent 1` ] = ` "Strong tuco-tuco"` ;
@@ -82,6 +86,8 @@ exports[`animal > 1337 > insect 1`] = `"Erythrina gall wasp"`;
8286
8387exports [` animal > 1337 > lion 1` ] = ` "Barbary Lion"` ;
8488
89+ exports [` animal > 1337 > petName 1` ] = ` "Cooper"` ;
90+
8591exports [` animal > 1337 > rabbit 1` ] = ` "Cinnamon"` ;
8692
8793exports [` animal > 1337 > rodent 1` ] = ` "Crested porcupine"` ;
Original file line number Diff line number Diff line change @@ -22,7 +22,8 @@ describe('animal', () => {
2222 'rabbit' ,
2323 'rodent' ,
2424 'snake' ,
25- 'type'
25+ 'type' ,
26+ 'petName'
2627 ) ;
2728 } ) ;
2829
@@ -133,6 +134,13 @@ describe('animal', () => {
133134 expect ( faker . definitions . animal . type ) . toContain ( actual ) ;
134135 } ) ;
135136 } ) ;
137+
138+ describe ( 'petName()' , ( ) => {
139+ it ( 'should return random value from pet name array' , ( ) => {
140+ const actual = faker . animal . petName ( ) ;
141+ expect ( faker . definitions . animal . pet_name ) . toContain ( actual ) ;
142+ } ) ;
143+ } ) ;
136144 }
137145 ) ;
138146} ) ;
You can’t perform that action at this time.
0 commit comments