test tweaks to facilitate conversion
[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
3f675fe5
DV
17noHoursTestCase.prototype.testNoHours = function() {
18 var opts = {
19 width: 480,
20 height: 320
21 };
22 var data = "Date,Y\n" +
23 "2012/03/13,-1\n" +
24 "2012/03/14,0\n" +
25 "2012/03/15,1\n" +
26 "2012/03/16,0\n"
27 ;
28
29 var graph = document.getElementById("graph");
30 var g = new Dygraph(graph, data, opts);
31
32 g.setSelection(0);
79aabc9d 33 assertEquals("2012/03/13: Y: -1", Util.getLegend());
3f675fe5
DV
34
35 g.setSelection(1);
79aabc9d 36 assertEquals("2012/03/14: Y: 0", Util.getLegend());
3f675fe5
DV
37
38 g.setSelection(2);
79aabc9d 39 assertEquals("2012/03/15: Y: 1", Util.getLegend());
3f675fe5
DV
40
41 g.setSelection(3);
79aabc9d 42 assertEquals("2012/03/16: Y: 0", Util.getLegend());
3f675fe5
DV
43};
44
45noHoursTestCase.prototype.testNoHoursDashed = function() {
46 var opts = {
47 width: 480,
48 height: 320
49 };
50 var data = "Date,Y\n" +
51 "2012-03-13,-1\n" +
52 "2012-03-14,0\n" +
53 "2012-03-15,1\n" +
54 "2012-03-16,0\n"
55 ;
56
57 var graph = document.getElementById("graph");
58 var g = new Dygraph(graph, data, opts);
59
60 g.setSelection(0);
79aabc9d 61 assertEquals("2012/03/13: Y: -1", Util.getLegend());
3f675fe5
DV
62
63 g.setSelection(1);
79aabc9d 64 assertEquals("2012/03/14: Y: 0", Util.getLegend());
3f675fe5
DV
65
66 g.setSelection(2);
79aabc9d 67 assertEquals("2012/03/15: Y: 1", Util.getLegend());
3f675fe5
DV
68
69 g.setSelection(3);
79aabc9d 70 assertEquals("2012/03/16: Y: 0", Util.getLegend());
3f675fe5
DV
71};
72