1
0
mirror of https://github.com/twbs/bootstrap.git synced 2025-08-16 10:34:07 +02:00

ScrollBar.js. Minor refactoring and add test (#35492)

This commit is contained in:
GeoSot
2021-12-09 15:05:50 +02:00
committed by GitHub
parent 2a7015e630
commit 4fd5539c75
2 changed files with 38 additions and 13 deletions

View File

@@ -137,6 +137,27 @@ describe('ScrollBar', () => {
done()
})
it('should remove padding & margin if not existed before adjustment', done => {
fixtureEl.innerHTML = [
'<div style="height: 110vh; width: 100%">',
' <div class="fixed" id="fixed" style="width: 100vw;"></div>',
' <div class="sticky-top" id="sticky" style=" width: 100vw;"></div>',
'</div>'
].join('')
doc.style.overflowY = 'scroll'
const fixedEl = fixtureEl.querySelector('#fixed')
const stickyEl = fixtureEl.querySelector('#sticky')
const scrollBar = new ScrollBarHelper()
scrollBar.hide()
scrollBar.reset()
expect(fixedEl.getAttribute('style').includes('padding-right')).toBeFalse()
expect(stickyEl.getAttribute('style').includes('margin-right')).toBeFalse()
done()
})
it('should adjust the inline margin and padding of sticky elements', done => {
fixtureEl.innerHTML = [
'<div style="height: 110vh">',