Skip to content

Commit

Permalink
test: split windows tests off
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewbrey committed Mar 23, 2024
1 parent 3632d9b commit 1eefe02
Showing 1 changed file with 16 additions and 7 deletions.
23 changes: 16 additions & 7 deletions src/util.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,21 @@ Deno.test("toFileURL works", () => {
const toPosix = (path: string) => path.replaceAll(SEP, POSIX_SEP);
let cwd = toPosix(Deno.cwd());

if (Deno.build.os === "windows") cwd = `/${cwd}`;
if (Deno.build.os === "windows") {
cwd = `/${cwd}`;

assertEquals(toFileURL("/a/b/c"), "file:///a/b/c");
assertEquals(toFileURL("./d/e/f"), `file://${cwd}/d/e/f`);
assertEquals(toFileURL("../d/e/f"), `file://${toPosix($.path(cwd).join("..").toString())}/d/e/f`);
assertEquals(toFileURL("file://./abc.ts"), `file://${cwd}/abc.ts`);
assertEquals(toFileURL("http://./def.ts"), `file://${cwd}/def.ts`);
assertEquals(toFileURL("https://./ghi.ts"), `file://${cwd}/ghi.ts`);
assertEquals(toFileURL("/a/b/c"), "file:///D:/a/b/c");
assertEquals(toFileURL("./d/e/f"), `file://${cwd}D:/d/e/f`);
assertEquals(toFileURL("../d/e/f"), `file:///D:/${toPosix($.path(cwd).join("..").toString())}/d/e/f`);
assertEquals(toFileURL("file://./abc.ts"), `file:///D:${cwd}/abc.ts`);
assertEquals(toFileURL("http://./def.ts"), `file:///D:${cwd}/def.ts`);
assertEquals(toFileURL("https://./ghi.ts"), `file:///D:${cwd}/ghi.ts`);
} else {
assertEquals(toFileURL("/a/b/c"), "file:///a/b/c");
assertEquals(toFileURL("./d/e/f"), `file://${cwd}/d/e/f`);
assertEquals(toFileURL("../d/e/f"), `file://${toPosix($.path(cwd).join("..").toString())}/d/e/f`);
assertEquals(toFileURL("file://./abc.ts"), `file://${cwd}/abc.ts`);
assertEquals(toFileURL("http://./def.ts"), `file://${cwd}/def.ts`);
assertEquals(toFileURL("https://./ghi.ts"), `file://${cwd}/ghi.ts`);
}
});

0 comments on commit 1eefe02

Please sign in to comment.