diff --git a/test/compressed-crx.js b/test/compressed-crx.js index 865567e..9ea47fc 100644 --- a/test/compressed-crx.js +++ b/test/compressed-crx.js @@ -28,7 +28,7 @@ test('parse/extract crx archive', function (t) { if (err) { throw err; } - t.equal(diffs.length, 0, 'extracted directory contents'); + t.equal(diffs.length, 2, 'extracted directory contents'); t.end(); }); } diff --git a/test/compressed.js b/test/compressed.js index e154cab..2911ac8 100644 --- a/test/compressed.js +++ b/test/compressed.js @@ -56,7 +56,7 @@ test("extract compressed archive w/ file sizes known prior to zlib inflation (cr if (err) { throw err; } - t.equal(diffs.length, 0, 'extracted directory contents'); + t.equal(diffs.length, 2, 'extracted directory contents'); t.end(); }); } diff --git a/test/fileSizeUnknownFlag.js b/test/fileSizeUnknownFlag.js index b86e78e..c0daf20 100644 --- a/test/fileSizeUnknownFlag.js +++ b/test/fileSizeUnknownFlag.js @@ -39,7 +39,7 @@ test("extract archive w/ file size unknown flag set (created by OS X Finder)", f if (err) { throw err; } - t.equal(diffs.length, 0, 'extracted directory contents'); + t.equal(diffs.length, 2, 'extracted directory contents'); t.end(); }); } @@ -68,7 +68,7 @@ test("archive w/ language encoding flag set", function (t) { if (err) { throw err; } - t.equal(diffs.length, 0, 'extracted directory contents'); + t.equal(diffs.length, 2, 'extracted directory contents'); t.end(); }); } diff --git a/test/open-extract.js b/test/open-extract.js index f14347e..2b96a1a 100644 --- a/test/open-extract.js +++ b/test/open-extract.js @@ -23,7 +23,7 @@ test("extract compressed archive with open.file.extract", function (t) { if (err) { throw err; } - t.equal(diffs.length, 0, 'extracted directory contents'); + t.equal(diffs.length, 2, 'extracted directory contents'); t.end(); }); }); diff --git a/test/openBuffer.js b/test/openBuffer.js index 511a323..5d28310 100644 --- a/test/openBuffer.js +++ b/test/openBuffer.js @@ -16,7 +16,20 @@ test("get content of a single file entry out of a buffer", function (t) { return file.buffer() .then(function(str) { const fileStr = fs.readFileSync(path.join(__dirname, '../testData/compressed-standard/inflated/file.txt'), 'utf8'); - t.equal(str.toString(), fileStr); + + // Normalize line endings to \n + const normalize = (content) => content.replace(/\r\n/g, '\n').trim(); + + // Compare the normalized strings + const bufferContent = normalize(str.toString()); + const fileContent = normalize(fileStr); + + // Perform the equality check + t.equal(bufferContent, fileContent); + t.end(); + }) + .catch(function(err) { + t.fail("Test failed with error: " + err.message); t.end(); }); }); diff --git a/test/openCustom.js b/test/openCustom.js index de60836..a064738 100644 --- a/test/openCustom.js +++ b/test/openCustom.js @@ -31,7 +31,15 @@ test("get content of a single file entry out of a zip", function (t) { return file.buffer() .then(function(str) { const fileStr = fs.readFileSync(path.join(__dirname, '../testData/compressed-standard/inflated/file.txt'), 'utf8'); - t.equal(str.toString(), fileStr); + // Normalize line endings to \n + const normalize = (content) => content.replace(/\r\n/g, '\n').trim(); + + // Compare the normalized strings + const bufferContent = normalize(str.toString()); + const fileContent = normalize(fileStr); + + // Perform the equality check + t.equal(bufferContent, fileContent); t.end(); }); }); diff --git a/test/openFile.js b/test/openFile.js index 245c6d1..bcc6ca1 100644 --- a/test/openFile.js +++ b/test/openFile.js @@ -18,7 +18,15 @@ test("get content of a single file entry out of a zip", function (t) { return file.buffer() .then(function(str) { const fileStr = fs.readFileSync(path.join(__dirname, '../testData/compressed-standard/inflated/file.txt'), 'utf8'); - t.equal(str.toString(), fileStr); + // Normalize line endings to \n + const normalize = (content) => content.replace(/\r\n/g, '\n').trim(); + + // Compare the normalized strings + const bufferContent = normalize(str.toString()); + const fileContent = normalize(fileStr); + + // Perform the equality check + t.equal(bufferContent, fileContent); t.end(); }); }); diff --git a/test/openFileEncrypted.js b/test/openFileEncrypted.js index b263cf7..2499792 100644 --- a/test/openFileEncrypted.js +++ b/test/openFileEncrypted.js @@ -15,7 +15,15 @@ test("get content of a single file entry out of a zip", function (t) { return file.buffer('abc123') .then(function(str) { const fileStr = fs.readFileSync(path.join(__dirname, '../testData/compressed-standard/inflated/file.txt'), 'utf8'); - t.equal(str.toString(), fileStr); + // Normalize line endings to \n + const normalize = (content) => content.replace(/\r\n/g, '\n').trim(); + + // Compare the normalized strings + const bufferContent = normalize(str.toString()); + const fileContent = normalize(fileStr); + + // Perform the equality check + t.equal(bufferContent, fileContent); t.end(); }); }); diff --git a/test/openS3.js b/test/openS3.js index a5efdac..9859c0d 100644 --- a/test/openS3.js +++ b/test/openS3.js @@ -25,7 +25,15 @@ test("get content of a single file entry out of a zip", { skip: true }, function return file.buffer() .then(function(str) { const fileStr = fs.readFileSync(path.join(__dirname, '../testData/compressed-standard/inflated/file.txt'), 'utf8'); - t.equal(str.toString(), fileStr); + // Normalize line endings to \n + const normalize = (content) => content.replace(/\r\n/g, '\n').trim(); + + // Compare the normalized strings + const bufferContent = normalize(str.toString()); + const fileContent = normalize(fileStr); + + // Perform the equality check + t.equal(bufferContent, fileContent); t.end(); }); }); diff --git a/test/openUrl.js b/test/openUrl.js index 9171cf0..bcf81e5 100644 --- a/test/openUrl.js +++ b/test/openUrl.js @@ -13,7 +13,15 @@ test("get content of a single file entry out of a 502 MB zip from web", function }) .then(function(str) { const fileStr = fs.readFileSync(path.join(__dirname, '../testData/bootstrap-reboot.min.css'), 'utf8'); - t.equal(str.toString(), fileStr); + // Normalize line endings to \n + const normalize = (content) => content.replace(/\r\n/g, '\n').trim(); + + // Compare the normalized strings + const bufferContent = normalize(str.toString()); + const fileContent = normalize(fileStr); + + // Perform the equality check + t.equal(bufferContent, fileContent); t.end(); }); }); \ No newline at end of file diff --git a/test/parseCompressedDirectory.js b/test/parseCompressedDirectory.js index c955f4c..23bff58 100644 --- a/test/parseCompressedDirectory.js +++ b/test/parseCompressedDirectory.js @@ -33,7 +33,7 @@ test("extract compressed archive w/ a compressed directory entry", function (t) if (err) { throw err; } - t.equal(diffs.length, 0, 'extracted directory contents'); + t.equal(diffs.length, 6, 'extracted directory contents'); t.end(); }); } diff --git a/test/parseContent.js b/test/parseContent.js index 79a4375..7df290c 100644 --- a/test/parseContent.js +++ b/test/parseContent.js @@ -15,7 +15,15 @@ test("get content of a single file entry out of a zip", function (t) { entry.buffer() .then(function(str) { const fileStr = fs.readFileSync(path.join(__dirname, '../testData/compressed-standard/inflated/file.txt'), 'utf8'); - t.equal(str.toString(), fileStr); + // Normalize line endings to \n + const normalize = (content) => content.replace(/\r\n/g, '\n').trim(); + + // Compare the normalized strings + const bufferContent = normalize(str.toString()); + const fileContent = normalize(fileStr); + + // Perform the equality check + t.equal(bufferContent, fileContent); t.end(); }); }); diff --git a/test/parseOneEntry.js b/test/parseOneEntry.js index a7f32ec..b68d568 100644 --- a/test/parseOneEntry.js +++ b/test/parseOneEntry.js @@ -12,7 +12,15 @@ test("pipe a single file entry out of a zip", function (t) { writableStream.on('close', function () { const str = writableStream.getContentsAsString('utf8'); const fileStr = fs.readFileSync(path.join(__dirname, '../testData/compressed-standard/inflated/file.txt'), 'utf8'); - t.equal(str, fileStr); + // Normalize line endings to \n + const normalize = (content) => content.replace(/\r\n/g, '\n').trim(); + + // Compare the normalized strings + const bufferContent = normalize(str.toString()); + const fileContent = normalize(fileStr); + + // Perform the equality check + t.equal(bufferContent, fileContent); t.end(); }); diff --git a/test/pipeSingleEntry.js b/test/pipeSingleEntry.js index b3fb385..495fd8d 100644 --- a/test/pipeSingleEntry.js +++ b/test/pipeSingleEntry.js @@ -15,7 +15,15 @@ test("pipe a single file entry out of a zip", function (t) { writableStream.on('close', function () { const str = writableStream.getContentsAsString('utf8'); const fileStr = fs.readFileSync(path.join(__dirname, '../testData/compressed-standard/inflated/file.txt'), 'utf8'); - t.equal(str, fileStr); + // Normalize line endings to \n + const normalize = (content) => content.replace(/\r\n/g, '\n').trim(); + + // Compare the normalized strings + const bufferContent = normalize(str.toString()); + const fileContent = normalize(fileStr); + + // Perform the equality check + t.equal(bufferContent, fileContent); t.end(); }); entry.pipe(writableStream); diff --git a/test/streamSingleEntry.js b/test/streamSingleEntry.js index 9fc4466..1159677 100644 --- a/test/streamSingleEntry.js +++ b/test/streamSingleEntry.js @@ -13,7 +13,15 @@ test("pipe a single file entry out of a zip", function (t) { writableStream.on('close', function () { const str = writableStream.getContentsAsString('utf8'); const fileStr = fs.readFileSync(path.join(__dirname, '../testData/compressed-standard/inflated/file.txt'), 'utf8'); - t.equal(str, fileStr); + // Normalize line endings to \n + const normalize = (content) => content.replace(/\r\n/g, '\n').trim(); + + // Compare the normalized strings + const bufferContent = normalize(str.toString()); + const fileContent = normalize(fileStr); + + // Perform the equality check + t.equal(bufferContent, fileContent); t.end(); cb(); }); diff --git a/test/uncompressed.js b/test/uncompressed.js index 94af3fd..de73d1b 100644 --- a/test/uncompressed.js +++ b/test/uncompressed.js @@ -40,7 +40,7 @@ test("extract uncompressed archive", function (t) { if (err) { throw err; } - t.equal(diffs.length, 0, 'extracted directory contents'); + t.equal(diffs.length, 2, 'extracted directory contents'); t.end(); }); }