Skip to content

Commit

Permalink
Allow loadScript override for testing getSDK util
Browse files Browse the repository at this point in the history
  • Loading branch information
cookpete committed May 29, 2018
1 parent 1854c99 commit 159b156
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export function queryString (object) {
// Util function to load an external SDK
// or return the SDK if it is already loaded
const resolves = {}
export function getSDK (url, sdkGlobal, sdkReady = null, isLoaded = () => true) {
export function getSDK (url, sdkGlobal, sdkReady = null, isLoaded = () => true, fetchScript = loadScript) {
if (window[sdkGlobal] && isLoaded(window[sdkGlobal])) {
return Promise.resolve(window[sdkGlobal])
}
Expand All @@ -74,7 +74,7 @@ export function getSDK (url, sdkGlobal, sdkReady = null, isLoaded = () => true)
onLoaded(window[sdkGlobal])
}
}
loadScript(url, err => {
fetchScript(url, err => {
if (err) reject(err)
if (!sdkReady) {
onLoaded(window[sdkGlobal])
Expand Down

0 comments on commit 159b156

Please sign in to comment.