]> git.ipfire.org Git - thirdparty/bootstrap.git/commitdiff
fix test of #34014 (#34070)
authorGeoSot <geo.sotis@gmail.com>
Sat, 22 May 2021 00:54:32 +0000 (03:54 +0300)
committerGitHub <noreply@github.com>
Sat, 22 May 2021 00:54:32 +0000 (02:54 +0200)
Fixes regression of https://github.com/twbs/bootstrap/commit/a2b5901efc6de12bb828f8dda118ddccbcd545cf breaking the test runner because it would wipe document.body.

js/tests/unit/util/backdrop.spec.js

index 02dea5a25b6038cb16c8581c22963d4f79c9746a..195d5067c21c6503eee3d6e1130d094e6bdbd826 100644 (file)
@@ -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'
     })
   })