Trying to fix Windows tests; one is left broken.

This commit is contained in:
XhmikosR 2016-04-14 09:52:41 +03:00
parent 806ddbe0c0
commit 285f3ec285

View File

@ -2,6 +2,14 @@
var grunt = require('grunt'); var grunt = require('grunt');
function readFile(file) {
var contents = grunt.file.read(file);
if (process.platform === 'win32') {
contents = contents.replace(/\r\n/g, '\n');
}
return contents;
}
exports.jst = { exports.jst = {
main: function(test) { main: function(test) {
@ -9,44 +17,44 @@ exports.jst = {
test.expect(10); test.expect(10);
expect = grunt.file.read('test/expected/jst.js'); expect = readFile('test/expected/jst.js');
result = grunt.file.read('tmp/jst.js'); result = readFile('tmp/jst.js');
test.equal(expect, result, 'should compile underscore templates into JST'); test.equal(expect, result, 'should compile underscore templates into JST');
expect = grunt.file.read('test/expected/uglyfile.js'); expect = readFile('test/expected/uglyfile.js');
result = grunt.file.read('tmp/uglyfile.js'); result = readFile('tmp/uglyfile.js');
test.equal(expect, result, 'should escape single quotes in filenames'); test.equal(expect, result, 'should escape single quotes in filenames');
expect = grunt.file.read('test/expected/ns_nested.js'); expect = readFile('test/expected/ns_nested.js');
result = grunt.file.read('tmp/ns_nested.js'); result = readFile('tmp/ns_nested.js');
test.equal(expect, result, 'should define parts of nested namespaces'); test.equal(expect, result, 'should define parts of nested namespaces');
expect = grunt.file.read('test/expected/ns_nested.js'); // same as previous test expect = readFile('test/expected/ns_nested.js'); // same as previous test
result = grunt.file.read('tmp/ns_nested_this.js'); result = readFile('tmp/ns_nested_this.js');
test.equal(expect, result, 'should define parts of nested namespaces, ignoring this.'); test.equal(expect, result, 'should define parts of nested namespaces, ignoring this.');
expect = grunt.file.read('test/expected/pretty.js'); expect = readFile('test/expected/pretty.js');
result = grunt.file.read('tmp/pretty.js'); result = readFile('tmp/pretty.js');
test.equal(expect, result, 'should make the output be 1 line per template, making the output less ugly'); test.equal(expect, result, 'should make the output be 1 line per template, making the output less ugly');
expect = grunt.file.read('test/expected/amd_wrapper.js'); expect = readFile('test/expected/amd_wrapper.js');
result = grunt.file.read('tmp/amd_wrapper.js'); result = readFile('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'); expect = readFile('test/expected/amd_wrapper_no_ns.js');
result = grunt.file.read('tmp/amd_wrapper_no_ns.js'); result = readFile('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'); 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 = readFile('test/expected/pretty_amd.js');
result = grunt.file.read('tmp/pretty_amd.js'); result = readFile('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');
expect = grunt.file.read('test/expected/process_content.js'); expect = readFile('test/expected/process_content.js');
result = grunt.file.read('tmp/process_content.js'); result = readFile('tmp/process_content.js');
test.equal(expect, result, 'should convert file content'); test.equal(expect, result, 'should convert file content');
expect = grunt.file.read('test/expected/local_scope.js'); expect = readFile('test/expected/local_scope.js');
result = grunt.file.read('tmp/local_scope.js'); result = readFile('tmp/local_scope.js');
test.equal(expect, result, 'should add `with` block when templateSettings.variable is undefined'); test.equal(expect, result, 'should add `with` block when templateSettings.variable is undefined');
test.done(); test.done();