diff --git a/test/core/Container.js b/test/core/Container.js old mode 100755 new mode 100644 index e139b07..4095f11 --- a/test/core/Container.js +++ b/test/core/Container.js @@ -18,7 +18,7 @@ describe('events', function () { - it('should trigger "added" and "removed" events on it\'s children', function () + it('should trigger "added" and "removed" events on its children', function () { var container = new PIXI.Container(); var child = new PIXI.DisplayObject(); @@ -47,4 +47,42 @@ expect(triggeredRemoved).to.be.true; }); }); + + describe('addChildAt', function () + { + it('should allow placements at start', function () + { + var container = new PIXI.Container(); + var child = new PIXI.DisplayObject(); + + container.addChild(new PIXI.DisplayObject()); + container.addChildAt(child, 0); + + expect(container.children.length).to.be.equals(2); + expect(container.children[0]).to.be.equals(child); + }); + + it('should allow placements at end', function () + { + var container = new PIXI.Container(); + var child = new PIXI.DisplayObject(); + + container.addChild(new PIXI.DisplayObject()); + container.addChildAt(child, 1); + + expect(container.children.length).to.be.equals(2); + expect(container.children[1]).to.be.equals(child); + }); + + it('should throw on out-of-bounds', function () + { + var container = new PIXI.Container(); + var child = new PIXI.DisplayObject(); + + container.addChild(new PIXI.DisplayObject()); + + expect(function () { container.addChildAt(child, -1); }).to.throw('The index -1 supplied is out of bounds 1'); + expect(function () { container.addChildAt(child, 2); }).to.throw('The index 2 supplied is out of bounds 1'); + }); + }); });