shaman-website-compiler
Version:
Compile raw HTML, CSS and Javascript into the smallest possible, SEO friendly website.
43 lines • 2.04 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
require("mocha");
var chai_1 = require("chai");
var app_composition_1 = require("../composition/app.composition");
var models_1 = require("../models");
var bundle_service_1 = require("./bundle.service");
var compiler_context_spec_1 = require("../data/compiler.context.spec");
describe('BundleService', function () {
beforeEach(function () {
app_composition_1.IoC.snapshot();
app_composition_1.IoC.bind(app_composition_1.TYPES.WebsiteConfig).toConstantValue(new models_1.WebsiteConfig());
});
afterEach(function () {
app_composition_1.IoC.restore();
});
it('updateBundleContent should set bundle content', function (done) {
(0, compiler_context_spec_1.CreateDataContext)(app_composition_1.IoC).then(addTestBundleToContext).then(addTestFilesToContext).then(function (context) {
var subject = new bundle_service_1.BundleService();
subject.updateBundleContent().then(function (_) {
var result = context.models.bundles.find('bundle1');
(0, chai_1.expect)(result.content).to.equal('var $1 = {}var $2 = {}');
done();
});
});
});
});
function addTestBundleToContext(context) {
var bundle = new models_1.Bundle({ name: 'bundle1', type: 'js', files: [], path: '' });
bundle.files = ['script1.js', 'script2.js'];
context.models.bundles.add('bundle1', bundle);
return context.saveChanges().then(function (_) { return (context); });
}
function addTestFilesToContext(context) {
var file1 = new models_1.FileData('script1.js', './script1.js');
var file2 = new models_1.FileData('script2.js', './script2.js');
file1.content = 'var $1 = {}';
file2.content = 'var $2 = {}';
context.models.files.add('script1.js', file1);
context.models.files.add('script2.js', file2);
return context.saveChanges().then(function (_) { return (context); });
}
//# sourceMappingURL=bundle.service.spec.js.map