import { describe, expect, test } from "bun:test";
import { readFileSync } from "node:fs";
import { join } from "node:path";
import { accountOgPath, featureOgPath, repoOgPath, siteOgPath } from "~/lib/og";
import { seo } from "./seo";
const ORIGIN = "https://gitfor.dev";
function tags(input: Parameters<typeof seo>[0]) {
const out = seo(input);
const byProperty = (key: string) =>
out.find((tag) => ("property" in tag && tag.property === key) || ("name" in tag && tag.name === key));
return { out, get: (key: string) => (byProperty(key) as { content?: string } | undefined)?.content };
}
function expectSocial(result: ReturnType<typeof tags>, image: string) {
expect(result.get("og:image")).toBe(`${ORIGIN}${image}`);
expect(result.get("twitter:image")).toBe(`${ORIGIN}${image}`);
expect(result.get("twitter:card")).toBe("summary_large_image");
expect(result.get("og:site_name")).toBe("gitfor");
expect(result.get("og:image:width")).toBe("1200");
expect(result.get("og:image:height")).toBe("630");
expect(result.get("og:image:alt")).toBeTruthy();
expect(result.out.some((tag) => "name" in tag && tag.name?.startsWith("og:"))).toBe(false);
}
const repo = {
owner: "alice",
name: "tool",
description: "A tool",
stars: 1,
forks: 0,
openIssues: 0,
openPulls: 0,
avatarKey: null,
latestRelease: null,
topics: [],
languages: [],
};