syntaxai/tdd.md · main · src / b51_render_admin.test.ts

b51_render_admin.test.ts 35 lines · 1196 bytes raw
// Sibling test for c51_render_admin.ts (Layer 1, render). The admin
// pages (list, edit, login wall, non-admin wall) are exercised by
// e2e/admin-block-editor.spec.ts. This sibling pins the export shape.

import { describe, test, expect } from "bun:test";
import {
  renderAdminList,
  renderAdminEdit,
  renderAdminLoginWall,
  renderAdminNonAdminWall,
} from "./b51_render_admin.ts";

describe("c51_render_admin — export shape", () => {
  test("renderAdminList is async", () => {
    expect(typeof renderAdminList).toBe("function");
  });
  test("renderAdminEdit is async", () => {
    expect(typeof renderAdminEdit).toBe("function");
  });
  test("renderAdminLoginWall is async", () => {
    expect(typeof renderAdminLoginWall).toBe("function");
  });
  test("renderAdminNonAdminWall is async", () => {
    expect(typeof renderAdminNonAdminWall).toBe("function");
  });
});

describe("c51_render_admin — login wall renders for anonymous viewer", () => {
  test("returns an HTML document mentioning sign-in", async () => {
    const html = await renderAdminLoginWall();
    expect(html).toContain("<!doctype html>");
    expect(html.toLowerCase()).toMatch(/sign in|login|github/);
  });
});