@@ -21,6 +21,8 @@ describe('.files (the MFS API part)', function () {
2121 let ipfs
2222 let fc
2323
24+ const expectedMultihash = 'Qma4hjFTnCasJ8PVp3mZbZK5g2vGDT4LByLJ7m8ciyRFZP'
25+
2426 before ( ( done ) => {
2527 fc = new FactoryClient ( )
2628 fc . spawnNode ( ( err , node ) => {
@@ -36,8 +38,6 @@ describe('.files (the MFS API part)', function () {
3638 this . timeout ( 120 * 1000 )
3739
3840 it ( 'add file for testing' , ( done ) => {
39- const expectedMultihash = 'Qma4hjFTnCasJ8PVp3mZbZK5g2vGDT4LByLJ7m8ciyRFZP'
40-
4141 ipfs . files . add ( testfile , ( err , res ) => {
4242 expect ( err ) . to . not . exist ( )
4343
@@ -49,15 +49,26 @@ describe('.files (the MFS API part)', function () {
4949 } )
5050
5151 it ( 'files.add with cid-version=1 and raw-leaves=false' , ( done ) => {
52- const expectedHash = 'zdj7Wh9x6gXdg4UAqhRYnjBTw9eJF7hvzUU4HjpnZXHYQz9jK'
52+ const expectedCid = 'zdj7Wh9x6gXdg4UAqhRYnjBTw9eJF7hvzUU4HjpnZXHYQz9jK'
5353 const options = { 'cid-version' : 1 , 'raw-leaves' : false }
5454
5555 ipfs . files . add ( testfile , options , ( err , res ) => {
5656 expect ( err ) . to . not . exist ( )
5757
5858 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 )
6172 done ( )
6273 } )
6374 } )
@@ -189,6 +200,15 @@ describe('.files (the MFS API part)', function () {
189200 describe ( 'Promise API' , function ( ) {
190201 this . timeout ( 120 * 1000 )
191202
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+
192212 it ( 'files.add with cid-version=1 and raw-leaves=false' , ( ) => {
193213 const expectedHash = 'zdj7Wh9x6gXdg4UAqhRYnjBTw9eJF7hvzUU4HjpnZXHYQz9jK'
194214 const options = { 'cid-version' : 1 , 'raw-leaves' : false }
@@ -201,13 +221,25 @@ describe('.files (the MFS API part)', function () {
201221 } )
202222 } )
203223
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+
204233 it ( 'files.mkdir' , ( ) => {
205234 return ipfs . files . mkdir ( '/test-folder' )
206235 } )
207236
208237 it ( 'files.cp' , ( ) => {
209238 return ipfs . files
210- . cp ( [ '/ipfs/Qma4hjFTnCasJ8PVp3mZbZK5g2vGDT4LByLJ7m8ciyRFZP' , '/test-folder/test-file' ] )
239+ . cp ( [
240+ '/ipfs/Qma4hjFTnCasJ8PVp3mZbZK5g2vGDT4LByLJ7m8ciyRFZP' ,
241+ '/test-folder/test-file'
242+ ] )
211243 } )
212244
213245 it ( 'files.ls' , ( ) => {
0 commit comments