Skip to content

Commit 4adc091

Browse files
committed
add styleOnSelect test
... as on-selection styling now goes a different pathway than restyle().
1 parent 3776e8f commit 4adc091

File tree

1 file changed

+23
-12
lines changed

1 file changed

+23
-12
lines changed

test/jasmine/tests/scatter_test.js

+23-12
Original file line numberDiff line numberDiff line change
@@ -893,25 +893,36 @@ describe('Test Scatter.style', function() {
893893

894894
afterEach(destroyGraphDiv);
895895

896+
function assertPts(attr, getterFn, expectation, msg2) {
897+
var selector = attr.indexOf('textfont') === 0 ? '.textpoint > text' : '.point';
898+
899+
d3.select(gd).selectAll('.trace').each(function(_, i) {
900+
var pts = d3.select(this).selectAll(selector);
901+
var expi = expectation[i];
902+
903+
expect(pts.size())
904+
.toBe(expi.length, '# of pts for trace ' + i + msg2);
905+
906+
pts.each(function(_, j) {
907+
var msg3 = ' for pt ' + j + ' in trace ' + i + msg2;
908+
expect(getterFn(this)).toBe(expi[j], attr + msg3);
909+
});
910+
});
911+
}
912+
896913
function makeCheckFn(attr, getterFn) {
897914
return function(update, expectation, msg) {
898-
var msg2 = ' (' + msg + ')';
899915
var promise = update ? Plotly.restyle(gd, update) : Promise.resolve();
900-
var selector = attr.indexOf('textfont') === 0 ? '.textpoint > text' : '.point';
901916

902917
return promise.then(function() {
903-
d3.selectAll('.trace').each(function(_, i) {
904-
var pts = d3.select(this).selectAll(selector);
905-
var expi = expectation[i];
906-
907-
expect(pts.size())
908-
.toBe(expi.length, '# of pts for trace ' + i + msg2);
918+
assertPts(attr, getterFn, expectation, ' (' + msg + ' after restyle)');
909919

910-
pts.each(function(_, j) {
911-
var msg3 = ' for pt ' + j + ' in trace ' + i + msg2;
912-
expect(getterFn(this)).toBe(expi[j], attr + msg3);
913-
});
920+
// make sure styleOnSelect (called during selection)
921+
// gives same results as restyle
922+
gd.calcdata.forEach(function(cd) {
923+
Scatter.styleOnSelect(gd, cd);
914924
});
925+
assertPts(attr, getterFn, expectation, ' (' + msg + ' via Scatter.styleOnSelect)');
915926
});
916927
};
917928
}

0 commit comments

Comments
 (0)