1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-11-26 16:09:27 -05:00

test(std/node): fix assertStats if atime, mtime or birthtime are null (#9311)

This commit is contained in:
Liam Murphy 2021-01-30 06:46:30 +11:00 committed by GitHub
parent 9965fc8cc3
commit d405e57c3c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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);