Skip to content

Commit 9b4a38d

Browse files
committed
checkTextTemplate: make sure empty text shows up as empty string
1 parent b5f0316 commit 9b4a38d

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

test/jasmine/assets/check_texttemplate.js

+12-2
Original file line numberDiff line numberDiff line change
@@ -65,11 +65,21 @@ module.exports = function checkTextTemplate(mock, selector, tests) {
6565
}
6666
tests.push(['%{meta.colname}', metaSolution]);
6767

68+
// Make sure that empty text shows up as an empty string
69+
var emptyTextMock = Lib.extendDeep([], mock);
70+
var emptyTextSolution = [];
71+
emptyTextMock[0].text = [];
72+
for(i = 0; i < N; i++) {
73+
emptyTextMock[0].text[i] = '';
74+
emptyTextSolution[i] = 'text:';
75+
}
76+
tests.push(['text:%{text}', emptyTextSolution, emptyTextMock]);
77+
6878
if(isGL) {
6979
tests.forEach(function(test) {
7080
it('@gl should support texttemplate', function(done) {
7181
var gd = createGraphDiv();
72-
var mockCopy = Lib.extendDeep([], mock);
82+
var mockCopy = Lib.extendDeep([], test[2] || mock);
7383
mockCopy[0].texttemplate = test[0];
7484
Plotly.newPlot(gd, mockCopy)
7585
.then(function() {
@@ -101,7 +111,7 @@ module.exports = function checkTextTemplate(mock, selector, tests) {
101111
tests.forEach(function(test) {
102112
it('should support texttemplate', function(done) {
103113
var gd = createGraphDiv();
104-
var mockCopy = Lib.extendDeep([], mock);
114+
var mockCopy = Lib.extendDeep([], test[2] || mock);
105115
mockCopy[0].texttemplate = test[0];
106116
Plotly.newPlot(gd, mockCopy)
107117
.then(function() {

0 commit comments

Comments
 (0)