File tree Expand file tree Collapse file tree 2 files changed +16
-0
lines changed Expand file tree Collapse file tree 2 files changed +16
-0
lines changed Original file line number Diff line number Diff line change 17
17
var containerDefer = $q . defer ( ) ;
18
18
19
19
var toast = {
20
+ active : active ,
20
21
clear : clear ,
21
22
error : error ,
22
23
info : info ,
28
29
return toast ;
29
30
30
31
/* Public API */
32
+ function active ( ) {
33
+ return toasts . length ;
34
+ }
35
+
31
36
function clear ( toast ) {
32
37
// Bit of a hack, I will remove this soon with a BC
33
38
if ( arguments . length === 1 && ! toast ) { return ; }
Original file line number Diff line number Diff line change @@ -372,6 +372,17 @@ describe('toastr', function() {
372
372
animationFlush ( ) ;
373
373
expect ( $document ) . not . toHaveToastContainer ( ) ;
374
374
} ) ;
375
+
376
+ it ( 'has a list of active toasts' , function ( ) {
377
+ openToasts ( 5 ) ;
378
+ expect ( toastr . active ( ) ) . toBe ( 5 ) ;
379
+ clickToast ( ) ;
380
+ clickToast ( ) ;
381
+ expect ( toastr . active ( ) ) . toBe ( 3 ) ;
382
+ intervalFlush ( ) ;
383
+ animationFlush ( ) ;
384
+ expect ( toastr . active ( ) ) . toBe ( 0 ) ;
385
+ } ) ;
375
386
} ) ;
376
387
377
388
describe ( 'container' , function ( ) {
You can’t perform that action at this time.
0 commit comments