*/
describe("range-selector", function() {
+var restoreConsole;
+var logs = {};
beforeEach(function() {
document.body.innerHTML = "<div id='graph'></div>";
+ restoreConsole = Util.captureConsole(logs);
});
afterEach(function() {
+ restoreConsole();
});
it('testRangeSelector', function() {
];
var graph = document.getElementById("graph");
var g = new Dygraph(graph, data, opts);
+ var initialChartHeight = g.getArea().h;
g.updateOptions({showRangeSelector: true});
assertGraphExistence(g, graph);
+ assert(g.getArea().h < initialChartHeight); // range selector shown
+
+ g.updateOptions({showRangeSelector: false});
+ assert.equal(g.getArea().h, initialChartHeight); // range selector hidden
});
// The animatedZooms option does not work with the range selector. Make sure it gets turned off.
var g = new Dygraph(graph, data, opts);
assertGraphExistence(g, graph);
assert.isFalse(g.getOption('animatedZooms'));
+ assert.deepEqual(logs, {
+ log: [], error: [],
+ warn: ["Animated zooms and range selector are not compatible; disabling animatedZooms."]
+ });
});
it('testRangeSelectorWithAnimatedZoomsOption2', function() {
g.updateOptions({showRangeSelector: true});
assertGraphExistence(g, graph);
assert.isFalse(g.getOption('animatedZooms'));
+ assert.deepEqual(logs, {
+ log: [], error: [],
+ warn: ["Animated zooms and range selector are not compatible; disabling animatedZooms."]
+ });
});
it('testRangeSelectorInteraction', function() {
zoomhandles[0].dispatchEvent(mouseUpEvent);
var newXRange = g.xAxisRange().slice();
- assert('left zoomhandle should have moved: '+newXRange[0]+'>'+xRange[0], newXRange[0] > xRange[0]);
- assert.equal('right zoomhandle should not have moved', xRange[1], newXRange[1]);
+ assert(newXRange[0] > xRange[0], 'left zoomhandle should have moved: '+newXRange[0]+'>'+xRange[0]);
+ assert.equal(xRange[1], newXRange[1], 'right zoomhandle should not have moved');
// Move right zoomhandle in
xRange = newXRange;
zoomhandles[1].dispatchEvent(mouseUpEvent);
var newXRange = g.xAxisRange().slice();
- assert('right zoomhandle should have moved: '+newXRange[1]+'<'+xRange[1], newXRange[1] < xRange[1]);
- assert.equal('left zoomhandle should not have moved', xRange[0], newXRange[0]);
+ assert(newXRange[1] < xRange[1], 'right zoomhandle should have moved: '+newXRange[1]+'<'+xRange[1]);
+ assert.equal(xRange[0], newXRange[0], 'left zoomhandle should not have moved');
// Pan left
xRange = newXRange;
fgcanvas.dispatchEvent(mouseUpEvent);
var newXRange = g.xAxisRange().slice();
- assert(newXRange[0]+'<'+xRange[0], newXRange[0] < xRange[0]);
- assert(newXRange[1]+'<'+xRange[1], newXRange[1] < xRange[1]);
+ assert(newXRange[0] < xRange[0], newXRange[0]+'<'+xRange[0]);
+ assert(newXRange[1] < xRange[1], newXRange[1]+'<'+xRange[1]);
});
// xAxis shouldn't be reserved since it isn't drawn.
assertGraphExistence(g, graph);
var bgcanvas = graph.getElementsByClassName('dygraph-rangesel-bgcanvas')[0];
- assert.equal("Range selector is not at the expected position.","70px", bgcanvas.style.top);
+ assert.equal("70px", bgcanvas.style.top, "Range selector is not at the expected position.");
var fgcanvas = graph.getElementsByClassName('dygraph-rangesel-fgcanvas')[0];
- assert.equal("Range selector is not at the expected position.","70px", fgcanvas.style.top);
+ assert.equal("70px", fgcanvas.style.top, "Range selector is not at the expected position.");
});
it('testMiniPlotDrawn', function() {
var origFunc = Dygraph.getContext;
var miniHtx;
Dygraph.getContext = function(canvas) {
- console.log(canvas.className);
if (canvas.className != 'dygraph-rangesel-bgcanvas') {
return origFunc(canvas);
}