diff --git a/spec/suites/geometry/PointSpec.js b/spec/suites/geometry/PointSpec.js index acdac15b..b1dcdd05 100644 --- a/spec/suites/geometry/PointSpec.js +++ b/spec/suites/geometry/PointSpec.js @@ -15,9 +15,23 @@ describe("Point", function() { }); }); - describe('#subtract', noSpecs); + describe('#subtract', function() { + it('should subtract the given point from this one', function() { + var a = new L.Point(50, 30), + b = new L.Point(20, 10); + expect(a.subtract(b)).toEqual(new L.Point(30, 20)); + }); + }); - describe('#add', noSpecs); + describe('#add', function() { + it('should add the given point to this one', function() { + expect(new L.Point(50, 30).add(new L.Point(20, 10))).toEqual(new L.Point(70, 40)); + }); + }); - describe('#divideBy', noSpecs); + describe('#divideBy', function() { + it('should divide this point by the given amount', function() { + expect(new L.Point(50, 30).divideBy(5)).toEqual(new L.Point(10, 6)); + }); + }); }); \ No newline at end of file diff --git a/src/geometry/Point.js b/src/geometry/Point.js index 26e004e9..ddd4793d 100644 --- a/src/geometry/Point.js +++ b/src/geometry/Point.js @@ -9,14 +9,14 @@ L.Point = function(/*Number*/ x, /*Number*/ y, /*Boolean*/ round) { L.Point.prototype = { add: function(point) { - return L.Point(this.x + point.x, this.y + point.y); + return new L.Point(this.x + point.x, this.y + point.y); }, subtract: function(point) { - return L.Point(this.x - point.x, this.y - point.y); + return new L.Point(this.x - point.x, this.y - point.y); }, divideBy: function(num, round) { - return L.Point(this.x/2, this.y/2, round); + return new L.Point(this.x/num, this.y/num, round); } }; \ No newline at end of file