Versie 0.2.0
This commit is contained in:
commit
e77d8fd373
495 files changed
+81026
No files matched your search
@@ -0,0 +1,68 @@
|
||||
// Generated, do not edit. sha256:f81905187f7271d470129be5251b18f9ab41f86bd73038bb85cd73f795065c11
|
||||
import { describe, it, mock } from 'node:test';
|
||||
import assert from 'node:assert/strict';
|
||||
|
||||
let MELDINGEN = [];
|
||||
let DETAIL = null;
|
||||
mock.module('../../client/data/notifications.js', {
|
||||
namedExports: {
|
||||
currentNotifications: async () => MELDINGEN,
|
||||
notificationDetail: async () => DETAIL,
|
||||
dismissNotification: async () => {},
|
||||
},
|
||||
});
|
||||
|
||||
const { renderNotifications } = await import('../../client/actions/notifications-widget.js');
|
||||
const { NOTIFICATION_PRIORITY } = await import('../../shared/config.js');
|
||||
|
||||
const melding = (kind, id) => ({ id, kind, count: 2, highWater: 1, createdAt: '2026-10-20T10:00:00.000Z' });
|
||||
|
||||
async function teken(rijen, detail = null) {
|
||||
MELDINGEN = rijen;
|
||||
DETAIL = detail;
|
||||
const host = { innerHTML: '', querySelectorAll() { return []; } };
|
||||
await renderNotifications(host, () => {});
|
||||
return host.innerHTML;
|
||||
}
|
||||
|
||||
const volgorde = html => [...html.matchAll(/data-kind="([a-z_]+)"/g)].map(m => m[1]);
|
||||
|
||||
describe('meldingenwidget: volgorde van belangrijkheid', () => {
|
||||
it('zet de rijen in de rangorde, ook als de server ze andersom levert', async () => {
|
||||
const omgekeerd = [...NOTIFICATION_PRIORITY].reverse().map((kind, i) => melding(kind, i + 1));
|
||||
assert.deepEqual(volgorde(await teken(omgekeerd)), [...NOTIFICATION_PRIORITY]);
|
||||
});
|
||||
|
||||
it('zet de belangrijkste bovenaan bij een greep uit de soorten', async () => {
|
||||
const rijen = [melding('schedule_ended', 9), melding('interest', 5), melding('valuation', 2)];
|
||||
assert.deepEqual(volgorde(await teken(rijen)), ['valuation', 'interest', 'schedule_ended']);
|
||||
});
|
||||
});
|
||||
|
||||
describe('meldingenwidget: dezelfde informatie per rij', () => {
|
||||
it('toont aantal, soort, hint, datum en de verbergknop', async () => {
|
||||
const html = await teken([melding('interest', 7)]);
|
||||
assert.match(html, /Rente te boeken/);
|
||||
assert.match(html, /Bijschrijvingen klaar om te boeken/);
|
||||
assert.match(html, /class="notify-date">20-10-2026</);
|
||||
});
|
||||
|
||||
it('zet het aantal in de verbergknop, met het id van de melding', async () => {
|
||||
const html = await teken([melding('interest', 7)]);
|
||||
assert.match(html, /<button[^>]*class="notify-count"[^>]*data-dismiss="7"[^>]*><span class="notify-n">2<\/span>/);
|
||||
assert.equal((html.match(/data-dismiss=/g) || []).length, 1, 'één verbergknop per rij');
|
||||
});
|
||||
|
||||
it('escapet het detail van een afgelopen afspraak, want daar staan namen van de gebruiker in', async () => {
|
||||
const html = await teken([melding('schedule_ended', 1)], { account: '<b>Bank</b>', asset: 'BTC', extra: 1 });
|
||||
assert.ok(!html.includes('<b>Bank</b>'), 'de accountnaam mag niet als markup in de rij staan');
|
||||
assert.match(html, /<b>Bank<\/b> · BTC \+1/);
|
||||
assert.match(html, /notify-row is-info/);
|
||||
});
|
||||
|
||||
it('toont zonder meldingen de lege stand en geen lijst', async () => {
|
||||
const html = await teken([]);
|
||||
assert.ok(!html.includes('notify-list'));
|
||||
assert.match(html, /task-card-empty/);
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user