mirror of
https://github.com/Termix-SSH/Termix.git
synced 2026-11-01 08:05:23 +00:00
fix: pick a free port for the desktop backend when 30001 is taken (#1663)
This commit is contained in:
1 parent
9949d0711e
commit
49f1914e6e
12 files changed
+115
-20
No files matched your search
@@ -0,0 +1,25 @@
|
||||
import { afterEach, describe, expect, it } from "vitest";
|
||||
import { localBackendPort } from "@/lib/electron";
|
||||
|
||||
function setElectronAPI(api: unknown) {
|
||||
(window as unknown as { electronAPI?: unknown }).electronAPI = api;
|
||||
}
|
||||
|
||||
afterEach(() => {
|
||||
delete (window as unknown as { electronAPI?: unknown }).electronAPI;
|
||||
});
|
||||
|
||||
describe("localBackendPort", () => {
|
||||
it("uses the port the desktop app picked", () => {
|
||||
setElectronAPI({ backendPort: 41234 });
|
||||
expect(localBackendPort()).toBe(41234);
|
||||
});
|
||||
|
||||
it("falls back to 30001", () => {
|
||||
expect(localBackendPort()).toBe(30001);
|
||||
setElectronAPI({ backendPort: Number.NaN });
|
||||
expect(localBackendPort()).toBe(30001);
|
||||
setElectronAPI({ backendPort: 70000 });
|
||||
expect(localBackendPort()).toBe(30001);
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user