Skip to content

Commit e362bc9

Browse files
committed
mv toSVG with <base> test to toImage suite
1 parent 2cddc84 commit e362bc9

File tree

2 files changed

+35
-30
lines changed

2 files changed

+35
-30
lines changed

test/jasmine/tests/snapshot_test.js

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -367,35 +367,5 @@ describe('Plotly.Snapshot', function() {
367367
.catch(failTest)
368368
.then(done);
369369
});
370-
371-
it('should work on pages with <base>', function(done) {
372-
var base = d3.select('body')
373-
.append('base')
374-
.attr('href', 'https://plot.ly');
375-
376-
Plotly.plot(gd, [{ y: [1, 2, 1] }], {}, {exportedPlot: true})
377-
.then(function() { return Plotly.Snapshot.toSVG(gd); })
378-
.then(function(svg) {
379-
var svgDOM = parser.parseFromString(svg, 'image/svg+xml');
380-
var gSubplot = svgDOM.getElementsByClassName('plot')[0];
381-
var clipPath = gSubplot.getAttribute('clip-path');
382-
var len = clipPath.length;
383-
384-
var head = clipPath.substr(0, 4);
385-
var tail = clipPath.substr(len - 7, len);
386-
expect(head).toBe('url(', 'subplot clipPath head');
387-
expect(tail).toBe('xyplot)', 'subplot clipPath tail');
388-
389-
var middle = clipPath.substr(5, 10);
390-
expect(middle.length).toBe(10, 'subplot clipPath uid length');
391-
expect(middle.indexOf('http://')).toBe(-1, 'no <base> URL in subplot clipPath!');
392-
expect(middle.indexOf('https://')).toBe(-1, 'no <base> URL in subplot clipPath!');
393-
})
394-
.catch(failTest)
395-
.then(function() {
396-
base.remove();
397-
done();
398-
});
399-
});
400370
});
401371
});

test/jasmine/tests/toimage_test.js

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
var Plotly = require('@lib');
22
var Lib = require('@src/lib');
33

4+
var d3 = require('d3');
45
var createGraphDiv = require('../assets/create_graph_div');
56
var destroyGraphDiv = require('../assets/destroy_graph_div');
67
var failTest = require('../assets/fail_test');
@@ -210,4 +211,38 @@ describe('Plotly.toImage', function() {
210211
.catch(failTest)
211212
.then(done);
212213
});
214+
215+
it('should work on pages with <base>', function(done) {
216+
var parser = new DOMParser();
217+
218+
var base = d3.select('body')
219+
.append('base')
220+
.attr('href', 'https://plot.ly');
221+
222+
Plotly.plot(gd, [{ y: [1, 2, 1] }])
223+
.then(function() {
224+
return Plotly.toImage(gd, {format: 'svg', imageDataOnly: true});
225+
})
226+
.then(function(svg) {
227+
var svgDOM = parser.parseFromString(svg, 'image/svg+xml');
228+
var gSubplot = svgDOM.getElementsByClassName('plot')[0];
229+
var clipPath = gSubplot.getAttribute('clip-path');
230+
var len = clipPath.length;
231+
232+
var head = clipPath.substr(0, 4);
233+
var tail = clipPath.substr(len - 7, len);
234+
expect(head).toBe('url(', 'subplot clipPath head');
235+
expect(tail).toBe('xyplot)', 'subplot clipPath tail');
236+
237+
var middle = clipPath.substr(4, 10);
238+
expect(middle.length).toBe(10, 'subplot clipPath uid length');
239+
expect(middle.indexOf('http://')).toBe(-1, 'no <base> URL in subplot clipPath!');
240+
expect(middle.indexOf('https://')).toBe(-1, 'no <base> URL in subplot clipPath!');
241+
})
242+
.catch(failTest)
243+
.then(function() {
244+
base.remove();
245+
done();
246+
});
247+
});
213248
});

0 commit comments

Comments
 (0)