X-Git-Url: https://adrianiainlam.tk/git/?a=blobdiff_plain;f=auto_tests%2Ftests%2Fresize.js;fp=auto_tests%2Ftests%2Fresize.js;h=9a8cffe650070456d9ec0132e4f061f12f7c4e2f;hb=3123ca57f71d145bb5bcc4a2f754d3dff3225346;hp=3ce99ad58136393a40a44961c33ce58bb022e481;hpb=26ee953643ccd2d32e38e6b60b20e6a01c1dc9ba;p=dygraphs.git diff --git a/auto_tests/tests/resize.js b/auto_tests/tests/resize.js index 3ce99ad..9a8cffe 100644 --- a/auto_tests/tests/resize.js +++ b/auto_tests/tests/resize.js @@ -3,9 +3,9 @@ * * @author konigsberg@google.com (Robert Konigsberg) */ -var ResizeTestCase = TestCase("resize"); +describe("resize", function() { -ResizeTestCase.data = +var data = "X,Y\n" + "1,100\n" + "2,200\n" + @@ -14,14 +14,14 @@ ResizeTestCase.data = "5,300\n" + "6,100\n"; -ResizeTestCase.prototype.setUp = function() { +beforeEach(function() { document.body.innerHTML = "
"; -}; +}); -ResizeTestCase.prototype.tearDown = function() { -}; +afterEach(function() { +}); -ResizeTestCase.prototype.testResizeMaintainsMouseOperations = function() { +it('testResizeMaintainsMouseOperations', function() { document.body.innerHTML = '
' + ''; @@ -41,34 +41,34 @@ ResizeTestCase.prototype.testResizeMaintainsMouseOperations = function() { DygraphOps.dispatchMouseUp_Point(g, x2 - 1, y); } - g = new Dygraph(graph, ResizeTestCase.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"; 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'; - var g = new Dygraph(div, ResizeTestCase.data, {width: 400, height: 300}); + var g = new Dygraph(div, data, {width: 400, height: 300}); 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 +76,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'; @@ -85,18 +85,20 @@ ResizeTestCase.prototype.testHiddenDivWithResize = function() { // Setting strokeWidth 3 removes any ambiguitiy from the pixel sampling // request, below. - var g = new Dygraph(div, ResizeTestCase.data, {strokeWidth: 3}); + var g = new Dygraph(div, data, {strokeWidth: 3}); 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); +}); + +});