| 1 | import { describe, expect, it } from "vite-plus/test"; |
| 2 | |
| 3 | import { getTerminalBufferReplayKey, getTerminalSurfaceReplayBuffer } from "./terminalBufferReplay"; |
| 4 | |
| 5 | describe("terminalBufferReplay", () => { |
| 6 | it("keys replay readiness by terminal identity and font metrics", () => { |
| 7 | expect( |
| 8 | getTerminalBufferReplayKey({ |
| 9 | terminalKey: "env-1:thread-1:default", |
| 10 | fontSize: 10, |
| 11 | }), |
| 12 | ).toBe("env-1:thread-1:default:10"); |
| 13 | }); |
| 14 | |
| 15 | it("shows terminal history while replay key is unset (initial mount / after key change)", () => { |
| 16 | const replayKey = getTerminalBufferReplayKey({ |
| 17 | terminalKey: "env-1:thread-1:default", |
| 18 | fontSize: 10, |
| 19 | }); |
| 20 | |
| 21 | expect( |
| 22 | getTerminalSurfaceReplayBuffer({ |
| 23 | buffer: "fastfetch output", |
| 24 | replayKey, |
| 25 | readyReplayKey: null, |
| 26 | }), |
| 27 | ).toBe("fastfetch output"); |
| 28 | expect( |
| 29 | getTerminalSurfaceReplayBuffer({ |
| 30 | buffer: "fastfetch output", |
| 31 | replayKey, |
| 32 | readyReplayKey: "env-1:thread-1:default:11", |
| 33 | }), |
| 34 | ).toBe(""); |
| 35 | expect( |
| 36 | getTerminalSurfaceReplayBuffer({ |
| 37 | buffer: "fastfetch output", |
| 38 | replayKey, |
| 39 | readyReplayKey: replayKey, |
| 40 | }), |
| 41 | ).toBe("fastfetch output"); |
| 42 | }); |
| 43 | }); |