| 1 | import { assert, describe, it } from "@effect/vitest"; |
| 2 | |
| 3 | import { |
| 4 | DesktopBackendPortUnavailableError, |
| 5 | DesktopDevelopmentBackendPortRequiredError, |
| 6 | } from "./DesktopApp.ts"; |
| 7 | |
| 8 | describe("DesktopApp errors", () => { |
| 9 | it("preserves unavailable backend port context", () => { |
| 10 | const error = new DesktopBackendPortUnavailableError({ |
| 11 | startPort: 3_773, |
| 12 | maxPort: 65_535, |
| 13 | hosts: ["127.0.0.1", "0.0.0.0", "::"], |
| 14 | }); |
| 15 | |
| 16 | assert.equal(error.startPort, 3_773); |
| 17 | assert.equal(error.maxPort, 65_535); |
| 18 | assert.deepEqual(error.hosts, ["127.0.0.1", "0.0.0.0", "::"]); |
| 19 | assert.equal( |
| 20 | error.message, |
| 21 | "No desktop backend port is available on hosts 127.0.0.1, 0.0.0.0, :: between 3773 and 65535.", |
| 22 | ); |
| 23 | }); |
| 24 | |
| 25 | it("reports the required development port", () => { |
| 26 | const error = new DesktopDevelopmentBackendPortRequiredError(); |
| 27 | |
| 28 | assert.equal(error.message, "T3CODE_PORT is required in desktop development."); |
| 29 | }); |
| 30 | }); |