Skip to content

Commit 675103c

Browse files
authored
Merge pull request #1299 from plotly/test-ie9
Test IE9 by mocking window globals
2 parents 3e81eca + 2b1c0fe commit 675103c

File tree

3 files changed

+63
-0
lines changed

3 files changed

+63
-0
lines changed

test/jasmine/assets/ie9_mock.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
delete window.Promise;
2+
3+
delete window.ArrayBuffer;
4+
delete window.Uint8Array;
5+
delete window.Float32Array;
6+
delete window.Float64Array;
7+
delete window.Int16Array;
8+
delete window.Int32Array;

test/jasmine/bundle_tests/ie9_test.js

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
var Plotly = require('@lib/core');
2+
3+
Plotly.register([
4+
require('@lib/bar'),
5+
require('@lib/box'),
6+
require('@lib/heatmap'),
7+
require('@lib/histogram'),
8+
require('@lib/histogram2d'),
9+
require('@lib/histogram2dcontour'),
10+
require('@lib/pie'),
11+
require('@lib/contour'),
12+
require('@lib/scatterternary'),
13+
require('@lib/ohlc'),
14+
require('@lib/candlestick')
15+
]);
16+
17+
var createGraphDiv = require('../assets/create_graph_div');
18+
var destroyGraphDiv = require('../assets/destroy_graph_div');
19+
20+
describe('Bundle with IE9 supported trace types:', function() {
21+
22+
afterEach(destroyGraphDiv);
23+
24+
it(' check that ie9_mock.js did its job', function() {
25+
expect(function() { return ArrayBuffer; })
26+
.toThrow(new ReferenceError('ArrayBuffer is not defined'));
27+
expect(function() { return Uint8Array; })
28+
.toThrow(new ReferenceError('Uint8Array is not defined'));
29+
});
30+
31+
it('heatmaps with smoothing should work', function(done) {
32+
var gd = createGraphDiv();
33+
var data = [{
34+
type: 'heatmap',
35+
z: [[1, 2, 3], [2, 1, 2]],
36+
zsmooth: 'best'
37+
}];
38+
39+
Plotly.plot(gd, data).then(done);
40+
});
41+
42+
});

test/jasmine/karma.conf.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ var arg = process.argv[4];
2020
var testFileGlob = arg ? arg : 'tests/*_test.js';
2121
var isSingleSuiteRun = (arg && arg.indexOf('bundle_tests/') === -1);
2222
var isRequireJSTest = (arg && arg.indexOf('bundle_tests/requirejs') !== -1);
23+
var isIE9Test = (arg && arg.indexOf('bundle_tests/ie9') !== -1);
2324

2425
var pathToMain = '../../lib/index.js';
2526
var pathToJQuery = 'assets/jquery-1.8.3.min.js';
@@ -127,6 +128,18 @@ else if(isRequireJSTest) {
127128
testFileGlob
128129
];
129130
}
131+
else if(isIE9Test) {
132+
// load ie9_mock.js before plotly.js+test bundle
133+
// to catch reference errors that could occur
134+
// when plotly.js is first loaded.
135+
136+
func.defaultConfig.files = [
137+
'./assets/ie9_mock.js',
138+
testFileGlob
139+
];
140+
141+
func.defaultConfig.preprocessors[testFileGlob] = ['browserify'];
142+
}
130143
else {
131144
func.defaultConfig.files = [
132145
pathToJQuery,

0 commit comments

Comments
 (0)