@@ -5,19 +5,25 @@ const seededRuns = [
55 {
66 seed : 42 ,
77 expectations : {
8- withMethod : 'Test-188' ,
8+ withCustomMethod : 'Test-188' ,
9+ withNumberMethod : 37454 ,
10+ withNumberMethodAndArgs : 19 ,
911 } ,
1012 } ,
1113 {
1214 seed : 1337 ,
1315 expectations : {
14- withMethod : 'Test-132' ,
16+ withCustomMethod : 'Test-132' ,
17+ withNumberMethod : 26202 ,
18+ withNumberMethodAndArgs : 13 ,
1519 } ,
1620 } ,
1721 {
1822 seed : 1211 ,
1923 expectations : {
20- withMethod : 'Test-465' ,
24+ withCustomMethod : 'Test-465' ,
25+ withNumberMethod : 92852 ,
26+ withNumberMethodAndArgs : 47 ,
2127 } ,
2228 } ,
2329] ;
@@ -29,7 +35,7 @@ const MOCK_ARRAY = Array.from(
2935 ( _ , index ) => `Test-${ index + 1 } `
3036) ;
3137
32- function method ( prefix : string = '' ) : string {
38+ function customMethod ( prefix : string = '' ) : string {
3339 const element = faker . random . arrayElement ( MOCK_ARRAY ) ;
3440 return `${ prefix } ${ element } ` ;
3541}
@@ -41,20 +47,34 @@ describe('unique', () => {
4147
4248 for ( const { seed, expectations } of seededRuns ) {
4349 describe ( `seed: ${ seed } ` , ( ) => {
44- it ( `unique(method )` , ( ) => {
50+ it ( `unique(customMethod )` , ( ) => {
4551 faker . seed ( seed ) ;
4652
47- const actual = faker . unique ( method ) ;
48- expect ( actual ) . toEqual ( expectations . withMethod ) ;
53+ const actual = faker . unique ( customMethod ) ;
54+ expect ( actual ) . toEqual ( expectations . withCustomMethod ) ;
4955 } ) ;
5056
51- it ( `unique(method , args)` , ( ) => {
57+ it ( `unique(customMethod , args)` , ( ) => {
5258 faker . seed ( seed ) ;
5359
5460 const prefix = 'prefix-1-' ;
5561
56- const actual = faker . unique ( method , [ prefix ] ) ;
57- expect ( actual ) . toEqual ( prefix + expectations . withMethod ) ;
62+ const actual = faker . unique ( customMethod , [ prefix ] ) ;
63+ expect ( actual ) . toEqual ( prefix + expectations . withCustomMethod ) ;
64+ } ) ;
65+
66+ it ( `unique(() => number)` , ( ) => {
67+ faker . seed ( seed ) ;
68+
69+ const actual = faker . unique ( faker . datatype . number ) ;
70+ expect ( actual ) . toEqual ( expectations . withNumberMethod ) ;
71+ } ) ;
72+
73+ it ( `unique(() => number), args)` , ( ) => {
74+ faker . seed ( seed ) ;
75+
76+ const actual = faker . unique ( faker . datatype . number , [ 50 ] ) ;
77+ expect ( actual ) . toEqual ( expectations . withNumberMethodAndArgs ) ;
5878 } ) ;
5979 } ) ;
6080 }
0 commit comments