@@ -76,6 +76,42 @@ describe('Unit testing Angular Flash', function() {
76
76
expect ( contents . querySelectorAll ( '.alert' ) . length ) . toEqual ( 0 ) ;
77
77
} ) ;
78
78
79
+ describe ( 'show flashes in designated containers' , function ( ) {
80
+ var containers ;
81
+
82
+ beforeEach ( function ( ) {
83
+ containers = $compile (
84
+ '<flash-message duration=1000></flash-message>' +
85
+ '<flash-message duration=1000 name="flash-container-a"></flash-message>' +
86
+ '<flash-message duration=1000 name="flash-container-b"></flash-message>' ) ( $rootScope ) ;
87
+
88
+ Flash . create ( 'success' , 'All good' ) ;
89
+ Flash . create ( 'success' , 'All good - A' , 0 , { container : 'flash-container-a' } ) ;
90
+ Flash . create ( 'success' , 'All good - B' , 0 , { container : 'flash-container-b' } ) ;
91
+
92
+ $rootScope . $digest ( ) ;
93
+ } ) ;
94
+
95
+ it ( 'only shows default alert in default container' , function ( ) {
96
+ expect ( containers [ 0 ] . querySelectorAll ( '.alert' ) . length ) . toEqual ( 1 ) ;
97
+ expect ( containers [ 0 ] . outerHTML ) . toContain ( 'All good' ) ;
98
+ expect ( containers [ 0 ] . outerHTML ) . not . toContain ( 'All good - A' ) ;
99
+ expect ( containers [ 0 ] . outerHTML ) . not . toContain ( 'All good - B' ) ;
100
+ } ) ;
101
+
102
+ it ( 'only shows alert A in container A' , function ( ) {
103
+ expect ( containers [ 1 ] . querySelectorAll ( '.alert' ) . length ) . toEqual ( 1 ) ;
104
+ expect ( containers [ 1 ] . outerHTML ) . toContain ( 'All good - A' ) ;
105
+ expect ( containers [ 1 ] . outerHTML ) . not . toContain ( 'All good - B' ) ;
106
+ } ) ;
107
+
108
+ it ( 'only shows alert B in container B' , function ( ) {
109
+ expect ( containers [ 2 ] . querySelectorAll ( '.alert' ) . length ) . toEqual ( 1 ) ;
110
+ expect ( containers [ 2 ] . outerHTML ) . toContain ( 'All good - B' ) ;
111
+ expect ( containers [ 2 ] . outerHTML ) . not . toContain ( 'All good - A' ) ;
112
+ } ) ;
113
+ } ) ;
114
+
79
115
describe ( 'close button' , function ( ) {
80
116
it ( 'is shown by default' , function ( ) {
81
117
Flash . create ( 'success' , 'All good' ) ;
0 commit comments