1 | var Lab = require('lab');
|
2 | var Moonboots = require('..');
|
3 | var moonboots, beforeBuildJSRan, beforeBuildCSSRan, transformRan;
|
4 |
|
5 | Lab.experiment('development mode', function () {
|
6 | Lab.before(function (done) {
|
7 | var options = {
|
8 | developmentMode: true,
|
9 | main: __dirname + '/../fixtures/app/app.js',
|
10 | jsFileName: 'app',
|
11 | cssFileName: 'app',
|
12 | beforeBuildJS: function (cb) {
|
13 | beforeBuildJSRan = true;
|
14 | cb();
|
15 | },
|
16 | beforeBuildCSS: function (cb) {
|
17 | beforeBuildCSSRan = true;
|
18 | cb();
|
19 | },
|
20 | modulesDir: __dirname + '/../fixtures/modules',
|
21 | browserify: {
|
22 | transforms: [
|
23 | function () {
|
24 | var through = require('through');
|
25 | transformRan = true;
|
26 | return through(
|
27 | function write(data) {
|
28 | this.queue(data);
|
29 | },
|
30 | function _end() {
|
31 | this.queue(null);
|
32 | }
|
33 | );
|
34 | }
|
35 | ]
|
36 | },
|
37 | stylesheets: [
|
38 | __dirname + '/../fixtures/stylesheets/style.css'
|
39 | ]
|
40 | };
|
41 | moonboots = new Moonboots(options);
|
42 | moonboots.on('ready', done);
|
43 | });
|
44 | Lab.test('htmlContext', function (done) {
|
45 | var context = moonboots.htmlContext();
|
46 | Lab.expect(context).to.have.keys('jsFileName', 'cssFileName');
|
47 | Lab.expect(context.jsFileName).to.equal('app.nonCached.js');
|
48 | Lab.expect(context.cssFileName).to.equal('app.nonCached.css');
|
49 | done();
|
50 | });
|
51 | Lab.test('js rebuilds every request', function (done) {
|
52 | beforeBuildJSRan = false;
|
53 | moonboots.jsSource(function (err, js) {
|
54 | Lab.expect(beforeBuildJSRan).to.equal(true);
|
55 | Lab.expect(transformRan).to.equal(true);
|
56 | Lab.expect(js, 'js source').to.contain('"foo"');
|
57 | done();
|
58 | });
|
59 | });
|
60 | Lab.test('css rebuilds every request', function (done) {
|
61 | beforeBuildCSSRan = false;
|
62 | transformRan = false;
|
63 | moonboots.cssSource(function () {
|
64 | Lab.expect(beforeBuildCSSRan).to.equal(true);
|
65 | done();
|
66 | });
|
67 | });
|
68 | });
|
69 |
|