Update unit tests
This commit is contained in:
parent
ee959189a7
commit
5ddb40a6ec
1 changed files with 7 additions and 12 deletions
|
|
@ -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 = [
|
||||
'<div class="sticky-top" style="margin-right: 0px; width: 50%"></div>',
|
||||
'<div class="sticky-top" style="margin-right: 0px; padding-right: 0px; width: calc(100vw - 50%)"></div>',
|
||||
'<div class="modal"><div class="modal-dialog"></div></div>'
|
||||
].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 => {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue