X-Git-Url: https://adrianiainlam.tk/git/?a=blobdiff_plain;f=auto_tests%2Ftests%2Fplugins.js;h=36051137223a2ac10d545674376469cf354a5381;hb=b3cb0794c0513e0a4c9b31d11fbe8b65778fc02e;hp=cff1d92de82626f2f8b801a7f9f5fbc357031c71;hpb=48238e1d74c1a973c74f80f5f87bd9205fbf252e;p=dygraphs.git diff --git a/auto_tests/tests/plugins.js b/auto_tests/tests/plugins.js index cff1d92..3605113 100644 --- a/auto_tests/tests/plugins.js +++ b/auto_tests/tests/plugins.js @@ -183,9 +183,8 @@ pluginsTestCase.prototype.testEventSequence = function() { events = []; g.updateOptions({series: {Y1: {color: 'blue'}}}); assertEquals([ - "clearChart", "predraw", - "clearChart", // why is clearChart called twice? + "clearChart", "willDrawChart", "didDrawChart" ], events); @@ -207,10 +206,30 @@ pluginsTestCase.prototype.testEventSequence = function() { assertEquals([ "dataWillUpdate", "dataDidUpdate", - "clearChart", "predraw", - "clearChart", // why is clearChart called twice? + "clearChart", "willDrawChart", "didDrawChart" ], events); }; + +pluginsTestCase.prototype.testDestroyCalledInOrder = function() { + var destructions = []; + var makePlugin = function(name) { + return { + activate: function(g) { return {} }, + destroy: function() { + destructions.push(name); + } + }; + }; + + var graph = document.getElementById("graph"); + var g = new Dygraph(graph, this.data, { + plugins: [makePlugin('p'), makePlugin('q')] + }); + + assertEquals([], destructions); + g.destroy(); + assertEquals(['q', 'p'], destructions); +};