import { describe, expect, test } from "bun:test";
import {
claimedLabel,
commitLabel,
emailAllowed,
hostLabel,
isBlockedOutbound,
isReservedSetCookie,
isValidLabel,
safeNext,
sanitizeSetCookie,
previewLabel,
pullLabel,
scratchLabel,
signAccess,
siteLabel,
slug,
splitWorker,
stripReservedCookies,
validSitesDomain,
verifyAccess,
} from "./naming";
import { hashSitePassword, verifySitePassword } from "./password";
const DOMAIN = "gitforstatic.dev";
describe("labels", () => {
test("slugs never contain the -- separator", () => {
expect(slug("My--Repo__v2.0")).toBe("my-repo-v2-0");
expect(slug("--x--")).toBe("x");
});
test("user, project, preview and scratch labels", () => {
expect(siteLabel("Alice", "alice", DOMAIN)).toBe("alice");
expect(siteLabel("alice", "alice.gitforstatic.dev", DOMAIN)).toBe("alice");
expect(siteLabel("alice", "blog", DOMAIN)).toBe("blog--alice");
expect(previewLabel("blog--alice", "feature/Login")).toBe("feature-login--blog--alice");
expect(previewLabel("alice", "dev")).toBe("dev--alice--alice");
expect(scratchLabel("k3x9")).toBe("k3x9--scratch");
expect(claimedLabel("k3x9", "alice")).toBe("k3x9--alice");