@@ -21,13 +21,13 @@ describe('Component: pfToastNotification', function () {
2121 scope . $digest ( ) ;
2222 } ;
2323
24- var setupHTML = function ( notificationType , header , showClose , primaryAction , showMenu , data ) {
24+ var setupHTML = function ( notificationType , header , message , showClose , primaryAction , showMenu , data ) {
2525 $scope . type = notificationType ;
2626 $scope . header = header ;
27- $scope . message = "Test Toast Notification Message" ;
27+ $scope . message = message || "Test Toast Notification Message" ;
2828 $scope . showClose = showClose ;
2929 $scope . primaryAction = primaryAction ;
30- $scope . data = data
30+ $scope . data = data ;
3131
3232 $scope . closeData = undefined ;
3333 $scope . closeCallback = function ( data ) {
@@ -100,26 +100,38 @@ describe('Component: pfToastNotification', function () {
100100 } ;
101101
102102 it ( 'should have the correct header and message' , function ( ) {
103- setupHTML ( "info" , "Test Header" , false , '' , false ) ;
103+ setupHTML ( "info" , "Test Header" , null , false , '' , false ) ;
104104 header = element . find ( '.toast-pf span strong' ) ;
105105 expect ( header . length ) . toBe ( 1 ) ;
106106 expect ( header . text ( ) ) . toBe ( "Test Header" ) ;
107- message = element . find ( '.toast-pf span' ) ;
107+ message = element . find ( '.toast-pf > span' ) ;
108108 expect ( message . length ) . toBe ( 2 ) ;
109109 expect ( angular . element ( message [ 1 ] ) . text ( ) ) . toContain ( "Test Toast Notification Message" ) ;
110110 } ) ;
111111
112112 it ( 'should have the correct message when no header is given' , function ( ) {
113- setupHTML ( "info" , "" , false , '' , false ) ;
113+ setupHTML ( "info" , "" , null , false , '' , false ) ;
114114 var header = element . find ( '.toast-pf span strong' ) ;
115115 expect ( header . length ) . toBe ( 0 ) ;
116- var message = element . find ( '.toast-pf span' ) ;
116+ var message = element . find ( '.toast-pf > span' ) ;
117117 expect ( message . length ) . toBe ( 2 ) ;
118118 expect ( angular . element ( message [ 1 ] ) . text ( ) ) . toContain ( "Test Toast Notification Message" ) ;
119119 } ) ;
120120
121+ it ( 'should allow HTML content within the header and message' , function ( ) {
122+ setupHTML ( "info" , "<em>Test Header</em>" , null , false , '' , false ) ;
123+ var header = element . find ( '.toast-pf span strong em' ) ;
124+ expect ( header . length ) . toBe ( 1 ) ;
125+ expect ( header . text ( ) ) . toContain ( "Test Header" ) ;
126+
127+ setupHTML ( "info" , "" , "<em>Test Notification Message</em>" , false , '' , false ) ;
128+ var message = element . find ( '.toast-pf > span em' ) ;
129+ expect ( message . length ) . toBe ( 1 ) ;
130+ expect ( message . text ( ) ) . toContain ( "Test Notification Message" ) ;
131+ } ) ;
132+
121133 it ( 'should have the correct status icon' , function ( ) {
122- setupHTML ( "success" , "Test Header" , false , '' , false ) ;
134+ setupHTML ( "success" , "Test Header" , null , false , '' , false ) ;
123135 var okIcon = element . find ( '.pficon.pficon-ok' ) ;
124136 var infoIcon = element . find ( '.pficon.pficon-info' ) ;
125137 var errorIcon = element . find ( '.pficon.pficon-error-circle-o' ) ;
@@ -129,7 +141,7 @@ describe('Component: pfToastNotification', function () {
129141 expect ( errorIcon . length ) . toBe ( 0 ) ;
130142 expect ( warnIcon . length ) . toBe ( 0 ) ;
131143
132- setupHTML ( "info" , "Test Header" , false , '' , false ) ;
144+ setupHTML ( "info" , "Test Header" , null , false , '' , false ) ;
133145 okIcon = element . find ( '.pficon.pficon-ok' ) ;
134146 infoIcon = element . find ( '.pficon.pficon-info' ) ;
135147 errorIcon = element . find ( '.pficon.pficon-error-circle-o' ) ;
@@ -139,7 +151,7 @@ describe('Component: pfToastNotification', function () {
139151 expect ( errorIcon . length ) . toBe ( 0 ) ;
140152 expect ( warnIcon . length ) . toBe ( 0 ) ;
141153
142- setupHTML ( "danger" , "Test Header" , false , '' , false ) ;
154+ setupHTML ( "danger" , "Test Header" , null , false , '' , false ) ;
143155 okIcon = element . find ( '.pficon.pficon-ok' ) ;
144156 infoIcon = element . find ( '.pficon.pficon-info' ) ;
145157 errorIcon = element . find ( '.pficon.pficon-error-circle-o' ) ;
@@ -149,7 +161,7 @@ describe('Component: pfToastNotification', function () {
149161 expect ( errorIcon . length ) . toBe ( 1 ) ;
150162 expect ( warnIcon . length ) . toBe ( 0 ) ;
151163
152- setupHTML ( "warning" , "Test Header" , false , '' , false ) ;
164+ setupHTML ( "warning" , "Test Header" , null , false , '' , false ) ;
153165 okIcon = element . find ( '.pficon.pficon-ok' ) ;
154166 infoIcon = element . find ( '.pficon.pficon-info' ) ;
155167 errorIcon = element . find ( '.pficon.pficon-error-circle-o' ) ;
@@ -162,11 +174,11 @@ describe('Component: pfToastNotification', function () {
162174 } ) ;
163175
164176 it ( 'should have the close button when specified' , function ( ) {
165- setupHTML ( "success" , "Test Header" , false , 'Test Action' , true ) ;
177+ setupHTML ( "success" , "Test Header" , null , false , 'Test Action' , true ) ;
166178 var closeButton = element . find ( 'button.close' ) ;
167179 expect ( closeButton . length ) . toBe ( 0 ) ;
168180
169- setupHTML ( "success" , "Test Header" , true , 'Test Action' , false ) ;
181+ setupHTML ( "success" , "Test Header" , null , true , 'Test Action' , false ) ;
170182 closeButton = element . find ( 'button.close' ) ;
171183 expect ( closeButton . length ) . toBe ( 1 ) ;
172184
@@ -179,13 +191,13 @@ describe('Component: pfToastNotification', function () {
179191 expect ( $scope . closeData . title ) . toBe ( "Test Notification" ) ;
180192
181193 // No close button even if specified when menu actions exist
182- setupHTML ( "success" , "Test Header" , true , 'Test Action' , true ) ;
194+ setupHTML ( "success" , "Test Header" , null , true , 'Test Action' , true ) ;
183195 closeButton = element . find ( 'button.close' ) ;
184196 expect ( closeButton . length ) . toBe ( 0 ) ;
185197 } ) ;
186198
187199 it ( 'should have the correct primary action and call the correct callback when clicked' , function ( ) {
188- setupHTML ( "success" , "Test Header" , false , 'Test Action' , false ) ;
200+ setupHTML ( "success" , "Test Header" , null , false , 'Test Action' , false ) ;
189201 var actionButton = element . find ( '.toast-pf-action > a' ) ;
190202 expect ( actionButton . length ) . toBe ( 1 ) ;
191203 expect ( $scope . actionData ) . toBeUndefined ( ) ;
@@ -198,7 +210,7 @@ describe('Component: pfToastNotification', function () {
198210 } ) ;
199211
200212 it ( 'should have the correct kebab menu and call the correct callback when items are clicked' , function ( ) {
201- setupHTML ( "success" , "Test Header" , false , 'Test Action' , true ) ;
213+ setupHTML ( "success" , "Test Header" , null , false , 'Test Action' , true ) ;
202214 var menuIndicator = element . find ( '.dropdown-kebab-pf' ) ;
203215 expect ( menuIndicator . length ) . toBe ( 1 ) ;
204216 var menuItems = element . find ( '.dropdown-kebab-pf .dropdown-menu li' ) ;
@@ -219,13 +231,13 @@ describe('Component: pfToastNotification', function () {
219231 } ) ;
220232
221233 it ( 'should have correct number of separators' , function ( ) {
222- setupHTML ( "success" , "Test Header" , false , 'Test Action' , true ) ;
234+ setupHTML ( "success" , "Test Header" , null , false , 'Test Action' , true ) ;
223235 var fields = element . find ( '.dropdown-kebab-pf .dropdown-menu .divider' ) ;
224236 expect ( fields . length ) . toBe ( 1 ) ;
225237 } ) ;
226238
227239 it ( 'should correctly disable actions and not call the callback if clicked' , function ( ) {
228- setupHTML ( "success" , "Test Header" , false , 'Test Action' , true ) ;
240+ setupHTML ( "success" , "Test Header" , null , false , 'Test Action' , true ) ;
229241 var fields = element . find ( '.dropdown-kebab-pf .dropdown-menu .disabled > a' ) ;
230242 expect ( fields . length ) . toBe ( 1 ) ;
231243
@@ -239,3 +251,4 @@ describe('Component: pfToastNotification', function () {
239251 expect ( $scope . menuData ) . toBeUndefined ( ) ;
240252 } ) ;
241253} ) ;
254+
0 commit comments