@@ -22,8 +22,11 @@ const seededRuns = [
22
22
withMinAndMaxAndPrecision : - 0.4261 ,
23
23
} ,
24
24
datetime : {
25
- // TODO @Shinigami 92 2022-01-29: We will fix the deterministic in #343
26
- noArgs : new Date ( '2092-03-22T16:55:38.644Z' ) ,
25
+ noArgs : new Date ( '2031-03-14T21:33:22.114Z' ) ,
26
+ number : new Date ( '1994-03-20T17:23:00.629Z' ) ,
27
+ withMin : new Date ( '1801-04-11T15:13:06.330Z' ) ,
28
+ withMax : new Date ( '1994-07-11T09:43:47.230Z' ) ,
29
+ withMinMax : new Date ( '1689-09-09T08:39:09.444Z' ) ,
27
30
} ,
28
31
string : {
29
32
noArgs : 'Cky2eiXX/J' ,
@@ -91,8 +94,11 @@ const seededRuns = [
91
94
withMinAndMaxAndPrecision : - 12.9153 ,
92
95
} ,
93
96
datetime : {
94
- // TODO @Shinigami 92 2022-01-29: We will fix the deterministic in #343
95
- noArgs : new Date ( '2092-03-22T16:55:38.644Z' ) ,
97
+ noArgs : new Date ( '2018-10-28T08:46:11.896Z' ) ,
98
+ number : new Date ( '1992-12-13T04:13:59.232Z' ) ,
99
+ withMin : new Date ( '1747-07-16T01:19:54.159Z' ) ,
100
+ withMax : new Date ( '1993-03-02T00:10:04.335Z' ) ,
101
+ withMinMax : new Date ( '1669-06-22T01:21:21.236Z' ) ,
96
102
} ,
97
103
string : {
98
104
noArgs : '9U/4:SK$>6' ,
@@ -160,8 +166,11 @@ const seededRuns = [
160
166
withMinAndMaxAndPrecision : 61.0658 ,
161
167
} ,
162
168
datetime : {
163
- // TODO @Shinigami 92 2022-01-29: We will fix the deterministic in #343
164
- noArgs : new Date ( '2092-03-22T16:55:38.644Z' ) ,
169
+ noArgs : new Date ( '2092-02-20T03:42:04.341Z' ) ,
170
+ number : new Date ( '2000-06-14T02:54:42.082Z' ) ,
171
+ withMin : new Date ( '2065-11-10T19:27:20.915Z' ) ,
172
+ withMax : new Date ( '2001-03-20T11:14:25.251Z' ) ,
173
+ withMinMax : new Date ( '1789-03-26T15:44:45.218Z' ) ,
165
174
} ,
166
175
string : {
167
176
noArgs : 'wKti5-}$_/' ,
@@ -230,17 +239,6 @@ describe('datatype', () => {
230
239
for ( const { seed, expectations } of seededRuns ) {
231
240
describe ( `seed: ${ seed } ` , ( ) => {
232
241
for ( const functionName of functionNames ) {
233
- if ( functionName === 'datetime' ) {
234
- // TODO @Shinigami 92 2022-01-29: We will fix the deterministic in #343
235
- it ( `${ functionName } ()` , ( ) => {
236
- faker . seed ( seed ) ;
237
-
238
- const actual = faker . datatype . datetime ( ) ;
239
- expect ( actual ) . toBeTypeOf ( 'object' ) ;
240
- } ) ;
241
- continue ;
242
- }
243
-
244
242
it ( `${ functionName } ()` , ( ) => {
245
243
faker . seed ( seed ) ;
246
244
@@ -335,10 +333,42 @@ describe('datatype', () => {
335
333
} ) ;
336
334
} ) ;
337
335
338
- // TODO @ST -DDT 2022-01-29: #343
339
- describe . todo ( 'datetime' , ( ) => {
340
- it ( 'should ... ' , ( ) => {
336
+ describe ( 'datetime' , ( ) => {
337
+ it ( 'should return a deterministic date when given a number' , ( ) => {
341
338
faker . seed ( seed ) ;
339
+
340
+ const actual = faker . datatype . datetime (
341
+ Date . parse ( '2001-04-03T23:21:10.773Z' )
342
+ ) ;
343
+ expect ( actual ) . toEqual ( expectations . datetime . number ) ;
344
+ } ) ;
345
+
346
+ it ( 'should return a deterministic date when given a min date' , ( ) => {
347
+ faker . seed ( seed ) ;
348
+
349
+ const actual = faker . datatype . datetime ( {
350
+ min : Date . parse ( '1622-05-23T13:45:08.843Z' ) ,
351
+ } ) ;
352
+ expect ( actual ) . toEqual ( expectations . datetime . withMin ) ;
353
+ } ) ;
354
+
355
+ it ( 'should return a deterministic date when given a max date' , ( ) => {
356
+ faker . seed ( seed ) ;
357
+
358
+ const actual = faker . datatype . datetime ( {
359
+ max : Date . parse ( '2002-01-29T19:47:52.605Z' ) ,
360
+ } ) ;
361
+ expect ( actual ) . toEqual ( expectations . datetime . withMax ) ;
362
+ } ) ;
363
+
364
+ it ( 'should return a deterministic date when given a min and max date' , ( ) => {
365
+ faker . seed ( seed ) ;
366
+
367
+ const actual = faker . datatype . datetime ( {
368
+ min : Date . parse ( '1622-05-23T13:45:08.843Z' ) ,
369
+ max : Date . parse ( '1802-01-29T19:47:52.605Z' ) ,
370
+ } ) ;
371
+ expect ( actual ) . toEqual ( expectations . datetime . withMinMax ) ;
342
372
} ) ;
343
373
} ) ;
344
374
0 commit comments