Skip to content

Commit 7b11efb

Browse files
author
Joe Previte
committed
fixup!: compare stat for files
1 parent 01c5691 commit 7b11efb

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

test/unit/node/heart.test.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)