Skip to content

Commit d38a61b

Browse files
committed
Added Plots.purge test
1 parent 42c96ef commit d38a61b

File tree

1 file changed

+48
-0
lines changed

1 file changed

+48
-0
lines changed

test/jasmine/tests/plots_test.js

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
var Plotly = require('@src/plotly');
2+
var createGraphDiv = require('../assets/create_graph_div');
3+
var destroyGraphDiv = require('../assets/destroy_graph_div');
24

35
describe('Test Plotly.Plots', function () {
46
'use strict';
@@ -298,4 +300,50 @@ describe('Test Plotly.Plots', function () {
298300
});
299301

300302
});
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+
});
301349
});

0 commit comments

Comments
 (0)