Skip to content

Commit 714e05b

Browse files
committed
Merge pull request #210 from plotly/geo-hover-test
add geo hover tests
2 parents 79ba3a7 + ba09f65 commit 714e05b

File tree

1 file changed

+68
-0
lines changed

1 file changed

+68
-0
lines changed
+68
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
var d3 = require('d3');
2+
3+
var Plotly = require('@lib/index');
4+
5+
var createGraphDiv = require('../assets/create_graph_div');
6+
var destroyGraphDiv = require('../assets/destroy_graph_div');
7+
var mouseEvent = require('../assets/mouse_event');
8+
9+
10+
describe('Test geo interactions', function() {
11+
'use strict';
12+
13+
afterEach(destroyGraphDiv);
14+
15+
describe('mock geo_first.json', function() {
16+
var mock = require('@mocks/geo_first.json');
17+
18+
beforeEach(function(done) {
19+
Plotly.plot(createGraphDiv(), mock.data, mock.layout).then(done);
20+
});
21+
22+
describe('scattegeo hover labels', function() {
23+
beforeEach(function() {
24+
mouseEvent('mouseover', 459, 246);
25+
});
26+
27+
it('should show one hover text group', function() {
28+
expect(d3.selectAll('g.hovertext').size()).toEqual(1);
29+
});
30+
31+
it('should show longitude and latitude values', function() {
32+
var node = d3.selectAll('g.hovertext').selectAll('tspan')[0][0];
33+
34+
expect(node.innerHTML).toEqual('(0°, 0°)');
35+
});
36+
37+
it('should show the trace name', function() {
38+
var node = d3.selectAll('g.hovertext').selectAll('text')[0][0];
39+
40+
expect(node.innerHTML).toEqual('trace 0');
41+
});
42+
});
43+
44+
describe('choropleth hover labels', function() {
45+
beforeEach(function() {
46+
mouseEvent('mouseover', 628, 162);
47+
});
48+
49+
it('should show one hover text group', function() {
50+
expect(d3.selectAll('g.hovertext').size()).toEqual(1);
51+
});
52+
53+
it('should show location and z values', function() {
54+
var node = d3.selectAll('g.hovertext').selectAll('tspan')[0];
55+
56+
expect(node[0].innerHTML).toEqual('RUS');
57+
expect(node[1].innerHTML).toEqual('10');
58+
});
59+
60+
it('should show the trace name', function() {
61+
var node = d3.selectAll('g.hovertext').selectAll('text')[0][0];
62+
63+
expect(node.innerHTML).toEqual('trace 1');
64+
});
65+
});
66+
67+
});
68+
});

0 commit comments

Comments
 (0)