@@ -38,12 +38,16 @@ describe("Heart", () => {
38
38
39
39
heart = new Heart ( pathToFile , mockIsActive ( true ) )
40
40
heart . beat ( )
41
+ // HACK@jsjoeio - beat has some async logic but is not an async method
42
+ // Therefore, we have to create an artificial wait in order to make sure
43
+ // all async code has completed before asserting
44
+ await new Promise ( ( r ) => setTimeout ( r , 100 ) )
41
45
// Check that the heart wrote to the heartbeatFilePath and overwrote our text
42
46
const fileContentsAfterBeat = await readFile ( pathToFile , { encoding : "utf8" } )
43
47
expect ( fileContentsAfterBeat ) . not . toBe ( text )
44
48
// Make sure the modified timestamp was updated.
45
49
const fileStatusAfterEdit = await stat ( pathToFile )
46
- expect ( fileStatusAfterEdit . mtimeMs ) . toBeGreaterThan ( fileStatusBeforeEdit . mtimeMs )
50
+ expect ( fileStatusAfterEdit . mtimeMs ) . toBeGreaterThanOrEqual ( fileStatusBeforeEdit . mtimeMs )
47
51
} )
48
52
it ( "should log a warning when given an invalid file path" , async ( ) => {
49
53
heart = new Heart ( `fakeDir/fake.txt` , mockIsActive ( false ) )
@@ -52,7 +56,6 @@ describe("Heart", () => {
52
56
// Therefore, we have to create an artificial wait in order to make sure
53
57
// all async code has completed before asserting
54
58
await new Promise ( ( r ) => setTimeout ( r , 100 ) )
55
- // expect(logger.trace).toHaveBeenCalled()
56
59
expect ( logger . warn ) . toHaveBeenCalled ( )
57
60
} )
58
61
it ( "should be active after calling beat" , ( ) => {
0 commit comments