mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-02-10 23:36:14 -05:00
refs0f59537b96
refs https://github.com/TryGhost/Team/issues/221 refs303046bc0a
- When the referenced changes were introduced they did not take into account upcoming engine versions and provided little guidance about what other areas might need to be checked and changed - The last referenced commit shows an approximate scale of changes that might be beened when frontend engine defaults are modified in the future
175 lines
4.5 KiB
JavaScript
175 lines
4.5 KiB
JavaScript
const should = require('should');
|
|
const sinon = require('sinon');
|
|
const themeEngines = require('../../../../../core/frontend/services/themes/engines');
|
|
|
|
/**
|
|
* @NOTE
|
|
*
|
|
* If this test fails for you, you are probably modifying supported theme engines.
|
|
*
|
|
* When you make a change, please test that:
|
|
*
|
|
* 1. Please check that uploading a theme with newly added/modified engine version works
|
|
* 2. Check other places that potentially need updates (e.g.: frontends resource cache config, )
|
|
* 3. Add the a protective test for when next verstion (v6?) is planned it has to be changed again
|
|
*/
|
|
describe('Themes: engines', function () {
|
|
const DEFAULT_ENGINE_VERSION = 'v4';
|
|
|
|
afterEach(function () {
|
|
sinon.restore();
|
|
});
|
|
|
|
it('no engines', function () {
|
|
const engines = themeEngines.create();
|
|
engines.should.eql({
|
|
'ghost-api': DEFAULT_ENGINE_VERSION
|
|
});
|
|
});
|
|
|
|
describe('ghost-api', function () {
|
|
it('unknown version falls back to default version', function () {
|
|
const engines = themeEngines.create({
|
|
engines: {
|
|
'ghost-api': 'v100'
|
|
}
|
|
});
|
|
|
|
engines.should.eql({
|
|
'ghost-api': DEFAULT_ENGINE_VERSION
|
|
});
|
|
});
|
|
|
|
it('deprecated and not supported version falls back to default version', function () {
|
|
const engines = themeEngines.create({
|
|
engines: {
|
|
'ghost-api': '^0.1'
|
|
}
|
|
});
|
|
|
|
engines.should.eql({
|
|
'ghost-api': DEFAULT_ENGINE_VERSION
|
|
});
|
|
});
|
|
|
|
it('not supported upcoming version falls back to default version', function () {
|
|
const engines = themeEngines.create({
|
|
engines: {
|
|
'ghost-api': 'v5'
|
|
}
|
|
});
|
|
|
|
engines.should.eql({
|
|
'ghost-api': DEFAULT_ENGINE_VERSION
|
|
});
|
|
});
|
|
|
|
it('v2', function () {
|
|
const engines = themeEngines.create({
|
|
engines: {
|
|
'ghost-api': 'v2'
|
|
}
|
|
});
|
|
|
|
engines.should.eql({
|
|
'ghost-api': 'v2'
|
|
});
|
|
});
|
|
|
|
it('^2', function () {
|
|
const engines = themeEngines.create({
|
|
engines: {
|
|
'ghost-api': '^2'
|
|
}
|
|
});
|
|
|
|
engines.should.eql({
|
|
'ghost-api': 'v2'
|
|
});
|
|
});
|
|
|
|
it('2.0.0', function () {
|
|
const engines = themeEngines.create({
|
|
engines: {
|
|
'ghost-api': '2.0.0'
|
|
}
|
|
});
|
|
|
|
engines.should.eql({
|
|
'ghost-api': 'v2'
|
|
});
|
|
});
|
|
|
|
it('2.17.0', function () {
|
|
const engines = themeEngines.create({
|
|
engines: {
|
|
'ghost-api': '2.17.0'
|
|
}
|
|
});
|
|
|
|
engines.should.eql({
|
|
'ghost-api': 'v2'
|
|
});
|
|
});
|
|
|
|
it('canary', function () {
|
|
const engines = themeEngines.create({
|
|
engines: {
|
|
'ghost-api': 'canary'
|
|
}
|
|
});
|
|
|
|
engines.should.eql({
|
|
'ghost-api': 'canary'
|
|
});
|
|
});
|
|
|
|
it('3', function () {
|
|
const engines = themeEngines.create({
|
|
engines: {
|
|
'ghost-api': '3'
|
|
}
|
|
});
|
|
|
|
engines.should.eql({
|
|
'ghost-api': 'v3'
|
|
});
|
|
});
|
|
|
|
it('v3', function () {
|
|
const engines = themeEngines.create({
|
|
engines: {
|
|
'ghost-api': 'v3'
|
|
}
|
|
});
|
|
|
|
engines.should.eql({
|
|
'ghost-api': 'v3'
|
|
});
|
|
});
|
|
|
|
it('4', function () {
|
|
const engines = themeEngines.create({
|
|
engines: {
|
|
'ghost-api': '4'
|
|
}
|
|
});
|
|
|
|
engines.should.eql({
|
|
'ghost-api': DEFAULT_ENGINE_VERSION
|
|
});
|
|
});
|
|
|
|
it('v4', function () {
|
|
const engines = themeEngines.create({
|
|
engines: {
|
|
'ghost-api': 'v4'
|
|
}
|
|
});
|
|
|
|
engines.should.eql({
|
|
'ghost-api': DEFAULT_ENGINE_VERSION
|
|
});
|
|
});
|
|
});
|
|
});
|