Regression test for issue #411
[dygraphs.git] / auto_tests / tests / plugins.js
1 /**
2 * @fileoverview Tests for the plugins option.
3 *
4 * @author konigsberg@google.com (Robert Konigsberg)
5 */
6 var pluginsTestCase = TestCase("plugins");
7
8 pluginsTestCase.prototype.setUp = function() {
9 document.body.innerHTML = "<div id='graph'></div>";
10 };
11
12 pluginsTestCase.prototype.tearDown = function() {
13 };
14
15 pluginsTestCase.prototype.testWillDrawChart = function() {
16 var draw = 0;
17
18 var plugin = (function() {
19 var p = function() {
20 };
21
22 p.prototype.activate = function(g) {
23 return {
24 willDrawChart: this.willDrawChart
25 };
26 };
27
28 p.prototype.willDrawChart = function(e) {
29 draw++;
30 };
31
32 return p;
33 })();
34
35 var data = "X,Y1,Y2\n" +
36 "0,1,1\n" +
37 "1,1,1\n" +
38 "2,1,1\n" +
39 "3,1,1\n"
40 ;
41
42 var graph = document.getElementById("graph");
43 var g = new Dygraph(graph, data, { plugins : [ plugin ] });
44
45 assertEquals(1, draw);
46 };