Compose freeform Truthtrance facts
Verify and publish checkpoint container / container (push) Successful in 11m2s
Verify and publish checkpoint container / container (push) Successful in 11m2s
This commit is contained in:
1 parent
cc9cc0945d
commit
593ff33ca8
10 files changed
+306
-4
No files matched your search
@@ -0,0 +1,39 @@
|
||||
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 a compound prediction and physical-force question', () => {
|
||||
const html = preview('Did you predict Guild and do you have at least 3 forces in your reserves?');
|
||||
assert.match(html, /Recognized freeform question/);
|
||||
assert.match(html, /your recorded Bene Gesserit prediction names Spacing Guild/);
|
||||
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/);
|
||||
});
|
||||
|
||||
void test('the editor previews a three-clause aggregate without exposing answers', () => {
|
||||
const text = 'Did you predict Guild and is your predicted turn at least 5 and do you have at least 3 forces in your reserves?';
|
||||
const html = preview(text);
|
||||
assert.match(html, /Recognized freeform question/);
|
||||
assert.match(html, /your recorded Bene Gesserit prediction names Spacing Guild/);
|
||||
assert.match(html, /the turn in your recorded Bene Gesserit prediction is at least 5/);
|
||||
assert.match(html, /currently have at least 3 physical forces in your reserves/);
|
||||
assert.equal((html.match(/AND/g) ?? []).length, 2);
|
||||
assert.doesNotMatch(html, /Your current game information establishes/);
|
||||
assert.match(preview(text, 'currentTurn'), /not automatically interpreted/);
|
||||
});
|
||||
|
||||
void test('ambiguous mixed operators remain player-managed', () => {
|
||||
const html = preview('Did you predict Guild and is your predicted turn at least 5 or do you have at least 3 forces in your reserves?');
|
||||
assert.match(html, /not automatically interpreted/);
|
||||
assert.doesNotMatch(html, /Recognized freeform question/);
|
||||
});
|
||||
Reference in new issue
Block a user