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

consoleStdin.test.ts

33 lines1.1 KB

1import { describe, expect, it } from "vite-plus/test";
2​
3import { needsConsoleStdin } from "./consoleStdin.ts";
4​
5const launcher = {
6 platform: "win32" as const,
7 env: { T3CODE_DESKTOP_CLI_LAUNCHER: "1" },
8 stdinOpen: false,
9 stdoutIsConsole: true,
10};
11​
12describe("needsConsoleStdin", () => {
13 it("reopens the console for the desktop launcher in a terminal without stdin", () => {
14 expect(needsConsoleStdin(launcher)).toBe(true);
15 });
16​
17 it("leaves every other way of running the CLI alone", () => {
18 for (const other of [
19 // Input the user piped or redirected.
20 { ...launcher, stdinOpen: true },
21 // Output to a pipe or file: the desktop backend, scripts, CI.
22 { ...launcher, stdoutIsConsole: false },
23 // The desktop backend runs the same executable but is not the launcher.
24 { ...launcher, env: { ELECTRON_RUN_AS_NODE: "1", T3CODE_CLI_PATH: "C:\\t3.cmd" } },
25 // npm, the install scripts, and plain Node runs.
26 { ...launcher, env: {} },
27 { ...launcher, platform: "linux" as const },
28 { ...launcher, platform: "darwin" as const },
29 ]) {
30 expect(needsConsoleStdin(other)).toBe(false);
31 }
32 });
33});