File tree 2 files changed +34
-20
lines changed
2 files changed +34
-20
lines changed Original file line number Diff line number Diff line change @@ -284,23 +284,22 @@ export class Name {
284
284
}
285
285
286
286
/**
287
- * Generates a random title.
287
+ * Generates a random job title.
288
288
*
289
289
* @example
290
290
* faker.name.title() // 'International Integration Manager'
291
+ *
292
+ * @deprecated
291
293
*/
292
294
title ( ) : string {
293
- const descriptor = this . faker . random . arrayElement (
294
- this . faker . definitions . name . title . descriptor
295
- ) ;
296
- const level = this . faker . random . arrayElement (
297
- this . faker . definitions . name . title . level
298
- ) ;
299
- const job = this . faker . random . arrayElement (
300
- this . faker . definitions . name . title . job
301
- ) ;
302
-
303
- return descriptor + ' ' + level + ' ' + job ;
295
+ deprecated ( {
296
+ deprecated : 'faker.name.title()' ,
297
+ proposed : 'faker.name.jobTitle()' ,
298
+ since : 'v6.1.2' ,
299
+ until : 'v7.0.0' ,
300
+ } ) ;
301
+
302
+ return this . jobTitle ( ) ;
304
303
}
305
304
306
305
/**
@@ -310,13 +309,7 @@ export class Name {
310
309
* faker.name.jobTitle() // 'Global Accounts Engineer'
311
310
*/
312
311
jobTitle ( ) : string {
313
- return (
314
- this . faker . name . jobDescriptor ( ) +
315
- ' ' +
316
- this . faker . name . jobArea ( ) +
317
- ' ' +
318
- this . faker . name . jobType ( )
319
- ) ;
312
+ return this . jobDescriptor ( ) + ' ' + this . jobArea ( ) + ' ' + this . jobType ( ) ;
320
313
}
321
314
322
315
/**
Original file line number Diff line number Diff line change @@ -519,14 +519,35 @@ describe('name', () => {
519
519
faker . localeFallback = 'en' ;
520
520
} ) ;
521
521
522
+ it ( 'should display deprecated message' , ( ) => {
523
+ const spy = vi . spyOn ( console , 'warn' ) ;
524
+
525
+ faker . name . title ( ) ;
526
+
527
+ expect ( spy ) . toHaveBeenCalledWith (
528
+ '[@faker-js/faker]: faker.name.title() is deprecated since v6.1.2 and will be removed in v7.0.0. Please use faker.name.jobTitle() instead.'
529
+ ) ;
530
+
531
+ spy . mockRestore ( ) ;
532
+ } ) ;
533
+
534
+ it ( 'should call jobTitle()' , ( ) => {
535
+ const spy = vi . spyOn ( faker . name , 'jobTitle' ) ;
536
+
537
+ faker . name . title ( ) ;
538
+
539
+ expect ( spy ) . toHaveBeenCalledWith ( ) ;
540
+
541
+ spy . mockRestore ( ) ;
542
+ } ) ;
543
+
522
544
it ( 'should return a title consisting of a descriptor, area, and type' , ( ) => {
523
545
const title = faker . name . title ( ) ;
524
546
525
547
expect ( title ) . toBeTypeOf ( 'string' ) ;
526
548
527
549
const [ descriptor , level , job ] = title . split ( ' ' ) ;
528
550
529
- // TODO @Shinigami 92 2022-01-31: jobTitle and title are the same
530
551
expect ( faker . definitions . name . title . descriptor ) . toContain ( descriptor ) ;
531
552
expect ( faker . definitions . name . title . level ) . toContain ( level ) ;
532
553
expect ( faker . definitions . name . title . job ) . toContain ( job ) ;
You can’t perform that action at this time.
0 commit comments