| 1 | import { describe, expect, it } from "vite-plus/test"; |
| 2 | |
| 3 | import { resolveThreadSettlementWarning } from "./threadSettled.ts"; |
| 4 | |
| 5 | describe("settlement resource warning", () => { |
| 6 | it("skips confirmation when no commands or browser tabs need closing", () => { |
| 7 | expect( |
| 8 | resolveThreadSettlementWarning({ runningCommands: false, browserTabs: false }), |
| 9 | ).toBeNull(); |
| 10 | }); |
| 11 | |
| 12 | it.each([ |
| 13 | { runningCommands: true, browserTabs: false, text: "Undo cannot restart them." }, |
| 14 | { runningCommands: false, browserTabs: true, text: "Undo cannot restore page state." }, |
| 15 | { |
| 16 | runningCommands: true, |
| 17 | browserTabs: true, |
| 18 | text: "Undo cannot restore commands or page state.", |
| 19 | }, |
| 20 | ])( |
| 21 | "describes only the resources being closed: $runningCommands/$browserTabs", |
| 22 | ({ text, ...resources }) => { |
| 23 | expect(resolveThreadSettlementWarning(resources)).toContain(text); |
| 24 | }, |
| 25 | ); |
| 26 | |
| 27 | it.each([ |
| 28 | { runningCommands: null, browserTabs: false }, |
| 29 | { runningCommands: false, browserTabs: null }, |
| 30 | { runningCommands: null, browserTabs: null }, |
| 31 | ])("never treats an unavailable resource read as empty", (resources) => { |
| 32 | expect(resolveThreadSettlementWarning(resources)).toContain("could not be checked"); |
| 33 | }); |
| 34 | }); |