Skip to content

Commit 5b9b476

Browse files
add tests for normalize-path
1 parent 88d5818 commit 5b9b476

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import path from "node:path";
2+
3+
import { describe, expect, it } from "vitest";
4+
5+
import { normalizePath } from "./normalize-path";
6+
7+
describe("normalizePath", () => {
8+
it("should produce an absolute path ready to be embedded in inlined code", () => {
9+
const joined = path.join("/", "Users", "me", "projects", "cloudflare", "index.mjs");
10+
const result = normalizePath(joined);
11+
// Note: the result is the same both on linux/mac and windows
12+
expect(result).toEqual("/Users/me/projects/cloudflare/index.mjs");
13+
});
14+
15+
it("should produce a relative path ready to be embedded in inlined code", () => {
16+
const joined = path.join("..", "..", "tmp", "index.mjs");
17+
const result = normalizePath(joined);
18+
19+
// Note: the result is the same both on linux/mac and windows
20+
expect(result).toEqual("../../tmp/index.mjs");
21+
});
22+
});

0 commit comments

Comments
 (0)