Remove all remaining logging from tests
[dygraphs.git] / auto_tests / tests / selection.js
CommitLineData
87bbdb4d
DV
1// Copyright 2011 Google Inc. All Rights Reserved.
2
3/**
4 * @fileoverview Regression test based on an optimization w/
5 * unforeseen consequences.
6 * @author danvk@google.com (Dan Vanderkam)
7 */
8
89fdcedb 9describe("selection", function() {
87bbdb4d 10
89fdcedb 11beforeEach(function() {
87bbdb4d 12 document.body.innerHTML = "<div id='graph'></div>";
89fdcedb 13});
87bbdb4d 14
89fdcedb 15it('testSetGetSelection', function() {
87bbdb4d
DV
16 var graph = document.getElementById("graph");
17 var g = new Dygraph(graph,
18 "X,Y\n" +
19 "1,1\n" +
20 "50,50\n" +
21 "100,100\n"
22 );
23
24 g.setSelection(0);
89fdcedb 25 assert.equal(0, g.getSelection());
87bbdb4d 26 g.setSelection(1);
89fdcedb 27 assert.equal(1, g.getSelection());
87bbdb4d 28 g.setSelection(2);
89fdcedb
DV
29 assert.equal(2, g.getSelection());
30});
87bbdb4d 31
89fdcedb 32it('testSetGetSelectionDense', function() {
87bbdb4d
DV
33 var graph = document.getElementById("graph");
34 var g = new Dygraph(graph,
35 "X,Y\n" +
36 "1,1\n" +
37 "50,50\n" +
38 "50.0001,50.0001\n" +
39 "100,100\n"
40 );
41
42 g.setSelection(0);
89fdcedb 43 assert.equal(0, g.getSelection());
87bbdb4d 44 g.setSelection(1);
89fdcedb 45 assert.equal(1, g.getSelection());
87bbdb4d 46 g.setSelection(2);
89fdcedb 47 assert.equal(2, g.getSelection());
87bbdb4d 48 g.setSelection(3);
89fdcedb
DV
49 assert.equal(3, g.getSelection());
50});
8b7f7651 51
89fdcedb
DV
52it('testSetGetSelectionMissingPoints', function() {
53 var dataHandler = function() {};
8b7f7651
AV
54 dataHandler.prototype = new Dygraph.DataHandlers.DefaultHandler();
55 dataHandler.prototype.seriesToPoints = function(series, setName, boundaryIdStart) {
56 var val = null;
57 if (setName == 'A') {
58 val = 1;
59 } else if (setName == 'B') {
60 val = 2;
61 } else if (setName == 'C') {
62 val = 3;
63 }
64 return [{
65 x: NaN,
66 y: NaN,
67 xval: val,
68 yval: val,
69 name: setName,
70 idx: val - 1
71 }];
72 };
73 var graph = document.getElementById("graph");
74 var g = new Dygraph(graph,
75 "X,A,B,C\n" +
1b7afc93
DV
76 "1,1,,\n" +
77 "2,,2,\n" +
78 "3,,,3\n",
8b7f7651
AV
79 {
80 dataHandler: dataHandler
81 }
82 );
83
84 g.setSelection(0);
89fdcedb 85 assert.equal(0, g.getSelection());
8b7f7651 86 g.setSelection(1);
89fdcedb 87 assert.equal(1, g.getSelection());
8b7f7651 88 g.setSelection(2);
89fdcedb
DV
89 assert.equal(2, g.getSelection());
90});
91
92});