Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit d15e541

Browse filesBrowse files
committed
layout.showlegend test
1 parent 68f5dbc commit d15e541
Copy full SHA for d15e541

File tree

1 file changed

+27
-6
lines changed
Filter options

1 file changed

+27
-6
lines changed

‎test/jasmine/tests/legend_test.js

Copy file name to clipboardExpand all lines: test/jasmine/tests/legend_test.js
+27-6Lines changed: 27 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -510,13 +510,34 @@ describe('legend anchor utils:', function() {
510510

511511
describe('legend relayout update', function() {
512512
'use strict';
513+
var gd;
514+
var mock = require('@mocks/0.json');
513515

516+
beforeEach(function() {
517+
gd = createGraphDiv();
518+
});
514519
afterEach(destroyGraphDiv);
515520

521+
it('should hide and show the legend', function(done) {
522+
var mockCopy = Lib.extendDeep({}, mock);
523+
Plotly.newPlot(gd, mockCopy.data, mockCopy.layout)
524+
.then(function() {
525+
expect(d3.selectAll('g.legend').size()).toBe(1);
526+
return Plotly.relayout(gd, {showlegend: false});
527+
})
528+
.then(function() {
529+
expect(d3.selectAll('g.legend').size()).toBe(0);
530+
return Plotly.relayout(gd, {showlegend: true});
531+
})
532+
.then(function() {
533+
expect(d3.selectAll('g.legend').size()).toBe(1);
534+
})
535+
.catch(fail)
536+
.then(done);
537+
});
538+
516539
it('should update border styling', function(done) {
517-
var mock = require('@mocks/0.json'),
518-
mockCopy = Lib.extendDeep({}, mock),
519-
gd = createGraphDiv();
540+
var mockCopy = Lib.extendDeep({}, mock);
520541

521542
function assertLegendStyle(bgColor, borderColor, borderWidth) {
522543
var node = d3.select('g.legend').select('rect');
@@ -547,9 +568,9 @@ describe('legend relayout update', function() {
547568
return Plotly.relayout(gd, 'paper_bgcolor', 'blue');
548569
}).then(function() {
549570
assertLegendStyle('rgb(0, 0, 255)', 'rgb(255, 0, 0)', 10);
550-
551-
done();
552-
});
571+
})
572+
.catch(fail)
573+
.then(done);
553574
});
554575
});
555576

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.