/* * Pruefungen der Berater-Mail (acquisitionNotify.js): laeuft mit `npm test`. * * Geprueft wird, wer eine Mail bekommt (nur neu hinzugekommene Berater) und * dass der Mailtext Eingaben escaped - Titel und Beschreibung kommen aus * Freitextfeldern und landen als HTML im Postfach des Beraters. */ const { addedConsultants, buildMessage } = await import('../src/acquisitionNotify.js'); let failures = 0; function check(name, condition, detail = '') { if (condition) { console.log(` ok ${name}${detail ? ` - ${detail}` : ''}`); } else { console.log(` FAIL ${name}${detail ? ` - ${detail}` : ''}`); failures += 1; } } const same = (left, right) => JSON.stringify(left) === JSON.stringify(right); console.log('\nWer bekommt eine Mail'); check('Anlegen: alle', same(addedConsultants(null, 'Nico, Lisa'), ['Nico', 'Lisa'])); check('Ohne Berater: niemand', same(addedConsultants(null, null), [])); check('Bearbeiten: nur neue', same(addedConsultants('Nico', 'Nico, Lisa'), ['Lisa'])); check('Schreibweise egal', same(addedConsultants('nico', 'Nico'), [])); check('Entfernen: niemand', same(addedConsultants('Nico, Lisa', 'Nico'), [])); console.log('\nMailtext'); const message = buildMessage( { id: 1, title: 'SAP