File tree Expand file tree Collapse file tree 2 files changed +17
-0
lines changed
Expand file tree Collapse file tree 2 files changed +17
-0
lines changed Original file line number Diff line number Diff line change @@ -155,3 +155,12 @@ test("setScript adds a nonce", () => {
155155 const script = document . head . childNodes [ 0 ] as HTMLScriptElement ;
156156 expect ( script . nonce ) . toBe ( nonce ) ;
157157} ) ;
158+
159+ test ( "loader should resolve immediately when google.maps defined" , async ( ) => {
160+ const loader = new Loader ( { apiKey : "foo" } ) ;
161+ window . google = { maps : { version : "3.*.*" } as any } ;
162+ console . warn = jest . fn ( ) ;
163+ await expect ( loader . loadPromise ( ) ) . resolves . toBeUndefined ( ) ;
164+ delete window . google ;
165+ expect ( console . warn ) . toHaveBeenCalledTimes ( 1 ) ;
166+ } ) ;
Original file line number Diff line number Diff line change @@ -398,6 +398,14 @@ export class Loader {
398398 }
399399
400400 private execute ( ) : void {
401+ if ( window . google && window . google . maps && window . google . maps . version ) {
402+ console . warn (
403+ "Aborted attempt to load Google Maps JS with @googlemaps/js-api-loader." +
404+ "This may result in undesirable behavior as script parameters may not match."
405+ ) ;
406+ this . callback ( ) ;
407+ }
408+
401409 if ( this . done ) {
402410 this . callback ( ) ;
403411 } else {
You can’t perform that action at this time.
0 commit comments