@@ -300,98 +300,104 @@ describe('Modal', () => {
300300
301301 describe ( 'onOpen' , ( ) => {
302302 it ( 'is called on trigger click' , ( ) => {
303- const spy = sandbox . spy ( )
304- wrapperMount ( < Modal onOpen = { spy } trigger = { < div id = 'trigger' /> } /> )
303+ const onOpen = sandbox . spy ( )
304+ wrapperMount ( < Modal onOpen = { onOpen } trigger = { < div id = 'trigger' /> } /> )
305305
306306 wrapper . find ( '#trigger' ) . simulate ( 'click' )
307- spy . should . have . been . calledOnce ( )
307+ onOpen . should . have . been . calledOnce ( )
308+ onOpen . should . have . been . calledWithMatch ( { } , { open : true } )
308309 } )
309310
310311 it ( 'is not called on body click' , ( ) => {
311- const spy = sandbox . spy ( )
312- wrapperMount ( < Modal onOpen = { spy } /> )
312+ const onOpen = sandbox . spy ( )
313+ wrapperMount ( < Modal onOpen = { onOpen } /> )
313314
314315 domEvent . click ( document . body )
315- spy . should . not . have . been . called ( )
316+ onOpen . should . not . have . been . called ( )
316317 } )
317318 } )
318319
319320 describe ( 'onClose' , ( ) => {
320- let spy
321-
322- beforeEach ( ( ) => {
323- spy = sandbox . spy ( )
324- } )
325-
326321 it ( 'is called on dimmer click' , ( ) => {
327- wrapperMount ( < Modal onClose = { spy } defaultOpen /> )
322+ const onClose = sandbox . spy ( )
323+ wrapperMount ( < Modal onClose = { onClose } defaultOpen /> )
328324
329325 domEvent . click ( '.ui.dimmer' )
330- spy . should . have . been . calledOnce ( )
326+ onClose . should . have . been . calledOnce ( )
327+ onClose . should . have . been . calledWithMatch ( { } , { open : false } )
331328 } )
332329
333330 it ( 'is called on click outside of the modal' , ( ) => {
334- wrapperMount ( < Modal onClose = { spy } defaultOpen /> )
331+ const onClose = sandbox . spy ( )
332+ wrapperMount ( < Modal onClose = { onClose } defaultOpen /> )
335333
336334 domEvent . click ( document . querySelector ( '.ui.modal' ) . parentNode )
337- spy . should . have . been . calledOnce ( )
335+ onClose . should . have . been . calledOnce ( )
338336 } )
339337
340338 it ( 'is not called on mousedown inside and mouseup outside of the modal' , ( ) => {
341- wrapperMount ( < Modal onClose = { spy } defaultOpen /> )
339+ const onClose = sandbox . spy ( )
340+ wrapperMount ( < Modal onClose = { onClose } defaultOpen /> )
342341
343342 domEvent . mouseDown ( document . querySelector ( '.ui.modal' ) )
344343 domEvent . click ( document . querySelector ( '.ui.modal' ) . parentNode )
345- spy . should . not . have . been . called ( )
344+ onClose . should . not . have . been . called ( )
346345 } )
347346
348347 it ( 'is not called on click inside of the modal' , ( ) => {
349- wrapperMount ( < Modal onClose = { spy } defaultOpen /> )
348+ const onClose = sandbox . spy ( )
349+ wrapperMount ( < Modal onClose = { onClose } defaultOpen /> )
350350
351351 domEvent . click ( document . querySelector ( '.ui.modal' ) )
352- spy . should . not . have . been . called ( )
352+ onClose . should . not . have . been . called ( )
353353 } )
354354
355355 it ( 'is not called on body click' , ( ) => {
356- wrapperMount ( < Modal onClose = { spy } defaultOpen /> )
356+ const onClose = sandbox . spy ( )
357+ wrapperMount ( < Modal onClose = { onClose } defaultOpen /> )
357358
358359 domEvent . click ( document . body )
359- spy . should . not . have . been . calledOnce ( )
360+ onClose . should . not . have . been . calledOnce ( )
360361 } )
361362
362363 it ( 'is called when pressing escape' , ( ) => {
363- wrapperMount ( < Modal onClose = { spy } defaultOpen /> )
364+ const onClose = sandbox . spy ( )
365+ wrapperMount ( < Modal onClose = { onClose } defaultOpen /> )
364366
365367 domEvent . keyDown ( document , { key : 'Escape' } )
366- spy . should . have . been . calledOnce ( )
368+ onClose . should . have . been . calledOnce ( )
367369 } )
368370
369371 it ( 'is not called when the open prop changes to false' , ( ) => {
370- wrapperMount ( < Modal onClose = { spy } defaultOpen /> )
372+ const onClose = sandbox . spy ( )
373+ wrapperMount ( < Modal onClose = { onClose } defaultOpen /> )
371374
372375 wrapper . setProps ( { open : false } )
373- spy . should . not . have . been . called ( )
376+ onClose . should . not . have . been . called ( )
374377 } )
375378
376379 it ( 'is not called when open changes to false programmatically' , ( ) => {
377- wrapperMount ( < Modal onClose = { spy } defaultOpen /> )
380+ const onClose = sandbox . spy ( )
381+ wrapperMount ( < Modal onClose = { onClose } defaultOpen /> )
378382
379383 wrapper . setProps ( { open : false } )
380- spy . should . not . have . been . called ( )
384+ onClose . should . not . have . been . called ( )
381385 } )
382386
383387 it ( 'is not called on dimmer click when closeOnDimmerClick is false' , ( ) => {
384- wrapperMount ( < Modal onClose = { spy } defaultOpen closeOnDimmerClick = { false } /> )
388+ const onClose = sandbox . spy ( )
389+ wrapperMount ( < Modal onClose = { onClose } defaultOpen closeOnDimmerClick = { false } /> )
385390
386391 domEvent . click ( '.ui.dimmer' )
387- spy . should . not . have . been . called ( )
392+ onClose . should . not . have . been . called ( )
388393 } )
389394
390395 it ( 'is not called on body click when closeOnDocumentClick is false' , ( ) => {
391- wrapperMount ( < Modal onClose = { spy } defaultOpen closeOnDocumentClick = { false } /> )
396+ const onClose = sandbox . spy ( )
397+ wrapperMount ( < Modal onClose = { onClose } defaultOpen closeOnDocumentClick = { false } /> )
392398
393399 domEvent . click ( document . body )
394- spy . should . not . have . been . called ( )
400+ onClose . should . not . have . been . called ( )
395401 } )
396402 } )
397403
0 commit comments