Versie 0.2.0
This commit is contained in:
commit
e77d8fd373
495 files changed
+81026
No files matched your search
@@ -0,0 +1,62 @@
|
||||
// Generated, do not edit. sha256:e9def29bc2006594fdeb8199e56fcff107612198b70d50be3a6d86402660dd84
|
||||
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 });
|
||||
for (const mod of ['providers', 'price-source']) {
|
||||
mock.module(`../../client/data/${mod}.js`, { namedExports: await import(`../../server/data/${mod}.js`) });
|
||||
}
|
||||
const leeg = async () => [];
|
||||
mock.module('../../client/data/notifications.js', { namedExports: { currentNotifications: leeg } });
|
||||
mock.module('../../client/data/ai-audit.js', { namedExports: { countAiToolCallsSince: async () => 0 } });
|
||||
mock.module('../../client/data/preferences.js', { namedExports: { getPref: async () => null } });
|
||||
mock.module('../../client/data/price-history.js', { namedExports: { listPriceGaps: async () => ({ rows: [], total: 0 }) } });
|
||||
mock.module('../../client/data/api-metrics.js', { namedExports: { apiCallsByProvider: leeg } });
|
||||
mock.module('../../client/license.js', { namedExports: { licenseChangedSinceSeen: async () => false } });
|
||||
mock.module('../../client/app-settings.js', { namedExports: { appSetting: () => null, baseCurrency: () => 'EUR' } });
|
||||
mock.module('../../client/price/providers.js', { namedExports: { rateSourceFor: async () => null } });
|
||||
|
||||
const producers = [];
|
||||
mock.module('../../client/ui/attention.js', { namedExports: { registerAttention: p => producers.push(p) } });
|
||||
|
||||
const { registerAttentionSources } = await import('../../client/ui/attention-sources.js');
|
||||
registerAttentionSources();
|
||||
const zonderKoers = producers.find(p => p.name === 'sourcesWithoutRate');
|
||||
|
||||
const { run, lastId } = harness.exports;
|
||||
let bron;
|
||||
|
||||
beforeEach(() => {
|
||||
harness.recreate();
|
||||
run(`INSERT INTO Asset (symbol, name, searchName, kind, unit, subunit, decimals, displayUnit)
|
||||
VALUES ('XAU','Goud','goud','metal','XAU','cent',2,'unit')`);
|
||||
const goud = lastId();
|
||||
run(`INSERT INTO Provider (key, name, searchName, baseUrl, authenticationKind, authenticationRequired,
|
||||
isActive, isSeed, isSystem, createdAt)
|
||||
VALUES ('dollar','Dollarbron','dollarbron','https://voorbeeld.test','none',0,1,1,0,'2026-10-16T10:00:00.000Z')`);
|
||||
bron = lastId();
|
||||
run(`INSERT INTO ProviderCoverage (providerId, symbol) VALUES (?, 'XAU')`, [bron]);
|
||||
run(`INSERT INTO ProviderEndpoint (providerId, capability, method, pathTemplate, quoteCurrency)
|
||||
VALUES (?, 'spot', 'GET', '/p', 'USD')`, [bron]);
|
||||
run(`INSERT INTO PriceSource (assetId, capability, providerId, rank, status) VALUES (?, 'spot', ?, 1, 'confirmed')`, [goud, bron]);
|
||||
});
|
||||
|
||||
describe('aandacht: een bronkeuze in een munt zonder wisselkoers', () => {
|
||||
it('meldt een actieve, gekozen bron als probleem', async () => {
|
||||
const uit = await zonderKoers();
|
||||
assert.deepEqual(uit.map(a => [a.id, a.severity]), [['fx:dollar:USD', 'problem']]);
|
||||
});
|
||||
|
||||
it('meldt niets voor een bron die uit staat', async () => {
|
||||
run(`UPDATE Provider SET isActive = 0 WHERE id = ?`, [bron]);
|
||||
assert.deepEqual(await zonderKoers(), []);
|
||||
});
|
||||
|
||||
it('meldt niets voor een gewiste keuze', async () => {
|
||||
run(`UPDATE PriceSource SET rank = NULL`);
|
||||
assert.deepEqual(await zonderKoers(), []);
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user