From 22c19fe1d0e0f02abbf263b915635c6469df515a Mon Sep 17 00:00:00 2001 From: bartland Date: Sat, 31 Oct 2015 12:36:12 +1100 Subject: [PATCH] move.test modified to support testing files with both LF (NIX) and CRLF (Windows) line endings. This commit fixes #188. --- lib/move/__tests__/move.test.js | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/lib/move/__tests__/move.test.js b/lib/move/__tests__/move.test.js index df6c8e87..67e137d1 100644 --- a/lib/move/__tests__/move.test.js +++ b/lib/move/__tests__/move.test.js @@ -60,8 +60,9 @@ describe('move', function () { fse.move(src, dest, function (err) { assert.ifError(err) fs.readFile(dest, 'utf8', function (err, contents) { + var expected = /^sonic the hedgehog\r?\n$/ assert.ifError(err) - assert.strictEqual(contents, 'sonic the hedgehog\n') + assert.ok(contents.match(expected), contents + ' match ' + expected) done() }) }) @@ -103,8 +104,9 @@ describe('move', function () { fse.move(src, dest, function (err) { assert.ifError(err) fs.readFile(dest, 'utf8', function (err, contents) { + var expected = /^sonic the hedgehog\r?\n$/ assert.ifError(err) - assert.strictEqual(contents, 'sonic the hedgehog\n') + assert.ok(contents.match(expected), contents + ' match ' + expected) done() }) }) @@ -121,8 +123,9 @@ describe('move', function () { assert.strictEqual(fs.link.callCount, 1) fs.readFile(dest, 'utf8', function (err, contents) { + var expected = /^sonic the hedgehog\r?\n$/ assert.ifError(err) - assert.strictEqual(contents, 'sonic the hedgehog\n') + assert.ok(contents.match(expected), contents + ' match ' + expected) tearDownMockFs() done() @@ -140,8 +143,9 @@ describe('move', function () { fse.move(src, dest, function (err) { assert.ifError(err) fs.readFile(dest + '/another-file', 'utf8', function (err, contents) { + var expected = /^tails\r?\n$/ assert.ifError(err) - assert.strictEqual(contents, 'tails\n') + assert.ok(contents.match(expected), contents + ' match ' + expected) done() }) }) @@ -158,8 +162,9 @@ describe('move', function () { assert.strictEqual(fs.link.callCount, 1) fs.readFile(dest + '/another-folder/file3', 'utf8', function (err, contents) { + var expected = /^knuckles\r?\n$/ assert.ifError(err) - assert.strictEqual(contents, 'knuckles\n') + assert.ok(contents.match(expected), contents + ' match ' + expected) tearDownMockFs('EISDIR') @@ -181,8 +186,9 @@ describe('move', function () { assert.strictEqual(fs.rename.callCount, 1) fs.readFile(dest + '/another-folder/file3', 'utf8', function (err, contents) { + var expected = /^knuckles\r?\n$/ assert.ifError(err) - assert.strictEqual(contents, 'knuckles\n') + assert.ok(contents.match(expected), contents + ' match ' + expected) tearDownMockFs('EXDEV') @@ -202,8 +208,9 @@ describe('move', function () { assert.strictEqual(fs.link.callCount, 1) fs.readFile(dest + '/another-folder/file3', 'utf8', function (err, contents) { + var expected = /^knuckles\r?\n$/ assert.ifError(err) - assert.strictEqual(contents, 'knuckles\n') + assert.ok(contents.match(expected), contents + ' match ' + expected) tearDownMockFs()