2021-12-08 13:00:45 +04:00
|
|
|
const chai = require('chai');
|
|
|
|
const {expect} = require('chai');
|
|
|
|
const {any, stringMatching} = require('expect');
|
|
|
|
const chaiJestSnapshot = require('@ethanresnick/chai-jest-snapshot');
|
2021-12-07 13:51:08 +04:00
|
|
|
const framework = require('../../../../utils/e2e-framework');
|
2021-03-09 22:10:27 +13:00
|
|
|
const config = require('../../../../../core/shared/config');
|
|
|
|
|
2021-12-08 13:00:45 +04:00
|
|
|
chai.use(chaiJestSnapshot);
|
|
|
|
|
2021-03-09 22:10:27 +13:00
|
|
|
describe('Config API', function () {
|
|
|
|
let request;
|
|
|
|
|
|
|
|
before(async function () {
|
2021-12-08 13:00:45 +04:00
|
|
|
chaiJestSnapshot.resetSnapshotRegistry();
|
2021-12-07 20:23:22 +04:00
|
|
|
request = await framework.getAgent('/ghost/api/canary/admin/');
|
2021-03-09 22:10:27 +13:00
|
|
|
});
|
|
|
|
|
2021-12-08 13:00:45 +04:00
|
|
|
beforeEach(function () {
|
|
|
|
chaiJestSnapshot.configureUsingMochaContext(this);
|
|
|
|
});
|
|
|
|
|
2021-03-09 22:10:27 +13:00
|
|
|
it('can retrieve config and all expected properties', async function () {
|
|
|
|
const res = await request
|
2021-12-07 20:23:22 +04:00
|
|
|
.get('site/')
|
2021-12-08 13:00:45 +04:00
|
|
|
.set('Origin', config.get('url'));
|
2021-03-09 22:10:27 +13:00
|
|
|
|
2021-12-08 13:00:45 +04:00
|
|
|
expect(res.body.site).to.matchSnapshot({
|
|
|
|
version: stringMatching(/\d+\.\d+/)
|
|
|
|
});
|
|
|
|
expect(res.headers).to.matchSnapshot({
|
|
|
|
date: any(String),
|
|
|
|
etag: any(String)
|
|
|
|
});
|
2021-03-09 22:10:27 +13:00
|
|
|
});
|
|
|
|
});
|