Files
Dune/tests/truthtrance-freeform-v8-controls.test.tsx
T
Quintine 4ec4f843a7
Verify and publish checkpoint container / container (push) Canceled after 0s
Honor Caladan auction knowledge in Truthtrance
2026-10-29 19:03:34 +11:00

45 lines
2.1 KiB
TypeScript

import assert from 'node:assert/strict';
import test from 'node:test';
import { createElement } from 'react';
import { renderToStaticMarkup } from 'react-dom/server';
import { FreeformFactPreview } from '../components/truthtrance';
const props = {
target: 'target', leaderName: (id: string) => id,
locationName: (id: string) => id, playerName: (id: string) => id,
};
const preview = (text: string, scope: 'fact' | 'currentTurn' = 'fact') =>
renderToStaticMarkup(createElement(FreeformFactPreview, { ...props, scope, text }));
void test('the editor previews No-Field and auction knowledge without revealing an answer', () => {
const noField = preview('Do you have a concealed No-Field with printed value 3?');
assert.match(noField, /Recognized freeform question/);
assert.match(noField, /you currently have a concealed No-Field with printed value 3/);
const auction = preview('Is the current auction card you inspected a Shield?');
assert.match(auction, /Recognized freeform question/);
assert.match(auction, /the current auction card you inspected is Shield/);
assert.doesNotMatch(auction, /Your current game information establishes/);
});
void test('the editor previews a mixed auction and force aggregate', () => {
const text = 'Is the current auction card you inspected a Shield and do you have at least 3 forces in your reserves?';
const html = preview(text);
assert.match(html, /Recognized freeform question/);
assert.match(html, /the current auction card you inspected is Shield/);
assert.match(html, /AND/);
assert.match(html, /currently have at least 3 physical forces in your reserves/);
assert.doesNotMatch(html, /Your current game information establishes/);
assert.match(preview(text, 'currentTurn'), /not automatically interpreted/);
});
void test('the editor leaves invalid or predictive inspection questions player-managed', () => {
for (const text of [
'Do you have a concealed No-Field with printed value 2?',
'Will the next auction card be a Shield?',
]) {
const html = preview(text);
assert.match(html, /not automatically interpreted/);
assert.doesNotMatch(html, /Recognized freeform question/);
}
});