Skip to content

Commit cc83b57

Browse files
committed
test: add unit test for normalizeConfig "root"
1 parent 1369c62 commit cc83b57

1 file changed

Lines changed: 14 additions & 1 deletion

File tree

src/config_test.ts

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { expect } from "@std/expect";
2-
import { parseRootPath } from "./config.ts";
2+
import { normalizeConfig, parseRootPath } from "./config.ts";
33

44
Deno.test("parseRootPath", () => {
55
const cwd = Deno.cwd().replaceAll("\\", "/");
@@ -22,3 +22,16 @@ Deno.test("parseRootPath", () => {
2222
expect(parseRootPath("/foo/bar.jsx", cwd)).toEqual("/foo");
2323
expect(parseRootPath("/foo/bar.mjs", cwd)).toEqual("/foo");
2424
});
25+
26+
Deno.test("normalizeConfig - root", () => {
27+
const cwd = Deno.cwd().replaceAll("\\", "/");
28+
const configRoot = (root?: string) => normalizeConfig({ root }).root;
29+
30+
expect(configRoot()).toEqual(cwd);
31+
expect(configRoot("/foo/bar")).toEqual("/foo/bar");
32+
expect(configRoot("/foo/bar.ts")).toEqual("/foo");
33+
expect(configRoot("file:///foo/bar")).toEqual("/foo/bar");
34+
expect(configRoot("file:///C:/foo/bar")).toEqual("C:/foo/bar");
35+
expect(configRoot("./foo/bar")).toEqual(`${cwd}/foo/bar`);
36+
expect(configRoot("./foo/bar.ts")).toEqual(`${cwd}/foo`);
37+
});

0 commit comments

Comments
 (0)