X-Git-Url: https://adrianiainlam.tk/git/?a=blobdiff_plain;f=auto_tests%2Ftests%2Fpathological_cases.js;h=40e877f01bfa4c5c949a1977cf2bc2a92a2558dd;hb=7bf909a7b076b5296734a6222e62ed1084e9c935;hp=502c8fdb62c4c499928a7909e7551f4636879e89;hpb=fa460473ef9397759466361ff32de56a4f8fa956;p=dygraphs.git diff --git a/auto_tests/tests/pathological_cases.js b/auto_tests/tests/pathological_cases.js index 502c8fd..40e877f 100644 --- a/auto_tests/tests/pathological_cases.js +++ b/auto_tests/tests/pathological_cases.js @@ -4,16 +4,16 @@ * * @author dan@dygraphs.com (Dan Vanderkam) */ -var pathologicalCasesTestCase = TestCase("pathological-cases"); +describe("pathological-cases", function() { -pathologicalCasesTestCase.prototype.setUp = function() { +beforeEach(function() { document.body.innerHTML = "
"; -}; +}); -pathologicalCasesTestCase.prototype.tearDown = function() { -}; +afterEach(function() { +}); -pathologicalCasesTestCase.prototype.testZeroPoint = function() { +it('testZeroPoint', function() { var opts = { width: 480, height: 320 @@ -22,9 +22,9 @@ pathologicalCasesTestCase.prototype.testZeroPoint = function() { var graph = document.getElementById("graph"); var g = new Dygraph(graph, data, opts); -}; +}); -pathologicalCasesTestCase.prototype.testOnePoint = function() { +it('testOnePoint', function() { var opts = { width: 480, height: 320 @@ -34,9 +34,9 @@ pathologicalCasesTestCase.prototype.testOnePoint = function() { var graph = document.getElementById("graph"); var g = new Dygraph(graph, data, opts); -}; +}); -pathologicalCasesTestCase.prototype.testCombinations = function() { +it('testCombinations', function() { var dataSets = { empty: [], onePoint: [[10, 2]], @@ -68,8 +68,8 @@ pathologicalCasesTestCase.prototype.testCombinations = function() { padded: { includeZero: true, drawAxesAtZero: true, - xRangePad: 0.02, - yRangePad: 0.04 + xRangePad: 2, + yRangePad: 4 } }; @@ -114,9 +114,9 @@ pathologicalCasesTestCase.prototype.testCombinations = function() { } } } -}; +}); -pathologicalCasesTestCase.prototype.testNullLegend = function() { +it('testNullLegend', function() { var opts = { width: 480, height: 320, @@ -127,11 +127,51 @@ pathologicalCasesTestCase.prototype.testNullLegend = function() { var graph = document.getElementById("graph"); var g = new Dygraph(graph, data, opts); -}; +}); -pathologicalCasesTestCase.prototype.testDivAsString = function() { +it('testDivAsString', function() { var data = "X,Y\n" + "1,2\n"; var g = new Dygraph('graph', data, {}); -} +}); + + +it('testConstantSeriesNegative', function() { + var data = "X,Y\n" + + "1,-1\n" + + "2,-1\n"; + + var g = new Dygraph('graph', data, {}); + // This check could be loosened to + // g.yAxisRange()[0] < g.yAxisRange()[1] if it breaks in the future. + assert.deepEqual([-1.1, -0.9], g.yAxisRange()); +}); + + +it('testConstantSeriesNegativeIncludeZero', function() { + var data = "X,Y\n" + + "1,-1\n" + + "2,-1\n"; + + var g = new Dygraph('graph', data, {includeZero: true}); + // This check could be loosened to + // g.yAxisRange()[0] < g.yAxisRange()[1] if it breaks in the future. + assert.deepEqual([-1.1, 0], g.yAxisRange()); +}); + +it('should throw with non-existent divs', function() { + var data = "X,Y\n" + + "1,-1\n" + + "2,1\n"; + + assert.throws(function() { + new Dygraph(null, data); + }, /non-existent div/); + + assert.throws(function() { + new Dygraph('non-existent-div-id', data); + }, /non-existent div/); +}); + +});