@@ -1070,3 +1070,126 @@ describe('@noCI Test plotly events on a scattermapbox plot:', function() {
1070
1070
} ) ;
1071
1071
} ) ;
1072
1072
} ) ;
1073
+
1074
+ describe ( '@noCI Test plotly events on a scattermapbox plot when css transform is present:' , function ( ) {
1075
+ var mock = require ( '@mocks/mapbox_0.json' ) ;
1076
+ var pointPos = [ 440 / 2 , 290 / 2 ] ;
1077
+ var nearPos = [ 460 / 2 , 290 / 2 ] ;
1078
+ var blankPos = [ 10 / 2 , 10 / 2 ] ;
1079
+ var mockCopy ;
1080
+ var gd ;
1081
+
1082
+ function transformPlot ( gd , transformString ) {
1083
+ gd . style . webkitTransform = transformString ;
1084
+ gd . style . MozTransform = transformString ;
1085
+ gd . style . msTransform = transformString ;
1086
+ gd . style . OTransform = transformString ;
1087
+ gd . style . transform = transformString ;
1088
+ }
1089
+
1090
+ beforeAll ( function ( ) {
1091
+ Plotly . setPlotConfig ( {
1092
+ mapboxAccessToken : require ( '@build/credentials.json' ) . MAPBOX_ACCESS_TOKEN
1093
+ } ) ;
1094
+ } ) ;
1095
+
1096
+ beforeEach ( function ( done ) {
1097
+ gd = createGraphDiv ( ) ;
1098
+ mockCopy = Lib . extendDeep ( { } , mock ) ;
1099
+ mockCopy . layout . width = 800 ;
1100
+ mockCopy . layout . height = 500 ;
1101
+
1102
+ transformPlot ( gd , 'translate(-25%, -25%) scale(0.5)' ) ;
1103
+ Plotly . plot ( gd , mockCopy ) . then ( done ) ;
1104
+ } ) ;
1105
+
1106
+ afterEach ( destroyGraphDiv ) ;
1107
+
1108
+ describe ( 'click events' , function ( ) {
1109
+ var futureData ;
1110
+
1111
+ beforeEach ( function ( ) {
1112
+ futureData = undefined ;
1113
+ gd . on ( 'plotly_click' , function ( data ) {
1114
+ futureData = data ;
1115
+ } ) ;
1116
+ } ) ;
1117
+
1118
+ it ( '@gl should not be trigged when not on data points' , function ( ) {
1119
+ click ( blankPos [ 0 ] , blankPos [ 1 ] ) ;
1120
+ expect ( futureData ) . toBe ( undefined ) ;
1121
+ } ) ;
1122
+
1123
+ it ( '@gl should contain the correct fields' , function ( ) {
1124
+ click ( pointPos [ 0 ] , pointPos [ 1 ] ) ;
1125
+
1126
+ var pt = futureData . points [ 0 ] ;
1127
+
1128
+ expect ( Object . keys ( pt ) ) . toEqual ( [
1129
+ 'data' , 'fullData' , 'curveNumber' , 'pointNumber' , 'pointIndex' , 'lon' , 'lat'
1130
+ ] ) ;
1131
+
1132
+ expect ( pt . curveNumber ) . toEqual ( 0 , 'points[0].curveNumber' ) ;
1133
+ expect ( typeof pt . data ) . toEqual ( typeof { } , 'points[0].data' ) ;
1134
+ expect ( typeof pt . fullData ) . toEqual ( typeof { } , 'points[0].fullData' ) ;
1135
+ expect ( pt . lat ) . toEqual ( 10 , 'points[0].lat' ) ;
1136
+ expect ( pt . lon ) . toEqual ( 10 , 'points[0].lon' ) ;
1137
+ expect ( pt . pointNumber ) . toEqual ( 0 , 'points[0].pointNumber' ) ;
1138
+ } ) ;
1139
+ } ) ;
1140
+
1141
+ describe ( 'hover events' , function ( ) {
1142
+ var futureData ;
1143
+
1144
+ beforeEach ( function ( ) {
1145
+ gd . on ( 'plotly_hover' , function ( data ) {
1146
+ futureData = data ;
1147
+ } ) ;
1148
+ } ) ;
1149
+
1150
+ it ( '@gl should contain the correct fields' , function ( ) {
1151
+ mouseEvent ( 'mousemove' , blankPos [ 0 ] , blankPos [ 1 ] ) ;
1152
+ mouseEvent ( 'mousemove' , pointPos [ 0 ] , pointPos [ 1 ] ) ;
1153
+
1154
+ var pt = futureData . points [ 0 ] ;
1155
+
1156
+ expect ( Object . keys ( pt ) ) . toEqual ( [
1157
+ 'data' , 'fullData' , 'curveNumber' , 'pointNumber' , 'pointIndex' , 'lon' , 'lat'
1158
+ ] ) ;
1159
+
1160
+ expect ( pt . curveNumber ) . toEqual ( 0 , 'points[0].curveNumber' ) ;
1161
+ expect ( typeof pt . data ) . toEqual ( typeof { } , 'points[0].data' ) ;
1162
+ expect ( typeof pt . fullData ) . toEqual ( typeof { } , 'points[0].fullData' ) ;
1163
+ expect ( pt . lat ) . toEqual ( 10 , 'points[0].lat' ) ;
1164
+ expect ( pt . lon ) . toEqual ( 10 , 'points[0].lon' ) ;
1165
+ expect ( pt . pointNumber ) . toEqual ( 0 , 'points[0].pointNumber' ) ;
1166
+ } ) ;
1167
+ } ) ;
1168
+
1169
+ describe ( 'unhover events' , function ( ) {
1170
+ var futureData ;
1171
+
1172
+ beforeEach ( function ( ) {
1173
+ gd . on ( 'plotly_unhover' , function ( data ) {
1174
+ futureData = data ;
1175
+ } ) ;
1176
+ } ) ;
1177
+
1178
+ it ( '@gl should contain the correct fields' , function ( done ) {
1179
+ move ( pointPos [ 0 ] , pointPos [ 1 ] , nearPos [ 0 ] , nearPos [ 1 ] , HOVERMINTIME + 10 ) . then ( function ( ) {
1180
+ var pt = futureData . points [ 0 ] ;
1181
+
1182
+ expect ( Object . keys ( pt ) ) . toEqual ( [
1183
+ 'data' , 'fullData' , 'curveNumber' , 'pointNumber' , 'pointIndex' , 'lon' , 'lat'
1184
+ ] ) ;
1185
+
1186
+ expect ( pt . curveNumber ) . toEqual ( 0 , 'points[0].curveNumber' ) ;
1187
+ expect ( typeof pt . data ) . toEqual ( typeof { } , 'points[0].data' ) ;
1188
+ expect ( typeof pt . fullData ) . toEqual ( typeof { } , 'points[0].fullData' ) ;
1189
+ expect ( pt . lat ) . toEqual ( 10 , 'points[0].lat' ) ;
1190
+ expect ( pt . lon ) . toEqual ( 10 , 'points[0].lon' ) ;
1191
+ expect ( pt . pointNumber ) . toEqual ( 0 , 'points[0].pointNumber' ) ;
1192
+ } ) . then ( done ) ;
1193
+ } ) ;
1194
+ } ) ;
1195
+ } ) ;
0 commit comments