@@ -14,6 +14,7 @@ var transitions = require('../assets/transitions');
1414var assertClip = customAssertions . assertClip ;
1515var assertNodeDisplay = customAssertions . assertNodeDisplay ;
1616var assertMultiNodeOrder = customAssertions . assertMultiNodeOrder ;
17+ var hover = require ( '../assets/hover' ) ;
1718
1819var getOpacity = function ( node ) { return Number ( node . style . opacity ) ; } ;
1920var getFillOpacity = function ( node ) { return Number ( node . style [ 'fill-opacity' ] ) ; } ;
@@ -1808,3 +1809,42 @@ describe('Test scatter *clipnaxis*:', function() {
18081809 . then ( done ) ;
18091810 } ) ;
18101811} ) ;
1812+
1813+ describe ( 'event data' , function ( ) {
1814+ var mock = require ( '@mocks/12' ) ;
1815+ var mockCopy = Lib . extendDeep ( { } , mock ) ,
1816+ gd ;
1817+
1818+ beforeEach ( function ( done ) {
1819+ gd = createGraphDiv ( ) ;
1820+
1821+ Plotly . plot ( gd , mockCopy . data , mockCopy . layout )
1822+ . then ( done ) ;
1823+ } ) ;
1824+
1825+ afterEach ( destroyGraphDiv ) ;
1826+
1827+ it ( 'should contain the correct fields' , function ( ) {
1828+
1829+ var hoverData ;
1830+
1831+ gd . on ( 'plotly_hover' , function ( data ) {
1832+ hoverData = data ;
1833+ } ) ;
1834+
1835+ hover ( 130 , 350 ) ;
1836+
1837+ expect ( hoverData . points . length ) . toEqual ( 1 ) ;
1838+
1839+ var fields = [
1840+ 'curveNumber' , 'pointNumber' ,
1841+ 'data' , 'fullData' ,
1842+ 'xaxis' , 'yaxis' , 'x' , 'y' ,
1843+ 'marker.size'
1844+ ] ;
1845+
1846+ fields . forEach ( function ( field ) {
1847+ expect ( Object . keys ( hoverData . points [ 0 ] ) ) . toContain ( field ) ;
1848+ } ) ;
1849+ } ) ;
1850+ } ) ;
0 commit comments