feat: add CHRNX theme preference and marks
This commit is contained in:
11 files changed
+469
-3
No files matched your search
@@ -0,0 +1,35 @@
|
||||
import assert from 'node:assert/strict';
|
||||
import { readFile } from 'node:fs/promises';
|
||||
import test from 'node:test';
|
||||
|
||||
const readProjectFile = (path) => readFile(new URL(`../../${path}`, import.meta.url), 'utf8');
|
||||
|
||||
test('theme toggle metadata is dynamic, localized, and frontend-only', async () => {
|
||||
const metadata = JSON.parse(await readProjectFile('blocks/theme-toggle/block.json'));
|
||||
assert.equal(metadata.apiVersion, 3);
|
||||
assert.equal(metadata.name, 'chrnx/theme-toggle');
|
||||
assert.equal(metadata.textdomain, 'chrnx');
|
||||
assert.equal(metadata.render, 'file:./render.php');
|
||||
assert.equal(metadata.viewScript, 'file:../../assets/js/theme-toggle.js');
|
||||
assert.equal(metadata.script, undefined);
|
||||
});
|
||||
|
||||
for (const asset of ['chrnx-cat.svg', 'chrnx-wordmark.svg']) {
|
||||
test(`${asset} is an inert, local, vector-only asset`, async () => {
|
||||
const svg = await readProjectFile(`assets/icons/${asset}`);
|
||||
assert.match(svg, /^<svg\b/);
|
||||
assert.doesNotMatch(svg, /<(?:script|image|foreignObject)\b/i);
|
||||
assert.doesNotMatch(svg, /(?:href|src)\s*=\s*["'](?:https?:|data:|javascript:)/i);
|
||||
assert.doesNotMatch(svg, /\b(?:aria-|role=|<title\b)/i);
|
||||
});
|
||||
}
|
||||
|
||||
test('wordmark uses real fallback-aware SVG text and shares exact cat geometry', async () => {
|
||||
const cat = await readProjectFile('assets/icons/chrnx-cat.svg');
|
||||
const wordmark = await readProjectFile('assets/icons/chrnx-wordmark.svg');
|
||||
const geometry = cat.match(/<g id="chrnx-cat-geometry"[^>]*>([\s\S]*?)<\/g>/)?.[1].trim();
|
||||
assert.ok(geometry, 'standalone cat must expose its canonical geometry group');
|
||||
assert.ok(wordmark.includes(geometry), 'wordmark must contain the exact canonical cat geometry');
|
||||
assert.match(wordmark, /<text\b[^>]*>CHRNX<\/text>/);
|
||||
assert.match(wordmark, /Zen Maru Gothic/);
|
||||
});
|
||||
Reference in new issue
Block a user