X-Git-Url: https://adrianiainlam.tk/git/?a=blobdiff_plain;f=auto_tests%2Ftests%2Fdate_formats.js;h=5148fe7fb6a84a34a79ec50d174749bf9a177019;hb=2d0fdf6eb18eafde50830b8109f42e20b82247b1;hp=05a62c676d1335d4427f406d3a245512eef2ed9f;hpb=795b16307db2a673ba7aa3452f6f6b0e93baeb3a;p=dygraphs.git diff --git a/auto_tests/tests/date_formats.js b/auto_tests/tests/date_formats.js index 05a62c6..5148fe7 100644 --- a/auto_tests/tests/date_formats.js +++ b/auto_tests/tests/date_formats.js @@ -3,15 +3,12 @@ * * @author dan@dygraphs.com (Dan Vanderkam) */ -var dateFormatsTestCase = TestCase("date-formats"); -dateFormatsTestCase.prototype.setUp = function() { -}; +import * as utils from '../../src/dygraph-utils'; -dateFormatsTestCase.prototype.tearDown = function() { -}; +describe("date-formats", function() { -dateFormatsTestCase.prototype.testISO8601 = function() { +it('testISO8601', function() { // Format: YYYY-MM-DDTHH:MM:SS.ddddddZ // The "Z" indicates UTC, so this test should pass regardless of the time // zone of the machine on which it is run. @@ -19,11 +16,11 @@ dateFormatsTestCase.prototype.testISO8601 = function() { // Firefox <4 does not support this format: // https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Date/parse if (navigator.userAgent.indexOf("Firefox/3.5") == -1) { - assertEquals(946816496789, Dygraph.dateParser("2000-01-02T12:34:56.789012Z")); + assert.equal(946816496789, utils.dateParser("2000-01-02T12:34:56.789012Z")); } -}; +}); -dateFormatsTestCase.prototype.testHyphenatedDate = function() { +it('testHyphenatedDate', function() { // Format: YYYY-MM-DD HH:MM // Midnight February 2, 2000, UTC @@ -36,5 +33,15 @@ dateFormatsTestCase.prototype.testHyphenatedDate = function() { zp(d.getDate()) + ' ' + zp(d.getHours()) + ':' + zp(d.getMinutes()); - assertEquals(Date.UTC(2000, 1, 2), Dygraph.dateParser(str)); -}; + assert.equal(Date.UTC(2000, 1, 2), utils.dateParser(str)); +}); + +it('testMillisecondsDate', function() { + // Format: YYYY-MM-DD HH:MM:SS.MS + + // Midnight February 2, 2000 14:25:42.123 UTC + var ts = Date.UTC(2000, 1, 2, 14, 25, 42, 123); + assert.equal("2000/02/02 14:25:42.123", utils.dateString_(ts, true)); +}); + +});