Skip to content

Commit

Permalink
Add test for stream-like sources (#745)
Browse files Browse the repository at this point in the history
  • Loading branch information
ctalkington authored Mar 10, 2024
1 parent f48db1a commit fdac04c
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion test/archiver.js
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -113,13 +114,14 @@ 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();
});

it('should append multiple entries', function() {
assert.isArray(actual);
assert.lengthOf(actual, 3);
assert.lengthOf(actual, 4);
});

it('should append buffer', function() {
Expand All @@ -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', 3632233996);
assert.propertyVal(entries['stream-like.txt'], 'size', 4);
});

it('should append directory', function() {
assert.property(entries, 'directory/');
assert.propertyVal(entries['directory/'], 'name', 'directory/');
Expand Down

0 comments on commit fdac04c

Please sign in to comment.