1import * as Schema from "effect/Schema";
2import { describe, expect, it } from "vite-plus/test";
3
4import { DesktopEnvironmentBootstrapSchema } from "./ipc.ts";
5
6describe("DesktopEnvironmentBootstrapSchema", () => {
7 const decode = Schema.decodeUnknownSync(DesktopEnvironmentBootstrapSchema);
8
9 it("preserves the concrete running distro separately from the backend id", () => {
10 expect(
11 decode({
12 id: "wsl:default",
13 label: "WSL (Ubuntu)",
14 runningDistro: "Ubuntu",
15 httpBaseUrl: "http://127.0.0.1:3774/",
16 wsBaseUrl: "ws://127.0.0.1:3774/",
17 }),
18 ).toEqual({
19 id: "wsl:default",
20 label: "WSL (Ubuntu)",
21 runningDistro: "Ubuntu",
22 httpBaseUrl: "http://127.0.0.1:3774/",
23 wsBaseUrl: "ws://127.0.0.1:3774/",
24 });
25 });
26
27 it("allows non-running and non-WSL bootstraps to report no running distro", () => {
28 expect(
29 decode({
30 id: "primary",
31 label: "Windows",
32 runningDistro: null,
33 httpBaseUrl: null,
34 wsBaseUrl: null,
35 }).runningDistro,
36 ).toBeNull();
37 });
38});