mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-01-27 22:49:56 -05:00
f08a55c21f
refs: https://github.com/TryGhost/Team/issues/856 refs: https://github.com/TryGhost/Team/issues/756 - The .test.js extension is better than _spec.js as it's more obvious that it's an extension - It also meaans we can use the --extension parameter in mocha, which should result in a better default behaviour for `yarn test` - It also highlights that some of our tests were named incorrectly and were not (and still will not be) run (see https://github.com/TryGhost/Team/issues/856) - Note: even with this change, `yarn test` is throwing errors, I believe because of this issue https://github.com/TryGhost/Team/issues/756
55 lines
1.6 KiB
JavaScript
55 lines
1.6 KiB
JavaScript
const should = require('should');
|
|
const sinon = require('sinon');
|
|
|
|
const preview = require('../../../../core/frontend/services/theme-engine/preview');
|
|
|
|
describe('Theme Preview', function () {
|
|
let req, previewString = '';
|
|
|
|
before(function () {
|
|
req = {
|
|
header: () => {
|
|
return previewString;
|
|
}
|
|
};
|
|
});
|
|
|
|
it('can handle empty strings', function () {
|
|
previewString = 'logo=';
|
|
|
|
let siteData = preview.handle(req, {});
|
|
|
|
siteData.should.be.an.Object().with.properties('logo');
|
|
should(siteData.logo).be.null();
|
|
});
|
|
|
|
it('can handle nulls', function () {
|
|
previewString = 'cover=null';
|
|
|
|
let siteData = preview.handle(req, {});
|
|
|
|
siteData.should.be.an.Object().with.properties('cover_image');
|
|
should(siteData.cover_image).be.null();
|
|
});
|
|
|
|
it('can handle URIEncoded accent colors', function () {
|
|
previewString = 'c=%23f02d2d';
|
|
|
|
let siteData = preview.handle(req, {});
|
|
|
|
siteData.should.be.an.Object().with.properties('accent_color');
|
|
should(siteData.accent_color).eql('#f02d2d');
|
|
});
|
|
|
|
it('can handle multiple values', function () {
|
|
previewString = 'c=%23f02d2d&icon=&logo=&cover=null';
|
|
|
|
let siteData = preview.handle(req, {});
|
|
siteData.should.be.an.Object().with.properties('accent_color', 'icon', 'logo', 'cover_image');
|
|
|
|
should(siteData.accent_color).eql('#f02d2d');
|
|
should(siteData.icon).be.null();
|
|
should(siteData.logo).be.null();
|
|
should(siteData.cover_image).be.null();
|
|
});
|
|
});
|