Skip to content

Commit

Permalink
test(node): fix assertStats if atime, mtime or birthtime are null (d…
Browse files Browse the repository at this point in the history
  • Loading branch information
Liamolucko authored and caspervonb committed Jan 31, 2021
1 parent 7f54a61 commit f4979f7
Showing 1 changed file with 15 additions and 6 deletions.
21 changes: 15 additions & 6 deletions node/_fs/_fs_stat_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit f4979f7

Please sign in to comment.