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

Skip to content

Commit 122ec6d

Browse files
authored
Merge pull request plotly#1727 from plotly/fixup-sort-transform-event-data-test
Fixup sort transform event data text using
2 parents 6cc5ffd + 50e36f5 commit 122ec6d

File tree

1 file changed

+9
-27
lines changed

1 file changed

+9
-27
lines changed

test/jasmine/tests/transform_sort_test.js

Lines changed: 9 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,7 @@ describe('Test sort transform interactions:', function() {
258258
.then(done);
259259
});
260260

261-
it('does not preserve hover/click `pointNumber` value', function(done) {
261+
it('does not preserve event data `pointNumber` value', function(done) {
262262
var gd = createGraphDiv();
263263

264264
function getPxPos(gd, id) {
@@ -273,32 +273,18 @@ describe('Test sort transform interactions:', function() {
273273
}
274274

275275
function hover(gd, id) {
276-
return new Promise(function(resolve) {
276+
return new Promise(function(resolve, reject) {
277277
gd.once('plotly_hover', function(eventData) {
278+
delete gd._lastHoverTime;
278279
resolve(eventData);
279280
});
280281

281282
var pos = getPxPos(gd, id);
282283
mouseEvent('mousemove', pos[0], pos[1]);
283-
});
284-
}
285-
286-
function click(gd, id) {
287-
return new Promise(function(resolve) {
288-
gd.once('plotly_click', function(eventData) {
289-
resolve(eventData);
290-
});
291-
292-
var pos = getPxPos(gd, id);
293-
mouseEvent('mousemove', pos[0], pos[1]);
294-
mouseEvent('mousedown', pos[0], pos[1]);
295-
mouseEvent('mouseup', pos[0], pos[1]);
296-
});
297-
}
298284

299-
function wait() {
300-
return new Promise(function(resolve) {
301-
setTimeout(resolve, 100);
285+
setTimeout(function() {
286+
reject('plotly_hover did not get called!');
287+
}, 100);
302288
});
303289
}
304290

@@ -334,21 +320,18 @@ describe('Test sort transform interactions:', function() {
334320
.then(function(eventData) {
335321
assertPt(eventData, 0, 1, 3, 'D');
336322
})
337-
.then(wait)
338-
.then(function() { return click(gd, 'G'); })
323+
.then(function() { return hover(gd, 'G'); })
339324
.then(function(eventData) {
340325
assertPt(eventData, 1, 1, 6, 'G');
341326
})
342-
.then(wait)
343327
.then(function() {
344328
return Plotly.restyle(gd, 'transforms[0].enabled', true);
345329
})
346330
.then(function() { return hover(gd, 'D'); })
347331
.then(function(eventData) {
348332
assertPt(eventData, 0, 1, 1, 'D');
349333
})
350-
.then(wait)
351-
.then(function() { return click(gd, 'G'); })
334+
.then(function() { return hover(gd, 'G'); })
352335
.then(function(eventData) {
353336
assertPt(eventData, 1, 1, 5, 'G');
354337
})
@@ -359,8 +342,7 @@ describe('Test sort transform interactions:', function() {
359342
.then(function(eventData) {
360343
assertPt(eventData, 0, 1, 1, 'D');
361344
})
362-
.then(wait)
363-
.then(function() { return click(gd, 'G'); })
345+
.then(function() { return hover(gd, 'G'); })
364346
.then(function(eventData) {
365347
assertPt(eventData, 1, 1, 5, 'G');
366348
})

0 commit comments

Comments
 (0)