Files
ihaleist/tests/exchange-rates.test.mjs
T

10 lines
700 B
JavaScript

import {test} from 'node:test';
import assert from 'node:assert/strict';
import {parseRates} from '../server/exchange-rates.mjs';
test('rates carry bulletin date and use unit-adjusted selling price',()=>{
const xml='<Tarih_Date Tarih="04.09.2026"><Currency CurrencyCode="USD"><Unit>1</Unit><ForexSelling>48.3195</ForexSelling></Currency><Currency CurrencyCode="EUR"><Unit>100</Unit><ForexSelling>5500</ForexSelling></Currency></Tarih_Date>';
const d=parseRates(xml);assert.equal(d.rates.USD,48.3195);assert.equal(d.rates.EUR,55);assert.equal(d.bulletinDate,'04.09.2026');
assert.throws(()=>parseRates('<html>error</html>'));
assert.throws(()=>parseRates(xml.replace('<Unit>100','<Unit>0')));
});