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