@@ -149,7 +149,7 @@ describe('ToastNotification', () => {
149
149
} ) ;
150
150
describe ( 'events and state' , ( ) => {
151
151
it ( 'initial open state set to true' , ( ) => {
152
- const mountedToast = mount (
152
+ const wrapper = mount (
153
153
< ToastNotification
154
154
kind = "error"
155
155
title = "this is a title"
@@ -158,11 +158,11 @@ describe('ToastNotification', () => {
158
158
/>
159
159
) ;
160
160
161
- expect ( mountedToast . state ( ) . open ) . toBe ( true ) ;
161
+ expect ( wrapper . children ( ) . length > 0 ) . toBe ( true ) ;
162
162
} ) ;
163
163
164
164
it ( 'sets open state to false when close button is clicked' , ( ) => {
165
- const mountedToast = mount (
165
+ const wrapper = mount (
166
166
< ToastNotification
167
167
kind = "error"
168
168
title = "this is a title"
@@ -171,12 +171,12 @@ describe('ToastNotification', () => {
171
171
/>
172
172
) ;
173
173
174
- mountedToast . find ( 'button' ) . simulate ( 'click' ) ;
175
- expect ( mountedToast . state ( ) . open ) . toEqual ( false ) ;
174
+ wrapper . find ( 'button' ) . simulate ( 'click' ) ;
175
+ expect ( wrapper . children ( ) . length ) . toBe ( 0 ) ;
176
176
} ) ;
177
177
178
178
it ( 'renders null when open state is false' , ( ) => {
179
- const mountedToast = mount (
179
+ const wrapper = mount (
180
180
< ToastNotification
181
181
kind = "error"
182
182
title = "this is a title"
@@ -185,8 +185,8 @@ describe('ToastNotification', () => {
185
185
/>
186
186
) ;
187
187
188
- mountedToast . setState ( { open : false } ) ;
189
- expect ( mountedToast . html ( ) ) . toBeNull ( ) ;
188
+ wrapper . find ( 'button' ) . simulate ( 'click' ) ;
189
+ expect ( wrapper . html ( ) ) . toBeNull ( ) ;
190
190
} ) ;
191
191
} ) ;
192
192
} ) ;
@@ -261,88 +261,44 @@ describe('InlineNotification', () => {
261
261
262
262
describe ( 'events and state' , ( ) => {
263
263
it ( 'initial open state set to true' , ( ) => {
264
- const mountedInline = mount (
264
+ const wrapper = mount (
265
265
< InlineNotification
266
266
title = "this is a title"
267
267
subtitle = "this is a subtitle"
268
268
kind = "error"
269
269
/>
270
270
) ;
271
271
272
- expect ( mountedInline . state ( ) . open ) . toBe ( true ) ;
272
+ expect ( wrapper . children ( ) . length > 0 ) . toBe ( true ) ;
273
273
} ) ;
274
274
275
275
it ( 'sets open state to false when close button is clicked' , ( ) => {
276
- const mountedInline = mount ( < InlineNotification { ...props } /> ) ;
276
+ const wrapper = mount (
277
+ < InlineNotification
278
+ kind = "success"
279
+ title = "title"
280
+ subtitle = "subtitle"
281
+ iconDescription = "description"
282
+ />
283
+ ) ;
277
284
278
- mountedInline . find ( 'button' ) . simulate ( 'click' ) ;
279
- expect ( mountedInline . state ( ) . open ) . toEqual ( false ) ;
285
+ wrapper . find ( 'button' ) . simulate ( 'click' ) ;
286
+ expect ( wrapper . children ( ) . length ) . toBe ( 0 ) ;
280
287
} ) ;
281
288
282
289
it ( 'renders null when open state is false' , ( ) => {
283
- const mountedInline = mount (
290
+ const wrapper = mount (
284
291
< InlineNotification
285
292
title = "this is a title"
286
293
subtitle = "this is a subtitle"
287
294
kind = "error"
288
295
/>
289
296
) ;
290
297
291
- mountedInline . setState ( { open : false } ) ;
292
- expect ( mountedInline . html ( ) ) . toBeNull ( ) ;
298
+ wrapper . find ( 'button' ) . simulate ( 'click' ) ;
299
+ expect ( wrapper . html ( ) ) . toBeNull ( ) ;
293
300
} ) ;
294
301
} ) ;
295
302
} ) ;
296
303
297
304
// Deprecated
298
-
299
- const props = {
300
- kind : 'success' ,
301
- title : 'title' ,
302
- subtitle : 'subtitle' ,
303
- iconDescription : 'description' ,
304
- } ;
305
-
306
- describe ( 'events and state' , ( ) => {
307
- it ( 'initial open state set to true' , ( ) => {
308
- const mountedToast = mount (
309
- < ToastNotification { ...props } caption = "caption" />
310
- ) ;
311
- const mountedInline = mount ( < InlineNotification { ...props } /> ) ;
312
-
313
- expect ( mountedToast . state ( ) . open ) . toBe ( true ) ;
314
- expect ( mountedInline . state ( ) . open ) . toBe ( true ) ;
315
- } ) ;
316
-
317
- it ( 'sets open state to false when close button is clicked' , ( ) => {
318
- const mountedToast = mount (
319
- < ToastNotification { ...props } caption = "caption" />
320
- ) ;
321
- const mountedInline = mount ( < InlineNotification { ...props } /> ) ;
322
-
323
- mountedToast . find ( 'button' ) . simulate ( 'click' ) ;
324
- mountedInline . find ( 'button' ) . simulate ( 'click' ) ;
325
- expect ( mountedToast . state ( ) . open ) . toEqual ( false ) ;
326
- expect ( mountedInline . state ( ) . open ) . toEqual ( false ) ;
327
- } ) ;
328
-
329
- it ( 'close button is not shown if hideCloseButton prop set' , ( ) => {
330
- const mountedToast = mount (
331
- < ToastNotification { ...props } hideCloseButton = { true } />
332
- ) ;
333
-
334
- expect ( mountedToast . find ( 'button' ) ) . toHaveLength ( 0 ) ;
335
- } ) ;
336
-
337
- it ( 'renders null when open state is false' , ( ) => {
338
- const mountedToast = mount (
339
- < ToastNotification { ...props } caption = "caption" />
340
- ) ;
341
- const mountedInline = mount ( < InlineNotification { ...props } /> ) ;
342
-
343
- mountedToast . setState ( { open : false } ) ;
344
- mountedInline . setState ( { open : false } ) ;
345
- expect ( mountedToast . html ( ) ) . toBeNull ( ) ;
346
- expect ( mountedInline . html ( ) ) . toBeNull ( ) ;
347
- } ) ;
348
- } ) ;
0 commit comments