Merge pull request #204 from sauter-hq/55eb8485b406174f15dcee0e97abc4c466de7733
[dygraphs.git] / auto_tests / tests / no_hours.js
CommitLineData
3f675fe5
DV
1/**
2 * @fileoverview Tests that we don'show specify hours, minutes or seconds
3 * in your dates if you don't specify them. This can get mixed up becaues of
4 * time zones.
5 *
6 * @author danvk@google.com (Dan Vanderkam)
7 */
8var noHoursTestCase = TestCase("no-hours");
9
10noHoursTestCase.prototype.setUp = function() {
11 document.body.innerHTML = "<div id='graph'></div>";
12};
13
14noHoursTestCase.prototype.tearDown = function() {
15};
16
17function getLegend() {
18 var legend = document.getElementsByClassName("dygraph-legend")[0];
19 return legend.textContent;
20}
21
22noHoursTestCase.prototype.testNoHours = function() {
23 var opts = {
24 width: 480,
25 height: 320
26 };
27 var data = "Date,Y\n" +
28 "2012/03/13,-1\n" +
29 "2012/03/14,0\n" +
30 "2012/03/15,1\n" +
31 "2012/03/16,0\n"
32 ;
33
34 var graph = document.getElementById("graph");
35 var g = new Dygraph(graph, data, opts);
36
37 g.setSelection(0);
38 assertEquals("2012/03/13: Y:-1", getLegend());
39
40 g.setSelection(1);
41 assertEquals("2012/03/14: Y:0", getLegend());
42
43 g.setSelection(2);
44 assertEquals("2012/03/15: Y:1", getLegend());
45
46 g.setSelection(3);
47 assertEquals("2012/03/16: Y:0", getLegend());
48};
49
50noHoursTestCase.prototype.testNoHoursDashed = function() {
51 var opts = {
52 width: 480,
53 height: 320
54 };
55 var data = "Date,Y\n" +
56 "2012-03-13,-1\n" +
57 "2012-03-14,0\n" +
58 "2012-03-15,1\n" +
59 "2012-03-16,0\n"
60 ;
61
62 var graph = document.getElementById("graph");
63 var g = new Dygraph(graph, data, opts);
64
65 g.setSelection(0);
66 assertEquals("2012/03/13: Y:-1", getLegend());
67
68 g.setSelection(1);
69 assertEquals("2012/03/14: Y:0", getLegend());
70
71 g.setSelection(2);
72 assertEquals("2012/03/15: Y:1", getLegend());
73
74 g.setSelection(3);
75 assertEquals("2012/03/16: Y:0", getLegend());
76};
77