Fixed the tests for the AMD-no-Namespace improvement

This commit is contained in:
Adrien Antoine 2013-03-06 13:56:40 +00:00
parent 4a4e1734bf
commit efee77f83c
6 changed files with 31 additions and 2 deletions

View File

@ -74,6 +74,18 @@ module.exports = function(grunt) {
"tmp/amd_wrapper.js": ["test/fixtures/template.html"] "tmp/amd_wrapper.js": ["test/fixtures/template.html"]
} }
}, },
amd_wrapper_no_ns: {
options: {
templateSettings: {
variable: 'obj'
},
amdWrapper:true,
namespace:false
},
files: {
"tmp/amd_wrapper_no_ns.js": ["test/fixtures/template.html"]
}
},
uglyfile: { uglyfile: {
options: { options: {
templateSettings: { templateSettings: {

View File

@ -83,7 +83,7 @@ module.exports = function(grunt) {
if (options.namespace !== false) { if (options.namespace !== false) {
// Namespace has not been explicitly set to false; the AMD // Namespace has not been explicitly set to false; the AMD
// wrapper will return the object containing the template. // wrapper will return the object containing the template.
output.push(" return " + nsInfo.namespace + ";" + lf); output.push(" return " + nsInfo.namespace + ";");
} }
output.push("});"); output.push("});");
} }

View File

@ -11,4 +11,5 @@ return __p
}; };
return this["JST"]; return this["JST"];
}); });

View File

@ -0,0 +1,11 @@
define(function(){
return function(obj) {
var __t, __p = '', __e = _.escape;
__p += '<head><title>' +
((__t = ( obj.title )) == null ? '' : __t) +
'</title></head>';
return __p
}
});

View File

@ -5,4 +5,5 @@ define(function(){
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}; 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"]; return this["JST"];
}); });

View File

@ -6,7 +6,7 @@ exports['jst'] = {
var expect, result; var expect, result;
test.expect(9); test.expect(10);
expect = grunt.file.read("test/expected/jst.js"); expect = grunt.file.read("test/expected/jst.js");
result = grunt.file.read("tmp/jst.js"); result = grunt.file.read("tmp/jst.js");
@ -32,6 +32,10 @@ exports['jst'] = {
result = grunt.file.read("tmp/amd_wrapper.js"); result = grunt.file.read("tmp/amd_wrapper.js");
test.equal(expect, result, "should wrap the template with define for AMD pattern"); test.equal(expect, result, "should wrap the template with define for AMD pattern");
expect = grunt.file.read("test/expected/amd_wrapper_no_ns.js");
result = grunt.file.read("tmp/amd_wrapper_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/pretty_amd.js"); expect = grunt.file.read("test/expected/pretty_amd.js");
result = grunt.file.read("tmp/pretty_amd.js"); result = grunt.file.read("tmp/pretty_amd.js");
test.equal(expect, result, "should make the AMD wrapper output pretty"); test.equal(expect, result, "should make the AMD wrapper output pretty");