@@ -471,25 +471,25 @@ describe.each([
471471 // Create a new electric collection with on-demand syncMode for this test
472472 vi . clearAllMocks ( )
473473
474- const testSubscriber = vi . fn < ( messages : Array < Message < User > > ) => void > ( )
474+ let testSubscriber : ( messages : Array < Message < User > > ) => void = ( ) => { }
475475 mockSubscribe . mockImplementation ( ( callback ) => {
476- testSubscriber . mockImplementation ( callback )
476+ testSubscriber = callback
477477 return ( ) => { }
478478 } )
479479
480- const testElectricCollection = createCollection ( {
481- ... electricCollectionOptions ( {
480+ const testElectricCollection = createCollection (
481+ electricCollectionOptions ( {
482482 id : `test-incremental-loading` ,
483483 shapeOptions : {
484484 url : `http://test-url` ,
485485 params : { table : `users` } ,
486486 } ,
487487 syncMode : `on-demand` ,
488488 getKey : ( user : User ) => user . id ,
489- } ) ,
490- startSync : true ,
491- autoIndex : `eager` as const ,
492- } )
489+ startSync : true ,
490+ autoIndex : `eager` as const ,
491+ } )
492+ )
493493
494494 mockRequestSnapshot . mockResolvedValue ( {
495495 data : [ ] ,
@@ -718,8 +718,15 @@ describe(`Electric Collection with Live Query - syncMode integration`, () => {
718718 // Wait for the live query to process
719719 await new Promise ( ( resolve ) => setTimeout ( resolve , 0 ) )
720720
721- // Should have requested more data from Electric
722- expect ( mockRequestSnapshot ) . toHaveBeenCalled ( )
721+ // Should have requested more data from Electric with correct parameters
722+ expect ( mockRequestSnapshot ) . toHaveBeenCalledWith (
723+ expect . objectContaining ( {
724+ limit : 5 , // Requests full limit from Electric
725+ orderBy : `age NULLS FIRST` ,
726+ where : `active = $1` ,
727+ params : { 1 : `true` } , // Parameters are stringified
728+ } )
729+ )
723730 expect ( liveQuery . size ) . toBeGreaterThan ( 2 )
724731 } )
725732
@@ -757,8 +764,15 @@ describe(`Electric Collection with Live Query - syncMode integration`, () => {
757764 // Wait for the live query to process
758765 await new Promise ( ( resolve ) => setTimeout ( resolve , 0 ) )
759766
760- // Should have requested more data from Electric
761- expect ( mockRequestSnapshot ) . toHaveBeenCalled ( )
767+ // Should have requested more data from Electric with correct parameters
768+ // First request asks for the full limit
769+ expect ( mockRequestSnapshot ) . toHaveBeenCalledWith (
770+ expect . objectContaining ( {
771+ limit : 3 , // Requests full limit from Electric
772+ orderBy : `id NULLS FIRST` ,
773+ params : { } ,
774+ } )
775+ )
762776 } )
763777
764778 it ( `should NOT trigger requestSnapshot in eager mode even when live query needs more data` , async ( ) => {
0 commit comments