describe('first', function() { it('1 is 1', function() { expect(1).toEqual(1) }) it('2 is 2', function() { expect(2).toEqual(2) }) }) describe('webgl support', function() { it('should work', function(done) { var gl var canvas try { canvas = document.createElement('canvas') gl = canvas.getContext('webgl') } catch(err) { gl = null } expect(!!gl).toBe(true) done() }) it('should have a devicePixelRatio window property', function() { expect(window.devicePixelRatio).toEqual(1) }) }) describe('plotly.js WebGL', function() { var gd = document.createElement('div') document.body.appendChild(gd) it('should load library', function() { expect(typeof Plotly).toEqual('object') }) it('should generate WebGL graph (3D case)', function(done) { Plotly.newPlot(gd, [{ type: 'scatter3d', x: [1, 2, 3], y: [1, 2, 3], z: [2, 1, 2] }]) .then(function() { expect(typeof gd._fullLayout.scene._scene).toEqual('object') return Plotly.toImage(gd) }) .then(function(img) { expect(img.length).toEqual(21914) }) .then(function() { Plotly.purge(gd) done() }) }) it('should generate WebGL graph (2D case)', function(done) { Plotly.newPlot(gd, [{ type: 'scattergl', x: [1, 2, 3], y: [1, 2, 1] }]) .then(function() { expect(typeof gd._fullLayout._plots.xy._scene2d).toEqual('object') return Plotly.toImage(gd) }) .then(function(img) { expect(img.length).toEqual(21062) }) .then(function() { Plotly.purge(gd) done() }) }) })