Skip to content

Commit 9f3827c

Browse files
committed
add gl text chart select test
1 parent 431c564 commit 9f3827c

File tree

1 file changed

+57
-0
lines changed

1 file changed

+57
-0
lines changed

test/jasmine/tests/gl2d_click_test.js

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -738,4 +738,61 @@ describe('@noCI @gl Test gl2d lasso/select:', function() {
738738
.catch(failTest)
739739
.then(done);
740740
});
741+
742+
it('should work on gl text charts', function(done) {
743+
var fig = Lib.extendDeep({}, require('@mocks/gl2d_text_chart_basic.json'));
744+
fig.layout.dragmode = 'select';
745+
fig.layout.margin = {t: 0, b: 0, l: 0, r: 0};
746+
fig.layout.height = 500;
747+
fig.layout.width = 500;
748+
gd = createGraphDiv();
749+
750+
function _assertGlTextOpts(msg, exp) {
751+
var scene = gd.calcdata[0][0].t._scene;
752+
scene.glText.forEach(function(opts, i) {
753+
expect(Array.from(opts.color))
754+
.toBeCloseToArray(exp.rgba[i], 2, 'item ' + i + ' - ' + msg);
755+
});
756+
}
757+
758+
Plotly.plot(gd, fig)
759+
.then(delay(100))
760+
.then(function() {
761+
_assertGlTextOpts('base', {
762+
rgba: [
763+
[68, 68, 68, 255],
764+
[68, 68, 68, 255],
765+
[68, 68, 68, 255]
766+
]
767+
});
768+
})
769+
.then(function() { return select([[100, 100], [250, 250]]); })
770+
.then(function(eventData) {
771+
assertEventData(eventData, {
772+
points: [{x: 1, y: 2}]
773+
});
774+
_assertGlTextOpts('after selection', {
775+
rgba: [
776+
[
777+
68, 68, 68, 51,
778+
68, 68, 68, 51,
779+
68, 68, 68, 51,
780+
],
781+
[
782+
68, 68, 68, 51,
783+
// this is the selected pt!
784+
68, 68, 68, 255,
785+
68, 68, 68, 51
786+
],
787+
[
788+
68, 68, 68, 51,
789+
68, 68, 68, 51,
790+
68, 68, 68, 51
791+
]
792+
]
793+
});
794+
})
795+
.catch(failTest)
796+
.then(done);
797+
});
741798
});

0 commit comments

Comments
 (0)