2 * @fileoverview Tests relating to annotations
4 * @author danvk@google.com (Dan Vanderkam)
6 var annotationsTestCase
= TestCase("annotations");
8 annotationsTestCase
.prototype.setUp
= function() {
9 document
.body
.innerHTML
= "<div id='graph'></div>";
12 annotationsTestCase
.prototype.tearDown
= function() {
15 annotationsTestCase
.prototype.testAnnotationsDrawn
= function() {
27 var graph
= document
.getElementById("graph");
28 var g
= new Dygraph(graph
, data
, opts
);
46 assertEquals(2, g
.annotations().length
);
47 var a1
= document
.getElementsByClassName('ann1');
48 assertEquals(1, a1
.length
);
50 assertEquals('A', a1
.textContent
);
52 var a2
= document
.getElementsByClassName('ann2');
53 assertEquals(1, a2
.length
);
55 assertEquals('B', a2
.textContent
);
58 // Some errors that should be flagged:
59 // 1. Invalid series name (e.g. 'X' or 'non-existent')
60 // 2. Passing a string as 'x' instead of a number (e.g. x: '1')
62 annotationsTestCase
.prototype.testAnnotationsDontDisappearOnResize
= function() {
72 var graph
= document
.getElementById("graph");
73 var g
= new Dygraph(graph
, data
, opts
);
84 // Check that it displays at all
85 assertEquals(1, g
.annotations().length
);
86 var a1
= document
.getElementsByClassName('ann1');
87 assertEquals(1, a1
.length
);
89 assertEquals('A', a1
.textContent
);
91 // ... and that resizing doesn't kill it.
93 assertEquals(1, g
.annotations().length
);
94 var a1
= document
.getElementsByClassName('ann1');
95 assertEquals(1, a1
.length
);
97 assertEquals('A', a1
.textContent
);