Spaces:
Running
Running
Download src/api.test.ts from sitcod3/BRIDGE_Modul-S_prod: direct link, hf CLI and curl.
- Browser
- Download file 1.2 kB
-
https://huggingface.co/spaces/sitcod3/BRIDGE_Modul-S_prod/resolve/main/src/api.test.ts
- Command line
-
hf download hf://spaces/sitcod3/BRIDGE_Modul-S_prod/src/api.test.ts
-
curl -L -o api.test.ts https://huggingface.co/spaces/sitcod3/BRIDGE_Modul-S_prod/resolve/main/src/api.test.ts
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"); | |
| }); | |
| }); | |