fix: convert island filePath to valid variable name (#2984)
I only added a unit test, but maybe it's testing internals too much? Should I add a more E2E test in `tests/` with real files? Closes #2971
This commit is contained in:
+12
-1
@@ -1,5 +1,5 @@
|
||||
import { expect } from "@std/expect";
|
||||
import { mergePaths } from "./utils.ts";
|
||||
import { mergePaths, pathToExportName } from "./utils.ts";
|
||||
|
||||
Deno.test("mergePaths", () => {
|
||||
expect(mergePaths("", "")).toEqual("");
|
||||
@@ -9,3 +9,14 @@ Deno.test("mergePaths", () => {
|
||||
expect(mergePaths("/foo/bar/", "/baz")).toEqual("/foo/bar/baz");
|
||||
expect(mergePaths("/foo/bar", "baz")).toEqual("/foo/bar/baz");
|
||||
});
|
||||
|
||||
Deno.test("filenameToExportName", () => {
|
||||
expect(pathToExportName("/islands/foo.tsx")).toBe("foo");
|
||||
expect(pathToExportName("/islands/foo.v2.tsx")).toBe("foo_v2");
|
||||
expect(pathToExportName("/islands/nav-bar.tsx")).toBe("nav_bar");
|
||||
expect(pathToExportName("/islands/_.$bar.tsx")).toBe("_$bar");
|
||||
expect(pathToExportName("/islands/1.hello.tsx")).toBe("_hello");
|
||||
expect(pathToExportName("/islands/collapse...repeat_-dash.tsx")).toBe(
|
||||
"collapse_repeat_dash",
|
||||
);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user