diff options
| author | Sascha <[email protected]> | 2020-11-01 14:32:36 +0100 |
|---|---|---|
| committer | GitHub <[email protected]> | 2020-11-01 15:32:36 +0200 |
| commit | c21506d499c682ea5e31107ce264b224c4bb644d (patch) | |
| tree | c2f0ec5f54fb64bde3db98d090485d88b51e0960 /js/tests | |
| parent | 3a5f9f5cf004ff02eca0b1680b461b79dd61d980 (diff) | |
| download | bootstrap-c21506d499c682ea5e31107ce264b224c4bb644d.tar.xz bootstrap-c21506d499c682ea5e31107ce264b224c4bb644d.zip | |
Fix TypeError when Bootstrap is included in `head` (#32024)
* extend jquery after domContentLoaded event is fired
* add unittest for util onDOMContentLoaded
* wait for trigger jquery event after domContentLoaded
* remove domcontentready from eventHandler
* move istanbul ignore statements to correct line
Co-authored-by: XhmikosR <[email protected]>
Diffstat (limited to 'js/tests')
| -rw-r--r-- | js/tests/unit/util/index.spec.js | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/js/tests/unit/util/index.spec.js b/js/tests/unit/util/index.spec.js index 541c10baa..f7cc37977 100644 --- a/js/tests/unit/util/index.spec.js +++ b/js/tests/unit/util/index.spec.js @@ -394,4 +394,23 @@ describe('Util', () => { expect(Util.getjQuery()).toEqual(null) }) }) + + describe('onDOMContentLoaded', () => { + it('should execute callback when DOMContentLoaded is fired', () => { + const spy = jasmine.createSpy() + spyOnProperty(document, 'readyState').and.returnValue('loading') + Util.onDOMContentLoaded(spy) + window.document.dispatchEvent(new Event('DOMContentLoaded', { + bubbles: true, + cancelable: true + })) + expect(spy).toHaveBeenCalled() + }) + + it('should execute callback if readyState is not "loading"', () => { + const spy = jasmine.createSpy() + Util.onDOMContentLoaded(spy) + expect(spy).toHaveBeenCalled() + }) + }) }) |
