Ghost/ghost/email-suppression-list/test/lib/email-suppression-list.test.js
Fabien "egg" O'Carroll 9736d942e1 Unsubscribed Members from newsletters when their email is suppressed
refs https://github.com/TryGhost/Team/issues/2367

This ensures that a Member is not considered subscribed to any emails, so that
counts for newsletter recipients are correct. Eventually we will filter members
on their email suppression status but this is not implemented yet.
2022-12-08 13:02:36 +07:00

39 lines
1.2 KiB
JavaScript

const assert = require('assert');
const {EmailSuppressionData, EmailSuppressedEvent} = require('../../lib/email-suppression-list');
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);
});
it('Has info when suppressed', function () {
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);
});
});
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);
});
});