Skip to content

Commit

Permalink
PR feedback - cover the other gl2d plot types - other plot type tests
Browse files Browse the repository at this point in the history
  • Loading branch information
monfera committed Oct 4, 2016
1 parent 2e54a99 commit 57cec8c
Showing 1 changed file with 158 additions and 0 deletions.
158 changes: 158 additions & 0 deletions test/jasmine/tests/gl2d_click_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,79 @@ describe('Test hover and click interactions', function() {
if(!hasWebGLSupport('gl2d_click_test')) return;

var mock = require('@mocks/gl2d_14.json');
var mock2 = require('@mocks/gl2d_pointcloud-basic.json');
var mock3 = {
'data': [
{
'type': 'contourgl',
'z': [
[
10,
10.625,
12.5,
15.625,
20
],
[
5.625,
6.25,
8.125,
11.25,
15.625
],
[
2.5,
3.125,
5,
8.125,
12.5
],
[
0.625,
1.25,
3.125,
6.25,
10.625
],
[
0,
0.625,
2.5,
5.625,
10
]
],
'colorscale': 'Jet',
'contours': {
'start': 2,
'end': 10,
'size': 1
},
'uid': 'ad5624',
'zmin': 0,
'zmax': 20
}
],
'layout': {
'xaxis': {
'range': [
0,
4
],
'autorange': true
},
'yaxis': {
'range': [
0,
4
],
'autorange': true
},
'height': 450,
'width': 1000,
'autosize': true
}
};

var mockCopy, gd;

Expand Down Expand Up @@ -183,6 +256,91 @@ describe('Test hover and click interactions', function() {

});

describe('hover event is fired for other gl2d plot types', function() {
var futureData;

it('pointcloud', function(done) {

var modifiedMockCopy = Lib.extendDeep({}, mock2);

Plotly.plot(gd, modifiedMockCopy.data, modifiedMockCopy.layout)

.then(new Promise(function() {

gd.on('plotly_hover', function(data) {
futureData = data;
});

hover(540, 150);

window.setTimeout(function() {

expect(futureData.points.length).toEqual(1);

var pt = futureData.points[0];

expect(Object.keys(pt)).toEqual([
'x', 'y', 'curveNumber', 'pointNumber', 'data', 'fullData', 'xaxis', 'yaxis'
]);

expect(pt.x).toEqual(4.5);
expect(pt.y).toEqual(9);
expect(pt.curveNumber).toEqual(2);
expect(pt.pointNumber).toEqual(1);
expect(pt.fullData.length).toEqual(3);
expect(typeof pt.data.uid).toEqual('string');
expect(pt.xaxis.domain.length).toEqual(2);
expect(pt.yaxis.domain.length).toEqual(2);

done();
}, 350);
}));


});

it('heatmapgl', function(done) {

var modifiedMockCopy = Lib.extendDeep({}, mock3);
modifiedMockCopy.data[0].type = 'heatmapgl';

Plotly.plot(gd, modifiedMockCopy.data, modifiedMockCopy.layout)

.then(new Promise(function() {

gd.on('plotly_hover', function(data) {
futureData = data;
});

hover(540, 150);

window.setTimeout(function() {

expect(futureData.points.length).toEqual(1);

var pt = futureData.points[0];

expect(Object.keys(pt)).toEqual([
'x', 'y', 'curveNumber', 'pointNumber', 'data', 'fullData', 'xaxis', 'yaxis'
]);

expect(pt.x).toEqual(2);
expect(pt.y).toEqual(3);
expect(pt.curveNumber).toEqual(0);
expect(pt.pointNumber).toEqual([2, 3, 17]);
expect(pt.fullData.length).toEqual(1);
expect(typeof pt.data.uid).toEqual('string');
expect(pt.xaxis.domain.length).toEqual(2);
expect(pt.yaxis.domain.length).toEqual(2);

done();
}, 350);
}));


});
});

describe('click event is fired on click', function() {
var futureData;

Expand Down

0 comments on commit 57cec8c

Please sign in to comment.