X-Git-Url: https://adrianiainlam.tk/git/?a=blobdiff_plain;ds=sidebyside;f=auto_tests%2Ftests%2Ferror_bars.js;h=2fd5ae4f5984686b2e2f0b78b5b4a29bb1ec1a9f;hb=refs%2Fheads%2F558-fill-artifacts;hp=1c3894cdb1b2370ab996b5233452d8193fca13d2;hpb=023b7bd44183090c18e450fbd717ad933fac2e41;p=dygraphs.git diff --git a/auto_tests/tests/error_bars.js b/auto_tests/tests/error_bars.js index 1c3894c..2fd5ae4 100644 --- a/auto_tests/tests/error_bars.js +++ b/auto_tests/tests/error_bars.js @@ -3,34 +3,41 @@ * * @author danvk@google.com (Dan Vanderkam) */ -var errorBarsTestCase = TestCase("error-bars"); +describe("error-bars", function() { -errorBarsTestCase.prototype.setUp = function() { +beforeEach(function() { document.body.innerHTML = "
"; -}; +}); -errorBarsTestCase._origFunc = Dygraph.getContext; -errorBarsTestCase.prototype.setUp = function() { +var _origFunc = Dygraph.getContext; +beforeEach(function() { document.body.innerHTML = ""; Dygraph.getContext = function(canvas) { - return new Proxy(errorBarsTestCase._origFunc(canvas)); + return new Proxy(_origFunc(canvas)); } -}; +}); -errorBarsTestCase.prototype.tearDown = function() { - Dygraph.getContext = errorBarsTestCase._origFunc; -}; +afterEach(function() { + Dygraph.getContext = _origFunc; +}); -errorBarsTestCase.prototype.testErrorBarsDrawn = function() { +it('testErrorBarsDrawn', function() { var opts = { width: 480, height: 320, - drawXGrid: false, - drawYGrid: false, - drawXAxis: false, - drawYAxis: false, + axes : { + x : { + drawGrid: false, + drawAxis: false, + }, + y : { + drawGrid: false, + drawAxis: false, + } + }, customBars: true, - errorBars: true + errorBars: true, + labels: ['X', 'Y'] }; var data = [ [1, [10, 10, 100]], @@ -47,7 +54,7 @@ errorBarsTestCase.prototype.testErrorBarsDrawn = function() { var graph = document.getElementById("graph"); var g = new Dygraph(graph, data, opts); - htx = g.hidden_ctx_; + var htx = g.hidden_ctx_; var attrs = {}; // TODO(danvk): fill in @@ -88,9 +95,9 @@ errorBarsTestCase.prototype.testErrorBarsDrawn = function() { } g.destroy(); // Restore balanced saves and restores. CanvasAssertions.assertBalancedSaveRestore(htx); -}; +}); -errorBarsTestCase.prototype.testErrorBarsCorrectColors = function() { +it('testErrorBarsCorrectColors', function() { // Two constant series with constant error. var data = [ [0, [100, 50], [200, 50]], @@ -102,10 +109,16 @@ errorBarsTestCase.prototype.testErrorBarsCorrectColors = function() { sigma: 1.0, fillAlpha: 0.15, colors: ['#00ff00', '#0000ff'], - drawXGrid: false, - drawYGrid: false, - drawXAxis: false, - drawYAxis: false, + axes : { + x : { + drawGrid: false, + drawAxis: false, + }, + y : { + drawGrid: false, + drawAxis: false, + } + }, width: 400, height: 300, valueRange: [0, 300], @@ -125,15 +138,15 @@ errorBarsTestCase.prototype.testErrorBarsCorrectColors = function() { // 249-299: empty (white) // TODO(danvk): test the edges of these regions. - assertEquals([0, 0, 255, 38], Util.samplePixel(g.hidden_, 200, 75)); - assertEquals([0, 0, 255, 38], Util.samplePixel(g.hidden_, 200, 125)); - assertEquals([0, 255, 0, 38], Util.samplePixel(g.hidden_, 200, 175)); - assertEquals([0, 255, 0, 38], Util.samplePixel(g.hidden_, 200, 225)); -}; + assert.deepEqual([0, 0, 255, 38], Util.samplePixel(g.hidden_, 200, 75)); + assert.deepEqual([0, 0, 255, 38], Util.samplePixel(g.hidden_, 200, 125)); + assert.deepEqual([0, 255, 0, 38], Util.samplePixel(g.hidden_, 200, 175)); + assert.deepEqual([0, 255, 0, 38], Util.samplePixel(g.hidden_, 200, 225)); +}); // Regression test for http://code.google.com/p/dygraphs/issues/detail?id=392 -errorBarsTestCase.prototype.testRollingAveragePreservesNaNs = function() { +it('testRollingAveragePreservesNaNs', function() { var graph = document.getElementById("graph"); var data = [ @@ -157,18 +170,20 @@ errorBarsTestCase.prototype.testRollingAveragePreservesNaNs = function() { var in_series = g.dataHandler_.extractSeries(data, 1, g.attributes_); - assertEquals(null, in_series[4][1]); - assertEquals(null, in_series[4][2][0]); - assertEquals(null, in_series[4][2][1]); - assertNaN(in_series[5][1]); - assertNaN(in_series[5][2][0]); - assertNaN(in_series[5][2][1]); + assert.equal(null, in_series[4][1]); + assert.equal(null, in_series[4][2][0]); + assert.equal(null, in_series[4][2][1]); + assert(isNaN(in_series[5][1])); + assert(isNaN(in_series[5][2][0])); + assert(isNaN(in_series[5][2][1])); var out_series = g.dataHandler_.rollingAverage(in_series, 1, g.attributes_); - assertNaN(out_series[5][1]); - assertNaN(out_series[5][2][0]); - assertNaN(out_series[5][2][1]); - assertEquals(null, out_series[4][1]); - assertEquals(null, out_series[4][2][0]); - assertEquals(null, out_series[4][2][1]); -}; + assert(isNaN(out_series[5][1])); + assert(isNaN(out_series[5][2][0])); + assert(isNaN(out_series[5][2][1])); + assert.equal(null, out_series[4][1]); + assert.equal(null, out_series[4][2][0]); + assert.equal(null, out_series[4][2][1]); +}); + +});