-
Notifications
You must be signed in to change notification settings - Fork 59
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Check to see if bundle has been loaded already. Fixes #273
- Loading branch information
Robert-Frampton
authored and
Robert-Frampton
committed
Oct 11, 2017
1 parent
cfe20c6
commit bf01bee
Showing
4 changed files
with
53 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
describe('metal-soy-bundle', function() { | ||
before(function() { | ||
sinon.stub(console, 'warn'); | ||
}); | ||
|
||
after(function() { | ||
console.warn.restore(); | ||
}); | ||
|
||
it('should show warning instead of erroring when loading bundle twice', function(done) { | ||
assert(window.__METAL_SOY_BUNDLE_LOADED__); | ||
assert.equal(console.warn.callCount, 0); | ||
|
||
loadBundle(function() { | ||
assert.equal(console.warn.callCount, 1); | ||
assert(console.warn.calledWith('Warning: metal-soy-bundle has already been loaded. Dedupe bundle to remove this warning.')); | ||
|
||
done(); | ||
}); | ||
}); | ||
}); | ||
|
||
function loadBundle(done) { | ||
var script = document.createElement('script'); | ||
|
||
script.crossOrigin = 'anonymous'; | ||
script.onload = done; | ||
script.src = '/base/packages/metal-soy-bundle/build/bundle.js'; | ||
script.type = 'text/javascript'; | ||
|
||
document.body.appendChild(script); | ||
} |