Files
houseplan-card/test/space-card-audit-lows.test.mjs
T
2026-09-03 16:50:54 +03:00

26 lines
1.3 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import test from 'node:test';
import assert from 'node:assert/strict';
import { readFileSync } from 'node:fs';
const card = readFileSync(new URL('../src/space-card.ts', import.meta.url), 'utf8');
// #376(а): YAML `title:` with no value parses as null. The owner decided null
// and '' mean the same thing — no header AND the compact frame. The behaviour
// is proven end-to-end by demo/smoke_space_card.mjs (nullTitleFrame); this
// contract keeps the condition from silently narrowing back to '' only.
test('#376(а) the compact frame accepts both the empty string and null title', () => {
assert.match(card,
/compactTopFrame: this\._config\.title === '' \|\| this\._config\.title === null,/);
});
// #376(е): the render gate is strict `=== true`; the dispose gate must be its
// exact mirror, so a truthy-but-not-true value (light_pools: 1) neither draws
// pools nor keeps a glow runtime and a blend probe alive.
test('#376(е) light_pools gates are symmetric: anything but true disposes', () => {
assert.match(card, /lightPools: this\._config\.light_pools === true,/);
assert.match(card,
/if \(this\._config\.light_pools !== true\) \{\s*\n\s*disposeGlowRuntime\(/);
assert.ok(!/if \(!this\._config\.light_pools\) \{\s*\n\s*disposeGlowRuntime\(/.test(card),
'the old truthy dispose gate must not return');
});