import test from 'node:test';
import assert from 'node:assert/strict';
import { readFileSync } from 'node:fs';

const indexHtml = readFileSync(new URL('../index.html', import.meta.url), 'utf8');
const viewerHtml = readFileSync(new URL('../viewer.html', import.meta.url), 'utf8');
const repositoryCardsCss = readFileSync(new URL('../css/repository/cards.css', import.meta.url), 'utf8');

test('Tapops index uses module scripts and no inline behavior', () => {
    assert.match(indexHtml, /<script type="module" src="js\/app\.js"><\/script>/);
    assert.doesNotMatch(indexHtml, /<script>\s*\(/);
    assert.doesNotMatch(indexHtml, /\sonclick=/);
});

test('Tapops viewer uses module scripts and no inline behavior', () => {
    assert.match(viewerHtml, /<script type="module" src="js\/viewer\/viewer-app\.js"><\/script>/);
    assert.doesNotMatch(viewerHtml, /<script>\s*\(/);
});

test('Tapops document tags keep the API-provided casing', () => {
    assert.doesNotMatch(repositoryCardsCss, /\.doc-tag\s*\{[^}]*text-transform:\s*lowercase/is);
});
