import assert from "node:assert/strict";
import { existsSync, readFileSync } from "node:fs";
import test from "node:test";

const themeRoot = new URL("../../", import.meta.url);
const headTemplate = readFileSync(
    new URL("templates/partials/head.html.twig", themeRoot),
    "utf8",
);

test("the theme provides white favicons when the browser uses a dark color scheme", () => {
    assert.equal(
        existsSync(new URL("public/favicon/favicon-dark-16x16.png", themeRoot)),
        true,
    );
    assert.equal(
        existsSync(new URL("public/favicon/favicon-dark-32x32.png", themeRoot)),
        true,
    );
    assert.match(
        headTemplate,
        /favicon-dark-32x32\.png[\s\S]*?media="\(prefers-color-scheme: dark\)"/u,
    );
    assert.match(
        headTemplate,
        /favicon-dark-16x16\.png[\s\S]*?media="\(prefers-color-scheme: dark\)"/u,
    );
});
