|
1 | 1 | var Surface = require('@src/traces/surface');
|
| 2 | +var Plotly = require('@lib/index'); |
| 3 | +var failTest = require('../assets/fail_test'); |
| 4 | +var createGraphDiv = require('../assets/create_graph_div'); |
| 5 | +var destroyGraphDiv = require('../assets/destroy_graph_div'); |
2 | 6 |
|
3 | 7 | var Lib = require('@src/lib');
|
4 | 8 |
|
@@ -178,5 +182,93 @@ describe('Test surface', function() {
|
178 | 182 | expect(traceOut.ycalendar).toBe('ethiopian');
|
179 | 183 | expect(traceOut.zcalendar).toBe('mayan');
|
180 | 184 | });
|
| 185 | + |
| 186 | + }); |
| 187 | + |
| 188 | + |
| 189 | + describe('Test dimension and expected visibility tests', function() { |
| 190 | + var gd; |
| 191 | + |
| 192 | + beforeEach(function() { |
| 193 | + gd = createGraphDiv(); |
| 194 | + }); |
| 195 | + |
| 196 | + |
| 197 | + afterEach(function() { |
| 198 | + Plotly.purge(gd); |
| 199 | + destroyGraphDiv(); |
| 200 | + }); |
| 201 | + |
| 202 | + |
| 203 | + function assertVisibility(exp, msg) { |
| 204 | + expect(gd._fullData[0]).not.toBe(undefined, 'no visibility!'); |
| 205 | + expect(gd._fullData[0].visible).toBe(exp, msg); |
| 206 | + } |
| 207 | + |
| 208 | + fit('@gl surface should be invisible when the z array is empty', function(done) { |
| 209 | + Plotly.plot(gd, [{ |
| 210 | + 'type': 'surface', |
| 211 | + 'z': [] |
| 212 | + }]) |
| 213 | + .then(function() { |
| 214 | + assertVisibility(false, 'not to be visible'); |
| 215 | + }) |
| 216 | + .catch(failTest) |
| 217 | + .then(done); |
| 218 | + }); |
| 219 | + |
| 220 | + fit('@gl surface should be invisible when the x array is defined but has less than two rows', function(done) { |
| 221 | + Plotly.plot(gd, [{ |
| 222 | + 'type': 'surface', |
| 223 | + 'x': [0], |
| 224 | + 'y': [0, 1], |
| 225 | + 'z': [[1], [2]] |
| 226 | + }]) |
| 227 | + .then(function() { |
| 228 | + assertVisibility(false, 'not to be visible'); |
| 229 | + }) |
| 230 | + .catch(failTest) |
| 231 | + .then(done); |
| 232 | + }); |
| 233 | + |
| 234 | + fit('@gl surface should be invisible when the y array is defined but has less than two colums', function(done) { |
| 235 | + Plotly.plot(gd, [{ |
| 236 | + 'type': 'surface', |
| 237 | + 'x': [0, 1], |
| 238 | + 'y': [0], |
| 239 | + 'z': [[1, 2]] |
| 240 | + }]) |
| 241 | + .then(function() { |
| 242 | + assertVisibility(false, 'not to be visible'); |
| 243 | + }) |
| 244 | + .catch(failTest) |
| 245 | + .then(done); |
| 246 | + }); |
| 247 | + |
| 248 | + fit('@gl surface should be visible when the x and y are not provided; but z array is provided', function(done) { |
| 249 | + Plotly.plot(gd, [{ |
| 250 | + 'type': 'surface', |
| 251 | + 'z': [[1, 2], [3, 4]] |
| 252 | + }]) |
| 253 | + .then(function() { |
| 254 | + assertVisibility(true, 'to be visible'); |
| 255 | + }) |
| 256 | + .catch(failTest) |
| 257 | + .then(done); |
| 258 | + }); |
| 259 | + |
| 260 | + fit('@gl surface should be invisible when the x and y are provided; but z array is not provided', function(done) { |
| 261 | + Plotly.plot(gd, [{ |
| 262 | + 'type': 'surface', |
| 263 | + 'x': [0, 1], |
| 264 | + 'y': [0, 1] |
| 265 | + }]) |
| 266 | + .then(function() { |
| 267 | + assertVisibility(false, 'to be invisible'); |
| 268 | + }) |
| 269 | + .catch(failTest) |
| 270 | + .then(done); |
| 271 | + }); |
| 272 | + |
181 | 273 | });
|
182 | 274 | });
|
0 commit comments