-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
/
Copy pathcheck_event_data.js
42 lines (31 loc) · 1.03 KB
/
check_event_data.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
var Plotly = require('@lib/index');
var createGraphDiv = require('../assets/create_graph_div');
var destroyGraphDiv = require('../assets/destroy_graph_div');
var Lib = require('@src/lib');
var hover = require('../assets/hover');
'use strict';
module.exports = function checkEventData(mock, x, y, additionalFields) {
var mockCopy = Lib.extendDeep({}, mock);
var gd;
beforeEach(function(done) {
gd = createGraphDiv();
Plotly.newPlot(gd, mockCopy.data, mockCopy.layout)
.then(done);
});
afterEach(destroyGraphDiv);
it('should contain the correct fields', function() {
var hoverData;
gd.on('plotly_hover', function(data) {
hoverData = data;
});
hover(x, y);
var fields = [
'curveNumber',
'data', 'fullData',
'xaxis', 'yaxis', 'x', 'y',
].concat(additionalFields);
fields.forEach(function(field) {
expect(Object.keys(hoverData.points[0])).toContain(field);
});
});
};