mirror of
https://github.com/twbs/bootstrap.git
synced 2025-08-16 18:44:01 +02:00
Clear timeout before showing the toast (#31155)
* clear timeout before showing the toast * Add unit test * Remove the check for timeout * Check for clearTimeout to have been called Co-authored-by: XhmikosR <xhmikosr@gmail.com>
This commit is contained in:
@@ -170,6 +170,33 @@ describe('Toast', () => {
|
||||
|
||||
toast.show()
|
||||
})
|
||||
|
||||
it('should clear timeout if toast is shown again before it is hidden', done => {
|
||||
fixtureEl.innerHTML = [
|
||||
'<div class="toast">',
|
||||
' <div class="toast-body">',
|
||||
' a simple toast',
|
||||
' </div>',
|
||||
'</div>'
|
||||
].join('')
|
||||
|
||||
const toastEl = fixtureEl.querySelector('.toast')
|
||||
const toast = new Toast(toastEl)
|
||||
|
||||
setTimeout(() => {
|
||||
toast._config.autohide = false
|
||||
toastEl.addEventListener('shown.bs.toast', () => {
|
||||
expect(toast._clearTimeout).toHaveBeenCalled()
|
||||
expect(toast._timeout).toBeNull()
|
||||
done()
|
||||
})
|
||||
toast.show()
|
||||
}, toast._config.delay / 2)
|
||||
|
||||
spyOn(toast, '_clearTimeout').and.callThrough()
|
||||
|
||||
toast.show()
|
||||
})
|
||||
})
|
||||
|
||||
describe('hide', () => {
|
||||
|
Reference in New Issue
Block a user