@@ -9,23 +9,26 @@ const Readable = require('readable-stream')
9
9
const path = require ( 'path' )
10
10
const isNode = require ( 'detect-node' )
11
11
12
- let testfile
13
- let testfileBig
14
- const testfilePath = path . join ( __dirname , './data/testfile.txt' )
15
-
16
- if ( isNode ) {
17
- const fs = require ( 'fs' )
18
- testfile = fs . readFileSync ( testfilePath )
19
- testfileBig = fs . createReadStream ( path . join ( __dirname , './data/15mb.random' ) , { bufferSize : 128 } )
20
- } else {
21
- testfile = require ( 'raw!./data/testfile.txt' )
22
- }
23
-
24
12
module . exports = ( common ) => {
25
13
describe ( '.files/add' , ( ) => {
14
+ let testfile
15
+ let testfileBig
26
16
let ipfs
27
17
28
18
before ( ( done ) => {
19
+ // load test data
20
+ if ( isNode ) {
21
+ const fs = require ( 'fs' )
22
+
23
+ const testfilePath = path . join ( __dirname , './data/testfile.txt' )
24
+ testfile = fs . readFileSync ( testfilePath )
25
+
26
+ const testfileBigPath = path . join ( __dirname , './data/15mb.random' )
27
+ testfileBig = fs . createReadStream ( testfileBigPath , { bufferSize : 128 } )
28
+ } else {
29
+ testfile = require ( 'raw!./data/testfile.txt' )
30
+ }
31
+
29
32
common . setup ( ( err , _ipfs ) => {
30
33
expect ( err ) . to . not . exist
31
34
ipfs = _ipfs
@@ -101,9 +104,10 @@ module.exports = (common) => {
101
104
expect ( err ) . to . not . exist
102
105
103
106
expect ( res ) . to . have . length ( 1 )
104
- const mh = bs58 . encode ( res [ 0 ] . node . multihash ( ) ) . toString ( )
105
- expect ( mh ) . to . equal ( 'Qmcx5werSWQPdrGVap7LARHB4QUSPRPJwxhFuHvdoXqQXT' )
106
107
expect ( res [ 0 ] . node . links ) . to . have . length ( 58 )
108
+ const mh = bs58 . encode ( res [ 0 ] . node . multihash ( ) ) . toString ( )
109
+ expect ( res [ 0 ] . path ) . to . equal ( mh )
110
+ expect ( mh ) . to . equal ( 'Qme79tX2bViL26vNjPsF3DP1R9rMKMvnPYJiKTTKPrXJjq' )
107
111
done ( )
108
112
} )
109
113
} )
@@ -123,13 +127,9 @@ module.exports = (common) => {
123
127
content ( 'alice.txt' ) ,
124
128
content ( 'files/hello.txt' ) ,
125
129
content ( 'files/ipfs.txt' ) ,
126
- {
127
- path : 'test-folder' ,
128
- dir : true
129
- }
130
130
]
131
131
132
- ipfs . files . add ( dirs , { recursive : true } , ( err , res ) => {
132
+ ipfs . files . add ( dirs , ( err , res ) => {
133
133
expect ( err ) . to . not . exist
134
134
135
135
const added = res [ res . length - 1 ]
0 commit comments