@@ -21,13 +21,14 @@ 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 , htmlContent ) {
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 ;
31+ $scope . htmlContent = htmlContent ;
3132
3233 $scope . closeData = undefined ;
3334 $scope . closeCallback = function ( data ) {
@@ -91,35 +92,47 @@ describe('Component: pfToastNotification', function () {
9192 title : "Test Notification"
9293 } ;
9394 var htmlTmp = '<pf-toast-notification notification-type="{{type}}" header="{{header}}" message="{{message}}"' +
94- ' show-close="{{showClose}}" close-callback="closeCallback" ' +
95- ' action-title="{{primaryAction}}" action-callback="handleAction "' +
96- ' menu-actions="menuActions" data="data">' +
95+ ' show-close="{{showClose}}" html-content="htmlContent" ' +
96+ ' close-callback="closeCallback" action-title="{{primaryAction}}"' +
97+ ' action-callback="handleAction" menu-actions="menuActions" data="data">' +
9798 ' </pf-toast-notification>' ;
9899
99100 compileHTML ( htmlTmp , $scope ) ;
100101 } ;
101102
102103 it ( 'should have the correct header and message' , function ( ) {
103- setupHTML ( "info" , "Test Header" , false , '' , false ) ;
104+ setupHTML ( "info" , "Test Header" , null , false , '' , false ) ;
104105 header = element . find ( '.toast-pf span strong' ) ;
105106 expect ( header . length ) . toBe ( 1 ) ;
106107 expect ( header . text ( ) ) . toBe ( "Test Header" ) ;
107- message = element . find ( '.toast-pf span' ) ;
108+ message = element . find ( '.toast-pf > span' ) ;
108109 expect ( message . length ) . toBe ( 2 ) ;
109110 expect ( angular . element ( message [ 1 ] ) . text ( ) ) . toContain ( "Test Toast Notification Message" ) ;
110111 } ) ;
111112
112113 it ( 'should have the correct message when no header is given' , function ( ) {
113- setupHTML ( "info" , "" , false , '' , false ) ;
114+ setupHTML ( "info" , "" , null , false , '' , false ) ;
114115 var header = element . find ( '.toast-pf span strong' ) ;
115116 expect ( header . length ) . toBe ( 0 ) ;
116- var message = element . find ( '.toast-pf span' ) ;
117+ var message = element . find ( '.toast-pf > span' ) ;
117118 expect ( message . length ) . toBe ( 2 ) ;
118119 expect ( angular . element ( message [ 1 ] ) . text ( ) ) . toContain ( "Test Toast Notification Message" ) ;
119120 } ) ;
120121
122+ it ( 'should allow HTML content within the header and message' , function ( ) {
123+ setupHTML ( "info" , "<em>Test Header</em>" , null , false , '' , false , null , true ) ;
124+ var header = element . find ( '.toast-pf span strong em' ) ;
125+ expect ( header . length ) . toBe ( 1 ) ;
126+ expect ( header . text ( ) ) . toContain ( "Test Header" ) ;
127+
128+ setupHTML ( "info" , "" , "<em>Test Notification Message</em>" , false , '' , false , null , true ) ;
129+ var message = element . find ( '.toast-pf > span em' ) ;
130+ expect ( message . length ) . toBe ( 1 ) ;
131+ expect ( message . text ( ) ) . toContain ( "Test Notification Message" ) ;
132+ } ) ;
133+
121134 it ( 'should have the correct status icon' , function ( ) {
122- setupHTML ( "success" , "Test Header" , false , '' , false ) ;
135+ setupHTML ( "success" , "Test Header" , null , false , '' , false ) ;
123136 var okIcon = element . find ( '.pficon.pficon-ok' ) ;
124137 var infoIcon = element . find ( '.pficon.pficon-info' ) ;
125138 var errorIcon = element . find ( '.pficon.pficon-error-circle-o' ) ;
@@ -129,7 +142,7 @@ describe('Component: pfToastNotification', function () {
129142 expect ( errorIcon . length ) . toBe ( 0 ) ;
130143 expect ( warnIcon . length ) . toBe ( 0 ) ;
131144
132- setupHTML ( "info" , "Test Header" , false , '' , false ) ;
145+ setupHTML ( "info" , "Test Header" , null , false , '' , false ) ;
133146 okIcon = element . find ( '.pficon.pficon-ok' ) ;
134147 infoIcon = element . find ( '.pficon.pficon-info' ) ;
135148 errorIcon = element . find ( '.pficon.pficon-error-circle-o' ) ;
@@ -139,7 +152,7 @@ describe('Component: pfToastNotification', function () {
139152 expect ( errorIcon . length ) . toBe ( 0 ) ;
140153 expect ( warnIcon . length ) . toBe ( 0 ) ;
141154
142- setupHTML ( "danger" , "Test Header" , false , '' , false ) ;
155+ setupHTML ( "danger" , "Test Header" , null , false , '' , false ) ;
143156 okIcon = element . find ( '.pficon.pficon-ok' ) ;
144157 infoIcon = element . find ( '.pficon.pficon-info' ) ;
145158 errorIcon = element . find ( '.pficon.pficon-error-circle-o' ) ;
@@ -149,7 +162,7 @@ describe('Component: pfToastNotification', function () {
149162 expect ( errorIcon . length ) . toBe ( 1 ) ;
150163 expect ( warnIcon . length ) . toBe ( 0 ) ;
151164
152- setupHTML ( "warning" , "Test Header" , false , '' , false ) ;
165+ setupHTML ( "warning" , "Test Header" , null , false , '' , false ) ;
153166 okIcon = element . find ( '.pficon.pficon-ok' ) ;
154167 infoIcon = element . find ( '.pficon.pficon-info' ) ;
155168 errorIcon = element . find ( '.pficon.pficon-error-circle-o' ) ;
@@ -162,11 +175,11 @@ describe('Component: pfToastNotification', function () {
162175 } ) ;
163176
164177 it ( 'should have the close button when specified' , function ( ) {
165- setupHTML ( "success" , "Test Header" , false , 'Test Action' , true ) ;
178+ setupHTML ( "success" , "Test Header" , null , false , 'Test Action' , true ) ;
166179 var closeButton = element . find ( 'button.close' ) ;
167180 expect ( closeButton . length ) . toBe ( 0 ) ;
168181
169- setupHTML ( "success" , "Test Header" , true , 'Test Action' , false ) ;
182+ setupHTML ( "success" , "Test Header" , null , true , 'Test Action' , false ) ;
170183 closeButton = element . find ( 'button.close' ) ;
171184 expect ( closeButton . length ) . toBe ( 1 ) ;
172185
@@ -179,13 +192,13 @@ describe('Component: pfToastNotification', function () {
179192 expect ( $scope . closeData . title ) . toBe ( "Test Notification" ) ;
180193
181194 // No close button even if specified when menu actions exist
182- setupHTML ( "success" , "Test Header" , true , 'Test Action' , true ) ;
195+ setupHTML ( "success" , "Test Header" , null , true , 'Test Action' , true ) ;
183196 closeButton = element . find ( 'button.close' ) ;
184197 expect ( closeButton . length ) . toBe ( 0 ) ;
185198 } ) ;
186199
187200 it ( 'should have the correct primary action and call the correct callback when clicked' , function ( ) {
188- setupHTML ( "success" , "Test Header" , false , 'Test Action' , false ) ;
201+ setupHTML ( "success" , "Test Header" , null , false , 'Test Action' , false ) ;
189202 var actionButton = element . find ( '.toast-pf-action > a' ) ;
190203 expect ( actionButton . length ) . toBe ( 1 ) ;
191204 expect ( $scope . actionData ) . toBeUndefined ( ) ;
@@ -198,7 +211,7 @@ describe('Component: pfToastNotification', function () {
198211 } ) ;
199212
200213 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 ) ;
214+ setupHTML ( "success" , "Test Header" , null , false , 'Test Action' , true ) ;
202215 var menuIndicator = element . find ( '.dropdown-kebab-pf' ) ;
203216 expect ( menuIndicator . length ) . toBe ( 1 ) ;
204217 var menuItems = element . find ( '.dropdown-kebab-pf .dropdown-menu li' ) ;
@@ -219,13 +232,13 @@ describe('Component: pfToastNotification', function () {
219232 } ) ;
220233
221234 it ( 'should have correct number of separators' , function ( ) {
222- setupHTML ( "success" , "Test Header" , false , 'Test Action' , true ) ;
235+ setupHTML ( "success" , "Test Header" , null , false , 'Test Action' , true ) ;
223236 var fields = element . find ( '.dropdown-kebab-pf .dropdown-menu .divider' ) ;
224237 expect ( fields . length ) . toBe ( 1 ) ;
225238 } ) ;
226239
227240 it ( 'should correctly disable actions and not call the callback if clicked' , function ( ) {
228- setupHTML ( "success" , "Test Header" , false , 'Test Action' , true ) ;
241+ setupHTML ( "success" , "Test Header" , null , false , 'Test Action' , true ) ;
229242 var fields = element . find ( '.dropdown-kebab-pf .dropdown-menu .disabled > a' ) ;
230243 expect ( fields . length ) . toBe ( 1 ) ;
231244
@@ -239,3 +252,4 @@ describe('Component: pfToastNotification', function () {
239252 expect ( $scope . menuData ) . toBeUndefined ( ) ;
240253 } ) ;
241254} ) ;
255+
0 commit comments