BRIDGE_Modul-S_prod / src /api.test.ts
sitcod3's picture
build: add Docker support and deployment pipeline
9e7f815
Raw History Blame Contribute Delete
1.2 kB
import { describe, it, expect } from "vitest";
describe("API & Data Integrity", () => {
it("calculates deliverability and reply rate percentages accurately", () => {
const sent = 1000;
const replies = 47;
const rate = ((replies / sent) * 100).toFixed(1);
expect(rate).toBe("4.7");
});
it("clamps reputation score between 0 and 100", () => {
const clamp = (val: number) => Math.min(100, Math.max(0, val));
expect(clamp(105)).toBe(100);
expect(clamp(-5)).toBe(0);
expect(clamp(98.4)).toBe(98.4);
});
it("formats provider names correctly", () => {
const formatProvider = (p: string) => {
const cleaned = p.toUpperCase();
if (cleaned === "GGOOGLE" || cleaned === "GOOGLE") return "Google Workspace";
if (cleaned === "MICROSOFT" || cleaned === "OFFICE365") return "Microsoft 365";
if (cleaned === "SMTP") return "Custom SMTP / IMAP";
return cleaned;
};
expect(formatProvider("GGOOGLE")).toBe("Google Workspace");
expect(formatProvider("GOOGLE")).toBe("Google Workspace");
expect(formatProvider("MICROSOFT")).toBe("Microsoft 365");
expect(formatProvider("SMTP")).toBe("Custom SMTP / IMAP");
});
});