@@ -21,6 +21,8 @@ describe('.files (the MFS API part)', function () {
21
21
let ipfs
22
22
let fc
23
23
24
+ const expectedMultihash = 'Qma4hjFTnCasJ8PVp3mZbZK5g2vGDT4LByLJ7m8ciyRFZP'
25
+
24
26
before ( ( done ) => {
25
27
fc = new FactoryClient ( )
26
28
fc . spawnNode ( ( err , node ) => {
@@ -36,8 +38,6 @@ describe('.files (the MFS API part)', function () {
36
38
this . timeout ( 120 * 1000 )
37
39
38
40
it ( 'add file for testing' , ( done ) => {
39
- const expectedMultihash = 'Qma4hjFTnCasJ8PVp3mZbZK5g2vGDT4LByLJ7m8ciyRFZP'
40
-
41
41
ipfs . files . add ( testfile , ( err , res ) => {
42
42
expect ( err ) . to . not . exist ( )
43
43
@@ -49,15 +49,26 @@ describe('.files (the MFS API part)', function () {
49
49
} )
50
50
51
51
it ( 'files.add with cid-version=1 and raw-leaves=false' , ( done ) => {
52
- const expectedHash = 'zdj7Wh9x6gXdg4UAqhRYnjBTw9eJF7hvzUU4HjpnZXHYQz9jK'
52
+ const expectedCid = 'zdj7Wh9x6gXdg4UAqhRYnjBTw9eJF7hvzUU4HjpnZXHYQz9jK'
53
53
const options = { 'cid-version' : 1 , 'raw-leaves' : false }
54
54
55
55
ipfs . files . add ( testfile , options , ( err , res ) => {
56
56
expect ( err ) . to . not . exist ( )
57
57
58
58
expect ( res ) . to . have . length ( 1 )
59
- expect ( res [ 0 ] . hash ) . to . equal ( expectedHash )
60
- expect ( res [ 0 ] . path ) . to . equal ( expectedHash )
59
+ expect ( res [ 0 ] . hash ) . to . equal ( expectedCid )
60
+ expect ( res [ 0 ] . path ) . to . equal ( expectedCid )
61
+ done ( )
62
+ } )
63
+ } )
64
+
65
+ it ( 'files.add with options' , ( done ) => {
66
+ ipfs . files . add ( testfile , { pin : false } , ( err , res ) => {
67
+ expect ( err ) . to . not . exist ( )
68
+
69
+ expect ( res ) . to . have . length ( 1 )
70
+ expect ( res [ 0 ] . hash ) . to . equal ( expectedMultihash )
71
+ expect ( res [ 0 ] . path ) . to . equal ( expectedMultihash )
61
72
done ( )
62
73
} )
63
74
} )
@@ -189,6 +200,15 @@ describe('.files (the MFS API part)', function () {
189
200
describe ( 'Promise API' , function ( ) {
190
201
this . timeout ( 120 * 1000 )
191
202
203
+ it ( 'files.add' , ( ) => {
204
+ return ipfs . files . add ( testfile )
205
+ . then ( ( res ) => {
206
+ expect ( res ) . to . have . length ( 1 )
207
+ expect ( res [ 0 ] . hash ) . to . equal ( expectedMultihash )
208
+ expect ( res [ 0 ] . path ) . to . equal ( expectedMultihash )
209
+ } )
210
+ } )
211
+
192
212
it ( 'files.add with cid-version=1 and raw-leaves=false' , ( ) => {
193
213
const expectedHash = 'zdj7Wh9x6gXdg4UAqhRYnjBTw9eJF7hvzUU4HjpnZXHYQz9jK'
194
214
const options = { 'cid-version' : 1 , 'raw-leaves' : false }
@@ -201,13 +221,25 @@ describe('.files (the MFS API part)', function () {
201
221
} )
202
222
} )
203
223
224
+ it ( 'files.add with options' , ( ) => {
225
+ return ipfs . files . add ( testfile , { pin : false } )
226
+ . then ( ( res ) => {
227
+ expect ( res ) . to . have . length ( 1 )
228
+ expect ( res [ 0 ] . hash ) . to . equal ( expectedMultihash )
229
+ expect ( res [ 0 ] . path ) . to . equal ( expectedMultihash )
230
+ } )
231
+ } )
232
+
204
233
it ( 'files.mkdir' , ( ) => {
205
234
return ipfs . files . mkdir ( '/test-folder' )
206
235
} )
207
236
208
237
it ( 'files.cp' , ( ) => {
209
238
return ipfs . files
210
- . cp ( [ '/ipfs/Qma4hjFTnCasJ8PVp3mZbZK5g2vGDT4LByLJ7m8ciyRFZP' , '/test-folder/test-file' ] )
239
+ . cp ( [
240
+ '/ipfs/Qma4hjFTnCasJ8PVp3mZbZK5g2vGDT4LByLJ7m8ciyRFZP' ,
241
+ '/test-folder/test-file'
242
+ ] )
211
243
} )
212
244
213
245
it ( 'files.ls' , ( ) => {
0 commit comments