diff --git a/packages/inbound-email-handler/test/newsletter.test.ts b/packages/inbound-email-handler/test/newsletter.test.ts index 284e327b3..60f96f712 100644 --- a/packages/inbound-email-handler/test/newsletter.test.ts +++ b/packages/inbound-email-handler/test/newsletter.test.ts @@ -3,12 +3,14 @@ import 'mocha' import { parsedTo } from '../src' import { getConfirmationCode, - isConfirmationEmail, + isGoogleConfirmationEmail, + isSubscriptionConfirmationEmail, + parseAuthor, parseUnsubscribe, } from '../src/newsletter' describe('Confirmation email test', () => { - describe('#isConfirmationEmail()', () => { + describe('#isGoogleConfirmationEmail()', () => { let from: string let subject: string @@ -16,7 +18,7 @@ describe('Confirmation email test', () => { from = 'Gmail Team ' subject = `(#123456789) Gmail Forwarding Confirmation - Receive Mail from test@omnivore.app` - expect(isConfirmationEmail(from, subject)).to.be.true + expect(isGoogleConfirmationEmail(from, subject)).to.be.true }) it('returns true when email is from Japan Gmail Team', () => { @@ -24,7 +26,7 @@ describe('Confirmation email test', () => { subject = '(#123456789)SWG の転送の確認 - test@omnivore.app からメールを受信' - expect(isConfirmationEmail(from, subject)).to.be.true + expect(isGoogleConfirmationEmail(from, subject)).to.be.true }) it('returns true when email is in Spanish', () => { @@ -32,7 +34,7 @@ describe('Confirmation email test', () => { subject = 'Confirmación de reenvío de 123456789 (n.º Gmail) - Recibir correo de test@omnivore.app' - expect(isConfirmationEmail(from, subject)).to.be.true + expect(isGoogleConfirmationEmail(from, subject)).to.be.true }) }) @@ -111,3 +113,18 @@ describe('parsedTo', () => { ).to.equal(to) }) }) + +describe('parseAuthor', () => { + it('returns author if exists', () => { + const author = 'Tester' + const address = `${author} ` + expect(parseAuthor(address)).to.eql(author) + }) +}) + +describe('isSubscriptionConfirmationEmail', () => { + it('returns true if email is a confirmation', () => { + const subject = 'Confirm your Omnivore newsletter subscription' + expect(isSubscriptionConfirmationEmail(subject)).to.be.true + }) +})