28 lines
1.4 KiB
JavaScript
28 lines
1.4 KiB
JavaScript
// The course stylesheets in styles/course/ are copies of the course site's files.
|
|
// Each must still have the hash its README records, so a change is made upstream and copied, not edited here.
|
|
import test from 'node:test';
|
|
import assert from 'node:assert/strict';
|
|
import fs from 'node:fs';
|
|
import crypto from 'node:crypto';
|
|
|
|
const DIR = new URL('../styles/course/', import.meta.url);
|
|
|
|
test('the course stylesheets are the course site\'s files, unchanged', () => {
|
|
const readme = fs.readFileSync(new URL('README.md', DIR), 'utf8');
|
|
const rows = [...readme.matchAll(/^\| `([\w-]+\.css)` \| `static\/css\/[^`]+` \|[^|]*\| `([0-9a-f]{64})` \|$/gm)];
|
|
assert.deepEqual(rows.map((r) => r[1]).sort(), ['asm86.css', 'kit.css', 'tokens.css']);
|
|
for (const [, file, want] of rows) {
|
|
const got = crypto.createHash('sha256').update(fs.readFileSync(new URL(file, DIR))).digest('hex');
|
|
assert.equal(got, want, `styles/course/${file} differs from the copy the README records`);
|
|
}
|
|
});
|
|
|
|
test('the bridge supplies every page variable the course stylesheets read', () => {
|
|
const bridge = fs.readFileSync(new URL('bridge.css', DIR), 'utf8');
|
|
const read = new Set();
|
|
for (const f of ['tokens.css', 'kit.css', 'asm86.css']) {
|
|
for (const m of fs.readFileSync(new URL(f, DIR), 'utf8').matchAll(/var\((--bs-[\w-]+)/g)) read.add(m[1]);
|
|
}
|
|
for (const v of read) assert.match(bridge, new RegExp(`${v}\\s*:`), `bridge.css does not set ${v}`);
|
|
});
|