mirror of
https://github.com/twbs/bootstrap.git
synced 2025-03-15 15:29:22 +01:00
parent
ec3cfae29c
commit
94109cabf4
@ -58,7 +58,7 @@ describe('Modal', () => {
|
|||||||
|
|
||||||
describe('toggle', () => {
|
describe('toggle', () => {
|
||||||
it('should toggle a modal', done => {
|
it('should toggle a modal', done => {
|
||||||
fixtureEl.innerHTML = '<div class="modal"><div class="modal-dialog"></div>'
|
fixtureEl.innerHTML = '<div class="modal"><div class="modal-dialog"></div></div>'
|
||||||
|
|
||||||
const modalEl = fixtureEl.querySelector('.modal')
|
const modalEl = fixtureEl.querySelector('.modal')
|
||||||
const modal = new Modal(modalEl)
|
const modal = new Modal(modalEl)
|
||||||
@ -83,7 +83,7 @@ describe('Modal', () => {
|
|||||||
it('should adjust the inline padding of fixed elements when opening and restore when closing', done => {
|
it('should adjust the inline padding of fixed elements when opening and restore when closing', done => {
|
||||||
fixtureEl.innerHTML = [
|
fixtureEl.innerHTML = [
|
||||||
'<div class="fixed-top" style="padding-right: 0px"></div>',
|
'<div class="fixed-top" style="padding-right: 0px"></div>',
|
||||||
'<div class="modal"><div class="modal-dialog"></div>'
|
'<div class="modal"><div class="modal-dialog"></div></div>'
|
||||||
].join('')
|
].join('')
|
||||||
|
|
||||||
const fixedEl = fixtureEl.querySelector('.fixed-top')
|
const fixedEl = fixtureEl.querySelector('.fixed-top')
|
||||||
@ -114,7 +114,7 @@ describe('Modal', () => {
|
|||||||
it('should adjust the inline margin of sticky elements when opening and restore when closing', done => {
|
it('should adjust the inline margin of sticky elements when opening and restore when closing', done => {
|
||||||
fixtureEl.innerHTML = [
|
fixtureEl.innerHTML = [
|
||||||
'<div class="sticky-top" style="margin-right: 0px;"></div>',
|
'<div class="sticky-top" style="margin-right: 0px;"></div>',
|
||||||
'<div class="modal"><div class="modal-dialog"></div>'
|
'<div class="modal"><div class="modal-dialog"></div></div>'
|
||||||
].join('')
|
].join('')
|
||||||
|
|
||||||
const stickyTopEl = fixtureEl.querySelector('.sticky-top')
|
const stickyTopEl = fixtureEl.querySelector('.sticky-top')
|
||||||
@ -143,7 +143,7 @@ describe('Modal', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
it('should ignore values set via CSS when trying to restore body padding after closing', done => {
|
it('should ignore values set via CSS when trying to restore body padding after closing', done => {
|
||||||
fixtureEl.innerHTML = '<div class="modal"><div class="modal-dialog"></div>'
|
fixtureEl.innerHTML = '<div class="modal"><div class="modal-dialog"></div></div>'
|
||||||
const styleTest = document.createElement('style')
|
const styleTest = document.createElement('style')
|
||||||
|
|
||||||
styleTest.type = 'text/css'
|
styleTest.type = 'text/css'
|
||||||
@ -167,7 +167,7 @@ describe('Modal', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
it('should ignore other inline styles when trying to restore body padding after closing', done => {
|
it('should ignore other inline styles when trying to restore body padding after closing', done => {
|
||||||
fixtureEl.innerHTML = '<div class="modal"><div class="modal-dialog"></div>'
|
fixtureEl.innerHTML = '<div class="modal"><div class="modal-dialog"></div></div>'
|
||||||
const styleTest = document.createElement('style')
|
const styleTest = document.createElement('style')
|
||||||
|
|
||||||
styleTest.type = 'text/css'
|
styleTest.type = 'text/css'
|
||||||
@ -197,7 +197,7 @@ describe('Modal', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
it('should properly restore non-pixel inline body padding after closing', done => {
|
it('should properly restore non-pixel inline body padding after closing', done => {
|
||||||
fixtureEl.innerHTML = '<div class="modal"><div class="modal-dialog"></div>'
|
fixtureEl.innerHTML = '<div class="modal"><div class="modal-dialog"></div></div>'
|
||||||
|
|
||||||
document.body.style.paddingRight = '5%'
|
document.body.style.paddingRight = '5%'
|
||||||
|
|
||||||
@ -220,7 +220,7 @@ describe('Modal', () => {
|
|||||||
|
|
||||||
describe('show', () => {
|
describe('show', () => {
|
||||||
it('should show a modal', done => {
|
it('should show a modal', done => {
|
||||||
fixtureEl.innerHTML = '<div class="modal"><div class="modal-dialog"></div>'
|
fixtureEl.innerHTML = '<div class="modal"><div class="modal-dialog"></div></div>'
|
||||||
|
|
||||||
const modalEl = fixtureEl.querySelector('.modal')
|
const modalEl = fixtureEl.querySelector('.modal')
|
||||||
const modal = new Modal(modalEl)
|
const modal = new Modal(modalEl)
|
||||||
@ -241,7 +241,7 @@ describe('Modal', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
it('should show a modal without backdrop', done => {
|
it('should show a modal without backdrop', done => {
|
||||||
fixtureEl.innerHTML = '<div class="modal"><div class="modal-dialog"></div>'
|
fixtureEl.innerHTML = '<div class="modal"><div class="modal-dialog"></div></div>'
|
||||||
|
|
||||||
const modalEl = fixtureEl.querySelector('.modal')
|
const modalEl = fixtureEl.querySelector('.modal')
|
||||||
const modal = new Modal(modalEl, {
|
const modal = new Modal(modalEl, {
|
||||||
@ -284,7 +284,7 @@ describe('Modal', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
it('should do nothing if a modal is shown', () => {
|
it('should do nothing if a modal is shown', () => {
|
||||||
fixtureEl.innerHTML = '<div class="modal"><div class="modal-dialog"></div>'
|
fixtureEl.innerHTML = '<div class="modal"><div class="modal-dialog"></div></div>'
|
||||||
|
|
||||||
const modalEl = fixtureEl.querySelector('.modal')
|
const modalEl = fixtureEl.querySelector('.modal')
|
||||||
const modal = new Modal(modalEl)
|
const modal = new Modal(modalEl)
|
||||||
@ -298,7 +298,7 @@ describe('Modal', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
it('should do nothing if a modal is transitioning', () => {
|
it('should do nothing if a modal is transitioning', () => {
|
||||||
fixtureEl.innerHTML = '<div class="modal"><div class="modal-dialog"></div>'
|
fixtureEl.innerHTML = '<div class="modal"><div class="modal-dialog"></div></div>'
|
||||||
|
|
||||||
const modalEl = fixtureEl.querySelector('.modal')
|
const modalEl = fixtureEl.querySelector('.modal')
|
||||||
const modal = new Modal(modalEl)
|
const modal = new Modal(modalEl)
|
||||||
@ -312,7 +312,7 @@ describe('Modal', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
it('should not fire shown event when show is prevented', done => {
|
it('should not fire shown event when show is prevented', done => {
|
||||||
fixtureEl.innerHTML = '<div class="modal"><div class="modal-dialog"></div>'
|
fixtureEl.innerHTML = '<div class="modal"><div class="modal-dialog"></div></div>'
|
||||||
|
|
||||||
const modalEl = fixtureEl.querySelector('.modal')
|
const modalEl = fixtureEl.querySelector('.modal')
|
||||||
const modal = new Modal(modalEl)
|
const modal = new Modal(modalEl)
|
||||||
@ -441,7 +441,7 @@ describe('Modal', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
it('should add listener when escape touch is pressed', done => {
|
it('should add listener when escape touch is pressed', done => {
|
||||||
fixtureEl.innerHTML = '<div class="modal"><div class="modal-dialog"></div>'
|
fixtureEl.innerHTML = '<div class="modal"><div class="modal-dialog"></div></div>'
|
||||||
|
|
||||||
const modalEl = fixtureEl.querySelector('.modal')
|
const modalEl = fixtureEl.querySelector('.modal')
|
||||||
const modal = new Modal(modalEl)
|
const modal = new Modal(modalEl)
|
||||||
@ -464,7 +464,7 @@ describe('Modal', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
it('should do nothing when the pressed key is not escape', done => {
|
it('should do nothing when the pressed key is not escape', done => {
|
||||||
fixtureEl.innerHTML = '<div class="modal"><div class="modal-dialog"></div>'
|
fixtureEl.innerHTML = '<div class="modal"><div class="modal-dialog"></div></div>'
|
||||||
|
|
||||||
const modalEl = fixtureEl.querySelector('.modal')
|
const modalEl = fixtureEl.querySelector('.modal')
|
||||||
const modal = new Modal(modalEl)
|
const modal = new Modal(modalEl)
|
||||||
@ -489,7 +489,7 @@ describe('Modal', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
it('should adjust dialog on resize', done => {
|
it('should adjust dialog on resize', done => {
|
||||||
fixtureEl.innerHTML = '<div class="modal"><div class="modal-dialog"></div>'
|
fixtureEl.innerHTML = '<div class="modal"><div class="modal-dialog"></div></div>'
|
||||||
|
|
||||||
const modalEl = fixtureEl.querySelector('.modal')
|
const modalEl = fixtureEl.querySelector('.modal')
|
||||||
const modal = new Modal(modalEl)
|
const modal = new Modal(modalEl)
|
||||||
@ -513,7 +513,7 @@ describe('Modal', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
it('should not close modal when clicking outside of modal-content if backdrop = false', done => {
|
it('should not close modal when clicking outside of modal-content if backdrop = false', done => {
|
||||||
fixtureEl.innerHTML = '<div class="modal"><div class="modal-dialog"></div>'
|
fixtureEl.innerHTML = '<div class="modal"><div class="modal-dialog"></div></div>'
|
||||||
|
|
||||||
const modalEl = fixtureEl.querySelector('.modal')
|
const modalEl = fixtureEl.querySelector('.modal')
|
||||||
const modal = new Modal(modalEl, {
|
const modal = new Modal(modalEl, {
|
||||||
@ -625,7 +625,7 @@ describe('Modal', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
it('should not adjust the inline body padding when it does not overflow', done => {
|
it('should not adjust the inline body padding when it does not overflow', done => {
|
||||||
fixtureEl.innerHTML = '<div class="modal"><div class="modal-dialog"></div>'
|
fixtureEl.innerHTML = '<div class="modal"><div class="modal-dialog"></div></div>'
|
||||||
|
|
||||||
const modalEl = fixtureEl.querySelector('.modal')
|
const modalEl = fixtureEl.querySelector('.modal')
|
||||||
const modal = new Modal(modalEl)
|
const modal = new Modal(modalEl)
|
||||||
@ -650,7 +650,7 @@ describe('Modal', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
it('should enforce focus', done => {
|
it('should enforce focus', done => {
|
||||||
fixtureEl.innerHTML = '<div class="modal"><div class="modal-dialog"></div>'
|
fixtureEl.innerHTML = '<div class="modal"><div class="modal-dialog"></div></div>'
|
||||||
|
|
||||||
const modalEl = fixtureEl.querySelector('.modal')
|
const modalEl = fixtureEl.querySelector('.modal')
|
||||||
const modal = new Modal(modalEl)
|
const modal = new Modal(modalEl)
|
||||||
@ -684,7 +684,7 @@ describe('Modal', () => {
|
|||||||
|
|
||||||
describe('hide', () => {
|
describe('hide', () => {
|
||||||
it('should hide a modal', done => {
|
it('should hide a modal', done => {
|
||||||
fixtureEl.innerHTML = '<div class="modal"><div class="modal-dialog"></div>'
|
fixtureEl.innerHTML = '<div class="modal"><div class="modal-dialog"></div></div>'
|
||||||
|
|
||||||
const modalEl = fixtureEl.querySelector('.modal')
|
const modalEl = fixtureEl.querySelector('.modal')
|
||||||
const modal = new Modal(modalEl)
|
const modal = new Modal(modalEl)
|
||||||
@ -709,7 +709,7 @@ describe('Modal', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
it('should close modal when clicking outside of modal-content', done => {
|
it('should close modal when clicking outside of modal-content', done => {
|
||||||
fixtureEl.innerHTML = '<div class="modal"><div class="modal-dialog"></div>'
|
fixtureEl.innerHTML = '<div class="modal"><div class="modal-dialog"></div></div>'
|
||||||
|
|
||||||
const modalEl = fixtureEl.querySelector('.modal')
|
const modalEl = fixtureEl.querySelector('.modal')
|
||||||
const modal = new Modal(modalEl)
|
const modal = new Modal(modalEl)
|
||||||
@ -730,7 +730,7 @@ describe('Modal', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
it('should do nothing is the modal is not shown', () => {
|
it('should do nothing is the modal is not shown', () => {
|
||||||
fixtureEl.innerHTML = '<div class="modal"><div class="modal-dialog"></div>'
|
fixtureEl.innerHTML = '<div class="modal"><div class="modal-dialog"></div></div>'
|
||||||
|
|
||||||
const modalEl = fixtureEl.querySelector('.modal')
|
const modalEl = fixtureEl.querySelector('.modal')
|
||||||
const modal = new Modal(modalEl)
|
const modal = new Modal(modalEl)
|
||||||
@ -741,7 +741,7 @@ describe('Modal', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
it('should do nothing is the modal is transitioning', () => {
|
it('should do nothing is the modal is transitioning', () => {
|
||||||
fixtureEl.innerHTML = '<div class="modal"><div class="modal-dialog"></div>'
|
fixtureEl.innerHTML = '<div class="modal"><div class="modal-dialog"></div></div>'
|
||||||
|
|
||||||
const modalEl = fixtureEl.querySelector('.modal')
|
const modalEl = fixtureEl.querySelector('.modal')
|
||||||
const modal = new Modal(modalEl)
|
const modal = new Modal(modalEl)
|
||||||
@ -753,7 +753,7 @@ describe('Modal', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
it('should not hide a modal if hide is prevented', done => {
|
it('should not hide a modal if hide is prevented', done => {
|
||||||
fixtureEl.innerHTML = '<div class="modal"><div class="modal-dialog"></div>'
|
fixtureEl.innerHTML = '<div class="modal"><div class="modal-dialog"></div></div>'
|
||||||
|
|
||||||
const modalEl = fixtureEl.querySelector('.modal')
|
const modalEl = fixtureEl.querySelector('.modal')
|
||||||
const modal = new Modal(modalEl)
|
const modal = new Modal(modalEl)
|
||||||
@ -970,7 +970,7 @@ describe('Modal', () => {
|
|||||||
|
|
||||||
describe('jQueryInterface', () => {
|
describe('jQueryInterface', () => {
|
||||||
it('should create a modal', () => {
|
it('should create a modal', () => {
|
||||||
fixtureEl.innerHTML = '<div class="modal"><div class="modal-dialog"></div>'
|
fixtureEl.innerHTML = '<div class="modal"><div class="modal-dialog"></div></div>'
|
||||||
|
|
||||||
const div = fixtureEl.querySelector('div')
|
const div = fixtureEl.querySelector('div')
|
||||||
|
|
||||||
@ -983,7 +983,7 @@ describe('Modal', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
it('should not re create a modal', () => {
|
it('should not re create a modal', () => {
|
||||||
fixtureEl.innerHTML = '<div class="modal"><div class="modal-dialog"></div>'
|
fixtureEl.innerHTML = '<div class="modal"><div class="modal-dialog"></div></div>'
|
||||||
|
|
||||||
const div = fixtureEl.querySelector('div')
|
const div = fixtureEl.querySelector('div')
|
||||||
const modal = new Modal(div)
|
const modal = new Modal(div)
|
||||||
@ -997,7 +997,7 @@ describe('Modal', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
it('should throw error on undefined method', () => {
|
it('should throw error on undefined method', () => {
|
||||||
fixtureEl.innerHTML = '<div class="modal"><div class="modal-dialog"></div>'
|
fixtureEl.innerHTML = '<div class="modal"><div class="modal-dialog"></div></div>'
|
||||||
|
|
||||||
const div = fixtureEl.querySelector('div')
|
const div = fixtureEl.querySelector('div')
|
||||||
const action = 'undefinedMethod'
|
const action = 'undefinedMethod'
|
||||||
@ -1013,7 +1013,7 @@ describe('Modal', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
it('should should call show method', () => {
|
it('should should call show method', () => {
|
||||||
fixtureEl.innerHTML = '<div class="modal"><div class="modal-dialog"></div>'
|
fixtureEl.innerHTML = '<div class="modal"><div class="modal-dialog"></div></div>'
|
||||||
|
|
||||||
const div = fixtureEl.querySelector('div')
|
const div = fixtureEl.querySelector('div')
|
||||||
const modal = new Modal(div)
|
const modal = new Modal(div)
|
||||||
@ -1046,7 +1046,7 @@ describe('Modal', () => {
|
|||||||
|
|
||||||
describe('getInstance', () => {
|
describe('getInstance', () => {
|
||||||
it('should return modal instance', () => {
|
it('should return modal instance', () => {
|
||||||
fixtureEl.innerHTML = '<div class="modal"><div class="modal-dialog"></div>'
|
fixtureEl.innerHTML = '<div class="modal"><div class="modal-dialog"></div></div>'
|
||||||
|
|
||||||
const div = fixtureEl.querySelector('div')
|
const div = fixtureEl.querySelector('div')
|
||||||
const modal = new Modal(div)
|
const modal = new Modal(div)
|
||||||
@ -1055,7 +1055,7 @@ describe('Modal', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
it('should return null when there is no modal instance', () => {
|
it('should return null when there is no modal instance', () => {
|
||||||
fixtureEl.innerHTML = '<div class="modal"><div class="modal-dialog"></div>'
|
fixtureEl.innerHTML = '<div class="modal"><div class="modal-dialog"></div></div>'
|
||||||
|
|
||||||
const div = fixtureEl.querySelector('div')
|
const div = fixtureEl.querySelector('div')
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user