blob: 7cd1ffd0b158e02274b4ac687c66a19a1324960c (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
|
/*global shouldThrow */
describe('precompiler', function() {
// NOP Under non-node environments
if (typeof process === 'undefined') {
return;
}
var Handlebars = require('../lib'),
Precompiler = require('../lib/precompiler');
var log,
logFunction;
beforeEach(function() {
logFunction = console.log;
log = '';
console.log = function() {
log += Array.prototype.join.call(arguments, '');
};
});
afterEach(function() {
console.log = logFunction;
});
it('should output version', function() {
Precompiler.cli({templates: [], version: true});
equals(log, Handlebars.VERSION);
});
it('should throw if lacking templates', function() {
shouldThrow(function() {
Precompiler.cli({templates: []});
}, Handlebars.Exception, 'Must define at least one template or directory.');
});
it('should throw on missing template', function() {
shouldThrow(function() {
Precompiler.cli({templates: ['foo']});
}, Handlebars.Exception, 'Unable to open template file "foo"');
});
});
|