Files
browser/platform_web/utils/iniConfig.test.ts
T

18 lines
919 B
TypeScript

import { describe, expect, it } from "vitest";
import { iniValue, updateIniValues } from "./iniConfig";
describe("SCUM INI configuration editing", () => {
it("reads prefixed keys without losing empty values", () => {
const content = "[General]\nscum.ServerName=Test\nscum.ServerPassword=\nscum.MaxPlayers=63\n";
expect(iniValue(content, "scum.ServerName")).toBe("Test");
expect(iniValue(content, "scum.ServerPassword")).toBe("");
expect(iniValue(content, "scum.Missing")).toBe("");
});
it("updates declared keys and appends a missing key while preserving the rest", () => {
const content = "[General]\r\n; keep this comment\r\nscum.ServerName=Old\r\nunknown.value=keep\r\n";
expect(updateIniValues(content, { "scum.ServerName": "New", "scum.MaxPlayers": "63" })).toBe("[General]\r\n; keep this comment\r\nscum.ServerName=New\r\nunknown.value=keep\r\n\r\nscum.MaxPlayers=63");
});
});