Versie 0.2.0
This commit is contained in:
commit
e77d8fd373
495 files changed
+81026
No files matched your search
@@ -0,0 +1,45 @@
|
||||
// Generated, do not edit. sha256:841593fe1e857633d46e2fe3ce5552c3a7874ece2d6acdbc7160656fde1ef2c6
|
||||
import { describe, it, beforeEach, mock } from 'node:test';
|
||||
import assert from 'node:assert/strict';
|
||||
|
||||
import { createDbHarness } from '../helpers/db-node.mjs';
|
||||
|
||||
const harness = createDbHarness();
|
||||
mock.module('../../server/db.js', { namedExports: harness.exports });
|
||||
|
||||
const { listAssets, listBookableAssets } = await import('../../server/data/assets.js');
|
||||
const { run, lastId } = harness.exports;
|
||||
|
||||
function asset(symbol, kind) {
|
||||
run(`INSERT INTO Asset (symbol, name, searchName, kind, unit, subunit, decimals, displayUnit)
|
||||
VALUES (?,?,?,?,?,'cent',2,'unit')`, [symbol, symbol, symbol.toLowerCase(), kind, symbol]);
|
||||
return lastId();
|
||||
}
|
||||
const symbolen = rijen => rijen.map(a => a.symbol);
|
||||
|
||||
let usd;
|
||||
beforeEach(() => {
|
||||
harness.recreate();
|
||||
asset('BTC', 'crypto');
|
||||
asset('EUR', 'fiat');
|
||||
usd = asset('USD', 'fiat');
|
||||
});
|
||||
|
||||
describe('listBookableAssets', () => {
|
||||
it('laat een ongebruikte vreemde munt weg, en de euro en bitcoin niet', () => {
|
||||
assert.deepEqual(symbolen(listBookableAssets()), ['BTC', 'EUR']);
|
||||
assert.deepEqual(symbolen(listAssets()), ['BTC', 'EUR', 'USD'], 'listAssets blijft alles geven');
|
||||
});
|
||||
|
||||
it('toont de munt zodra er een boeking in staat', () => {
|
||||
run(`INSERT INTO Event (assetId, amount, type, source, occurredAt, createdAt)
|
||||
VALUES (?, 100, 'transfer', 'manual', '2026-09-01T10:00:00Z', '2026-09-01T10:00:00Z')`, [usd]);
|
||||
assert.deepEqual(symbolen(listBookableAssets()), ['BTC', 'EUR', 'USD']);
|
||||
});
|
||||
|
||||
it('toont de munt zodra er een balans in staat', () => {
|
||||
run(`INSERT INTO Valuation (assetId, balance, fiatRate, source, valuedOn, rateAt)
|
||||
VALUES (?, 100, 0.9, 'manual', '2026-09-01', '2026-09-01T00:00:00Z')`, [usd]);
|
||||
assert.deepEqual(symbolen(listBookableAssets()), ['BTC', 'EUR', 'USD']);
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user