card #149: update ventures/box-art-night/test.js
time/worker-run cd ventures/box-art-night && node test.js && node --check app.js && python3 -c "import html.parser;

This commit is contained in:
time committed 2026-10-18 17:59:45 +00:00
1 parent f4b109f78a
commit 7361b70b05
1 file changed
+12
+12
View File
@@ -0,0 +1,12 @@
// Self-check for the pure helpers: node ventures/box-art-night/test.js
const assert = require('assert');
const { hash, parseStats, wrap } = require('./app.js');
assert.strictEqual(hash('a'), hash('a'));
assert.notStrictEqual(hash('a'), hash('b'));
assert.deepStrictEqual(parseStats('Players: 1\n\n Price : Free: yes \nNo colon\nx: y\nz: w', 4),
[['Players', '1'], ['Price', 'Free: yes'], ['', 'No colon'], ['x', 'y']]);
const m = s => s.length * 10;
assert.deepStrictEqual(wrap(m, 'aa bb cc dd', 50, 5), ['aa bb', 'cc dd']);
assert.deepStrictEqual(wrap(m, 'aa bb cc dd', 50, 1), ['aa b…'.length * 10 <= 50 ? 'aa b…' : 'aa…']);
assert.deepStrictEqual(wrap(m, '', 50, 2), []);
console.log('ok');