@@ -117,5 +117,102 @@ export function testAddAll (factory: Factory<KuboNode>, options: MochaConfig): v
117117 }
118118 } ( ) )
119119 } )
120+
121+ it ( 'should add pins with individual names' , async ( ) => {
122+ const pins = await all ( ipfs . pin . addAll ( [
123+ {
124+ cid : fixtures . files [ 0 ] . cid ,
125+ name : 'pin-1'
126+ } ,
127+ {
128+ cid : fixtures . files [ 1 ] . cid ,
129+ name : 'pin-2'
130+ }
131+ ] ) )
132+
133+ expect ( pins ) . to . have . deep . members ( [
134+ fixtures . files [ 0 ] . cid ,
135+ fixtures . files [ 1 ] . cid
136+ ] )
137+
138+ // Verify names were set (need to use names flag to see them)
139+ const pinList = await all ( ipfs . pin . ls ( { names : true } ) )
140+ const pin1 = pinList . find ( p => p . cid . equals ( fixtures . files [ 0 ] . cid ) )
141+ const pin2 = pinList . find ( p => p . cid . equals ( fixtures . files [ 1 ] . cid ) )
142+
143+ expect ( pin1 ?. name ) . to . equal ( 'pin-1' )
144+ expect ( pin2 ?. name ) . to . equal ( 'pin-2' )
145+ } )
146+
147+ it ( 'should add pins with a global name option' , async ( ) => {
148+ const globalName = 'global-pin-name'
149+ const pins = await all ( ipfs . pin . addAll ( [
150+ fixtures . files [ 0 ] . cid ,
151+ fixtures . files [ 1 ] . cid
152+ ] , { name : globalName } ) )
153+
154+ expect ( pins ) . to . have . deep . members ( [
155+ fixtures . files [ 0 ] . cid ,
156+ fixtures . files [ 1 ] . cid
157+ ] )
158+
159+ // Verify global name was applied (name filter automatically enables names)
160+ const pinList = await all ( ipfs . pin . ls ( { name : globalName } ) )
161+ expect ( pinList ) . to . have . lengthOf ( 2 )
162+ expect ( pinList . map ( p => p . name ) ) . to . deep . equal ( [ globalName , globalName ] )
163+ } )
164+
165+ it ( 'should prioritize individual names over global option' , async ( ) => {
166+ const globalName = 'global-name'
167+ const individualName = 'individual-name'
168+
169+ const pins = await all ( ipfs . pin . addAll ( [
170+ {
171+ cid : fixtures . files [ 0 ] . cid ,
172+ name : individualName
173+ } ,
174+ fixtures . files [ 1 ] . cid
175+ ] , { name : globalName } ) )
176+
177+ expect ( pins ) . to . have . deep . members ( [
178+ fixtures . files [ 0 ] . cid ,
179+ fixtures . files [ 1 ] . cid
180+ ] )
181+
182+ // Verify individual name took precedence (need names flag)
183+ const pinList = await all ( ipfs . pin . ls ( { names : true } ) )
184+ const pin1 = pinList . find ( p => p . cid . equals ( fixtures . files [ 0 ] . cid ) )
185+ const pin2 = pinList . find ( p => p . cid . equals ( fixtures . files [ 1 ] . cid ) )
186+
187+ expect ( pin1 ?. name ) . to . equal ( individualName )
188+ expect ( pin2 ?. name ) . to . equal ( globalName )
189+ } )
190+
191+ it ( 'should add pins without names' , async ( ) => {
192+ const pins = await all ( ipfs . pin . addAll ( [
193+ fixtures . files [ 0 ] . cid ,
194+ fixtures . files [ 1 ] . cid
195+ ] ) )
196+
197+ expect ( pins ) . to . have . deep . members ( [
198+ fixtures . files [ 0 ] . cid ,
199+ fixtures . files [ 1 ] . cid
200+ ] )
201+
202+ // Verify no names were set
203+ // Without names flag, names should be undefined
204+ const pinList = await all ( ipfs . pin . ls ( ) )
205+ const pin1 = pinList . find ( p => p . cid . equals ( fixtures . files [ 0 ] . cid ) )
206+ const pin2 = pinList . find ( p => p . cid . equals ( fixtures . files [ 1 ] . cid ) )
207+ expect ( pin1 ?. name ) . to . be . undefined ( )
208+ expect ( pin2 ?. name ) . to . be . undefined ( )
209+
210+ // Even with names flag, they should still be undefined since no names were set
211+ const pinListWithNames = await all ( ipfs . pin . ls ( { names : true } ) )
212+ const pin1WithNames = pinListWithNames . find ( p => p . cid . equals ( fixtures . files [ 0 ] . cid ) )
213+ const pin2WithNames = pinListWithNames . find ( p => p . cid . equals ( fixtures . files [ 1 ] . cid ) )
214+ expect ( pin1WithNames ?. name ) . to . be . undefined ( )
215+ expect ( pin2WithNames ?. name ) . to . be . undefined ( )
216+ } )
120217 } )
121218}
0 commit comments