Delete multiple_axes-old properly. Keep it dead, dead, dead.
[dygraphs.git] / auto_tests / tests / parser.js
... / ...
CommitLineData
1/**
2 * @fileoverview Tests the way that dygraphs parses data.
3 *
4 * @author danvk@google.com (Dan Vanderkam)
5 */
6var parserTestCase = TestCase("parser");
7
8parserTestCase.prototype.setUp = function() {
9 document.body.innerHTML = "<div id='graph'></div>";
10};
11
12parserTestCase.prototype.tearDown = function() {
13};
14
15parserTestCase.prototype.testDetectLineDelimiter = function() {
16 var data = "X,Y\r" +
17 "0,-1\r" +
18 "1,0\r" +
19 "2,1\r" +
20 "3,0\r"
21 ;
22 assertEquals("\r", Dygraph.detectLineDelimiter(data));
23
24 data = "X,Y\n" +
25 "0,-1\n" +
26 "1,0\n" +
27 "2,1\n" +
28 "3,0\n"
29 ;
30 assertEquals("\n", Dygraph.detectLineDelimiter(data));
31
32 data = "X,Y\n\r" +
33 "0,-1\n\r" +
34 "1,0\n\r" +
35 "2,1\n\r" +
36 "3,0\n\r"
37 ;
38 assertEquals("\n\r", Dygraph.detectLineDelimiter(data));
39};
40
41parserTestCase.prototype.testParseDosNewlines = function() {
42 var opts = {
43 width: 480,
44 height: 320
45 };
46 var data = "X,Y\r" +
47 "0,-1\r" +
48 "1,0\r" +
49 "2,1\r" +
50 "3,0\r"
51 ;
52
53 var graph = document.getElementById("graph");
54 var g = new Dygraph(graph, data, opts);
55
56 assertEquals(0, g.getValue(0, 0));
57 assertEquals(-1, g.getValue(0, 1));
58 assertEquals(1, g.getValue(1, 0));
59 assertEquals(0, g.getValue(1, 1));
60 assertEquals(['X', 'Y'], g.getLabels());
61};
62