2020-04-29 18:44:27 +03:00
|
|
|
const should = require('should');
|
|
|
|
const sinon = require('sinon');
|
2021-10-06 12:52:46 +03:00
|
|
|
const themeConfig = require('../../../../../core/frontend/services/theme-engine/config');
|
2017-03-22 09:52:58 +03:00
|
|
|
|
|
|
|
describe('Themes', function () {
|
|
|
|
afterEach(function () {
|
2019-01-21 19:53:44 +03:00
|
|
|
sinon.restore();
|
2017-03-22 09:52:58 +03:00
|
|
|
});
|
|
|
|
|
|
|
|
describe('Config', function () {
|
|
|
|
it('handles no package.json', function () {
|
2020-04-29 18:44:27 +03:00
|
|
|
const config = themeConfig.create();
|
2017-03-22 09:52:58 +03:00
|
|
|
|
2021-10-13 10:45:56 +03:00
|
|
|
config.should.eql({
|
|
|
|
posts_per_page: 5,
|
2021-10-19 19:33:20 +03:00
|
|
|
card_assets: {
|
|
|
|
exclude: ['bookmark', 'gallery']
|
|
|
|
}
|
2021-10-13 10:45:56 +03:00
|
|
|
});
|
2017-03-22 09:52:58 +03:00
|
|
|
});
|
|
|
|
|
|
|
|
it('handles package.json without config', function () {
|
2020-04-29 18:44:27 +03:00
|
|
|
const config = themeConfig.create({name: 'casper'});
|
2017-03-22 09:52:58 +03:00
|
|
|
|
2021-10-13 10:45:56 +03:00
|
|
|
config.should.eql({
|
|
|
|
posts_per_page: 5,
|
2021-10-19 19:33:20 +03:00
|
|
|
card_assets: {
|
|
|
|
exclude: ['bookmark', 'gallery']
|
|
|
|
}
|
2021-10-13 10:45:56 +03:00
|
|
|
});
|
2017-03-22 09:52:58 +03:00
|
|
|
});
|
|
|
|
|
2021-10-19 19:33:20 +03:00
|
|
|
it('handles allows package.json to override default', function () {
|
|
|
|
const config = themeConfig.create({name: 'casper', config: {posts_per_page: 3, card_assets: true}});
|
2017-03-22 09:52:58 +03:00
|
|
|
|
2021-10-13 10:45:56 +03:00
|
|
|
config.should.eql({
|
|
|
|
posts_per_page: 3,
|
2021-10-19 19:33:20 +03:00
|
|
|
card_assets: true
|
2021-10-13 10:45:56 +03:00
|
|
|
});
|
2017-03-22 09:52:58 +03:00
|
|
|
});
|
|
|
|
|
|
|
|
it('handles ignores non-allowed config', function () {
|
2020-04-29 18:44:27 +03:00
|
|
|
const config = themeConfig.create({name: 'casper', config: {magic: 'roundabout'}});
|
2017-03-22 09:52:58 +03:00
|
|
|
|
2021-10-13 10:45:56 +03:00
|
|
|
config.should.eql({
|
|
|
|
posts_per_page: 5,
|
2021-10-19 19:33:20 +03:00
|
|
|
card_assets: {
|
|
|
|
exclude: ['bookmark', 'gallery']
|
|
|
|
}
|
2021-10-13 10:45:56 +03:00
|
|
|
});
|
2017-03-22 09:52:58 +03:00
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|