|
|
|
|
@ -1,5 +1,5 @@
|
|
|
|
|
import { describe, expect, it } from "vitest";
|
|
|
|
|
import { resolveAccountEntry } from "./account-lookup.js";
|
|
|
|
|
import { resolveAccountEntry, resolveNormalizedAccountEntry } from "./account-lookup.js";
|
|
|
|
|
|
|
|
|
|
describe("resolveAccountEntry", () => {
|
|
|
|
|
it("resolves direct and case-insensitive account keys", () => {
|
|
|
|
|
@ -17,3 +17,26 @@ describe("resolveAccountEntry", () => {
|
|
|
|
|
expect(resolveAccountEntry(accounts, "default")).toBeUndefined();
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
describe("resolveNormalizedAccountEntry", () => {
|
|
|
|
|
it("resolves normalized account keys with a custom normalizer", () => {
|
|
|
|
|
const accounts = {
|
|
|
|
|
"Ops Team": { id: "ops" },
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
expect(
|
|
|
|
|
resolveNormalizedAccountEntry(accounts, "ops-team", (accountId) =>
|
|
|
|
|
accountId.trim().toLowerCase().replaceAll(" ", "-"),
|
|
|
|
|
),
|
|
|
|
|
).toEqual({ id: "ops" });
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it("ignores prototype-chain values", () => {
|
|
|
|
|
const inherited = { default: { id: "polluted" } };
|
|
|
|
|
const accounts = Object.create(inherited) as Record<string, { id: string }>;
|
|
|
|
|
|
|
|
|
|
expect(
|
|
|
|
|
resolveNormalizedAccountEntry(accounts, "default", (accountId) => accountId),
|
|
|
|
|
).toBeUndefined();
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|