Skip to content
Source
Sign inSign up

projectScriptTerminal.test.ts

44 lines1.4 KB

1import { describe, expect, it } from "vite-plus/test";
2​
3import { findReusableProjectScriptTerminal } from "./projectScriptTerminal";
4​
5describe("findReusableProjectScriptTerminal", () => {
6 it.each([
7 {
8 name: "never reuses a right-panel terminal, even when stale in drawer state",
9 drawerTerminalIds: ["term-1"],
10 activeTerminalId: "term-1",
11 panelTerminalIds: ["term-1"],
12 runningTerminalIds: [],
13 expected: null,
14 },
15 {
16 name: "reuses the active idle drawer terminal",
17 drawerTerminalIds: ["term-1", "term-2"],
18 activeTerminalId: "term-2",
19 panelTerminalIds: [],
20 runningTerminalIds: [],
21 expected: "term-2",
22 },
23 {
24 name: "falls back to another idle drawer terminal when the active one is busy",
25 drawerTerminalIds: ["term-1", "term-2"],
26 activeTerminalId: "term-1",
27 panelTerminalIds: [],
28 runningTerminalIds: ["term-1"],
29 expected: "term-2",
30 },
31 {
32 name: "finds nothing when every drawer terminal is busy",
33 drawerTerminalIds: ["term-1"],
34 activeTerminalId: "term-1",
35 panelTerminalIds: [],
36 runningTerminalIds: ["term-1"],
37 expected: null,
38 },
39 ])("$name", ({ panelTerminalIds, expected, ...input }) => {
40 expect(
41 findReusableProjectScriptTerminal({ ...input, panelTerminalIds: new Set(panelTerminalIds) }),
42 ).toBe(expected);
43 });
44});