@@ -11,16 +11,23 @@ const concat = require('concat-stream')
11
11
const through = require ( 'through2' )
12
12
13
13
module . exports = ( common ) => {
14
- describe ( '.files' , ( ) => {
14
+ describe . only ( '.files' , ( ) => {
15
15
let smallFile
16
16
let bigFile
17
+ let directoryContent
17
18
let ipfs
18
19
19
20
before ( ( done ) => {
20
- smallFile = fs . readFileSync ( path . join ( __dirname , './data/testfile.txt' )
21
- )
22
- bigFile = fs . readFileSync ( path . join ( __dirname , './data/15mb.random' )
23
- )
21
+ smallFile = fs . readFileSync ( path . join ( __dirname , './data/testfile.txt' ) )
22
+ bigFile = fs . readFileSync ( path . join ( __dirname , './data/15mb.random' ) )
23
+ directoryContent = {
24
+ 'pp.txt' : fs . readFileSync ( path . join ( __dirname , './data/test-folder/pp.txt' ) ) ,
25
+ 'holmes.txt' : fs . readFileSync ( path . join ( __dirname , './data/test-folder/holmes.txt' ) ) ,
26
+ 'jungle.txt' : fs . readFileSync ( path . join ( __dirname , './data/test-folder/jungle.txt' ) ) ,
27
+ 'alice.txt' : fs . readFileSync ( path . join ( __dirname , './data/test-folder/alice.txt' ) ) ,
28
+ 'files/hello.txt' : fs . readFileSync ( path . join ( __dirname , './data/test-folder/files/hello.txt' ) ) ,
29
+ 'files/ipfs.txt' : fs . readFileSync ( path . join ( __dirname , './data/test-folder/files/ipfs.txt' ) ) ,
30
+ }
24
31
25
32
common . setup ( ( err , _ipfs ) => {
26
33
expect ( err ) . to . not . exist
@@ -101,15 +108,9 @@ module.exports = (common) => {
101
108
} )
102
109
103
110
it ( 'add a nested dir as array' , ( done ) => {
104
- if ( ! isNode ) {
105
- return done ( )
106
- // can't run this test cause browserify
107
- // can't shim readFileSync in runtime
108
- }
109
- const base = path . join ( __dirname , 'data/test-folder' )
110
111
const content = ( name ) => ( {
111
112
path : `test-folder/${ name } ` ,
112
- content : fs . readFileSync ( path . join ( base , name ) )
113
+ content : directoryContent [ name ]
113
114
} )
114
115
const emptyDir = ( name ) => ( {
115
116
path : `test-folder/${ name } `
@@ -139,16 +140,9 @@ module.exports = (common) => {
139
140
140
141
describe ( '.createAddStream' , ( ) => {
141
142
it ( 'stream of valid files and dirs' , ( done ) => {
142
- if ( ! isNode ) {
143
- return done ( )
144
- // can't run this test cause browserify
145
- // can't shim readFileSync in runtime
146
- }
147
-
148
- const base = path . join ( __dirname , 'data/test-folder' )
149
143
const content = ( name ) => ( {
150
144
path : `test-folder/${ name } ` ,
151
- content : fs . readFileSync ( path . join ( base , name ) )
145
+ content : directoryContent [ name ]
152
146
} )
153
147
const emptyDir = ( name ) => ( {
154
148
path : `test-folder/${ name } `
@@ -175,13 +169,11 @@ module.exports = (common) => {
175
169
expect ( tuple . node . links ) . to . have . length ( 6 )
176
170
}
177
171
} )
178
-
179
172
stream . on ( 'end' , done )
180
173
181
174
files . forEach ( ( file ) => {
182
175
stream . write ( file )
183
176
} )
184
-
185
177
stream . end ( )
186
178
} )
187
179
} )
0 commit comments