Ghost/ghost/posts-service/test/PostsService.test.js
Simon Backx a5dff4207e Moved posts service to its own package
fixes https://github.com/TryGhost/Team/issues/2778

It is easier to add extra classes using the latest patterns if it has its own package.
2023-03-20 16:06:42 +01:00

43 lines
1.4 KiB
JavaScript

const {PostsService} = require('../index');
const assert = require('assert');
describe('Posts Service', function () {
it('Can construct class', function () {
new PostsService({});
});
describe('shouldSendEmail', function () {
it('calculates if an email should be sent', async function () {
const postsService = new PostsService({});
assert.deepEqual([
postsService.shouldSendEmail('published', 'draft'),
postsService.shouldSendEmail('published', 'scheduled'),
postsService.shouldSendEmail('sent', 'draft'),
postsService.shouldSendEmail('sent', 'scheduled'),
postsService.shouldSendEmail('published', 'published'),
postsService.shouldSendEmail('published', 'sent'),
postsService.shouldSendEmail('published', 'published'),
postsService.shouldSendEmail('published', 'sent'),
postsService.shouldSendEmail('sent', 'published'),
postsService.shouldSendEmail('sent', 'sent'),
postsService.shouldSendEmail()
], [
true,
true,
true,
true,
false,
false,
false,
false,
false,
false,
false
]);
});
});
});