Fix two inconsistencies in dygraph-externs.js (#859)
[dygraphs.git] / auto_tests / tests / data_api.js
index 4b0ebe0..6319909 100644 (file)
@@ -3,12 +3,15 @@
  *
  * @author danvdk@gmail.com (Dan Vanderkam)
  */
+import Dygraph from '../../src/dygraph';
+import * as utils from '../../src/dygraph-utils';
 describe("data-api", function() {
 
+cleanupAfterEach();
+
 var opts, graphDiv;
 
 beforeEach(function() {
-  document.body.innerHTML = "<div id='graph'></div>";
   opts = {
     width: 480,
     height: 320
@@ -17,9 +20,6 @@ beforeEach(function() {
   graphDiv = document.getElementById("graph");
 });
 
-afterEach(function() {
-});
-
 it('testBasicAccessors', function() {
   var g = new Dygraph(graphDiv, temperature_data, opts);
 
@@ -100,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"));
+});
+
 });