Ghost/test/unit/frontend/services/theme-engine/config.test.js
Hannah Wolfe e25f1df0ae
Added card-asset config with sensible default
- This comment removes the block on themes controlling card assets via config
- It also changes the default behaviour from "false" config (doing nothing) to excluding bookmark and gallery card assets
- This is essentially the same thing, as only bookmark and gallery card assets exist at the moment, but it's being done because it makes this feature future-proof for all theme developers.
- As we add new cards, all themes will automatically get the assets to make them work
- As theme developers want to, they can create their own custom assets and disble assets for any cards they support by adding them to the exclude list
- They can also remove any custom code they currently have to support bookmark and gallery cards, and set card_assets: true in package.json to use the defaults instead
2021-11-05 12:20:02 +00:00

54 lines
1.6 KiB
JavaScript

const should = require('should');
const sinon = require('sinon');
const themeConfig = require('../../../../../core/frontend/services/theme-engine/config');
describe('Themes', function () {
afterEach(function () {
sinon.restore();
});
describe('Config', function () {
it('handles no package.json', function () {
const config = themeConfig.create();
config.should.eql({
posts_per_page: 5,
card_assets: {
exclude: ['bookmark', 'gallery']
}
});
});
it('handles package.json without config', function () {
const config = themeConfig.create({name: 'casper'});
config.should.eql({
posts_per_page: 5,
card_assets: {
exclude: ['bookmark', 'gallery']
}
});
});
it('handles allows package.json to override default', function () {
const config = themeConfig.create({name: 'casper', config: {posts_per_page: 3, card_assets: true}});
config.should.eql({
posts_per_page: 3,
card_assets: true
});
});
it('handles ignores non-allowed config', function () {
const config = themeConfig.create({name: 'casper', config: {magic: 'roundabout'}});
config.should.eql({
posts_per_page: 5,
card_assets: {
exclude: ['bookmark', 'gallery']
}
});
});
});
});