@@ -662,6 +662,34 @@ describe('server', () => {
662662 new Parse . Object ( 'TestObject' ) . save ( )
663663 ) . toBeRejected ( ) ;
664664 } ) ;
665+
666+ it ( 'should execute publicServerURL function on every access' , async ( ) => {
667+ let counter = 0 ;
668+ await reconfigureServer ( {
669+ publicServerURL : ( ) => {
670+ counter ++ ;
671+ return `https://server-${ counter } .com/1` ;
672+ } ,
673+ } ) ;
674+
675+ // First request - should call the function
676+ await new Parse . Object ( 'TestObject' ) . save ( ) ;
677+ const config1 = Config . get ( Parse . applicationId ) ;
678+ expect ( config1 . publicServerURL ) . toEqual ( 'https://server-1.com/1' ) ;
679+ expect ( counter ) . toEqual ( 1 ) ;
680+
681+ // Second request - should call the function again
682+ await new Parse . Object ( 'TestObject' ) . save ( ) ;
683+ const config2 = Config . get ( Parse . applicationId ) ;
684+ expect ( config2 . publicServerURL ) . toEqual ( 'https://server-2.com/1' ) ;
685+ expect ( counter ) . toEqual ( 2 ) ;
686+
687+ // Third request - should call the function again
688+ await new Parse . Object ( 'TestObject' ) . save ( ) ;
689+ const config3 = Config . get ( Parse . applicationId ) ;
690+ expect ( config3 . publicServerURL ) . toEqual ( 'https://server-3.com/1' ) ;
691+ expect ( counter ) . toEqual ( 3 ) ;
692+ } ) ;
665693
666694 it ( 'should not reload if ttl is not set' , async ( ) => {
667695 const masterKeySpy = jasmine . createSpy ( ) . and . returnValue ( Promise . resolve ( 'initialMasterKey' ) ) ;
0 commit comments