2022-11-18 10:59:06 +03:00
|
|
|
const assert = require('assert');
|
2022-12-05 12:56:01 +03:00
|
|
|
const {EmailSuppressionData, EmailSuppressedEvent} = require('../../lib/email-suppression-list');
|
2022-11-18 10:59:06 +03:00
|
|
|
|
|
|
|
describe('EmailSuppressionData', function () {
|
|
|
|
it('Has null info when not suppressed', function () {
|
|
|
|
const now = new Date();
|
|
|
|
const data = new EmailSuppressionData(false, {
|
|
|
|
reason: 'spam',
|
|
|
|
timestamp: now
|
|
|
|
});
|
|
|
|
|
|
|
|
assert(data.suppressed === false);
|
|
|
|
assert(data.info === null);
|
|
|
|
});
|
2022-12-05 12:56:01 +03:00
|
|
|
it('Has info when suppressed', function () {
|
2022-11-18 10:59:06 +03:00
|
|
|
const now = new Date();
|
|
|
|
const data = new EmailSuppressionData(true, {
|
|
|
|
reason: 'spam',
|
|
|
|
timestamp: now
|
|
|
|
});
|
|
|
|
|
|
|
|
assert(data.suppressed === true);
|
|
|
|
assert(data.info.reason === 'spam');
|
|
|
|
assert(data.info.timestamp === now);
|
|
|
|
});
|
|
|
|
});
|
2022-12-05 12:56:01 +03:00
|
|
|
|
|
|
|
describe('EmailSuppressedEvent', function () {
|
|
|
|
it('Exposes a create factory method', function () {
|
|
|
|
const event = EmailSuppressedEvent.create({
|
|
|
|
emailAddress: 'test@test.com',
|
|
|
|
emailId: '1234567890abcdef',
|
|
|
|
reason: 'spam'
|
|
|
|
});
|
|
|
|
assert(event instanceof EmailSuppressedEvent);
|
|
|
|
assert(event.timestamp);
|
|
|
|
});
|
|
|
|
});
|