forked from unimatrix/web
Fresh production baseline [skip ci]
This commit is contained in:
commit
0a11a18274
1 changed files with 229644 additions and 0 deletions
18
website/tests/code-redemption.test.mjs
Normal file
18
website/tests/code-redemption.test.mjs
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
import test from 'node:test';
|
||||
import assert from 'node:assert/strict';
|
||||
import {describeRedemption} from '../control-panel/public/cp-v2/cp-v2-code-redemption.mjs';
|
||||
|
||||
test('existing deliverable codes describe their real route',()=>{
|
||||
assert.equal(describeRedemption(' drk-'+ 'a'.repeat(32)+' ').kind,'kit');
|
||||
assert.equal(describeRedemption('DRQ-'+ 'A'.repeat(40)).available,true);
|
||||
assert.equal(describeRedemption('DRU-'+ 'A'.repeat(48)).href,'#realm/kits-exchange');
|
||||
});
|
||||
test('clan upgrades are available while company and political decisions retain their own routes',()=>{
|
||||
assert.equal(describeRedemption('CLAN-'+ 'A'.repeat(48)).available,true);
|
||||
for(const prefix of ['COM','POL'])assert.equal(describeRedemption(prefix+'-'+ 'A'.repeat(48)).available,false);
|
||||
assert.match(describeRedemption('CLAN-'+ 'A'.repeat(48)).description,/separate political appointment/);
|
||||
assert.match(describeRedemption('POL-'+ 'A'.repeat(48)).description,/recorded by a political decision/);
|
||||
});
|
||||
test('partial, malformed and unsupported codes cannot advance to confirmation',()=>{
|
||||
for(const code of ['', 'CLAN-123', 'DRK-'+ '0'.repeat(32), '/communitycode test','<script>','POL-'+ 'A'.repeat(47)])assert.throws(()=>describeRedemption(code));
|
||||
});
|
||||
Loading…
Reference in a new issue

Staff