Skip to content

Commit

Permalink
fix offcanvas test
Browse files Browse the repository at this point in the history
  • Loading branch information
korki43 committed Apr 6, 2021
1 parent 1fa8b41 commit 03bb1ab
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions js/tests/unit/offcanvas.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -146,20 +146,20 @@ describe('Offcanvas', () => {
})
})
describe('options', () => {
it('if scroll is enabled, should allow body to scroll while offcanvas is open', done => {
it('if scroll is enabled, should allow body to scroll while offcanvas is open, except when viewport is blocked', done => {
fixtureEl.innerHTML = '<div class="offcanvas"></div>'

const offCanvasEl = fixtureEl.querySelector('.offcanvas')
const offCanvas = new Offcanvas(offCanvasEl, { scroll: true })
const initialOverFlow = document.body.style.overflow
const hideScrollBar = fixtureEl.offsetWidth >= document.body.offsetWidth

offCanvasEl.addEventListener('shown.bs.offcanvas', () => {
expect(document.body.style.overflow).toEqual(initialOverFlow)
expect(document.body.style.overflow).toEqual(hideScrollBar ? 'hidden' : 'auto')

offCanvas.hide()
})
offCanvasEl.addEventListener('hidden.bs.offcanvas', () => {
expect(document.body.style.overflow).toEqual(initialOverFlow)
expect(document.body.style.overflow).toEqual('auto')
done()
})
offCanvas.show()
Expand Down

0 comments on commit 03bb1ab

Please sign in to comment.