diff options
Diffstat (limited to 'js/tests')
| -rw-r--r-- | js/tests/unit/toast.spec.js | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/js/tests/unit/toast.spec.js b/js/tests/unit/toast.spec.js index ee623c8cc..031c841af 100644 --- a/js/tests/unit/toast.spec.js +++ b/js/tests/unit/toast.spec.js @@ -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', () => { |
