X-Git-Url: https://adrianiainlam.tk/git/?a=blobdiff_plain;f=auto_tests%2Ftests%2Fresize.js;h=6230ffb941750cc7da47064b94fde89d6feb8dfc;hb=b6126069a9e468e80a27edf7bdf20ef0ae20b4fb;hp=5a996d2b9d84fa08b481ce706fa20b79c520c5b0;hpb=319d0361d2e512ed8049dfedffd79254e491201c;p=dygraphs.git diff --git a/auto_tests/tests/resize.js b/auto_tests/tests/resize.js index 5a996d2..6230ffb 100644 --- a/auto_tests/tests/resize.js +++ b/auto_tests/tests/resize.js @@ -3,7 +3,15 @@ * * @author konigsberg@google.com (Robert Konigsberg) */ -var ResizeTestCase = TestCase("resize"); + +import Dygraph from '../../src/dygraph'; + +import DygraphOps from './DygraphOps'; +import Util from './Util'; + +describe("resize", function() { + +cleanupAfterEach(); var data = "X,Y\n" + @@ -14,18 +22,9 @@ var data = "5,300\n" + "6,100\n"; -ResizeTestCase.prototype.setUp = function() { - document.body.innerHTML = "
"; -}; - -ResizeTestCase.prototype.tearDown = function() { -}; - -ResizeTestCase.prototype.testResizeMaintainsMouseOperations = function() { - document.body.innerHTML = - '
' + - ''; - var graph = document.getElementById("graph"); +it('testResizeMaintainsMouseOperations', function() { + var graph = document.getElementById('graph'); + graph.setAttribute('style', 'width: 640px; height: 480px;'); var callbackCount = 0; var callback = function() { @@ -41,24 +40,24 @@ ResizeTestCase.prototype.testResizeMaintainsMouseOperations = function() { DygraphOps.dispatchMouseUp_Point(g, x2 - 1, y); } - g = new Dygraph(graph, data, {highlightCallback: callback}); + var g = new Dygraph(graph, data, {highlightCallback: callback}); strum(g, 300, 640); - assertEquals(6, callbackCount); + assert.equal(6, callbackCount); - document.getElementById("graph").style.width = "500px"; + graph.style.width = "500px"; g.resize(); callbackCount = 0; strum(g, 300, 500); - assertEquals(6, callbackCount); -}; + assert.equal(6, callbackCount); +}); /** * Tests that a graph created in a not-displayed div works as expected * if the graph options include height and width. Resize not needed. */ -ResizeTestCase.prototype.testHiddenDivWithSizedGraph = function() { +it('testHiddenDivWithSizedGraph', function() { var div = document.getElementById("graph"); div.style.display = 'none'; @@ -66,9 +65,9 @@ ResizeTestCase.prototype.testHiddenDivWithSizedGraph = function() { div.style.display = ''; var area = g.getArea(); - assertTrue(area.w > 0); - assertTrue(area.h > 0); -}; + assert.isTrue(area.w > 0); + assert.isTrue(area.h > 0); +}); /** * Tests that a graph created in a not-displayed div with @@ -76,7 +75,7 @@ ResizeTestCase.prototype.testHiddenDivWithSizedGraph = function() { * expected. The user needs to call resize() on it after displaying * it. */ -ResizeTestCase.prototype.testHiddenDivWithResize = function() { +it('testHiddenDivWithResize', function() { var div = document.getElementById("graph"); div.style.display = 'none'; @@ -89,14 +88,16 @@ ResizeTestCase.prototype.testHiddenDivWithResize = function() { div.style.display = ''; g.resize(); - area = g.getArea(); - assertTrue(area.w > 0); - assertTrue(area.h > 0); + var area = g.getArea(); + assert.isTrue(area.w > 0); + assert.isTrue(area.h > 0); // Regression test: check that graph remains visible after no-op resize. g.resize(); var x = Math.floor(g.toDomXCoord(2)); var y = Math.floor(g.toDomYCoord(200)); - assertEquals("Unexpected grid color found at pixel: x: " + x + " y: " + y, - [0, 128, 128, 255], Util.samplePixel(g.hidden_, x, y)); -}; + assert.deepEqual([0, 128, 128, 255], Util.samplePixel(g.hidden_, x, y), + "Unexpected grid color found at pixel: x: " + x + " y: " + y); +}); + +});