mirror of
https://git.quad4.io/RNS-Things/MeshChatX.git
synced 2026-04-25 15:22:10 +00:00
36 lines
1.4 KiB
JavaScript
36 lines
1.4 KiB
JavaScript
import { describe, expect, it } from "vitest";
|
|
import { createRequire } from "module";
|
|
|
|
const require = createRequire(import.meta.url);
|
|
const notice = require("../../electron/loadingStatusNotice.js");
|
|
|
|
describe("electron/loadingStatusNotice", () => {
|
|
it("classifyConnectionIssue prefers backend-exited when runtime not running", () => {
|
|
const r = notice.classifyConnectionIssue([], {
|
|
running: false,
|
|
lastExitCode: 1,
|
|
});
|
|
expect(r.reason).toBe("backend-exited");
|
|
});
|
|
|
|
it("classifyConnectionIssue flags loopback blocked", () => {
|
|
const r = notice.classifyConnectionIssue([{ kind: "address-unreachable" }], { running: true });
|
|
expect(r.reason).toBe("loopback-blocked");
|
|
});
|
|
|
|
it("classifyConnectionIssue uses starting before network threshold", () => {
|
|
const r = notice.classifyConnectionIssue([{ kind: "network-error" }], { running: true }, { attemptCount: 1 });
|
|
expect(r.reason).toBe("starting");
|
|
});
|
|
|
|
it("classifyFetchError maps address unreachable", () => {
|
|
expect(notice.classifyFetchError({ name: "Error", message: "net::ERR_ADDRESS_UNREACHABLE" })).toBe(
|
|
"address-unreachable"
|
|
);
|
|
});
|
|
|
|
it("classifyFetchError defaults to network-error", () => {
|
|
expect(notice.classifyFetchError({ name: "TypeError", message: "fetch failed" })).toBe("network-error");
|
|
});
|
|
});
|