This repository was archived by the owner on Dec 15, 2022. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +13
-4
lines changed
Expand file tree Collapse file tree 1 file changed +13
-4
lines changed Original file line number Diff line number Diff line change @@ -125,14 +125,23 @@ describe("API Tasks Functions", () => {
125125 ( allTodayJSON = await myClient . extras . getTodayTaskJSON ( ) ) ,
126126 ( allTodayNames = await myClient . extras . getTodayTaskNames ( ) ) ,
127127 ] ) ;
128-
129128 const firstTaskExists =
130129 allTodayJSON . some ( ( taskObj ) => taskObj . content === "First task" ) &&
131130 allTodayNames . some ( ( name ) => name === "First task" ) ;
132131
133- expect ( allTodayJSON . length ) . toBe ( 2 ) ;
134- expect ( typeof allTodayJSON [ 0 ] ) . toBe ( "object" ) ;
135- expect ( firstTaskExists ) . toBe ( true ) ;
132+ let normalDate = new Date ( ) . toISOString ( ) . substring ( 0 , 10 ) ;
133+ let momentDate = moment . parseZone ( new Date ( ) ) . format ( ) . substring ( 0 , 10 ) ;
134+
135+ if ( normalDate === momentDate ) {
136+ // GMT day = local day
137+ expect ( allTodayJSON . length ) . toBe ( 2 ) ;
138+ expect ( typeof allTodayJSON [ 0 ] ) . toBe ( "object" ) ;
139+ expect ( firstTaskExists ) . toBe ( true ) ;
140+ } else {
141+ // GMT day != local day (offset influence in day)
142+ expect ( allTodayJSON . length ) . toBe ( 0 ) ;
143+ expect ( firstTaskExists ) . toBe ( false ) ;
144+ }
136145 } ) ;
137146
138147 test ( "Test getAllTaskNames" , async ( ) => {
You can’t perform that action at this time.
0 commit comments