@@ -59,7 +59,7 @@ module.exports = (http) => {
59
59
expect ( multibase . isEncoded ( JSON . parse ( res . result ) . Hash ) ) . to . deep . equal ( 'base64' )
60
60
done ( )
61
61
} )
62
- } ) . catch ( err => console . error ( err ) )
62
+ } )
63
63
} )
64
64
65
65
it ( 'should add data without pinning and return a base64 encoded CID' , ( done ) => {
@@ -78,7 +78,7 @@ module.exports = (http) => {
78
78
expect ( multibase . isEncoded ( JSON . parse ( res . result ) . Hash ) ) . to . deep . equal ( 'base64' )
79
79
done ( )
80
80
} )
81
- } ) . catch ( err => console . error ( err ) )
81
+ } )
82
82
} )
83
83
} )
84
84
@@ -120,6 +120,37 @@ module.exports = (http) => {
120
120
121
121
describe ( '/get' , ( ) => { } ) // TODO
122
122
123
- describe ( '/ls' , ( ) => { } ) // TODO
123
+ describe ( '/ls' , ( ) => {
124
+ it ( 'should list directory contents and return a base64 encoded CIDs' , ( done ) => {
125
+ const form = new FormData ( )
126
+ form . append ( 'file' , Buffer . from ( 'TEST' + Date . now ( ) ) , { filename : 'data.txt' } )
127
+ const headers = form . getHeaders ( )
128
+
129
+ streamToPromise ( form ) . then ( ( payload ) => {
130
+ api . inject ( {
131
+ method : 'POST' ,
132
+ url : '/api/v0/add?wrap-with-directory=true' ,
133
+ headers : headers ,
134
+ payload : payload
135
+ } , ( res ) => {
136
+ expect ( res . statusCode ) . to . equal ( 200 )
137
+
138
+ const files = res . result . trim ( ) . split ( '\n' ) . map ( r => JSON . parse ( r ) )
139
+ const dir = files [ files . length - 1 ]
140
+
141
+ api . inject ( {
142
+ method : 'POST' ,
143
+ url : '/api/v0/ls?cid-base=base64&arg=' + dir . Hash
144
+ } , ( res ) => {
145
+ expect ( res . statusCode ) . to . equal ( 200 )
146
+ res . result . Objects . forEach ( item => {
147
+ expect ( multibase . isEncoded ( item . Hash ) ) . to . deep . equal ( 'base64' )
148
+ } )
149
+ done ( )
150
+ } )
151
+ } )
152
+ } )
153
+ } )
154
+ } )
124
155
} )
125
156
}
0 commit comments