From: GeoSot Date: Sat, 22 May 2021 00:54:32 +0000 (+0300) Subject: fix test of #34014 (#34070) X-Git-Tag: v5.0.2~74 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=e06e6dfe53b663b7ec557495d46f685734a6a5a4;p=thirdparty%2Fbootstrap.git 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. --- 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 = '
' - 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' }) })