Merge pull request #19 from colinhicks/fix-tests

Fix tests failing since lodash version bump
This commit is contained in:
Tyler Kellen 2013-02-15 15:56:12 -08:00
commit ffe9197837
13 changed files with 61 additions and 15 deletions

View File

@ -31,12 +31,20 @@ module.exports = function(grunt) {
// Configuration to be run (and then tested).
jst: {
compile: {
options: {
templateSettings: {
variable: 'obj'
}
},
files: {
"tmp/jst.js": ["test/fixtures/template.html"]
}
},
pretty_amd: {
options: {
templateSettings: {
variable: 'obj'
},
prettify: true,
amdWrapper: true
},
@ -46,6 +54,9 @@ module.exports = function(grunt) {
},
prettify: {
options: {
templateSettings: {
variable: 'obj'
},
prettify: true
},
files: {
@ -54,6 +65,9 @@ module.exports = function(grunt) {
},
amd_wrapper: {
options: {
templateSettings: {
variable: 'obj'
},
amdWrapper:true
},
files: {
@ -61,12 +75,20 @@ module.exports = function(grunt) {
}
},
uglyfile: {
options: {
templateSettings: {
variable: 'obj'
},
},
files: {
"tmp/uglyfile.js": ["test/fixtures/*bad-filename*"]
}
},
ns_nested: {
options: {
templateSettings: {
variable: 'obj'
},
namespace: "MyApp.JST.Main"
},
files: {
@ -75,6 +97,9 @@ module.exports = function(grunt) {
},
ns_nested_this: {
options: {
templateSettings: {
variable: 'obj'
},
namespace: "this.MyApp.JST.Main"
},
files: {
@ -83,6 +108,9 @@ module.exports = function(grunt) {
},
process_content: {
options: {
templateSettings: {
variable: 'obj'
},
processContent: function (src) {
return src.replace(/(^\s+|\s+$)/gm, '');
}
@ -90,6 +118,11 @@ module.exports = function(grunt) {
files: {
"tmp/process_content.js": ["test/fixtures/indent_template.html"]
}
},
local_scope: {
files: {
"tmp/local_scope.js": ["test/fixtures/template_local_scope.html"]
}
}
},

View File

@ -3,8 +3,7 @@ define(function(){
this["JST"] = this["JST"] || {};
this["JST"]["test/fixtures/template.html"] = function(obj) {
obj || (obj = {});
var __t, __p = '', __e = _.escape, __d = obj.obj || obj;
var __t, __p = '', __e = _.escape;
__p += '<head><title>' +
((__t = ( obj.title )) == null ? '' : __t) +
'</title></head>';

View File

@ -1,8 +1,7 @@
this["JST"] = this["JST"] || {};
this["JST"]["test/fixtures/template.html"] = function(obj) {
obj || (obj = {});
var __t, __p = '', __e = _.escape, __d = obj.obj || obj;
var __t, __p = '', __e = _.escape;
__p += '<head><title>' +
((__t = ( obj.title )) == null ? '' : __t) +
'</title></head>';

View File

@ -0,0 +1,13 @@
this["JST"] = this["JST"] || {};
this["JST"]["test/fixtures/template_local_scope.html"] = function(obj) {
obj || (obj = {});
var __t, __p = '', __e = _.escape, __d = obj.obj || obj;
with (obj) {
__p += '<head><title>' +
((__t = ( title )) == null ? '' : __t) +
'</title></head>';
}
return __p
};

View File

@ -3,8 +3,7 @@ this["MyApp"]["JST"] = this["MyApp"]["JST"] || {};
this["MyApp"]["JST"]["Main"] = this["MyApp"]["JST"]["Main"] || {};
this["MyApp"]["JST"]["Main"]["test/fixtures/template.html"] = function(obj) {
obj || (obj = {});
var __t, __p = '', __e = _.escape, __d = obj.obj || obj;
var __t, __p = '', __e = _.escape;
__p += '<head><title>' +
((__t = ( obj.title )) == null ? '' : __t) +
'</title></head>';

View File

@ -1,3 +1,3 @@
this["JST"] = this["JST"] || {};
this["JST"]["test/fixtures/template.html"] = function(obj) {obj || (obj = {});var __t, __p = '', __e = _.escape, __d = obj.obj || obj;__p += '<head><title>' +((__t = ( obj.title )) == null ? '' : __t) +'</title></head>';return __p};
this["JST"]["test/fixtures/template.html"] = function(obj) {var __t, __p = '', __e = _.escape;__p += '<head><title>' +((__t = ( obj.title )) == null ? '' : __t) +'</title></head>';return __p};

View File

@ -2,7 +2,7 @@ define(function(){
this["JST"] = this["JST"] || {};
this["JST"]["test/fixtures/template.html"] = function(obj) {obj || (obj = {});var __t, __p = '', __e = _.escape, __d = obj.obj || obj;__p += '<head><title>' +((__t = ( obj.title )) == null ? '' : __t) +'</title></head>';return __p};
this["JST"]["test/fixtures/template.html"] = function(obj) {var __t, __p = '', __e = _.escape;__p += '<head><title>' +((__t = ( obj.title )) == null ? '' : __t) +'</title></head>';return __p};
return this["JST"];
});

View File

@ -1,8 +1,7 @@
this["JST"] = this["JST"] || {};
this["JST"]["test/fixtures/indent_template.html"] = function(obj) {
obj || (obj = {});
var __t, __p = '', __e = _.escape, __d = obj.obj || obj;
var __t, __p = '', __e = _.escape;
__p += '<div>\n<div>\n<div>\n' +
((__t = ( obj.name )) == null ? '' : __t) +
'\n</div>\n</div>\n</div>';

View File

@ -1,8 +1,7 @@
this["JST"] = this["JST"] || {};
this["JST"]["test/fixtures/it's-a-bad-filename.html"] = function(obj) {
obj || (obj = {});
var __t, __p = '', __e = _.escape, __d = obj.obj || obj;
var __t, __p = '', __e = _.escape;
__p += 'never name your file like this.';
return __p
};

View File

@ -1,7 +1,7 @@
<div>
<div>
<div>
<%= name %>
<%= obj.name %>
</div>
</div>
</div>

View File

@ -1 +1 @@
<head><title><%= title %></title></head>
<head><title><%= obj.title %></title></head>

View File

@ -0,0 +1 @@
<head><title><%= title %></title></head>

View File

@ -6,7 +6,7 @@ exports['jst'] = {
var expect, result;
test.expect(8);
test.expect(9);
expect = grunt.file.read("test/expected/jst.js");
result = grunt.file.read("tmp/jst.js");
@ -40,6 +40,10 @@ exports['jst'] = {
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();
}
};