import assert from 'node:assert/strict'; import { toISO, monthPrefix, getWeekday, formatDateDE, buildNameMap } from '../js/utils.js'; // toISO: zero-pads month and day assert.equal(toISO(2026, 4, 1), '2026-04-01', 'toISO pads single digits'); assert.equal(toISO(2026, 12, 31), '2026-12-31', 'toISO keeps two-digit parts'); // monthPrefix: YYYY-MM assert.equal(monthPrefix(2026, 5), '2026-05', 'monthPrefix pads month'); // getWeekday: 1=Mon … 7=Sun (2026-04-01 is a Wednesday → 3; 2026-04-05 Sunday → 7) assert.equal(getWeekday('2026-04-01'), 3, 'Wednesday → 3'); assert.equal(getWeekday('2026-04-05'), 7, 'Sunday → 7'); assert.equal(getWeekday('2026-04-06'), 1, 'Monday → 1'); // formatDateDE: ISO → DD.MM.YYYY assert.equal(formatDateDE('2026-04-01'), '01.04.2026', 'formatDateDE DD.MM.YYYY'); // buildNameMap: id → name lookup assert.deepEqual( buildNameMap([{ id: 'a', name: 'Alice' }, { id: 'b', name: 'Bob' }]), { a: 'Alice', b: 'Bob' }, 'buildNameMap maps id to name' ); console.log('All utils tests passed.');