33 lines
1.7 KiB
TypeScript
33 lines
1.7 KiB
TypeScript
import assert from 'node:assert/strict';
|
||
import test from 'node:test';
|
||
import { createElement } from 'react';
|
||
import { renderToStaticMarkup } from 'react-dom/server';
|
||
import type { GameView } from '../game/engine';
|
||
import { EmperorAuctionGift } from '../components/emperor-auction-gift';
|
||
|
||
/** Synthetic owner projection: this verifies the rendered distinction, not
|
||
* a claim that a real cache-sale journey has already reached this control. */
|
||
const view = (source?: 'richese') => ({
|
||
players: [{id:'ally', name:'Ally'}],
|
||
emperorAuctionGift: {event:'gift-event', recipient:'ally', maximum:5, ...(source ? {source} : {})},
|
||
}) as unknown as GameView;
|
||
const render = (game: GameView, busy = false) => renderToStaticMarkup(
|
||
createElement(EmperorAuctionGift, {game, busy, act() {}}),
|
||
);
|
||
|
||
void test('Richese sale describes the committed payment and retains gift and Continue controls', () => {
|
||
const html = render(view('richese'));
|
||
assert.match(html, /Share spice with Ally/);
|
||
assert.match(html, /Continue settles the Richese sale with that payment after any gift response/);
|
||
assert.doesNotMatch(html, /Your ally chooses how to pay/);
|
||
assert.match(html, /<button\b(?![^>]*disabled)[^>]*>Share spice<\/button>/);
|
||
assert.match(html, /<button\b(?![^>]*disabled)[^>]*>Continue to payment<\/button>/);
|
||
assert.match(render(view('richese'), true), /<button\b[^>]*disabled=""[^>]*>Continue to payment<\/button>/);
|
||
});
|
||
|
||
void test('ordinary auction keeps its original buyer-payment guidance', () => {
|
||
const html = render(view());
|
||
assert.match(html, /Your ally chooses how to pay after the gift’s Karama response/);
|
||
assert.doesNotMatch(html, /Continue settles the Richese sale/);
|
||
});
|