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 1717 var containerDefer = $q . defer ( ) ;
1818
1919 var toast = {
20+ active : active ,
2021 clear : clear ,
2122 error : error ,
2223 info : info ,
2829 return toast ;
2930
3031 /* Public API */
32+ function active ( ) {
33+ return toasts . length ;
34+ }
35+
3136 function clear ( toast ) {
3237 // Bit of a hack, I will remove this soon with a BC
3338 if ( arguments . length === 1 && ! toast ) { return ; }
Original file line number Diff line number Diff line change @@ -372,6 +372,17 @@ describe('toastr', function() {
372372 animationFlush ( ) ;
373373 expect ( $document ) . not . toHaveToastContainer ( ) ;
374374 } ) ;
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+ } ) ;
375386 } ) ;
376387
377388 describe ( 'container' , function ( ) {
You can’t perform that action at this time.
0 commit comments