From bdfb4cc54d29c0c7bcd7944d3c8de2e1cd41bb6c Mon Sep 17 00:00:00 2001 From: GeoSot Date: Wed, 15 Sep 2021 15:33:19 +0300 Subject: Fix Collapse regression of handling toggling between sibling chilldren (#34951) --- js/tests/unit/collapse.spec.js | 57 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) (limited to 'js/tests/unit') diff --git a/js/tests/unit/collapse.spec.js b/js/tests/unit/collapse.spec.js index 82cd5c1f7..da709bb85 100644 --- a/js/tests/unit/collapse.spec.js +++ b/js/tests/unit/collapse.spec.js @@ -267,6 +267,63 @@ describe('Collapse', () => { collapse.show() }) + it('should be able to handle toggling of other children siblings', done => { + fixtureEl.innerHTML = [ + '
', + '
', + ' ', + '
', + '
', + '
', + '
', + '
', + '
', + ' ', + '
', + '
', + '
content
', + '
', + '
', + '
', + '
', + ' ', + '
', + '
', + '
content
', + '
', + '
', + '
', + '
', + '
', + '
' + ].join('') + + const el = selector => fixtureEl.querySelector(selector) + + const parentBtn = el('[data-bs-target="#parentContent"]') + const childBtn1 = el('[data-bs-target="#childContent1"]') + const childBtn2 = el('[data-bs-target="#childContent2"]') + + const parentCollapseEl = el('#parentContent') + const childCollapseEl1 = el('#childContent1') + const childCollapseEl2 = el('#childContent2') + + parentCollapseEl.addEventListener('shown.bs.collapse', () => { + expect(parentCollapseEl.classList.contains('show')).toEqual(true) + childBtn1.click() + }) + childCollapseEl1.addEventListener('shown.bs.collapse', () => { + expect(childCollapseEl1.classList.contains('show')).toEqual(true) + childBtn2.click() + }) + childCollapseEl2.addEventListener('shown.bs.collapse', () => { + expect(childCollapseEl2.classList.contains('show')).toEqual(true) + expect(childCollapseEl1.classList.contains('show')).toEqual(false) + done() + }) + + parentBtn.click() + }) it('should not change tab tabpanels descendants on accordion', done => { fixtureEl.innerHTML = [ '
', -- cgit v1.2.3