mirror of
https://github.com/Tria-plc/edr-platform.git
synced 2026-08-29 16:28:12 +00:00
refactor: centralized the iam seeder
This commit is contained in:
27
packages/iam-seed/src/missing-settings.util.spec.ts
Normal file
27
packages/iam-seed/src/missing-settings.util.spec.ts
Normal file
@@ -0,0 +1,27 @@
|
||||
import { missingSettings } from "./missing-settings.util";
|
||||
|
||||
const defaults = [
|
||||
{ key: "primaryColor", displayName: "Primary Color", value: null },
|
||||
{ key: "logoFileUrl", displayName: "Logo", value: null },
|
||||
];
|
||||
|
||||
describe("missingSettings", () => {
|
||||
it("returns every default when the owner has none", () => {
|
||||
expect(missingSettings(defaults, new Set(), "org-1")).toHaveLength(2);
|
||||
});
|
||||
|
||||
it("skips keys the owner has, but not the same key on another owner", () => {
|
||||
const existing = new Set(["org-1:primaryColor"]);
|
||||
|
||||
expect(
|
||||
missingSettings(defaults, existing, "org-1").map((s) => s.key),
|
||||
).toEqual(["logoFileUrl"]);
|
||||
expect(missingSettings(defaults, existing, "org-2")).toHaveLength(2);
|
||||
});
|
||||
|
||||
it("drops nulls so the column default applies", () => {
|
||||
expect(
|
||||
missingSettings(defaults, new Set(), "org-1")[0].value,
|
||||
).toBeUndefined();
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user