diff --git a/test/build.test.mjs b/test/build.test.mjs index 6c410cc..b516033 100644 --- a/test/build.test.mjs +++ b/test/build.test.mjs @@ -1,8 +1,8 @@ import test from 'node:test'; import assert from 'node:assert/strict'; -import { cp, mkdtemp, readFile, readdir, rm, writeFile } from 'node:fs/promises'; +import { cp, mkdtemp, readFile, readdir, rm, writeFile, stat } from 'node:fs/promises'; import { tmpdir } from 'node:os'; -import { join } from 'node:path'; +import { join, dirname } from 'node:path'; import { execFile } from 'node:child_process'; import { promisify } from 'node:util'; import { renderDirectory } from '../src/index.mjs'; @@ -44,3 +44,81 @@ test('actual valid build preserves both rendered artifacts', async (t) => { assert.equal(await readFile(join(root, 'dist/index.html'), 'utf8'), renderDirectory(directory)); assert.equal(await readFile(join(root, 'dist', privacy.path, 'index.html'), 'utf8'), renderPrivacyPage(privacy)); }); + +test('static site build validates metadata, syntax, and internal assets', async (t) => { + const { root, privacy, build } = await fixture(t); + await build(); + + const pages = [ + { path: 'dist/index.html', dir: 'dist' }, + { path: join('dist', privacy.path, 'index.html'), dir: join('dist', privacy.path) } + ]; + + for (const page of pages) { + const html = await readFile(join(root, page.path), 'utf8'); + + // Metadata tags + assert.match(html, //); + assert.match(html, //); + assert.match(html, //); + + // Basic HTML syntax + assert.match(html, /^/i); + assert.match(html, //); + assert.match(html, /[\s\S]*<\/head>/i); + assert.match(html, /