@@ -29,11 +29,11 @@ describe("Heart", () => {
29
29
} )
30
30
it ( "should write to a file when given a valid file path" , async ( ) => {
31
31
// Set up heartbeat file with contents
32
- const before = Date . now ( )
33
32
const text = "test"
34
33
const pathToFile = `${ testDir } /file.txt`
35
34
await writeFile ( pathToFile , text )
36
35
const fileContents = await readFile ( pathToFile , { encoding : "utf8" } )
36
+ const fileStatusBeforeEdit = await stat ( pathToFile )
37
37
expect ( fileContents ) . toBe ( text )
38
38
39
39
heart = new Heart ( pathToFile , mockIsActive ( true ) )
@@ -42,8 +42,8 @@ describe("Heart", () => {
42
42
const fileContentsAfterBeat = await readFile ( pathToFile , { encoding : "utf8" } )
43
43
expect ( fileContentsAfterBeat ) . not . toBe ( text )
44
44
// 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 )
47
47
} )
48
48
it ( "should log a warning when given an invalid file path" , async ( ) => {
49
49
heart = new Heart ( `fakeDir/fake.txt` , mockIsActive ( false ) )
0 commit comments