test(shops): cover non-finite and missing-key guards in describeRequirement

This commit is contained in:
Bastian Wagner
2026-08-22 18:18:44 +02:00
parent 149a9521be
commit 7e1b79315e

View File

@@ -94,6 +94,47 @@ describe('describeRequirement', () => {
), ),
).toBeNull(); ).toBeNull();
}); });
it('renders no line if the condition has a non-numeric value', () => {
// A requirement with no valid threshold is unactionable -- the player
// has no goal to work toward. Better to hide the gate than to render
// a malformed line.
expect(
describeRequirement(
{
condition: {
type: GameConditionType.REGION_REPUTATION,
key: 'border-guard',
operator: ComparisonOperator.GTE,
value: NaN,
},
met: false,
actual: 14,
},
FACTIONS,
),
).toBeNull();
});
it('renders no line for a reputation gate with no faction key', () => {
// A gate that names no faction is malformed. The player cannot act on a
// requirement that never says which faction. Better to show nothing than
// broken content.
expect(
describeRequirement(
{
condition: {
type: GameConditionType.REGION_REPUTATION,
operator: ComparisonOperator.GTE,
value: 25,
} as any,
met: false,
actual: 14,
},
FACTIONS,
),
).toBeNull();
});
}); });
describe('describeItemEffect', () => { describe('describeItemEffect', () => {