|
| 1 | +var Plotly = require('@lib'); |
| 2 | + |
| 3 | +var createGraphDiv = require('../assets/create_graph_div'); |
| 4 | +var destroyGraphDiv = require('../assets/destroy_graph_div'); |
| 5 | +var failTest = require('../assets/fail_test'); |
| 6 | + |
| 7 | +describe('Plotly w/o WebGL support:', function() { |
| 8 | + var gd; |
| 9 | + |
| 10 | + beforeEach(function() { |
| 11 | + gd = createGraphDiv(); |
| 12 | + }); |
| 13 | + |
| 14 | + afterEach(function() { |
| 15 | + Plotly.purge(gd); |
| 16 | + destroyGraphDiv(); |
| 17 | + }); |
| 18 | + |
| 19 | + function checkNoWebGLMsg(visible) { |
| 20 | + var msg = gd.querySelector('div.no-webgl > p'); |
| 21 | + if(visible) { |
| 22 | + expect(msg.innerHTML.substr(0, 22)).toBe('WebGL is not supported'); |
| 23 | + } else { |
| 24 | + expect(msg).toBe(null); |
| 25 | + } |
| 26 | + } |
| 27 | + |
| 28 | + it('gl3d subplots', function(done) { |
| 29 | + Plotly.react(gd, require('@mocks/gl3d_autocolorscale.json')) |
| 30 | + .then(function() { |
| 31 | + checkNoWebGLMsg(true); |
| 32 | + return Plotly.react(gd, require('@mocks/10.json')); |
| 33 | + }) |
| 34 | + .then(function() { |
| 35 | + checkNoWebGLMsg(false); |
| 36 | + }) |
| 37 | + .catch(failTest) |
| 38 | + .then(done); |
| 39 | + }); |
| 40 | + |
| 41 | + it('gl2d subplots', function(done) { |
| 42 | + Plotly.react(gd, require('@mocks/gl2d_pointcloud-basic.json')) |
| 43 | + .then(function() { |
| 44 | + checkNoWebGLMsg(true); |
| 45 | + return Plotly.react(gd, require('@mocks/10.json')); |
| 46 | + }) |
| 47 | + .then(function() { |
| 48 | + checkNoWebGLMsg(false); |
| 49 | + }) |
| 50 | + .catch(failTest) |
| 51 | + .then(done); |
| 52 | + }); |
| 53 | + |
| 54 | + it('scattergl subplots', function(done) { |
| 55 | + Plotly.react(gd, require('@mocks/gl2d_12.json')) |
| 56 | + .then(function() { |
| 57 | + checkNoWebGLMsg(true); |
| 58 | + return Plotly.react(gd, require('@mocks/10.json')); |
| 59 | + }) |
| 60 | + .then(function() { |
| 61 | + checkNoWebGLMsg(false); |
| 62 | + |
| 63 | + // one with all regl2d modules |
| 64 | + return Plotly.react(gd, [{ |
| 65 | + type: 'scattergl', |
| 66 | + mode: 'lines+markers', |
| 67 | + fill: 'tozerox', |
| 68 | + y: [1, 2, 1], |
| 69 | + error_x: { value: 10 }, |
| 70 | + error_y: { value: 10 } |
| 71 | + }]); |
| 72 | + }) |
| 73 | + .then(function() { |
| 74 | + checkNoWebGLMsg(true); |
| 75 | + return Plotly.react(gd, require('@mocks/10.json')); |
| 76 | + }) |
| 77 | + .then(function() { |
| 78 | + checkNoWebGLMsg(false); |
| 79 | + }) |
| 80 | + .catch(failTest) |
| 81 | + .then(done); |
| 82 | + }); |
| 83 | + |
| 84 | + it('scatterpolargl subplots', function(done) { |
| 85 | + Plotly.react(gd, require('@mocks/glpolar_scatter.json')) |
| 86 | + .then(function() { |
| 87 | + checkNoWebGLMsg(true); |
| 88 | + return Plotly.react(gd, require('@mocks/10.json')); |
| 89 | + }) |
| 90 | + .then(function() { |
| 91 | + checkNoWebGLMsg(false); |
| 92 | + }) |
| 93 | + .catch(failTest) |
| 94 | + .then(done); |
| 95 | + }); |
| 96 | + |
| 97 | + it('splom subplots', function(done) { |
| 98 | + Plotly.react(gd, require('@mocks/splom_0.json')) |
| 99 | + .then(function() { |
| 100 | + checkNoWebGLMsg(true); |
| 101 | + return Plotly.react(gd, require('@mocks/10.json')); |
| 102 | + }) |
| 103 | + .then(function() { |
| 104 | + checkNoWebGLMsg(false); |
| 105 | + }) |
| 106 | + .catch(failTest) |
| 107 | + .then(done); |
| 108 | + }); |
| 109 | + |
| 110 | + it('parcoords subplots', function(done) { |
| 111 | + Plotly.react(gd, require('@mocks/gl2d_parcoords_2.json')) |
| 112 | + .then(function() { |
| 113 | + checkNoWebGLMsg(true); |
| 114 | + return Plotly.react(gd, require('@mocks/10.json')); |
| 115 | + }) |
| 116 | + .then(function() { |
| 117 | + checkNoWebGLMsg(false); |
| 118 | + }) |
| 119 | + .catch(failTest) |
| 120 | + .then(done); |
| 121 | + }); |
| 122 | +}); |
0 commit comments