Skip to content

Commit

Permalink
build tests.
Browse files Browse the repository at this point in the history
Adjust compile to clear old templates as we go.
  • Loading branch information
mattyod committed Jul 2, 2014
1 parent 68a02af commit 2239930
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/build.js
Expand Up @@ -18,6 +18,6 @@ module.exports = function (config) {
this.clipboard.files[fileName] = template(index.call(this, config));
}

delete this.clipboard.files.templates;
//delete this.clipboard.files.templates;

};
6 changes: 5 additions & 1 deletion lib/utils/compile.js
Expand Up @@ -13,8 +13,12 @@ module.exports = function (config) {
compiled[name] = engine.compile(template, {
filename: config.templates.path
});

delete this.clipboard.files.templates[name];
}
});
}, this);

delete this.clipboard.files.templates;

return compiled;
};
46 changes: 46 additions & 0 deletions test/unit/lib/build.test.js
@@ -0,0 +1,46 @@
'use strict';

var build = require('../../../lib/build');

describe('lib/buid', function () {
var config;

beforeEach(function () {
config = {
templates: {
lib: 'jade',
suffix: 'jade',
file: 'index'
},
schemas: {
suffix: 'json'
},
target: {
suffix: 'html'
}
};

this.clipboard = {
files: {
templates: {
'foo.jade': 'h1= id',
'bar.jade': 'h1= id'
},
schemas: {
'foo.json': JSON.stringify({ id: 'foo' }),
'bar.json': JSON.stringify({ id: 'bar' })
}
}
};

build.call(this, config);
});

it('sets rendered files to the clipboard', function () {
this.clipboard.files['foo.html']
.should.equal('<h1>foo</h1>');
this.clipboard.files['bar.html']
.should.equal('<h1>bar</h1>');
});

});
4 changes: 4 additions & 0 deletions test/unit/lib/utils/compile.test.js
Expand Up @@ -34,4 +34,8 @@ describe('lib/utils/compile', sandbox(function () {
(typeof compiled['bar.json']).should.equal('function');
});

it('clears the templates from the clipboard', function () {
(this.clipboard.files.templates === undefined).should.be.true;
});

}));

0 comments on commit 2239930

Please sign in to comment.