From: Dan Vanderkam Date: Mon, 22 Jul 2013 20:31:34 +0000 (-0400) Subject: remove private method from test X-Git-Url: https://adrianiainlam.tk/git/?a=commitdiff_plain;h=114cd089787dc0b9e5a9d1f52b03250f71ea225c;p=dygraphs.git remove private method from test --- diff --git a/auto_tests/tests/Util.js b/auto_tests/tests/Util.js index 2d652ed..69889c3 100644 --- a/auto_tests/tests/Util.js +++ b/auto_tests/tests/Util.js @@ -95,3 +95,22 @@ Util.samplePixel = function(canvas, x, y) { var d = imageData.data; return [d[i], d[i+1], d[i+2], d[i+3]]; }; + +/** + * Format a date as 2000/01/23 + * @param {number} date_ms Millis since epoch. + * @return {string} The date formatted as YYYY-MM-DD. + */ +Util.formatDate = function(date_ms) { + var zeropad = function(x) { if (x < 10) return "0" + x; else return "" + x; }; + var d = new Date(date_ms); + + // Get the year: + var year = "" + d.getFullYear(); + // Get a 0 padded month string + var month = zeropad(d.getMonth() + 1); //months are 0-offset, sigh + // Get a 0 padded day string + var day = zeropad(d.getDate()); + + return year + "/" + month + "/" + day; +}; diff --git a/auto_tests/tests/axis_labels-deprecated.js b/auto_tests/tests/axis_labels-deprecated.js index d2d1412..43253dc 100644 --- a/auto_tests/tests/axis_labels-deprecated.js +++ b/auto_tests/tests/axis_labels-deprecated.js @@ -85,7 +85,7 @@ DeprecatedAxisLabelsTestCase.prototype.testDeprecatedDateAxisLabelFormatter = fu assertEquals('number', typeof(granularity)); assertEquals('function', typeof(opts)); assertEquals('[Dygraph graph]', dg.toString()); - return 'x' + Dygraph.dateString_(x); + return 'x' + Util.formatDate(x); }, yAxisLabelFormatter: function(y, granularity, opts, dg) { assertEquals('number', typeof(y)); @@ -159,7 +159,7 @@ DeprecatedAxisLabelsTestCase.prototype.testDeprecatedDateValueFormatter = functi assertEquals('function', typeof(opts)); assertEquals('string', typeof(series_name)); assertEquals('[Dygraph graph]', dg.toString()); - return 'x' + Dygraph.dateString_(new Date(x)); + return 'x' + Util.formatDate(x); }, yValueFormatter: function(y, opts, series_name, dg) { assertEquals('number', typeof(y)); diff --git a/auto_tests/tests/axis_labels.js b/auto_tests/tests/axis_labels.js index ae26439..c3a87e7 100644 --- a/auto_tests/tests/axis_labels.js +++ b/auto_tests/tests/axis_labels.js @@ -206,7 +206,7 @@ AxisLabelsTestCase.prototype.testDateAxisLabelFormatter = function () { assertEquals('number', typeof(granularity)); assertEquals('function', typeof(opts)); assertEquals('[Dygraph graph]', dg.toString()); - return 'x' + Dygraph.dateString_(x); + return 'x' + Util.formatDate(x); } }, y : { @@ -292,7 +292,7 @@ AxisLabelsTestCase.prototype.testDateValueFormatter = function () { assertEquals('function', typeof(opts)); assertEquals('string', typeof(series_name)); assertEquals('[Dygraph graph]', dg.toString()); - return 'x' + Dygraph.dateString_(new Date(x)); + return 'x' + Util.formatDate(x); } }, y : {