Backend modules from tastefully 8bd93d15: core-libs, core-session, api-gateway, mobile-api, services-auth, services-system, services-counter, services-member, services-log, services-email. solvway-admin-portal from babyboo f64d096ea, solvway-customer-portal from tastefully 8bd93d15. Copied as tracked files only. Literal secrets replaced with environment placeholders: - services-email: SMTP_PASSWORD, MAILGUN_API_KEY, SENDGRID_API_KEY, MAILJET_API_KEY, MAILJET_SECRET_KEY (optional, empty default) - services-system: JUMIO_TOKEN, JUMIO_SECRET (optional) - services-auth: USER_AUTH_API_SECRET (required); commented JWT secret removed - core-libs: JWT_TOKEN default removed (required), XXL_JOB_TOKEN default removed, ipgeolocation key read from IPGEOLOCATION_API_KEY - services-system EkycAppConfig: commented Jumio credentials removed Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01EFUzfj5akPxyikzGc2iAHM
24 lines
1.3 KiB
TypeScript
24 lines
1.3 KiB
TypeScript
import { describe, it, expect } from "vitest";
|
|
import { buildTarget, type TargetDraft } from "./broadcastTarget";
|
|
|
|
const d = (over: Partial<TargetDraft>): TargetDraft => ({
|
|
kind: "ALL", rank: "", status: "", nationality: "", codes: [], downlineCode: "", includeSelf: false, ...over,
|
|
});
|
|
|
|
describe("buildTarget", () => {
|
|
it("ALL", () => expect(buildTarget(d({}))).toEqual({ kind: "ALL" }));
|
|
it("FILTER carries only the fields that are set, nationality upper-cased", () => {
|
|
expect(buildTarget(d({ kind: "FILTER", rank: "GIRAFFE", nationality: " my " }))).toEqual({ kind: "FILTER", rank: "GIRAFFE", nationality: "MY" });
|
|
expect(buildTarget(d({ kind: "FILTER", status: "Y" }))).toEqual({ kind: "FILTER", status: "Y" });
|
|
});
|
|
it("an empty FILTER is incomplete", () => expect(buildTarget(d({ kind: "FILTER" }))).toBeNull());
|
|
it("LIST needs at least one code", () => {
|
|
expect(buildTarget(d({ kind: "LIST" }))).toBeNull();
|
|
expect(buildTarget(d({ kind: "LIST", codes: ["MY3", "MY5"] }))).toEqual({ kind: "LIST", codes: ["MY3", "MY5"] });
|
|
});
|
|
it("DOWNLINE needs a member and carries includeSelf", () => {
|
|
expect(buildTarget(d({ kind: "DOWNLINE" }))).toBeNull();
|
|
expect(buildTarget(d({ kind: "DOWNLINE", downlineCode: "MY2", includeSelf: true }))).toEqual({ kind: "DOWNLINE", code: "MY2", includeSelf: true });
|
|
});
|
|
});
|