Versie 0.2.0
This commit is contained in:
commit
e77d8fd373
495 files changed
+81026
No files matched your search
@@ -0,0 +1,36 @@
|
||||
// Generated, do not edit. sha256:5a77c077506d2707d2736f39b88eecc950595e5f584434a26aa51da671343df6
|
||||
import { describe, it, mock } from 'node:test';
|
||||
import assert from 'node:assert/strict';
|
||||
|
||||
const INSTELLING = { asset_show_name: 1, asset_show_symbol: 0 };
|
||||
mock.module('../../client/app-settings.js', { namedExports: { appSetting: k => INSTELLING[k], baseCurrency: () => 'EUR' } });
|
||||
const { byKindAndLabel } = await import('../../client/ui/asset-label.js');
|
||||
|
||||
const a = (symbol, name, kind) => ({ symbol, name, kind });
|
||||
const XRP = a('XRP', 'Ripple', 'crypto');
|
||||
const BTC = a('BTC', 'Bitcoin', 'crypto');
|
||||
const ETH = a('ETH', 'Ether', 'crypto');
|
||||
const XAU = a('XAU', 'Goud', 'metal');
|
||||
const USD = a('USD', 'Amerikaanse dollar', 'fiat');
|
||||
|
||||
describe('byKindAndLabel', () => {
|
||||
it('zet alle crypto bij elkaar vóór de metalen, ook een asset dat later is aangemaakt', () => {
|
||||
const volgorde = [XAU, BTC, XRP, USD, ETH].sort(byKindAndLabel).map(x => x.symbol);
|
||||
assert.deepEqual(volgorde, ['BTC', 'ETH', 'XRP', 'XAU', 'USD']);
|
||||
});
|
||||
|
||||
it('sorteert op het label dat je ziet: de naam, of het symbool als dat is ingesteld', () => {
|
||||
INSTELLING.asset_show_name = 1; INSTELLING.asset_show_symbol = 0;
|
||||
assert.deepEqual([XRP, ETH].sort(byKindAndLabel).map(x => x.symbol), ['ETH', 'XRP'], 'Ether vóór Ripple');
|
||||
const zelfdeNaam = [a('ZZZ', 'Alfa', 'crypto'), a('AAA', 'Zulu', 'crypto')];
|
||||
INSTELLING.asset_show_name = 0; INSTELLING.asset_show_symbol = 1;
|
||||
assert.deepEqual([...zelfdeNaam].sort(byKindAndLabel).map(x => x.symbol), ['AAA', 'ZZZ'], 'op symbool');
|
||||
INSTELLING.asset_show_name = 1;
|
||||
assert.deepEqual([...zelfdeNaam].sort(byKindAndLabel).map(x => x.symbol), ['ZZZ', 'AAA'], 'op naam');
|
||||
INSTELLING.asset_show_symbol = 0;
|
||||
});
|
||||
|
||||
it('zet een onbekende soort achteraan', () => {
|
||||
assert.deepEqual([a('Q', 'Q', 'onbekend'), BTC].sort(byKindAndLabel).map(x => x.symbol), ['BTC', 'Q']);
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user