Skip to content
Source
Sign inSign up
pingdotgg/t3code
Open History to see the last commit

projects.test.ts

34 lines1.2 KB

1import { describe, expect, it } from "vite-plus/test";
2​
3import { isScratchProject, resolveProjectPathForDispatch } from "./projects.ts";
4​
5describe("isScratchProject", () => {
6 it.each([null, undefined])(
7 "recognises a loaded scratch project when its environment offers no available root (%s)",
8 (scratchWorkspaceRoot) => {
9 const project = { workspaceRoot: "/remote/scratch", isScratch: true as const };
10​
11 expect(isScratchProject(project, scratchWorkspaceRoot)).toBe(true);
12 },
13 );
14});
15​
16describe("resolveProjectPathForDispatch", () => {
17 it("keeps literal backslashes in relative POSIX project paths", () => {
18 expect(resolveProjectPathForDispatch("./docs\\archive", "/workspace/app")).toBe(
19 "/workspace/app/docs\\archive",
20 );
21 expect(resolveProjectPathForDispatch("./docs\\archive/../other", "/workspace/app")).toBe(
22 "/workspace/app/other",
23 );
24 });
25​
26 it("splits relative paths on both slashes and backslashes for Windows bases", () => {
27 expect(resolveProjectPathForDispatch("..\\sibling\\sub", "C:\\workspace\\app")).toBe(
28 "C:\\workspace\\sibling\\sub",
29 );
30 expect(resolveProjectPathForDispatch("./docs/archive", "\\\\server\\share\\app")).toBe(
31 "\\\\server\\share\\app\\docs\\archive",
32 );
33 });
34});