0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-02-03 23:00:14 -05:00
ghost/test/unit/services/theme-engine/engines/create.test.js
Hannah Wolfe f08a55c21f
Renamed tests to .test.js & updated commands
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
2021-07-06 20:45:01 +01:00

176 lines
4.6 KiB
JavaScript

const should = require('should');
const sinon = require('sinon');
const themeEngines = require('../../../../../core/frontend/services/theme-engine/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 () {
// NOTE: This is deliberately hard-coded so that when the default version is upgraded this test fails and needs reading!
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
});
});
});
});