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