|
| 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