@@ -485,7 +485,7 @@ describe('Search', () => {
485485 } )
486486
487487 describe ( 'onBlur' , ( ) => {
488- it ( 'is called with (event, data) on search input blur' , ( ) => {
488+ it ( 'is called on search input blur' , ( ) => {
489489 const onBlur = sandbox . spy ( )
490490 wrapperMount ( < Search results = { options } onBlur = { onBlur } /> ) . simulate ( 'blur' , nativeEvent )
491491
@@ -504,7 +504,7 @@ describe('Search', () => {
504504 } )
505505
506506 describe ( 'onFocus' , ( ) => {
507- it ( 'is called with (event, data) on search input focus' , ( ) => {
507+ it ( 'is called on search input focus' , ( ) => {
508508 const onFocus = sandbox . spy ( )
509509 wrapperMount ( < Search results = { options } onFocus = { onFocus } /> ) . simulate ( 'focus' , nativeEvent )
510510
@@ -514,36 +514,41 @@ describe('Search', () => {
514514 } )
515515
516516 describe ( 'onResultSelect' , ( ) => {
517- let spy
517+ let onResultSelect
518518 beforeEach ( ( ) => {
519- spy = sandbox . spy ( )
519+ onResultSelect = sandbox . spy ( )
520520 } )
521521
522- it ( 'is called with event and value on item click' , ( ) => {
522+ it ( 'is called on item click' , ( ) => {
523523 const randomIndex = _ . random ( options . length - 1 )
524524 const randomResult = options [ randomIndex ]
525- wrapperMount ( < Search results = { options } minCharacters = { 0 } onResultSelect = { spy } /> )
525+ wrapperMount ( < Search results = { options } minCharacters = { 0 } onResultSelect = { onResultSelect } /> )
526526
527527 // open
528528 openSearchResults ( )
529529 searchResultsIsOpen ( )
530530
531531 wrapper . find ( 'SearchResult' ) . at ( randomIndex ) . simulate ( 'click' , nativeEvent )
532532
533- spy . should . have . been . calledOnce ( )
534- spy . should . have . been . calledWithMatch (
533+ onResultSelect . should . have . been . calledOnce ( )
534+ onResultSelect . should . have . been . calledWithMatch (
535535 { } ,
536536 {
537537 minCharacters : 0 ,
538- result : randomResult ,
539538 results : options ,
540539 } ,
540+ randomResult ,
541541 )
542542 } )
543- it ( 'is called with event and value when pressing enter on a selected item' , ( ) => {
543+ it ( 'is called when pressing enter on a selected item' , ( ) => {
544544 const firstResult = options [ 0 ]
545545 wrapperMount (
546- < Search results = { options } minCharacters = { 0 } onResultSelect = { spy } selectFirstResult /> ,
546+ < Search
547+ results = { options }
548+ minCharacters = { 0 }
549+ onResultSelect = { onResultSelect }
550+ selectFirstResult
551+ /> ,
547552 )
548553
549554 // open
@@ -552,18 +557,23 @@ describe('Search', () => {
552557
553558 domEvent . keyDown ( document , { key : 'Enter' } )
554559
555- spy . should . have . been . calledOnce ( )
556- spy . should . have . been . calledWithMatch ( { } , { result : firstResult } )
560+ onResultSelect . should . have . been . calledOnce ( )
561+ onResultSelect . should . have . been . calledWithMatch ( { } , { } , firstResult )
557562 } )
558563 it ( 'is not called when updating the value prop' , ( ) => {
559564 const value = _ . sample ( options ) . title
560565 const next = _ . sample ( _ . without ( options , value ) ) . title
561566
562567 wrapperMount (
563- < Search results = { options } minCharacters = { 0 } value = { value } onResultSelect = { spy } /> ,
568+ < Search
569+ results = { options }
570+ minCharacters = { 0 }
571+ value = { value }
572+ onResultSelect = { onResultSelect }
573+ /> ,
564574 ) . setProps ( { value : next } )
565575
566- spy . should . not . have . been . called ( )
576+ onResultSelect . should . not . have . been . called ( )
567577 } )
568578 it ( 'does not call onResultSelect on query change' , ( ) => {
569579 const onResultSelectSpy = sandbox . spy ( )
@@ -579,26 +589,26 @@ describe('Search', () => {
579589 } )
580590
581591 describe ( 'onSearchChange' , ( ) => {
582- it ( 'is called with (event, value) on search input change' , ( ) => {
583- const spy = sandbox . spy ( )
584- wrapperMount ( < Search results = { options } minCharacters = { 0 } onSearchChange = { spy } /> )
592+ it ( 'is called on search input change' , ( ) => {
593+ const onSearchChange = sandbox . spy ( )
594+ wrapperMount ( < Search results = { options } minCharacters = { 0 } onSearchChange = { onSearchChange } /> )
585595 . find ( 'input.prompt' )
586596 . simulate ( 'change' , { target : { value : 'a' } , stopPropagation : _ . noop } )
587597
588- spy . should . have . been . calledOnce ( )
589- spy . should . have . been . calledWithMatch (
598+ onSearchChange . should . have . been . calledOnce ( )
599+ onSearchChange . should . have . been . calledWithMatch (
590600 { target : { value : 'a' } } ,
591601 {
592602 minCharacters : 0 ,
593603 results : options ,
594- value : 'a' ,
595604 } ,
605+ 'a' ,
596606 )
597607 } )
598608 } )
599609
600- describe ( 'onSearchChange ' , ( ) => {
601- it ( 'is called with (event, data) when the active selection index is changed' , ( ) => {
610+ describe ( 'onSelectionChange ' , ( ) => {
611+ it ( 'is called when the active selection index is changed' , ( ) => {
602612 const onSelectionChange = sandbox . spy ( )
603613
604614 wrapperMount (
@@ -617,9 +627,9 @@ describe('Search', () => {
617627 { } ,
618628 {
619629 minCharacters : 0 ,
620- result : options [ 1 ] ,
621630 results : options ,
622631 } ,
632+ options [ 1 ] ,
623633 )
624634 } )
625635 } )
0 commit comments