forked from unimatrix/web
7 lines
1.5 KiB
JavaScript
7 lines
1.5 KiB
JavaScript
import test from 'node:test';import assert from 'node:assert/strict';
|
|
import {isVerifiedMarketPayload,marketChartPoints,CORRINO_MARKET_FEED} from '../web/corrino-group.js';
|
|
import {readFileSync,existsSync} from 'node:fs';
|
|
const valid={verified:true,symbol:'CRG',history:[{timestamp:1,price:100},{timestamp:2,price:110},{timestamp:3,price:95}]};
|
|
test('stock chart accepts only verified ordered finite price history',()=>{assert.equal(isVerifiedMarketPayload(valid),true);for(const invalid of [{...valid,verified:false},{...valid,symbol:'<script>'},{...valid,history:[valid.history[1],valid.history[0]]},{...valid,history:[{timestamp:1,price:-5},{timestamp:2,price:1}]},{...valid,history:[]}])assert.equal(isVerifiedMarketPayload(invalid),false);});
|
|
test('chart points derive from source prices without invented values',()=>{assert.equal(marketChartPoints(valid.history,100,100),'0.0,66.7 50.0,0.0 100.0,100.0');assert.equal(marketChartPoints([]),'');assert.equal(CORRINO_MARKET_FEED,'/api/companies/market');});
|
|
test('Corrino page uses original existing artwork and retains unavailable-market fallback',()=>{const html=readFileSync(new URL('../web/corrino-group.html',import.meta.url),'utf8');for(const name of ['corrino-founder-v1.png','corrino-group-v4.png','corrino-charter-v2.png']){assert.ok(html.includes('/assets/'+name));assert.ok(existsSync(new URL('../web/assets/'+name,import.meta.url)));}assert.match(html,/No verified trading history/);assert.match(html,/Appointment not verified/);});
|

Staff