Open History to see the last commit
1import { assert, expect, it } from "@effect/vitest";
2import { HostProcessPlatform } from "@t3tools/shared/hostProcess";
3import * as Cause from "effect/Cause";
4import * as Effect from "effect/Effect";
5import * as Exit from "effect/Exit";
6
7import * as BunPtyAdapter from "./BunPtyAdapter.ts";
8
9it("describes unavailable Bun PTY operations structurally", () => {
10 const error = new BunPtyAdapter.BunPtyOperationUnavailableError({
11 operation: "resize",
12 pid: 42,
13 });
14
15 expect(error).toMatchObject({
16 _tag: "BunPtyOperationUnavailableError",
17 operation: "resize",
18 pid: 42,
19 });
20 expect(error.message).toBe("Bun PTY resize is unavailable for process 42.");
21});
22
23it.effect("reports unsupported platforms with a structured startup defect", () =>
24 Effect.gen(function* () {
25 const exit = yield* BunPtyAdapter.make().pipe(
26 Effect.provideService(HostProcessPlatform, "win32"),
27 Effect.exit,
28 );
29
30 expect(Exit.isFailure(exit)).toBe(true);
31 if (Exit.isFailure(exit)) {
32 expect(Cause.hasDies(exit.cause)).toBe(true);
33 const error = Cause.squash(exit.cause);
34 assert.instanceOf(error, BunPtyAdapter.BunPtyUnsupportedPlatformError);
35 expect(error).toMatchObject({
36 _tag: "BunPtyUnsupportedPlatformError",
37 platform: "win32",
38 });
39 expect(error.message).toBe(
40 "Bun PTY terminal support is unavailable on win32. Please use Node.js (e.g. by running `npx t3`) instead.",
41 );
42 }
43 }),
44);