Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/twbs/bootstrap.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/js
diff options
context:
space:
mode:
authorGeoSot <geo.sotis@gmail.com>2021-04-19 06:55:22 +0300
committerGitHub <noreply@github.com>2021-04-19 06:55:22 +0300
commit6ea4dab142e3196180ede266459f8af35f32fee4 (patch)
treedc24ec4a6193feb578d3d8cf3e5364fa1fafa0f7 /js
parentaace863463c1915cce47ebad962787e2749b66eb (diff)
modal.js: fix test for scrollbar (#33666)
Co-authored-by: XhmikosR <xhmikosr@gmail.com>
Diffstat (limited to 'js')
-rw-r--r--js/tests/unit/modal.spec.js10
1 files changed, 6 insertions, 4 deletions
diff --git a/js/tests/unit/modal.spec.js b/js/tests/unit/modal.spec.js
index 2bd723ea02..624f44dc5d 100644
--- a/js/tests/unit/modal.spec.js
+++ b/js/tests/unit/modal.spec.js
@@ -100,10 +100,11 @@ 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 currentPadding = Number.parseInt(window.getComputedStyle(modalEl).paddingRight, 10)
+ const expectedPadding = originalPadding + scrollBarWidth
+ const currentPadding = Number.parseInt(window.getComputedStyle(fixedEl).paddingRight, 10)
expect(fixedEl.getAttribute('data-bs-padding-right')).toEqual(`${originalPadding}px`, 'original fixed element padding should be stored in data-bs-padding-right')
expect(currentPadding).toEqual(expectedPadding, 'fixed element padding should be adjusted while opening')
@@ -111,7 +112,7 @@ describe('Modal', () => {
})
modalEl.addEventListener('hidden.bs.modal', () => {
- const currentPadding = Number.parseInt(window.getComputedStyle(modalEl).paddingRight, 10)
+ const currentPadding = Number.parseInt(window.getComputedStyle(fixedEl).paddingRight, 10)
expect(fixedEl.hasAttribute('data-bs-padding-right')).toEqual(false, 'data-bs-padding-right should be cleared after closing')
expect(currentPadding).toEqual(originalPadding, 'fixed element padding should be reset after closing')
@@ -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')