1
1
/*global before,describe,it */
2
2
var fs = require ( 'fs' ) ;
3
3
var PassThrough = require ( 'readable-stream' ) . PassThrough ;
4
+ var Readable = require ( 'readable-stream' ) . Readable ;
4
5
var WriteStream = fs . createWriteStream ;
5
6
6
7
var assert = require ( 'chai' ) . assert ;
@@ -113,13 +114,14 @@ describe('archiver', function() {
113
114
archive
114
115
. append ( testBuffer , { name : 'buffer.txt' , date : testDate } )
115
116
. append ( fs . createReadStream ( 'test/fixtures/test.txt' ) , { name : 'stream.txt' , date : testDate } )
117
+ . append ( Readable . from ( [ 'test' ] ) , { name : 'stream-like.txt' , date : testDate } )
116
118
. append ( null , { name : 'directory/' , date : testDate } )
117
119
. finalize ( ) ;
118
120
} ) ;
119
121
120
122
it ( 'should append multiple entries' , function ( ) {
121
123
assert . isArray ( actual ) ;
122
- assert . lengthOf ( actual , 3 ) ;
124
+ assert . lengthOf ( actual , 4 ) ;
123
125
} ) ;
124
126
125
127
it ( 'should append buffer' , function ( ) {
@@ -142,6 +144,16 @@ describe('archiver', function() {
142
144
assert . propertyVal ( entries [ 'stream.txt' ] , 'size' , 19 ) ;
143
145
} ) ;
144
146
147
+ it ( 'should append stream-like source' , function ( ) {
148
+ assert . property ( entries , 'stream-like.txt' ) ;
149
+ assert . propertyVal ( entries [ 'stream-like.txt' ] , 'name' , 'stream-like.txt' ) ;
150
+ assert . propertyVal ( entries [ 'stream-like.txt' ] , 'type' , 'file' ) ;
151
+ assert . propertyVal ( entries [ 'stream-like.txt' ] , 'date' , '2013-01-03T14:26:38.000Z' ) ;
152
+ assert . propertyVal ( entries [ 'stream-like.txt' ] , 'mode' , 420 ) ;
153
+ assert . propertyVal ( entries [ 'stream-like.txt' ] , 'crc32' , 3632233996 ) ;
154
+ assert . propertyVal ( entries [ 'stream-like.txt' ] , 'size' , 4 ) ;
155
+ } ) ;
156
+
145
157
it ( 'should append directory' , function ( ) {
146
158
assert . property ( entries , 'directory/' ) ;
147
159
assert . propertyVal ( entries [ 'directory/' ] , 'name' , 'directory/' ) ;
0 commit comments