bcfc1feb956834f1f87ca50fa57241dbcf164a1f
[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
9 import Dygraph from '../../src/dygraph';
10 import Util from './Util';
11
12 describe("no-hours", function() {
13
14 cleanupAfterEach();
15
16 it('testNoHours', function() {
17 var opts = {
18 width: 480,
19 height: 320
20 };
21 var data = "Date,Y\n" +
22 "2012/03/13,-1\n" +
23 "2012/03/14,0\n" +
24 "2012/03/15,1\n" +
25 "2012/03/16,0\n"
26 ;
27
28 var graph = document.getElementById("graph");
29 var g = new Dygraph(graph, data, opts);
30
31 g.setSelection(0);
32 assert.equal("2012/03/13: Y: -1", Util.getLegend());
33
34 g.setSelection(1);
35 assert.equal("2012/03/14: Y: 0", Util.getLegend());
36
37 g.setSelection(2);
38 assert.equal("2012/03/15: Y: 1", Util.getLegend());
39
40 g.setSelection(3);
41 assert.equal("2012/03/16: Y: 0", Util.getLegend());
42 });
43
44 it('testNoHoursDashed', function() {
45 var opts = {
46 width: 480,
47 height: 320
48 };
49 var data = "Date,Y\n" +
50 "2012-03-13,-1\n" +
51 "2012-03-14,0\n" +
52 "2012-03-15,1\n" +
53 "2012-03-16,0\n"
54 ;
55
56 var graph = document.getElementById("graph");
57 var g = new Dygraph(graph, data, opts);
58
59 g.setSelection(0);
60 assert.equal("2012/03/13: Y: -1", Util.getLegend());
61
62 g.setSelection(1);
63 assert.equal("2012/03/14: Y: 0", Util.getLegend());
64
65 g.setSelection(2);
66 assert.equal("2012/03/15: Y: 1", Util.getLegend());
67
68 g.setSelection(3);
69 assert.equal("2012/03/16: Y: 0", Util.getLegend());
70 });
71
72
73 });