Merge pull request #674 from danvk/module
[dygraphs.git] / auto_tests / tests / step_plot_per_series.js
index 2364561..805a65a 100644 (file)
@@ -8,33 +8,32 @@
  *
  * @author julian.eichstaedt@ch.sauter-bc.com (Fr. Sauter AG)
  */
-var StepTestCase = TestCase("step-plot-per-series");
 
-StepTestCase.prototype.setUp = function() {
-  document.body.innerHTML = "<div id='graph'></div>";
-};
+import Dygraph from '../../src/dygraph';
+import * as utils from '../../src/dygraph-utils';
 
-StepTestCase.origFunc = Dygraph.getContext;
+import Proxy from './Proxy';
+import CanvasAssertions from './CanvasAssertions';
 
-StepTestCase.prototype.setUp = function() {
-  document.body.innerHTML = "<div id='graph'></div>";
-  Dygraph.getContext = function(canvas) {
-    return new Proxy(StepTestCase.origFunc(canvas));
-  };
-};
+describe("step-plot-per-series", function() {
 
-StepTestCase.prototype.tearDown = function() {
-  Dygraph.getContext = StepTestCase.origFunc;
-};
+cleanupAfterEach();
+useProxyCanvas(utils, Proxy);
 
-StepTestCase.prototype.testMixedModeStepAndLineFilled = function() {
+it('testMixedModeStepAndLineFilled', function() {
   var opts = {
     width: 480,
     height: 320,
-    drawXGrid: false,
-    drawYGrid: false,
-    drawXAxis: false,
-    drawYAxis: false,
+    axes : {
+      x : {
+        drawGrid: false,
+        drawAxis: false,
+      },
+      y : {
+        drawGrid: false,
+        drawAxis: false,
+      }
+    },
     errorBars: false,
     labels: ["X", "Idle", "Used"],
     series: {
@@ -57,7 +56,7 @@ StepTestCase.prototype.testMixedModeStepAndLineFilled = function() {
   var graph = document.getElementById("graph");
   var g = new Dygraph(graph, data, opts);
 
-  htx = g.hidden_ctx_;
+  var htx = g.hidden_ctx_;
 
   var attrs = {};  
 
@@ -88,16 +87,22 @@ StepTestCase.prototype.testMixedModeStepAndLineFilled = function() {
     xy2 = g.toDomCoords(x2, y2);
     CanvasAssertions.assertLineDrawn(htx, xy1, xy2, attrs);
   }
-};
+});
 
-StepTestCase.prototype.testMixedModeStepAndLineStackedAndFilled = function() {
+it('testMixedModeStepAndLineStackedAndFilled', function() {
   var opts = {
     width: 480,
     height: 320,
-    drawXGrid: false,
-    drawYGrid: false,
-    drawXAxis: false,
-    drawYAxis: false,
+    axes : {
+      x : {
+        drawGrid: false,
+        drawAxis: false,
+      },
+      y : {
+        drawGrid: false,
+        drawAxis: false,
+      }
+    },
     errorBars: false,
     labels: ["X", "Idle", "Used", "NotUsed", "Active"],
     series: {
@@ -122,7 +127,7 @@ StepTestCase.prototype.testMixedModeStepAndLineStackedAndFilled = function() {
   var graph = document.getElementById("graph");
   var g = new Dygraph(graph, data, opts);
 
-  htx = g.hidden_ctx_;
+  var htx = g.hidden_ctx_;
 
   var attrs = {};  
 
@@ -237,16 +242,22 @@ StepTestCase.prototype.testMixedModeStepAndLineStackedAndFilled = function() {
     // The last edge can not be tested via assertLineDrawn since it wasn't drawn as a line but via clossePath.
     // But a rectangle is completely tested with three of its four edges.
   }
-};
+});
 
-StepTestCase.prototype.testMixedModeStepAndLineErrorBars = function() {
+it('testMixedModeStepAndLineErrorBars', function() {
   var opts = {
     width: 480,
     height: 320,
-    drawXGrid: false,
-    drawYGrid: false,
-    drawXAxis: false,
-    drawYAxis: false,
+    axes : {
+      x : {
+        drawGrid: false,
+        drawAxis: false,
+      },
+      y : {
+        drawGrid: false,
+        drawAxis: false,
+      }
+    },
     errorBars: true,
     sigma: 1,
     labels: ["X", "Data1", "Data2"],
@@ -266,7 +277,7 @@ StepTestCase.prototype.testMixedModeStepAndLineErrorBars = function() {
   var graph = document.getElementById("graph");
   var g = new Dygraph(graph, data, opts);
 
-  htx = g.hidden_ctx_;
+  var htx = g.hidden_ctx_;
 
   var attrs = {};  
 
@@ -330,16 +341,22 @@ StepTestCase.prototype.testMixedModeStepAndLineErrorBars = function() {
     CanvasAssertions.assertLineDrawn(htx, xy1, xy2, attrs);
   }
 
-};
+});
 
-StepTestCase.prototype.testMixedModeStepAndLineCustomBars = function() {
+it('testMixedModeStepAndLineCustomBars', function() {
   var opts = {
     width: 480,
     height: 320,
-    drawXGrid: false,
-    drawYGrid: false,
-    drawXAxis: false,
-    drawYAxis: false,
+    axes : {
+      x : {
+        drawGrid: false,
+        drawAxis: false,
+      },
+      y : {
+        drawGrid: false,
+        drawAxis: false,
+      }
+    },
     customBars: true,
        labels: ["X", "Data1", "Data2"],
     series: {
@@ -358,7 +375,7 @@ StepTestCase.prototype.testMixedModeStepAndLineCustomBars = function() {
   var graph = document.getElementById("graph");
   var g = new Dygraph(graph, data, opts);
 
-  htx = g.hidden_ctx_;
+  var htx = g.hidden_ctx_;
 
   var attrs = {};  
 
@@ -423,4 +440,6 @@ StepTestCase.prototype.testMixedModeStepAndLineCustomBars = function() {
     xy2 = g.toDomCoords(data[i + 1][0], data[i + 1][2][1]);
     CanvasAssertions.assertLineDrawn(htx, xy1, xy2, attrs);
   }
-};
+});
+
+});