@@ -43,11 +43,7 @@ describe("Heart", () => {
43
43
expect ( fileContents ) . toBe ( text )
44
44
45
45
heart = new Heart ( pathToFile , mockIsActive ( true ) )
46
- heart . beat ( )
47
- // HACK@jsjoeio - beat has some async logic but is not an async method
48
- // Therefore, we have to create an artificial wait in order to make sure
49
- // all async code has completed before asserting
50
- await new Promise ( ( r ) => setTimeout ( r , 100 ) )
46
+ await heart . beat ( )
51
47
// Check that the heart wrote to the heartbeatFilePath and overwrote our text
52
48
const fileContentsAfterBeat = await readFile ( pathToFile , { encoding : "utf8" } )
53
49
expect ( fileContentsAfterBeat ) . not . toBe ( text )
@@ -57,15 +53,11 @@ describe("Heart", () => {
57
53
} )
58
54
it ( "should log a warning when given an invalid file path" , async ( ) => {
59
55
heart = new Heart ( `fakeDir/fake.txt` , mockIsActive ( false ) )
60
- heart . beat ( )
61
- // HACK@jsjoeio - beat has some async logic but is not an async method
62
- // Therefore, we have to create an artificial wait in order to make sure
63
- // all async code has completed before asserting
64
- await new Promise ( ( r ) => setTimeout ( r , 100 ) )
56
+ await heart . beat ( )
65
57
expect ( logger . warn ) . toHaveBeenCalled ( )
66
58
} )
67
- it ( "should be active after calling beat" , ( ) => {
68
- heart . beat ( )
59
+ it ( "should be active after calling beat" , async ( ) => {
60
+ await heart . beat ( )
69
61
70
62
const isAlive = heart . alive ( )
71
63
expect ( isAlive ) . toBe ( true )
0 commit comments