Commit | Line | Data |
---|---|---|
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 | */ | |
89fdcedb | 8 | describe("no-hours", function() { |
3f675fe5 | 9 | |
89fdcedb | 10 | beforeEach(function() { |
3f675fe5 | 11 | document.body.innerHTML = "<div id='graph'></div>"; |
89fdcedb | 12 | }); |
3f675fe5 | 13 | |
89fdcedb DV |
14 | afterEach(function() { |
15 | }); | |
3f675fe5 | 16 | |
89fdcedb | 17 | it('testNoHours', function() { |
3f675fe5 DV |
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); | |
89fdcedb | 33 | assert.equal("2012/03/13: Y: -1", Util.getLegend()); |
3f675fe5 DV |
34 | |
35 | g.setSelection(1); | |
89fdcedb | 36 | assert.equal("2012/03/14: Y: 0", Util.getLegend()); |
3f675fe5 DV |
37 | |
38 | g.setSelection(2); | |
89fdcedb | 39 | assert.equal("2012/03/15: Y: 1", Util.getLegend()); |
3f675fe5 DV |
40 | |
41 | g.setSelection(3); | |
89fdcedb DV |
42 | assert.equal("2012/03/16: Y: 0", Util.getLegend()); |
43 | }); | |
3f675fe5 | 44 | |
89fdcedb | 45 | it('testNoHoursDashed', function() { |
3f675fe5 DV |
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); | |
89fdcedb | 61 | assert.equal("2012/03/13: Y: -1", Util.getLegend()); |
3f675fe5 DV |
62 | |
63 | g.setSelection(1); | |
89fdcedb | 64 | assert.equal("2012/03/14: Y: 0", Util.getLegend()); |
3f675fe5 DV |
65 | |
66 | g.setSelection(2); | |
89fdcedb | 67 | assert.equal("2012/03/15: Y: 1", Util.getLegend()); |
3f675fe5 DV |
68 | |
69 | g.setSelection(3); | |
89fdcedb DV |
70 | assert.equal("2012/03/16: Y: 0", Util.getLegend()); |
71 | }); | |
3f675fe5 | 72 | |
89fdcedb DV |
73 | |
74 | }); |