Bug fix: indexFromSetName on invisible sets (#771)
[dygraphs.git] / auto_tests / tests / data_api.js
index e692fc6..6319909 100644 (file)
@@ -4,6 +4,7 @@
  * @author danvdk@gmail.com (Dan Vanderkam)
  */
 import Dygraph from '../../src/dygraph';
+import * as utils from '../../src/dygraph-utils';
 describe("data-api", function() {
 
 cleanupAfterEach();
@@ -99,4 +100,21 @@ it('testGetRowForXDuplicates', function() {
   assert.equal(5, g.getRowForX(9));
 });
 
+// indexFromSeriesName should return a value even if the series is invisible
+// In 1.1.1, if you request the last set and it's invisible, the method returns undefined.
+it('testIndexFromSetNameOnInvisibleSet', function() {
+  
+  var localOpts = utils.clone(opts);
+  localOpts.visibility = [true, false];
+
+  var g = new Dygraph(graphDiv, [
+    "x,y1,y2",
+    "1,1,1",
+    "2,2,2",
+    "3,3,3"
+  ].join('\n'), localOpts);
+
+  assert.equal(2, g.indexFromSetName("y2"));
+});
+
 });