30 lines
2.0 KiB
TypeScript
30 lines
2.0 KiB
TypeScript
import assert from 'node:assert/strict';
|
|
import test from 'node:test';
|
|
import { compileMixedActionExpression } from '../game/mixed-action-question';
|
|
import { mixedRicheseBidResidual, type MixedRicheseBidClaim } from '../game/mixed-richese-bid-question';
|
|
import { truthQuestionText, validateTruthQuestionReceipt, type TruthQuestion } from '../game/truthtrance';
|
|
import { createTruthRicheseBidFixture } from './fixture-truth-richese-bid';
|
|
|
|
const mixed: MixedRicheseBidClaim['mixed'] = {kind:'and',terms:[
|
|
{kind:'fact',fact:{kind:'spice',compare:'gte',value:10}},
|
|
{kind:'or',terms:[{kind:'action',action:{minimum:4}},{kind:'action',action:{minimum:7}}]},
|
|
]};
|
|
|
|
void test('Richese mixed bid reduction preserves the actual turn, public event and native threshold', () => {
|
|
const claim: MixedRicheseBidClaim = {turn:3,event:'original-public-lot',mixed};
|
|
const result = compileMixedActionExpression(mixed,() => 'yes',true);
|
|
assert.deepEqual(mixedRicheseBidResidual(claim,result),{turn:3,event:'original-public-lot',minimum:4});
|
|
assert.throws(() => mixedRicheseBidResidual({...claim,event:' stale '},result));
|
|
assert.throws(() => mixedRicheseBidResidual(claim,compileMixedActionExpression(mixed,() => 'no',false)));
|
|
});
|
|
|
|
void test('a Richese mixed bid question binds a current Once Around event without accepting old or extra metadata', () => {
|
|
const f = createTruthRicheseBidFixture(false);
|
|
const question: TruthQuestion = {kind:'mixedRicheseBid',target:f.target,turn:f.game.turn,event:f.lot,mixed};
|
|
assert.doesNotThrow(() => validateTruthQuestionReceipt(f.game,f.asker,question));
|
|
assert.match(truthQuestionText(question,id => id,id => id,id => id),/Richese auction/);
|
|
assert.throws(() => validateTruthQuestionReceipt(f.game,f.asker,{...question,event:'stale-lot'}));
|
|
assert.throws(() => validateTruthQuestionReceipt(f.game,f.asker,{...question,turn:f.game.turn+1}));
|
|
assert.throws(() => validateTruthQuestionReceipt(f.game,f.asker,{...question,lot:1} as TruthQuestion));
|
|
});
|