2018-10-12 15:25:20 +03:00
|
|
|
var should = require('should'),
|
|
|
|
supertest = require('supertest'),
|
2019-09-20 18:02:45 +03:00
|
|
|
testUtils = require('../../utils'),
|
|
|
|
config = require('../../../server/config'),
|
|
|
|
localUtils = require('./utils'),
|
|
|
|
|
2018-10-12 15:25:20 +03:00
|
|
|
ghost = testUtils.startGhost,
|
|
|
|
request;
|
|
|
|
|
|
|
|
describe('Slug API', function () {
|
|
|
|
let ghostServer;
|
|
|
|
|
|
|
|
before(function () {
|
|
|
|
return ghost()
|
|
|
|
.then(function (_ghostServer) {
|
|
|
|
ghostServer = _ghostServer;
|
|
|
|
request = supertest.agent(config.get('url'));
|
|
|
|
})
|
|
|
|
.then(function () {
|
|
|
|
return localUtils.doAuth(request);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2019-02-04 17:16:24 +03:00
|
|
|
it('Can generate a slug ', function (done) {
|
2018-10-12 15:25:20 +03:00
|
|
|
request.get(localUtils.API.getApiQuery('slugs/post/a post title/'))
|
|
|
|
.set('Origin', config.get('url'))
|
|
|
|
.expect('Content-Type', /json/)
|
|
|
|
.expect('Cache-Control', testUtils.cacheRules.private)
|
|
|
|
.expect(200)
|
|
|
|
.end(function (err, res) {
|
|
|
|
if (err) {
|
|
|
|
return done(err);
|
|
|
|
}
|
|
|
|
|
|
|
|
should.not.exist(res.headers['x-cache-invalidate']);
|
|
|
|
var jsonResponse = res.body;
|
|
|
|
should.exist(jsonResponse);
|
|
|
|
should.exist(jsonResponse.slugs);
|
|
|
|
jsonResponse.slugs.should.have.length(1);
|
2018-12-17 18:14:36 +03:00
|
|
|
localUtils.API.checkResponse(jsonResponse.slugs[0], 'slug');
|
2018-10-12 15:25:20 +03:00
|
|
|
jsonResponse.slugs[0].slug.should.equal('a-post-title');
|
|
|
|
|
|
|
|
done();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|