@@ -450,93 +450,6 @@ describe('GunRegistry', () => {
450450 } ) ;
451451 } ) ;
452452
453- describe ( 'sendSignalingMessage' , ( ) => {
454- beforeEach ( ( ) => {
455- registry = new GunRegistry ( ) ;
456- } ) ;
457-
458- it ( 'should throw error when Gun.js is not available' , async ( ) => {
459- ( registry as any ) . isGunAvailable = false ;
460-
461- await expect ( registry . sendSignalingMessage ( 'target-peer' , { test : 'message' } ) )
462- . rejects . toThrow ( 'Gun.js registry not available' ) ;
463- } ) ;
464-
465- it ( 'should send signaling message with timestamp' , async ( ) => {
466- const targetPeer = 'target-peer' ;
467- const message = { test : 'message' , data : 'value' } ;
468-
469- await registry . sendSignalingMessage ( targetPeer , message ) ;
470-
471- expect ( mockGunChain . get ) . toHaveBeenCalledWith ( 'dig-nat-tools' ) ;
472- expect ( mockGunChain . get ) . toHaveBeenCalledWith ( 'signaling' ) ;
473- expect ( mockGunChain . get ) . toHaveBeenCalledWith ( targetPeer ) ;
474- expect ( mockGunChain . put ) . toHaveBeenCalledWith ( {
475- test : 'message' ,
476- data : 'value' ,
477- timestamp : expect . any ( Number )
478- } ) ;
479- } ) ;
480- } ) ;
481-
482- describe ( 'onSignalingMessage' , ( ) => {
483- beforeEach ( ( ) => {
484- registry = new GunRegistry ( ) ;
485- } ) ;
486-
487- it ( 'should warn when Gun.js is not available' , ( ) => {
488- ( registry as any ) . isGunAvailable = false ;
489-
490- const consoleSpy = jest . spyOn ( console , 'warn' ) . mockImplementation ( ) ;
491- const callback = jest . fn ( ) ;
492-
493- registry . onSignalingMessage ( 'test-store-id' , callback ) ;
494-
495- expect ( consoleSpy ) . toHaveBeenCalledWith ( 'Gun.js not available, signaling will not work' ) ;
496- consoleSpy . mockRestore ( ) ;
497- } ) ;
498-
499- it ( 'should set up signaling message listener' , ( ) => {
500- const callback = jest . fn ( ) ;
501- const storeId = 'test-store-id' ;
502-
503- registry . onSignalingMessage ( storeId , callback ) ;
504-
505- expect ( mockGunChain . get ) . toHaveBeenCalledWith ( 'dig-nat-tools' ) ;
506- expect ( mockGunChain . get ) . toHaveBeenCalledWith ( 'signaling' ) ;
507- expect ( mockGunChain . get ) . toHaveBeenCalledWith ( storeId ) ;
508- expect ( mockGunChain . on ) . toHaveBeenCalled ( ) ;
509- } ) ;
510-
511- it ( 'should call callback when message with timestamp is received' , ( ) => {
512- const callback = jest . fn ( ) ;
513- const storeId = 'test-store-id' ;
514- const message = { test : 'message' , timestamp : Date . now ( ) } ;
515-
516- registry . onSignalingMessage ( storeId , callback ) ;
517-
518- // Simulate receiving a message
519- const onCallback = Array . from ( mockOnCallbacks . values ( ) ) [ 0 ] ;
520- if ( onCallback ) onCallback ( message ) ;
521-
522- expect ( callback ) . toHaveBeenCalledWith ( message ) ;
523- } ) ;
524-
525- it ( 'should call callback when message is received' , ( ) => {
526- const callback = jest . fn ( ) ;
527- const storeId = 'test-store-id' ;
528- const message = { test : 'message' } ;
529-
530- registry . onSignalingMessage ( storeId , callback ) ;
531-
532- // Simulate receiving a message
533- const onCallback = Array . from ( mockOnCallbacks . values ( ) ) [ 0 ] ;
534- if ( onCallback ) onCallback ( message ) ;
535-
536- expect ( callback ) . toHaveBeenCalledWith ( message ) ;
537- } ) ;
538- } ) ;
539-
540453 describe ( 'unregister' , ( ) => {
541454 beforeEach ( ( ) => {
542455 registry = new GunRegistry ( ) ;
0 commit comments