Remove all remaining logging from tests
[dygraphs.git] / auto_tests / tests / update_while_panning.js
CommitLineData
97583b90
DV
1/**
2 * @fileoverview Regression test for a bug involving data update while panning.
3 *
4 * See http://stackoverflow.com/questions/9528173
5 *
6 * @author dan@dygraphs.com (Dan Vanderkam)
7 */
89fdcedb 8describe("update-while-panning", function() {
97583b90 9
89fdcedb 10beforeEach(function() {
97583b90 11 document.body.innerHTML = "<div id='graph'></div>";
89fdcedb 12});
97583b90 13
89fdcedb
DV
14afterEach(function() {
15});
97583b90
DV
16
17// This tests the following sequence:
18// 1. Begin dragging a chart (x-panning)
19// 2. Do a data update (updateOptions({file: ...}))
20// 3. Verify that the y-axis is still well-defined.
89fdcedb 21it('testUpdateWhilePanning', function() {
97583b90
DV
22 var sinewave = function(start, limit, step) {
23 var data = [];
24 for (var x = start; x < limit; x += step) {
25 data.push([x, Math.sin(x)]);
26 }
27 return data;
28 };
29
30 var opts = {
31 width: 480,
32 height: 320,
1b7afc93
DV
33 valueRange: [-2, 2],
34 labels: ['X', 'Y']
97583b90
DV
35 };
36
37 var graph = document.getElementById("graph");
38
39 var g = new Dygraph(graph, sinewave(0, 6, 0.1), opts);
89fdcedb 40 assert.deepEqual([-2, 2], g.yAxisRange());
97583b90
DV
41
42 // Start a pan, but don't finish it yet.
43 DygraphOps.dispatchMouseDown_Point(g, 200, 100, {shiftKey: true});
44 DygraphOps.dispatchMouseMove_Point(g, 100, 100, {shiftKey: true});
89fdcedb 45 assert.deepEqual([-2, 2], g.yAxisRange());
97583b90
DV
46
47 // Now do a data update. y-axis should remain the same.
48 g.updateOptions({file: sinewave(0, 7, 0.1)});
89fdcedb 49 assert.deepEqual([-2, 2], g.yAxisRange());
97583b90
DV
50
51 // Keep the pan going.
52 DygraphOps.dispatchMouseMove_Point(g, 50, 100, {shiftKey: true});
89fdcedb 53 assert.deepEqual([-2, 2], g.yAxisRange());
97583b90
DV
54
55 // Now finish the pan.
56 DygraphOps.dispatchMouseUp_Point(g, 100, 100, {shiftKey: true});
89fdcedb
DV
57 assert.deepEqual([-2, 2], g.yAxisRange());
58});
97583b90 59
89fdcedb
DV
60
61});