grunt-contrib-jst/test/jst_test.js
2013-11-05 12:08:44 -05:00

54 lines
2.3 KiB
JavaScript

var grunt = require('grunt');
exports['jst'] = {
main: function(test) {
'use strict';
var expect, result;
test.expect(10);
expect = grunt.file.read("test/expected/jst.js");
result = grunt.file.read("tmp/jst.js");
test.equal(expect, result, "should compile underscore templates into JST");
expect = grunt.file.read("test/expected/uglyfile.js");
result = grunt.file.read("tmp/uglyfile.js");
test.equal(expect, result, "should escape single quotes in filenames");
expect = grunt.file.read("test/expected/ns_nested.js");
result = grunt.file.read("tmp/ns_nested.js");
test.equal(expect, result, "should define parts of nested namespaces");
expect = grunt.file.read("test/expected/ns_nested.js"); // same as previous test
result = grunt.file.read("tmp/ns_nested_this.js");
test.equal(expect, result, "should define parts of nested namespaces, ignoring this.");
expect = grunt.file.read("test/expected/pretty.js");
result = grunt.file.read("tmp/pretty.js");
test.equal(expect, result, "should make the output be 1 line per template, making the output less ugly");
expect = grunt.file.read("test/expected/format_amd.js");
result = grunt.file.read("tmp/format_amd.js");
test.equal(expect, result, "should wrap the template with define for AMD pattern");
expect = grunt.file.read("test/expected/format_amd_with_dep.js");
result = grunt.file.read("tmp/format_amd_with_dep.js");
test.equal(expect, result, "should wrap the template with define for AMD pattern and load dependencies");
expect = grunt.file.read("test/expected/format_amd_no_ns.js");
result = grunt.file.read("tmp/format_amd_no_ns.js");
test.equal(expect, result, "should wrap the template with define for AMD pattern and return the function itself with no namespace");
expect = grunt.file.read("test/expected/process_content.js");
result = grunt.file.read("tmp/process_content.js");
test.equal(expect, result, "should convert file content");
expect = grunt.file.read("test/expected/local_scope.js");
result = grunt.file.read("tmp/local_scope.js");
test.equal(expect, result, "should add `with` block when templateSettings.variable is undefined");
test.done();
}
};