Open History to see the last commit
1import * as Schema from "effect/Schema";
2import { describe, expect, it } from "vite-plus/test";
3
4import { parseT3ProjectFile, T3ProjectFileFromJson } from "./t3ProjectFile.ts";
5
6const decodeJson = Schema.decodeUnknownSync(T3ProjectFileFromJson);
7
8describe("T3ProjectFileFromJson", () => {
9 it("decodes lenient JSONC with comments and trailing commas", () => {
10 const decoded = decodeJson(`{
11 // team scripts
12 "iconPath": "assets/logo.svg",
13 "scripts": [
14 { "name": "Dev", "command": "pnpm dev", "stopOnSettle": true, },
15 ],
16 }`);
17
18 expect(decoded.iconPath).toBe("assets/logo.svg");
19 expect(decoded.scripts?.[0]).toEqual({ name: "Dev", command: "pnpm dev", stopOnSettle: true });
20 });
21});
22
23describe("parseT3ProjectFile", () => {
24 it("reads project defaults from JSONC with a URL in a block comment", () => {
25 expect(
26 parseT3ProjectFile(`{
27 /* See https://t3.codes/schema/t3.json */
28 "defaultThreadEnvMode": "worktree"
29 }`),
30 ).toEqual({ defaultThreadEnvMode: "worktree" });
31 });
32});