mirror of
https://github.com/twbs/bootstrap.git
synced 2025-01-18 10:52:19 +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', () => {
|
||||
return new Promise(resolve => {
|
||||
return new Promise((resolve, reject) => {
|
||||
fixtureEl.innerHTML = '<div class="alert"></div>'
|
||||
|
||||
const getAlert = () => document.querySelector('.alert')
|
||||
@ -118,7 +118,7 @@ describe('Alert', () => {
|
||||
})
|
||||
|
||||
alertEl.addEventListener('closed.bs.alert', () => {
|
||||
throw new Error('should not fire closed event')
|
||||
reject(new Error('should not fire closed event'))
|
||||
})
|
||||
|
||||
alert.close()
|
||||
|
@ -270,7 +270,7 @@ describe('Carousel', () => {
|
||||
})
|
||||
|
||||
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 = [
|
||||
'<div id="myCarousel" class="carousel slide">',
|
||||
' <div class="carousel-inner">',
|
||||
@ -286,7 +286,7 @@ describe('Carousel', () => {
|
||||
const carousel = new Carousel(carouselEl, { wrap: false })
|
||||
|
||||
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()
|
||||
|
@ -385,7 +385,7 @@ describe('Collapse', () => {
|
||||
})
|
||||
|
||||
it('should not fire shown when show is prevented', () => {
|
||||
return new Promise(resolve => {
|
||||
return new Promise((resolve, reject) => {
|
||||
fixtureEl.innerHTML = '<div class="collapse"></div>'
|
||||
|
||||
const collapseEl = fixtureEl.querySelector('div')
|
||||
@ -406,7 +406,7 @@ describe('Collapse', () => {
|
||||
})
|
||||
|
||||
collapseEl.addEventListener('shown.bs.collapse', () => {
|
||||
throw new Error('should not fire shown event')
|
||||
reject(new Error('should not fire shown event'))
|
||||
})
|
||||
|
||||
collapse.show()
|
||||
@ -466,7 +466,7 @@ describe('Collapse', () => {
|
||||
})
|
||||
|
||||
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>'
|
||||
|
||||
const collapseEl = fixtureEl.querySelector('div')
|
||||
@ -487,7 +487,7 @@ describe('Collapse', () => {
|
||||
})
|
||||
|
||||
collapseEl.addEventListener('hidden.bs.collapse', () => {
|
||||
throw new Error('should not fire hidden event')
|
||||
reject(new Error('should not fire hidden event'))
|
||||
})
|
||||
|
||||
collapse.hide()
|
||||
|
@ -373,12 +373,12 @@ describe('EventHandler', () => {
|
||||
})
|
||||
|
||||
it('should remove a listener registered by .one', () => {
|
||||
return new Promise(resolve => {
|
||||
return new Promise((resolve, reject) => {
|
||||
fixtureEl.innerHTML = '<div></div>'
|
||||
|
||||
const div = fixtureEl.querySelector('div')
|
||||
const handler = () => {
|
||||
throw new Error('called')
|
||||
reject(new Error('called'))
|
||||
}
|
||||
|
||||
EventHandler.one(div, 'foobar', handler)
|
||||
|
@ -513,7 +513,7 @@ describe('Dropdown', () => {
|
||||
})
|
||||
|
||||
it('should not toggle a dropdown if the element is disabled', () => {
|
||||
return new Promise(resolve => {
|
||||
return new Promise((resolve, reject) => {
|
||||
fixtureEl.innerHTML = [
|
||||
'<div class="dropdown">',
|
||||
' <button disabled class="btn dropdown-toggle" data-bs-toggle="dropdown">Dropdown</button>',
|
||||
@ -527,7 +527,7 @@ describe('Dropdown', () => {
|
||||
const dropdown = new Dropdown(btnDropdown)
|
||||
|
||||
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()
|
||||
@ -540,7 +540,7 @@ describe('Dropdown', () => {
|
||||
})
|
||||
|
||||
it('should not toggle a dropdown if the element contains .disabled', () => {
|
||||
return new Promise(resolve => {
|
||||
return new Promise((resolve, reject) => {
|
||||
fixtureEl.innerHTML = [
|
||||
'<div class="dropdown">',
|
||||
' <button class="btn dropdown-toggle disabled" data-bs-toggle="dropdown">Dropdown</button>',
|
||||
@ -554,7 +554,7 @@ describe('Dropdown', () => {
|
||||
const dropdown = new Dropdown(btnDropdown)
|
||||
|
||||
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()
|
||||
@ -567,7 +567,7 @@ describe('Dropdown', () => {
|
||||
})
|
||||
|
||||
it('should not toggle a dropdown if the menu is shown', () => {
|
||||
return new Promise(resolve => {
|
||||
return new Promise((resolve, reject) => {
|
||||
fixtureEl.innerHTML = [
|
||||
'<div class="dropdown">',
|
||||
' <button class="btn dropdown-toggle" data-bs-toggle="dropdown">Dropdown</button>',
|
||||
@ -581,7 +581,7 @@ describe('Dropdown', () => {
|
||||
const dropdown = new Dropdown(btnDropdown)
|
||||
|
||||
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()
|
||||
@ -594,7 +594,7 @@ describe('Dropdown', () => {
|
||||
})
|
||||
|
||||
it('should not toggle a dropdown if show event is prevented', () => {
|
||||
return new Promise(resolve => {
|
||||
return new Promise((resolve, reject) => {
|
||||
fixtureEl.innerHTML = [
|
||||
'<div class="dropdown">',
|
||||
' <button class="btn dropdown-toggle" data-bs-toggle="dropdown">Dropdown</button>',
|
||||
@ -612,7 +612,7 @@ describe('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()
|
||||
@ -650,7 +650,7 @@ describe('Dropdown', () => {
|
||||
})
|
||||
|
||||
it('should not show a dropdown if the element is disabled', () => {
|
||||
return new Promise(resolve => {
|
||||
return new Promise((resolve, reject) => {
|
||||
fixtureEl.innerHTML = [
|
||||
'<div class="dropdown">',
|
||||
' <button disabled class="btn dropdown-toggle" data-bs-toggle="dropdown">Dropdown</button>',
|
||||
@ -664,7 +664,7 @@ describe('Dropdown', () => {
|
||||
const dropdown = new Dropdown(btnDropdown)
|
||||
|
||||
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()
|
||||
@ -677,7 +677,7 @@ describe('Dropdown', () => {
|
||||
})
|
||||
|
||||
it('should not show a dropdown if the element contains .disabled', () => {
|
||||
return new Promise(resolve => {
|
||||
return new Promise((resolve, reject) => {
|
||||
fixtureEl.innerHTML = [
|
||||
'<div class="dropdown">',
|
||||
' <button class="btn dropdown-toggle disabled" data-bs-toggle="dropdown">Dropdown</button>',
|
||||
@ -691,7 +691,7 @@ describe('Dropdown', () => {
|
||||
const dropdown = new Dropdown(btnDropdown)
|
||||
|
||||
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()
|
||||
@ -704,7 +704,7 @@ describe('Dropdown', () => {
|
||||
})
|
||||
|
||||
it('should not show a dropdown if the menu is shown', () => {
|
||||
return new Promise(resolve => {
|
||||
return new Promise((resolve, reject) => {
|
||||
fixtureEl.innerHTML = [
|
||||
'<div class="dropdown">',
|
||||
' <button class="btn dropdown-toggle" data-bs-toggle="dropdown">Dropdown</button>',
|
||||
@ -718,7 +718,7 @@ describe('Dropdown', () => {
|
||||
const dropdown = new Dropdown(btnDropdown)
|
||||
|
||||
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()
|
||||
@ -731,7 +731,7 @@ describe('Dropdown', () => {
|
||||
})
|
||||
|
||||
it('should not show a dropdown if show event is prevented', () => {
|
||||
return new Promise(resolve => {
|
||||
return new Promise((resolve, reject) => {
|
||||
fixtureEl.innerHTML = [
|
||||
'<div class="dropdown">',
|
||||
' <button class="btn dropdown-toggle" data-bs-toggle="dropdown">Dropdown</button>',
|
||||
@ -749,7 +749,7 @@ describe('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()
|
||||
@ -817,7 +817,7 @@ describe('Dropdown', () => {
|
||||
})
|
||||
|
||||
it('should not hide a dropdown if the element is disabled', () => {
|
||||
return new Promise(resolve => {
|
||||
return new Promise((resolve, reject) => {
|
||||
fixtureEl.innerHTML = [
|
||||
'<div class="dropdown">',
|
||||
' <button disabled class="btn dropdown-toggle" data-bs-toggle="dropdown">Dropdown</button>',
|
||||
@ -832,7 +832,7 @@ describe('Dropdown', () => {
|
||||
const dropdown = new Dropdown(btnDropdown)
|
||||
|
||||
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()
|
||||
@ -845,7 +845,7 @@ describe('Dropdown', () => {
|
||||
})
|
||||
|
||||
it('should not hide a dropdown if the element contains .disabled', () => {
|
||||
return new Promise(resolve => {
|
||||
return new Promise((resolve, reject) => {
|
||||
fixtureEl.innerHTML = [
|
||||
'<div class="dropdown">',
|
||||
' <button class="btn dropdown-toggle disabled" data-bs-toggle="dropdown">Dropdown</button>',
|
||||
@ -860,7 +860,7 @@ describe('Dropdown', () => {
|
||||
const dropdown = new Dropdown(btnDropdown)
|
||||
|
||||
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()
|
||||
@ -873,7 +873,7 @@ describe('Dropdown', () => {
|
||||
})
|
||||
|
||||
it('should not hide a dropdown if the menu is not shown', () => {
|
||||
return new Promise(resolve => {
|
||||
return new Promise((resolve, reject) => {
|
||||
fixtureEl.innerHTML = [
|
||||
'<div class="dropdown">',
|
||||
' <button class="btn dropdown-toggle" data-bs-toggle="dropdown">Dropdown</button>',
|
||||
@ -887,7 +887,7 @@ describe('Dropdown', () => {
|
||||
const dropdown = new Dropdown(btnDropdown)
|
||||
|
||||
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()
|
||||
@ -900,7 +900,7 @@ describe('Dropdown', () => {
|
||||
})
|
||||
|
||||
it('should not hide a dropdown if hide event is prevented', () => {
|
||||
return new Promise(resolve => {
|
||||
return new Promise((resolve, reject) => {
|
||||
fixtureEl.innerHTML = [
|
||||
'<div class="dropdown">',
|
||||
' <button class="btn dropdown-toggle" data-bs-toggle="dropdown">Dropdown</button>',
|
||||
@ -919,7 +919,7 @@ describe('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()
|
||||
|
@ -182,7 +182,7 @@ describe('Modal', () => {
|
||||
})
|
||||
|
||||
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>'
|
||||
|
||||
const modalEl = fixtureEl.querySelector('.modal')
|
||||
@ -200,7 +200,7 @@ describe('Modal', () => {
|
||||
})
|
||||
|
||||
modalEl.addEventListener('shown.bs.modal', () => {
|
||||
throw new Error('shown event triggered')
|
||||
reject(new Error('shown event triggered'))
|
||||
})
|
||||
|
||||
modal.show()
|
||||
@ -458,7 +458,7 @@ describe('Modal', () => {
|
||||
})
|
||||
|
||||
it('should not close modal when clicking on modal-content', () => {
|
||||
return new Promise(resolve => {
|
||||
return new Promise((resolve, reject) => {
|
||||
fixtureEl.innerHTML = [
|
||||
'<div class="modal">',
|
||||
' <div class="modal-dialog">',
|
||||
@ -484,7 +484,7 @@ describe('Modal', () => {
|
||||
})
|
||||
|
||||
modalEl.addEventListener('hidden.bs.modal', () => {
|
||||
throw new Error('Should not hide a modal')
|
||||
reject(new Error('Should not hide a modal'))
|
||||
})
|
||||
|
||||
modal.show()
|
||||
@ -492,7 +492,7 @@ describe('Modal', () => {
|
||||
})
|
||||
|
||||
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>'
|
||||
|
||||
const modalEl = fixtureEl.querySelector('.modal')
|
||||
@ -513,7 +513,7 @@ describe('Modal', () => {
|
||||
})
|
||||
|
||||
modalEl.addEventListener('hidden.bs.modal', () => {
|
||||
throw new Error('Should not hide a modal')
|
||||
reject(new Error('Should not hide a modal'))
|
||||
})
|
||||
|
||||
modal.show()
|
||||
@ -521,7 +521,7 @@ describe('Modal', () => {
|
||||
})
|
||||
|
||||
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>'
|
||||
|
||||
const modalEl = fixtureEl.querySelector('.modal')
|
||||
@ -542,7 +542,7 @@ describe('Modal', () => {
|
||||
})
|
||||
|
||||
modalEl.addEventListener('hidden.bs.modal', () => {
|
||||
throw new Error('Should not hide a modal')
|
||||
reject(new Error('Should not hide a modal'))
|
||||
})
|
||||
|
||||
modal.show()
|
||||
@ -578,7 +578,7 @@ describe('Modal', () => {
|
||||
})
|
||||
|
||||
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>'
|
||||
|
||||
const modalEl = fixtureEl.querySelector('.modal')
|
||||
@ -602,7 +602,7 @@ describe('Modal', () => {
|
||||
})
|
||||
|
||||
modalEl.addEventListener('hidden.bs.modal', () => {
|
||||
throw new Error('Should not hide a modal')
|
||||
reject(new Error('Should not hide a modal'))
|
||||
})
|
||||
|
||||
modal.show()
|
||||
@ -751,7 +751,7 @@ describe('Modal', () => {
|
||||
})
|
||||
|
||||
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>'
|
||||
|
||||
const modalEl = fixtureEl.querySelector('.modal')
|
||||
@ -774,7 +774,7 @@ describe('Modal', () => {
|
||||
})
|
||||
|
||||
modalEl.addEventListener('hidden.bs.modal', () => {
|
||||
throw new Error('should not trigger hidden')
|
||||
reject(new Error('should not trigger hidden'))
|
||||
})
|
||||
|
||||
modal.show()
|
||||
|
@ -329,7 +329,7 @@ describe('Offcanvas', () => {
|
||||
})
|
||||
|
||||
it('should not fire shown when show is prevented', () => {
|
||||
return new Promise(resolve => {
|
||||
return new Promise((resolve, reject) => {
|
||||
fixtureEl.innerHTML = '<div class="offcanvas"></div>'
|
||||
|
||||
const offCanvasEl = fixtureEl.querySelector('div')
|
||||
@ -349,7 +349,7 @@ describe('Offcanvas', () => {
|
||||
})
|
||||
|
||||
offCanvasEl.addEventListener('shown.bs.offcanvas', () => {
|
||||
throw new Error('should not fire shown event')
|
||||
reject(new Error('should not fire shown event'))
|
||||
})
|
||||
|
||||
offCanvas.show()
|
||||
@ -455,7 +455,7 @@ describe('Offcanvas', () => {
|
||||
})
|
||||
|
||||
it('should not fire hidden when hide is prevented', () => {
|
||||
return new Promise(resolve => {
|
||||
return new Promise((resolve, reject) => {
|
||||
fixtureEl.innerHTML = '<div class="offcanvas"></div>'
|
||||
|
||||
const offCanvasEl = fixtureEl.querySelector('div')
|
||||
@ -477,7 +477,7 @@ describe('Offcanvas', () => {
|
||||
})
|
||||
|
||||
offCanvasEl.addEventListener('hidden.bs.offcanvas', () => {
|
||||
throw new Error('should not fire hidden event')
|
||||
reject(new Error('should not fire hidden event'))
|
||||
})
|
||||
|
||||
offCanvas.hide()
|
||||
|
@ -167,7 +167,7 @@ describe('Tab', () => {
|
||||
})
|
||||
|
||||
it('should not fire shown when show is prevented', () => {
|
||||
return new Promise(resolve => {
|
||||
return new Promise((resolve, reject) => {
|
||||
fixtureEl.innerHTML = '<div class="nav"></div>'
|
||||
|
||||
const navEl = fixtureEl.querySelector('div')
|
||||
@ -185,7 +185,7 @@ describe('Tab', () => {
|
||||
})
|
||||
|
||||
navEl.addEventListener('shown.bs.tab', () => {
|
||||
throw new Error('should not trigger shown event')
|
||||
reject(new Error('should not trigger shown event'))
|
||||
})
|
||||
|
||||
tab.show()
|
||||
@ -193,7 +193,7 @@ describe('Tab', () => {
|
||||
})
|
||||
|
||||
it('should not fire shown when tab is already active', () => {
|
||||
return new Promise(resolve => {
|
||||
return new Promise((resolve, reject) => {
|
||||
fixtureEl.innerHTML = [
|
||||
'<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>',
|
||||
@ -209,7 +209,7 @@ describe('Tab', () => {
|
||||
const tab = new Tab(triggerActive)
|
||||
|
||||
triggerActive.addEventListener('shown.bs.tab', () => {
|
||||
throw new Error('should not trigger shown event')
|
||||
reject(new Error('should not trigger shown event'))
|
||||
})
|
||||
|
||||
tab.show()
|
||||
@ -285,7 +285,7 @@ describe('Tab', () => {
|
||||
})
|
||||
|
||||
it('should not fire hidden when hide is prevented', () => {
|
||||
return new Promise(resolve => {
|
||||
return new Promise((resolve, reject) => {
|
||||
fixtureEl.innerHTML = [
|
||||
'<ul class="nav" role="tablist">',
|
||||
' <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', () => {
|
||||
throw new Error('should not trigger hidden')
|
||||
reject(new Error('should not trigger hidden'))
|
||||
})
|
||||
|
||||
firstTab.show()
|
||||
@ -751,7 +751,7 @@ describe('Tab', () => {
|
||||
})
|
||||
|
||||
it('should not fire shown when tab has disabled attribute', () => {
|
||||
return new Promise(resolve => {
|
||||
return new Promise((resolve, reject) => {
|
||||
fixtureEl.innerHTML = [
|
||||
'<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>',
|
||||
@ -765,7 +765,7 @@ describe('Tab', () => {
|
||||
|
||||
const triggerDisabled = fixtureEl.querySelector('button[disabled]')
|
||||
triggerDisabled.addEventListener('shown.bs.tab', () => {
|
||||
throw new Error('should not trigger shown event')
|
||||
reject(new Error('should not trigger shown event'))
|
||||
})
|
||||
|
||||
triggerDisabled.click()
|
||||
@ -777,7 +777,7 @@ describe('Tab', () => {
|
||||
})
|
||||
|
||||
it('should not fire shown when tab has disabled class', () => {
|
||||
return new Promise(resolve => {
|
||||
return new Promise((resolve, reject) => {
|
||||
fixtureEl.innerHTML = [
|
||||
'<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>',
|
||||
@ -792,7 +792,7 @@ describe('Tab', () => {
|
||||
const triggerDisabled = fixtureEl.querySelector('a.disabled')
|
||||
|
||||
triggerDisabled.addEventListener('shown.bs.tab', () => {
|
||||
throw new Error('should not trigger shown event')
|
||||
reject(new Error('should not trigger shown event'))
|
||||
})
|
||||
|
||||
triggerDisabled.click()
|
||||
|
@ -160,7 +160,7 @@ describe('Toast', () => {
|
||||
})
|
||||
|
||||
it('should not trigger shown if show is prevented', () => {
|
||||
return new Promise(resolve => {
|
||||
return new Promise((resolve, reject) => {
|
||||
fixtureEl.innerHTML = [
|
||||
'<div class="toast" data-bs-delay="1" data-bs-animation="false">',
|
||||
' <div class="toast-body">',
|
||||
@ -185,7 +185,7 @@ describe('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()
|
||||
@ -449,7 +449,7 @@ describe('Toast', () => {
|
||||
})
|
||||
|
||||
it('should not trigger hidden if hide is prevented', () => {
|
||||
return new Promise(resolve => {
|
||||
return new Promise((resolve, reject) => {
|
||||
fixtureEl.innerHTML = [
|
||||
'<div class="toast" data-bs-delay="1" data-bs-animation="false">',
|
||||
' <div class="toast-body">',
|
||||
@ -478,7 +478,7 @@ describe('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()
|
||||
|
@ -211,7 +211,7 @@ describe('Tooltip', () => {
|
||||
|
||||
describe('disable', () => {
|
||||
it('should disable tooltip', () => {
|
||||
return new Promise(resolve => {
|
||||
return new Promise((resolve, reject) => {
|
||||
fixtureEl.innerHTML = '<a href="#" rel="tooltip" title="Another tooltip">'
|
||||
|
||||
const tooltipEl = fixtureEl.querySelector('a')
|
||||
@ -220,7 +220,7 @@ describe('Tooltip', () => {
|
||||
tooltip.disable()
|
||||
|
||||
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()
|
||||
@ -250,7 +250,7 @@ describe('Tooltip', () => {
|
||||
|
||||
describe('toggle', () => {
|
||||
it('should do nothing if disabled', () => {
|
||||
return new Promise(resolve => {
|
||||
return new Promise((resolve, reject) => {
|
||||
fixtureEl.innerHTML = '<a href="#" rel="tooltip" title="Another tooltip">'
|
||||
|
||||
const tooltipEl = fixtureEl.querySelector('a')
|
||||
@ -259,7 +259,7 @@ describe('Tooltip', () => {
|
||||
tooltip.disable()
|
||||
|
||||
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()
|
||||
@ -652,7 +652,7 @@ describe('Tooltip', () => {
|
||||
})
|
||||
|
||||
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">'
|
||||
|
||||
const tooltipEl = fixtureEl.querySelector('a')
|
||||
@ -671,7 +671,7 @@ describe('Tooltip', () => {
|
||||
})
|
||||
|
||||
tooltipEl.addEventListener('shown.bs.tooltip', () => {
|
||||
throw new Error('Tooltip should not be shown')
|
||||
reject(new Error('Tooltip should not be shown'))
|
||||
})
|
||||
|
||||
tooltip.show()
|
||||
@ -1001,7 +1001,7 @@ describe('Tooltip', () => {
|
||||
})
|
||||
|
||||
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">'
|
||||
|
||||
const assertDone = () => {
|
||||
@ -1022,7 +1022,7 @@ describe('Tooltip', () => {
|
||||
assertDone()
|
||||
})
|
||||
tooltipEl.addEventListener('hidden.bs.tooltip', () => {
|
||||
throw new Error('should not trigger hidden event')
|
||||
reject(new Error('should not trigger hidden event'))
|
||||
})
|
||||
|
||||
tooltip.show()
|
||||
|
Loading…
x
Reference in New Issue
Block a user