Skip to content

Commit 859daeb

Browse files
monferaetpinard
authored andcommitted
additional test case; minor renames
1 parent b6d83ca commit 859daeb

File tree

2 files changed

+50
-5
lines changed

2 files changed

+50
-5
lines changed

src/traces/table/attributes.js

+4-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,10 @@ module.exports = overrideAll({
4848
arrayOk: true,
4949
dflt: null,
5050
role: 'style',
51-
description: 'The width of cells.'
51+
description: [
52+
'The width of columns expressed as a ratio. Columns fill the available width',
53+
'in proportion of their specified column widths.'
54+
].join(' ')
5255
},
5356

5457
columnorder: {

test/jasmine/tests/table_test.js

+46-4
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ describe('table', function() {
192192
});
193193
});
194194

195-
describe('basic use', function() {
195+
describe('basic use and basic data restyling', function() {
196196
var mockCopy,
197197
gd;
198198

@@ -211,7 +211,7 @@ describe('table', function() {
211211
expect(gd.data.length).toEqual(1);
212212
expect(gd.data[0].header.values.length).toEqual(7);
213213
expect(gd.data[0].cells.values.length).toEqual(7);
214-
expect(document.querySelectorAll('.' + cn.yColumn).length).toEqual(7); // one dimension is `visible: false`
214+
expect(document.querySelectorAll('.' + cn.yColumn).length).toEqual(7);
215215
});
216216

217217
it('Calling `Plotly.plot` again should add the new table trace', function(done) {
@@ -269,7 +269,7 @@ describe('table', function() {
269269
.then(done);
270270
});
271271

272-
it('Calling `Plotly.relayout` with string should amend the preexisting parcoords', function(done) {
272+
it('Calling `Plotly.relayout` with string should amend the preexisting table', function(done) {
273273
expect(gd.layout.width).toEqual(1000);
274274
Plotly.relayout(gd, 'width', 500).then(function() {
275275
expect(gd.data.length).toEqual(1);
@@ -278,7 +278,7 @@ describe('table', function() {
278278
});
279279
});
280280

281-
it('Calling `Plotly.relayout` with object should amend the preexisting parcoords', function(done) {
281+
it('Calling `Plotly.relayout` with object should amend the preexisting table', function(done) {
282282
expect(gd.layout.width).toEqual(1000);
283283
Plotly.relayout(gd, {width: 500}).then(function() {
284284
expect(gd.data.length).toEqual(1);
@@ -287,4 +287,46 @@ describe('table', function() {
287287
});
288288
});
289289
});
290+
291+
describe('more restyling tests with scenegraph queries', function() {
292+
var mockCopy,
293+
gd;
294+
295+
beforeEach(function(done) {
296+
mockCopy = Lib.extendDeep({}, mock2);
297+
gd = createGraphDiv();
298+
Plotly.plot(gd, mockCopy.data, mockCopy.layout).then(done);
299+
});
300+
301+
it('Calling `Plotly.restyle` for a `header.values` change should amend the preexisting one', function(done) {
302+
303+
function restyleValues(what, fun, setterValue) {
304+
305+
var value = Lib.isArray(setterValue) ? setterValue[0] : setterValue;
306+
307+
return function() {
308+
return Plotly.restyle(gd, what, setterValue).then(function() {
309+
expect(fun(gd)).toEqual(value, what + ':::' + value);
310+
expect(document.querySelectorAll('.' + cn.yColumn).length).toEqual(2);
311+
expect(document.querySelectorAll('.' + cn.columnBlock).length).toEqual(6);
312+
expect(document.querySelectorAll('.' + cn.columnCell).length).toEqual(6);
313+
expect(document.querySelectorAll('.' + cn.cellRect).length).toEqual(6);
314+
expect(document.querySelectorAll('.' + cn.cellTextHolder).length).toEqual(6);
315+
});
316+
};
317+
}
318+
319+
restyleValues('cells.fill.color', function(gd) {return gd.data[0].cells.fill.color;}, [['green', 'red']])()
320+
.then(restyleValues('cells.line.color', function(gd) {return gd.data[0].cells.line.color;}, [['magenta', 'blue']]))
321+
.then(restyleValues('cells.line.width', function(gd) {return gd.data[0].cells.line.width;}, [[5, 3]]))
322+
.then(restyleValues('cells.format', function(gd) {return gd.data[0].cells.format;}, [['', '']]))
323+
.then(restyleValues('cells.prefix', function(gd) {return gd.data[0].cells.prefix;}, [['p1']]))
324+
.then(restyleValues('cells.suffix', function(gd) {return gd.data[0].cells.suffix;}, [['s1']]))
325+
.then(restyleValues('header.fill.color', function(gd) {return gd.data[0].header.fill.color;}, [['yellow', 'purple']]))
326+
.then(restyleValues('header.line.color', function(gd) {return gd.data[0].header.line.color;}, [['green', 'red']]))
327+
.then(restyleValues('header.line.width', function(gd) {return gd.data[0].header.line.width;}, [[2, 6]]))
328+
.then(restyleValues('header.format', function(gd) {return gd.data[0].header.format;}, [['', '']]))
329+
.then(done);
330+
});
331+
});
290332
});

0 commit comments

Comments
 (0)