leistungsbilanz-ts/tests/config-access.test.ts

26 lines
1.1 KiB
TypeScript

import assert from "node:assert/strict";
import { describe, it } from "node:test";
import {
getConfigEntry,
getConfigRedirect,
getConfigTabs,
} from "../src/frontend/utils/config-access.js";
describe("config access", () => {
it("offers account settings to every signed-in user", () => {
assert.deepEqual(getConfigEntry(false), { href: "/config/konto", label: "Konto" });
assert.deepEqual(getConfigTabs(false), [{ href: "/config/konto", label: "Konto" }]);
assert.equal(getConfigRedirect("/config", false), "/config/konto");
assert.equal(getConfigRedirect("/config/konto", false), null);
});
it("keeps user administration admin-only", () => {
assert.equal(getConfigRedirect("/config/benutzer", false), "/config/konto");
assert.deepEqual(getConfigTabs(true), [
{ href: "/config/benutzer", label: "Benutzer" },
{ href: "/config/konto", label: "Konto" },
]);
assert.deepEqual(getConfigEntry(true), { href: "/config/benutzer", label: "Config" });
assert.equal(getConfigRedirect("/config/benutzer", true), null);
});
});