@@ -47,7 +47,7 @@ describe(`Electric Integration`, () => {
4747 table : `test_table` ,
4848 } ,
4949 } ,
50- getId : ( item : Row ) => item . id ,
50+ getKey : ( item : Row ) => item . id as number ,
5151 }
5252
5353 // Get the options with utilities
@@ -75,7 +75,7 @@ describe(`Electric Integration`, () => {
7575 ] )
7676
7777 expect ( collection . state ) . toEqual (
78- new Map ( [ [ `KEY:: ${ collection . id } /1` , { id : 1 , name : `Test User` } ] ] )
78+ new Map ( [ [ 1 , { id : 1 , name : `Test User` } ] ] )
7979 )
8080 } )
8181
@@ -107,8 +107,8 @@ describe(`Electric Integration`, () => {
107107
108108 expect ( collection . state ) . toEqual (
109109 new Map ( [
110- [ `KEY:: ${ collection . id } /1` , { id : 1 , name : `Test User` } ] ,
111- [ `KEY:: ${ collection . id } /2` , { id : 2 , name : `Another User` } ] ,
110+ [ 1 , { id : 1 , name : `Test User` } ] ,
111+ [ 2 , { id : 2 , name : `Another User` } ] ,
112112 ] )
113113 )
114114 } )
@@ -140,7 +140,7 @@ describe(`Electric Integration`, () => {
140140 ] )
141141
142142 expect ( collection . state ) . toEqual (
143- new Map ( [ [ `KEY:: ${ collection . id } /1` , { id : 1 , name : `Updated User` } ] ] )
143+ new Map ( [ [ 1 , { id : 1 , name : `Updated User` } ] ] )
144144 )
145145 } )
146146
@@ -161,7 +161,7 @@ describe(`Electric Integration`, () => {
161161 subscriber ( [
162162 {
163163 key : `1` ,
164- value : { id : `1` } ,
164+ value : { id : 1 } ,
165165 headers : { operation : `delete` } ,
166166 } ,
167167 {
@@ -293,7 +293,7 @@ describe(`Electric Integration`, () => {
293293 it ( `should simulate the complete flow` , async ( ) => {
294294 // Create a fake backend store to simulate server-side storage
295295 const fakeBackend = {
296- data : new Map < string , { txid : string ; value : unknown } > ( ) ,
296+ data : new Map < number , { txid : string ; value : unknown } > ( ) ,
297297 // Simulates persisting data to a backend and returning a txid
298298 persist : ( mutations : Array < PendingMutation > ) : Promise < string > => {
299299 const txid = String ( Date . now ( ) )
@@ -316,7 +316,7 @@ describe(`Electric Integration`, () => {
316316 fakeBackend . data . forEach ( ( value , key ) => {
317317 if ( value . txid === txid ) {
318318 messages . push ( {
319- key,
319+ key : key . toString ( ) ,
320320 value : value . value as Row ,
321321 headers : {
322322 operation : `insert` ,
@@ -371,16 +371,16 @@ describe(`Electric Integration`, () => {
371371
372372 await transaction . isPersisted . promise
373373
374- transaction = collection . transactions . state . get ( transaction . id ) !
374+ transaction = collection . transactions . get ( transaction . id ) !
375375
376376 // Verify the mutation function was called correctly
377377 expect ( testMutationFn ) . toHaveBeenCalledTimes ( 1 )
378378
379379 // Check that the data was added to the collection
380380 // Note: In a real implementation, the collection would be updated by the sync process
381381 // This is just verifying our test setup worked correctly
382- expect ( fakeBackend . data . has ( `KEY:: ${ collection . id } /1` ) ) . toBe ( true )
383- expect ( collection . state . has ( `KEY:: ${ collection . id } /1` ) ) . toBe ( true )
382+ expect ( fakeBackend . data . has ( 1 ) ) . toBe ( true )
383+ expect ( collection . has ( 1 ) ) . toBe ( true )
384384 } )
385385 } )
386386
@@ -400,7 +400,7 @@ describe(`Electric Integration`, () => {
400400 table : `test_table` ,
401401 } ,
402402 } ,
403- getId : ( item : Row ) => item . id ,
403+ getKey : ( item : Row ) => item . id as number ,
404404 onInsert,
405405 onUpdate,
406406 onDelete,
@@ -433,7 +433,7 @@ describe(`Electric Integration`, () => {
433433 table : `test_table` ,
434434 } ,
435435 } ,
436- getId : ( item : Row ) => item . id ,
436+ getKey : ( item : Row ) => item . id as number ,
437437 onInsert,
438438 }
439439
@@ -517,7 +517,7 @@ describe(`Electric Integration`, () => {
517517 table : `test_table` ,
518518 } ,
519519 } ,
520- getId : ( item : Row ) => item . id ,
520+ getKey : ( item : Row ) => item . id as number ,
521521 onInsert,
522522 }
523523
@@ -530,28 +530,20 @@ describe(`Electric Integration`, () => {
530530 } )
531531
532532 // If awaitTxId wasn't called automatically, this wouldn't be true.
533- expect ( testCollection . syncedData . state . size ) . toEqual ( 0 )
534- expect (
535- testCollection . optimisticOperations . state . filter ( ( o ) => o . isActive )
536- . length
537- ) . toEqual ( 1 )
533+ expect ( testCollection . syncedData . size ) . toEqual ( 0 )
538534
539535 // Verify that our onInsert handler was called
540536 expect ( onInsert ) . toHaveBeenCalled ( )
541537
542538 await tx . isPersisted . promise
543539
544540 // Verify that the data was added to the collection via the sync process
545- expect ( testCollection . state . has ( `KEY:: ${ testCollection . id } /1` ) ) . toBe ( true )
546- expect ( testCollection . state . get ( `KEY:: ${ testCollection . id } /1` ) ) . toEqual ( {
541+ expect ( testCollection . has ( 1 ) ) . toBe ( true )
542+ expect ( testCollection . get ( 1 ) ) . toEqual ( {
547543 id : 1 ,
548544 name : `Direct Persistence User` ,
549545 } )
550- expect ( testCollection . syncedData . state . size ) . toEqual ( 1 )
551- expect (
552- testCollection . optimisticOperations . state . filter ( ( o ) => o . isActive )
553- . length
554- ) . toEqual ( 0 )
546+ expect ( testCollection . syncedData . size ) . toEqual ( 1 )
555547 } )
556548 } )
557549} )
0 commit comments