Files
gods-eye-view/src/ui/views/mountApplicationViews.test.mjs
T
Sameh Khamis ac04812db2 A row plays only with a timeline to play; the speed shown follows the world clock; mark labels merge whole and cut by character
A weather row's play started the world clock even with no time to show,
where there is no timeline; it now does nothing then, as the timeline's
own Play cannot be reached. A weather layer made without a weather clock
does nothing once destroyed, so enabling it after builds no clock.

The timeline's speed follows the world clock's rate whoever set it, and
its Play runs at that rate, so it and a row's play never run at different
rates; a rate not offered shows as the nearest offered speed. Choosing a
speed sets the clock's rate first, also while a driver steps.

Marks merge on their whole label and are cut for showing after, so two
whose labels only differ past the cut stay two, and the cut counts
graphemes (code points where the runtime cannot tell them), so an emoji is
never split.

Tests that compared a DOM element with null built an assertion message
from the element when they failed, which hung the run; they compare plain
values now, so they fail at once. The timeline tests put the clock back to
real time after each.
2026-11-14 21:12:43 -08:00

78 lines
2.5 KiB
JavaScript

// src/ui/views/mountApplicationViews.test.mjs — a page's view hosts render
// their views, and an application can leave views out, over happy-dom.
import '../../testSupport/registerDom.mjs';
import test from 'node:test';
import assert from 'node:assert/strict';
import { createApplication } from '../../app/application.js';
import { mountApplicationViews } from './index.js';
function page(names) {
document.body.replaceChildren();
for (const name of names) {
const host = document.createElement('div');
host.className = 'gev-view';
host.setAttribute('data-gev-view', name);
document.body.append(host);
}
}
const hostNames = () =>
[...document.querySelectorAll('[data-gev-view]')].map((host) =>
host.getAttribute('data-gev-view'),
);
test('omitted views lose their hosts and the rest render', () => {
page(['welcome', 'provider-settings']);
mountApplicationViews(document, { omit: ['provider-settings'] });
assert.deepEqual(hostNames(), ['welcome']);
assert.equal(document.getElementById('key-setup-chip') === null, true);
assert.ok(
document.querySelector('[data-gev-view="welcome"]').children.length,
);
});
test('a view an earlier call rendered is unmounted when a later call omits it', () => {
page(['welcome', 'provider-settings']);
mountApplicationViews(document);
assert.ok(document.getElementById('key-setup-chip'));
mountApplicationViews(document, { omit: ['provider-settings'] });
assert.deepEqual(hostNames(), ['welcome']);
assert.equal(document.getElementById('key-setup-chip') === null, true);
});
test('unknown view names are refused, in the page or in the omit list', () => {
page([]);
for (const name of ['toString', 'constructor'])
assert.throws(
() => mountApplicationViews(document, { omit: [name] }),
/Unknown application view/,
);
page(['toString']);
assert.throws(
() => mountApplicationViews(document),
/Unknown application view/,
);
assert.throws(
() => mountApplicationViews(document, { omit: ['nope'] }),
/Unknown application view: nope/,
);
page(['nope']);
assert.throws(
() => mountApplicationViews(document),
/Unknown application view: nope/,
);
});
test('createApplication leaves out the views its omitViews names', () => {
page(['welcome', 'provider-settings']);
const noop = () => ({});
createApplication({
createScene: noop,
createControls: noop,
createData: noop,
createTools: noop,
omitViews: ['provider-settings'],
});
assert.deepEqual(hostNames(), ['welcome']);
});