Tests for option warnings
[dygraphs.git] / auto_tests / tests / plugins.js
index cff1d92..3605113 100644 (file)
@@ -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);
+};