diff --git a/test/core/Container.js b/test/core/Container.js index 88cc338..4095f11 100644 --- a/test/core/Container.js +++ b/test/core/Container.js @@ -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'); + }); + }); });