|
1 | 1 | var Plotly = require('@src/plotly');
|
| 2 | +var createGraphDiv = require('../assets/create_graph_div'); |
| 3 | +var destroyGraphDiv = require('../assets/destroy_graph_div'); |
2 | 4 |
|
3 | 5 | describe('Test Plotly.Plots', function () {
|
4 | 6 | 'use strict';
|
@@ -298,4 +300,50 @@ describe('Test Plotly.Plots', function () {
|
298 | 300 | });
|
299 | 301 |
|
300 | 302 | });
|
| 303 | + |
| 304 | + describe('Plotly.Plots.purge', function () { |
| 305 | + var gd; |
| 306 | + |
| 307 | + beforeEach(function (done) { |
| 308 | + gd = createGraphDiv(); |
| 309 | + Plotly.plot(gd, [{ x: [1,2,3], y: [2,3,4] }], {}).then(done); |
| 310 | + }); |
| 311 | + |
| 312 | + afterEach(destroyGraphDiv); |
| 313 | + |
| 314 | + it('should unset everything in the gd except _context', function () { |
| 315 | + var expectedKeys = [ |
| 316 | + '_ev', 'on', 'once', 'removeListener', 'removeAllListeners', |
| 317 | + 'emit', '_context', '_replotPending', '_mouseDownTime', |
| 318 | + '_hmpixcount', '_hmlumcount' |
| 319 | + ]; |
| 320 | + |
| 321 | + Plotly.Plots.purge(gd); |
| 322 | + expect(Object.keys(gd)).toEqual(expectedKeys); |
| 323 | + expect(gd.data).toBeUndefined(); |
| 324 | + expect(gd.layout).toBeUndefined(); |
| 325 | + expect(gd._fullData).toBeUndefined(); |
| 326 | + expect(gd._fullLayout).toBeUndefined(); |
| 327 | + expect(gd.calcdata).toBeUndefined(); |
| 328 | + expect(gd.framework).toBeUndefined(); |
| 329 | + expect(gd.empty).toBeUndefined(); |
| 330 | + expect(gd.fid).toBeUndefined(); |
| 331 | + expect(gd.undoqueue).toBeUndefined(); |
| 332 | + expect(gd.undonum).toBeUndefined(); |
| 333 | + expect(gd.autoplay).toBeUndefined(); |
| 334 | + expect(gd.changed).toBeUndefined(); |
| 335 | + expect(gd._modules).toBeUndefined(); |
| 336 | + expect(gd._tester).toBeUndefined(); |
| 337 | + expect(gd._testref).toBeUndefined(); |
| 338 | + expect(gd._promises).toBeUndefined(); |
| 339 | + expect(gd._redrawTimer).toBeUndefined(); |
| 340 | + expect(gd._replotting).toBeUndefined(); |
| 341 | + expect(gd.firstscatter).toBeUndefined(); |
| 342 | + expect(gd.hmlumcount).toBeUndefined(); |
| 343 | + expect(gd.hmpixcount).toBeUndefined(); |
| 344 | + expect(gd.numboxes).toBeUndefined(); |
| 345 | + expect(gd._hoverTimer).toBeUndefined(); |
| 346 | + expect(gd._lastHoverTime).toBeUndefined(); |
| 347 | + }); |
| 348 | + }); |
301 | 349 | });
|
0 commit comments