From ada192298ba88e2c4680ece4c284abe165e786fc Mon Sep 17 00:00:00 2001 From: Chris Talkington Date: Sat, 9 Mar 2024 19:57:09 -0600 Subject: [PATCH] add test for stream-like sources --- test/archiver.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/test/archiver.js b/test/archiver.js index 30a6a445..d5ecd605 100644 --- a/test/archiver.js +++ b/test/archiver.js @@ -1,6 +1,7 @@ /*global before,describe,it */ var fs = require('fs'); var PassThrough = require('readable-stream').PassThrough; +var Readable = require('readable-stream').Readable; var WriteStream = fs.createWriteStream; var assert = require('chai').assert; @@ -113,6 +114,7 @@ describe('archiver', function() { archive .append(testBuffer, { name: 'buffer.txt', date: testDate }) .append(fs.createReadStream('test/fixtures/test.txt'), { name: 'stream.txt', date: testDate }) + .append(Readable.from(['test']), { name: 'stream-like.txt', date: testDate }) .append(null, { name: 'directory/', date: testDate }) .finalize(); }); @@ -142,6 +144,16 @@ describe('archiver', function() { assert.propertyVal(entries['stream.txt'], 'size', 19); }); + it('should append stream-like source', function() { + assert.property(entries, 'stream-like.txt'); + assert.propertyVal(entries['stream-like.txt'], 'name', 'stream-like.txt'); + assert.propertyVal(entries['stream-like.txt'], 'type', 'file'); + assert.propertyVal(entries['stream-like.txt'], 'date', '2013-01-03T14:26:38.000Z'); + assert.propertyVal(entries['stream-like.txt'], 'mode', 420); + assert.propertyVal(entries['stream-like.txt'], 'crc32', 585446183); + assert.propertyVal(entries['stream-like.txt'], 'size', 19); + }); + it('should append directory', function() { assert.property(entries, 'directory/'); assert.propertyVal(entries['directory/'], 'name', 'directory/');