~ knotless Search/
↑↓ move↵ open⇧↵ all results

chadtmiller.com/hud

A remote MCP server that shows atproto records as interactive UI inside MCP Apps hosts

0
0
27 lines · 1.2 KB Raw History
// `npm run unit` in web/ (`just check` runs it).
import { strict as assert } from 'node:assert';
import { test } from 'node:test';
import { unknownDrawn } from './tree/unknown.ts';

const text = (words: string) => ({ c: 'Text', p: { runs: [{ text: words }], style: 'body' } });

test('in development, an unknown component draws the box saying it is not drawn yet, whatever it holds', () => {
	assert.equal(unknownDrawn({ c: 'Gauge' }, true), 'notYet');
	assert.equal(unknownDrawn({ c: 'Gauge', k: [text('a')], fallback: text('b') }, true), 'notYet');
});

test('else an unknown component with children draws them as a Stack with gap md, before its fallback', () => {
	const k = [text('a'), text('b')];
	assert.deepEqual(unknownDrawn({ c: 'Gauge', p: { value: 3 }, k, fallback: text('c') }, false), { c: 'Stack', p: { gap: 'md' }, k });
});

test('else its fallback, as it is, an unknown one too', () => {
	const fallback = { c: 'Dial', fallback: text('c') };
	assert.equal(unknownDrawn({ c: 'Gauge', k: [], fallback }, false), fallback);
	assert.equal(unknownDrawn(fallback, false), fallback.fallback);
});

test('else nothing', () => {
	assert.equal(unknownDrawn({ c: 'Gauge' }, false), null);
	assert.equal(unknownDrawn({ c: 'Gauge', k: [] }, false), null);
});