Skip to content

Commit 6687034

Browse files
committed
Add test of current plot title alignment [882]
1 parent 695f311 commit 6687034

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

test/jasmine/tests/titles_test.js

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,42 @@ var createGraphDiv = require('../assets/create_graph_div');
77
var destroyGraphDiv = require('../assets/destroy_graph_div');
88
var mouseEvent = require('../assets/mouse_event');
99

10+
11+
describe('Plot title', function() {
12+
'use strict';
13+
14+
var data = [{x: [1, 2, 3], y: [1, 2, 3]}];
15+
var layout = {title: 'Plotly line chart'};
16+
var gd;
17+
18+
beforeEach(function() {
19+
gd = createGraphDiv();
20+
});
21+
22+
afterEach(destroyGraphDiv);
23+
24+
it('is centered horizontally and vertically above the plot by default', function() {
25+
Plotly.plot(gd, data, layout);
26+
27+
var containerBB = gd.getBoundingClientRect();
28+
29+
expect(titleX()).toBe(containerBB.width / 2);
30+
expect(titleY()).toBe(gd._fullLayout.margin.t / 2);
31+
});
32+
33+
function titleX() {
34+
return Number.parseFloat(titleSel().attr('x'));
35+
}
36+
37+
function titleY() {
38+
return Number.parseFloat(titleSel().attr('y'));
39+
}
40+
41+
function titleSel() {
42+
return d3.select('.infolayer .g-gtitle .gtitle');
43+
}
44+
});
45+
1046
describe('editable titles', function() {
1147
'use strict';
1248

0 commit comments

Comments
 (0)