|
1 | 1 | var Plotly = require('@lib/index'); |
| 2 | +var Lib = require('@src/lib'); |
| 3 | + |
| 4 | +var helpers = require('@src/snapshot/helpers'); |
| 5 | + |
2 | 6 | var createGraphDiv = require('../assets/create_graph_div'); |
3 | 7 | var destroyGraphDiv = require('../assets/destroy_graph_div'); |
4 | | -var textchartMock = require('@mocks/text_chart_arrays.json'); |
5 | 8 | var failTest = require('../assets/fail_test'); |
6 | 9 |
|
7 | | -var Lib = require('@src/lib'); |
8 | | - |
| 10 | +var textchartMock = require('@mocks/text_chart_arrays.json'); |
9 | 11 | var LONG_TIMEOUT_INTERVAL = 2 * jasmine.DEFAULT_TIMEOUT_INTERVAL; |
10 | 12 |
|
11 | 13 | describe('Plotly.downloadImage', function() { |
@@ -136,6 +138,26 @@ describe('Plotly.downloadImage', function() { |
136 | 138 | .catch(failTest) |
137 | 139 | .then(done); |
138 | 140 | }, LONG_TIMEOUT_INTERVAL); |
| 141 | + |
| 142 | + it('should produce right output in Safari', function(done) { |
| 143 | + spyOn(Lib, 'isSafari').and.callFake(function() { return true; }); |
| 144 | + spyOn(helpers, 'octetStream'); |
| 145 | + |
| 146 | + Plotly.plot(gd, textchartMock.data, textchartMock.layout) |
| 147 | + .then(function() { return Plotly.downloadImage(gd, {format: 'svg'}); }) |
| 148 | + .then(function() { return Plotly.downloadImage(gd, {format: 'png'}); }) |
| 149 | + .then(function() { return Plotly.downloadImage(gd, {format: 'jpeg'}); }) |
| 150 | + .then(function() { return Plotly.downloadImage(gd, {format: 'webp'}); }) |
| 151 | + .then(function() { |
| 152 | + var args = helpers.octetStream.calls.allArgs(); |
| 153 | + expect(args[0][0].slice(0, 15)).toBe(',%3Csvg%20class', 'format:svg'); |
| 154 | + expect(args[1][0].slice(0, 8)).toBe(';base64,', 'format:png'); |
| 155 | + expect(args[2][0].slice(0, 8)).toBe(';base64,', 'format:jpeg'); |
| 156 | + expect(args[3][0].slice(0, 8)).toBe(';base64,', 'format:webp'); |
| 157 | + }) |
| 158 | + .catch(failTest) |
| 159 | + .then(done); |
| 160 | + }); |
139 | 161 | }); |
140 | 162 |
|
141 | 163 | function downloadTest(gd, format) { |
|
0 commit comments