mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-25 11:55:03 +03:00
Integrated chai-jest-snapshot
refs https://github.com/TryGhost/Toolbox/issues/129 - Minimal version of chai-jest-snapshot with property matcher support. It runs off the forked version of https://github.com/suchipi/chai-jest-snapshot
This commit is contained in:
parent
743b7a16e0
commit
3dfab7d682
@ -180,10 +180,13 @@
|
||||
"devDependencies": {
|
||||
"@lodder/grunt-postcss": "3.1.1",
|
||||
"c8": "7.10.0",
|
||||
"chai": "4.3.4",
|
||||
"@ethanresnick/chai-jest-snapshot": "3.0.0",
|
||||
"coffeescript": "2.6.1",
|
||||
"cssnano": "5.0.12",
|
||||
"eslint": "7.32.0",
|
||||
"eslint-plugin-ghost": "2.11.0",
|
||||
"expect": "27.4.2",
|
||||
"grunt": "1.4.1",
|
||||
"grunt-bg-shell": "2.3.3",
|
||||
"grunt-contrib-clean": "2.0.0",
|
||||
|
@ -1,27 +1,35 @@
|
||||
const should = require('should');
|
||||
const chai = require('chai');
|
||||
const {expect} = require('chai');
|
||||
const {any, stringMatching} = require('expect');
|
||||
const chaiJestSnapshot = require('@ethanresnick/chai-jest-snapshot');
|
||||
const framework = require('../../../../utils/e2e-framework');
|
||||
const testUtils = require('../../../../utils');
|
||||
const localUtils = require('./utils');
|
||||
const config = require('../../../../../core/shared/config');
|
||||
|
||||
chai.use(chaiJestSnapshot);
|
||||
|
||||
describe('Config API', function () {
|
||||
let request;
|
||||
|
||||
before(async function () {
|
||||
chaiJestSnapshot.resetSnapshotRegistry();
|
||||
request = await framework.getAgent('/ghost/api/canary/admin/');
|
||||
});
|
||||
|
||||
beforeEach(function () {
|
||||
chaiJestSnapshot.configureUsingMochaContext(this);
|
||||
});
|
||||
|
||||
it('can retrieve config and all expected properties', async function () {
|
||||
const res = await request
|
||||
.get('site/')
|
||||
.set('Origin', config.get('url'))
|
||||
.expect('Content-Type', /json/)
|
||||
.expect('Cache-Control', testUtils.cacheRules.private)
|
||||
.expect(200);
|
||||
.set('Origin', config.get('url'));
|
||||
|
||||
localUtils.API.checkResponse(res.body.site, 'site');
|
||||
|
||||
// minor (safe) version
|
||||
res.body.site.version.should.match(/\d+\.\d+/);
|
||||
expect(res.body.site).to.matchSnapshot({
|
||||
version: stringMatching(/\d+\.\d+/)
|
||||
});
|
||||
expect(res.headers).to.matchSnapshot({
|
||||
date: any(String),
|
||||
etag: any(String)
|
||||
});
|
||||
});
|
||||
});
|
||||
|
27
test/regression/api/canary/admin/site.test.js.snap
Normal file
27
test/regression/api/canary/admin/site.test.js.snap
Normal file
@ -0,0 +1,27 @@
|
||||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||
|
||||
exports[`Config API can retrieve config and all expected properties 1`] = `
|
||||
Object {
|
||||
"accent_color": "#FF1A75",
|
||||
"description": "Thoughts, stories and ideas",
|
||||
"icon": null,
|
||||
"logo": null,
|
||||
"title": "Ghost",
|
||||
"url": "http://127.0.0.1:2369/",
|
||||
"version": StringMatching /\\\\d\\+\\\\\\.\\\\d\\+/,
|
||||
}
|
||||
`;
|
||||
|
||||
exports[`Config API can retrieve config and all expected properties 2`] = `
|
||||
Object {
|
||||
"access-control-allow-origin": "http://127.0.0.1:2369",
|
||||
"cache-control": "no-cache, private, no-store, must-revalidate, max-stale=0, post-check=0, pre-check=0",
|
||||
"connection": "close",
|
||||
"content-length": "167",
|
||||
"content-type": "application/json; charset=utf-8",
|
||||
"date": Any<String>,
|
||||
"etag": Any<String>,
|
||||
"vary": "Origin, Accept-Encoding",
|
||||
"x-powered-by": "Express",
|
||||
}
|
||||
`;
|
Loading…
Reference in New Issue
Block a user