Code coverage report for spec/spec.js

Statements: 76.19% (16 / 21)      Branches: 73.33% (11 / 15)      Functions: 83.33% (5 / 6)      Lines: 76.19% (16 / 21)      Ignored: none     

All files » spec/ » spec.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 42 43 44 45 46 47 48 49 503   3       3       3 3 42     3 21 21     366                 30 78 78     288 288       288                    
describe('spec', function() {
  // NOP Under non-node environments
  Iif (typeof process === 'undefined') {
    return;
  }
 
  var _ = require('underscore'),
      Handlebars = require('../lib'),
      fs = require('fs');
 
  var specDir =__dirname + '/mustache/specs/';
  var specs = _.filter(fs.readdirSync(specDir), function(name) {
    return /.*\.json$/.test(name);
  });
 
  _.each(specs, function(name) {
    var spec = require(specDir + name);
    _.each(spec.tests, function(test) {
      // Our lambda implementation knowingly deviates from the optional Mustace lambda spec
      // We also do not support alternative delimeters
      if (name === '~lambdas.json'
 
          // We also choose to throw if paritals are not found
          || (name === 'partials.json' && test.name === 'Failed Lookup')
 
          // We nest the entire response from partials, not just the literals
          || (name === 'partials.json' && test.name === 'Standalone Indentation')
 
          || /\{\{\=/.test(test.template)
          || _.any(test.partials, function(partial) { return /\{\{\=/.test(partial); })) {
        it.skip(name + ' - ' + test.name);
        return;
      }
 
      var data = _.clone(test.data);
      Iif (data.lambda) {
        // Blergh
        data.lambda = eval('(' + data.lambda.js + ')');
      }
      it(name + ' - ' + test.name, function() {
        if (test.partials) {
          shouldCompileToWithPartials(test.template, [data, {}, test.partials, true], true, test.expected, test.desc + ' "' + test.template + '"');
        } else {
          shouldCompileTo(test.template, [data, {}, {}, true], test.expected, test.desc + ' "' + test.template + '"');
        }
      });
    });
  });
});