# Code coverage report for spec/precompiler.js

## Statements: 42.86% (9 / 21) Branches: 50% (1 / 2) Functions: 11.11% (1 / 9) Lines: 42.86% (9 / 21) Ignored: none

All files » spec/ » precompiler.js

    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
    41

    3

    3

    3

    3

    3

    3

    3

    3

    3

     /*global shouldThrow */

    describe('precompiler', function() {
      // NOP Under non-node environments
      Iif (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"');
      });
    });