consolidating scripts
[dygraphs.git] / auto_tests / tests / smooth_plotter.js
CommitLineData
c36a62c2
DV
1/**
2 * @fileoverview Tests for the smooth (bezier curve) plotter.
3 *
4 * @author danvdk@gmail.com (Dan Vanderkam)
5 */
e8c70e4e
DV
6
7import Dygraph from '../../src/dygraph';
8import '../../src/extras/smooth-plotter'; // defines Dygraph.smoothPlotter
9
89fdcedb 10describe("smooth-plotter", function() {
c36a62c2 11
e8c70e4e 12var smoothPlotter = Dygraph.smoothPlotter;
c36a62c2
DV
13var getControlPoints = smoothPlotter._getControlPoints;
14
89fdcedb
DV
15beforeEach(function() {
16});
c36a62c2 17
89fdcedb
DV
18afterEach(function() {
19});
c36a62c2 20
89fdcedb 21it('testNoSmoothing', function() {
c36a62c2
DV
22 var lastPt = {x: 10, y: 0},
23 pt = {x: 11, y: 1},
24 nextPt = {x: 12, y: 0},
25 alpha = 0;
26
89fdcedb
DV
27 assert.deepEqual([11, 1, 11, 1], getControlPoints(lastPt, pt, nextPt, alpha));
28});
c36a62c2 29
89fdcedb 30it('testHalfSmoothing', function() {
c36a62c2
DV
31 var lastPt = {x: 10, y: 0},
32 pt = {x: 11, y: 1},
33 nextPt = {x: 12, y: 0},
34 alpha = 0.5;
35
89fdcedb
DV
36 assert.deepEqual([10.5, 1, 11.5, 1], getControlPoints(lastPt, pt, nextPt, alpha));
37});
c36a62c2 38
89fdcedb 39it('testExtrema', function() {
c36a62c2
DV
40 var lastPt = {x: 10, y: 0},
41 pt = {x: 11, y: 1},
42 nextPt = {x: 12, y: 1},
43 alpha = 0.5;
44
89fdcedb 45 assert.deepEqual([10.5, 0.75, 11.5, 1.25],
c36a62c2
DV
46 getControlPoints(lastPt, pt, nextPt, alpha, true));
47
89fdcedb 48 assert.deepEqual([10.5, 1, 11.5, 1],
c36a62c2 49 getControlPoints(lastPt, pt, nextPt, alpha, false));
89fdcedb
DV
50});
51
52});