@@ -815,7 +815,7 @@ describe("LEGEND", () => {
815815 } ) ;
816816
817817 it ( "set options: legend.item.onclick" , ( ) => {
818- args . legend . item . onclick = ( ) => { } ;
818+ args . legend . item . onclick = sinon . spy ( ( ) => { } ) ;
819819 } ) ;
820820
821821 it ( "should only 'click' event lister bound" , ( ) => {
@@ -826,14 +826,24 @@ describe("LEGEND", () => {
826826
827827 expect ( item . on ( "mouseover mouseout" ) ) . to . be . undefined ;
828828 expect ( item . on ( "click" ) ) . to . not . be . undefined ;
829-
830829 expect ( item . style ( "cursor" ) ) . to . be . equal ( "pointer" ) ;
830+
831+ id === "data1" && chart . hide ( id ) ;
832+
833+ fireEvent ( item . node ( ) , "click" , {
834+ clientX : 2 ,
835+ clientY : 2
836+ } , chart ) ;
831837 } ) ;
838+
839+ // given visible state argguments?
840+ expect ( args . legend . item . onclick . args )
841+ . to . be . deep . equal ( chart . data ( ) . map ( ( { id} ) => [ id , id === "data1" ? false : true ] ) ) ;
832842 } ) ;
833843
834844 it ( "set options: legend.item.onover" , ( ) => {
835845 delete args . legend . item . onclick ;
836- args . legend . item . onover = ( ) => { } ;
846+ args . legend . item . onover = sinon . spy ( ( ) => { } ) ;
837847 } ) ;
838848
839849 it ( "should only 'mouseover' event lister bound" , ( ) => {
@@ -844,14 +854,24 @@ describe("LEGEND", () => {
844854
845855 expect ( item . on ( "click mouseout" ) ) . to . be . undefined ;
846856 expect ( item . on ( "mouseover" ) ) . to . not . be . undefined ;
847-
848857 expect ( item . style ( "cursor" ) ) . to . be . equal ( "pointer" ) ;
858+
859+ id === "data2" && chart . hide ( id ) ;
860+
861+ fireEvent ( item . node ( ) , "mouseover" , {
862+ clientX : 2 ,
863+ clientY : 2
864+ } , chart ) ;
849865 } ) ;
866+
867+ // given visible state argguments?
868+ expect ( args . legend . item . onover . args )
869+ . to . be . deep . equal ( chart . data ( ) . map ( ( { id} ) => [ id , id === "data2" ? false : true ] ) ) ;
850870 } ) ;
851871
852872 it ( "set options: legend.item.onout" , ( ) => {
853873 delete args . legend . item . onover ;
854- args . legend . item . onout = ( ) => { } ;
874+ args . legend . item . onout = sinon . spy ( ( ) => { } ) ;
855875 } ) ;
856876
857877 it ( "should only 'mouseout' event lister bound" , ( ) => {
@@ -862,9 +882,19 @@ describe("LEGEND", () => {
862882
863883 expect ( item . on ( "click mouseover" ) ) . to . be . undefined ;
864884 expect ( item . on ( "mouseout" ) ) . to . not . be . undefined ;
865-
866885 expect ( item . style ( "cursor" ) ) . to . be . equal ( "pointer" ) ;
886+
887+ id === "data1" && chart . hide ( id ) ;
888+
889+ fireEvent ( item . node ( ) , "mouseout" , {
890+ clientX : 2 ,
891+ clientY : 2
892+ } , chart ) ;
867893 } ) ;
894+
895+ // given visible state argguments?
896+ expect ( args . legend . item . onout . args )
897+ . to . be . deep . equal ( chart . data ( ) . map ( ( { id} ) => [ id , id === "data1" ? false : true ] ) ) ;
868898 } ) ;
869899
870900 it ( "set options: legend.item.interaction.dblclik=true" , ( ) => {
0 commit comments