diff --git a/test/core/Container.js b/test/core/Container.js index 9211158..e0001ea 100644 --- a/test/core/Container.js +++ b/test/core/Container.js @@ -1,13 +1,13 @@ 'use strict'; -describe('PIXI.Container', function () +describe('PIXI.Container', () => { - describe('parent', function () + describe('parent', () => { - it('should be present when adding children to Container', function () + it('should be present when adding children to Container', () => { - var container = new PIXI.Container(); - var child = new PIXI.DisplayObject(); + const container = new PIXI.Container(); + const child = new PIXI.DisplayObject(); expect(container.children.length).to.be.equals(0); container.addChild(child); @@ -16,22 +16,22 @@ }); }); - describe('events', function () + describe('events', () => { - it('should trigger "added" and "removed" events on its children', function () + it('should trigger "added" and "removed" events on its children', () => { - var container = new PIXI.Container(); - var child = new PIXI.DisplayObject(); - var triggeredAdded = false; - var triggeredRemoved = false; + const container = new PIXI.Container(); + const child = new PIXI.DisplayObject(); + let triggeredAdded = false; + let triggeredRemoved = false; - child.on('added', function (to) + child.on('added', (to) => { triggeredAdded = true; expect(container.children.length).to.be.equals(1); expect(child.parent).to.be.equals(to); }); - child.on('removed', function (from) + child.on('removed', (from) => { triggeredRemoved = true; expect(container.children.length).to.be.equals(0); @@ -48,35 +48,35 @@ }); }); - describe('addChild', function () + describe('addChild', () => { - it('should remove from current parent', function () + it('should remove from current parent', () => { - var parent = new PIXI.Container(); - var container = new PIXI.Container(); - var child = new PIXI.DisplayObject(); + const parent = new PIXI.Container(); + const container = new PIXI.Container(); + const child = new PIXI.DisplayObject(); - assertRemovedFromParent(parent, container, child, function () { container.addChild(child); }); + assertRemovedFromParent(parent, container, child, () => { container.addChild(child); }); }); }); - describe('removeChildAt', function () + describe('removeChildAt', () => { - it('should remove from current parent', function () + it('should remove from current parent', () => { - var parent = new PIXI.Container(); - var child = new PIXI.DisplayObject(); + const parent = new PIXI.Container(); + const child = new PIXI.DisplayObject(); - assertRemovedFromParent(parent, null, child, function () { parent.removeChildAt(0); }); + assertRemovedFromParent(parent, null, child, () => { parent.removeChildAt(0); }); }); }); - describe('addChildAt', function () + describe('addChildAt', () => { - it('should allow placements at start', function () + it('should allow placements at start', () => { - var container = new PIXI.Container(); - var child = new PIXI.DisplayObject(); + const container = new PIXI.Container(); + const child = new PIXI.DisplayObject(); container.addChild(new PIXI.DisplayObject()); container.addChildAt(child, 0); @@ -85,10 +85,10 @@ expect(container.children[0]).to.be.equals(child); }); - it('should allow placements at end', function () + it('should allow placements at end', () => { - var container = new PIXI.Container(); - var child = new PIXI.DisplayObject(); + const container = new PIXI.Container(); + const child = new PIXI.DisplayObject(); container.addChild(new PIXI.DisplayObject()); container.addChildAt(child, 1); @@ -97,33 +97,33 @@ expect(container.children[1]).to.be.equals(child); }); - it('should throw on out-of-bounds', function () + it('should throw on out-of-bounds', () => { - var container = new PIXI.Container(); - var child = new PIXI.DisplayObject(); + const container = new PIXI.Container(); + const 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'); + expect(() => container.addChildAt(child, -1)).to.throw('The index -1 supplied is out of bounds 1'); + expect(() => container.addChildAt(child, 2)).to.throw('The index 2 supplied is out of bounds 1'); }); - it('should remove from current parent', function () + it('should remove from current parent', () => { - var parent = new PIXI.Container(); - var container = new PIXI.Container(); - var child = new PIXI.DisplayObject(); + const parent = new PIXI.Container(); + const container = new PIXI.Container(); + const child = new PIXI.DisplayObject(); - assertRemovedFromParent(parent, container, child, function () { container.addChildAt(child, 0); }); + assertRemovedFromParent(parent, container, child, () => { container.addChildAt(child, 0); }); }); }); - describe('removeChild', function () + describe('removeChild', () => { - it('should ignore non-children', function () + it('should ignore non-children', () => { - var container = new PIXI.Container(); - var child = new PIXI.DisplayObject(); + const container = new PIXI.Container(); + const child = new PIXI.DisplayObject(); container.addChild(child); @@ -132,11 +132,11 @@ expect(container.children.length).to.be.equals(1); }); - it('should remove all children supplied', function () + it('should remove all children supplied', () => { - var container = new PIXI.Container(); - var child1 = new PIXI.DisplayObject(); - var child2 = new PIXI.DisplayObject(); + const container = new PIXI.Container(); + const child1 = new PIXI.DisplayObject(); + const child2 = new PIXI.DisplayObject(); container.addChild(child1, child2); @@ -148,36 +148,38 @@ }); }); - describe('getChildIndex', function () + describe('getChildIndex', () => { - it('should return the correct index', function () + it('should return the correct index', () => { - var container = new PIXI.Container(); - var child = new PIXI.DisplayObject(); + const container = new PIXI.Container(); + const child = new PIXI.DisplayObject(); container.addChild(new PIXI.DisplayObject(), child, new PIXI.DisplayObject()); expect(container.getChildIndex(child)).to.be.equals(1); }); - it('should throw when child does not exist', function () + it('should throw when child does not exist', () => { - var container = new PIXI.Container(); - var child = new PIXI.DisplayObject(); + const container = new PIXI.Container(); + const child = new PIXI.DisplayObject(); - expect(function () { container.getChildIndex(child); }) + expect(() => container.getChildIndex(child)) .to.throw('The supplied DisplayObject must be a child of the caller'); }); }); - describe('getChildAt', function () + describe('getChildAt', () => { - it('should throw when out-of-bounds', function () + it('should throw when out-of-bounds', () => { - var container = new PIXI.Container(); + const container = new PIXI.Container(); - expect(function () { container.getChildAt(-1); }).to.throw('getChildAt: Index (-1) does not exist.'); - expect(function () { container.getChildAt(1); }).to.throw('getChildAt: Index (1) does not exist.'); + expect(() => container.getChildAt(-1)).to.throw('getChildAt: Index (-1) does not exist.'); + expect(() => container.getChildAt(1)).to.throw('getChildAt: Index (1) does not exist.'); + }); + }); }); });