File tree 2 files changed +17
-0
lines changed
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", () => {
155
155
const script = document . head . childNodes [ 0 ] as HTMLScriptElement ;
156
156
expect ( script . nonce ) . toBe ( nonce ) ;
157
157
} ) ;
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 {
398
398
}
399
399
400
400
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
+
401
409
if ( this . done ) {
402
410
this . callback ( ) ;
403
411
} else {
You can’t perform that action at this time.
0 commit comments