Skip to content

Commit e06e6df

Browse files
authored
fix test of #34014 (#34070)
Fixes regression of twbs/bootstrap@a2b5901 breaking the test runner because it would wipe document.body.
1 parent a2b5901 commit e06e6df

File tree

1 file changed

+16
-14
lines changed

1 file changed

+16
-14
lines changed

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

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -127,24 +127,26 @@ describe('Backdrop', () => {
127127
})
128128
})
129129
})
130-
})
131130

132-
it('should not error if the backdrop no longer has a parent', done => {
133-
const instance = new Backdrop({
134-
isVisible: true,
135-
isAnimated: true
136-
})
137-
const getElements = () => document.querySelectorAll(CLASS_BACKDROP)
131+
it('should not error if the backdrop no longer has a parent', done => {
132+
fixtureEl.innerHTML = '<div id="wrapper"></div>'
138133

139-
instance.show(() => {
140-
instance.hide(() => {
141-
expect(getElements().length).toEqual(0)
134+
const wrapper = fixtureEl.querySelector('#wrapper')
135+
const instance = new Backdrop({
136+
isVisible: true,
137+
isAnimated: true,
138+
rootElement: wrapper
139+
})
142140

143-
// replace the fixture, which was just wiped out
144-
fixtureEl = getFixture()
145-
done()
141+
const getElements = () => document.querySelectorAll(CLASS_BACKDROP)
142+
143+
instance.show(() => {
144+
wrapper.parentNode.removeChild(wrapper)
145+
instance.hide(() => {
146+
expect(getElements().length).toEqual(0)
147+
done()
148+
})
146149
})
147-
document.body.innerHTML = 'changed'
148150
})
149151
})
150152

0 commit comments

Comments
 (0)