@@ -24,10 +24,10 @@ export function testLs (factory: Factory<KuboNode>, options: MochaConfig): void
24
24
await ipfs . pin . add ( fixtures . directory . cid , { recursive : true } )
25
25
// a file (CID pinned recursively)
26
26
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 } )
28
28
// a single CID (pinned directly)
29
29
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 } )
31
31
} )
32
32
33
33
after ( async function ( ) {
@@ -77,6 +77,7 @@ export function testLs (factory: Factory<KuboNode>, options: MochaConfig): void
77
77
const pinset = await all ( ipfs . pin . ls ( ) )
78
78
79
79
expect ( pinset ) . to . not . be . empty ( )
80
+
80
81
// check the three "roots"
81
82
expect ( pinset ) . to . deep . include ( {
82
83
type : 'recursive' ,
@@ -98,6 +99,11 @@ export function testLs (factory: Factory<KuboNode>, options: MochaConfig): void
98
99
type : 'indirect' ,
99
100
cid : fixtures . directory . files [ 1 ] . cid
100
101
} )
102
+
103
+ // Verify each pin has no name property
104
+ for ( const pin of pinset ) {
105
+ expect ( pin ) . to . not . have . property ( 'name' )
106
+ }
101
107
} )
102
108
103
109
it ( 'should list all direct pins' , async ( ) => {
@@ -174,6 +180,30 @@ export function testLs (factory: Factory<KuboNode>, options: MochaConfig): void
174
180
expect ( cids ) . to . include ( fixtures . files [ 1 ] . cid . toString ( ) )
175
181
} )
176
182
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
+
177
207
it ( 'should throw error for invalid non-string pin type option' , ( ) => {
178
208
// @ts -expect-error wrong pin type
179
209
return expect ( all ( ipfs . pin . ls ( { type : 6 } ) ) )
0 commit comments