summaryrefslogtreecommitdiffstats
path: root/spec/precompiler.js
diff options
context:
space:
mode:
authorkpdecker <kpdecker@gmail.com>2014-07-05 14:17:11 -0500
committerkpdecker <kpdecker@gmail.com>2014-07-05 14:39:28 -0500
commit059532295d022c775f6c3e6636a9d6ffce8da728 (patch)
treea9766dd85630be28c24e5f1bd0bd3c7b988640c4 /spec/precompiler.js
parent0c084399e27946c29ead76e870d76a7504e13474 (diff)
downloadhandlebars.js-059532295d022c775f6c3e6636a9d6ffce8da728.zip
handlebars.js-059532295d022c775f6c3e6636a9d6ffce8da728.tar.gz
handlebars.js-059532295d022c775f6c3e6636a9d6ffce8da728.tar.bz2
Move precompiler to safer location
Attempts to avoid some of the Node vs. ES6 confusion between the different styles within the application. Also adds some simple tests in addition to the integration test.
Diffstat (limited to 'spec/precompiler.js')
-rw-r--r--spec/precompiler.js40
1 files changed, 40 insertions, 0 deletions
diff --git a/spec/precompiler.js b/spec/precompiler.js
new file mode 100644
index 0000000..10e2a2e
--- /dev/null
+++ b/spec/precompiler.js
@@ -0,0 +1,40 @@
+/*global shouldThrow */
+
+// NOP Under non-node environments
+if (typeof process === 'undefined') {
+ return;
+}
+
+var Handlebars = require('../lib'),
+ Precompiler = require('../lib/precompiler');
+
+describe('precompiler', function() {
+ 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"');
+ });
+});