File tree 1 file changed +31
-0
lines changed
1 file changed +31
-0
lines changed Original file line number Diff line number Diff line change @@ -290,6 +290,37 @@ $(function () {
290
290
. bootstrapToast ( 'show' )
291
291
} )
292
292
293
+ QUnit . test ( 'should clear timeout if toast is shown again before it is hidden' , function ( assert ) {
294
+ assert . expect ( 2 )
295
+ var done = assert . async ( )
296
+
297
+ var toastHtml =
298
+ '<div class="toast">' +
299
+ '<div class="toast-body">' +
300
+ 'a simple toast' +
301
+ '</div>' +
302
+ '</div>'
303
+
304
+ var $toast = $ ( toastHtml )
305
+ . bootstrapToast ( )
306
+ . appendTo ( $ ( '#qunit-fixture' ) )
307
+
308
+ var toast = $toast . data ( 'bs.toast' )
309
+ var spyClearTimeout = sinon . spy ( toast , '_clearTimeout' )
310
+
311
+ setTimeout ( function ( ) {
312
+ toast . _config . autohide = false
313
+ $toast . on ( 'shown.bs.toast' , function ( ) {
314
+ assert . ok ( spyClearTimeout . called )
315
+ assert . ok ( toast . _timeout === null )
316
+ done ( )
317
+ } )
318
+ $toast . bootstrapToast ( 'show' )
319
+ } , toast . _config . delay / 2 )
320
+
321
+ $toast . bootstrapToast ( 'show' )
322
+ } )
323
+
293
324
QUnit . test ( 'should not trigger hidden if hide is prevented' , function ( assert ) {
294
325
assert . expect ( 1 )
295
326
var done = assert . async ( )
You can’t perform that action at this time.
0 commit comments