22 lines
829 B
TypeScript
22 lines
829 B
TypeScript
import { readFile } from "node:fs/promises";
|
|
import { describe, expect, it } from "vitest";
|
|
import { isValidPhone, normalizePhone } from "@/lib/server/account-store";
|
|
|
|
type Fixture = {
|
|
version: 1;
|
|
phoneCases: Array<{ input: string; normalized: string; valid: boolean }>;
|
|
};
|
|
|
|
const fixtureURL = new URL("../contracts/admin/accounts-organizations-v1.json", import.meta.url);
|
|
|
|
describe("administration accounts and organizations v1 contract", () => {
|
|
it("shares phone normalization and validation with the real TypeScript store", async () => {
|
|
const fixture = JSON.parse(await readFile(fixtureURL, "utf8")) as Fixture;
|
|
for (const testCase of fixture.phoneCases) {
|
|
expect(normalizePhone(testCase.input)).toBe(testCase.normalized);
|
|
expect(isValidPhone(testCase.input)).toBe(testCase.valid);
|
|
}
|
|
});
|
|
|
|
});
|