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

c14_github.test.ts 29 lines · 1229 bytes raw
// Sibling test for c14_github.ts (Layer 2, HTTP adapter). The
// functions in this file all make network calls; covering them
// end-to-end belongs in integration tests that hit GitHub. This
// sibling pins that the public contract (export list + their type)
// hasn't drifted, and exercises pure-ish helpers where they exist.

import { describe, test, expect } from "bun:test";
import { isConfigured, authorizeUrl } from "./c14_github.ts";

describe("c14_github — export shape", () => {
  test("isConfigured is a function returning boolean", () => {
    expect(typeof isConfigured).toBe("function");
    expect(typeof isConfigured()).toBe("boolean");
  });
  test("authorizeUrl is a function", () => {
    expect(typeof authorizeUrl).toBe("function");
  });
});

describe("c14_github — authorizeUrl shape", () => {
  test("returns a github.com/login/oauth/authorize URL with the supplied state + redirect_uri", () => {
    const url = authorizeUrl("nonce-abc", "https://example.test/cb");
    expect(url).toContain("github.com/login/oauth/authorize");
    expect(url).toContain("state=nonce-abc");
    expect(url).toContain("redirect_uri=");
    expect(url).toMatch(/redirect_uri=https?%3A%2F%2Fexample\.test%2Fcb/);
  });
});