From 841e5bb494e63835eb2eb587f4018f92c683540c Mon Sep 17 00:00:00 2001 From: Liam Murphy <43807659+Liamolucko@users.noreply.github.com> Date: Sat, 30 Jan 2021 06:46:30 +1100 Subject: [PATCH] test(node): fix `assertStats` if atime, mtime or birthtime are null (denoland/deno#9311) --- node/_fs/_fs_stat_test.ts | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/node/_fs/_fs_stat_test.ts b/node/_fs/_fs_stat_test.ts index e991985ea8d9..5a25cddcc883 100644 --- a/node/_fs/_fs_stat_test.ts +++ b/node/_fs/_fs_stat_test.ts @@ -17,9 +17,9 @@ export function assertStats(actual: Stats, expected: Deno.FileInfo) { assertEquals(actual.atime?.getTime(), expected.atime?.getTime()); assertEquals(actual.mtime?.getTime(), expected.mtime?.getTime()); assertEquals(actual.birthtime?.getTime(), expected.birthtime?.getTime()); - assertEquals(actual.atimeMs, expected.atime?.getTime()); - assertEquals(actual.mtimeMs, expected.mtime?.getTime()); - assertEquals(actual.birthtimeMs, expected.birthtime?.getTime()); + assertEquals(actual.atimeMs ?? undefined, expected.atime?.getTime()); + assertEquals(actual.mtimeMs ?? undefined, expected.mtime?.getTime()); + assertEquals(actual.birthtimeMs ?? undefined, expected.birthtime?.getTime()); assertEquals(actual.isFile(), expected.isFile); assertEquals(actual.isDirectory(), expected.isDirectory); assertEquals(actual.isSymbolicLink(), expected.isSymlink); @@ -48,9 +48,18 @@ export function assertStatsBigInt( assertEquals(actual.atime?.getTime(), expected.atime?.getTime()); assertEquals(actual.mtime?.getTime(), expected.mtime?.getTime()); assertEquals(actual.birthtime?.getTime(), expected.birthtime?.getTime()); - assertEquals(Number(actual.atimeMs), expected.atime?.getTime()); - assertEquals(Number(actual.mtimeMs), expected.mtime?.getTime()); - assertEquals(Number(actual.birthtimeMs), expected.birthtime?.getTime()); + assertEquals( + actual.atimeMs === null ? undefined : Number(actual.atimeMs), + expected.atime?.getTime(), + ); + assertEquals( + actual.mtimeMs === null ? undefined : Number(actual.mtimeMs), + expected.mtime?.getTime(), + ); + assertEquals( + actual.birthtimeMs === null ? undefined : Number(actual.birthtimeMs), + expected.birthtime?.getTime(), + ); assertEquals(actual.atimeNs === null, actual.atime === null); assertEquals(actual.mtimeNs === null, actual.mtime === null); assertEquals(actual.birthtimeNs === null, actual.birthtime === null);