web/website/tests/upgrade-policy.test.mjs
unimatrixgit 77cdf19faa Checkpoint Alpha 1.0.0.3 graphical menus and moderation evidence
Preserve the current Alpha source and artwork snapshot. See handoff/alpha-1.0.0.3 for actual deployed hashes, checks, staged follow-ups and the production pause. This checkpoint does not claim every source feature is deployed.
2026-11-02 00:05:34 +01:00

5 lines
1.4 KiB
JavaScript

import test from 'node:test';import assert from 'node:assert/strict';import {rollUpgrade,validUpgrade,LEGENDARY} from '../control-panel/upgrade-policy.mjs';
test('a roll can split two Thorns points and one Protection point',()=>{const values=[3,3,3,0];const r=rollUpgrade(()=>values.shift());assert.deepEqual(r.bonuses,[{piece:'helmet',enchantment:'thorns',levels:2},{piece:'helmet',enchantment:'protection',levels:1}]);assert.ok(validUpgrade(r));});
test('all piece/enchantment slots are reachable, including single-level enchantments',()=>{let slot=0;for(const[piece,enchants]of Object.entries(LEGENDARY))for(const enchantment of Object.keys(enchants)){let call=0;const r=rollUpgrade(()=>call++===0?1:slot);assert.deepEqual(r.bonuses,[{piece,enchantment,levels:1}]);assert.ok(validUpgrade(r));slot++;}});
test('each new roll has its own bounded budget, not the previous bonus',()=>{for(let n=1;n<=3;n++){const r=rollUpgrade((min,max)=>min===1?n:0);assert.equal(r.points,n);assert.equal(r.bonuses[0].levels,n);assert.ok(validUpgrade(r));}assert.equal(LEGENDARY.helmet.protection,4);});
test('invalid or duplicate distributions are rejected',()=>{assert.equal(validUpgrade({policy:'legendary-player-v1',points:3,bonuses:[{piece:'boots',enchantment:'swift_sneak',levels:3}]}),false);assert.equal(validUpgrade({policy:'legendary-player-v1',points:2,bonuses:[{piece:'helmet',enchantment:'thorns',levels:1},{piece:'helmet',enchantment:'thorns',levels:1}]}),false);});