diff --git a/test/core/Graphics.js b/test/core/Graphics.js index 020ecaf..c7c7a45 100644 --- a/test/core/Graphics.js +++ b/test/core/Graphics.js @@ -103,4 +103,29 @@ expect(graphics.height).to.be.equals(70); }); }); + + describe('containsPoint', () => + { + it('should return true when point inside', () => + { + const point = new PIXI.Point(1, 1); + const graphics = new PIXI.Graphics(); + + graphics.beginFill(0); + graphics.drawRect(0, 0, 10, 10); + + expect(graphics.containsPoint(point)).to.be.true; + }); + + it('should return false when point outside', () => + { + const point = new PIXI.Point(20, 20); + const graphics = new PIXI.Graphics(); + + graphics.beginFill(0); + graphics.drawRect(0, 0, 10, 10); + + expect(graphics.containsPoint(point)).to.be.false; + }); + }); }); diff --git a/test/core/Graphics.js b/test/core/Graphics.js index 020ecaf..c7c7a45 100644 --- a/test/core/Graphics.js +++ b/test/core/Graphics.js @@ -103,4 +103,29 @@ expect(graphics.height).to.be.equals(70); }); }); + + describe('containsPoint', () => + { + it('should return true when point inside', () => + { + const point = new PIXI.Point(1, 1); + const graphics = new PIXI.Graphics(); + + graphics.beginFill(0); + graphics.drawRect(0, 0, 10, 10); + + expect(graphics.containsPoint(point)).to.be.true; + }); + + it('should return false when point outside', () => + { + const point = new PIXI.Point(20, 20); + const graphics = new PIXI.Graphics(); + + graphics.beginFill(0); + graphics.drawRect(0, 0, 10, 10); + + expect(graphics.containsPoint(point)).to.be.false; + }); + }); }); diff --git a/test/core/Plane.js b/test/core/Plane.js index ab2f460..9c428d3 100644 --- a/test/core/Plane.js +++ b/test/core/Plane.js @@ -22,4 +22,25 @@ expect(plane.verticesX).to.equal(100); expect(plane.verticesY).to.equal(100); }); + + describe('containsPoint', function () + { + it('should return true when point inside', function () + { + const point = new PIXI.Point(10, 10); + const texture = new PIXI.RenderTexture.create(20, 30); + const plane = new PIXI.mesh.Plane(texture, 100, 100); + + expect(plane.containsPoint(point)).to.be.true; + }); + + it('should return false when point outside', function () + { + const point = new PIXI.Point(100, 100); + const texture = new PIXI.RenderTexture.create(20, 30); + const plane = new PIXI.mesh.Plane(texture, 100, 100); + + expect(plane.containsPoint(point)).to.be.false; + }); + }); }); diff --git a/test/core/Graphics.js b/test/core/Graphics.js index 020ecaf..c7c7a45 100644 --- a/test/core/Graphics.js +++ b/test/core/Graphics.js @@ -103,4 +103,29 @@ expect(graphics.height).to.be.equals(70); }); }); + + describe('containsPoint', () => + { + it('should return true when point inside', () => + { + const point = new PIXI.Point(1, 1); + const graphics = new PIXI.Graphics(); + + graphics.beginFill(0); + graphics.drawRect(0, 0, 10, 10); + + expect(graphics.containsPoint(point)).to.be.true; + }); + + it('should return false when point outside', () => + { + const point = new PIXI.Point(20, 20); + const graphics = new PIXI.Graphics(); + + graphics.beginFill(0); + graphics.drawRect(0, 0, 10, 10); + + expect(graphics.containsPoint(point)).to.be.false; + }); + }); }); diff --git a/test/core/Plane.js b/test/core/Plane.js index ab2f460..9c428d3 100644 --- a/test/core/Plane.js +++ b/test/core/Plane.js @@ -22,4 +22,25 @@ expect(plane.verticesX).to.equal(100); expect(plane.verticesY).to.equal(100); }); + + describe('containsPoint', function () + { + it('should return true when point inside', function () + { + const point = new PIXI.Point(10, 10); + const texture = new PIXI.RenderTexture.create(20, 30); + const plane = new PIXI.mesh.Plane(texture, 100, 100); + + expect(plane.containsPoint(point)).to.be.true; + }); + + it('should return false when point outside', function () + { + const point = new PIXI.Point(100, 100); + const texture = new PIXI.RenderTexture.create(20, 30); + const plane = new PIXI.mesh.Plane(texture, 100, 100); + + expect(plane.containsPoint(point)).to.be.false; + }); + }); }); diff --git a/test/core/Sprite.js b/test/core/Sprite.js index 2a3d301..b14419d 100755 --- a/test/core/Sprite.js +++ b/test/core/Sprite.js @@ -62,7 +62,7 @@ }); }); - describe('getBounds()', function () + describe('getBounds', function () { it('must have correct value according to texture size, width, height and anchor', function () { @@ -88,4 +88,25 @@ expect(bounds.height).to.equal(600); }); }); + + describe('containsPoint', function () + { + it('should return true when point inside', function () + { + const point = new PIXI.Point(10, 10); + const texture = new PIXI.RenderTexture.create(20, 30); + const sprite = new PIXI.Sprite(texture); + + expect(sprite.containsPoint(point)).to.be.true; + }); + + it('should return false when point outside', function () + { + const point = new PIXI.Point(100, 100); + const texture = new PIXI.RenderTexture.create(20, 30); + const sprite = new PIXI.Sprite(texture); + + expect(sprite.containsPoint(point)).to.be.false; + }); + }); });