2020-04-29 18:44:27 +03:00
|
|
|
const should = require('should');
|
|
|
|
const supertest = require('supertest');
|
|
|
|
const testUtils = require('../../utils');
|
2020-05-27 20:47:53 +03:00
|
|
|
const config = require('../../../core/shared/config');
|
2020-04-29 18:44:27 +03:00
|
|
|
const localUtils = require('./utils');
|
2018-10-12 15:25:20 +03:00
|
|
|
|
|
|
|
describe('Slug API', function () {
|
2020-11-30 17:25:22 +03:00
|
|
|
let request;
|
2018-10-12 15:25:20 +03:00
|
|
|
|
2020-11-30 17:25:22 +03:00
|
|
|
before(async function () {
|
2021-11-18 11:55:35 +03:00
|
|
|
await localUtils.startGhost();
|
2020-11-30 17:25:22 +03:00
|
|
|
request = supertest.agent(config.get('url'));
|
|
|
|
await localUtils.doAuth(request);
|
2018-10-12 15:25:20 +03:00
|
|
|
});
|
|
|
|
|
2020-11-30 17:25:22 +03:00
|
|
|
it('Can generate a slug', async function () {
|
|
|
|
const res = await request.get(localUtils.API.getApiQuery('slugs/post/a post title/'))
|
2018-10-12 15:25:20 +03:00
|
|
|
.set('Origin', config.get('url'))
|
|
|
|
.expect('Content-Type', /json/)
|
|
|
|
.expect('Cache-Control', testUtils.cacheRules.private)
|
2020-11-30 17:25:22 +03:00
|
|
|
.expect(200);
|
2018-10-12 15:25:20 +03:00
|
|
|
|
2024-02-26 19:59:29 +03:00
|
|
|
should.not.exist(res.headers['x-cache-invalidate']);
|
2020-11-30 17:25:22 +03:00
|
|
|
const jsonResponse = res.body;
|
|
|
|
should.exist(jsonResponse);
|
|
|
|
should.exist(jsonResponse.slugs);
|
|
|
|
jsonResponse.slugs.should.have.length(1);
|
|
|
|
localUtils.API.checkResponse(jsonResponse.slugs[0], 'slug');
|
|
|
|
jsonResponse.slugs[0].slug.should.equal('a-post-title');
|
2018-10-12 15:25:20 +03:00
|
|
|
});
|
|
|
|
});
|