@@ -177,4 +177,67 @@ describe('ls', () => {
177177 expect ( files . length ) . to . equal ( 1 )
178178 expect ( files . filter ( file => file . name === fileName ) ) . to . be . ok ( )
179179 } )
180+
181+ it ( 'should list a basic entry' , async ( ) => {
182+ const filePath = '/foo.txt'
183+
184+ await fs . writeBytes ( Uint8Array . from ( [ 0 , 1 , 2 , 3 ] ) , filePath , {
185+ rawLeaves : false ,
186+ force : true
187+ } )
188+
189+ const files = await all ( fs . ls ( filePath ) )
190+
191+ expect ( files ) . to . have . nested . property ( '[0].type' )
192+ expect ( files ) . to . have . nested . property ( '[0].content' )
193+
194+ const basicFiles = await all ( fs . ls ( filePath , {
195+ extended : false
196+ } ) )
197+
198+ expect ( basicFiles ) . to . not . have . nested . property ( '[0].type' )
199+ expect ( basicFiles ) . to . not . have . nested . property ( '[0].content' )
200+ } )
201+
202+ it ( 'lists basic files in a directory' , async ( ) => {
203+ const dirName = 'bar'
204+ const dirPath = `/${ dirName } `
205+ const fileName = 'foo.txt'
206+ const filePath = `${ dirPath } /${ fileName } `
207+
208+ await fs . writeBytes ( Uint8Array . from ( [ 0 , 1 , 2 , 3 ] ) , filePath , {
209+ rawLeaves : false ,
210+ force : true
211+ } )
212+
213+ const files = await all ( fs . ls ( dirPath ) )
214+
215+ expect ( files ) . to . have . nested . property ( '[0].type' )
216+ expect ( files ) . to . have . nested . property ( '[0].content' )
217+
218+ const basicFiles = await all ( fs . ls ( dirPath , {
219+ extended : false
220+ } ) )
221+
222+ expect ( basicFiles ) . to . not . have . nested . property ( '[0].type' )
223+ expect ( basicFiles ) . to . not . have . nested . property ( '[0].content' )
224+ } )
225+
226+ it ( 'lists basic contents of a sharded directory' , async ( ) => {
227+ const shardedDirPath = '/sharded-dir'
228+ const shardedDirCid = await createShardedDirectory ( blockstore )
229+ await fs . cp ( shardedDirCid , shardedDirPath )
230+
231+ const files = await all ( fs . ls ( shardedDirPath ) )
232+
233+ expect ( files ) . to . have . nested . property ( '[0].type' )
234+ expect ( files ) . to . have . nested . property ( '[0].content' )
235+
236+ const basicFiles = await all ( fs . ls ( shardedDirPath , {
237+ extended : false
238+ } ) )
239+
240+ expect ( basicFiles ) . to . not . have . nested . property ( '[0].type' )
241+ expect ( basicFiles ) . to . not . have . nested . property ( '[0].content' )
242+ } )
180243} )
0 commit comments