@@ -24,10 +24,10 @@ export function testLs (factory: Factory<KuboNode>, options: MochaConfig): void
2424 await ipfs . pin . add ( fixtures . directory . cid , { recursive : true } )
2525 // a file (CID pinned recursively)
2626 await ipfs . add ( fixtures . files [ 0 ] . data , { pin : false , cidVersion : 0 } )
27- await ipfs . pin . add ( fixtures . files [ 0 ] . cid , { recursive : true } )
27+ await ipfs . pin . add ( fixtures . files [ 0 ] . cid , { recursive : true , name : fixtures . files [ 0 ] . pinName } )
2828 // a single CID (pinned directly)
2929 await ipfs . add ( fixtures . files [ 1 ] . data , { pin : false , cidVersion : 0 } )
30- await ipfs . pin . add ( fixtures . files [ 1 ] . cid , { recursive : false } )
30+ await ipfs . pin . add ( fixtures . files [ 1 ] . cid , { recursive : false , name : fixtures . files [ 1 ] . pinName } )
3131 } )
3232
3333 after ( async function ( ) {
@@ -77,6 +77,7 @@ export function testLs (factory: Factory<KuboNode>, options: MochaConfig): void
7777 const pinset = await all ( ipfs . pin . ls ( ) )
7878
7979 expect ( pinset ) . to . not . be . empty ( )
80+
8081 // check the three "roots"
8182 expect ( pinset ) . to . deep . include ( {
8283 type : 'recursive' ,
@@ -98,6 +99,11 @@ export function testLs (factory: Factory<KuboNode>, options: MochaConfig): void
9899 type : 'indirect' ,
99100 cid : fixtures . directory . files [ 1 ] . cid
100101 } )
102+
103+ // Verify each pin has no name property
104+ for ( const pin of pinset ) {
105+ expect ( pin ) . to . not . have . property ( 'name' )
106+ }
101107 } )
102108
103109 it ( 'should list all direct pins' , async ( ) => {
@@ -174,6 +180,30 @@ export function testLs (factory: Factory<KuboNode>, options: MochaConfig): void
174180 expect ( cids ) . to . include ( fixtures . files [ 1 ] . cid . toString ( ) )
175181 } )
176182
183+ it ( 'should list multiple partially matched named pins' , async ( ) => {
184+ const pinset = await all ( ipfs . pin . ls ( {
185+ name : 'file'
186+ } ) )
187+ expect ( pinset ) . to . have . lengthOf ( 2 )
188+ const cids = pinset . map ( p => p . cid . toString ( ) )
189+ expect ( cids ) . to . include ( fixtures . files [ 0 ] . cid . toString ( ) )
190+ expect ( cids ) . to . include ( fixtures . files [ 1 ] . cid . toString ( ) )
191+ const names = pinset . map ( p => p . name )
192+ expect ( names ) . to . include ( fixtures . files [ 0 ] . pinName )
193+ expect ( names ) . to . include ( fixtures . files [ 1 ] . pinName )
194+ } )
195+
196+ it ( 'should list specific named pin' , async ( ) => {
197+ const pinset = await all ( ipfs . pin . ls ( {
198+ name : fixtures . files [ 0 ] . pinName
199+ } ) )
200+ expect ( pinset ) . to . have . lengthOf ( 1 )
201+ const cids = pinset . map ( p => p . cid . toString ( ) )
202+ expect ( cids ) . to . include ( fixtures . files [ 0 ] . cid . toString ( ) )
203+ const names = pinset . map ( p => p . name )
204+ expect ( names ) . to . include ( fixtures . files [ 0 ] . pinName )
205+ } )
206+
177207 it ( 'should throw error for invalid non-string pin type option' , ( ) => {
178208 // @ts -expect-error wrong pin type
179209 return expect ( all ( ipfs . pin . ls ( { type : 6 } ) ) )
0 commit comments