@@ -13,7 +13,7 @@ module.exports = (createCommon, options) => {
13
13
const it = getIt ( options )
14
14
const common = createCommon ( )
15
15
16
- describe ( '.files. add' , function ( ) {
16
+ describe ( '.add' , function ( ) {
17
17
this . timeout ( 40 * 1000 )
18
18
19
19
let ipfs
@@ -36,7 +36,7 @@ module.exports = (createCommon, options) => {
36
36
after ( ( done ) => common . teardown ( done ) )
37
37
38
38
it ( 'should add a Buffer' , ( done ) => {
39
- ipfs . files . add ( fixtures . smallFile . data , ( err , filesAdded ) => {
39
+ ipfs . add ( fixtures . smallFile . data , ( err , filesAdded ) => {
40
40
expect ( err ) . to . not . exist ( )
41
41
42
42
expect ( filesAdded ) . to . have . length ( 1 )
@@ -50,7 +50,7 @@ module.exports = (createCommon, options) => {
50
50
} )
51
51
52
52
it ( 'should add a Buffer (promised)' , ( ) => {
53
- return ipfs . files . add ( fixtures . smallFile . data )
53
+ return ipfs . add ( fixtures . smallFile . data )
54
54
. then ( ( filesAdded ) => {
55
55
const file = filesAdded [ 0 ]
56
56
expect ( file . hash ) . to . equal ( fixtures . smallFile . cid )
@@ -59,7 +59,7 @@ module.exports = (createCommon, options) => {
59
59
} )
60
60
61
61
it ( 'should add a BIG Buffer' , ( done ) => {
62
- ipfs . files . add ( fixtures . bigFile . data , ( err , filesAdded ) => {
62
+ ipfs . add ( fixtures . bigFile . data , ( err , filesAdded ) => {
63
63
expect ( err ) . to . not . exist ( )
64
64
65
65
expect ( filesAdded ) . to . have . length ( 1 )
@@ -80,7 +80,7 @@ module.exports = (createCommon, options) => {
80
80
accumProgress = p
81
81
}
82
82
83
- ipfs . files . add ( fixtures . bigFile . data , { progress : handler } , ( err , filesAdded ) => {
83
+ ipfs . add ( fixtures . bigFile . data , { progress : handler } , ( err , filesAdded ) => {
84
84
expect ( err ) . to . not . exist ( )
85
85
86
86
expect ( filesAdded ) . to . have . length ( 1 )
@@ -97,7 +97,7 @@ module.exports = (createCommon, options) => {
97
97
it ( 'should add a Buffer as tuple' , ( done ) => {
98
98
const tuple = { path : 'testfile.txt' , content : fixtures . smallFile . data }
99
99
100
- ipfs . files . add ( [
100
+ ipfs . add ( [
101
101
tuple
102
102
] , ( err , filesAdded ) => {
103
103
expect ( err ) . to . not . exist ( )
@@ -114,7 +114,7 @@ module.exports = (createCommon, options) => {
114
114
it ( 'should not be able to add by path' , ( done ) => {
115
115
const validPath = path . join ( process . cwd ( ) + '/package.json' )
116
116
117
- ipfs . files . add ( validPath , ( err , res ) => {
117
+ ipfs . add ( validPath , ( err , res ) => {
118
118
expect ( err ) . to . exist ( )
119
119
done ( )
120
120
} )
@@ -127,7 +127,7 @@ module.exports = (createCommon, options) => {
127
127
rs . push ( Buffer . from ( 'some data' ) )
128
128
rs . push ( null )
129
129
130
- ipfs . files . add ( rs , ( err , filesAdded ) => {
130
+ ipfs . add ( rs , ( err , filesAdded ) => {
131
131
expect ( err ) . to . not . exist ( )
132
132
133
133
expect ( filesAdded ) . to . be . length ( 1 )
@@ -148,7 +148,7 @@ module.exports = (createCommon, options) => {
148
148
149
149
const tuple = { path : 'data.txt' , content : rs }
150
150
151
- ipfs . files . add ( [ tuple ] , ( err , filesAdded ) => {
151
+ ipfs . add ( [ tuple ] , ( err , filesAdded ) => {
152
152
expect ( err ) . to . not . exist ( )
153
153
154
154
expect ( filesAdded ) . to . be . length ( 1 )
@@ -163,7 +163,7 @@ module.exports = (createCommon, options) => {
163
163
it ( 'should add pull stream' , ( done ) => {
164
164
const expectedCid = 'QmRf22bZar3WKmojipms22PkXH1MZGmvsqzQtuSvQE3uhm'
165
165
166
- ipfs . files . add ( pull . values ( [ Buffer . from ( 'test' ) ] ) , ( err , res ) => {
166
+ ipfs . add ( pull . values ( [ Buffer . from ( 'test' ) ] ) , ( err , res ) => {
167
167
if ( err ) return done ( err )
168
168
expect ( res ) . to . have . length ( 1 )
169
169
expect ( res [ 0 ] ) . to . deep . equal ( { path : expectedCid , hash : expectedCid , size : 12 } )
@@ -174,7 +174,7 @@ module.exports = (createCommon, options) => {
174
174
it ( 'should add pull stream (promised)' , ( ) => {
175
175
const expectedCid = 'QmRf22bZar3WKmojipms22PkXH1MZGmvsqzQtuSvQE3uhm'
176
176
177
- return ipfs . files . add ( pull . values ( [ Buffer . from ( 'test' ) ] ) )
177
+ return ipfs . add ( pull . values ( [ Buffer . from ( 'test' ) ] ) )
178
178
. then ( ( res ) => {
179
179
expect ( res ) . to . have . length ( 1 )
180
180
expect ( res [ 0 ] ) . to . deep . equal ( { path : expectedCid , hash : expectedCid , size : 12 } )
@@ -184,7 +184,7 @@ module.exports = (createCommon, options) => {
184
184
it ( 'should add array of objects with pull stream content (promised)' , ( ) => {
185
185
const expectedCid = 'QmRf22bZar3WKmojipms22PkXH1MZGmvsqzQtuSvQE3uhm'
186
186
187
- return ipfs . files . add ( [ { content : pull . values ( [ Buffer . from ( 'test' ) ] ) } ] )
187
+ return ipfs . add ( [ { content : pull . values ( [ Buffer . from ( 'test' ) ] ) } ] )
188
188
. then ( ( res ) => {
189
189
expect ( res ) . to . have . length ( 1 )
190
190
expect ( res [ 0 ] ) . to . deep . equal ( { path : expectedCid , hash : expectedCid , size : 12 } )
@@ -210,7 +210,7 @@ module.exports = (createCommon, options) => {
210
210
emptyDir ( 'files/empty' )
211
211
]
212
212
213
- ipfs . files . add ( dirs , ( err , res ) => {
213
+ ipfs . add ( dirs , ( err , res ) => {
214
214
expect ( err ) . to . not . exist ( )
215
215
const root = res [ res . length - 1 ]
216
216
@@ -250,7 +250,7 @@ module.exports = (createCommon, options) => {
250
250
accumProgress += p
251
251
}
252
252
253
- ipfs . files . add ( dirs , { progress : handler } , ( err , filesAdded ) => {
253
+ ipfs . add ( dirs , { progress : handler } , ( err , filesAdded ) => {
254
254
expect ( err ) . to . not . exist ( )
255
255
const root = filesAdded [ filesAdded . length - 1 ]
256
256
@@ -265,7 +265,7 @@ module.exports = (createCommon, options) => {
265
265
it ( 'should fail when passed invalid input' , ( done ) => {
266
266
const nonValid = 'sfdasfasfs'
267
267
268
- ipfs . files . add ( nonValid , ( err , result ) => {
268
+ ipfs . add ( nonValid , ( err , result ) => {
269
269
expect ( err ) . to . exist ( )
270
270
done ( )
271
271
} )
@@ -274,7 +274,7 @@ module.exports = (createCommon, options) => {
274
274
it ( 'should wrap content in a directory' , ( done ) => {
275
275
const data = { path : 'testfile.txt' , content : fixtures . smallFile . data }
276
276
277
- ipfs . files . add ( data , { wrapWithDirectory : true } , ( err , filesAdded ) => {
277
+ ipfs . add ( data , { wrapWithDirectory : true } , ( err , filesAdded ) => {
278
278
expect ( err ) . to . not . exist ( )
279
279
expect ( filesAdded ) . to . have . length ( 2 )
280
280
const file = filesAdded [ 0 ]
@@ -290,7 +290,7 @@ module.exports = (createCommon, options) => {
290
290
this . slow ( 10 * 1000 )
291
291
const content = String ( Math . random ( ) + Date . now ( ) )
292
292
293
- return ipfs . files . add ( Buffer . from ( content ) , { onlyHash : true } )
293
+ return ipfs . add ( Buffer . from ( content ) , { onlyHash : true } )
294
294
. then ( files => {
295
295
expect ( files ) . to . have . length ( 1 )
296
296
0 commit comments