| 1 | import { beforeEach, describe, expect, it } from "vite-plus/test"; |
| 2 | import { EnvironmentId, ThreadId } from "@t3tools/contracts"; |
| 3 | |
| 4 | import { |
| 5 | cacheTerminalGridSize, |
| 6 | getCachedTerminalGridSize, |
| 7 | resetTerminalUiStateCaches, |
| 8 | } from "./terminalUiState"; |
| 9 | |
| 10 | describe("terminalUiState", () => { |
| 11 | beforeEach(() => { |
| 12 | resetTerminalUiStateCaches(); |
| 13 | }); |
| 14 | |
| 15 | it("stores terminal grid sizes per terminal target", () => { |
| 16 | const primaryTarget = { |
| 17 | environmentId: EnvironmentId.make("env-1"), |
| 18 | threadId: ThreadId.make("thread-1"), |
| 19 | terminalId: "default", |
| 20 | }; |
| 21 | const otherTarget = { |
| 22 | environmentId: EnvironmentId.make("env-1"), |
| 23 | threadId: ThreadId.make("thread-1"), |
| 24 | terminalId: "term-2", |
| 25 | }; |
| 26 | |
| 27 | expect(getCachedTerminalGridSize(primaryTarget)).toBeNull(); |
| 28 | expect( |
| 29 | cacheTerminalGridSize(primaryTarget, { |
| 30 | cols: 107.9, |
| 31 | rows: 33.2, |
| 32 | }), |
| 33 | ).toEqual({ |
| 34 | cols: 107, |
| 35 | rows: 33, |
| 36 | }); |
| 37 | expect(getCachedTerminalGridSize(primaryTarget)).toEqual({ |
| 38 | cols: 107, |
| 39 | rows: 33, |
| 40 | }); |
| 41 | expect(getCachedTerminalGridSize(otherTarget)).toBeNull(); |
| 42 | }); |
| 43 | }); |