diff --git a/test/hand.js b/test/hand.js index 1c3e8e6..0e178ac 100644 --- a/test/hand.js +++ b/test/hand.js @@ -1,8 +1,8 @@ describe('Hand', function(){ describe("an instance", function() { - var data = fakeFrame({fingers: 5, hands:1}) - var frame = createFrame(data); - var hand = frame.hands[0]; + let data = fakeFrame({fingers: 5, hands:1}) + let frame = createFrame(data); + let hand = frame.hands[0]; describe("properties", function() { it('should have palmPosition', function() { assert(hand.palmPosition) }) @@ -32,8 +32,8 @@ describe('Hand', function(){ it('should return fingers ordered by id', function(){ - var hand = fakeActualFrame().hands[0]; - for (var i = 1; i < hand.fingers.length; i++){ + let hand = fakeActualFrame().hands[0]; + for (let i = 1; i < hand.fingers.length; i++){ assert(hand.fingers[i].id > hand.fingers[i-1].id, "Fingers to be in sequential order. Got '" + hand.fingers[i].id + ', ' + hand.fingers[i-1].id + "'"); } @@ -42,11 +42,11 @@ describe('Hand', function(){ describe("#rotationAngle", function() { it('should work', function() { - var frame1 = createFrame(data); + let frame1 = createFrame(data); frame1.hand(0)._rotation = [1.0,0.0,0.0,0.0,1.0,0.0,0.0,0.0,1.0]; - var frame2 = createFrame(data); + let frame2 = createFrame(data); frame2.hand(0)._rotation = [1.0,0.0,0.0,0.0,1.0,0.0,0.5,0.0,0.5]; - var result = frame2.hand(0).rotationAngle(frame1); + let result = frame2.hand(0).rotationAngle(frame1); assert.closeTo(0.72273, result, 0.0001) }) }) @@ -54,30 +54,30 @@ describe('Hand', function(){ describe('#translation()', function(){ it('should return the translation', function(){ - var data1 = fakeFrame({handData: [fakeHand({translation: [1, 2, 3]})]}) - var frame1 = createFrame(data1); - var data2 = fakeFrame({handData: [fakeHand({translation: [3, 1, 5]})]}) - var frame2 = createFrame(data2); + let data1 = fakeFrame({handData: [fakeHand({translation: [1, 2, 3]})]}) + let frame1 = createFrame(data1); + let data2 = fakeFrame({handData: [fakeHand({translation: [3, 1, 5]})]}) + let frame2 = createFrame(data2); assert.deepEqual([-2, 1, -2], frame1.hand(0).translation(frame2)) }) }) describe('#rotationAxis()', function(){ it('should return the rotationAxis', function(){ - var data1 = fakeFrame({handData: [fakeHand({rotation: [[0,1,2], [2,3,4], [2,3,4]]})]}) - var frame1 = createFrame(data1); - var data2 = fakeFrame({handData: [fakeHand({rotation: [[0,4,5], [1,3,7], [5,4,2]]})]}) - var frame2 = createFrame(data2); - var result = frame1.hand(0).rotationAxis(frame2); + let data1 = fakeFrame({handData: [fakeHand({rotation: [[0,1,2], [2,3,4], [2,3,4]]})]}) + let frame1 = createFrame(data1); + let data2 = fakeFrame({handData: [fakeHand({rotation: [[0,4,5], [1,3,7], [5,4,2]]})]}) + let frame2 = createFrame(data2); + let result = frame1.hand(0).rotationAxis(frame2); assertUtil.vectorCloseTo([-0.74278, -0.55708,-0.37139], result, 0.0001, 'rotation axis'); }) it('should return a null vector if the hand is invalid', function(){ - var data1 = fakeFrame({handData: [fakeHand({rotation: [[0,4,5], [1,3,7], [5,4,2]]})]}) - var frame1 = createFrame(data1); - var data2 = fakeFrame({handData: []}) - var frame2 = createFrame(data2); - var result = frame1.hand(0).rotationAxis(frame2); + let data1 = fakeFrame({handData: [fakeHand({rotation: [[0,4,5], [1,3,7], [5,4,2]]})]}) + let frame1 = createFrame(data1); + let data2 = fakeFrame({handData: []}) + let frame2 = createFrame(data2); + let result = frame1.hand(0).rotationAxis(frame2); assert(!frame2.hand(0).valid); assertUtil.vectorCloseTo(result, Leap.vec3.create(), 0.0001, 'result is zero vector'); }); @@ -85,11 +85,11 @@ describe('Hand', function(){ describe('#rotationAngle()', function(){ it('should return the rotationAngle', function(){ - var data1 = fakeFrame({handData: [fakeHand({rotation: [[1,0,0], [0,1,0], [0,0,1]]})]}) - var frame1 = createFrame(data1); - var data2 = fakeFrame({handData: [fakeHand({rotation: [[1,0,0], [0,1,0], [0.5,0,0.5]]})]}) - var frame2 = createFrame(data2); - var result = frame1.hand(0).rotationAngle(frame2); + let data1 = fakeFrame({handData: [fakeHand({rotation: [[1,0,0], [0,1,0], [0,0,1]]})]}) + let frame1 = createFrame(data1); + let data2 = fakeFrame({handData: [fakeHand({rotation: [[1,0,0], [0,1,0], [0.5,0,0.5]]})]}) + let frame2 = createFrame(data2); + let result = frame1.hand(0).rotationAngle(frame2); assert.closeTo(0.72273, result, 0.0001) }) })