@@ -65,6 +65,26 @@ describe('Date time utils', () => {
65
65
} ) ;
66
66
} ) ;
67
67
68
+ describe ( 'formatDate' , ( ) => {
69
+ it ( 'should format date properly' , ( ) => {
70
+ const formattedDate = datetimeUtility . formatDate ( new Date ( '07/23/2016' ) ) ;
71
+
72
+ expect ( formattedDate ) . toBe ( 'Jul 23, 2016 12:00am GMT+0000' ) ;
73
+ } ) ;
74
+
75
+ it ( 'should format ISO date properly' , ( ) => {
76
+ const formattedDate = datetimeUtility . formatDate ( '2016-07-23T00:00:00.559Z' ) ;
77
+
78
+ expect ( formattedDate ) . toBe ( 'Jul 23, 2016 12:00am GMT+0000' ) ;
79
+ } ) ;
80
+
81
+ it ( 'should throw an error if date is invalid' , ( ) => {
82
+ expect ( ( ) => {
83
+ datetimeUtility . formatDate ( '2016-07-23 00:00:00 UTC' ) ;
84
+ } ) . toThrow ( new Error ( 'Invalid date' ) ) ;
85
+ } ) ;
86
+ } ) ;
87
+
68
88
describe ( 'get day difference' , ( ) => {
69
89
it ( 'should return 7' , ( ) => {
70
90
const firstDay = new Date ( '07/01/2016' ) ;
@@ -380,7 +400,7 @@ describe('prettyTime methods', () => {
380
400
381
401
describe ( 'calculateRemainingMilliseconds' , ( ) => {
382
402
beforeEach ( ( ) => {
383
- spyOn ( Date , 'now' ) . and . callFake ( ( ) => new Date ( '2063-04-04T00:42:00Z' ) . getTime ( ) ) ;
403
+ jest . spyOn ( Date , 'now' ) . mockImplementation ( ( ) => new Date ( '2063-04-04T00:42:00Z' ) . getTime ( ) ) ;
384
404
} ) ;
385
405
386
406
it ( 'calculates the remaining time for a given end date' , ( ) => {
0 commit comments