mirror of
https://github.com/twbs/bootstrap.git
synced 2025-01-30 22:52:24 +01:00
tests: revisit all tests using Promise.reject instead of throwing an error (#35765)
This commit is contained in:
parent
ae12d645ef
commit
4b17868fb4
@ -102,7 +102,7 @@ describe('Alert', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
it('should not remove alert if close event is prevented', () => {
|
it('should not remove alert if close event is prevented', () => {
|
||||||
return new Promise(resolve => {
|
return new Promise((resolve, reject) => {
|
||||||
fixtureEl.innerHTML = '<div class="alert"></div>'
|
fixtureEl.innerHTML = '<div class="alert"></div>'
|
||||||
|
|
||||||
const getAlert = () => document.querySelector('.alert')
|
const getAlert = () => document.querySelector('.alert')
|
||||||
@ -118,7 +118,7 @@ describe('Alert', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
alertEl.addEventListener('closed.bs.alert', () => {
|
alertEl.addEventListener('closed.bs.alert', () => {
|
||||||
throw new Error('should not fire closed event')
|
reject(new Error('should not fire closed event'))
|
||||||
})
|
})
|
||||||
|
|
||||||
alert.close()
|
alert.close()
|
||||||
|
@ -270,7 +270,7 @@ describe('Carousel', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
it('should stay at the start when the prev method is called and wrap is false', () => {
|
it('should stay at the start when the prev method is called and wrap is false', () => {
|
||||||
return new Promise(resolve => {
|
return new Promise((resolve, reject) => {
|
||||||
fixtureEl.innerHTML = [
|
fixtureEl.innerHTML = [
|
||||||
'<div id="myCarousel" class="carousel slide">',
|
'<div id="myCarousel" class="carousel slide">',
|
||||||
' <div class="carousel-inner">',
|
' <div class="carousel-inner">',
|
||||||
@ -286,7 +286,7 @@ describe('Carousel', () => {
|
|||||||
const carousel = new Carousel(carouselEl, { wrap: false })
|
const carousel = new Carousel(carouselEl, { wrap: false })
|
||||||
|
|
||||||
carouselEl.addEventListener('slid.bs.carousel', () => {
|
carouselEl.addEventListener('slid.bs.carousel', () => {
|
||||||
throw new Error('carousel slid when it should not have slid')
|
reject(new Error('carousel slid when it should not have slid'))
|
||||||
})
|
})
|
||||||
|
|
||||||
carousel.prev()
|
carousel.prev()
|
||||||
|
@ -385,7 +385,7 @@ describe('Collapse', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
it('should not fire shown when show is prevented', () => {
|
it('should not fire shown when show is prevented', () => {
|
||||||
return new Promise(resolve => {
|
return new Promise((resolve, reject) => {
|
||||||
fixtureEl.innerHTML = '<div class="collapse"></div>'
|
fixtureEl.innerHTML = '<div class="collapse"></div>'
|
||||||
|
|
||||||
const collapseEl = fixtureEl.querySelector('div')
|
const collapseEl = fixtureEl.querySelector('div')
|
||||||
@ -406,7 +406,7 @@ describe('Collapse', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
collapseEl.addEventListener('shown.bs.collapse', () => {
|
collapseEl.addEventListener('shown.bs.collapse', () => {
|
||||||
throw new Error('should not fire shown event')
|
reject(new Error('should not fire shown event'))
|
||||||
})
|
})
|
||||||
|
|
||||||
collapse.show()
|
collapse.show()
|
||||||
@ -466,7 +466,7 @@ describe('Collapse', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
it('should not fire hidden when hide is prevented', () => {
|
it('should not fire hidden when hide is prevented', () => {
|
||||||
return new Promise(resolve => {
|
return new Promise((resolve, reject) => {
|
||||||
fixtureEl.innerHTML = '<div class="collapse show"></div>'
|
fixtureEl.innerHTML = '<div class="collapse show"></div>'
|
||||||
|
|
||||||
const collapseEl = fixtureEl.querySelector('div')
|
const collapseEl = fixtureEl.querySelector('div')
|
||||||
@ -487,7 +487,7 @@ describe('Collapse', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
collapseEl.addEventListener('hidden.bs.collapse', () => {
|
collapseEl.addEventListener('hidden.bs.collapse', () => {
|
||||||
throw new Error('should not fire hidden event')
|
reject(new Error('should not fire hidden event'))
|
||||||
})
|
})
|
||||||
|
|
||||||
collapse.hide()
|
collapse.hide()
|
||||||
|
@ -373,12 +373,12 @@ describe('EventHandler', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
it('should remove a listener registered by .one', () => {
|
it('should remove a listener registered by .one', () => {
|
||||||
return new Promise(resolve => {
|
return new Promise((resolve, reject) => {
|
||||||
fixtureEl.innerHTML = '<div></div>'
|
fixtureEl.innerHTML = '<div></div>'
|
||||||
|
|
||||||
const div = fixtureEl.querySelector('div')
|
const div = fixtureEl.querySelector('div')
|
||||||
const handler = () => {
|
const handler = () => {
|
||||||
throw new Error('called')
|
reject(new Error('called'))
|
||||||
}
|
}
|
||||||
|
|
||||||
EventHandler.one(div, 'foobar', handler)
|
EventHandler.one(div, 'foobar', handler)
|
||||||
|
@ -513,7 +513,7 @@ describe('Dropdown', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
it('should not toggle a dropdown if the element is disabled', () => {
|
it('should not toggle a dropdown if the element is disabled', () => {
|
||||||
return new Promise(resolve => {
|
return new Promise((resolve, reject) => {
|
||||||
fixtureEl.innerHTML = [
|
fixtureEl.innerHTML = [
|
||||||
'<div class="dropdown">',
|
'<div class="dropdown">',
|
||||||
' <button disabled class="btn dropdown-toggle" data-bs-toggle="dropdown">Dropdown</button>',
|
' <button disabled class="btn dropdown-toggle" data-bs-toggle="dropdown">Dropdown</button>',
|
||||||
@ -527,7 +527,7 @@ describe('Dropdown', () => {
|
|||||||
const dropdown = new Dropdown(btnDropdown)
|
const dropdown = new Dropdown(btnDropdown)
|
||||||
|
|
||||||
btnDropdown.addEventListener('shown.bs.dropdown', () => {
|
btnDropdown.addEventListener('shown.bs.dropdown', () => {
|
||||||
throw new Error('should not throw shown.bs.dropdown event')
|
reject(new Error('should not throw shown.bs.dropdown event'))
|
||||||
})
|
})
|
||||||
|
|
||||||
dropdown.toggle()
|
dropdown.toggle()
|
||||||
@ -540,7 +540,7 @@ describe('Dropdown', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
it('should not toggle a dropdown if the element contains .disabled', () => {
|
it('should not toggle a dropdown if the element contains .disabled', () => {
|
||||||
return new Promise(resolve => {
|
return new Promise((resolve, reject) => {
|
||||||
fixtureEl.innerHTML = [
|
fixtureEl.innerHTML = [
|
||||||
'<div class="dropdown">',
|
'<div class="dropdown">',
|
||||||
' <button class="btn dropdown-toggle disabled" data-bs-toggle="dropdown">Dropdown</button>',
|
' <button class="btn dropdown-toggle disabled" data-bs-toggle="dropdown">Dropdown</button>',
|
||||||
@ -554,7 +554,7 @@ describe('Dropdown', () => {
|
|||||||
const dropdown = new Dropdown(btnDropdown)
|
const dropdown = new Dropdown(btnDropdown)
|
||||||
|
|
||||||
btnDropdown.addEventListener('shown.bs.dropdown', () => {
|
btnDropdown.addEventListener('shown.bs.dropdown', () => {
|
||||||
throw new Error('should not throw shown.bs.dropdown event')
|
reject(new Error('should not throw shown.bs.dropdown event'))
|
||||||
})
|
})
|
||||||
|
|
||||||
dropdown.toggle()
|
dropdown.toggle()
|
||||||
@ -567,7 +567,7 @@ describe('Dropdown', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
it('should not toggle a dropdown if the menu is shown', () => {
|
it('should not toggle a dropdown if the menu is shown', () => {
|
||||||
return new Promise(resolve => {
|
return new Promise((resolve, reject) => {
|
||||||
fixtureEl.innerHTML = [
|
fixtureEl.innerHTML = [
|
||||||
'<div class="dropdown">',
|
'<div class="dropdown">',
|
||||||
' <button class="btn dropdown-toggle" data-bs-toggle="dropdown">Dropdown</button>',
|
' <button class="btn dropdown-toggle" data-bs-toggle="dropdown">Dropdown</button>',
|
||||||
@ -581,7 +581,7 @@ describe('Dropdown', () => {
|
|||||||
const dropdown = new Dropdown(btnDropdown)
|
const dropdown = new Dropdown(btnDropdown)
|
||||||
|
|
||||||
btnDropdown.addEventListener('shown.bs.dropdown', () => {
|
btnDropdown.addEventListener('shown.bs.dropdown', () => {
|
||||||
throw new Error('should not throw shown.bs.dropdown event')
|
reject(new Error('should not throw shown.bs.dropdown event'))
|
||||||
})
|
})
|
||||||
|
|
||||||
dropdown.toggle()
|
dropdown.toggle()
|
||||||
@ -594,7 +594,7 @@ describe('Dropdown', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
it('should not toggle a dropdown if show event is prevented', () => {
|
it('should not toggle a dropdown if show event is prevented', () => {
|
||||||
return new Promise(resolve => {
|
return new Promise((resolve, reject) => {
|
||||||
fixtureEl.innerHTML = [
|
fixtureEl.innerHTML = [
|
||||||
'<div class="dropdown">',
|
'<div class="dropdown">',
|
||||||
' <button class="btn dropdown-toggle" data-bs-toggle="dropdown">Dropdown</button>',
|
' <button class="btn dropdown-toggle" data-bs-toggle="dropdown">Dropdown</button>',
|
||||||
@ -612,7 +612,7 @@ describe('Dropdown', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
btnDropdown.addEventListener('shown.bs.dropdown', () => {
|
btnDropdown.addEventListener('shown.bs.dropdown', () => {
|
||||||
throw new Error('should not throw shown.bs.dropdown event')
|
reject(new Error('should not throw shown.bs.dropdown event'))
|
||||||
})
|
})
|
||||||
|
|
||||||
dropdown.toggle()
|
dropdown.toggle()
|
||||||
@ -650,7 +650,7 @@ describe('Dropdown', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
it('should not show a dropdown if the element is disabled', () => {
|
it('should not show a dropdown if the element is disabled', () => {
|
||||||
return new Promise(resolve => {
|
return new Promise((resolve, reject) => {
|
||||||
fixtureEl.innerHTML = [
|
fixtureEl.innerHTML = [
|
||||||
'<div class="dropdown">',
|
'<div class="dropdown">',
|
||||||
' <button disabled class="btn dropdown-toggle" data-bs-toggle="dropdown">Dropdown</button>',
|
' <button disabled class="btn dropdown-toggle" data-bs-toggle="dropdown">Dropdown</button>',
|
||||||
@ -664,7 +664,7 @@ describe('Dropdown', () => {
|
|||||||
const dropdown = new Dropdown(btnDropdown)
|
const dropdown = new Dropdown(btnDropdown)
|
||||||
|
|
||||||
btnDropdown.addEventListener('shown.bs.dropdown', () => {
|
btnDropdown.addEventListener('shown.bs.dropdown', () => {
|
||||||
throw new Error('should not throw shown.bs.dropdown event')
|
reject(new Error('should not throw shown.bs.dropdown event'))
|
||||||
})
|
})
|
||||||
|
|
||||||
dropdown.show()
|
dropdown.show()
|
||||||
@ -677,7 +677,7 @@ describe('Dropdown', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
it('should not show a dropdown if the element contains .disabled', () => {
|
it('should not show a dropdown if the element contains .disabled', () => {
|
||||||
return new Promise(resolve => {
|
return new Promise((resolve, reject) => {
|
||||||
fixtureEl.innerHTML = [
|
fixtureEl.innerHTML = [
|
||||||
'<div class="dropdown">',
|
'<div class="dropdown">',
|
||||||
' <button class="btn dropdown-toggle disabled" data-bs-toggle="dropdown">Dropdown</button>',
|
' <button class="btn dropdown-toggle disabled" data-bs-toggle="dropdown">Dropdown</button>',
|
||||||
@ -691,7 +691,7 @@ describe('Dropdown', () => {
|
|||||||
const dropdown = new Dropdown(btnDropdown)
|
const dropdown = new Dropdown(btnDropdown)
|
||||||
|
|
||||||
btnDropdown.addEventListener('shown.bs.dropdown', () => {
|
btnDropdown.addEventListener('shown.bs.dropdown', () => {
|
||||||
throw new Error('should not throw shown.bs.dropdown event')
|
reject(new Error('should not throw shown.bs.dropdown event'))
|
||||||
})
|
})
|
||||||
|
|
||||||
dropdown.show()
|
dropdown.show()
|
||||||
@ -704,7 +704,7 @@ describe('Dropdown', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
it('should not show a dropdown if the menu is shown', () => {
|
it('should not show a dropdown if the menu is shown', () => {
|
||||||
return new Promise(resolve => {
|
return new Promise((resolve, reject) => {
|
||||||
fixtureEl.innerHTML = [
|
fixtureEl.innerHTML = [
|
||||||
'<div class="dropdown">',
|
'<div class="dropdown">',
|
||||||
' <button class="btn dropdown-toggle" data-bs-toggle="dropdown">Dropdown</button>',
|
' <button class="btn dropdown-toggle" data-bs-toggle="dropdown">Dropdown</button>',
|
||||||
@ -718,7 +718,7 @@ describe('Dropdown', () => {
|
|||||||
const dropdown = new Dropdown(btnDropdown)
|
const dropdown = new Dropdown(btnDropdown)
|
||||||
|
|
||||||
btnDropdown.addEventListener('shown.bs.dropdown', () => {
|
btnDropdown.addEventListener('shown.bs.dropdown', () => {
|
||||||
throw new Error('should not throw shown.bs.dropdown event')
|
reject(new Error('should not throw shown.bs.dropdown event'))
|
||||||
})
|
})
|
||||||
|
|
||||||
dropdown.show()
|
dropdown.show()
|
||||||
@ -731,7 +731,7 @@ describe('Dropdown', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
it('should not show a dropdown if show event is prevented', () => {
|
it('should not show a dropdown if show event is prevented', () => {
|
||||||
return new Promise(resolve => {
|
return new Promise((resolve, reject) => {
|
||||||
fixtureEl.innerHTML = [
|
fixtureEl.innerHTML = [
|
||||||
'<div class="dropdown">',
|
'<div class="dropdown">',
|
||||||
' <button class="btn dropdown-toggle" data-bs-toggle="dropdown">Dropdown</button>',
|
' <button class="btn dropdown-toggle" data-bs-toggle="dropdown">Dropdown</button>',
|
||||||
@ -749,7 +749,7 @@ describe('Dropdown', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
btnDropdown.addEventListener('shown.bs.dropdown', () => {
|
btnDropdown.addEventListener('shown.bs.dropdown', () => {
|
||||||
throw new Error('should not throw shown.bs.dropdown event')
|
reject(new Error('should not throw shown.bs.dropdown event'))
|
||||||
})
|
})
|
||||||
|
|
||||||
dropdown.show()
|
dropdown.show()
|
||||||
@ -817,7 +817,7 @@ describe('Dropdown', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
it('should not hide a dropdown if the element is disabled', () => {
|
it('should not hide a dropdown if the element is disabled', () => {
|
||||||
return new Promise(resolve => {
|
return new Promise((resolve, reject) => {
|
||||||
fixtureEl.innerHTML = [
|
fixtureEl.innerHTML = [
|
||||||
'<div class="dropdown">',
|
'<div class="dropdown">',
|
||||||
' <button disabled class="btn dropdown-toggle" data-bs-toggle="dropdown">Dropdown</button>',
|
' <button disabled class="btn dropdown-toggle" data-bs-toggle="dropdown">Dropdown</button>',
|
||||||
@ -832,7 +832,7 @@ describe('Dropdown', () => {
|
|||||||
const dropdown = new Dropdown(btnDropdown)
|
const dropdown = new Dropdown(btnDropdown)
|
||||||
|
|
||||||
btnDropdown.addEventListener('hidden.bs.dropdown', () => {
|
btnDropdown.addEventListener('hidden.bs.dropdown', () => {
|
||||||
throw new Error('should not throw hidden.bs.dropdown event')
|
reject(new Error('should not throw hidden.bs.dropdown event'))
|
||||||
})
|
})
|
||||||
|
|
||||||
dropdown.hide()
|
dropdown.hide()
|
||||||
@ -845,7 +845,7 @@ describe('Dropdown', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
it('should not hide a dropdown if the element contains .disabled', () => {
|
it('should not hide a dropdown if the element contains .disabled', () => {
|
||||||
return new Promise(resolve => {
|
return new Promise((resolve, reject) => {
|
||||||
fixtureEl.innerHTML = [
|
fixtureEl.innerHTML = [
|
||||||
'<div class="dropdown">',
|
'<div class="dropdown">',
|
||||||
' <button class="btn dropdown-toggle disabled" data-bs-toggle="dropdown">Dropdown</button>',
|
' <button class="btn dropdown-toggle disabled" data-bs-toggle="dropdown">Dropdown</button>',
|
||||||
@ -860,7 +860,7 @@ describe('Dropdown', () => {
|
|||||||
const dropdown = new Dropdown(btnDropdown)
|
const dropdown = new Dropdown(btnDropdown)
|
||||||
|
|
||||||
btnDropdown.addEventListener('hidden.bs.dropdown', () => {
|
btnDropdown.addEventListener('hidden.bs.dropdown', () => {
|
||||||
throw new Error('should not throw hidden.bs.dropdown event')
|
reject(new Error('should not throw hidden.bs.dropdown event'))
|
||||||
})
|
})
|
||||||
|
|
||||||
dropdown.hide()
|
dropdown.hide()
|
||||||
@ -873,7 +873,7 @@ describe('Dropdown', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
it('should not hide a dropdown if the menu is not shown', () => {
|
it('should not hide a dropdown if the menu is not shown', () => {
|
||||||
return new Promise(resolve => {
|
return new Promise((resolve, reject) => {
|
||||||
fixtureEl.innerHTML = [
|
fixtureEl.innerHTML = [
|
||||||
'<div class="dropdown">',
|
'<div class="dropdown">',
|
||||||
' <button class="btn dropdown-toggle" data-bs-toggle="dropdown">Dropdown</button>',
|
' <button class="btn dropdown-toggle" data-bs-toggle="dropdown">Dropdown</button>',
|
||||||
@ -887,7 +887,7 @@ describe('Dropdown', () => {
|
|||||||
const dropdown = new Dropdown(btnDropdown)
|
const dropdown = new Dropdown(btnDropdown)
|
||||||
|
|
||||||
btnDropdown.addEventListener('hidden.bs.dropdown', () => {
|
btnDropdown.addEventListener('hidden.bs.dropdown', () => {
|
||||||
throw new Error('should not throw hidden.bs.dropdown event')
|
reject(new Error('should not throw hidden.bs.dropdown event'))
|
||||||
})
|
})
|
||||||
|
|
||||||
dropdown.hide()
|
dropdown.hide()
|
||||||
@ -900,7 +900,7 @@ describe('Dropdown', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
it('should not hide a dropdown if hide event is prevented', () => {
|
it('should not hide a dropdown if hide event is prevented', () => {
|
||||||
return new Promise(resolve => {
|
return new Promise((resolve, reject) => {
|
||||||
fixtureEl.innerHTML = [
|
fixtureEl.innerHTML = [
|
||||||
'<div class="dropdown">',
|
'<div class="dropdown">',
|
||||||
' <button class="btn dropdown-toggle" data-bs-toggle="dropdown">Dropdown</button>',
|
' <button class="btn dropdown-toggle" data-bs-toggle="dropdown">Dropdown</button>',
|
||||||
@ -919,7 +919,7 @@ describe('Dropdown', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
btnDropdown.addEventListener('hidden.bs.dropdown', () => {
|
btnDropdown.addEventListener('hidden.bs.dropdown', () => {
|
||||||
throw new Error('should not throw hidden.bs.dropdown event')
|
reject(new Error('should not throw hidden.bs.dropdown event'))
|
||||||
})
|
})
|
||||||
|
|
||||||
dropdown.hide()
|
dropdown.hide()
|
||||||
|
@ -182,7 +182,7 @@ describe('Modal', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
it('should not fire shown event when show is prevented', () => {
|
it('should not fire shown event when show is prevented', () => {
|
||||||
return new Promise(resolve => {
|
return new Promise((resolve, reject) => {
|
||||||
fixtureEl.innerHTML = '<div class="modal"><div class="modal-dialog"></div></div>'
|
fixtureEl.innerHTML = '<div class="modal"><div class="modal-dialog"></div></div>'
|
||||||
|
|
||||||
const modalEl = fixtureEl.querySelector('.modal')
|
const modalEl = fixtureEl.querySelector('.modal')
|
||||||
@ -200,7 +200,7 @@ describe('Modal', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
modalEl.addEventListener('shown.bs.modal', () => {
|
modalEl.addEventListener('shown.bs.modal', () => {
|
||||||
throw new Error('shown event triggered')
|
reject(new Error('shown event triggered'))
|
||||||
})
|
})
|
||||||
|
|
||||||
modal.show()
|
modal.show()
|
||||||
@ -458,7 +458,7 @@ describe('Modal', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
it('should not close modal when clicking on modal-content', () => {
|
it('should not close modal when clicking on modal-content', () => {
|
||||||
return new Promise(resolve => {
|
return new Promise((resolve, reject) => {
|
||||||
fixtureEl.innerHTML = [
|
fixtureEl.innerHTML = [
|
||||||
'<div class="modal">',
|
'<div class="modal">',
|
||||||
' <div class="modal-dialog">',
|
' <div class="modal-dialog">',
|
||||||
@ -484,7 +484,7 @@ describe('Modal', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
modalEl.addEventListener('hidden.bs.modal', () => {
|
modalEl.addEventListener('hidden.bs.modal', () => {
|
||||||
throw new Error('Should not hide a modal')
|
reject(new Error('Should not hide a modal'))
|
||||||
})
|
})
|
||||||
|
|
||||||
modal.show()
|
modal.show()
|
||||||
@ -492,7 +492,7 @@ describe('Modal', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
it('should not close modal when clicking outside of modal-content if backdrop = false', () => {
|
it('should not close modal when clicking outside of modal-content if backdrop = false', () => {
|
||||||
return new Promise(resolve => {
|
return new Promise((resolve, reject) => {
|
||||||
fixtureEl.innerHTML = '<div class="modal"><div class="modal-dialog"></div></div>'
|
fixtureEl.innerHTML = '<div class="modal"><div class="modal-dialog"></div></div>'
|
||||||
|
|
||||||
const modalEl = fixtureEl.querySelector('.modal')
|
const modalEl = fixtureEl.querySelector('.modal')
|
||||||
@ -513,7 +513,7 @@ describe('Modal', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
modalEl.addEventListener('hidden.bs.modal', () => {
|
modalEl.addEventListener('hidden.bs.modal', () => {
|
||||||
throw new Error('Should not hide a modal')
|
reject(new Error('Should not hide a modal'))
|
||||||
})
|
})
|
||||||
|
|
||||||
modal.show()
|
modal.show()
|
||||||
@ -521,7 +521,7 @@ describe('Modal', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
it('should not close modal when clicking outside of modal-content if backdrop = static', () => {
|
it('should not close modal when clicking outside of modal-content if backdrop = static', () => {
|
||||||
return new Promise(resolve => {
|
return new Promise((resolve, reject) => {
|
||||||
fixtureEl.innerHTML = '<div class="modal"><div class="modal-dialog"></div></div>'
|
fixtureEl.innerHTML = '<div class="modal"><div class="modal-dialog"></div></div>'
|
||||||
|
|
||||||
const modalEl = fixtureEl.querySelector('.modal')
|
const modalEl = fixtureEl.querySelector('.modal')
|
||||||
@ -542,7 +542,7 @@ describe('Modal', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
modalEl.addEventListener('hidden.bs.modal', () => {
|
modalEl.addEventListener('hidden.bs.modal', () => {
|
||||||
throw new Error('Should not hide a modal')
|
reject(new Error('Should not hide a modal'))
|
||||||
})
|
})
|
||||||
|
|
||||||
modal.show()
|
modal.show()
|
||||||
@ -578,7 +578,7 @@ describe('Modal', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
it('should not close modal when escape key is pressed with keyboard = false', () => {
|
it('should not close modal when escape key is pressed with keyboard = false', () => {
|
||||||
return new Promise(resolve => {
|
return new Promise((resolve, reject) => {
|
||||||
fixtureEl.innerHTML = '<div class="modal"><div class="modal-dialog"></div></div>'
|
fixtureEl.innerHTML = '<div class="modal"><div class="modal-dialog"></div></div>'
|
||||||
|
|
||||||
const modalEl = fixtureEl.querySelector('.modal')
|
const modalEl = fixtureEl.querySelector('.modal')
|
||||||
@ -602,7 +602,7 @@ describe('Modal', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
modalEl.addEventListener('hidden.bs.modal', () => {
|
modalEl.addEventListener('hidden.bs.modal', () => {
|
||||||
throw new Error('Should not hide a modal')
|
reject(new Error('Should not hide a modal'))
|
||||||
})
|
})
|
||||||
|
|
||||||
modal.show()
|
modal.show()
|
||||||
@ -751,7 +751,7 @@ describe('Modal', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
it('should not hide a modal if hide is prevented', () => {
|
it('should not hide a modal if hide is prevented', () => {
|
||||||
return new Promise(resolve => {
|
return new Promise((resolve, reject) => {
|
||||||
fixtureEl.innerHTML = '<div class="modal"><div class="modal-dialog"></div></div>'
|
fixtureEl.innerHTML = '<div class="modal"><div class="modal-dialog"></div></div>'
|
||||||
|
|
||||||
const modalEl = fixtureEl.querySelector('.modal')
|
const modalEl = fixtureEl.querySelector('.modal')
|
||||||
@ -774,7 +774,7 @@ describe('Modal', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
modalEl.addEventListener('hidden.bs.modal', () => {
|
modalEl.addEventListener('hidden.bs.modal', () => {
|
||||||
throw new Error('should not trigger hidden')
|
reject(new Error('should not trigger hidden'))
|
||||||
})
|
})
|
||||||
|
|
||||||
modal.show()
|
modal.show()
|
||||||
|
@ -329,7 +329,7 @@ describe('Offcanvas', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
it('should not fire shown when show is prevented', () => {
|
it('should not fire shown when show is prevented', () => {
|
||||||
return new Promise(resolve => {
|
return new Promise((resolve, reject) => {
|
||||||
fixtureEl.innerHTML = '<div class="offcanvas"></div>'
|
fixtureEl.innerHTML = '<div class="offcanvas"></div>'
|
||||||
|
|
||||||
const offCanvasEl = fixtureEl.querySelector('div')
|
const offCanvasEl = fixtureEl.querySelector('div')
|
||||||
@ -349,7 +349,7 @@ describe('Offcanvas', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
offCanvasEl.addEventListener('shown.bs.offcanvas', () => {
|
offCanvasEl.addEventListener('shown.bs.offcanvas', () => {
|
||||||
throw new Error('should not fire shown event')
|
reject(new Error('should not fire shown event'))
|
||||||
})
|
})
|
||||||
|
|
||||||
offCanvas.show()
|
offCanvas.show()
|
||||||
@ -455,7 +455,7 @@ describe('Offcanvas', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
it('should not fire hidden when hide is prevented', () => {
|
it('should not fire hidden when hide is prevented', () => {
|
||||||
return new Promise(resolve => {
|
return new Promise((resolve, reject) => {
|
||||||
fixtureEl.innerHTML = '<div class="offcanvas"></div>'
|
fixtureEl.innerHTML = '<div class="offcanvas"></div>'
|
||||||
|
|
||||||
const offCanvasEl = fixtureEl.querySelector('div')
|
const offCanvasEl = fixtureEl.querySelector('div')
|
||||||
@ -477,7 +477,7 @@ describe('Offcanvas', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
offCanvasEl.addEventListener('hidden.bs.offcanvas', () => {
|
offCanvasEl.addEventListener('hidden.bs.offcanvas', () => {
|
||||||
throw new Error('should not fire hidden event')
|
reject(new Error('should not fire hidden event'))
|
||||||
})
|
})
|
||||||
|
|
||||||
offCanvas.hide()
|
offCanvas.hide()
|
||||||
|
@ -167,7 +167,7 @@ describe('Tab', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
it('should not fire shown when show is prevented', () => {
|
it('should not fire shown when show is prevented', () => {
|
||||||
return new Promise(resolve => {
|
return new Promise((resolve, reject) => {
|
||||||
fixtureEl.innerHTML = '<div class="nav"></div>'
|
fixtureEl.innerHTML = '<div class="nav"></div>'
|
||||||
|
|
||||||
const navEl = fixtureEl.querySelector('div')
|
const navEl = fixtureEl.querySelector('div')
|
||||||
@ -185,7 +185,7 @@ describe('Tab', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
navEl.addEventListener('shown.bs.tab', () => {
|
navEl.addEventListener('shown.bs.tab', () => {
|
||||||
throw new Error('should not trigger shown event')
|
reject(new Error('should not trigger shown event'))
|
||||||
})
|
})
|
||||||
|
|
||||||
tab.show()
|
tab.show()
|
||||||
@ -193,7 +193,7 @@ describe('Tab', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
it('should not fire shown when tab is already active', () => {
|
it('should not fire shown when tab is already active', () => {
|
||||||
return new Promise(resolve => {
|
return new Promise((resolve, reject) => {
|
||||||
fixtureEl.innerHTML = [
|
fixtureEl.innerHTML = [
|
||||||
'<ul class="nav nav-tabs" role="tablist">',
|
'<ul class="nav nav-tabs" role="tablist">',
|
||||||
' <li class="nav-item" role="presentation"><button type="button" data-bs-target="#home" class="nav-link active" role="tab" aria-selected="true">Home</button></li>',
|
' <li class="nav-item" role="presentation"><button type="button" data-bs-target="#home" class="nav-link active" role="tab" aria-selected="true">Home</button></li>',
|
||||||
@ -209,7 +209,7 @@ describe('Tab', () => {
|
|||||||
const tab = new Tab(triggerActive)
|
const tab = new Tab(triggerActive)
|
||||||
|
|
||||||
triggerActive.addEventListener('shown.bs.tab', () => {
|
triggerActive.addEventListener('shown.bs.tab', () => {
|
||||||
throw new Error('should not trigger shown event')
|
reject(new Error('should not trigger shown event'))
|
||||||
})
|
})
|
||||||
|
|
||||||
tab.show()
|
tab.show()
|
||||||
@ -285,7 +285,7 @@ describe('Tab', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
it('should not fire hidden when hide is prevented', () => {
|
it('should not fire hidden when hide is prevented', () => {
|
||||||
return new Promise(resolve => {
|
return new Promise((resolve, reject) => {
|
||||||
fixtureEl.innerHTML = [
|
fixtureEl.innerHTML = [
|
||||||
'<ul class="nav" role="tablist">',
|
'<ul class="nav" role="tablist">',
|
||||||
' <li><button type="button" data-bs-target="#home" role="tab">Home</button></li>',
|
' <li><button type="button" data-bs-target="#home" role="tab">Home</button></li>',
|
||||||
@ -313,7 +313,7 @@ describe('Tab', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
triggerList[0].addEventListener('hidden.bs.tab', () => {
|
triggerList[0].addEventListener('hidden.bs.tab', () => {
|
||||||
throw new Error('should not trigger hidden')
|
reject(new Error('should not trigger hidden'))
|
||||||
})
|
})
|
||||||
|
|
||||||
firstTab.show()
|
firstTab.show()
|
||||||
@ -751,7 +751,7 @@ describe('Tab', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
it('should not fire shown when tab has disabled attribute', () => {
|
it('should not fire shown when tab has disabled attribute', () => {
|
||||||
return new Promise(resolve => {
|
return new Promise((resolve, reject) => {
|
||||||
fixtureEl.innerHTML = [
|
fixtureEl.innerHTML = [
|
||||||
'<ul class="nav nav-tabs" role="tablist">',
|
'<ul class="nav nav-tabs" role="tablist">',
|
||||||
' <li class="nav-item" role="presentation"><button type="button" data-bs-target="#home" class="nav-link active" role="tab" aria-selected="true">Home</button></li>',
|
' <li class="nav-item" role="presentation"><button type="button" data-bs-target="#home" class="nav-link active" role="tab" aria-selected="true">Home</button></li>',
|
||||||
@ -765,7 +765,7 @@ describe('Tab', () => {
|
|||||||
|
|
||||||
const triggerDisabled = fixtureEl.querySelector('button[disabled]')
|
const triggerDisabled = fixtureEl.querySelector('button[disabled]')
|
||||||
triggerDisabled.addEventListener('shown.bs.tab', () => {
|
triggerDisabled.addEventListener('shown.bs.tab', () => {
|
||||||
throw new Error('should not trigger shown event')
|
reject(new Error('should not trigger shown event'))
|
||||||
})
|
})
|
||||||
|
|
||||||
triggerDisabled.click()
|
triggerDisabled.click()
|
||||||
@ -777,7 +777,7 @@ describe('Tab', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
it('should not fire shown when tab has disabled class', () => {
|
it('should not fire shown when tab has disabled class', () => {
|
||||||
return new Promise(resolve => {
|
return new Promise((resolve, reject) => {
|
||||||
fixtureEl.innerHTML = [
|
fixtureEl.innerHTML = [
|
||||||
'<ul class="nav nav-tabs" role="tablist">',
|
'<ul class="nav nav-tabs" role="tablist">',
|
||||||
' <li class="nav-item" role="presentation"><a href="#home" class="nav-link active" role="tab" aria-selected="true">Home</a></li>',
|
' <li class="nav-item" role="presentation"><a href="#home" class="nav-link active" role="tab" aria-selected="true">Home</a></li>',
|
||||||
@ -792,7 +792,7 @@ describe('Tab', () => {
|
|||||||
const triggerDisabled = fixtureEl.querySelector('a.disabled')
|
const triggerDisabled = fixtureEl.querySelector('a.disabled')
|
||||||
|
|
||||||
triggerDisabled.addEventListener('shown.bs.tab', () => {
|
triggerDisabled.addEventListener('shown.bs.tab', () => {
|
||||||
throw new Error('should not trigger shown event')
|
reject(new Error('should not trigger shown event'))
|
||||||
})
|
})
|
||||||
|
|
||||||
triggerDisabled.click()
|
triggerDisabled.click()
|
||||||
|
@ -160,7 +160,7 @@ describe('Toast', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
it('should not trigger shown if show is prevented', () => {
|
it('should not trigger shown if show is prevented', () => {
|
||||||
return new Promise(resolve => {
|
return new Promise((resolve, reject) => {
|
||||||
fixtureEl.innerHTML = [
|
fixtureEl.innerHTML = [
|
||||||
'<div class="toast" data-bs-delay="1" data-bs-animation="false">',
|
'<div class="toast" data-bs-delay="1" data-bs-animation="false">',
|
||||||
' <div class="toast-body">',
|
' <div class="toast-body">',
|
||||||
@ -185,7 +185,7 @@ describe('Toast', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
toastEl.addEventListener('shown.bs.toast', () => {
|
toastEl.addEventListener('shown.bs.toast', () => {
|
||||||
throw new Error('shown event should not be triggered if show is prevented')
|
reject(new Error('shown event should not be triggered if show is prevented'))
|
||||||
})
|
})
|
||||||
|
|
||||||
toast.show()
|
toast.show()
|
||||||
@ -449,7 +449,7 @@ describe('Toast', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
it('should not trigger hidden if hide is prevented', () => {
|
it('should not trigger hidden if hide is prevented', () => {
|
||||||
return new Promise(resolve => {
|
return new Promise((resolve, reject) => {
|
||||||
fixtureEl.innerHTML = [
|
fixtureEl.innerHTML = [
|
||||||
'<div class="toast" data-bs-delay="1" data-bs-animation="false">',
|
'<div class="toast" data-bs-delay="1" data-bs-animation="false">',
|
||||||
' <div class="toast-body">',
|
' <div class="toast-body">',
|
||||||
@ -478,7 +478,7 @@ describe('Toast', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
toastEl.addEventListener('hidden.bs.toast', () => {
|
toastEl.addEventListener('hidden.bs.toast', () => {
|
||||||
throw new Error('hidden event should not be triggered if hide is prevented')
|
reject(new Error('hidden event should not be triggered if hide is prevented'))
|
||||||
})
|
})
|
||||||
|
|
||||||
toast.show()
|
toast.show()
|
||||||
|
@ -211,7 +211,7 @@ describe('Tooltip', () => {
|
|||||||
|
|
||||||
describe('disable', () => {
|
describe('disable', () => {
|
||||||
it('should disable tooltip', () => {
|
it('should disable tooltip', () => {
|
||||||
return new Promise(resolve => {
|
return new Promise((resolve, reject) => {
|
||||||
fixtureEl.innerHTML = '<a href="#" rel="tooltip" title="Another tooltip">'
|
fixtureEl.innerHTML = '<a href="#" rel="tooltip" title="Another tooltip">'
|
||||||
|
|
||||||
const tooltipEl = fixtureEl.querySelector('a')
|
const tooltipEl = fixtureEl.querySelector('a')
|
||||||
@ -220,7 +220,7 @@ describe('Tooltip', () => {
|
|||||||
tooltip.disable()
|
tooltip.disable()
|
||||||
|
|
||||||
tooltipEl.addEventListener('show.bs.tooltip', () => {
|
tooltipEl.addEventListener('show.bs.tooltip', () => {
|
||||||
throw new Error('should not show a disabled tooltip')
|
reject(new Error('should not show a disabled tooltip'))
|
||||||
})
|
})
|
||||||
|
|
||||||
tooltip.show()
|
tooltip.show()
|
||||||
@ -250,7 +250,7 @@ describe('Tooltip', () => {
|
|||||||
|
|
||||||
describe('toggle', () => {
|
describe('toggle', () => {
|
||||||
it('should do nothing if disabled', () => {
|
it('should do nothing if disabled', () => {
|
||||||
return new Promise(resolve => {
|
return new Promise((resolve, reject) => {
|
||||||
fixtureEl.innerHTML = '<a href="#" rel="tooltip" title="Another tooltip">'
|
fixtureEl.innerHTML = '<a href="#" rel="tooltip" title="Another tooltip">'
|
||||||
|
|
||||||
const tooltipEl = fixtureEl.querySelector('a')
|
const tooltipEl = fixtureEl.querySelector('a')
|
||||||
@ -259,7 +259,7 @@ describe('Tooltip', () => {
|
|||||||
tooltip.disable()
|
tooltip.disable()
|
||||||
|
|
||||||
tooltipEl.addEventListener('show.bs.tooltip', () => {
|
tooltipEl.addEventListener('show.bs.tooltip', () => {
|
||||||
throw new Error('should not show a disabled tooltip')
|
reject(new Error('should not show a disabled tooltip'))
|
||||||
})
|
})
|
||||||
|
|
||||||
tooltip.toggle()
|
tooltip.toggle()
|
||||||
@ -652,7 +652,7 @@ describe('Tooltip', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
it('should not show a tooltip if show.bs.tooltip is prevented', () => {
|
it('should not show a tooltip if show.bs.tooltip is prevented', () => {
|
||||||
return new Promise(resolve => {
|
return new Promise((resolve, reject) => {
|
||||||
fixtureEl.innerHTML = '<a href="#" rel="tooltip" title="Another tooltip">'
|
fixtureEl.innerHTML = '<a href="#" rel="tooltip" title="Another tooltip">'
|
||||||
|
|
||||||
const tooltipEl = fixtureEl.querySelector('a')
|
const tooltipEl = fixtureEl.querySelector('a')
|
||||||
@ -671,7 +671,7 @@ describe('Tooltip', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
tooltipEl.addEventListener('shown.bs.tooltip', () => {
|
tooltipEl.addEventListener('shown.bs.tooltip', () => {
|
||||||
throw new Error('Tooltip should not be shown')
|
reject(new Error('Tooltip should not be shown'))
|
||||||
})
|
})
|
||||||
|
|
||||||
tooltip.show()
|
tooltip.show()
|
||||||
@ -1001,7 +1001,7 @@ describe('Tooltip', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
it('should not hide a tooltip if hide event is prevented', () => {
|
it('should not hide a tooltip if hide event is prevented', () => {
|
||||||
return new Promise(resolve => {
|
return new Promise((resolve, reject) => {
|
||||||
fixtureEl.innerHTML = '<a href="#" rel="tooltip" title="Another tooltip">'
|
fixtureEl.innerHTML = '<a href="#" rel="tooltip" title="Another tooltip">'
|
||||||
|
|
||||||
const assertDone = () => {
|
const assertDone = () => {
|
||||||
@ -1022,7 +1022,7 @@ describe('Tooltip', () => {
|
|||||||
assertDone()
|
assertDone()
|
||||||
})
|
})
|
||||||
tooltipEl.addEventListener('hidden.bs.tooltip', () => {
|
tooltipEl.addEventListener('hidden.bs.tooltip', () => {
|
||||||
throw new Error('should not trigger hidden event')
|
reject(new Error('should not trigger hidden event'))
|
||||||
})
|
})
|
||||||
|
|
||||||
tooltip.show()
|
tooltip.show()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user