From: Robert Konigsberg Date: Fri, 23 Nov 2012 20:19:25 +0000 (-0500) Subject: Add sanity test for xValueParser. X-Git-Tag: v1.0.0~168^2 X-Git-Url: https://adrianiainlam.tk/git/?a=commitdiff_plain;h=57154831f03ec3c7d43d398c9c748935122ca344;p=dygraphs.git Add sanity test for xValueParser. --- diff --git a/auto_tests/tests/formats.js b/auto_tests/tests/formats.js index 78e2240..38ba88e 100644 --- a/auto_tests/tests/formats.js +++ b/auto_tests/tests/formats.js @@ -58,6 +58,28 @@ FormatsTestCase.prototype.testFunctionDefinesArray = function() { this.assertData(g); }; +FormatsTestCase.prototype.testXValueParser = function() { + var data = + "X,Y\n" + + "d,-1\n" + + "e,0\n" + + "f,1\n" + + "g,0\n"; + + var graph = document.getElementById("graph"); + var g = new Dygraph(graph, data, { + xValueParser : function(str) { + assertEquals(1, str.length); + return str.charCodeAt(0) - "a".charCodeAt(0); + } + }); + + assertEquals(3, g.getValue(0, 0)); + assertEquals(4, g.getValue(1, 0)); + assertEquals(5, g.getValue(2, 0)); + assertEquals(6, g.getValue(3, 0)); +}; + FormatsTestCase.prototype.assertData = function(g) { var expected = this.dataArray;