From 564f5f51146b7812d208d741b745c4ea9c869a6d Mon Sep 17 00:00:00 2001 From: Liam Date: Fri, 29 Jan 2021 06:24:54 +1100 Subject: [PATCH] test(std/node): fix `assertStats` if atime, mtime or birthtime are null --- std/node/_fs/_fs_stat_test.ts | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/std/node/_fs/_fs_stat_test.ts b/std/node/_fs/_fs_stat_test.ts index e991985ea8d984..5a25cddcc8836e 100644 --- a/std/node/_fs/_fs_stat_test.ts +++ b/std/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);