The best way to control Claude Code, Codex and more from any computer or phone
Mirrored from https://github.com/Camo67/t3code.git
Synced Nov 21, 04:45 UTC
| 1 | import { describe, expect, it } from "vite-plus/test"; |
| 2 | |
| 3 | import { findReusableProjectScriptTerminal } from "./projectScriptTerminal"; |
| 4 | |
| 5 | describe("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 | { |
| 40 | name: "skips an idle terminal whose close is still pending", |
| 41 | drawerTerminalIds: ["term-1"], |
| 42 | activeTerminalId: "term-1", |
| 43 | panelTerminalIds: [], |
| 44 | runningTerminalIds: [], |
| 45 | closingTerminalIds: ["term-1"], |
| 46 | expected: null, |
| 47 | }, |
| 48 | ])("$name", ({ panelTerminalIds, closingTerminalIds = [], expected, ...input }) => { |
| 49 | expect( |
| 50 | findReusableProjectScriptTerminal({ |
| 51 | ...input, |
| 52 | panelTerminalIds: new Set(panelTerminalIds), |
| 53 | closingTerminalIds, |
| 54 | }), |
| 55 | ).toBe(expected); |
| 56 | }); |
| 57 | }); |