diff options
author | GeoSot <geo.sotis@gmail.com> | 2021-05-22 03:54:32 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-05-22 03:54:32 +0300 |
commit | e06e6dfe53b663b7ec557495d46f685734a6a5a4 (patch) | |
tree | 59d8688e5b0292bffdf46355f520427c125705ce /js/tests/unit/util | |
parent | a2b5901efc6de12bb828f8dda118ddccbcd545cf (diff) |
fix test of #34014 (#34070)
Fixes regression of https://github.com/twbs/bootstrap/commit/a2b5901efc6de12bb828f8dda118ddccbcd545cf breaking the test runner because it would wipe document.body.
Diffstat (limited to 'js/tests/unit/util')
-rw-r--r-- | js/tests/unit/util/backdrop.spec.js | 30 |
1 files changed, 16 insertions, 14 deletions
diff --git a/js/tests/unit/util/backdrop.spec.js b/js/tests/unit/util/backdrop.spec.js index 02dea5a25b..195d5067c2 100644 --- a/js/tests/unit/util/backdrop.spec.js +++ b/js/tests/unit/util/backdrop.spec.js @@ -127,24 +127,26 @@ describe('Backdrop', () => { }) }) }) - }) - it('should not error if the backdrop no longer has a parent', done => { - const instance = new Backdrop({ - isVisible: true, - isAnimated: true - }) - const getElements = () => document.querySelectorAll(CLASS_BACKDROP) + it('should not error if the backdrop no longer has a parent', done => { + fixtureEl.innerHTML = '<div id="wrapper"></div>' - instance.show(() => { - instance.hide(() => { - expect(getElements().length).toEqual(0) + const wrapper = fixtureEl.querySelector('#wrapper') + const instance = new Backdrop({ + isVisible: true, + isAnimated: true, + rootElement: wrapper + }) - // replace the fixture, which was just wiped out - fixtureEl = getFixture() - done() + const getElements = () => document.querySelectorAll(CLASS_BACKDROP) + + instance.show(() => { + wrapper.parentNode.removeChild(wrapper) + instance.hide(() => { + expect(getElements().length).toEqual(0) + done() + }) }) - document.body.innerHTML = 'changed' }) }) |