Remove dead code (#818)
[dygraphs.git] / auto_tests / tests / scrolling_div.js
index 763504c..c9dec0c 100644 (file)
@@ -3,11 +3,15 @@
  *
  * @author konigsberg@google.com (Robert Konigsbrg)
  */
-var ScrollingDivTestCase = TestCase("scrolling-div");
+
+import Dygraph from '../../src/dygraph';
+import DygraphOps from './DygraphOps';
+
+describe("scrolling-div", function() {
 
 var point, g; 
 
-ScrollingDivTestCase.prototype.setUp = function() {
+beforeEach(function() {
 
 var LOREM_IPSUM =
     "<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod\n" +
@@ -18,13 +22,19 @@ var LOREM_IPSUM =
     "non proident, sunt in culpa qui officia deserunt mollit anim id est\n" +
     "laborum.</p>";
 
-  document.body.innerHTML = 
+  var testDiv = document.getElementById('graph');
+  testDiv.innerHTML =
       "<div id='scroller' style='overflow: scroll; height: 450px; width: 800px;'>" +
-      "<div id='graph'></div>" +
+      "<div id='graph-inner'></div>" +
       "<div style='height:100px; background-color:green;'>" + LOREM_IPSUM + " </div>" +
       "<div style='height:100px; background-color:red;'>" + LOREM_IPSUM + "</div>" +
       "</div>";
 
+  // The old test runner had an 8px margin on the body
+  // The Mocha test runner does not. We set it on the test div to keep the
+  // coordinates the same.
+  testDiv.style.margin = '8px';
+
   var data = [
       [ 10, 1 ],
       [ 20, 3 ],
@@ -35,7 +45,7 @@ var LOREM_IPSUM =
       [ 70, 4 ],
       [ 80, 6 ] ];
 
-  var graph = document.getElementById("graph");
+  var graph = document.getElementById("graph-inner");
 
   point = null;
   g = new Dygraph(graph, data,
@@ -43,13 +53,13 @@ var LOREM_IPSUM =
             labels : ['a', 'b'],
             drawPoints : true,
             highlightCircleSize : 6,
-            pointClickCallback : function(evt, point) {
-              point = point;
+            pointClickCallback : function(evt, p) {
+              point = p;
             }
           }
       );
   
-};
+});
 
 // This is usually something like 15, but for OS X Lion and its auto-hiding
 // scrollbars, it's 0. This is a large enough difference that we need to
@@ -74,13 +84,10 @@ var detectScrollbarWidth = function() {
   return scrollbarWidth;
 };
 
-ScrollingDivTestCase.prototype.tearDown = function() {
-};
-
 /**
  * This tests that when the nested div is unscrolled, things work normally.
  */
-ScrollingDivTestCase.prototype.testUnscrolledDiv = function() {
+it('testUnscrolledDiv', function() {
 
   document.getElementById('scroller').scrollTop = 0;
 
@@ -95,14 +102,14 @@ ScrollingDivTestCase.prototype.testUnscrolledDiv = function() {
   DygraphOps.dispatchCanvasEvent(g, DygraphOps.createEvent(clickOn4_40, { type : 'mousedown' }));
   DygraphOps.dispatchCanvasEvent(g, DygraphOps.createEvent(clickOn4_40, { type : 'mouseup' }));
 
-  assertEquals(40, point.xval);
-  assertEquals(4, point.yval);
-};
+  assert.equal(40, point.xval);
+  assert.equal(4, point.yval);
+});
 
 /**
  * This tests that when the nested div is scrolled, things work normally.
  */
-ScrollingDivTestCase.prototype.testScrolledDiv = function() {
+it('testScrolledDiv', function() {
   document.getElementById('scroller').scrollTop = 117;
 
   var clickOn4_40 = {
@@ -116,6 +123,8 @@ ScrollingDivTestCase.prototype.testScrolledDiv = function() {
   DygraphOps.dispatchCanvasEvent(g, DygraphOps.createEvent(clickOn4_40, { type : 'mousedown' }));
   DygraphOps.dispatchCanvasEvent(g, DygraphOps.createEvent(clickOn4_40, { type : 'mouseup' }));
 
-  assertEquals(40, point.xval);
-  assertEquals(4, point.yval);
-};
+  assert.equal(40, point.xval);
+  assert.equal(4, point.yval);
+});
+
+});