X-Git-Url: https://adrianiainlam.tk/git/?a=blobdiff_plain;f=auto_tests%2Ftests%2Fdygraph-options-tests.js;fp=auto_tests%2Ftests%2Fdygraph-options-tests.js;h=4311fb5fa32e3e78d1ba94f79fd733b43af22253;hb=89fdcedbda6906d90e15d84285c4f6c0b8d96d28;hp=7222a217a9aed1fbee2bd8098fe58a95ec61a4dd;hpb=319d0361d2e512ed8049dfedffd79254e491201c;p=dygraphs.git diff --git a/auto_tests/tests/dygraph-options-tests.js b/auto_tests/tests/dygraph-options-tests.js index 7222a21..4311fb5 100644 --- a/auto_tests/tests/dygraph-options-tests.js +++ b/auto_tests/tests/dygraph-options-tests.js @@ -1,19 +1,22 @@ /** * @fileoverview Test cases for DygraphOptions. */ -var DygraphOptionsTestCase = TestCase("dygraph-options-tests"); +describe("dygraph-options-tests", function() { -DygraphOptionsTestCase.prototype.setUp = function() { +var graph; + +beforeEach(function() { document.body.innerHTML = "
"; -}; + graph = document.getElementById("graph"); +}); -DygraphOptionsTestCase.prototype.tearDown = function() { -}; +afterEach(function() { +}); /* * Pathalogical test to ensure getSeriesNames works */ -DygraphOptionsTestCase.prototype.testGetSeriesNames = function() { +it('testGetSeriesNames', function() { var opts = { width: 480, height: 320 @@ -22,20 +25,19 @@ DygraphOptionsTestCase.prototype.testGetSeriesNames = function() { "0,-1,0,0"; // Kind of annoying that you need a DOM to test the object. - var graph = document.getElementById("graph"); var g = new Dygraph(graph, data, opts); // We don't need to get at g's attributes_ object just // to test DygraphOptions. var o = new DygraphOptions(g); - assertEquals(["Y", "Y2", "Y3"], o.seriesNames()); -}; + assert.deepEqual(["Y", "Y2", "Y3"], o.seriesNames()); +}); /* * Ensures that even if logscale is set globally, it doesn't impact the * x axis. */ -DygraphOptionsTestCase.prototype.testGetLogscaleForX = function() { +it('testGetLogscaleForX', function() { var opts = { width: 480, height: 320 @@ -44,16 +46,15 @@ DygraphOptionsTestCase.prototype.testGetLogscaleForX = function() { "1,-1,2,3"; // Kind of annoying that you need a DOM to test the object. - var graph = document.getElementById("graph"); var g = new Dygraph(graph, data, opts); - assertFalse(!!g.getOptionForAxis('logscale', 'x')); - assertFalse(!!g.getOptionForAxis('logscale', 'y')); + assert.isFalse(!!g.getOptionForAxis('logscale', 'x')); + assert.isFalse(!!g.getOptionForAxis('logscale', 'y')); g.updateOptions({ logscale : true }); - assertFalse(!!g.getOptionForAxis('logscale', 'x')); - assertTrue(!!g.getOptionForAxis('logscale', 'y')); -}; + assert.isFalse(!!g.getOptionForAxis('logscale', 'x')); + assert.isTrue(!!g.getOptionForAxis('logscale', 'y')); +}); // Helper to gather all warnings emitted by Dygraph constructor. // Removes everything after the first open parenthesis in each warning. @@ -72,24 +73,23 @@ var getWarnings = function(div, data, opts) { return warnings; }; -DygraphOptionsTestCase.prototype.testLogWarningForNonexistentOption = function() { +it('testLogWarningForNonexistentOption', function() { if (typeof(Dygraph.OPTIONS_REFERENCE) === 'undefined') { return; // this test won't pass in non-debug mode. } - var graph = document.getElementById("graph"); var data = "X,Y,Y2,Y3\n" + "1,-1,2,3"; var expectWarning = function(opts, badOptionName) { DygraphOptions.resetWarnings_(); var warnings = getWarnings(graph, data, opts); - assertEquals(['Unknown option ' + badOptionName], warnings); + assert.deepEqual(['Unknown option ' + badOptionName], warnings); }; var expectNoWarning = function(opts) { DygraphOptions.resetWarnings_(); var warnings = getWarnings(graph, data, opts); - assertEquals([], warnings); + assert.deepEqual([], warnings); }; expectNoWarning({}); @@ -100,19 +100,20 @@ DygraphOptionsTestCase.prototype.testLogWarningForNonexistentOption = function() expectWarning({highlightSeriesOpts: {anotherNonExistentOption: true}}, 'anotherNonExistentOption'); expectNoWarning({highlightSeriesOpts: {strokeWidth: 20}}); expectNoWarning({strokeWidth: 20}); -}; +}); -DygraphOptionsTestCase.prototype.testOnlyLogsEachWarningOnce = function() { +it('testOnlyLogsEachWarningOnce', function() { if (typeof(Dygraph.OPTIONS_REFERENCE) === 'undefined') { return; // this test won't pass in non-debug mode. } - var graph = document.getElementById("graph"); var data = "X,Y,Y2,Y3\n" + "1,-1,2,3"; var warnings1 = getWarnings(graph, data, {nonExistent: true}); var warnings2 = getWarnings(graph, data, {nonExistent: true}); - assertEquals(['Unknown option nonExistent'], warnings1); - assertEquals([], warnings2); -}; + assert.deepEqual(['Unknown option nonExistent'], warnings1); + assert.deepEqual([], warnings2); +}); + +});