From 9add72ebb149eabd6e419be5f172e668376e7f79 Mon Sep 17 00:00:00 2001 From: "Fabien \"egg\" O'Carroll" Date: Fri, 18 Nov 2022 14:59:06 +0700 Subject: [PATCH] Fixed tests for @tryghost/email-suppression-list These were missing and caused the build to fail --- ghost/email-suppression-list/package.json | 1 + .../email-suppression-list/test/index.test.js | 6 +++++ .../test/lib/email-suppression-list.test.js | 26 +++++++++++++++++++ 3 files changed, 33 insertions(+) create mode 100644 ghost/email-suppression-list/test/index.test.js create mode 100644 ghost/email-suppression-list/test/lib/email-suppression-list.test.js diff --git a/ghost/email-suppression-list/package.json b/ghost/email-suppression-list/package.json index 12925bf400..038bf45b76 100644 --- a/ghost/email-suppression-list/package.json +++ b/ghost/email-suppression-list/package.json @@ -8,6 +8,7 @@ "scripts": { "dev": "echo \"Implement me!\"", "test": "NODE_ENV=testing c8 --all --check-coverage --reporter text --reporter cobertura mocha './test/**/*.test.js'", + "test:unit": "yarn test", "lint:code": "eslint *.js lib/ --ext .js --cache", "lint": "yarn lint:code && yarn lint:test", "lint:test": "eslint -c test/.eslintrc.js test/ --ext .js --cache" diff --git a/ghost/email-suppression-list/test/index.test.js b/ghost/email-suppression-list/test/index.test.js new file mode 100644 index 0000000000..0dc6d2b095 --- /dev/null +++ b/ghost/email-suppression-list/test/index.test.js @@ -0,0 +1,6 @@ +const assert = require('assert'); +describe('exports', function () { + it('exports the lib/email-suppression-list file', function () { + assert(require('../') === require('../lib/email-suppression-list')); + }); +}); diff --git a/ghost/email-suppression-list/test/lib/email-suppression-list.test.js b/ghost/email-suppression-list/test/lib/email-suppression-list.test.js new file mode 100644 index 0000000000..235913d2d3 --- /dev/null +++ b/ghost/email-suppression-list/test/lib/email-suppression-list.test.js @@ -0,0 +1,26 @@ +const assert = require('assert'); +const {EmailSuppressionData} = 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('', 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); + }); +});