|
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,118 @@ describe('Test surface', function() {
|
178 | 182 | expect(traceOut.ycalendar).toBe('ethiopian');
|
179 | 183 | expect(traceOut.zcalendar).toBe('mayan');
|
180 | 184 | });
|
| 185 | + |
| 186 | + }); |
| 187 | + |
| 188 | + describe('Test dimension and expected visibility tests', function() { |
| 189 | + var gd; |
| 190 | + |
| 191 | + beforeEach(function() { |
| 192 | + gd = createGraphDiv(); |
| 193 | + }); |
| 194 | + |
| 195 | + afterEach(function() { |
| 196 | + Plotly.purge(gd); |
| 197 | + destroyGraphDiv(); |
| 198 | + }); |
| 199 | + |
| 200 | + function assertVisibility(exp, msg) { |
| 201 | + expect(gd._fullData[0]).not.toBe(undefined, 'no visibility!'); |
| 202 | + expect(gd._fullData[0].visible).toBe(exp, msg); |
| 203 | + } |
| 204 | + |
| 205 | + it('@gl surface should be invisible when the z array is empty', function(done) { |
| 206 | + Plotly.plot(gd, [{ |
| 207 | + 'type': 'surface', |
| 208 | + 'z': [] |
| 209 | + }]) |
| 210 | + .then(function() { |
| 211 | + assertVisibility(false, 'not to be visible'); |
| 212 | + }) |
| 213 | + .catch(failTest) |
| 214 | + .then(done); |
| 215 | + }); |
| 216 | + |
| 217 | + it('@gl surface should be invisible when the x array is defined but is empty', function(done) { |
| 218 | + Plotly.plot(gd, [{ |
| 219 | + 'type': 'surface', |
| 220 | + 'x': [], |
| 221 | + 'y': [0, 1], |
| 222 | + 'z': [] |
| 223 | + }]) |
| 224 | + .then(function() { |
| 225 | + assertVisibility(false, 'not to be visible'); |
| 226 | + }) |
| 227 | + .catch(failTest) |
| 228 | + .then(done); |
| 229 | + }); |
| 230 | + |
| 231 | + it('@gl surface should be invisible when the y array is defined but is empty', function(done) { |
| 232 | + Plotly.plot(gd, [{ |
| 233 | + 'type': 'surface', |
| 234 | + 'x': [0, 1], |
| 235 | + 'y': [], |
| 236 | + 'z': [] |
| 237 | + }]) |
| 238 | + .then(function() { |
| 239 | + assertVisibility(false, 'not to be visible'); |
| 240 | + }) |
| 241 | + .catch(failTest) |
| 242 | + .then(done); |
| 243 | + }); |
| 244 | + |
| 245 | + it('@gl surface should be invisible when the x array is defined and has at least one item', function(done) { |
| 246 | + Plotly.plot(gd, [{ |
| 247 | + 'type': 'surface', |
| 248 | + 'x': [0], |
| 249 | + 'y': [0, 1], |
| 250 | + 'z': [[1], [2]] |
| 251 | + }]) |
| 252 | + .then(function() { |
| 253 | + assertVisibility(true, 'to be visible'); |
| 254 | + }) |
| 255 | + .catch(failTest) |
| 256 | + .then(done); |
| 257 | + }); |
| 258 | + |
| 259 | + it('@gl surface should be invisible when the y array is defined and has at least one item', function(done) { |
| 260 | + Plotly.plot(gd, [{ |
| 261 | + 'type': 'surface', |
| 262 | + 'x': [0, 1], |
| 263 | + 'y': [0], |
| 264 | + 'z': [[1, 2]] |
| 265 | + }]) |
| 266 | + .then(function() { |
| 267 | + assertVisibility(true, 'to be visible'); |
| 268 | + }) |
| 269 | + .catch(failTest) |
| 270 | + .then(done); |
| 271 | + }); |
| 272 | + |
| 273 | + it('@gl surface should be visible when the x and y are not provided; but z array is provided', function(done) { |
| 274 | + Plotly.plot(gd, [{ |
| 275 | + 'type': 'surface', |
| 276 | + 'z': [[1, 2], [3, 4]] |
| 277 | + }]) |
| 278 | + .then(function() { |
| 279 | + assertVisibility(true, 'to be visible'); |
| 280 | + }) |
| 281 | + .catch(failTest) |
| 282 | + .then(done); |
| 283 | + }); |
| 284 | + |
| 285 | + it('@gl surface should be invisible when the x and y are provided; but z array is not provided', function(done) { |
| 286 | + Plotly.plot(gd, [{ |
| 287 | + 'type': 'surface', |
| 288 | + 'x': [0, 1], |
| 289 | + 'y': [0, 1] |
| 290 | + }]) |
| 291 | + .then(function() { |
| 292 | + assertVisibility(false, 'to be invisible'); |
| 293 | + }) |
| 294 | + .catch(failTest) |
| 295 | + .then(done); |
| 296 | + }); |
| 297 | + |
181 | 298 | });
|
182 | 299 | });
|
0 commit comments