diff --git a/tests/vector-test.js b/tests/vector-test.js index cf50ff9..108ccc8 100644 --- a/tests/vector-test.js +++ b/tests/vector-test.js @@ -2,6 +2,11 @@ var v = require('../').vector; var should = require('should'); describe('Creating vectors: ', function () { + it('truly creates a vector', function () { + var a = new v(1); + a.isVector.should.eql(true); + }); + it('Should pass with 3 arguments', function () { var a = new v(1,0,0); a.v.length.should.eql(3); @@ -29,28 +34,54 @@ describe('Creating vectors: ', function () { var a = new v(1,0,0); var b = new v(1,1,0); +var d = new v(0,1,1); describe('Between two vectors: ', function () { it('should add two vectors easily', function () { var c = a.add(b); c.v.length.should.eql(3); c.v.should.eql([ 2, 1, 0 ]); + + var c = a.add(d); + c.v.length.should.eql(3); + c.v.should.eql([ 1, 1, 1 ]); }); it('should calculate the dot product', function () { var c = a.dot(b); c.should.eql(1); + + var c = a.dot(d); + c.should.eql(0); }); it('should calculate the cross product', function () { var c = a.cross(b); c.v.length.should.eql(3); c.v.should.eql([0,0,1]); + + var c = b.cross(a); + c.v.length.should.eql(3); + c.v.should.eql([0,0,-1]); + + var c = a.cross(d); + c.v.length.should.eql(3); + c.v.should.eql([0,-1,1]); + + var c = d.cross(b); + c.v.length.should.eql(3); + c.v.should.eql([-1,1,-1]); }); it('should calculate the distance between the two', function () { var c = a.distanceFrom(b); c.should.eql(1); + + var c = a.distanceFrom(a); + c.should.eql(0); + + var c = b.distanceFrom(d); + c.should.eql(Math.sqrt(2)); }); it('should calculate the length of the vector', function () {