From 5ddb40a6ecdaacb719a4e887a0d3dbac18afd81a Mon Sep 17 00:00:00 2001 From: Rohit Sharma Date: Tue, 8 Dec 2020 01:28:22 +0530 Subject: [PATCH] Update unit tests --- js/tests/unit/modal.spec.js | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/js/tests/unit/modal.spec.js b/js/tests/unit/modal.spec.js index 34e1ac2d8..ca76439eb 100644 --- a/js/tests/unit/modal.spec.js +++ b/js/tests/unit/modal.spec.js @@ -142,33 +142,28 @@ describe('Modal', () => { modal.toggle() }) - it('should not adjust the inline margin of sticky elements when element do not have full width', done => { + it('should not adjust the inline margin and padding of sticky and fixed elements when element do not have full width', done => { fixtureEl.innerHTML = [ - '
', + '
', '' ].join('') const stickyTopEl = fixtureEl.querySelector('.sticky-top') const originalMargin = Number.parseInt(window.getComputedStyle(stickyTopEl).marginRight, 10) + const originalPadding = Number.parseInt(window.getComputedStyle(stickyTopEl).paddingRight, 10) const modalEl = fixtureEl.querySelector('.modal') const modal = new Modal(modalEl) modalEl.addEventListener('shown.bs.modal', () => { const currentMargin = Number.parseInt(window.getComputedStyle(stickyTopEl).marginRight, 10) + const currentPadding = Number.parseInt(window.getComputedStyle(stickyTopEl).paddingRight, 10) - expect(currentMargin).toEqual(originalMargin, 'sticky element margin should not be adjusted while opening') - modal.toggle() - }) - - modalEl.addEventListener('hidden.bs.modal', () => { - const currentMargin = Number.parseInt(window.getComputedStyle(stickyTopEl).marginRight, 10) - - expect(stickyTopEl.getAttribute('data-margin-right')).toEqual(null, 'data-margin-right should be cleared after closing') - expect(currentMargin).toEqual(originalMargin, 'sticky element margin should be reset after closing') + expect(currentMargin).toEqual(originalMargin, 'sticky element\'s margin should not be adjusted while opening') + expect(currentPadding).toEqual(originalPadding, 'sticky element\'s padding should not be adjusted while opening') done() }) - modal.toggle() + modal.show() }) it('should ignore values set via CSS when trying to restore body padding after closing', done => {