Skip to content

Commit b01fbcf

Browse files
committed
test: use os-agnostic file paths in test assertions
1 parent 4c04c92 commit b01fbcf

File tree

4 files changed

+17
-4
lines changed

4 files changed

+17
-4
lines changed

dev_deps.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
export * as path from "https://deno.land/std@0.103.0/path/mod.ts";
12
export {
23
assertEquals,
34
assertThrowsAsync,

tests/helpers.uploadable.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { isFile } from "./helpers/io.ts";
2-
import { path } from "../deps.ts";
2+
import { path } from "../dev_deps.ts";
33
import { assertEquals } from "../dev_deps.ts";
44
import { prepareFilesOrDirectoryForUpload } from "../helpers/uploadable.ts";
55
import { default as temporaryDirectory } from "../utils/temp-directory.ts";

tests/helpers/path.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import { path } from "../../dev_deps.ts";
2+
3+
export const normaliseFilePath = (filePath: string): string => {
4+
return path.toFileUrl(path.resolve(filePath)).href;
5+
};

tests/utils.zip.test.ts

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { calculateFileSize } from "./helpers/io.ts";
2-
import { path } from "../deps.ts";
2+
import { normaliseFilePath } from "./helpers/path.ts";
3+
import { path } from "../dev_deps.ts";
34
import { assertEquals } from "../dev_deps.ts";
45
import { getFilepaths, zipDirectory } from "../utils/zip.ts";
56
import { default as temporaryDirectory } from "../utils/temp-directory.ts";
@@ -15,7 +16,10 @@ Deno.test({
1516
"tests/fixtures/extension/manifest.json",
1617
"tests/fixtures/extension/assets/dummy.txt",
1718
];
18-
assertEquals(output.sort(), expected.sort());
19+
assertEquals(
20+
output.map(normaliseFilePath).sort(),
21+
expected.map(normaliseFilePath).sort(),
22+
);
1923
},
2024
});
2125

@@ -32,7 +36,10 @@ Deno.test({
3236
"tests/fixtures/extension/manifest.json",
3337
"tests/fixtures/extension/assets/dummy.txt",
3438
].map((p) => path.join(`${Deno.cwd()}`, p));
35-
assertEquals(output.sort(), expected.sort());
39+
assertEquals(
40+
output.map(normaliseFilePath).sort(),
41+
expected.map(normaliseFilePath).sort(),
42+
);
3643
},
3744
});
3845

0 commit comments

Comments
 (0)