@@ -133,6 +133,54 @@ module.exports = (common) => {
133
133
} )
134
134
} )
135
135
136
+ it ( 'createAddStream' , ( done ) => {
137
+ if ( ! isNode ) {
138
+ return done ( )
139
+ // can't run this test cause browserify
140
+ // can't shim readFileSync in runtime
141
+ }
142
+
143
+ const base = path . join ( __dirname , 'data/test-folder' )
144
+ const content = ( name ) => ( {
145
+ path : `test-folder/${ name } ` ,
146
+ content : fs . readFileSync ( path . join ( base , name ) )
147
+ } )
148
+ const emptyDir = ( name ) => ( {
149
+ path : `test-folder/${ name } `
150
+ } )
151
+
152
+ const files = [
153
+ content ( 'pp.txt' ) ,
154
+ content ( 'holmes.txt' ) ,
155
+ content ( 'jungle.txt' ) ,
156
+ content ( 'alice.txt' ) ,
157
+ emptyDir ( 'empty-folder' ) ,
158
+ content ( 'files/hello.txt' ) ,
159
+ content ( 'files/ipfs.txt' ) ,
160
+ emptyDir ( 'files/empty' )
161
+ ]
162
+
163
+ ipfs . files . createAddStream ( ( err , stream ) => {
164
+ expect ( err ) . to . not . exist
165
+
166
+ stream . on ( 'data' , ( tuple ) => {
167
+ if ( tuple . path === 'test-folder' ) {
168
+ const mh = bs58 . encode ( tuple . node . multihash ( ) ) . toString ( )
169
+ expect ( mh ) . to . equal ( 'QmVvjDy7yF7hdnqE8Hrf4MHo5ABDtb5AbX6hWbD3Y42bXP' )
170
+ expect ( tuple . node . links ) . to . have . length ( 6 )
171
+ }
172
+ } )
173
+
174
+ stream . on ( 'end' , done )
175
+
176
+ files . forEach ( ( file ) => {
177
+ stream . write ( file )
178
+ } )
179
+
180
+ stream . end ( )
181
+ } )
182
+ } )
183
+
136
184
describe ( 'promise' , ( ) => {
137
185
it ( 'buffer' , ( ) => {
138
186
return ipfs . files . add ( smallFile )
0 commit comments