|
| 1 | +var Plotly = require('@lib'); |
| 2 | +var createGraphDiv = require('../assets/create_graph_div'); |
| 3 | +var destroyGraphDiv = require('../assets/destroy_graph_div'); |
| 4 | +var fail = require('../assets/fail_test'); |
| 5 | + |
| 6 | +describe('Test mesh3d restyle', function() { |
| 7 | + afterEach(destroyGraphDiv); |
| 8 | + |
| 9 | + it('should clear *cauto* when restyle *cmin* and/or *cmax*', function(done) { |
| 10 | + var gd = createGraphDiv(); |
| 11 | + |
| 12 | + function _assert(user, full) { |
| 13 | + var trace = gd.data[0]; |
| 14 | + var fullTrace = gd._fullData[0]; |
| 15 | + |
| 16 | + expect(trace.cauto).toBe(user[0], 'user cauto'); |
| 17 | + expect(trace.cmin).toEqual(user[1], 'user cmin'); |
| 18 | + expect(trace.cmax).toEqual(user[2], 'user cmax'); |
| 19 | + expect(fullTrace.cauto).toBe(full[0], 'full cauto'); |
| 20 | + expect(fullTrace.cmin).toEqual(full[1], 'full cmin'); |
| 21 | + expect(fullTrace.cmax).toEqual(full[2], 'full cmax'); |
| 22 | + } |
| 23 | + |
| 24 | + Plotly.plot(gd, [{ |
| 25 | + type: 'mesh3d', |
| 26 | + x: [0, 1, 2, 0], |
| 27 | + y: [0, 0, 1, 2], |
| 28 | + z: [0, 2, 0, 1], |
| 29 | + i: [0, 0, 0, 1], |
| 30 | + j: [1, 2, 3, 2], |
| 31 | + k: [2, 3, 1, 3], |
| 32 | + intensity: [0, 0.33, 0.66, 3] |
| 33 | + }]) |
| 34 | + .then(function() { |
| 35 | + _assert([true, 0, 3], [true, 0, 3]); |
| 36 | + |
| 37 | + return Plotly.restyle(gd, 'cmin', 0); |
| 38 | + }) |
| 39 | + .then(function() { |
| 40 | + _assert([false, 0, 3], [false, 0, 3]); |
| 41 | + |
| 42 | + return Plotly.restyle(gd, 'cmax', 10); |
| 43 | + }) |
| 44 | + .then(function() { |
| 45 | + _assert([false, 0, 10], [false, 0, 10]); |
| 46 | + |
| 47 | + return Plotly.restyle(gd, 'cauto', true); |
| 48 | + }) |
| 49 | + .then(function() { |
| 50 | + _assert([true, 0, 3], [true, 0, 3]); |
| 51 | + |
| 52 | + return Plotly.purge(gd); |
| 53 | + }) |
| 54 | + .catch(fail) |
| 55 | + .then(done); |
| 56 | + }); |
| 57 | +}); |
0 commit comments