2018-10-17 10:23:56 +03:00
|
|
|
const should = require('should');
|
|
|
|
const sinon = require('sinon');
|
2020-03-30 18:26:47 +03:00
|
|
|
const themeEngines = require('../../../../../core/frontend/services/themes/engines');
|
2018-10-17 10:23:56 +03:00
|
|
|
|
2021-02-24 08:55:12 +03:00
|
|
|
/**
|
|
|
|
* @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
|
|
|
|
*/
|
2018-10-17 10:23:56 +03:00
|
|
|
describe('Themes: engines', function () {
|
2021-04-21 19:53:58 +03:00
|
|
|
// NOTE: This is deliberately hard-coded so that when the default version is upgraded this test fails and needs reading!
|
2021-02-24 08:55:12 +03:00
|
|
|
const DEFAULT_ENGINE_VERSION = 'v4';
|
|
|
|
|
2018-10-17 10:23:56 +03:00
|
|
|
afterEach(function () {
|
2019-01-21 19:53:44 +03:00
|
|
|
sinon.restore();
|
2018-10-17 10:23:56 +03:00
|
|
|
});
|
|
|
|
|
|
|
|
it('no engines', function () {
|
|
|
|
const engines = themeEngines.create();
|
|
|
|
engines.should.eql({
|
2021-02-24 08:55:12 +03:00
|
|
|
'ghost-api': DEFAULT_ENGINE_VERSION
|
2018-10-17 10:23:56 +03:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('ghost-api', function () {
|
2021-02-24 08:55:12 +03:00
|
|
|
it('unknown version falls back to default version', function () {
|
2018-10-17 10:23:56 +03:00
|
|
|
const engines = themeEngines.create({
|
|
|
|
engines: {
|
2021-02-24 08:55:12 +03:00
|
|
|
'ghost-api': 'v100'
|
2018-10-17 10:23:56 +03:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
engines.should.eql({
|
2021-02-24 08:55:12 +03:00
|
|
|
'ghost-api': DEFAULT_ENGINE_VERSION
|
2018-10-17 10:23:56 +03:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2021-02-24 08:55:12 +03:00
|
|
|
it('deprecated and not supported version falls back to default version', function () {
|
2018-10-17 10:23:56 +03:00
|
|
|
const engines = themeEngines.create({
|
|
|
|
engines: {
|
2021-02-24 08:55:12 +03:00
|
|
|
'ghost-api': '^0.1'
|
2018-10-17 10:23:56 +03:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
engines.should.eql({
|
2021-02-24 08:55:12 +03:00
|
|
|
'ghost-api': DEFAULT_ENGINE_VERSION
|
2018-10-17 10:23:56 +03:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2021-02-24 08:55:12 +03:00
|
|
|
it('not supported upcoming version falls back to default version', function () {
|
2018-10-17 10:23:56 +03:00
|
|
|
const engines = themeEngines.create({
|
|
|
|
engines: {
|
2021-02-24 08:55:12 +03:00
|
|
|
'ghost-api': 'v5'
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
engines.should.eql({
|
|
|
|
'ghost-api': DEFAULT_ENGINE_VERSION
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
it('v2', function () {
|
|
|
|
const engines = themeEngines.create({
|
|
|
|
engines: {
|
|
|
|
'ghost-api': 'v2'
|
2018-10-17 10:23:56 +03:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
engines.should.eql({
|
2021-02-24 08:55:12 +03:00
|
|
|
'ghost-api': 'v2'
|
2018-10-17 10:23:56 +03:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
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'
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2019-09-03 10:03:31 +03:00
|
|
|
it('canary', function () {
|
|
|
|
const engines = themeEngines.create({
|
|
|
|
engines: {
|
|
|
|
'ghost-api': 'canary'
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
engines.should.eql({
|
|
|
|
'ghost-api': 'canary'
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2018-10-17 10:23:56 +03:00
|
|
|
it('3', function () {
|
|
|
|
const engines = themeEngines.create({
|
|
|
|
engines: {
|
|
|
|
'ghost-api': '3'
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
engines.should.eql({
|
2019-09-03 10:03:31 +03:00
|
|
|
'ghost-api': 'v3'
|
2018-10-17 10:23:56 +03:00
|
|
|
});
|
|
|
|
});
|
2019-08-09 17:25:12 +03:00
|
|
|
|
2019-09-03 10:03:31 +03:00
|
|
|
it('v3', function () {
|
2019-08-09 17:25:12 +03:00
|
|
|
const engines = themeEngines.create({
|
|
|
|
engines: {
|
2019-09-03 10:03:31 +03:00
|
|
|
'ghost-api': 'v3'
|
2019-08-09 17:25:12 +03:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
engines.should.eql({
|
2019-09-03 10:03:31 +03:00
|
|
|
'ghost-api': 'v3'
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
it('4', function () {
|
|
|
|
const engines = themeEngines.create({
|
|
|
|
engines: {
|
|
|
|
'ghost-api': '4'
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
engines.should.eql({
|
2021-02-24 08:55:12 +03:00
|
|
|
'ghost-api': DEFAULT_ENGINE_VERSION
|
2021-02-22 17:39:48 +03:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
it('v4', function () {
|
|
|
|
const engines = themeEngines.create({
|
|
|
|
engines: {
|
|
|
|
'ghost-api': 'v4'
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
engines.should.eql({
|
2021-02-24 08:55:12 +03:00
|
|
|
'ghost-api': DEFAULT_ENGINE_VERSION
|
2019-08-09 17:25:12 +03:00
|
|
|
});
|
|
|
|
});
|
2018-10-17 10:23:56 +03:00
|
|
|
});
|
|
|
|
});
|