Skip to content

Commit 34829f3

Browse files
committed
add test (all clip paths are compatible in <base> envs)
1 parent c1f4598 commit 34829f3

File tree

1 file changed

+70
-0
lines changed

1 file changed

+70
-0
lines changed

test/jasmine/tests/cartesian_test.js

+70
Original file line numberDiff line numberDiff line change
@@ -49,3 +49,73 @@ describe('zoom box element', function() {
4949
.toEqual(0);
5050
});
5151
});
52+
53+
describe('plot svg clip paths', function() {
54+
55+
// plot with all features that rely on clip paths
56+
function plot() {
57+
return Plotly.plot(createGraphDiv(), [{
58+
type: 'contour',
59+
z: [[1,2,3], [2,3,1]]
60+
}, {
61+
type: 'scatter',
62+
y: [2, 1, 2]
63+
}], {
64+
showlegend: true,
65+
xaxis: {
66+
rangeslider: {}
67+
},
68+
shapes: [{
69+
xref: 'x',
70+
yref: 'y',
71+
x0: 0,
72+
y0: 0,
73+
x1: 3,
74+
y1: 3
75+
}]
76+
});
77+
}
78+
79+
afterEach(destroyGraphDiv);
80+
81+
it('should set clip path url to ids (base case)', function(done) {
82+
plot().then(function() {
83+
84+
d3.selectAll('[clip-path]').each(function() {
85+
var cp = d3.select(this).attr('clip-path');
86+
87+
expect(cp.substring(0, 5)).toEqual('url(#');
88+
expect(cp.substring(cp.length-1)).toEqual(')');
89+
});
90+
91+
done();
92+
});
93+
});
94+
95+
it('should set clip path url to ids appended to window url', function(done) {
96+
97+
// this case occurs in some past versions of AngularJS
98+
// https://github.com/angular/angular.js/issues/8934
99+
100+
// append <base> with href
101+
d3.select('body')
102+
.append('base')
103+
.attr('href', 'https://plot.ly');
104+
105+
// grab window URL
106+
var href = window.location.href;
107+
108+
plot().then(function() {
109+
110+
d3.selectAll('[clip-path]').each(function() {
111+
var cp = d3.select(this).attr('clip-path');
112+
113+
expect(cp.substring(0, 5 + href.length)).toEqual('url(' + href + '#');
114+
expect(cp.substring(cp.length-1)).toEqual(')');
115+
});
116+
117+
done();
118+
});
119+
120+
});
121+
});

0 commit comments

Comments
 (0)