@@ -9,7 +9,7 @@ interface TestItem {
99 value ?: number
1010}
1111
12- const getPrimaryKey = ( item : TestItem ) => item . id
12+ const getId = ( item : TestItem ) => item . id
1313
1414// Helper to advance timers and allow microtasks to flush
1515const flushPromises = ( ) => new Promise ( ( resolve ) => setTimeout ( resolve , 0 ) )
@@ -49,7 +49,7 @@ describe(`QueryCollection`, () => {
4949 queryClient,
5050 queryKey,
5151 queryFn,
52- getPrimaryKey ,
52+ getId ,
5353 }
5454
5555 const collection = createQueryCollection ( config )
@@ -100,7 +100,7 @@ describe(`QueryCollection`, () => {
100100 queryClient,
101101 queryKey,
102102 queryFn,
103- getPrimaryKey ,
103+ getId ,
104104 }
105105
106106 const collection = createQueryCollection ( config )
@@ -168,7 +168,7 @@ describe(`QueryCollection`, () => {
168168 queryClient,
169169 queryKey,
170170 queryFn,
171- getPrimaryKey ,
171+ getId ,
172172 retry : 0 , // Disable retries for this test case
173173 } )
174174
@@ -217,7 +217,7 @@ describe(`QueryCollection`, () => {
217217 queryClient,
218218 queryKey,
219219 queryFn,
220- getPrimaryKey ,
220+ getId ,
221221 } )
222222
223223 // Wait for the query to execute
@@ -264,7 +264,7 @@ describe(`QueryCollection`, () => {
264264 queryClient,
265265 queryKey,
266266 queryFn,
267- getPrimaryKey ,
267+ getId ,
268268 } )
269269
270270 // Wait for initial data to load
@@ -320,7 +320,7 @@ describe(`QueryCollection`, () => {
320320 consoleSpy . mockRestore ( )
321321 } )
322322
323- it ( `should use the provided getPrimaryKey function to identify items` , async ( ) => {
323+ it ( `should use the provided getId function to identify items` , async ( ) => {
324324 const queryKey = [ `customKeyTest` ]
325325
326326 // Items with a non-standard ID field
@@ -331,15 +331,15 @@ describe(`QueryCollection`, () => {
331331
332332 const queryFn = vi . fn ( ) . mockResolvedValue ( items )
333333
334- // Create a spy for the getPrimaryKey function
335- const getPrimaryKeySpy = vi . fn ( ( item : any ) => item . customId )
334+ // Create a spy for the getId function
335+ const getIdSpy = vi . fn ( ( item : any ) => item . customId )
336336
337337 const collection = createQueryCollection ( {
338338 id : `test` ,
339339 queryClient,
340340 queryKey,
341341 queryFn,
342- getPrimaryKey : getPrimaryKeySpy ,
342+ getId : getIdSpy ,
343343 } )
344344
345345 // Wait for initial data to load
@@ -348,10 +348,10 @@ describe(`QueryCollection`, () => {
348348 expect ( collection . state . size ) . toBe ( items . length )
349349 } )
350350
351- // Verify getPrimaryKey was called for each item
352- expect ( getPrimaryKeySpy ) . toHaveBeenCalledTimes ( items . length )
351+ // Verify getId was called for each item
352+ expect ( getIdSpy ) . toHaveBeenCalledTimes ( items . length )
353353 items . forEach ( ( item ) => {
354- expect ( getPrimaryKeySpy ) . toHaveBeenCalledWith ( item )
354+ expect ( getIdSpy ) . toHaveBeenCalledWith ( item )
355355 } )
356356
357357 // Verify items are stored with the custom keys
@@ -368,7 +368,7 @@ describe(`QueryCollection`, () => {
368368 ]
369369
370370 // Reset the spy to track new calls
371- getPrimaryKeySpy . mockClear ( )
371+ getIdSpy . mockClear ( )
372372 queryFn . mockResolvedValueOnce ( updatedItems )
373373
374374 // Trigger a refetch
@@ -380,11 +380,11 @@ describe(`QueryCollection`, () => {
380380 expect ( collection . state . size ) . toBe ( updatedItems . length )
381381 } )
382382
383- // Verify getPrimaryKey was called at least once for each item
383+ // Verify getId was called at least once for each item
384384 // It may be called multiple times per item during the diffing process
385- expect ( getPrimaryKeySpy ) . toHaveBeenCalled ( )
385+ expect ( getIdSpy ) . toHaveBeenCalled ( )
386386 updatedItems . forEach ( ( item ) => {
387- expect ( getPrimaryKeySpy ) . toHaveBeenCalledWith ( item )
387+ expect ( getIdSpy ) . toHaveBeenCalledWith ( item )
388388 } )
389389
390390 // Verify the state reflects the changes
0 commit comments