0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-02-24 23:48:13 -05:00
ghost/core/test/unit/themes_spec.js
Hannah Wolfe fe90cf2be2 Theme loading part 1 (#7989)
no issue

*  Add new server start & stop events
* 🔥 Get rid of unused availableApps concept
- when we need an API endpoint for a list of apps, we'll build one 😝
*  Move theme loading into a module
- move loading from API method to a module method and use as needed
- wire up read one vs read all as per LTS
- read one (the active theme) on boot, and read the rest after
- fudge validation - this isn't all that helpful
* Settings API tests need to preload themes
- this used to automatically happen as part of loading settings
- now we need to trigger this to happen specifically for this test
2017-02-22 00:26:19 +01:00

42 lines
1.6 KiB
JavaScript

var should = require('should'),
fs = require('fs'),
tmp = require('tmp'),
join = require('path').join,
readThemes = require('../../server/themes/read');
// To stop jshint complaining
should.equal(true, true);
describe('Themes', function () {
describe('Read', function () {
it('should read directory and include only folders', function (done) {
var themesPath = tmp.dirSync({unsafeCleanup: true});
// create trash
fs.writeFileSync(join(themesPath.name, 'casper.zip'));
fs.writeFileSync(join(themesPath.name, '.DS_Store'));
// create actual theme
fs.mkdirSync(join(themesPath.name, 'casper'));
fs.mkdirSync(join(themesPath.name, 'casper', 'partials'));
fs.writeFileSync(join(themesPath.name, 'casper', 'index.hbs'));
fs.writeFileSync(join(themesPath.name, 'casper', 'partials', 'navigation.hbs'));
readThemes.all(themesPath.name)
.then(function (tree) {
tree.should.eql({
casper: {
partials: {
'navigation.hbs': join(themesPath.name, 'casper', 'partials', 'navigation.hbs')
},
'index.hbs': join(themesPath.name, 'casper', 'index.hbs')
}
});
done();
})
.catch(done)
.finally(themesPath.removeCallback);
});
});
});