mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-03-11 02:12:21 -05:00
Added basic read endpoint test
This commit is contained in:
parent
c342ea1454
commit
1ed2598c3b
2 changed files with 41 additions and 0 deletions
38
core/test/acceptance/admin/emails_spec.js
Normal file
38
core/test/acceptance/admin/emails_spec.js
Normal file
|
@ -0,0 +1,38 @@
|
||||||
|
const should = require('should');
|
||||||
|
const supertest = require('supertest');
|
||||||
|
const testUtils = require('../../utils');
|
||||||
|
const config = require('../../../server/config');
|
||||||
|
const localUtils = require('./utils');
|
||||||
|
|
||||||
|
const ghost = testUtils.startGhost;
|
||||||
|
|
||||||
|
describe('Email API', function () {
|
||||||
|
let request;
|
||||||
|
|
||||||
|
before(function () {
|
||||||
|
return ghost()
|
||||||
|
.then(function () {
|
||||||
|
request = supertest.agent(config.get('url'));
|
||||||
|
})
|
||||||
|
.then(function () {
|
||||||
|
return localUtils.doAuth(request, 'posts', 'emails');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it('Can read an email', function () {
|
||||||
|
return request
|
||||||
|
.get(localUtils.API.getApiQuery(`emails/${testUtils.DataGenerator.Content.emails[0].id}/`))
|
||||||
|
.set('Origin', config.get('url'))
|
||||||
|
.expect('Content-Type', /json/)
|
||||||
|
.expect('Cache-Control', testUtils.cacheRules.private)
|
||||||
|
.expect(200)
|
||||||
|
.then((res) => {
|
||||||
|
should.not.exist(res.headers['x-cache-invalidate']);
|
||||||
|
const jsonResponse = res.body;
|
||||||
|
should.exist(jsonResponse);
|
||||||
|
should.exist(jsonResponse.emails);
|
||||||
|
jsonResponse.emails.should.have.length(1);
|
||||||
|
localUtils.API.checkResponse(jsonResponse.emails[0], 'email');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
|
@ -101,6 +101,9 @@ const expectedProperties = {
|
||||||
,
|
,
|
||||||
webhook: _(schema.webhooks)
|
webhook: _(schema.webhooks)
|
||||||
.keys()
|
.keys()
|
||||||
|
,
|
||||||
|
email: _(schema.emails)
|
||||||
|
.keys()
|
||||||
};
|
};
|
||||||
|
|
||||||
_.each(expectedProperties, (value, key) => {
|
_.each(expectedProperties, (value, key) => {
|
||||||
|
|
Loading…
Add table
Reference in a new issue