Smooth plotter using bezier curves.
[dygraphs.git] / auto_tests / tests / no_hours.js
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 */
8 var noHoursTestCase = TestCase("no-hours");
9
10 noHoursTestCase.prototype.setUp = function() {
11 document.body.innerHTML = "<div id='graph'></div>";
12 };
13
14 noHoursTestCase.prototype.tearDown = function() {
15 };
16
17 noHoursTestCase.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);
33 assertEquals("2012/03/13: Y: -1", Util.getLegend());
34
35 g.setSelection(1);
36 assertEquals("2012/03/14: Y: 0", Util.getLegend());
37
38 g.setSelection(2);
39 assertEquals("2012/03/15: Y: 1", Util.getLegend());
40
41 g.setSelection(3);
42 assertEquals("2012/03/16: Y: 0", Util.getLegend());
43 };
44
45 noHoursTestCase.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);
61 assertEquals("2012/03/13: Y: -1", Util.getLegend());
62
63 g.setSelection(1);
64 assertEquals("2012/03/14: Y: 0", Util.getLegend());
65
66 g.setSelection(2);
67 assertEquals("2012/03/15: Y: 1", Util.getLegend());
68
69 g.setSelection(3);
70 assertEquals("2012/03/16: Y: 0", Util.getLegend());
71 };
72