- graph.updateOptions({ colors: null, file: this.data });
- assertEquals(defaultColors, graph.getColors());
-}
+ graph.updateOptions({ colors: null, file: data });
+ assert.deepEqual(defaultColors, graph.getColors());
+});
+
+// Regression test for http://code.google.com/p/dygraphs/issues/detail?id=249
+// Verifies that setting 'legend: always' via update immediately shows the
+// legend.
+it('testUpdateLegendAlways', function() {
+ var graphDiv = document.getElementById("graph");
+ var graph = new Dygraph(graphDiv, data, opts);
+
+ var legend = document.getElementsByClassName("dygraph-legend");
+ assert.equal(1, legend.length);
+ legend = legend[0];
+ assert.equal("", legend.innerHTML);
+
+ graph.updateOptions({legend: 'always'});
+
+ legend = document.getElementsByClassName("dygraph-legend");
+ assert.equal(1, legend.length);
+ legend = legend[0];
+ assert.notEqual(-1, legend.textContent.indexOf("Y1"));
+ assert.notEqual(-1, legend.textContent.indexOf("Y2"));
+});
+
+});