*
* @author julian.eichstaedt@ch.sauter-bc.com (Fr. Sauter AG)
*/
-var ConnectSeparatedPointsTestCase = TestCase("connect-separated-points");
-ConnectSeparatedPointsTestCase.prototype.setUp = function() {
- document.body.innerHTML = "<div id='graph'></div>";
-};
+import Dygraph from '../../src/dygraph';
+import * as utils from '../../src/dygraph-utils';
+import CanvasAssertions from './CanvasAssertions';
+import Proxy from './Proxy';
-ConnectSeparatedPointsTestCase.origFunc = Dygraph.getContext;
+describe("connect-separated-points", function() {
-ConnectSeparatedPointsTestCase.prototype.setUp = function() {
- document.body.innerHTML = "<div id='graph'></div>";
- Dygraph.getContext = function(canvas) {
- return new Proxy(ConnectSeparatedPointsTestCase.origFunc(canvas));
+cleanupAfterEach();
+
+var origFunc = utils.getContext;
+
+beforeEach(function() {
+ utils.getContext = function(canvas) {
+ return new Proxy(origFunc(canvas));
};
-};
+});
-ConnectSeparatedPointsTestCase.prototype.tearDown = function() {
- Dygraph.getContext = ConnectSeparatedPointsTestCase.origFunc;
-};
+afterEach(function() {
+ Dygraph.getContext = origFunc;
+});
-ConnectSeparatedPointsTestCase.prototype.testEdgePointsSimple = function() {
+it('testEdgePointsSimple', function() {
var opts = {
width: 480,
height: 320,
var graph = document.getElementById("graph");
var g = new Dygraph(graph, data, opts);
- htx = g.hidden_ctx_;
+ var htx = g.hidden_ctx_;
var attrs = {};
// Check if both points are connected at the right edge of the canvas and if the option "connectSeparatedPoints" works properly
// even if the point is outside the visible range and only one series has a valid value for this point.
CanvasAssertions.assertLineDrawn(htx, xy1, xy2, attrs);
-};
+});
-ConnectSeparatedPointsTestCase.prototype.testEdgePointsCustomBars = function() {
+it('testEdgePointsCustomBars', function() {
var opts = {
width: 480,
height: 320,
var graph = document.getElementById("graph");
var g = new Dygraph(graph, data, opts);
- htx = g.hidden_ctx_;
+ var htx = g.hidden_ctx_;
var attrs = {};
// Check if both points are connected at the right edge of the canvas and if the option "connectSeparatedPoints" works properly
// even if the point is outside the visible range and only one series has a valid value for this point.
CanvasAssertions.assertLineDrawn(htx, xy1, xy2, attrs);
-};
+});
-ConnectSeparatedPointsTestCase.prototype.testEdgePointsErrorBars = function() {
+it('testEdgePointsErrorBars', function() {
var opts = {
width: 480,
height: 320,
var graph = document.getElementById("graph");
var g = new Dygraph(graph, data, opts);
- htx = g.hidden_ctx_;
+ var htx = g.hidden_ctx_;
var attrs = {};
// Check if both points are connected at the right edge of the canvas and if the option "connectSeparatedPoints" works properly
// even if the point is outside the visible range and only one series has a valid value for this point.
CanvasAssertions.assertLineDrawn(htx, xy1, xy2, attrs);
-};
+});
-ConnectSeparatedPointsTestCase.prototype.testConnectSeparatedPointsPerSeries = function() {
+it('testConnectSeparatedPointsPerSeries', function() {
var assertExpectedLinesDrawnPerSeries = function(htx, expectedSeries1, expectedSeries2, expectedSeries3) {
var expected = [expectedSeries1, expectedSeries2, expectedSeries3];
var actual = [
CanvasAssertions.numLinesDrawn(htx, "#ff0000"),
CanvasAssertions.numLinesDrawn(htx, "#00ff00"),
CanvasAssertions.numLinesDrawn(htx, "#0000ff")];
- assertEquals(expected, actual);
+ assert.deepEqual(expected, actual);
}
var g = new Dygraph(document.getElementById("graph"),
colors: ["#ff0000", "#00ff00", "#0000ff"]
});
- htx = g.hidden_ctx_;
+ var htx = g.hidden_ctx_;
assertExpectedLinesDrawnPerSeries(htx, 4, 1, 2);
Proxy.reset(htx);
}
});
assertExpectedLinesDrawnPerSeries(htx, 4, 3, 3);
-}
+});
-ConnectSeparatedPointsTestCase.prototype.testNaNErrorBars = function() {
+it('testNaNErrorBars', function() {
var data = [
[0,[1,2,3]],
[1,[2,3,4]],
var graph = document.getElementById("graph");
var g = new Dygraph(graph, data, opts);
- htx = g.hidden_ctx_;
+ var htx = g.hidden_ctx_;
var attrs = {};
// No line across the NaN gap, and a single line (not two)
// across the null gap.
- assertEquals(8, CanvasAssertions.numLinesDrawn(htx, '#ff0000'));
-};
+ assert.equal(8, CanvasAssertions.numLinesDrawn(htx, '#ff0000'));
+});
+
+});