62 lines
1.6 KiB
TypeScript
62 lines
1.6 KiB
TypeScript
import { describe, expect, it } from "vitest";
|
|
import {
|
|
configChangeRows,
|
|
configSnapshotFromUi,
|
|
sameConfigSnapshot,
|
|
} from "./snapshots";
|
|
|
|
describe("configuration snapshots", () => {
|
|
it("normalizes proxy and Windows app values", () => {
|
|
const snapshot = configSnapshotFromUi(
|
|
"external",
|
|
" SOCKS5://Proxy.Example.Test:1080 ",
|
|
[
|
|
{ type: "process", value: "C:\\Apps\\Discord.exe" },
|
|
{ type: "folder", value: " C:\\Games " },
|
|
],
|
|
);
|
|
|
|
expect(snapshot.proxy).toBe("socks5://proxy.example.test:1080");
|
|
expect(snapshot.items).toEqual([
|
|
{ type: "folder", value: "c:\\games" },
|
|
{ type: "process", value: "discord" },
|
|
]);
|
|
});
|
|
|
|
it("detects a server change by stable id even when tags match", () => {
|
|
const applied = configSnapshotFromUi(
|
|
"local-singbox",
|
|
"",
|
|
[],
|
|
"server-a",
|
|
"Same tag",
|
|
);
|
|
const current = configSnapshotFromUi(
|
|
"local-singbox",
|
|
"",
|
|
[],
|
|
"server-b",
|
|
"Same tag",
|
|
);
|
|
|
|
expect(sameConfigSnapshot(applied, current)).toBe(false);
|
|
expect(configChangeRows(applied, current).map((row) => row.id)).toContain(
|
|
"vpn-server",
|
|
);
|
|
});
|
|
|
|
it("reports added and removed app items independent of input order", () => {
|
|
const applied = configSnapshotFromUi("external", "proxy.test:1080", [
|
|
{ type: "process", value: "Discord.exe" },
|
|
]);
|
|
const current = configSnapshotFromUi("external", "proxy.test:1080", [
|
|
{ type: "process", value: "Telegram.exe" },
|
|
]);
|
|
|
|
expect(configChangeRows(applied, current).map((row) => row.tone)).toEqual([
|
|
"added",
|
|
"removed",
|
|
]);
|
|
});
|
|
});
|