Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit d88abf8

Browse files
committed
fix gl2d annotations test
1 parent 87b12cf commit d88abf8

File tree

1 file changed

+14
-14
lines changed

1 file changed

+14
-14
lines changed

test/jasmine/tests/gl_plot_interact_test.js

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ var d3 = require('d3');
33
var Plotly = require('@lib/index');
44
var Plots = require('@src/plots/plots');
55
var Lib = require('@src/lib');
6+
var Drawing = require('@src/components/drawing');
67

78
var createGraphDiv = require('../assets/create_graph_div');
89
var destroyGraphDiv = require('../assets/destroy_graph_div');
@@ -587,6 +588,7 @@ describe('Test gl plot interactions', function() {
587588
});
588589
});
589590
});
591+
590592
describe('Plotly.newPlot', function() {
591593

592594
var mockData2dNew = [{
@@ -761,20 +763,18 @@ describe('gl2d interaction', function() {
761763
it('data-referenced annotations should update on drag', function(done) {
762764

763765
function drag(start, end) {
764-
var opts = { buttons: 1 };
765-
766-
mouseEvent('mousemove', start[0], start[1], opts);
767-
mouseEvent('mousedown', start[0], start[1], opts);
768-
mouseEvent('mousemove', end[0], end[1], opts);
769-
mouseEvent('mouseup', end[0], end[1], opts);
766+
mouseEvent('mousemove', start[0], start[1]);
767+
mouseEvent('mousedown', start[0], start[1], { buttons: 1 });
768+
mouseEvent('mousemove', end[0], end[1], { buttons: 1 });
769+
mouseEvent('mouseup', end[0], end[1]);
770770
}
771771

772772
function assertAnnotation(xy) {
773-
var ann = d3.select('g.annotation-text-g');
774-
var x = +ann.attr('x');
775-
var y = +ann.attr('y');
773+
var ann = d3.select('g.annotation-text-g').select('g');
774+
var translate = Drawing.getTranslate(ann);
776775

777-
expect([x, y]).toBeCloseToArray(xy);
776+
expect(translate.x).toBeWithin(xy[0], 1.5);
777+
expect(translate.y).toBeWithin(xy[1], 1.5);
778778
}
779779

780780
Plotly.plot(gd, [{
@@ -790,18 +790,18 @@ describe('gl2d interaction', function() {
790790
dragmode: 'pan'
791791
})
792792
.then(function() {
793-
assertAnnotation([340, 334]);
793+
assertAnnotation([327, 325]);
794794

795-
drag([250, 200], [150, 300]);
796-
assertAnnotation([410, 264]);
795+
drag([250, 200], [200, 150]);
796+
assertAnnotation([277, 275]);
797797

798798
return Plotly.relayout(gd, {
799799
'xaxis.range': [1.5, 2.5],
800800
'yaxis.range': [1, 1.5]
801801
});
802802
})
803803
.then(function() {
804-
assertAnnotation([340, 340]);
804+
assertAnnotation([327, 331]);
805805
})
806806
.then(done);
807807
});

0 commit comments

Comments
 (0)