0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-01-27 22:49:56 -05:00
ghost/test/e2e-api/admin/mail.test.js

61 lines
1.6 KiB
JavaScript
Raw Normal View History

const {agentProvider, fixtureManager, matchers, mockManager} = require('../../utils/e2e-framework');
const {anyEtag} = matchers;
describe('Mail API', function () {
let agent;
2018-10-12 19:44:05 +02:00
before(async function () {
agent = await agentProvider.getAdminAPIAgent();
await fixtureManager.init('invites');
await agent.loginAsOwner();
2018-10-12 19:44:05 +02:00
});
beforeEach(function () {
mockManager.mockMail({message: 'sent'});
2018-10-12 19:44:05 +02:00
});
afterEach(function () {
mockManager.restore();
2018-10-12 19:44:05 +02:00
});
it('Can send mail', async function () {
await agent
.post('mail/')
.body({
2018-10-12 19:44:05 +02:00
mail: [{
message: {
to: 'joe@example.com',
subject: 'testemail',
html: '<p>This</p>'
}
}]
})
.expectStatus(200)
.matchBodySnapshot()
.matchHeaderSnapshot({
etag: anyEtag
});
mockManager.assert.sentEmail({
to: 'joe@example.com',
subject: 'testemail'
});
});
2018-10-12 19:44:05 +02:00
it('Can send a test mail', async function () {
// @TODO: either remove this endpoint or fix its response body
await agent
.post('mail/test')
.expectStatus(200)
.matchBodySnapshot()
.matchHeaderSnapshot({
etag: anyEtag
});
mockManager.assert.sentEmail({
to: 'jbloggs@example.com',
subject: 'Test Ghost Email'
});
2018-10-12 19:44:05 +02:00
});
});