web/website/tests/claim-tariffs.test.mjs
2026-11-27 23:43:05 +00:00

15 lines
2.1 KiB
JavaScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import test from 'node:test';import assert from 'node:assert/strict';
import {claimTariffs} from '../control-panel/public/cp-v2/cp-v2-claim-tariffs.mjs';
import {bankRatesPage} from '../scripts/bank-rates-page.mjs';
test('agreed clan schedule, tier transitions and sequential unlock formula',()=>{
const rows=claimTariffs();assert.deepEqual(rows.map(r=>r.chunks),[1,2,3,4,4,6,9,12,16,16,20,25,36]);
assert.deepEqual(rows.map(r=>r.upkeepMinor),[0,200,400,600,500,800,1200,1600,2200,1800,2400,3000,4400]);
assert.deepEqual(rows.map(r=>r.unlockMinor),[0,4000,6000,8000,5000,12000,18000,22000,30000,18000,32000,40000,66000]);
assert.equal(rows.at(-1).chunks*16*16,96*96);assert.equal(rows[4].requirement,'CLAN-key');assert.match(rows[9].requirement,/POL-key/);
});
test('organisation scaling floors whole chunks and scales both costs without stacking or floating money',()=>{
const clans=claimTariffs();for(const [kind,multiplier,prefix]of [['company',1.5,'BCO'],['protected',0.5,'PBC']]){const rows=claimTariffs(kind);assert.match(rows[0].code,new RegExp('^'+prefix));rows.forEach((row,i)=>{assert.equal(row.chunks,Math.floor(clans[i].chunks*1.5));assert.equal(row.upkeepMinor,clans[i].upkeepMinor*multiplier);assert.equal(row.unlockMinor,clans[i].unlockMinor*multiplier);assert(Number.isSafeInteger(row.upkeepMinor)&&Number.isSafeInteger(row.unlockMinor));});assert.equal(rows.at(-1).chunks,54);}assert.equal(claimTariffs('company')[4].requirement,'COM-key');assert.throws(()=>claimTariffs('administrator'));assert.equal(claimTariffs()[0].chunks,1);
});
test('public guide includes all 39 rows as a planned schedule and preserves banking tables',()=>{
const html=bankRatesPage();for(const kind of ['clan','company','protected'])for(const row of claimTariffs(kind))assert(html.includes(row.code));assert.match(html,/id="claims"/);assert.match(html,/Published schedule · claims system coming soon/);assert.match(html,/16 × 16 blocks/);assert.match(html,/does not reserve land/);assert.match(html,/id="packages"/);assert.match(html,/id="credit"/);assert.match(html,/complete downloadable handbook includes this capacity and fee schedule/);
});