From d0eea479460b90f22e68bd63e789a1061ca9c17f Mon Sep 17 00:00:00 2001 From: GeoSot Date: Sat, 17 Apr 2021 11:54:56 +0300 Subject: [PATCH] modal.js: fix test for scrollbar --- js/tests/unit/modal.spec.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/js/tests/unit/modal.spec.js b/js/tests/unit/modal.spec.js index 2bd723ea0255..e61a71fc25df 100644 --- a/js/tests/unit/modal.spec.js +++ b/js/tests/unit/modal.spec.js @@ -100,9 +100,10 @@ describe('Modal', () => { const originalPadding = Number.parseInt(window.getComputedStyle(fixedEl).paddingRight, 10) const modalEl = fixtureEl.querySelector('.modal') const modal = new Modal(modalEl) + const scrollBarWidth = getScrollBarWidth() modalEl.addEventListener('shown.bs.modal', () => { - const expectedPadding = originalPadding + getScrollBarWidth() + const expectedPadding = originalPadding + scrollBarWidth const currentPadding = Number.parseInt(window.getComputedStyle(modalEl).paddingRight, 10) expect(fixedEl.getAttribute('data-bs-padding-right')).toEqual(`${originalPadding}px`, 'original fixed element padding should be stored in data-bs-padding-right') @@ -134,9 +135,10 @@ describe('Modal', () => { const originalMargin = Number.parseInt(window.getComputedStyle(stickyTopEl).marginRight, 10) const modalEl = fixtureEl.querySelector('.modal') const modal = new Modal(modalEl) + const scrollBarWidth = getScrollBarWidth() modalEl.addEventListener('shown.bs.modal', () => { - const expectedMargin = originalMargin - getScrollBarWidth() + const expectedMargin = originalMargin - scrollBarWidth const currentMargin = Number.parseInt(window.getComputedStyle(stickyTopEl).marginRight, 10) expect(stickyTopEl.getAttribute('data-bs-margin-right')).toEqual(`${originalMargin}px`, 'original sticky element margin should be stored in data-bs-margin-right')