@@ -29,11 +29,11 @@ describe("Heart", () => {
2929 } )
3030 it ( "should write to a file when given a valid file path" , async ( ) => {
3131 // Set up heartbeat file with contents
32- const before = Date . now ( )
3332 const text = "test"
3433 const pathToFile = `${ testDir } /file.txt`
3534 await writeFile ( pathToFile , text )
3635 const fileContents = await readFile ( pathToFile , { encoding : "utf8" } )
36+ const fileStatusBeforeEdit = await stat ( pathToFile )
3737 expect ( fileContents ) . toBe ( text )
3838
3939 heart = new Heart ( pathToFile , mockIsActive ( true ) )
@@ -42,8 +42,8 @@ describe("Heart", () => {
4242 const fileContentsAfterBeat = await readFile ( pathToFile , { encoding : "utf8" } )
4343 expect ( fileContentsAfterBeat ) . not . toBe ( text )
4444 // Make sure the modified timestamp was updated.
45- const status = await stat ( pathToFile )
46- expect ( status . mtimeMs ) . toBeGreaterThan ( before )
45+ const fileStatusAfterEdit = await stat ( pathToFile )
46+ expect ( fileStatusAfterEdit . mtimeMs ) . toBeGreaterThan ( fileStatusBeforeEdit . mtimeMs )
4747 } )
4848 it ( "should log a warning when given an invalid file path" , async ( ) => {
4949 heart = new Heart ( `fakeDir/fake.txt` , mockIsActive ( false ) )
0 commit comments