Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test IE9 by mocking window globals #1299

Merged
merged 4 commits into from
Jan 13, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 8 additions & 0 deletions test/jasmine/assets/ie9_mock.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
delete window.Promise;

delete window.ArrayBuffer;
delete window.Uint8Array;
delete window.Float32Array;
delete window.Float64Array;
delete window.Int16Array;
delete window.Int32Array;
42 changes: 42 additions & 0 deletions test/jasmine/bundle_tests/ie9_test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
var Plotly = require('@lib/core');

Plotly.register([
require('@lib/bar'),
require('@lib/box'),
require('@lib/heatmap'),
require('@lib/histogram'),
require('@lib/histogram2d'),
require('@lib/histogram2dcontour'),
require('@lib/pie'),
require('@lib/contour'),
require('@lib/scatterternary'),
require('@lib/ohlc'),
require('@lib/candlestick')
]);

var createGraphDiv = require('../assets/create_graph_div');
var destroyGraphDiv = require('../assets/destroy_graph_div');

describe('Bundle with IE9 supported trace types:', function() {

afterEach(destroyGraphDiv);

it(' check that ie9_mock.js did its job', function() {
expect(function() { return ArrayBuffer; })
.toThrow(new ReferenceError('ArrayBuffer is not defined'));
expect(function() { return Uint8Array; })
.toThrow(new ReferenceError('Uint8Array is not defined'));
});

it('heatmaps with smoothing should work', function(done) {
var gd = createGraphDiv();
var data = [{
type: 'heatmap',
z: [[1, 2, 3], [2, 1, 2]],
zsmooth: 'best'
}];

Plotly.plot(gd, data).then(done);
});

});
13 changes: 13 additions & 0 deletions test/jasmine/karma.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ var arg = process.argv[4];
var testFileGlob = arg ? arg : 'tests/*_test.js';
var isSingleSuiteRun = (arg && arg.indexOf('bundle_tests/') === -1);
var isRequireJSTest = (arg && arg.indexOf('bundle_tests/requirejs') !== -1);
var isIE9Test = (arg && arg.indexOf('bundle_tests/ie9') !== -1);

var pathToMain = '../../lib/index.js';
var pathToJQuery = 'assets/jquery-1.8.3.min.js';
Expand Down Expand Up @@ -127,6 +128,18 @@ else if(isRequireJSTest) {
testFileGlob
];
}
else if(isIE9Test) {
// load ie9_mock.js before plotly.js+test bundle
// to catch reference errors that could occur
// when plotly.js is first loaded.

func.defaultConfig.files = [
'./assets/ie9_mock.js',
testFileGlob
];

func.defaultConfig.preprocessors[testFileGlob] = ['browserify'];
}
else {
func.defaultConfig.files = [
pathToJQuery,
Expand Down