diff --git a/test/unit/pixi-v2/InteractionManager.js b/test/unit/pixi-v2/InteractionManager.js new file mode 100644 index 0000000..ed3001f --- /dev/null +++ b/test/unit/pixi-v2/InteractionManager.js @@ -0,0 +1,10 @@ +describe('pixi/InteractionManager', function () { + 'use strict'; + + var expect = chai.expect; + var InteractionManager = PIXI.InteractionManager; + + it('Module exists', function () { + expect(InteractionManager).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/InteractionManager.js b/test/unit/pixi-v2/InteractionManager.js new file mode 100644 index 0000000..ed3001f --- /dev/null +++ b/test/unit/pixi-v2/InteractionManager.js @@ -0,0 +1,10 @@ +describe('pixi/InteractionManager', function () { + 'use strict'; + + var expect = chai.expect; + var InteractionManager = PIXI.InteractionManager; + + it('Module exists', function () { + expect(InteractionManager).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/Pixi.js b/test/unit/pixi-v2/Pixi.js new file mode 100644 index 0000000..27debc1 --- /dev/null +++ b/test/unit/pixi-v2/Pixi.js @@ -0,0 +1,9 @@ +describe('pixi/Pixi', function () { + 'use strict'; + + var expect = chai.expect; + + it('Module exists', function () { + expect(global).to.have.property('PIXI').and.to.be.an('object'); + }); +}); diff --git a/test/unit/pixi-v2/InteractionManager.js b/test/unit/pixi-v2/InteractionManager.js new file mode 100644 index 0000000..ed3001f --- /dev/null +++ b/test/unit/pixi-v2/InteractionManager.js @@ -0,0 +1,10 @@ +describe('pixi/InteractionManager', function () { + 'use strict'; + + var expect = chai.expect; + var InteractionManager = PIXI.InteractionManager; + + it('Module exists', function () { + expect(InteractionManager).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/Pixi.js b/test/unit/pixi-v2/Pixi.js new file mode 100644 index 0000000..27debc1 --- /dev/null +++ b/test/unit/pixi-v2/Pixi.js @@ -0,0 +1,9 @@ +describe('pixi/Pixi', function () { + 'use strict'; + + var expect = chai.expect; + + it('Module exists', function () { + expect(global).to.have.property('PIXI').and.to.be.an('object'); + }); +}); diff --git a/test/unit/pixi-v2/core/Circle.js b/test/unit/pixi-v2/core/Circle.js new file mode 100644 index 0000000..fbcfa17 --- /dev/null +++ b/test/unit/pixi-v2/core/Circle.js @@ -0,0 +1,21 @@ +describe('pixi/core/Circle', function () { + 'use strict'; + + var expect = chai.expect; + var Circle = PIXI.Circle; + + it('Module exists', function () { + expect(Circle).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Circle(); + pixi_core_Circle_confirmNewCircle(obj); + }); + + it("getBounds should return Rectangle that bounds the circle", function() { + var obj = new Circle(100, 250, 50); + var bounds = obj.getBounds(); + pixi_core_Circle_isBoundedByRectangle(obj, bounds); + }); +}); diff --git a/test/unit/pixi-v2/InteractionManager.js b/test/unit/pixi-v2/InteractionManager.js new file mode 100644 index 0000000..ed3001f --- /dev/null +++ b/test/unit/pixi-v2/InteractionManager.js @@ -0,0 +1,10 @@ +describe('pixi/InteractionManager', function () { + 'use strict'; + + var expect = chai.expect; + var InteractionManager = PIXI.InteractionManager; + + it('Module exists', function () { + expect(InteractionManager).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/Pixi.js b/test/unit/pixi-v2/Pixi.js new file mode 100644 index 0000000..27debc1 --- /dev/null +++ b/test/unit/pixi-v2/Pixi.js @@ -0,0 +1,9 @@ +describe('pixi/Pixi', function () { + 'use strict'; + + var expect = chai.expect; + + it('Module exists', function () { + expect(global).to.have.property('PIXI').and.to.be.an('object'); + }); +}); diff --git a/test/unit/pixi-v2/core/Circle.js b/test/unit/pixi-v2/core/Circle.js new file mode 100644 index 0000000..fbcfa17 --- /dev/null +++ b/test/unit/pixi-v2/core/Circle.js @@ -0,0 +1,21 @@ +describe('pixi/core/Circle', function () { + 'use strict'; + + var expect = chai.expect; + var Circle = PIXI.Circle; + + it('Module exists', function () { + expect(Circle).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Circle(); + pixi_core_Circle_confirmNewCircle(obj); + }); + + it("getBounds should return Rectangle that bounds the circle", function() { + var obj = new Circle(100, 250, 50); + var bounds = obj.getBounds(); + pixi_core_Circle_isBoundedByRectangle(obj, bounds); + }); +}); diff --git a/test/unit/pixi-v2/core/Ellipse.js b/test/unit/pixi-v2/core/Ellipse.js new file mode 100644 index 0000000..026b56f --- /dev/null +++ b/test/unit/pixi-v2/core/Ellipse.js @@ -0,0 +1,24 @@ +describe('pixi/core/Ellipse', function () { + 'use strict'; + + var expect = chai.expect; + var Ellipse = PIXI.Ellipse; + + it('Module exists', function () { + expect(Ellipse).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Ellipse(); + + expect(obj).to.be.an.instanceof(Ellipse); + expect(obj).to.respondTo('clone'); + expect(obj).to.respondTo('contains'); + expect(obj).to.respondTo('getBounds'); + + expect(obj).to.have.property('x', 0); + expect(obj).to.have.property('y', 0); + expect(obj).to.have.property('width', 0); + expect(obj).to.have.property('height', 0); + }); +}); diff --git a/test/unit/pixi-v2/InteractionManager.js b/test/unit/pixi-v2/InteractionManager.js new file mode 100644 index 0000000..ed3001f --- /dev/null +++ b/test/unit/pixi-v2/InteractionManager.js @@ -0,0 +1,10 @@ +describe('pixi/InteractionManager', function () { + 'use strict'; + + var expect = chai.expect; + var InteractionManager = PIXI.InteractionManager; + + it('Module exists', function () { + expect(InteractionManager).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/Pixi.js b/test/unit/pixi-v2/Pixi.js new file mode 100644 index 0000000..27debc1 --- /dev/null +++ b/test/unit/pixi-v2/Pixi.js @@ -0,0 +1,9 @@ +describe('pixi/Pixi', function () { + 'use strict'; + + var expect = chai.expect; + + it('Module exists', function () { + expect(global).to.have.property('PIXI').and.to.be.an('object'); + }); +}); diff --git a/test/unit/pixi-v2/core/Circle.js b/test/unit/pixi-v2/core/Circle.js new file mode 100644 index 0000000..fbcfa17 --- /dev/null +++ b/test/unit/pixi-v2/core/Circle.js @@ -0,0 +1,21 @@ +describe('pixi/core/Circle', function () { + 'use strict'; + + var expect = chai.expect; + var Circle = PIXI.Circle; + + it('Module exists', function () { + expect(Circle).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Circle(); + pixi_core_Circle_confirmNewCircle(obj); + }); + + it("getBounds should return Rectangle that bounds the circle", function() { + var obj = new Circle(100, 250, 50); + var bounds = obj.getBounds(); + pixi_core_Circle_isBoundedByRectangle(obj, bounds); + }); +}); diff --git a/test/unit/pixi-v2/core/Ellipse.js b/test/unit/pixi-v2/core/Ellipse.js new file mode 100644 index 0000000..026b56f --- /dev/null +++ b/test/unit/pixi-v2/core/Ellipse.js @@ -0,0 +1,24 @@ +describe('pixi/core/Ellipse', function () { + 'use strict'; + + var expect = chai.expect; + var Ellipse = PIXI.Ellipse; + + it('Module exists', function () { + expect(Ellipse).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Ellipse(); + + expect(obj).to.be.an.instanceof(Ellipse); + expect(obj).to.respondTo('clone'); + expect(obj).to.respondTo('contains'); + expect(obj).to.respondTo('getBounds'); + + expect(obj).to.have.property('x', 0); + expect(obj).to.have.property('y', 0); + expect(obj).to.have.property('width', 0); + expect(obj).to.have.property('height', 0); + }); +}); diff --git a/test/unit/pixi-v2/core/Matrix.js b/test/unit/pixi-v2/core/Matrix.js new file mode 100644 index 0000000..da75e2e --- /dev/null +++ b/test/unit/pixi-v2/core/Matrix.js @@ -0,0 +1,14 @@ +describe('pixi/core/Matrix', function () { + 'use strict'; + + var expect = chai.expect; + + it('Matrix exists', function () { + expect(PIXI.Matrix).to.be.an('function'); + }); + + it('Confirm new Matrix', function () { + var matrix = new PIXI.Matrix(); + pixi_core_Matrix_confirmNewMatrix(matrix); + }); +}); diff --git a/test/unit/pixi-v2/InteractionManager.js b/test/unit/pixi-v2/InteractionManager.js new file mode 100644 index 0000000..ed3001f --- /dev/null +++ b/test/unit/pixi-v2/InteractionManager.js @@ -0,0 +1,10 @@ +describe('pixi/InteractionManager', function () { + 'use strict'; + + var expect = chai.expect; + var InteractionManager = PIXI.InteractionManager; + + it('Module exists', function () { + expect(InteractionManager).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/Pixi.js b/test/unit/pixi-v2/Pixi.js new file mode 100644 index 0000000..27debc1 --- /dev/null +++ b/test/unit/pixi-v2/Pixi.js @@ -0,0 +1,9 @@ +describe('pixi/Pixi', function () { + 'use strict'; + + var expect = chai.expect; + + it('Module exists', function () { + expect(global).to.have.property('PIXI').and.to.be.an('object'); + }); +}); diff --git a/test/unit/pixi-v2/core/Circle.js b/test/unit/pixi-v2/core/Circle.js new file mode 100644 index 0000000..fbcfa17 --- /dev/null +++ b/test/unit/pixi-v2/core/Circle.js @@ -0,0 +1,21 @@ +describe('pixi/core/Circle', function () { + 'use strict'; + + var expect = chai.expect; + var Circle = PIXI.Circle; + + it('Module exists', function () { + expect(Circle).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Circle(); + pixi_core_Circle_confirmNewCircle(obj); + }); + + it("getBounds should return Rectangle that bounds the circle", function() { + var obj = new Circle(100, 250, 50); + var bounds = obj.getBounds(); + pixi_core_Circle_isBoundedByRectangle(obj, bounds); + }); +}); diff --git a/test/unit/pixi-v2/core/Ellipse.js b/test/unit/pixi-v2/core/Ellipse.js new file mode 100644 index 0000000..026b56f --- /dev/null +++ b/test/unit/pixi-v2/core/Ellipse.js @@ -0,0 +1,24 @@ +describe('pixi/core/Ellipse', function () { + 'use strict'; + + var expect = chai.expect; + var Ellipse = PIXI.Ellipse; + + it('Module exists', function () { + expect(Ellipse).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Ellipse(); + + expect(obj).to.be.an.instanceof(Ellipse); + expect(obj).to.respondTo('clone'); + expect(obj).to.respondTo('contains'); + expect(obj).to.respondTo('getBounds'); + + expect(obj).to.have.property('x', 0); + expect(obj).to.have.property('y', 0); + expect(obj).to.have.property('width', 0); + expect(obj).to.have.property('height', 0); + }); +}); diff --git a/test/unit/pixi-v2/core/Matrix.js b/test/unit/pixi-v2/core/Matrix.js new file mode 100644 index 0000000..da75e2e --- /dev/null +++ b/test/unit/pixi-v2/core/Matrix.js @@ -0,0 +1,14 @@ +describe('pixi/core/Matrix', function () { + 'use strict'; + + var expect = chai.expect; + + it('Matrix exists', function () { + expect(PIXI.Matrix).to.be.an('function'); + }); + + it('Confirm new Matrix', function () { + var matrix = new PIXI.Matrix(); + pixi_core_Matrix_confirmNewMatrix(matrix); + }); +}); diff --git a/test/unit/pixi-v2/core/Point.js b/test/unit/pixi-v2/core/Point.js new file mode 100644 index 0000000..c4d5163 --- /dev/null +++ b/test/unit/pixi-v2/core/Point.js @@ -0,0 +1,15 @@ +describe('pixi/core/Point', function () { + 'use strict'; + + var expect = chai.expect; + var Point = PIXI.Point; + + it('Module exists', function () { + expect(Point).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Point(); + pixi_core_Point_confirm(obj, 0, 0); + }); +}); diff --git a/test/unit/pixi-v2/InteractionManager.js b/test/unit/pixi-v2/InteractionManager.js new file mode 100644 index 0000000..ed3001f --- /dev/null +++ b/test/unit/pixi-v2/InteractionManager.js @@ -0,0 +1,10 @@ +describe('pixi/InteractionManager', function () { + 'use strict'; + + var expect = chai.expect; + var InteractionManager = PIXI.InteractionManager; + + it('Module exists', function () { + expect(InteractionManager).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/Pixi.js b/test/unit/pixi-v2/Pixi.js new file mode 100644 index 0000000..27debc1 --- /dev/null +++ b/test/unit/pixi-v2/Pixi.js @@ -0,0 +1,9 @@ +describe('pixi/Pixi', function () { + 'use strict'; + + var expect = chai.expect; + + it('Module exists', function () { + expect(global).to.have.property('PIXI').and.to.be.an('object'); + }); +}); diff --git a/test/unit/pixi-v2/core/Circle.js b/test/unit/pixi-v2/core/Circle.js new file mode 100644 index 0000000..fbcfa17 --- /dev/null +++ b/test/unit/pixi-v2/core/Circle.js @@ -0,0 +1,21 @@ +describe('pixi/core/Circle', function () { + 'use strict'; + + var expect = chai.expect; + var Circle = PIXI.Circle; + + it('Module exists', function () { + expect(Circle).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Circle(); + pixi_core_Circle_confirmNewCircle(obj); + }); + + it("getBounds should return Rectangle that bounds the circle", function() { + var obj = new Circle(100, 250, 50); + var bounds = obj.getBounds(); + pixi_core_Circle_isBoundedByRectangle(obj, bounds); + }); +}); diff --git a/test/unit/pixi-v2/core/Ellipse.js b/test/unit/pixi-v2/core/Ellipse.js new file mode 100644 index 0000000..026b56f --- /dev/null +++ b/test/unit/pixi-v2/core/Ellipse.js @@ -0,0 +1,24 @@ +describe('pixi/core/Ellipse', function () { + 'use strict'; + + var expect = chai.expect; + var Ellipse = PIXI.Ellipse; + + it('Module exists', function () { + expect(Ellipse).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Ellipse(); + + expect(obj).to.be.an.instanceof(Ellipse); + expect(obj).to.respondTo('clone'); + expect(obj).to.respondTo('contains'); + expect(obj).to.respondTo('getBounds'); + + expect(obj).to.have.property('x', 0); + expect(obj).to.have.property('y', 0); + expect(obj).to.have.property('width', 0); + expect(obj).to.have.property('height', 0); + }); +}); diff --git a/test/unit/pixi-v2/core/Matrix.js b/test/unit/pixi-v2/core/Matrix.js new file mode 100644 index 0000000..da75e2e --- /dev/null +++ b/test/unit/pixi-v2/core/Matrix.js @@ -0,0 +1,14 @@ +describe('pixi/core/Matrix', function () { + 'use strict'; + + var expect = chai.expect; + + it('Matrix exists', function () { + expect(PIXI.Matrix).to.be.an('function'); + }); + + it('Confirm new Matrix', function () { + var matrix = new PIXI.Matrix(); + pixi_core_Matrix_confirmNewMatrix(matrix); + }); +}); diff --git a/test/unit/pixi-v2/core/Point.js b/test/unit/pixi-v2/core/Point.js new file mode 100644 index 0000000..c4d5163 --- /dev/null +++ b/test/unit/pixi-v2/core/Point.js @@ -0,0 +1,15 @@ +describe('pixi/core/Point', function () { + 'use strict'; + + var expect = chai.expect; + var Point = PIXI.Point; + + it('Module exists', function () { + expect(Point).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Point(); + pixi_core_Point_confirm(obj, 0, 0); + }); +}); diff --git a/test/unit/pixi-v2/core/Polygon.js b/test/unit/pixi-v2/core/Polygon.js new file mode 100644 index 0000000..dc8c918 --- /dev/null +++ b/test/unit/pixi-v2/core/Polygon.js @@ -0,0 +1,20 @@ +describe('pixi/core/Polygon', function () { + 'use strict'; + + var expect = chai.expect; + var Polygon = PIXI.Polygon; + + it('Module exists', function () { + expect(Polygon).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Polygon(); + + expect(obj).to.be.an.instanceof(Polygon); + expect(obj).to.respondTo('clone'); + expect(obj).to.respondTo('contains'); + + expect(obj).to.have.deep.property('points.length', 0); + }); +}); diff --git a/test/unit/pixi-v2/InteractionManager.js b/test/unit/pixi-v2/InteractionManager.js new file mode 100644 index 0000000..ed3001f --- /dev/null +++ b/test/unit/pixi-v2/InteractionManager.js @@ -0,0 +1,10 @@ +describe('pixi/InteractionManager', function () { + 'use strict'; + + var expect = chai.expect; + var InteractionManager = PIXI.InteractionManager; + + it('Module exists', function () { + expect(InteractionManager).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/Pixi.js b/test/unit/pixi-v2/Pixi.js new file mode 100644 index 0000000..27debc1 --- /dev/null +++ b/test/unit/pixi-v2/Pixi.js @@ -0,0 +1,9 @@ +describe('pixi/Pixi', function () { + 'use strict'; + + var expect = chai.expect; + + it('Module exists', function () { + expect(global).to.have.property('PIXI').and.to.be.an('object'); + }); +}); diff --git a/test/unit/pixi-v2/core/Circle.js b/test/unit/pixi-v2/core/Circle.js new file mode 100644 index 0000000..fbcfa17 --- /dev/null +++ b/test/unit/pixi-v2/core/Circle.js @@ -0,0 +1,21 @@ +describe('pixi/core/Circle', function () { + 'use strict'; + + var expect = chai.expect; + var Circle = PIXI.Circle; + + it('Module exists', function () { + expect(Circle).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Circle(); + pixi_core_Circle_confirmNewCircle(obj); + }); + + it("getBounds should return Rectangle that bounds the circle", function() { + var obj = new Circle(100, 250, 50); + var bounds = obj.getBounds(); + pixi_core_Circle_isBoundedByRectangle(obj, bounds); + }); +}); diff --git a/test/unit/pixi-v2/core/Ellipse.js b/test/unit/pixi-v2/core/Ellipse.js new file mode 100644 index 0000000..026b56f --- /dev/null +++ b/test/unit/pixi-v2/core/Ellipse.js @@ -0,0 +1,24 @@ +describe('pixi/core/Ellipse', function () { + 'use strict'; + + var expect = chai.expect; + var Ellipse = PIXI.Ellipse; + + it('Module exists', function () { + expect(Ellipse).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Ellipse(); + + expect(obj).to.be.an.instanceof(Ellipse); + expect(obj).to.respondTo('clone'); + expect(obj).to.respondTo('contains'); + expect(obj).to.respondTo('getBounds'); + + expect(obj).to.have.property('x', 0); + expect(obj).to.have.property('y', 0); + expect(obj).to.have.property('width', 0); + expect(obj).to.have.property('height', 0); + }); +}); diff --git a/test/unit/pixi-v2/core/Matrix.js b/test/unit/pixi-v2/core/Matrix.js new file mode 100644 index 0000000..da75e2e --- /dev/null +++ b/test/unit/pixi-v2/core/Matrix.js @@ -0,0 +1,14 @@ +describe('pixi/core/Matrix', function () { + 'use strict'; + + var expect = chai.expect; + + it('Matrix exists', function () { + expect(PIXI.Matrix).to.be.an('function'); + }); + + it('Confirm new Matrix', function () { + var matrix = new PIXI.Matrix(); + pixi_core_Matrix_confirmNewMatrix(matrix); + }); +}); diff --git a/test/unit/pixi-v2/core/Point.js b/test/unit/pixi-v2/core/Point.js new file mode 100644 index 0000000..c4d5163 --- /dev/null +++ b/test/unit/pixi-v2/core/Point.js @@ -0,0 +1,15 @@ +describe('pixi/core/Point', function () { + 'use strict'; + + var expect = chai.expect; + var Point = PIXI.Point; + + it('Module exists', function () { + expect(Point).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Point(); + pixi_core_Point_confirm(obj, 0, 0); + }); +}); diff --git a/test/unit/pixi-v2/core/Polygon.js b/test/unit/pixi-v2/core/Polygon.js new file mode 100644 index 0000000..dc8c918 --- /dev/null +++ b/test/unit/pixi-v2/core/Polygon.js @@ -0,0 +1,20 @@ +describe('pixi/core/Polygon', function () { + 'use strict'; + + var expect = chai.expect; + var Polygon = PIXI.Polygon; + + it('Module exists', function () { + expect(Polygon).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Polygon(); + + expect(obj).to.be.an.instanceof(Polygon); + expect(obj).to.respondTo('clone'); + expect(obj).to.respondTo('contains'); + + expect(obj).to.have.deep.property('points.length', 0); + }); +}); diff --git a/test/unit/pixi-v2/core/Rectangle.js b/test/unit/pixi-v2/core/Rectangle.js new file mode 100644 index 0000000..d43316e --- /dev/null +++ b/test/unit/pixi-v2/core/Rectangle.js @@ -0,0 +1,15 @@ +describe('pixi/core/Rectangle', function () { + 'use strict'; + + var expect = chai.expect; + var Rectangle = PIXI.Rectangle; + + it('Module exists', function () { + expect(Rectangle).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var rect = new Rectangle(); + pixi_core_Rectangle_confirm(rect, 0, 0, 0, 0); + }); +}); diff --git a/test/unit/pixi-v2/InteractionManager.js b/test/unit/pixi-v2/InteractionManager.js new file mode 100644 index 0000000..ed3001f --- /dev/null +++ b/test/unit/pixi-v2/InteractionManager.js @@ -0,0 +1,10 @@ +describe('pixi/InteractionManager', function () { + 'use strict'; + + var expect = chai.expect; + var InteractionManager = PIXI.InteractionManager; + + it('Module exists', function () { + expect(InteractionManager).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/Pixi.js b/test/unit/pixi-v2/Pixi.js new file mode 100644 index 0000000..27debc1 --- /dev/null +++ b/test/unit/pixi-v2/Pixi.js @@ -0,0 +1,9 @@ +describe('pixi/Pixi', function () { + 'use strict'; + + var expect = chai.expect; + + it('Module exists', function () { + expect(global).to.have.property('PIXI').and.to.be.an('object'); + }); +}); diff --git a/test/unit/pixi-v2/core/Circle.js b/test/unit/pixi-v2/core/Circle.js new file mode 100644 index 0000000..fbcfa17 --- /dev/null +++ b/test/unit/pixi-v2/core/Circle.js @@ -0,0 +1,21 @@ +describe('pixi/core/Circle', function () { + 'use strict'; + + var expect = chai.expect; + var Circle = PIXI.Circle; + + it('Module exists', function () { + expect(Circle).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Circle(); + pixi_core_Circle_confirmNewCircle(obj); + }); + + it("getBounds should return Rectangle that bounds the circle", function() { + var obj = new Circle(100, 250, 50); + var bounds = obj.getBounds(); + pixi_core_Circle_isBoundedByRectangle(obj, bounds); + }); +}); diff --git a/test/unit/pixi-v2/core/Ellipse.js b/test/unit/pixi-v2/core/Ellipse.js new file mode 100644 index 0000000..026b56f --- /dev/null +++ b/test/unit/pixi-v2/core/Ellipse.js @@ -0,0 +1,24 @@ +describe('pixi/core/Ellipse', function () { + 'use strict'; + + var expect = chai.expect; + var Ellipse = PIXI.Ellipse; + + it('Module exists', function () { + expect(Ellipse).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Ellipse(); + + expect(obj).to.be.an.instanceof(Ellipse); + expect(obj).to.respondTo('clone'); + expect(obj).to.respondTo('contains'); + expect(obj).to.respondTo('getBounds'); + + expect(obj).to.have.property('x', 0); + expect(obj).to.have.property('y', 0); + expect(obj).to.have.property('width', 0); + expect(obj).to.have.property('height', 0); + }); +}); diff --git a/test/unit/pixi-v2/core/Matrix.js b/test/unit/pixi-v2/core/Matrix.js new file mode 100644 index 0000000..da75e2e --- /dev/null +++ b/test/unit/pixi-v2/core/Matrix.js @@ -0,0 +1,14 @@ +describe('pixi/core/Matrix', function () { + 'use strict'; + + var expect = chai.expect; + + it('Matrix exists', function () { + expect(PIXI.Matrix).to.be.an('function'); + }); + + it('Confirm new Matrix', function () { + var matrix = new PIXI.Matrix(); + pixi_core_Matrix_confirmNewMatrix(matrix); + }); +}); diff --git a/test/unit/pixi-v2/core/Point.js b/test/unit/pixi-v2/core/Point.js new file mode 100644 index 0000000..c4d5163 --- /dev/null +++ b/test/unit/pixi-v2/core/Point.js @@ -0,0 +1,15 @@ +describe('pixi/core/Point', function () { + 'use strict'; + + var expect = chai.expect; + var Point = PIXI.Point; + + it('Module exists', function () { + expect(Point).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Point(); + pixi_core_Point_confirm(obj, 0, 0); + }); +}); diff --git a/test/unit/pixi-v2/core/Polygon.js b/test/unit/pixi-v2/core/Polygon.js new file mode 100644 index 0000000..dc8c918 --- /dev/null +++ b/test/unit/pixi-v2/core/Polygon.js @@ -0,0 +1,20 @@ +describe('pixi/core/Polygon', function () { + 'use strict'; + + var expect = chai.expect; + var Polygon = PIXI.Polygon; + + it('Module exists', function () { + expect(Polygon).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Polygon(); + + expect(obj).to.be.an.instanceof(Polygon); + expect(obj).to.respondTo('clone'); + expect(obj).to.respondTo('contains'); + + expect(obj).to.have.deep.property('points.length', 0); + }); +}); diff --git a/test/unit/pixi-v2/core/Rectangle.js b/test/unit/pixi-v2/core/Rectangle.js new file mode 100644 index 0000000..d43316e --- /dev/null +++ b/test/unit/pixi-v2/core/Rectangle.js @@ -0,0 +1,15 @@ +describe('pixi/core/Rectangle', function () { + 'use strict'; + + var expect = chai.expect; + var Rectangle = PIXI.Rectangle; + + it('Module exists', function () { + expect(Rectangle).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var rect = new Rectangle(); + pixi_core_Rectangle_confirm(rect, 0, 0, 0, 0); + }); +}); diff --git a/test/unit/pixi-v2/display/DisplayObject.js b/test/unit/pixi-v2/display/DisplayObject.js new file mode 100644 index 0000000..044acf8 --- /dev/null +++ b/test/unit/pixi-v2/display/DisplayObject.js @@ -0,0 +1,21 @@ +describe('pixi/display/DisplayObject', function () { + 'use strict'; + + var expect = chai.expect; + var DisplayObject = PIXI.DisplayObject; + + it('Module exists', function () { + expect(DisplayObject).to.be.a('function'); + // expect(PIXI).to.have.property('visibleCount', 0); + }); + + it('Confirm new instance', function () { + var obj = new DisplayObject(); + + pixi_display_DisplayObject_confirmNew(obj); + expect(obj).to.have.property('hitArea', null); + expect(obj).to.have.property('interactive', false); + expect(obj).to.have.property('renderable', false); + expect(obj).to.have.property('stage', null); + }); +}); diff --git a/test/unit/pixi-v2/InteractionManager.js b/test/unit/pixi-v2/InteractionManager.js new file mode 100644 index 0000000..ed3001f --- /dev/null +++ b/test/unit/pixi-v2/InteractionManager.js @@ -0,0 +1,10 @@ +describe('pixi/InteractionManager', function () { + 'use strict'; + + var expect = chai.expect; + var InteractionManager = PIXI.InteractionManager; + + it('Module exists', function () { + expect(InteractionManager).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/Pixi.js b/test/unit/pixi-v2/Pixi.js new file mode 100644 index 0000000..27debc1 --- /dev/null +++ b/test/unit/pixi-v2/Pixi.js @@ -0,0 +1,9 @@ +describe('pixi/Pixi', function () { + 'use strict'; + + var expect = chai.expect; + + it('Module exists', function () { + expect(global).to.have.property('PIXI').and.to.be.an('object'); + }); +}); diff --git a/test/unit/pixi-v2/core/Circle.js b/test/unit/pixi-v2/core/Circle.js new file mode 100644 index 0000000..fbcfa17 --- /dev/null +++ b/test/unit/pixi-v2/core/Circle.js @@ -0,0 +1,21 @@ +describe('pixi/core/Circle', function () { + 'use strict'; + + var expect = chai.expect; + var Circle = PIXI.Circle; + + it('Module exists', function () { + expect(Circle).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Circle(); + pixi_core_Circle_confirmNewCircle(obj); + }); + + it("getBounds should return Rectangle that bounds the circle", function() { + var obj = new Circle(100, 250, 50); + var bounds = obj.getBounds(); + pixi_core_Circle_isBoundedByRectangle(obj, bounds); + }); +}); diff --git a/test/unit/pixi-v2/core/Ellipse.js b/test/unit/pixi-v2/core/Ellipse.js new file mode 100644 index 0000000..026b56f --- /dev/null +++ b/test/unit/pixi-v2/core/Ellipse.js @@ -0,0 +1,24 @@ +describe('pixi/core/Ellipse', function () { + 'use strict'; + + var expect = chai.expect; + var Ellipse = PIXI.Ellipse; + + it('Module exists', function () { + expect(Ellipse).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Ellipse(); + + expect(obj).to.be.an.instanceof(Ellipse); + expect(obj).to.respondTo('clone'); + expect(obj).to.respondTo('contains'); + expect(obj).to.respondTo('getBounds'); + + expect(obj).to.have.property('x', 0); + expect(obj).to.have.property('y', 0); + expect(obj).to.have.property('width', 0); + expect(obj).to.have.property('height', 0); + }); +}); diff --git a/test/unit/pixi-v2/core/Matrix.js b/test/unit/pixi-v2/core/Matrix.js new file mode 100644 index 0000000..da75e2e --- /dev/null +++ b/test/unit/pixi-v2/core/Matrix.js @@ -0,0 +1,14 @@ +describe('pixi/core/Matrix', function () { + 'use strict'; + + var expect = chai.expect; + + it('Matrix exists', function () { + expect(PIXI.Matrix).to.be.an('function'); + }); + + it('Confirm new Matrix', function () { + var matrix = new PIXI.Matrix(); + pixi_core_Matrix_confirmNewMatrix(matrix); + }); +}); diff --git a/test/unit/pixi-v2/core/Point.js b/test/unit/pixi-v2/core/Point.js new file mode 100644 index 0000000..c4d5163 --- /dev/null +++ b/test/unit/pixi-v2/core/Point.js @@ -0,0 +1,15 @@ +describe('pixi/core/Point', function () { + 'use strict'; + + var expect = chai.expect; + var Point = PIXI.Point; + + it('Module exists', function () { + expect(Point).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Point(); + pixi_core_Point_confirm(obj, 0, 0); + }); +}); diff --git a/test/unit/pixi-v2/core/Polygon.js b/test/unit/pixi-v2/core/Polygon.js new file mode 100644 index 0000000..dc8c918 --- /dev/null +++ b/test/unit/pixi-v2/core/Polygon.js @@ -0,0 +1,20 @@ +describe('pixi/core/Polygon', function () { + 'use strict'; + + var expect = chai.expect; + var Polygon = PIXI.Polygon; + + it('Module exists', function () { + expect(Polygon).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Polygon(); + + expect(obj).to.be.an.instanceof(Polygon); + expect(obj).to.respondTo('clone'); + expect(obj).to.respondTo('contains'); + + expect(obj).to.have.deep.property('points.length', 0); + }); +}); diff --git a/test/unit/pixi-v2/core/Rectangle.js b/test/unit/pixi-v2/core/Rectangle.js new file mode 100644 index 0000000..d43316e --- /dev/null +++ b/test/unit/pixi-v2/core/Rectangle.js @@ -0,0 +1,15 @@ +describe('pixi/core/Rectangle', function () { + 'use strict'; + + var expect = chai.expect; + var Rectangle = PIXI.Rectangle; + + it('Module exists', function () { + expect(Rectangle).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var rect = new Rectangle(); + pixi_core_Rectangle_confirm(rect, 0, 0, 0, 0); + }); +}); diff --git a/test/unit/pixi-v2/display/DisplayObject.js b/test/unit/pixi-v2/display/DisplayObject.js new file mode 100644 index 0000000..044acf8 --- /dev/null +++ b/test/unit/pixi-v2/display/DisplayObject.js @@ -0,0 +1,21 @@ +describe('pixi/display/DisplayObject', function () { + 'use strict'; + + var expect = chai.expect; + var DisplayObject = PIXI.DisplayObject; + + it('Module exists', function () { + expect(DisplayObject).to.be.a('function'); + // expect(PIXI).to.have.property('visibleCount', 0); + }); + + it('Confirm new instance', function () { + var obj = new DisplayObject(); + + pixi_display_DisplayObject_confirmNew(obj); + expect(obj).to.have.property('hitArea', null); + expect(obj).to.have.property('interactive', false); + expect(obj).to.have.property('renderable', false); + expect(obj).to.have.property('stage', null); + }); +}); diff --git a/test/unit/pixi-v2/display/DisplayObjectContainer.js b/test/unit/pixi-v2/display/DisplayObjectContainer.js new file mode 100644 index 0000000..15a3376 --- /dev/null +++ b/test/unit/pixi-v2/display/DisplayObjectContainer.js @@ -0,0 +1,67 @@ +describe('pixi/display/DisplayObjectContainer', function () { + 'use strict'; + + var expect = chai.expect; + var DisplayObjectContainer = PIXI.DisplayObjectContainer; + + it('Module exists', function () { + expect(DisplayObjectContainer).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new DisplayObjectContainer(); + + pixi_display_DisplayObjectContainer_confirmNew(obj); + expect(obj).to.have.property('hitArea', null); + expect(obj).to.have.property('interactive', false); + expect(obj).to.have.property('renderable', false); + expect(obj).to.have.property('stage', null); + }); + + it('Gets child index', function() { + var container = new PIXI.DisplayObjectContainer(); + var children = []; + for (var i = 0; i < 10; i++) { + var child = new PIXI.DisplayObject(); + children.push(child); + container.addChild(child); + } + + for (i = 0; i < children.length; i++) { + expect(i).to.eql(container.getChildIndex(children[i])); + } + }); + + it('throws error when trying to get index of not a child', function() { + var container = new PIXI.DisplayObjectContainer(); + var child = new PIXI.DisplayObject(); + + expect(function() { container.getChildIndex(child); }).to.throw(); + }); + + it('Sets child index', function() { + var container = new PIXI.DisplayObjectContainer(); + var children = []; + + for (var i = 0; i < 10; i++) { + var child = new PIXI.DisplayObject(); + children.push(child); + container.addChild(child); + } + children.reverse(); + + for (i = 0; i < children.length; i++) { + container.setChildIndex(children[i], i); + expect(i).to.eql(container.getChildIndex(children[i])); + } + }); + + it('throws error when trying to set incorect index', function() { + var container = new PIXI.DisplayObjectContainer(); + var child = new PIXI.DisplayObject(); + container.addChild(child); + + expect(function() { container.setChildIndex(child, -1); }).to.throw(); + expect(function() { container.setChildIndex(child, 1); }).to.throw(); + }); +}); diff --git a/test/unit/pixi-v2/InteractionManager.js b/test/unit/pixi-v2/InteractionManager.js new file mode 100644 index 0000000..ed3001f --- /dev/null +++ b/test/unit/pixi-v2/InteractionManager.js @@ -0,0 +1,10 @@ +describe('pixi/InteractionManager', function () { + 'use strict'; + + var expect = chai.expect; + var InteractionManager = PIXI.InteractionManager; + + it('Module exists', function () { + expect(InteractionManager).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/Pixi.js b/test/unit/pixi-v2/Pixi.js new file mode 100644 index 0000000..27debc1 --- /dev/null +++ b/test/unit/pixi-v2/Pixi.js @@ -0,0 +1,9 @@ +describe('pixi/Pixi', function () { + 'use strict'; + + var expect = chai.expect; + + it('Module exists', function () { + expect(global).to.have.property('PIXI').and.to.be.an('object'); + }); +}); diff --git a/test/unit/pixi-v2/core/Circle.js b/test/unit/pixi-v2/core/Circle.js new file mode 100644 index 0000000..fbcfa17 --- /dev/null +++ b/test/unit/pixi-v2/core/Circle.js @@ -0,0 +1,21 @@ +describe('pixi/core/Circle', function () { + 'use strict'; + + var expect = chai.expect; + var Circle = PIXI.Circle; + + it('Module exists', function () { + expect(Circle).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Circle(); + pixi_core_Circle_confirmNewCircle(obj); + }); + + it("getBounds should return Rectangle that bounds the circle", function() { + var obj = new Circle(100, 250, 50); + var bounds = obj.getBounds(); + pixi_core_Circle_isBoundedByRectangle(obj, bounds); + }); +}); diff --git a/test/unit/pixi-v2/core/Ellipse.js b/test/unit/pixi-v2/core/Ellipse.js new file mode 100644 index 0000000..026b56f --- /dev/null +++ b/test/unit/pixi-v2/core/Ellipse.js @@ -0,0 +1,24 @@ +describe('pixi/core/Ellipse', function () { + 'use strict'; + + var expect = chai.expect; + var Ellipse = PIXI.Ellipse; + + it('Module exists', function () { + expect(Ellipse).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Ellipse(); + + expect(obj).to.be.an.instanceof(Ellipse); + expect(obj).to.respondTo('clone'); + expect(obj).to.respondTo('contains'); + expect(obj).to.respondTo('getBounds'); + + expect(obj).to.have.property('x', 0); + expect(obj).to.have.property('y', 0); + expect(obj).to.have.property('width', 0); + expect(obj).to.have.property('height', 0); + }); +}); diff --git a/test/unit/pixi-v2/core/Matrix.js b/test/unit/pixi-v2/core/Matrix.js new file mode 100644 index 0000000..da75e2e --- /dev/null +++ b/test/unit/pixi-v2/core/Matrix.js @@ -0,0 +1,14 @@ +describe('pixi/core/Matrix', function () { + 'use strict'; + + var expect = chai.expect; + + it('Matrix exists', function () { + expect(PIXI.Matrix).to.be.an('function'); + }); + + it('Confirm new Matrix', function () { + var matrix = new PIXI.Matrix(); + pixi_core_Matrix_confirmNewMatrix(matrix); + }); +}); diff --git a/test/unit/pixi-v2/core/Point.js b/test/unit/pixi-v2/core/Point.js new file mode 100644 index 0000000..c4d5163 --- /dev/null +++ b/test/unit/pixi-v2/core/Point.js @@ -0,0 +1,15 @@ +describe('pixi/core/Point', function () { + 'use strict'; + + var expect = chai.expect; + var Point = PIXI.Point; + + it('Module exists', function () { + expect(Point).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Point(); + pixi_core_Point_confirm(obj, 0, 0); + }); +}); diff --git a/test/unit/pixi-v2/core/Polygon.js b/test/unit/pixi-v2/core/Polygon.js new file mode 100644 index 0000000..dc8c918 --- /dev/null +++ b/test/unit/pixi-v2/core/Polygon.js @@ -0,0 +1,20 @@ +describe('pixi/core/Polygon', function () { + 'use strict'; + + var expect = chai.expect; + var Polygon = PIXI.Polygon; + + it('Module exists', function () { + expect(Polygon).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Polygon(); + + expect(obj).to.be.an.instanceof(Polygon); + expect(obj).to.respondTo('clone'); + expect(obj).to.respondTo('contains'); + + expect(obj).to.have.deep.property('points.length', 0); + }); +}); diff --git a/test/unit/pixi-v2/core/Rectangle.js b/test/unit/pixi-v2/core/Rectangle.js new file mode 100644 index 0000000..d43316e --- /dev/null +++ b/test/unit/pixi-v2/core/Rectangle.js @@ -0,0 +1,15 @@ +describe('pixi/core/Rectangle', function () { + 'use strict'; + + var expect = chai.expect; + var Rectangle = PIXI.Rectangle; + + it('Module exists', function () { + expect(Rectangle).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var rect = new Rectangle(); + pixi_core_Rectangle_confirm(rect, 0, 0, 0, 0); + }); +}); diff --git a/test/unit/pixi-v2/display/DisplayObject.js b/test/unit/pixi-v2/display/DisplayObject.js new file mode 100644 index 0000000..044acf8 --- /dev/null +++ b/test/unit/pixi-v2/display/DisplayObject.js @@ -0,0 +1,21 @@ +describe('pixi/display/DisplayObject', function () { + 'use strict'; + + var expect = chai.expect; + var DisplayObject = PIXI.DisplayObject; + + it('Module exists', function () { + expect(DisplayObject).to.be.a('function'); + // expect(PIXI).to.have.property('visibleCount', 0); + }); + + it('Confirm new instance', function () { + var obj = new DisplayObject(); + + pixi_display_DisplayObject_confirmNew(obj); + expect(obj).to.have.property('hitArea', null); + expect(obj).to.have.property('interactive', false); + expect(obj).to.have.property('renderable', false); + expect(obj).to.have.property('stage', null); + }); +}); diff --git a/test/unit/pixi-v2/display/DisplayObjectContainer.js b/test/unit/pixi-v2/display/DisplayObjectContainer.js new file mode 100644 index 0000000..15a3376 --- /dev/null +++ b/test/unit/pixi-v2/display/DisplayObjectContainer.js @@ -0,0 +1,67 @@ +describe('pixi/display/DisplayObjectContainer', function () { + 'use strict'; + + var expect = chai.expect; + var DisplayObjectContainer = PIXI.DisplayObjectContainer; + + it('Module exists', function () { + expect(DisplayObjectContainer).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new DisplayObjectContainer(); + + pixi_display_DisplayObjectContainer_confirmNew(obj); + expect(obj).to.have.property('hitArea', null); + expect(obj).to.have.property('interactive', false); + expect(obj).to.have.property('renderable', false); + expect(obj).to.have.property('stage', null); + }); + + it('Gets child index', function() { + var container = new PIXI.DisplayObjectContainer(); + var children = []; + for (var i = 0; i < 10; i++) { + var child = new PIXI.DisplayObject(); + children.push(child); + container.addChild(child); + } + + for (i = 0; i < children.length; i++) { + expect(i).to.eql(container.getChildIndex(children[i])); + } + }); + + it('throws error when trying to get index of not a child', function() { + var container = new PIXI.DisplayObjectContainer(); + var child = new PIXI.DisplayObject(); + + expect(function() { container.getChildIndex(child); }).to.throw(); + }); + + it('Sets child index', function() { + var container = new PIXI.DisplayObjectContainer(); + var children = []; + + for (var i = 0; i < 10; i++) { + var child = new PIXI.DisplayObject(); + children.push(child); + container.addChild(child); + } + children.reverse(); + + for (i = 0; i < children.length; i++) { + container.setChildIndex(children[i], i); + expect(i).to.eql(container.getChildIndex(children[i])); + } + }); + + it('throws error when trying to set incorect index', function() { + var container = new PIXI.DisplayObjectContainer(); + var child = new PIXI.DisplayObject(); + container.addChild(child); + + expect(function() { container.setChildIndex(child, -1); }).to.throw(); + expect(function() { container.setChildIndex(child, 1); }).to.throw(); + }); +}); diff --git a/test/unit/pixi-v2/display/MovieClip.js b/test/unit/pixi-v2/display/MovieClip.js new file mode 100644 index 0000000..f3c6c6a --- /dev/null +++ b/test/unit/pixi-v2/display/MovieClip.js @@ -0,0 +1,33 @@ +describe('pixi/display/MovieClip', function () { + 'use strict'; + + var expect = chai.expect; + var MovieClip = PIXI.MovieClip; + var Texture = PIXI.Texture; + + it('Module exists', function () { + expect(MovieClip).to.be.a('function'); + }); + + it('Confirm new instance', function (done) { + var texture = Texture.fromImage('/base/test/textures/SpriteSheet-Explosion.png'); + var obj = new MovieClip([texture]); + + pixi_display_Sprite_confirmNew(obj, done); + + expect(obj).to.be.an.instanceof(MovieClip); + expect(obj).to.respondTo('stop'); + expect(obj).to.respondTo('play'); + expect(obj).to.respondTo('gotoAndStop'); + expect(obj).to.respondTo('gotoAndPlay'); + expect(obj).to.respondTo('updateTransform'); + + expect(obj).to.have.deep.property('textures.length', 1); + expect(obj).to.have.deep.property('textures[0]', texture); + expect(obj).to.have.property('animationSpeed', 1); + expect(obj).to.have.property('loop', true); + expect(obj).to.have.property('onComplete', null); + expect(obj).to.have.property('currentFrame', 0); + expect(obj).to.have.property('playing', false); + }); +}); diff --git a/test/unit/pixi-v2/InteractionManager.js b/test/unit/pixi-v2/InteractionManager.js new file mode 100644 index 0000000..ed3001f --- /dev/null +++ b/test/unit/pixi-v2/InteractionManager.js @@ -0,0 +1,10 @@ +describe('pixi/InteractionManager', function () { + 'use strict'; + + var expect = chai.expect; + var InteractionManager = PIXI.InteractionManager; + + it('Module exists', function () { + expect(InteractionManager).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/Pixi.js b/test/unit/pixi-v2/Pixi.js new file mode 100644 index 0000000..27debc1 --- /dev/null +++ b/test/unit/pixi-v2/Pixi.js @@ -0,0 +1,9 @@ +describe('pixi/Pixi', function () { + 'use strict'; + + var expect = chai.expect; + + it('Module exists', function () { + expect(global).to.have.property('PIXI').and.to.be.an('object'); + }); +}); diff --git a/test/unit/pixi-v2/core/Circle.js b/test/unit/pixi-v2/core/Circle.js new file mode 100644 index 0000000..fbcfa17 --- /dev/null +++ b/test/unit/pixi-v2/core/Circle.js @@ -0,0 +1,21 @@ +describe('pixi/core/Circle', function () { + 'use strict'; + + var expect = chai.expect; + var Circle = PIXI.Circle; + + it('Module exists', function () { + expect(Circle).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Circle(); + pixi_core_Circle_confirmNewCircle(obj); + }); + + it("getBounds should return Rectangle that bounds the circle", function() { + var obj = new Circle(100, 250, 50); + var bounds = obj.getBounds(); + pixi_core_Circle_isBoundedByRectangle(obj, bounds); + }); +}); diff --git a/test/unit/pixi-v2/core/Ellipse.js b/test/unit/pixi-v2/core/Ellipse.js new file mode 100644 index 0000000..026b56f --- /dev/null +++ b/test/unit/pixi-v2/core/Ellipse.js @@ -0,0 +1,24 @@ +describe('pixi/core/Ellipse', function () { + 'use strict'; + + var expect = chai.expect; + var Ellipse = PIXI.Ellipse; + + it('Module exists', function () { + expect(Ellipse).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Ellipse(); + + expect(obj).to.be.an.instanceof(Ellipse); + expect(obj).to.respondTo('clone'); + expect(obj).to.respondTo('contains'); + expect(obj).to.respondTo('getBounds'); + + expect(obj).to.have.property('x', 0); + expect(obj).to.have.property('y', 0); + expect(obj).to.have.property('width', 0); + expect(obj).to.have.property('height', 0); + }); +}); diff --git a/test/unit/pixi-v2/core/Matrix.js b/test/unit/pixi-v2/core/Matrix.js new file mode 100644 index 0000000..da75e2e --- /dev/null +++ b/test/unit/pixi-v2/core/Matrix.js @@ -0,0 +1,14 @@ +describe('pixi/core/Matrix', function () { + 'use strict'; + + var expect = chai.expect; + + it('Matrix exists', function () { + expect(PIXI.Matrix).to.be.an('function'); + }); + + it('Confirm new Matrix', function () { + var matrix = new PIXI.Matrix(); + pixi_core_Matrix_confirmNewMatrix(matrix); + }); +}); diff --git a/test/unit/pixi-v2/core/Point.js b/test/unit/pixi-v2/core/Point.js new file mode 100644 index 0000000..c4d5163 --- /dev/null +++ b/test/unit/pixi-v2/core/Point.js @@ -0,0 +1,15 @@ +describe('pixi/core/Point', function () { + 'use strict'; + + var expect = chai.expect; + var Point = PIXI.Point; + + it('Module exists', function () { + expect(Point).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Point(); + pixi_core_Point_confirm(obj, 0, 0); + }); +}); diff --git a/test/unit/pixi-v2/core/Polygon.js b/test/unit/pixi-v2/core/Polygon.js new file mode 100644 index 0000000..dc8c918 --- /dev/null +++ b/test/unit/pixi-v2/core/Polygon.js @@ -0,0 +1,20 @@ +describe('pixi/core/Polygon', function () { + 'use strict'; + + var expect = chai.expect; + var Polygon = PIXI.Polygon; + + it('Module exists', function () { + expect(Polygon).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Polygon(); + + expect(obj).to.be.an.instanceof(Polygon); + expect(obj).to.respondTo('clone'); + expect(obj).to.respondTo('contains'); + + expect(obj).to.have.deep.property('points.length', 0); + }); +}); diff --git a/test/unit/pixi-v2/core/Rectangle.js b/test/unit/pixi-v2/core/Rectangle.js new file mode 100644 index 0000000..d43316e --- /dev/null +++ b/test/unit/pixi-v2/core/Rectangle.js @@ -0,0 +1,15 @@ +describe('pixi/core/Rectangle', function () { + 'use strict'; + + var expect = chai.expect; + var Rectangle = PIXI.Rectangle; + + it('Module exists', function () { + expect(Rectangle).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var rect = new Rectangle(); + pixi_core_Rectangle_confirm(rect, 0, 0, 0, 0); + }); +}); diff --git a/test/unit/pixi-v2/display/DisplayObject.js b/test/unit/pixi-v2/display/DisplayObject.js new file mode 100644 index 0000000..044acf8 --- /dev/null +++ b/test/unit/pixi-v2/display/DisplayObject.js @@ -0,0 +1,21 @@ +describe('pixi/display/DisplayObject', function () { + 'use strict'; + + var expect = chai.expect; + var DisplayObject = PIXI.DisplayObject; + + it('Module exists', function () { + expect(DisplayObject).to.be.a('function'); + // expect(PIXI).to.have.property('visibleCount', 0); + }); + + it('Confirm new instance', function () { + var obj = new DisplayObject(); + + pixi_display_DisplayObject_confirmNew(obj); + expect(obj).to.have.property('hitArea', null); + expect(obj).to.have.property('interactive', false); + expect(obj).to.have.property('renderable', false); + expect(obj).to.have.property('stage', null); + }); +}); diff --git a/test/unit/pixi-v2/display/DisplayObjectContainer.js b/test/unit/pixi-v2/display/DisplayObjectContainer.js new file mode 100644 index 0000000..15a3376 --- /dev/null +++ b/test/unit/pixi-v2/display/DisplayObjectContainer.js @@ -0,0 +1,67 @@ +describe('pixi/display/DisplayObjectContainer', function () { + 'use strict'; + + var expect = chai.expect; + var DisplayObjectContainer = PIXI.DisplayObjectContainer; + + it('Module exists', function () { + expect(DisplayObjectContainer).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new DisplayObjectContainer(); + + pixi_display_DisplayObjectContainer_confirmNew(obj); + expect(obj).to.have.property('hitArea', null); + expect(obj).to.have.property('interactive', false); + expect(obj).to.have.property('renderable', false); + expect(obj).to.have.property('stage', null); + }); + + it('Gets child index', function() { + var container = new PIXI.DisplayObjectContainer(); + var children = []; + for (var i = 0; i < 10; i++) { + var child = new PIXI.DisplayObject(); + children.push(child); + container.addChild(child); + } + + for (i = 0; i < children.length; i++) { + expect(i).to.eql(container.getChildIndex(children[i])); + } + }); + + it('throws error when trying to get index of not a child', function() { + var container = new PIXI.DisplayObjectContainer(); + var child = new PIXI.DisplayObject(); + + expect(function() { container.getChildIndex(child); }).to.throw(); + }); + + it('Sets child index', function() { + var container = new PIXI.DisplayObjectContainer(); + var children = []; + + for (var i = 0; i < 10; i++) { + var child = new PIXI.DisplayObject(); + children.push(child); + container.addChild(child); + } + children.reverse(); + + for (i = 0; i < children.length; i++) { + container.setChildIndex(children[i], i); + expect(i).to.eql(container.getChildIndex(children[i])); + } + }); + + it('throws error when trying to set incorect index', function() { + var container = new PIXI.DisplayObjectContainer(); + var child = new PIXI.DisplayObject(); + container.addChild(child); + + expect(function() { container.setChildIndex(child, -1); }).to.throw(); + expect(function() { container.setChildIndex(child, 1); }).to.throw(); + }); +}); diff --git a/test/unit/pixi-v2/display/MovieClip.js b/test/unit/pixi-v2/display/MovieClip.js new file mode 100644 index 0000000..f3c6c6a --- /dev/null +++ b/test/unit/pixi-v2/display/MovieClip.js @@ -0,0 +1,33 @@ +describe('pixi/display/MovieClip', function () { + 'use strict'; + + var expect = chai.expect; + var MovieClip = PIXI.MovieClip; + var Texture = PIXI.Texture; + + it('Module exists', function () { + expect(MovieClip).to.be.a('function'); + }); + + it('Confirm new instance', function (done) { + var texture = Texture.fromImage('/base/test/textures/SpriteSheet-Explosion.png'); + var obj = new MovieClip([texture]); + + pixi_display_Sprite_confirmNew(obj, done); + + expect(obj).to.be.an.instanceof(MovieClip); + expect(obj).to.respondTo('stop'); + expect(obj).to.respondTo('play'); + expect(obj).to.respondTo('gotoAndStop'); + expect(obj).to.respondTo('gotoAndPlay'); + expect(obj).to.respondTo('updateTransform'); + + expect(obj).to.have.deep.property('textures.length', 1); + expect(obj).to.have.deep.property('textures[0]', texture); + expect(obj).to.have.property('animationSpeed', 1); + expect(obj).to.have.property('loop', true); + expect(obj).to.have.property('onComplete', null); + expect(obj).to.have.property('currentFrame', 0); + expect(obj).to.have.property('playing', false); + }); +}); diff --git a/test/unit/pixi-v2/display/Sprite.js b/test/unit/pixi-v2/display/Sprite.js new file mode 100644 index 0000000..30c8076 --- /dev/null +++ b/test/unit/pixi-v2/display/Sprite.js @@ -0,0 +1,28 @@ +describe('pixi/display/Sprite', function () { + 'use strict'; + + var expect = chai.expect; + var Sprite = PIXI.Sprite; + var Texture = PIXI.Texture; + + it('Module exists', function () { + expect(Sprite).to.be.a('function'); + expect(PIXI).to.have.deep.property('blendModes.NORMAL', 0); + expect(PIXI).to.have.deep.property('blendModes.ADD', 1); + expect(PIXI).to.have.deep.property('blendModes.MULTIPLY', 2); + expect(PIXI).to.have.deep.property('blendModes.SCREEN', 3); + }); + + + it('Members exist', function () { + expect(Sprite).itself.to.respondTo('fromImage'); + expect(Sprite).itself.to.respondTo('fromFrame'); + }); + + it('Confirm new instance', function (done) { + var texture = Texture.fromImage('/base/test/textures/SpriteSheet-Aliens.png'); + var obj = new Sprite(texture); + + pixi_display_Sprite_confirmNew(obj, done); + }); +}); diff --git a/test/unit/pixi-v2/InteractionManager.js b/test/unit/pixi-v2/InteractionManager.js new file mode 100644 index 0000000..ed3001f --- /dev/null +++ b/test/unit/pixi-v2/InteractionManager.js @@ -0,0 +1,10 @@ +describe('pixi/InteractionManager', function () { + 'use strict'; + + var expect = chai.expect; + var InteractionManager = PIXI.InteractionManager; + + it('Module exists', function () { + expect(InteractionManager).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/Pixi.js b/test/unit/pixi-v2/Pixi.js new file mode 100644 index 0000000..27debc1 --- /dev/null +++ b/test/unit/pixi-v2/Pixi.js @@ -0,0 +1,9 @@ +describe('pixi/Pixi', function () { + 'use strict'; + + var expect = chai.expect; + + it('Module exists', function () { + expect(global).to.have.property('PIXI').and.to.be.an('object'); + }); +}); diff --git a/test/unit/pixi-v2/core/Circle.js b/test/unit/pixi-v2/core/Circle.js new file mode 100644 index 0000000..fbcfa17 --- /dev/null +++ b/test/unit/pixi-v2/core/Circle.js @@ -0,0 +1,21 @@ +describe('pixi/core/Circle', function () { + 'use strict'; + + var expect = chai.expect; + var Circle = PIXI.Circle; + + it('Module exists', function () { + expect(Circle).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Circle(); + pixi_core_Circle_confirmNewCircle(obj); + }); + + it("getBounds should return Rectangle that bounds the circle", function() { + var obj = new Circle(100, 250, 50); + var bounds = obj.getBounds(); + pixi_core_Circle_isBoundedByRectangle(obj, bounds); + }); +}); diff --git a/test/unit/pixi-v2/core/Ellipse.js b/test/unit/pixi-v2/core/Ellipse.js new file mode 100644 index 0000000..026b56f --- /dev/null +++ b/test/unit/pixi-v2/core/Ellipse.js @@ -0,0 +1,24 @@ +describe('pixi/core/Ellipse', function () { + 'use strict'; + + var expect = chai.expect; + var Ellipse = PIXI.Ellipse; + + it('Module exists', function () { + expect(Ellipse).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Ellipse(); + + expect(obj).to.be.an.instanceof(Ellipse); + expect(obj).to.respondTo('clone'); + expect(obj).to.respondTo('contains'); + expect(obj).to.respondTo('getBounds'); + + expect(obj).to.have.property('x', 0); + expect(obj).to.have.property('y', 0); + expect(obj).to.have.property('width', 0); + expect(obj).to.have.property('height', 0); + }); +}); diff --git a/test/unit/pixi-v2/core/Matrix.js b/test/unit/pixi-v2/core/Matrix.js new file mode 100644 index 0000000..da75e2e --- /dev/null +++ b/test/unit/pixi-v2/core/Matrix.js @@ -0,0 +1,14 @@ +describe('pixi/core/Matrix', function () { + 'use strict'; + + var expect = chai.expect; + + it('Matrix exists', function () { + expect(PIXI.Matrix).to.be.an('function'); + }); + + it('Confirm new Matrix', function () { + var matrix = new PIXI.Matrix(); + pixi_core_Matrix_confirmNewMatrix(matrix); + }); +}); diff --git a/test/unit/pixi-v2/core/Point.js b/test/unit/pixi-v2/core/Point.js new file mode 100644 index 0000000..c4d5163 --- /dev/null +++ b/test/unit/pixi-v2/core/Point.js @@ -0,0 +1,15 @@ +describe('pixi/core/Point', function () { + 'use strict'; + + var expect = chai.expect; + var Point = PIXI.Point; + + it('Module exists', function () { + expect(Point).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Point(); + pixi_core_Point_confirm(obj, 0, 0); + }); +}); diff --git a/test/unit/pixi-v2/core/Polygon.js b/test/unit/pixi-v2/core/Polygon.js new file mode 100644 index 0000000..dc8c918 --- /dev/null +++ b/test/unit/pixi-v2/core/Polygon.js @@ -0,0 +1,20 @@ +describe('pixi/core/Polygon', function () { + 'use strict'; + + var expect = chai.expect; + var Polygon = PIXI.Polygon; + + it('Module exists', function () { + expect(Polygon).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Polygon(); + + expect(obj).to.be.an.instanceof(Polygon); + expect(obj).to.respondTo('clone'); + expect(obj).to.respondTo('contains'); + + expect(obj).to.have.deep.property('points.length', 0); + }); +}); diff --git a/test/unit/pixi-v2/core/Rectangle.js b/test/unit/pixi-v2/core/Rectangle.js new file mode 100644 index 0000000..d43316e --- /dev/null +++ b/test/unit/pixi-v2/core/Rectangle.js @@ -0,0 +1,15 @@ +describe('pixi/core/Rectangle', function () { + 'use strict'; + + var expect = chai.expect; + var Rectangle = PIXI.Rectangle; + + it('Module exists', function () { + expect(Rectangle).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var rect = new Rectangle(); + pixi_core_Rectangle_confirm(rect, 0, 0, 0, 0); + }); +}); diff --git a/test/unit/pixi-v2/display/DisplayObject.js b/test/unit/pixi-v2/display/DisplayObject.js new file mode 100644 index 0000000..044acf8 --- /dev/null +++ b/test/unit/pixi-v2/display/DisplayObject.js @@ -0,0 +1,21 @@ +describe('pixi/display/DisplayObject', function () { + 'use strict'; + + var expect = chai.expect; + var DisplayObject = PIXI.DisplayObject; + + it('Module exists', function () { + expect(DisplayObject).to.be.a('function'); + // expect(PIXI).to.have.property('visibleCount', 0); + }); + + it('Confirm new instance', function () { + var obj = new DisplayObject(); + + pixi_display_DisplayObject_confirmNew(obj); + expect(obj).to.have.property('hitArea', null); + expect(obj).to.have.property('interactive', false); + expect(obj).to.have.property('renderable', false); + expect(obj).to.have.property('stage', null); + }); +}); diff --git a/test/unit/pixi-v2/display/DisplayObjectContainer.js b/test/unit/pixi-v2/display/DisplayObjectContainer.js new file mode 100644 index 0000000..15a3376 --- /dev/null +++ b/test/unit/pixi-v2/display/DisplayObjectContainer.js @@ -0,0 +1,67 @@ +describe('pixi/display/DisplayObjectContainer', function () { + 'use strict'; + + var expect = chai.expect; + var DisplayObjectContainer = PIXI.DisplayObjectContainer; + + it('Module exists', function () { + expect(DisplayObjectContainer).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new DisplayObjectContainer(); + + pixi_display_DisplayObjectContainer_confirmNew(obj); + expect(obj).to.have.property('hitArea', null); + expect(obj).to.have.property('interactive', false); + expect(obj).to.have.property('renderable', false); + expect(obj).to.have.property('stage', null); + }); + + it('Gets child index', function() { + var container = new PIXI.DisplayObjectContainer(); + var children = []; + for (var i = 0; i < 10; i++) { + var child = new PIXI.DisplayObject(); + children.push(child); + container.addChild(child); + } + + for (i = 0; i < children.length; i++) { + expect(i).to.eql(container.getChildIndex(children[i])); + } + }); + + it('throws error when trying to get index of not a child', function() { + var container = new PIXI.DisplayObjectContainer(); + var child = new PIXI.DisplayObject(); + + expect(function() { container.getChildIndex(child); }).to.throw(); + }); + + it('Sets child index', function() { + var container = new PIXI.DisplayObjectContainer(); + var children = []; + + for (var i = 0; i < 10; i++) { + var child = new PIXI.DisplayObject(); + children.push(child); + container.addChild(child); + } + children.reverse(); + + for (i = 0; i < children.length; i++) { + container.setChildIndex(children[i], i); + expect(i).to.eql(container.getChildIndex(children[i])); + } + }); + + it('throws error when trying to set incorect index', function() { + var container = new PIXI.DisplayObjectContainer(); + var child = new PIXI.DisplayObject(); + container.addChild(child); + + expect(function() { container.setChildIndex(child, -1); }).to.throw(); + expect(function() { container.setChildIndex(child, 1); }).to.throw(); + }); +}); diff --git a/test/unit/pixi-v2/display/MovieClip.js b/test/unit/pixi-v2/display/MovieClip.js new file mode 100644 index 0000000..f3c6c6a --- /dev/null +++ b/test/unit/pixi-v2/display/MovieClip.js @@ -0,0 +1,33 @@ +describe('pixi/display/MovieClip', function () { + 'use strict'; + + var expect = chai.expect; + var MovieClip = PIXI.MovieClip; + var Texture = PIXI.Texture; + + it('Module exists', function () { + expect(MovieClip).to.be.a('function'); + }); + + it('Confirm new instance', function (done) { + var texture = Texture.fromImage('/base/test/textures/SpriteSheet-Explosion.png'); + var obj = new MovieClip([texture]); + + pixi_display_Sprite_confirmNew(obj, done); + + expect(obj).to.be.an.instanceof(MovieClip); + expect(obj).to.respondTo('stop'); + expect(obj).to.respondTo('play'); + expect(obj).to.respondTo('gotoAndStop'); + expect(obj).to.respondTo('gotoAndPlay'); + expect(obj).to.respondTo('updateTransform'); + + expect(obj).to.have.deep.property('textures.length', 1); + expect(obj).to.have.deep.property('textures[0]', texture); + expect(obj).to.have.property('animationSpeed', 1); + expect(obj).to.have.property('loop', true); + expect(obj).to.have.property('onComplete', null); + expect(obj).to.have.property('currentFrame', 0); + expect(obj).to.have.property('playing', false); + }); +}); diff --git a/test/unit/pixi-v2/display/Sprite.js b/test/unit/pixi-v2/display/Sprite.js new file mode 100644 index 0000000..30c8076 --- /dev/null +++ b/test/unit/pixi-v2/display/Sprite.js @@ -0,0 +1,28 @@ +describe('pixi/display/Sprite', function () { + 'use strict'; + + var expect = chai.expect; + var Sprite = PIXI.Sprite; + var Texture = PIXI.Texture; + + it('Module exists', function () { + expect(Sprite).to.be.a('function'); + expect(PIXI).to.have.deep.property('blendModes.NORMAL', 0); + expect(PIXI).to.have.deep.property('blendModes.ADD', 1); + expect(PIXI).to.have.deep.property('blendModes.MULTIPLY', 2); + expect(PIXI).to.have.deep.property('blendModes.SCREEN', 3); + }); + + + it('Members exist', function () { + expect(Sprite).itself.to.respondTo('fromImage'); + expect(Sprite).itself.to.respondTo('fromFrame'); + }); + + it('Confirm new instance', function (done) { + var texture = Texture.fromImage('/base/test/textures/SpriteSheet-Aliens.png'); + var obj = new Sprite(texture); + + pixi_display_Sprite_confirmNew(obj, done); + }); +}); diff --git a/test/unit/pixi-v2/display/Stage.js b/test/unit/pixi-v2/display/Stage.js new file mode 100644 index 0000000..6974c2e --- /dev/null +++ b/test/unit/pixi-v2/display/Stage.js @@ -0,0 +1,49 @@ +describe('pixi/display/Stage', function () { + 'use strict'; + + var expect = chai.expect; + var Stage = PIXI.Stage; + var InteractionManager = PIXI.InteractionManager; + var Rectangle = PIXI.Rectangle; + + it('Module exists', function () { + expect(Stage).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Stage(null, true); + + pixi_display_DisplayObjectContainer_confirmNew(obj); + + expect(obj).to.be.an.instanceof(Stage); + expect(obj).to.respondTo('updateTransform'); + expect(obj).to.respondTo('setBackgroundColor'); + expect(obj).to.respondTo('getMousePosition'); + // FIXME: duplicate member in DisplayObject + pixi_core_Matrix_confirmNewMatrix(obj.worldTransform); + // FIXME: convert arg to bool in constructor + expect(obj).to.have.property('interactive', true); + + expect(obj).to.have.property('interactionManager') + .and.to.be.an.instanceof(InteractionManager) + .and.to.have.property('stage', obj); + + expect(obj).to.have.property('dirty', true); + + expect(obj).to.have.property('stage', obj); + + expect(obj).to.have.property('hitArea') + .and.to.be.an.instanceof(Rectangle); + pixi_core_Rectangle_confirm(obj.hitArea, 0, 0, 100000, 100000); + + expect(obj).to.have.property('backgroundColor', 0x000000); + expect(obj).to.have.deep.property('backgroundColorSplit.length', 3); + expect(obj).to.have.deep.property('backgroundColorSplit[0]', 0); + expect(obj).to.have.deep.property('backgroundColorSplit[1]', 0); + expect(obj).to.have.deep.property('backgroundColorSplit[2]', 0); + expect(obj).to.have.property('backgroundColorString', '#000000'); + + + expect(obj).to.have.property('worldVisible', true); + }); +}); diff --git a/test/unit/pixi-v2/InteractionManager.js b/test/unit/pixi-v2/InteractionManager.js new file mode 100644 index 0000000..ed3001f --- /dev/null +++ b/test/unit/pixi-v2/InteractionManager.js @@ -0,0 +1,10 @@ +describe('pixi/InteractionManager', function () { + 'use strict'; + + var expect = chai.expect; + var InteractionManager = PIXI.InteractionManager; + + it('Module exists', function () { + expect(InteractionManager).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/Pixi.js b/test/unit/pixi-v2/Pixi.js new file mode 100644 index 0000000..27debc1 --- /dev/null +++ b/test/unit/pixi-v2/Pixi.js @@ -0,0 +1,9 @@ +describe('pixi/Pixi', function () { + 'use strict'; + + var expect = chai.expect; + + it('Module exists', function () { + expect(global).to.have.property('PIXI').and.to.be.an('object'); + }); +}); diff --git a/test/unit/pixi-v2/core/Circle.js b/test/unit/pixi-v2/core/Circle.js new file mode 100644 index 0000000..fbcfa17 --- /dev/null +++ b/test/unit/pixi-v2/core/Circle.js @@ -0,0 +1,21 @@ +describe('pixi/core/Circle', function () { + 'use strict'; + + var expect = chai.expect; + var Circle = PIXI.Circle; + + it('Module exists', function () { + expect(Circle).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Circle(); + pixi_core_Circle_confirmNewCircle(obj); + }); + + it("getBounds should return Rectangle that bounds the circle", function() { + var obj = new Circle(100, 250, 50); + var bounds = obj.getBounds(); + pixi_core_Circle_isBoundedByRectangle(obj, bounds); + }); +}); diff --git a/test/unit/pixi-v2/core/Ellipse.js b/test/unit/pixi-v2/core/Ellipse.js new file mode 100644 index 0000000..026b56f --- /dev/null +++ b/test/unit/pixi-v2/core/Ellipse.js @@ -0,0 +1,24 @@ +describe('pixi/core/Ellipse', function () { + 'use strict'; + + var expect = chai.expect; + var Ellipse = PIXI.Ellipse; + + it('Module exists', function () { + expect(Ellipse).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Ellipse(); + + expect(obj).to.be.an.instanceof(Ellipse); + expect(obj).to.respondTo('clone'); + expect(obj).to.respondTo('contains'); + expect(obj).to.respondTo('getBounds'); + + expect(obj).to.have.property('x', 0); + expect(obj).to.have.property('y', 0); + expect(obj).to.have.property('width', 0); + expect(obj).to.have.property('height', 0); + }); +}); diff --git a/test/unit/pixi-v2/core/Matrix.js b/test/unit/pixi-v2/core/Matrix.js new file mode 100644 index 0000000..da75e2e --- /dev/null +++ b/test/unit/pixi-v2/core/Matrix.js @@ -0,0 +1,14 @@ +describe('pixi/core/Matrix', function () { + 'use strict'; + + var expect = chai.expect; + + it('Matrix exists', function () { + expect(PIXI.Matrix).to.be.an('function'); + }); + + it('Confirm new Matrix', function () { + var matrix = new PIXI.Matrix(); + pixi_core_Matrix_confirmNewMatrix(matrix); + }); +}); diff --git a/test/unit/pixi-v2/core/Point.js b/test/unit/pixi-v2/core/Point.js new file mode 100644 index 0000000..c4d5163 --- /dev/null +++ b/test/unit/pixi-v2/core/Point.js @@ -0,0 +1,15 @@ +describe('pixi/core/Point', function () { + 'use strict'; + + var expect = chai.expect; + var Point = PIXI.Point; + + it('Module exists', function () { + expect(Point).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Point(); + pixi_core_Point_confirm(obj, 0, 0); + }); +}); diff --git a/test/unit/pixi-v2/core/Polygon.js b/test/unit/pixi-v2/core/Polygon.js new file mode 100644 index 0000000..dc8c918 --- /dev/null +++ b/test/unit/pixi-v2/core/Polygon.js @@ -0,0 +1,20 @@ +describe('pixi/core/Polygon', function () { + 'use strict'; + + var expect = chai.expect; + var Polygon = PIXI.Polygon; + + it('Module exists', function () { + expect(Polygon).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Polygon(); + + expect(obj).to.be.an.instanceof(Polygon); + expect(obj).to.respondTo('clone'); + expect(obj).to.respondTo('contains'); + + expect(obj).to.have.deep.property('points.length', 0); + }); +}); diff --git a/test/unit/pixi-v2/core/Rectangle.js b/test/unit/pixi-v2/core/Rectangle.js new file mode 100644 index 0000000..d43316e --- /dev/null +++ b/test/unit/pixi-v2/core/Rectangle.js @@ -0,0 +1,15 @@ +describe('pixi/core/Rectangle', function () { + 'use strict'; + + var expect = chai.expect; + var Rectangle = PIXI.Rectangle; + + it('Module exists', function () { + expect(Rectangle).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var rect = new Rectangle(); + pixi_core_Rectangle_confirm(rect, 0, 0, 0, 0); + }); +}); diff --git a/test/unit/pixi-v2/display/DisplayObject.js b/test/unit/pixi-v2/display/DisplayObject.js new file mode 100644 index 0000000..044acf8 --- /dev/null +++ b/test/unit/pixi-v2/display/DisplayObject.js @@ -0,0 +1,21 @@ +describe('pixi/display/DisplayObject', function () { + 'use strict'; + + var expect = chai.expect; + var DisplayObject = PIXI.DisplayObject; + + it('Module exists', function () { + expect(DisplayObject).to.be.a('function'); + // expect(PIXI).to.have.property('visibleCount', 0); + }); + + it('Confirm new instance', function () { + var obj = new DisplayObject(); + + pixi_display_DisplayObject_confirmNew(obj); + expect(obj).to.have.property('hitArea', null); + expect(obj).to.have.property('interactive', false); + expect(obj).to.have.property('renderable', false); + expect(obj).to.have.property('stage', null); + }); +}); diff --git a/test/unit/pixi-v2/display/DisplayObjectContainer.js b/test/unit/pixi-v2/display/DisplayObjectContainer.js new file mode 100644 index 0000000..15a3376 --- /dev/null +++ b/test/unit/pixi-v2/display/DisplayObjectContainer.js @@ -0,0 +1,67 @@ +describe('pixi/display/DisplayObjectContainer', function () { + 'use strict'; + + var expect = chai.expect; + var DisplayObjectContainer = PIXI.DisplayObjectContainer; + + it('Module exists', function () { + expect(DisplayObjectContainer).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new DisplayObjectContainer(); + + pixi_display_DisplayObjectContainer_confirmNew(obj); + expect(obj).to.have.property('hitArea', null); + expect(obj).to.have.property('interactive', false); + expect(obj).to.have.property('renderable', false); + expect(obj).to.have.property('stage', null); + }); + + it('Gets child index', function() { + var container = new PIXI.DisplayObjectContainer(); + var children = []; + for (var i = 0; i < 10; i++) { + var child = new PIXI.DisplayObject(); + children.push(child); + container.addChild(child); + } + + for (i = 0; i < children.length; i++) { + expect(i).to.eql(container.getChildIndex(children[i])); + } + }); + + it('throws error when trying to get index of not a child', function() { + var container = new PIXI.DisplayObjectContainer(); + var child = new PIXI.DisplayObject(); + + expect(function() { container.getChildIndex(child); }).to.throw(); + }); + + it('Sets child index', function() { + var container = new PIXI.DisplayObjectContainer(); + var children = []; + + for (var i = 0; i < 10; i++) { + var child = new PIXI.DisplayObject(); + children.push(child); + container.addChild(child); + } + children.reverse(); + + for (i = 0; i < children.length; i++) { + container.setChildIndex(children[i], i); + expect(i).to.eql(container.getChildIndex(children[i])); + } + }); + + it('throws error when trying to set incorect index', function() { + var container = new PIXI.DisplayObjectContainer(); + var child = new PIXI.DisplayObject(); + container.addChild(child); + + expect(function() { container.setChildIndex(child, -1); }).to.throw(); + expect(function() { container.setChildIndex(child, 1); }).to.throw(); + }); +}); diff --git a/test/unit/pixi-v2/display/MovieClip.js b/test/unit/pixi-v2/display/MovieClip.js new file mode 100644 index 0000000..f3c6c6a --- /dev/null +++ b/test/unit/pixi-v2/display/MovieClip.js @@ -0,0 +1,33 @@ +describe('pixi/display/MovieClip', function () { + 'use strict'; + + var expect = chai.expect; + var MovieClip = PIXI.MovieClip; + var Texture = PIXI.Texture; + + it('Module exists', function () { + expect(MovieClip).to.be.a('function'); + }); + + it('Confirm new instance', function (done) { + var texture = Texture.fromImage('/base/test/textures/SpriteSheet-Explosion.png'); + var obj = new MovieClip([texture]); + + pixi_display_Sprite_confirmNew(obj, done); + + expect(obj).to.be.an.instanceof(MovieClip); + expect(obj).to.respondTo('stop'); + expect(obj).to.respondTo('play'); + expect(obj).to.respondTo('gotoAndStop'); + expect(obj).to.respondTo('gotoAndPlay'); + expect(obj).to.respondTo('updateTransform'); + + expect(obj).to.have.deep.property('textures.length', 1); + expect(obj).to.have.deep.property('textures[0]', texture); + expect(obj).to.have.property('animationSpeed', 1); + expect(obj).to.have.property('loop', true); + expect(obj).to.have.property('onComplete', null); + expect(obj).to.have.property('currentFrame', 0); + expect(obj).to.have.property('playing', false); + }); +}); diff --git a/test/unit/pixi-v2/display/Sprite.js b/test/unit/pixi-v2/display/Sprite.js new file mode 100644 index 0000000..30c8076 --- /dev/null +++ b/test/unit/pixi-v2/display/Sprite.js @@ -0,0 +1,28 @@ +describe('pixi/display/Sprite', function () { + 'use strict'; + + var expect = chai.expect; + var Sprite = PIXI.Sprite; + var Texture = PIXI.Texture; + + it('Module exists', function () { + expect(Sprite).to.be.a('function'); + expect(PIXI).to.have.deep.property('blendModes.NORMAL', 0); + expect(PIXI).to.have.deep.property('blendModes.ADD', 1); + expect(PIXI).to.have.deep.property('blendModes.MULTIPLY', 2); + expect(PIXI).to.have.deep.property('blendModes.SCREEN', 3); + }); + + + it('Members exist', function () { + expect(Sprite).itself.to.respondTo('fromImage'); + expect(Sprite).itself.to.respondTo('fromFrame'); + }); + + it('Confirm new instance', function (done) { + var texture = Texture.fromImage('/base/test/textures/SpriteSheet-Aliens.png'); + var obj = new Sprite(texture); + + pixi_display_Sprite_confirmNew(obj, done); + }); +}); diff --git a/test/unit/pixi-v2/display/Stage.js b/test/unit/pixi-v2/display/Stage.js new file mode 100644 index 0000000..6974c2e --- /dev/null +++ b/test/unit/pixi-v2/display/Stage.js @@ -0,0 +1,49 @@ +describe('pixi/display/Stage', function () { + 'use strict'; + + var expect = chai.expect; + var Stage = PIXI.Stage; + var InteractionManager = PIXI.InteractionManager; + var Rectangle = PIXI.Rectangle; + + it('Module exists', function () { + expect(Stage).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Stage(null, true); + + pixi_display_DisplayObjectContainer_confirmNew(obj); + + expect(obj).to.be.an.instanceof(Stage); + expect(obj).to.respondTo('updateTransform'); + expect(obj).to.respondTo('setBackgroundColor'); + expect(obj).to.respondTo('getMousePosition'); + // FIXME: duplicate member in DisplayObject + pixi_core_Matrix_confirmNewMatrix(obj.worldTransform); + // FIXME: convert arg to bool in constructor + expect(obj).to.have.property('interactive', true); + + expect(obj).to.have.property('interactionManager') + .and.to.be.an.instanceof(InteractionManager) + .and.to.have.property('stage', obj); + + expect(obj).to.have.property('dirty', true); + + expect(obj).to.have.property('stage', obj); + + expect(obj).to.have.property('hitArea') + .and.to.be.an.instanceof(Rectangle); + pixi_core_Rectangle_confirm(obj.hitArea, 0, 0, 100000, 100000); + + expect(obj).to.have.property('backgroundColor', 0x000000); + expect(obj).to.have.deep.property('backgroundColorSplit.length', 3); + expect(obj).to.have.deep.property('backgroundColorSplit[0]', 0); + expect(obj).to.have.deep.property('backgroundColorSplit[1]', 0); + expect(obj).to.have.deep.property('backgroundColorSplit[2]', 0); + expect(obj).to.have.property('backgroundColorString', '#000000'); + + + expect(obj).to.have.property('worldVisible', true); + }); +}); diff --git a/test/unit/pixi-v2/extras/Rope.js b/test/unit/pixi-v2/extras/Rope.js new file mode 100644 index 0000000..05885ac --- /dev/null +++ b/test/unit/pixi-v2/extras/Rope.js @@ -0,0 +1,31 @@ +describe('pixi/extras/Rope', function () { + 'use strict'; + + var expect = chai.expect; + var Rope = PIXI.Rope; + var Texture = PIXI.Texture; + var Point = PIXI.Point; + + it('Module exists', function () { + expect(Rope).to.be.a('function'); + }); + + it('Confirm new instance', function () { + + var texture = Texture.fromImage('/base/test/textures/bunny.png'); + + // TODO-Alvin + // Same as Strip + + // var obj = new Rope(texture, [new Point(), new Point(5, 10), new Point(10, 20)]); + + // pixi_extras_Strip_confirmNew(obj); + + // expect(obj).to.be.an.instanceof(Rope); + // expect(obj).to.respondTo('refresh'); + // expect(obj).to.respondTo('updateTransform'); + // expect(obj).to.respondTo('setTexture'); + + // TODO: Test properties + }); +}); diff --git a/test/unit/pixi-v2/InteractionManager.js b/test/unit/pixi-v2/InteractionManager.js new file mode 100644 index 0000000..ed3001f --- /dev/null +++ b/test/unit/pixi-v2/InteractionManager.js @@ -0,0 +1,10 @@ +describe('pixi/InteractionManager', function () { + 'use strict'; + + var expect = chai.expect; + var InteractionManager = PIXI.InteractionManager; + + it('Module exists', function () { + expect(InteractionManager).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/Pixi.js b/test/unit/pixi-v2/Pixi.js new file mode 100644 index 0000000..27debc1 --- /dev/null +++ b/test/unit/pixi-v2/Pixi.js @@ -0,0 +1,9 @@ +describe('pixi/Pixi', function () { + 'use strict'; + + var expect = chai.expect; + + it('Module exists', function () { + expect(global).to.have.property('PIXI').and.to.be.an('object'); + }); +}); diff --git a/test/unit/pixi-v2/core/Circle.js b/test/unit/pixi-v2/core/Circle.js new file mode 100644 index 0000000..fbcfa17 --- /dev/null +++ b/test/unit/pixi-v2/core/Circle.js @@ -0,0 +1,21 @@ +describe('pixi/core/Circle', function () { + 'use strict'; + + var expect = chai.expect; + var Circle = PIXI.Circle; + + it('Module exists', function () { + expect(Circle).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Circle(); + pixi_core_Circle_confirmNewCircle(obj); + }); + + it("getBounds should return Rectangle that bounds the circle", function() { + var obj = new Circle(100, 250, 50); + var bounds = obj.getBounds(); + pixi_core_Circle_isBoundedByRectangle(obj, bounds); + }); +}); diff --git a/test/unit/pixi-v2/core/Ellipse.js b/test/unit/pixi-v2/core/Ellipse.js new file mode 100644 index 0000000..026b56f --- /dev/null +++ b/test/unit/pixi-v2/core/Ellipse.js @@ -0,0 +1,24 @@ +describe('pixi/core/Ellipse', function () { + 'use strict'; + + var expect = chai.expect; + var Ellipse = PIXI.Ellipse; + + it('Module exists', function () { + expect(Ellipse).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Ellipse(); + + expect(obj).to.be.an.instanceof(Ellipse); + expect(obj).to.respondTo('clone'); + expect(obj).to.respondTo('contains'); + expect(obj).to.respondTo('getBounds'); + + expect(obj).to.have.property('x', 0); + expect(obj).to.have.property('y', 0); + expect(obj).to.have.property('width', 0); + expect(obj).to.have.property('height', 0); + }); +}); diff --git a/test/unit/pixi-v2/core/Matrix.js b/test/unit/pixi-v2/core/Matrix.js new file mode 100644 index 0000000..da75e2e --- /dev/null +++ b/test/unit/pixi-v2/core/Matrix.js @@ -0,0 +1,14 @@ +describe('pixi/core/Matrix', function () { + 'use strict'; + + var expect = chai.expect; + + it('Matrix exists', function () { + expect(PIXI.Matrix).to.be.an('function'); + }); + + it('Confirm new Matrix', function () { + var matrix = new PIXI.Matrix(); + pixi_core_Matrix_confirmNewMatrix(matrix); + }); +}); diff --git a/test/unit/pixi-v2/core/Point.js b/test/unit/pixi-v2/core/Point.js new file mode 100644 index 0000000..c4d5163 --- /dev/null +++ b/test/unit/pixi-v2/core/Point.js @@ -0,0 +1,15 @@ +describe('pixi/core/Point', function () { + 'use strict'; + + var expect = chai.expect; + var Point = PIXI.Point; + + it('Module exists', function () { + expect(Point).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Point(); + pixi_core_Point_confirm(obj, 0, 0); + }); +}); diff --git a/test/unit/pixi-v2/core/Polygon.js b/test/unit/pixi-v2/core/Polygon.js new file mode 100644 index 0000000..dc8c918 --- /dev/null +++ b/test/unit/pixi-v2/core/Polygon.js @@ -0,0 +1,20 @@ +describe('pixi/core/Polygon', function () { + 'use strict'; + + var expect = chai.expect; + var Polygon = PIXI.Polygon; + + it('Module exists', function () { + expect(Polygon).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Polygon(); + + expect(obj).to.be.an.instanceof(Polygon); + expect(obj).to.respondTo('clone'); + expect(obj).to.respondTo('contains'); + + expect(obj).to.have.deep.property('points.length', 0); + }); +}); diff --git a/test/unit/pixi-v2/core/Rectangle.js b/test/unit/pixi-v2/core/Rectangle.js new file mode 100644 index 0000000..d43316e --- /dev/null +++ b/test/unit/pixi-v2/core/Rectangle.js @@ -0,0 +1,15 @@ +describe('pixi/core/Rectangle', function () { + 'use strict'; + + var expect = chai.expect; + var Rectangle = PIXI.Rectangle; + + it('Module exists', function () { + expect(Rectangle).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var rect = new Rectangle(); + pixi_core_Rectangle_confirm(rect, 0, 0, 0, 0); + }); +}); diff --git a/test/unit/pixi-v2/display/DisplayObject.js b/test/unit/pixi-v2/display/DisplayObject.js new file mode 100644 index 0000000..044acf8 --- /dev/null +++ b/test/unit/pixi-v2/display/DisplayObject.js @@ -0,0 +1,21 @@ +describe('pixi/display/DisplayObject', function () { + 'use strict'; + + var expect = chai.expect; + var DisplayObject = PIXI.DisplayObject; + + it('Module exists', function () { + expect(DisplayObject).to.be.a('function'); + // expect(PIXI).to.have.property('visibleCount', 0); + }); + + it('Confirm new instance', function () { + var obj = new DisplayObject(); + + pixi_display_DisplayObject_confirmNew(obj); + expect(obj).to.have.property('hitArea', null); + expect(obj).to.have.property('interactive', false); + expect(obj).to.have.property('renderable', false); + expect(obj).to.have.property('stage', null); + }); +}); diff --git a/test/unit/pixi-v2/display/DisplayObjectContainer.js b/test/unit/pixi-v2/display/DisplayObjectContainer.js new file mode 100644 index 0000000..15a3376 --- /dev/null +++ b/test/unit/pixi-v2/display/DisplayObjectContainer.js @@ -0,0 +1,67 @@ +describe('pixi/display/DisplayObjectContainer', function () { + 'use strict'; + + var expect = chai.expect; + var DisplayObjectContainer = PIXI.DisplayObjectContainer; + + it('Module exists', function () { + expect(DisplayObjectContainer).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new DisplayObjectContainer(); + + pixi_display_DisplayObjectContainer_confirmNew(obj); + expect(obj).to.have.property('hitArea', null); + expect(obj).to.have.property('interactive', false); + expect(obj).to.have.property('renderable', false); + expect(obj).to.have.property('stage', null); + }); + + it('Gets child index', function() { + var container = new PIXI.DisplayObjectContainer(); + var children = []; + for (var i = 0; i < 10; i++) { + var child = new PIXI.DisplayObject(); + children.push(child); + container.addChild(child); + } + + for (i = 0; i < children.length; i++) { + expect(i).to.eql(container.getChildIndex(children[i])); + } + }); + + it('throws error when trying to get index of not a child', function() { + var container = new PIXI.DisplayObjectContainer(); + var child = new PIXI.DisplayObject(); + + expect(function() { container.getChildIndex(child); }).to.throw(); + }); + + it('Sets child index', function() { + var container = new PIXI.DisplayObjectContainer(); + var children = []; + + for (var i = 0; i < 10; i++) { + var child = new PIXI.DisplayObject(); + children.push(child); + container.addChild(child); + } + children.reverse(); + + for (i = 0; i < children.length; i++) { + container.setChildIndex(children[i], i); + expect(i).to.eql(container.getChildIndex(children[i])); + } + }); + + it('throws error when trying to set incorect index', function() { + var container = new PIXI.DisplayObjectContainer(); + var child = new PIXI.DisplayObject(); + container.addChild(child); + + expect(function() { container.setChildIndex(child, -1); }).to.throw(); + expect(function() { container.setChildIndex(child, 1); }).to.throw(); + }); +}); diff --git a/test/unit/pixi-v2/display/MovieClip.js b/test/unit/pixi-v2/display/MovieClip.js new file mode 100644 index 0000000..f3c6c6a --- /dev/null +++ b/test/unit/pixi-v2/display/MovieClip.js @@ -0,0 +1,33 @@ +describe('pixi/display/MovieClip', function () { + 'use strict'; + + var expect = chai.expect; + var MovieClip = PIXI.MovieClip; + var Texture = PIXI.Texture; + + it('Module exists', function () { + expect(MovieClip).to.be.a('function'); + }); + + it('Confirm new instance', function (done) { + var texture = Texture.fromImage('/base/test/textures/SpriteSheet-Explosion.png'); + var obj = new MovieClip([texture]); + + pixi_display_Sprite_confirmNew(obj, done); + + expect(obj).to.be.an.instanceof(MovieClip); + expect(obj).to.respondTo('stop'); + expect(obj).to.respondTo('play'); + expect(obj).to.respondTo('gotoAndStop'); + expect(obj).to.respondTo('gotoAndPlay'); + expect(obj).to.respondTo('updateTransform'); + + expect(obj).to.have.deep.property('textures.length', 1); + expect(obj).to.have.deep.property('textures[0]', texture); + expect(obj).to.have.property('animationSpeed', 1); + expect(obj).to.have.property('loop', true); + expect(obj).to.have.property('onComplete', null); + expect(obj).to.have.property('currentFrame', 0); + expect(obj).to.have.property('playing', false); + }); +}); diff --git a/test/unit/pixi-v2/display/Sprite.js b/test/unit/pixi-v2/display/Sprite.js new file mode 100644 index 0000000..30c8076 --- /dev/null +++ b/test/unit/pixi-v2/display/Sprite.js @@ -0,0 +1,28 @@ +describe('pixi/display/Sprite', function () { + 'use strict'; + + var expect = chai.expect; + var Sprite = PIXI.Sprite; + var Texture = PIXI.Texture; + + it('Module exists', function () { + expect(Sprite).to.be.a('function'); + expect(PIXI).to.have.deep.property('blendModes.NORMAL', 0); + expect(PIXI).to.have.deep.property('blendModes.ADD', 1); + expect(PIXI).to.have.deep.property('blendModes.MULTIPLY', 2); + expect(PIXI).to.have.deep.property('blendModes.SCREEN', 3); + }); + + + it('Members exist', function () { + expect(Sprite).itself.to.respondTo('fromImage'); + expect(Sprite).itself.to.respondTo('fromFrame'); + }); + + it('Confirm new instance', function (done) { + var texture = Texture.fromImage('/base/test/textures/SpriteSheet-Aliens.png'); + var obj = new Sprite(texture); + + pixi_display_Sprite_confirmNew(obj, done); + }); +}); diff --git a/test/unit/pixi-v2/display/Stage.js b/test/unit/pixi-v2/display/Stage.js new file mode 100644 index 0000000..6974c2e --- /dev/null +++ b/test/unit/pixi-v2/display/Stage.js @@ -0,0 +1,49 @@ +describe('pixi/display/Stage', function () { + 'use strict'; + + var expect = chai.expect; + var Stage = PIXI.Stage; + var InteractionManager = PIXI.InteractionManager; + var Rectangle = PIXI.Rectangle; + + it('Module exists', function () { + expect(Stage).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Stage(null, true); + + pixi_display_DisplayObjectContainer_confirmNew(obj); + + expect(obj).to.be.an.instanceof(Stage); + expect(obj).to.respondTo('updateTransform'); + expect(obj).to.respondTo('setBackgroundColor'); + expect(obj).to.respondTo('getMousePosition'); + // FIXME: duplicate member in DisplayObject + pixi_core_Matrix_confirmNewMatrix(obj.worldTransform); + // FIXME: convert arg to bool in constructor + expect(obj).to.have.property('interactive', true); + + expect(obj).to.have.property('interactionManager') + .and.to.be.an.instanceof(InteractionManager) + .and.to.have.property('stage', obj); + + expect(obj).to.have.property('dirty', true); + + expect(obj).to.have.property('stage', obj); + + expect(obj).to.have.property('hitArea') + .and.to.be.an.instanceof(Rectangle); + pixi_core_Rectangle_confirm(obj.hitArea, 0, 0, 100000, 100000); + + expect(obj).to.have.property('backgroundColor', 0x000000); + expect(obj).to.have.deep.property('backgroundColorSplit.length', 3); + expect(obj).to.have.deep.property('backgroundColorSplit[0]', 0); + expect(obj).to.have.deep.property('backgroundColorSplit[1]', 0); + expect(obj).to.have.deep.property('backgroundColorSplit[2]', 0); + expect(obj).to.have.property('backgroundColorString', '#000000'); + + + expect(obj).to.have.property('worldVisible', true); + }); +}); diff --git a/test/unit/pixi-v2/extras/Rope.js b/test/unit/pixi-v2/extras/Rope.js new file mode 100644 index 0000000..05885ac --- /dev/null +++ b/test/unit/pixi-v2/extras/Rope.js @@ -0,0 +1,31 @@ +describe('pixi/extras/Rope', function () { + 'use strict'; + + var expect = chai.expect; + var Rope = PIXI.Rope; + var Texture = PIXI.Texture; + var Point = PIXI.Point; + + it('Module exists', function () { + expect(Rope).to.be.a('function'); + }); + + it('Confirm new instance', function () { + + var texture = Texture.fromImage('/base/test/textures/bunny.png'); + + // TODO-Alvin + // Same as Strip + + // var obj = new Rope(texture, [new Point(), new Point(5, 10), new Point(10, 20)]); + + // pixi_extras_Strip_confirmNew(obj); + + // expect(obj).to.be.an.instanceof(Rope); + // expect(obj).to.respondTo('refresh'); + // expect(obj).to.respondTo('updateTransform'); + // expect(obj).to.respondTo('setTexture'); + + // TODO: Test properties + }); +}); diff --git a/test/unit/pixi-v2/extras/Spine.js b/test/unit/pixi-v2/extras/Spine.js new file mode 100644 index 0000000..0708bc0 --- /dev/null +++ b/test/unit/pixi-v2/extras/Spine.js @@ -0,0 +1,10 @@ +describe('pixi/extras/Spine', function () { + 'use strict'; + + var expect = chai.expect; + var Spine = PIXI.Spine; + + it('Module exists', function () { + expect(Spine).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/InteractionManager.js b/test/unit/pixi-v2/InteractionManager.js new file mode 100644 index 0000000..ed3001f --- /dev/null +++ b/test/unit/pixi-v2/InteractionManager.js @@ -0,0 +1,10 @@ +describe('pixi/InteractionManager', function () { + 'use strict'; + + var expect = chai.expect; + var InteractionManager = PIXI.InteractionManager; + + it('Module exists', function () { + expect(InteractionManager).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/Pixi.js b/test/unit/pixi-v2/Pixi.js new file mode 100644 index 0000000..27debc1 --- /dev/null +++ b/test/unit/pixi-v2/Pixi.js @@ -0,0 +1,9 @@ +describe('pixi/Pixi', function () { + 'use strict'; + + var expect = chai.expect; + + it('Module exists', function () { + expect(global).to.have.property('PIXI').and.to.be.an('object'); + }); +}); diff --git a/test/unit/pixi-v2/core/Circle.js b/test/unit/pixi-v2/core/Circle.js new file mode 100644 index 0000000..fbcfa17 --- /dev/null +++ b/test/unit/pixi-v2/core/Circle.js @@ -0,0 +1,21 @@ +describe('pixi/core/Circle', function () { + 'use strict'; + + var expect = chai.expect; + var Circle = PIXI.Circle; + + it('Module exists', function () { + expect(Circle).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Circle(); + pixi_core_Circle_confirmNewCircle(obj); + }); + + it("getBounds should return Rectangle that bounds the circle", function() { + var obj = new Circle(100, 250, 50); + var bounds = obj.getBounds(); + pixi_core_Circle_isBoundedByRectangle(obj, bounds); + }); +}); diff --git a/test/unit/pixi-v2/core/Ellipse.js b/test/unit/pixi-v2/core/Ellipse.js new file mode 100644 index 0000000..026b56f --- /dev/null +++ b/test/unit/pixi-v2/core/Ellipse.js @@ -0,0 +1,24 @@ +describe('pixi/core/Ellipse', function () { + 'use strict'; + + var expect = chai.expect; + var Ellipse = PIXI.Ellipse; + + it('Module exists', function () { + expect(Ellipse).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Ellipse(); + + expect(obj).to.be.an.instanceof(Ellipse); + expect(obj).to.respondTo('clone'); + expect(obj).to.respondTo('contains'); + expect(obj).to.respondTo('getBounds'); + + expect(obj).to.have.property('x', 0); + expect(obj).to.have.property('y', 0); + expect(obj).to.have.property('width', 0); + expect(obj).to.have.property('height', 0); + }); +}); diff --git a/test/unit/pixi-v2/core/Matrix.js b/test/unit/pixi-v2/core/Matrix.js new file mode 100644 index 0000000..da75e2e --- /dev/null +++ b/test/unit/pixi-v2/core/Matrix.js @@ -0,0 +1,14 @@ +describe('pixi/core/Matrix', function () { + 'use strict'; + + var expect = chai.expect; + + it('Matrix exists', function () { + expect(PIXI.Matrix).to.be.an('function'); + }); + + it('Confirm new Matrix', function () { + var matrix = new PIXI.Matrix(); + pixi_core_Matrix_confirmNewMatrix(matrix); + }); +}); diff --git a/test/unit/pixi-v2/core/Point.js b/test/unit/pixi-v2/core/Point.js new file mode 100644 index 0000000..c4d5163 --- /dev/null +++ b/test/unit/pixi-v2/core/Point.js @@ -0,0 +1,15 @@ +describe('pixi/core/Point', function () { + 'use strict'; + + var expect = chai.expect; + var Point = PIXI.Point; + + it('Module exists', function () { + expect(Point).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Point(); + pixi_core_Point_confirm(obj, 0, 0); + }); +}); diff --git a/test/unit/pixi-v2/core/Polygon.js b/test/unit/pixi-v2/core/Polygon.js new file mode 100644 index 0000000..dc8c918 --- /dev/null +++ b/test/unit/pixi-v2/core/Polygon.js @@ -0,0 +1,20 @@ +describe('pixi/core/Polygon', function () { + 'use strict'; + + var expect = chai.expect; + var Polygon = PIXI.Polygon; + + it('Module exists', function () { + expect(Polygon).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Polygon(); + + expect(obj).to.be.an.instanceof(Polygon); + expect(obj).to.respondTo('clone'); + expect(obj).to.respondTo('contains'); + + expect(obj).to.have.deep.property('points.length', 0); + }); +}); diff --git a/test/unit/pixi-v2/core/Rectangle.js b/test/unit/pixi-v2/core/Rectangle.js new file mode 100644 index 0000000..d43316e --- /dev/null +++ b/test/unit/pixi-v2/core/Rectangle.js @@ -0,0 +1,15 @@ +describe('pixi/core/Rectangle', function () { + 'use strict'; + + var expect = chai.expect; + var Rectangle = PIXI.Rectangle; + + it('Module exists', function () { + expect(Rectangle).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var rect = new Rectangle(); + pixi_core_Rectangle_confirm(rect, 0, 0, 0, 0); + }); +}); diff --git a/test/unit/pixi-v2/display/DisplayObject.js b/test/unit/pixi-v2/display/DisplayObject.js new file mode 100644 index 0000000..044acf8 --- /dev/null +++ b/test/unit/pixi-v2/display/DisplayObject.js @@ -0,0 +1,21 @@ +describe('pixi/display/DisplayObject', function () { + 'use strict'; + + var expect = chai.expect; + var DisplayObject = PIXI.DisplayObject; + + it('Module exists', function () { + expect(DisplayObject).to.be.a('function'); + // expect(PIXI).to.have.property('visibleCount', 0); + }); + + it('Confirm new instance', function () { + var obj = new DisplayObject(); + + pixi_display_DisplayObject_confirmNew(obj); + expect(obj).to.have.property('hitArea', null); + expect(obj).to.have.property('interactive', false); + expect(obj).to.have.property('renderable', false); + expect(obj).to.have.property('stage', null); + }); +}); diff --git a/test/unit/pixi-v2/display/DisplayObjectContainer.js b/test/unit/pixi-v2/display/DisplayObjectContainer.js new file mode 100644 index 0000000..15a3376 --- /dev/null +++ b/test/unit/pixi-v2/display/DisplayObjectContainer.js @@ -0,0 +1,67 @@ +describe('pixi/display/DisplayObjectContainer', function () { + 'use strict'; + + var expect = chai.expect; + var DisplayObjectContainer = PIXI.DisplayObjectContainer; + + it('Module exists', function () { + expect(DisplayObjectContainer).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new DisplayObjectContainer(); + + pixi_display_DisplayObjectContainer_confirmNew(obj); + expect(obj).to.have.property('hitArea', null); + expect(obj).to.have.property('interactive', false); + expect(obj).to.have.property('renderable', false); + expect(obj).to.have.property('stage', null); + }); + + it('Gets child index', function() { + var container = new PIXI.DisplayObjectContainer(); + var children = []; + for (var i = 0; i < 10; i++) { + var child = new PIXI.DisplayObject(); + children.push(child); + container.addChild(child); + } + + for (i = 0; i < children.length; i++) { + expect(i).to.eql(container.getChildIndex(children[i])); + } + }); + + it('throws error when trying to get index of not a child', function() { + var container = new PIXI.DisplayObjectContainer(); + var child = new PIXI.DisplayObject(); + + expect(function() { container.getChildIndex(child); }).to.throw(); + }); + + it('Sets child index', function() { + var container = new PIXI.DisplayObjectContainer(); + var children = []; + + for (var i = 0; i < 10; i++) { + var child = new PIXI.DisplayObject(); + children.push(child); + container.addChild(child); + } + children.reverse(); + + for (i = 0; i < children.length; i++) { + container.setChildIndex(children[i], i); + expect(i).to.eql(container.getChildIndex(children[i])); + } + }); + + it('throws error when trying to set incorect index', function() { + var container = new PIXI.DisplayObjectContainer(); + var child = new PIXI.DisplayObject(); + container.addChild(child); + + expect(function() { container.setChildIndex(child, -1); }).to.throw(); + expect(function() { container.setChildIndex(child, 1); }).to.throw(); + }); +}); diff --git a/test/unit/pixi-v2/display/MovieClip.js b/test/unit/pixi-v2/display/MovieClip.js new file mode 100644 index 0000000..f3c6c6a --- /dev/null +++ b/test/unit/pixi-v2/display/MovieClip.js @@ -0,0 +1,33 @@ +describe('pixi/display/MovieClip', function () { + 'use strict'; + + var expect = chai.expect; + var MovieClip = PIXI.MovieClip; + var Texture = PIXI.Texture; + + it('Module exists', function () { + expect(MovieClip).to.be.a('function'); + }); + + it('Confirm new instance', function (done) { + var texture = Texture.fromImage('/base/test/textures/SpriteSheet-Explosion.png'); + var obj = new MovieClip([texture]); + + pixi_display_Sprite_confirmNew(obj, done); + + expect(obj).to.be.an.instanceof(MovieClip); + expect(obj).to.respondTo('stop'); + expect(obj).to.respondTo('play'); + expect(obj).to.respondTo('gotoAndStop'); + expect(obj).to.respondTo('gotoAndPlay'); + expect(obj).to.respondTo('updateTransform'); + + expect(obj).to.have.deep.property('textures.length', 1); + expect(obj).to.have.deep.property('textures[0]', texture); + expect(obj).to.have.property('animationSpeed', 1); + expect(obj).to.have.property('loop', true); + expect(obj).to.have.property('onComplete', null); + expect(obj).to.have.property('currentFrame', 0); + expect(obj).to.have.property('playing', false); + }); +}); diff --git a/test/unit/pixi-v2/display/Sprite.js b/test/unit/pixi-v2/display/Sprite.js new file mode 100644 index 0000000..30c8076 --- /dev/null +++ b/test/unit/pixi-v2/display/Sprite.js @@ -0,0 +1,28 @@ +describe('pixi/display/Sprite', function () { + 'use strict'; + + var expect = chai.expect; + var Sprite = PIXI.Sprite; + var Texture = PIXI.Texture; + + it('Module exists', function () { + expect(Sprite).to.be.a('function'); + expect(PIXI).to.have.deep.property('blendModes.NORMAL', 0); + expect(PIXI).to.have.deep.property('blendModes.ADD', 1); + expect(PIXI).to.have.deep.property('blendModes.MULTIPLY', 2); + expect(PIXI).to.have.deep.property('blendModes.SCREEN', 3); + }); + + + it('Members exist', function () { + expect(Sprite).itself.to.respondTo('fromImage'); + expect(Sprite).itself.to.respondTo('fromFrame'); + }); + + it('Confirm new instance', function (done) { + var texture = Texture.fromImage('/base/test/textures/SpriteSheet-Aliens.png'); + var obj = new Sprite(texture); + + pixi_display_Sprite_confirmNew(obj, done); + }); +}); diff --git a/test/unit/pixi-v2/display/Stage.js b/test/unit/pixi-v2/display/Stage.js new file mode 100644 index 0000000..6974c2e --- /dev/null +++ b/test/unit/pixi-v2/display/Stage.js @@ -0,0 +1,49 @@ +describe('pixi/display/Stage', function () { + 'use strict'; + + var expect = chai.expect; + var Stage = PIXI.Stage; + var InteractionManager = PIXI.InteractionManager; + var Rectangle = PIXI.Rectangle; + + it('Module exists', function () { + expect(Stage).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Stage(null, true); + + pixi_display_DisplayObjectContainer_confirmNew(obj); + + expect(obj).to.be.an.instanceof(Stage); + expect(obj).to.respondTo('updateTransform'); + expect(obj).to.respondTo('setBackgroundColor'); + expect(obj).to.respondTo('getMousePosition'); + // FIXME: duplicate member in DisplayObject + pixi_core_Matrix_confirmNewMatrix(obj.worldTransform); + // FIXME: convert arg to bool in constructor + expect(obj).to.have.property('interactive', true); + + expect(obj).to.have.property('interactionManager') + .and.to.be.an.instanceof(InteractionManager) + .and.to.have.property('stage', obj); + + expect(obj).to.have.property('dirty', true); + + expect(obj).to.have.property('stage', obj); + + expect(obj).to.have.property('hitArea') + .and.to.be.an.instanceof(Rectangle); + pixi_core_Rectangle_confirm(obj.hitArea, 0, 0, 100000, 100000); + + expect(obj).to.have.property('backgroundColor', 0x000000); + expect(obj).to.have.deep.property('backgroundColorSplit.length', 3); + expect(obj).to.have.deep.property('backgroundColorSplit[0]', 0); + expect(obj).to.have.deep.property('backgroundColorSplit[1]', 0); + expect(obj).to.have.deep.property('backgroundColorSplit[2]', 0); + expect(obj).to.have.property('backgroundColorString', '#000000'); + + + expect(obj).to.have.property('worldVisible', true); + }); +}); diff --git a/test/unit/pixi-v2/extras/Rope.js b/test/unit/pixi-v2/extras/Rope.js new file mode 100644 index 0000000..05885ac --- /dev/null +++ b/test/unit/pixi-v2/extras/Rope.js @@ -0,0 +1,31 @@ +describe('pixi/extras/Rope', function () { + 'use strict'; + + var expect = chai.expect; + var Rope = PIXI.Rope; + var Texture = PIXI.Texture; + var Point = PIXI.Point; + + it('Module exists', function () { + expect(Rope).to.be.a('function'); + }); + + it('Confirm new instance', function () { + + var texture = Texture.fromImage('/base/test/textures/bunny.png'); + + // TODO-Alvin + // Same as Strip + + // var obj = new Rope(texture, [new Point(), new Point(5, 10), new Point(10, 20)]); + + // pixi_extras_Strip_confirmNew(obj); + + // expect(obj).to.be.an.instanceof(Rope); + // expect(obj).to.respondTo('refresh'); + // expect(obj).to.respondTo('updateTransform'); + // expect(obj).to.respondTo('setTexture'); + + // TODO: Test properties + }); +}); diff --git a/test/unit/pixi-v2/extras/Spine.js b/test/unit/pixi-v2/extras/Spine.js new file mode 100644 index 0000000..0708bc0 --- /dev/null +++ b/test/unit/pixi-v2/extras/Spine.js @@ -0,0 +1,10 @@ +describe('pixi/extras/Spine', function () { + 'use strict'; + + var expect = chai.expect; + var Spine = PIXI.Spine; + + it('Module exists', function () { + expect(Spine).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/extras/Strip.js b/test/unit/pixi-v2/extras/Strip.js new file mode 100644 index 0000000..230af90 --- /dev/null +++ b/test/unit/pixi-v2/extras/Strip.js @@ -0,0 +1,26 @@ +describe('pixi/extras/Strip', function () { + 'use strict'; + + var expect = chai.expect; + var Strip = PIXI.Strip; + var Texture = PIXI.Texture; + + it('Module exists', function () { + expect(Strip).to.be.a('function'); + }); + + it('Confirm new instance', function () { + + + // TODO-Alvin + // We tweaked it to make it pass the tests, but the whole strip class needs + // to be re-coded + + var texture = Texture.fromImage('/base/test/textures/bunny.png'); + + // var obj = new Strip(texture, 20, 10000); + + + // pixi_extras_Strip_confirmNew(obj); + }); +}); diff --git a/test/unit/pixi-v2/InteractionManager.js b/test/unit/pixi-v2/InteractionManager.js new file mode 100644 index 0000000..ed3001f --- /dev/null +++ b/test/unit/pixi-v2/InteractionManager.js @@ -0,0 +1,10 @@ +describe('pixi/InteractionManager', function () { + 'use strict'; + + var expect = chai.expect; + var InteractionManager = PIXI.InteractionManager; + + it('Module exists', function () { + expect(InteractionManager).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/Pixi.js b/test/unit/pixi-v2/Pixi.js new file mode 100644 index 0000000..27debc1 --- /dev/null +++ b/test/unit/pixi-v2/Pixi.js @@ -0,0 +1,9 @@ +describe('pixi/Pixi', function () { + 'use strict'; + + var expect = chai.expect; + + it('Module exists', function () { + expect(global).to.have.property('PIXI').and.to.be.an('object'); + }); +}); diff --git a/test/unit/pixi-v2/core/Circle.js b/test/unit/pixi-v2/core/Circle.js new file mode 100644 index 0000000..fbcfa17 --- /dev/null +++ b/test/unit/pixi-v2/core/Circle.js @@ -0,0 +1,21 @@ +describe('pixi/core/Circle', function () { + 'use strict'; + + var expect = chai.expect; + var Circle = PIXI.Circle; + + it('Module exists', function () { + expect(Circle).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Circle(); + pixi_core_Circle_confirmNewCircle(obj); + }); + + it("getBounds should return Rectangle that bounds the circle", function() { + var obj = new Circle(100, 250, 50); + var bounds = obj.getBounds(); + pixi_core_Circle_isBoundedByRectangle(obj, bounds); + }); +}); diff --git a/test/unit/pixi-v2/core/Ellipse.js b/test/unit/pixi-v2/core/Ellipse.js new file mode 100644 index 0000000..026b56f --- /dev/null +++ b/test/unit/pixi-v2/core/Ellipse.js @@ -0,0 +1,24 @@ +describe('pixi/core/Ellipse', function () { + 'use strict'; + + var expect = chai.expect; + var Ellipse = PIXI.Ellipse; + + it('Module exists', function () { + expect(Ellipse).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Ellipse(); + + expect(obj).to.be.an.instanceof(Ellipse); + expect(obj).to.respondTo('clone'); + expect(obj).to.respondTo('contains'); + expect(obj).to.respondTo('getBounds'); + + expect(obj).to.have.property('x', 0); + expect(obj).to.have.property('y', 0); + expect(obj).to.have.property('width', 0); + expect(obj).to.have.property('height', 0); + }); +}); diff --git a/test/unit/pixi-v2/core/Matrix.js b/test/unit/pixi-v2/core/Matrix.js new file mode 100644 index 0000000..da75e2e --- /dev/null +++ b/test/unit/pixi-v2/core/Matrix.js @@ -0,0 +1,14 @@ +describe('pixi/core/Matrix', function () { + 'use strict'; + + var expect = chai.expect; + + it('Matrix exists', function () { + expect(PIXI.Matrix).to.be.an('function'); + }); + + it('Confirm new Matrix', function () { + var matrix = new PIXI.Matrix(); + pixi_core_Matrix_confirmNewMatrix(matrix); + }); +}); diff --git a/test/unit/pixi-v2/core/Point.js b/test/unit/pixi-v2/core/Point.js new file mode 100644 index 0000000..c4d5163 --- /dev/null +++ b/test/unit/pixi-v2/core/Point.js @@ -0,0 +1,15 @@ +describe('pixi/core/Point', function () { + 'use strict'; + + var expect = chai.expect; + var Point = PIXI.Point; + + it('Module exists', function () { + expect(Point).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Point(); + pixi_core_Point_confirm(obj, 0, 0); + }); +}); diff --git a/test/unit/pixi-v2/core/Polygon.js b/test/unit/pixi-v2/core/Polygon.js new file mode 100644 index 0000000..dc8c918 --- /dev/null +++ b/test/unit/pixi-v2/core/Polygon.js @@ -0,0 +1,20 @@ +describe('pixi/core/Polygon', function () { + 'use strict'; + + var expect = chai.expect; + var Polygon = PIXI.Polygon; + + it('Module exists', function () { + expect(Polygon).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Polygon(); + + expect(obj).to.be.an.instanceof(Polygon); + expect(obj).to.respondTo('clone'); + expect(obj).to.respondTo('contains'); + + expect(obj).to.have.deep.property('points.length', 0); + }); +}); diff --git a/test/unit/pixi-v2/core/Rectangle.js b/test/unit/pixi-v2/core/Rectangle.js new file mode 100644 index 0000000..d43316e --- /dev/null +++ b/test/unit/pixi-v2/core/Rectangle.js @@ -0,0 +1,15 @@ +describe('pixi/core/Rectangle', function () { + 'use strict'; + + var expect = chai.expect; + var Rectangle = PIXI.Rectangle; + + it('Module exists', function () { + expect(Rectangle).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var rect = new Rectangle(); + pixi_core_Rectangle_confirm(rect, 0, 0, 0, 0); + }); +}); diff --git a/test/unit/pixi-v2/display/DisplayObject.js b/test/unit/pixi-v2/display/DisplayObject.js new file mode 100644 index 0000000..044acf8 --- /dev/null +++ b/test/unit/pixi-v2/display/DisplayObject.js @@ -0,0 +1,21 @@ +describe('pixi/display/DisplayObject', function () { + 'use strict'; + + var expect = chai.expect; + var DisplayObject = PIXI.DisplayObject; + + it('Module exists', function () { + expect(DisplayObject).to.be.a('function'); + // expect(PIXI).to.have.property('visibleCount', 0); + }); + + it('Confirm new instance', function () { + var obj = new DisplayObject(); + + pixi_display_DisplayObject_confirmNew(obj); + expect(obj).to.have.property('hitArea', null); + expect(obj).to.have.property('interactive', false); + expect(obj).to.have.property('renderable', false); + expect(obj).to.have.property('stage', null); + }); +}); diff --git a/test/unit/pixi-v2/display/DisplayObjectContainer.js b/test/unit/pixi-v2/display/DisplayObjectContainer.js new file mode 100644 index 0000000..15a3376 --- /dev/null +++ b/test/unit/pixi-v2/display/DisplayObjectContainer.js @@ -0,0 +1,67 @@ +describe('pixi/display/DisplayObjectContainer', function () { + 'use strict'; + + var expect = chai.expect; + var DisplayObjectContainer = PIXI.DisplayObjectContainer; + + it('Module exists', function () { + expect(DisplayObjectContainer).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new DisplayObjectContainer(); + + pixi_display_DisplayObjectContainer_confirmNew(obj); + expect(obj).to.have.property('hitArea', null); + expect(obj).to.have.property('interactive', false); + expect(obj).to.have.property('renderable', false); + expect(obj).to.have.property('stage', null); + }); + + it('Gets child index', function() { + var container = new PIXI.DisplayObjectContainer(); + var children = []; + for (var i = 0; i < 10; i++) { + var child = new PIXI.DisplayObject(); + children.push(child); + container.addChild(child); + } + + for (i = 0; i < children.length; i++) { + expect(i).to.eql(container.getChildIndex(children[i])); + } + }); + + it('throws error when trying to get index of not a child', function() { + var container = new PIXI.DisplayObjectContainer(); + var child = new PIXI.DisplayObject(); + + expect(function() { container.getChildIndex(child); }).to.throw(); + }); + + it('Sets child index', function() { + var container = new PIXI.DisplayObjectContainer(); + var children = []; + + for (var i = 0; i < 10; i++) { + var child = new PIXI.DisplayObject(); + children.push(child); + container.addChild(child); + } + children.reverse(); + + for (i = 0; i < children.length; i++) { + container.setChildIndex(children[i], i); + expect(i).to.eql(container.getChildIndex(children[i])); + } + }); + + it('throws error when trying to set incorect index', function() { + var container = new PIXI.DisplayObjectContainer(); + var child = new PIXI.DisplayObject(); + container.addChild(child); + + expect(function() { container.setChildIndex(child, -1); }).to.throw(); + expect(function() { container.setChildIndex(child, 1); }).to.throw(); + }); +}); diff --git a/test/unit/pixi-v2/display/MovieClip.js b/test/unit/pixi-v2/display/MovieClip.js new file mode 100644 index 0000000..f3c6c6a --- /dev/null +++ b/test/unit/pixi-v2/display/MovieClip.js @@ -0,0 +1,33 @@ +describe('pixi/display/MovieClip', function () { + 'use strict'; + + var expect = chai.expect; + var MovieClip = PIXI.MovieClip; + var Texture = PIXI.Texture; + + it('Module exists', function () { + expect(MovieClip).to.be.a('function'); + }); + + it('Confirm new instance', function (done) { + var texture = Texture.fromImage('/base/test/textures/SpriteSheet-Explosion.png'); + var obj = new MovieClip([texture]); + + pixi_display_Sprite_confirmNew(obj, done); + + expect(obj).to.be.an.instanceof(MovieClip); + expect(obj).to.respondTo('stop'); + expect(obj).to.respondTo('play'); + expect(obj).to.respondTo('gotoAndStop'); + expect(obj).to.respondTo('gotoAndPlay'); + expect(obj).to.respondTo('updateTransform'); + + expect(obj).to.have.deep.property('textures.length', 1); + expect(obj).to.have.deep.property('textures[0]', texture); + expect(obj).to.have.property('animationSpeed', 1); + expect(obj).to.have.property('loop', true); + expect(obj).to.have.property('onComplete', null); + expect(obj).to.have.property('currentFrame', 0); + expect(obj).to.have.property('playing', false); + }); +}); diff --git a/test/unit/pixi-v2/display/Sprite.js b/test/unit/pixi-v2/display/Sprite.js new file mode 100644 index 0000000..30c8076 --- /dev/null +++ b/test/unit/pixi-v2/display/Sprite.js @@ -0,0 +1,28 @@ +describe('pixi/display/Sprite', function () { + 'use strict'; + + var expect = chai.expect; + var Sprite = PIXI.Sprite; + var Texture = PIXI.Texture; + + it('Module exists', function () { + expect(Sprite).to.be.a('function'); + expect(PIXI).to.have.deep.property('blendModes.NORMAL', 0); + expect(PIXI).to.have.deep.property('blendModes.ADD', 1); + expect(PIXI).to.have.deep.property('blendModes.MULTIPLY', 2); + expect(PIXI).to.have.deep.property('blendModes.SCREEN', 3); + }); + + + it('Members exist', function () { + expect(Sprite).itself.to.respondTo('fromImage'); + expect(Sprite).itself.to.respondTo('fromFrame'); + }); + + it('Confirm new instance', function (done) { + var texture = Texture.fromImage('/base/test/textures/SpriteSheet-Aliens.png'); + var obj = new Sprite(texture); + + pixi_display_Sprite_confirmNew(obj, done); + }); +}); diff --git a/test/unit/pixi-v2/display/Stage.js b/test/unit/pixi-v2/display/Stage.js new file mode 100644 index 0000000..6974c2e --- /dev/null +++ b/test/unit/pixi-v2/display/Stage.js @@ -0,0 +1,49 @@ +describe('pixi/display/Stage', function () { + 'use strict'; + + var expect = chai.expect; + var Stage = PIXI.Stage; + var InteractionManager = PIXI.InteractionManager; + var Rectangle = PIXI.Rectangle; + + it('Module exists', function () { + expect(Stage).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Stage(null, true); + + pixi_display_DisplayObjectContainer_confirmNew(obj); + + expect(obj).to.be.an.instanceof(Stage); + expect(obj).to.respondTo('updateTransform'); + expect(obj).to.respondTo('setBackgroundColor'); + expect(obj).to.respondTo('getMousePosition'); + // FIXME: duplicate member in DisplayObject + pixi_core_Matrix_confirmNewMatrix(obj.worldTransform); + // FIXME: convert arg to bool in constructor + expect(obj).to.have.property('interactive', true); + + expect(obj).to.have.property('interactionManager') + .and.to.be.an.instanceof(InteractionManager) + .and.to.have.property('stage', obj); + + expect(obj).to.have.property('dirty', true); + + expect(obj).to.have.property('stage', obj); + + expect(obj).to.have.property('hitArea') + .and.to.be.an.instanceof(Rectangle); + pixi_core_Rectangle_confirm(obj.hitArea, 0, 0, 100000, 100000); + + expect(obj).to.have.property('backgroundColor', 0x000000); + expect(obj).to.have.deep.property('backgroundColorSplit.length', 3); + expect(obj).to.have.deep.property('backgroundColorSplit[0]', 0); + expect(obj).to.have.deep.property('backgroundColorSplit[1]', 0); + expect(obj).to.have.deep.property('backgroundColorSplit[2]', 0); + expect(obj).to.have.property('backgroundColorString', '#000000'); + + + expect(obj).to.have.property('worldVisible', true); + }); +}); diff --git a/test/unit/pixi-v2/extras/Rope.js b/test/unit/pixi-v2/extras/Rope.js new file mode 100644 index 0000000..05885ac --- /dev/null +++ b/test/unit/pixi-v2/extras/Rope.js @@ -0,0 +1,31 @@ +describe('pixi/extras/Rope', function () { + 'use strict'; + + var expect = chai.expect; + var Rope = PIXI.Rope; + var Texture = PIXI.Texture; + var Point = PIXI.Point; + + it('Module exists', function () { + expect(Rope).to.be.a('function'); + }); + + it('Confirm new instance', function () { + + var texture = Texture.fromImage('/base/test/textures/bunny.png'); + + // TODO-Alvin + // Same as Strip + + // var obj = new Rope(texture, [new Point(), new Point(5, 10), new Point(10, 20)]); + + // pixi_extras_Strip_confirmNew(obj); + + // expect(obj).to.be.an.instanceof(Rope); + // expect(obj).to.respondTo('refresh'); + // expect(obj).to.respondTo('updateTransform'); + // expect(obj).to.respondTo('setTexture'); + + // TODO: Test properties + }); +}); diff --git a/test/unit/pixi-v2/extras/Spine.js b/test/unit/pixi-v2/extras/Spine.js new file mode 100644 index 0000000..0708bc0 --- /dev/null +++ b/test/unit/pixi-v2/extras/Spine.js @@ -0,0 +1,10 @@ +describe('pixi/extras/Spine', function () { + 'use strict'; + + var expect = chai.expect; + var Spine = PIXI.Spine; + + it('Module exists', function () { + expect(Spine).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/extras/Strip.js b/test/unit/pixi-v2/extras/Strip.js new file mode 100644 index 0000000..230af90 --- /dev/null +++ b/test/unit/pixi-v2/extras/Strip.js @@ -0,0 +1,26 @@ +describe('pixi/extras/Strip', function () { + 'use strict'; + + var expect = chai.expect; + var Strip = PIXI.Strip; + var Texture = PIXI.Texture; + + it('Module exists', function () { + expect(Strip).to.be.a('function'); + }); + + it('Confirm new instance', function () { + + + // TODO-Alvin + // We tweaked it to make it pass the tests, but the whole strip class needs + // to be re-coded + + var texture = Texture.fromImage('/base/test/textures/bunny.png'); + + // var obj = new Strip(texture, 20, 10000); + + + // pixi_extras_Strip_confirmNew(obj); + }); +}); diff --git a/test/unit/pixi-v2/extras/TilingSprite.js b/test/unit/pixi-v2/extras/TilingSprite.js new file mode 100644 index 0000000..56aea14 --- /dev/null +++ b/test/unit/pixi-v2/extras/TilingSprite.js @@ -0,0 +1,24 @@ +describe('pixi/extras/TilingSprite', function () { + 'use strict'; + + var expect = chai.expect; + var TilingSprite = PIXI.TilingSprite; + var Texture = PIXI.Texture; + + it('Module exists', function () { + expect(TilingSprite).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var texture = Texture.fromImage('/base/test/textures/bunny.png'); + var obj = new TilingSprite(texture, 6000, 12000); + + pixi_display_DisplayObjectContainer_confirmNew(obj); + + expect(obj).to.be.an.instanceof(TilingSprite); + expect(obj).to.respondTo('setTexture'); + expect(obj).to.respondTo('onTextureUpdate'); + + // TODO: Test properties + }); +}); diff --git a/test/unit/pixi-v2/InteractionManager.js b/test/unit/pixi-v2/InteractionManager.js new file mode 100644 index 0000000..ed3001f --- /dev/null +++ b/test/unit/pixi-v2/InteractionManager.js @@ -0,0 +1,10 @@ +describe('pixi/InteractionManager', function () { + 'use strict'; + + var expect = chai.expect; + var InteractionManager = PIXI.InteractionManager; + + it('Module exists', function () { + expect(InteractionManager).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/Pixi.js b/test/unit/pixi-v2/Pixi.js new file mode 100644 index 0000000..27debc1 --- /dev/null +++ b/test/unit/pixi-v2/Pixi.js @@ -0,0 +1,9 @@ +describe('pixi/Pixi', function () { + 'use strict'; + + var expect = chai.expect; + + it('Module exists', function () { + expect(global).to.have.property('PIXI').and.to.be.an('object'); + }); +}); diff --git a/test/unit/pixi-v2/core/Circle.js b/test/unit/pixi-v2/core/Circle.js new file mode 100644 index 0000000..fbcfa17 --- /dev/null +++ b/test/unit/pixi-v2/core/Circle.js @@ -0,0 +1,21 @@ +describe('pixi/core/Circle', function () { + 'use strict'; + + var expect = chai.expect; + var Circle = PIXI.Circle; + + it('Module exists', function () { + expect(Circle).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Circle(); + pixi_core_Circle_confirmNewCircle(obj); + }); + + it("getBounds should return Rectangle that bounds the circle", function() { + var obj = new Circle(100, 250, 50); + var bounds = obj.getBounds(); + pixi_core_Circle_isBoundedByRectangle(obj, bounds); + }); +}); diff --git a/test/unit/pixi-v2/core/Ellipse.js b/test/unit/pixi-v2/core/Ellipse.js new file mode 100644 index 0000000..026b56f --- /dev/null +++ b/test/unit/pixi-v2/core/Ellipse.js @@ -0,0 +1,24 @@ +describe('pixi/core/Ellipse', function () { + 'use strict'; + + var expect = chai.expect; + var Ellipse = PIXI.Ellipse; + + it('Module exists', function () { + expect(Ellipse).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Ellipse(); + + expect(obj).to.be.an.instanceof(Ellipse); + expect(obj).to.respondTo('clone'); + expect(obj).to.respondTo('contains'); + expect(obj).to.respondTo('getBounds'); + + expect(obj).to.have.property('x', 0); + expect(obj).to.have.property('y', 0); + expect(obj).to.have.property('width', 0); + expect(obj).to.have.property('height', 0); + }); +}); diff --git a/test/unit/pixi-v2/core/Matrix.js b/test/unit/pixi-v2/core/Matrix.js new file mode 100644 index 0000000..da75e2e --- /dev/null +++ b/test/unit/pixi-v2/core/Matrix.js @@ -0,0 +1,14 @@ +describe('pixi/core/Matrix', function () { + 'use strict'; + + var expect = chai.expect; + + it('Matrix exists', function () { + expect(PIXI.Matrix).to.be.an('function'); + }); + + it('Confirm new Matrix', function () { + var matrix = new PIXI.Matrix(); + pixi_core_Matrix_confirmNewMatrix(matrix); + }); +}); diff --git a/test/unit/pixi-v2/core/Point.js b/test/unit/pixi-v2/core/Point.js new file mode 100644 index 0000000..c4d5163 --- /dev/null +++ b/test/unit/pixi-v2/core/Point.js @@ -0,0 +1,15 @@ +describe('pixi/core/Point', function () { + 'use strict'; + + var expect = chai.expect; + var Point = PIXI.Point; + + it('Module exists', function () { + expect(Point).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Point(); + pixi_core_Point_confirm(obj, 0, 0); + }); +}); diff --git a/test/unit/pixi-v2/core/Polygon.js b/test/unit/pixi-v2/core/Polygon.js new file mode 100644 index 0000000..dc8c918 --- /dev/null +++ b/test/unit/pixi-v2/core/Polygon.js @@ -0,0 +1,20 @@ +describe('pixi/core/Polygon', function () { + 'use strict'; + + var expect = chai.expect; + var Polygon = PIXI.Polygon; + + it('Module exists', function () { + expect(Polygon).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Polygon(); + + expect(obj).to.be.an.instanceof(Polygon); + expect(obj).to.respondTo('clone'); + expect(obj).to.respondTo('contains'); + + expect(obj).to.have.deep.property('points.length', 0); + }); +}); diff --git a/test/unit/pixi-v2/core/Rectangle.js b/test/unit/pixi-v2/core/Rectangle.js new file mode 100644 index 0000000..d43316e --- /dev/null +++ b/test/unit/pixi-v2/core/Rectangle.js @@ -0,0 +1,15 @@ +describe('pixi/core/Rectangle', function () { + 'use strict'; + + var expect = chai.expect; + var Rectangle = PIXI.Rectangle; + + it('Module exists', function () { + expect(Rectangle).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var rect = new Rectangle(); + pixi_core_Rectangle_confirm(rect, 0, 0, 0, 0); + }); +}); diff --git a/test/unit/pixi-v2/display/DisplayObject.js b/test/unit/pixi-v2/display/DisplayObject.js new file mode 100644 index 0000000..044acf8 --- /dev/null +++ b/test/unit/pixi-v2/display/DisplayObject.js @@ -0,0 +1,21 @@ +describe('pixi/display/DisplayObject', function () { + 'use strict'; + + var expect = chai.expect; + var DisplayObject = PIXI.DisplayObject; + + it('Module exists', function () { + expect(DisplayObject).to.be.a('function'); + // expect(PIXI).to.have.property('visibleCount', 0); + }); + + it('Confirm new instance', function () { + var obj = new DisplayObject(); + + pixi_display_DisplayObject_confirmNew(obj); + expect(obj).to.have.property('hitArea', null); + expect(obj).to.have.property('interactive', false); + expect(obj).to.have.property('renderable', false); + expect(obj).to.have.property('stage', null); + }); +}); diff --git a/test/unit/pixi-v2/display/DisplayObjectContainer.js b/test/unit/pixi-v2/display/DisplayObjectContainer.js new file mode 100644 index 0000000..15a3376 --- /dev/null +++ b/test/unit/pixi-v2/display/DisplayObjectContainer.js @@ -0,0 +1,67 @@ +describe('pixi/display/DisplayObjectContainer', function () { + 'use strict'; + + var expect = chai.expect; + var DisplayObjectContainer = PIXI.DisplayObjectContainer; + + it('Module exists', function () { + expect(DisplayObjectContainer).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new DisplayObjectContainer(); + + pixi_display_DisplayObjectContainer_confirmNew(obj); + expect(obj).to.have.property('hitArea', null); + expect(obj).to.have.property('interactive', false); + expect(obj).to.have.property('renderable', false); + expect(obj).to.have.property('stage', null); + }); + + it('Gets child index', function() { + var container = new PIXI.DisplayObjectContainer(); + var children = []; + for (var i = 0; i < 10; i++) { + var child = new PIXI.DisplayObject(); + children.push(child); + container.addChild(child); + } + + for (i = 0; i < children.length; i++) { + expect(i).to.eql(container.getChildIndex(children[i])); + } + }); + + it('throws error when trying to get index of not a child', function() { + var container = new PIXI.DisplayObjectContainer(); + var child = new PIXI.DisplayObject(); + + expect(function() { container.getChildIndex(child); }).to.throw(); + }); + + it('Sets child index', function() { + var container = new PIXI.DisplayObjectContainer(); + var children = []; + + for (var i = 0; i < 10; i++) { + var child = new PIXI.DisplayObject(); + children.push(child); + container.addChild(child); + } + children.reverse(); + + for (i = 0; i < children.length; i++) { + container.setChildIndex(children[i], i); + expect(i).to.eql(container.getChildIndex(children[i])); + } + }); + + it('throws error when trying to set incorect index', function() { + var container = new PIXI.DisplayObjectContainer(); + var child = new PIXI.DisplayObject(); + container.addChild(child); + + expect(function() { container.setChildIndex(child, -1); }).to.throw(); + expect(function() { container.setChildIndex(child, 1); }).to.throw(); + }); +}); diff --git a/test/unit/pixi-v2/display/MovieClip.js b/test/unit/pixi-v2/display/MovieClip.js new file mode 100644 index 0000000..f3c6c6a --- /dev/null +++ b/test/unit/pixi-v2/display/MovieClip.js @@ -0,0 +1,33 @@ +describe('pixi/display/MovieClip', function () { + 'use strict'; + + var expect = chai.expect; + var MovieClip = PIXI.MovieClip; + var Texture = PIXI.Texture; + + it('Module exists', function () { + expect(MovieClip).to.be.a('function'); + }); + + it('Confirm new instance', function (done) { + var texture = Texture.fromImage('/base/test/textures/SpriteSheet-Explosion.png'); + var obj = new MovieClip([texture]); + + pixi_display_Sprite_confirmNew(obj, done); + + expect(obj).to.be.an.instanceof(MovieClip); + expect(obj).to.respondTo('stop'); + expect(obj).to.respondTo('play'); + expect(obj).to.respondTo('gotoAndStop'); + expect(obj).to.respondTo('gotoAndPlay'); + expect(obj).to.respondTo('updateTransform'); + + expect(obj).to.have.deep.property('textures.length', 1); + expect(obj).to.have.deep.property('textures[0]', texture); + expect(obj).to.have.property('animationSpeed', 1); + expect(obj).to.have.property('loop', true); + expect(obj).to.have.property('onComplete', null); + expect(obj).to.have.property('currentFrame', 0); + expect(obj).to.have.property('playing', false); + }); +}); diff --git a/test/unit/pixi-v2/display/Sprite.js b/test/unit/pixi-v2/display/Sprite.js new file mode 100644 index 0000000..30c8076 --- /dev/null +++ b/test/unit/pixi-v2/display/Sprite.js @@ -0,0 +1,28 @@ +describe('pixi/display/Sprite', function () { + 'use strict'; + + var expect = chai.expect; + var Sprite = PIXI.Sprite; + var Texture = PIXI.Texture; + + it('Module exists', function () { + expect(Sprite).to.be.a('function'); + expect(PIXI).to.have.deep.property('blendModes.NORMAL', 0); + expect(PIXI).to.have.deep.property('blendModes.ADD', 1); + expect(PIXI).to.have.deep.property('blendModes.MULTIPLY', 2); + expect(PIXI).to.have.deep.property('blendModes.SCREEN', 3); + }); + + + it('Members exist', function () { + expect(Sprite).itself.to.respondTo('fromImage'); + expect(Sprite).itself.to.respondTo('fromFrame'); + }); + + it('Confirm new instance', function (done) { + var texture = Texture.fromImage('/base/test/textures/SpriteSheet-Aliens.png'); + var obj = new Sprite(texture); + + pixi_display_Sprite_confirmNew(obj, done); + }); +}); diff --git a/test/unit/pixi-v2/display/Stage.js b/test/unit/pixi-v2/display/Stage.js new file mode 100644 index 0000000..6974c2e --- /dev/null +++ b/test/unit/pixi-v2/display/Stage.js @@ -0,0 +1,49 @@ +describe('pixi/display/Stage', function () { + 'use strict'; + + var expect = chai.expect; + var Stage = PIXI.Stage; + var InteractionManager = PIXI.InteractionManager; + var Rectangle = PIXI.Rectangle; + + it('Module exists', function () { + expect(Stage).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Stage(null, true); + + pixi_display_DisplayObjectContainer_confirmNew(obj); + + expect(obj).to.be.an.instanceof(Stage); + expect(obj).to.respondTo('updateTransform'); + expect(obj).to.respondTo('setBackgroundColor'); + expect(obj).to.respondTo('getMousePosition'); + // FIXME: duplicate member in DisplayObject + pixi_core_Matrix_confirmNewMatrix(obj.worldTransform); + // FIXME: convert arg to bool in constructor + expect(obj).to.have.property('interactive', true); + + expect(obj).to.have.property('interactionManager') + .and.to.be.an.instanceof(InteractionManager) + .and.to.have.property('stage', obj); + + expect(obj).to.have.property('dirty', true); + + expect(obj).to.have.property('stage', obj); + + expect(obj).to.have.property('hitArea') + .and.to.be.an.instanceof(Rectangle); + pixi_core_Rectangle_confirm(obj.hitArea, 0, 0, 100000, 100000); + + expect(obj).to.have.property('backgroundColor', 0x000000); + expect(obj).to.have.deep.property('backgroundColorSplit.length', 3); + expect(obj).to.have.deep.property('backgroundColorSplit[0]', 0); + expect(obj).to.have.deep.property('backgroundColorSplit[1]', 0); + expect(obj).to.have.deep.property('backgroundColorSplit[2]', 0); + expect(obj).to.have.property('backgroundColorString', '#000000'); + + + expect(obj).to.have.property('worldVisible', true); + }); +}); diff --git a/test/unit/pixi-v2/extras/Rope.js b/test/unit/pixi-v2/extras/Rope.js new file mode 100644 index 0000000..05885ac --- /dev/null +++ b/test/unit/pixi-v2/extras/Rope.js @@ -0,0 +1,31 @@ +describe('pixi/extras/Rope', function () { + 'use strict'; + + var expect = chai.expect; + var Rope = PIXI.Rope; + var Texture = PIXI.Texture; + var Point = PIXI.Point; + + it('Module exists', function () { + expect(Rope).to.be.a('function'); + }); + + it('Confirm new instance', function () { + + var texture = Texture.fromImage('/base/test/textures/bunny.png'); + + // TODO-Alvin + // Same as Strip + + // var obj = new Rope(texture, [new Point(), new Point(5, 10), new Point(10, 20)]); + + // pixi_extras_Strip_confirmNew(obj); + + // expect(obj).to.be.an.instanceof(Rope); + // expect(obj).to.respondTo('refresh'); + // expect(obj).to.respondTo('updateTransform'); + // expect(obj).to.respondTo('setTexture'); + + // TODO: Test properties + }); +}); diff --git a/test/unit/pixi-v2/extras/Spine.js b/test/unit/pixi-v2/extras/Spine.js new file mode 100644 index 0000000..0708bc0 --- /dev/null +++ b/test/unit/pixi-v2/extras/Spine.js @@ -0,0 +1,10 @@ +describe('pixi/extras/Spine', function () { + 'use strict'; + + var expect = chai.expect; + var Spine = PIXI.Spine; + + it('Module exists', function () { + expect(Spine).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/extras/Strip.js b/test/unit/pixi-v2/extras/Strip.js new file mode 100644 index 0000000..230af90 --- /dev/null +++ b/test/unit/pixi-v2/extras/Strip.js @@ -0,0 +1,26 @@ +describe('pixi/extras/Strip', function () { + 'use strict'; + + var expect = chai.expect; + var Strip = PIXI.Strip; + var Texture = PIXI.Texture; + + it('Module exists', function () { + expect(Strip).to.be.a('function'); + }); + + it('Confirm new instance', function () { + + + // TODO-Alvin + // We tweaked it to make it pass the tests, but the whole strip class needs + // to be re-coded + + var texture = Texture.fromImage('/base/test/textures/bunny.png'); + + // var obj = new Strip(texture, 20, 10000); + + + // pixi_extras_Strip_confirmNew(obj); + }); +}); diff --git a/test/unit/pixi-v2/extras/TilingSprite.js b/test/unit/pixi-v2/extras/TilingSprite.js new file mode 100644 index 0000000..56aea14 --- /dev/null +++ b/test/unit/pixi-v2/extras/TilingSprite.js @@ -0,0 +1,24 @@ +describe('pixi/extras/TilingSprite', function () { + 'use strict'; + + var expect = chai.expect; + var TilingSprite = PIXI.TilingSprite; + var Texture = PIXI.Texture; + + it('Module exists', function () { + expect(TilingSprite).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var texture = Texture.fromImage('/base/test/textures/bunny.png'); + var obj = new TilingSprite(texture, 6000, 12000); + + pixi_display_DisplayObjectContainer_confirmNew(obj); + + expect(obj).to.be.an.instanceof(TilingSprite); + expect(obj).to.respondTo('setTexture'); + expect(obj).to.respondTo('onTextureUpdate'); + + // TODO: Test properties + }); +}); diff --git a/test/unit/pixi-v2/filters/FilterBlock.js b/test/unit/pixi-v2/filters/FilterBlock.js new file mode 100644 index 0000000..870cec0 --- /dev/null +++ b/test/unit/pixi-v2/filters/FilterBlock.js @@ -0,0 +1,10 @@ +describe('pixi/filters/FilterBlock', function () { + 'use strict'; + + var expect = chai.expect; + var FilterBlock = PIXI.FilterBlock; + + it('Module exists', function () { + expect(FilterBlock).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/InteractionManager.js b/test/unit/pixi-v2/InteractionManager.js new file mode 100644 index 0000000..ed3001f --- /dev/null +++ b/test/unit/pixi-v2/InteractionManager.js @@ -0,0 +1,10 @@ +describe('pixi/InteractionManager', function () { + 'use strict'; + + var expect = chai.expect; + var InteractionManager = PIXI.InteractionManager; + + it('Module exists', function () { + expect(InteractionManager).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/Pixi.js b/test/unit/pixi-v2/Pixi.js new file mode 100644 index 0000000..27debc1 --- /dev/null +++ b/test/unit/pixi-v2/Pixi.js @@ -0,0 +1,9 @@ +describe('pixi/Pixi', function () { + 'use strict'; + + var expect = chai.expect; + + it('Module exists', function () { + expect(global).to.have.property('PIXI').and.to.be.an('object'); + }); +}); diff --git a/test/unit/pixi-v2/core/Circle.js b/test/unit/pixi-v2/core/Circle.js new file mode 100644 index 0000000..fbcfa17 --- /dev/null +++ b/test/unit/pixi-v2/core/Circle.js @@ -0,0 +1,21 @@ +describe('pixi/core/Circle', function () { + 'use strict'; + + var expect = chai.expect; + var Circle = PIXI.Circle; + + it('Module exists', function () { + expect(Circle).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Circle(); + pixi_core_Circle_confirmNewCircle(obj); + }); + + it("getBounds should return Rectangle that bounds the circle", function() { + var obj = new Circle(100, 250, 50); + var bounds = obj.getBounds(); + pixi_core_Circle_isBoundedByRectangle(obj, bounds); + }); +}); diff --git a/test/unit/pixi-v2/core/Ellipse.js b/test/unit/pixi-v2/core/Ellipse.js new file mode 100644 index 0000000..026b56f --- /dev/null +++ b/test/unit/pixi-v2/core/Ellipse.js @@ -0,0 +1,24 @@ +describe('pixi/core/Ellipse', function () { + 'use strict'; + + var expect = chai.expect; + var Ellipse = PIXI.Ellipse; + + it('Module exists', function () { + expect(Ellipse).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Ellipse(); + + expect(obj).to.be.an.instanceof(Ellipse); + expect(obj).to.respondTo('clone'); + expect(obj).to.respondTo('contains'); + expect(obj).to.respondTo('getBounds'); + + expect(obj).to.have.property('x', 0); + expect(obj).to.have.property('y', 0); + expect(obj).to.have.property('width', 0); + expect(obj).to.have.property('height', 0); + }); +}); diff --git a/test/unit/pixi-v2/core/Matrix.js b/test/unit/pixi-v2/core/Matrix.js new file mode 100644 index 0000000..da75e2e --- /dev/null +++ b/test/unit/pixi-v2/core/Matrix.js @@ -0,0 +1,14 @@ +describe('pixi/core/Matrix', function () { + 'use strict'; + + var expect = chai.expect; + + it('Matrix exists', function () { + expect(PIXI.Matrix).to.be.an('function'); + }); + + it('Confirm new Matrix', function () { + var matrix = new PIXI.Matrix(); + pixi_core_Matrix_confirmNewMatrix(matrix); + }); +}); diff --git a/test/unit/pixi-v2/core/Point.js b/test/unit/pixi-v2/core/Point.js new file mode 100644 index 0000000..c4d5163 --- /dev/null +++ b/test/unit/pixi-v2/core/Point.js @@ -0,0 +1,15 @@ +describe('pixi/core/Point', function () { + 'use strict'; + + var expect = chai.expect; + var Point = PIXI.Point; + + it('Module exists', function () { + expect(Point).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Point(); + pixi_core_Point_confirm(obj, 0, 0); + }); +}); diff --git a/test/unit/pixi-v2/core/Polygon.js b/test/unit/pixi-v2/core/Polygon.js new file mode 100644 index 0000000..dc8c918 --- /dev/null +++ b/test/unit/pixi-v2/core/Polygon.js @@ -0,0 +1,20 @@ +describe('pixi/core/Polygon', function () { + 'use strict'; + + var expect = chai.expect; + var Polygon = PIXI.Polygon; + + it('Module exists', function () { + expect(Polygon).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Polygon(); + + expect(obj).to.be.an.instanceof(Polygon); + expect(obj).to.respondTo('clone'); + expect(obj).to.respondTo('contains'); + + expect(obj).to.have.deep.property('points.length', 0); + }); +}); diff --git a/test/unit/pixi-v2/core/Rectangle.js b/test/unit/pixi-v2/core/Rectangle.js new file mode 100644 index 0000000..d43316e --- /dev/null +++ b/test/unit/pixi-v2/core/Rectangle.js @@ -0,0 +1,15 @@ +describe('pixi/core/Rectangle', function () { + 'use strict'; + + var expect = chai.expect; + var Rectangle = PIXI.Rectangle; + + it('Module exists', function () { + expect(Rectangle).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var rect = new Rectangle(); + pixi_core_Rectangle_confirm(rect, 0, 0, 0, 0); + }); +}); diff --git a/test/unit/pixi-v2/display/DisplayObject.js b/test/unit/pixi-v2/display/DisplayObject.js new file mode 100644 index 0000000..044acf8 --- /dev/null +++ b/test/unit/pixi-v2/display/DisplayObject.js @@ -0,0 +1,21 @@ +describe('pixi/display/DisplayObject', function () { + 'use strict'; + + var expect = chai.expect; + var DisplayObject = PIXI.DisplayObject; + + it('Module exists', function () { + expect(DisplayObject).to.be.a('function'); + // expect(PIXI).to.have.property('visibleCount', 0); + }); + + it('Confirm new instance', function () { + var obj = new DisplayObject(); + + pixi_display_DisplayObject_confirmNew(obj); + expect(obj).to.have.property('hitArea', null); + expect(obj).to.have.property('interactive', false); + expect(obj).to.have.property('renderable', false); + expect(obj).to.have.property('stage', null); + }); +}); diff --git a/test/unit/pixi-v2/display/DisplayObjectContainer.js b/test/unit/pixi-v2/display/DisplayObjectContainer.js new file mode 100644 index 0000000..15a3376 --- /dev/null +++ b/test/unit/pixi-v2/display/DisplayObjectContainer.js @@ -0,0 +1,67 @@ +describe('pixi/display/DisplayObjectContainer', function () { + 'use strict'; + + var expect = chai.expect; + var DisplayObjectContainer = PIXI.DisplayObjectContainer; + + it('Module exists', function () { + expect(DisplayObjectContainer).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new DisplayObjectContainer(); + + pixi_display_DisplayObjectContainer_confirmNew(obj); + expect(obj).to.have.property('hitArea', null); + expect(obj).to.have.property('interactive', false); + expect(obj).to.have.property('renderable', false); + expect(obj).to.have.property('stage', null); + }); + + it('Gets child index', function() { + var container = new PIXI.DisplayObjectContainer(); + var children = []; + for (var i = 0; i < 10; i++) { + var child = new PIXI.DisplayObject(); + children.push(child); + container.addChild(child); + } + + for (i = 0; i < children.length; i++) { + expect(i).to.eql(container.getChildIndex(children[i])); + } + }); + + it('throws error when trying to get index of not a child', function() { + var container = new PIXI.DisplayObjectContainer(); + var child = new PIXI.DisplayObject(); + + expect(function() { container.getChildIndex(child); }).to.throw(); + }); + + it('Sets child index', function() { + var container = new PIXI.DisplayObjectContainer(); + var children = []; + + for (var i = 0; i < 10; i++) { + var child = new PIXI.DisplayObject(); + children.push(child); + container.addChild(child); + } + children.reverse(); + + for (i = 0; i < children.length; i++) { + container.setChildIndex(children[i], i); + expect(i).to.eql(container.getChildIndex(children[i])); + } + }); + + it('throws error when trying to set incorect index', function() { + var container = new PIXI.DisplayObjectContainer(); + var child = new PIXI.DisplayObject(); + container.addChild(child); + + expect(function() { container.setChildIndex(child, -1); }).to.throw(); + expect(function() { container.setChildIndex(child, 1); }).to.throw(); + }); +}); diff --git a/test/unit/pixi-v2/display/MovieClip.js b/test/unit/pixi-v2/display/MovieClip.js new file mode 100644 index 0000000..f3c6c6a --- /dev/null +++ b/test/unit/pixi-v2/display/MovieClip.js @@ -0,0 +1,33 @@ +describe('pixi/display/MovieClip', function () { + 'use strict'; + + var expect = chai.expect; + var MovieClip = PIXI.MovieClip; + var Texture = PIXI.Texture; + + it('Module exists', function () { + expect(MovieClip).to.be.a('function'); + }); + + it('Confirm new instance', function (done) { + var texture = Texture.fromImage('/base/test/textures/SpriteSheet-Explosion.png'); + var obj = new MovieClip([texture]); + + pixi_display_Sprite_confirmNew(obj, done); + + expect(obj).to.be.an.instanceof(MovieClip); + expect(obj).to.respondTo('stop'); + expect(obj).to.respondTo('play'); + expect(obj).to.respondTo('gotoAndStop'); + expect(obj).to.respondTo('gotoAndPlay'); + expect(obj).to.respondTo('updateTransform'); + + expect(obj).to.have.deep.property('textures.length', 1); + expect(obj).to.have.deep.property('textures[0]', texture); + expect(obj).to.have.property('animationSpeed', 1); + expect(obj).to.have.property('loop', true); + expect(obj).to.have.property('onComplete', null); + expect(obj).to.have.property('currentFrame', 0); + expect(obj).to.have.property('playing', false); + }); +}); diff --git a/test/unit/pixi-v2/display/Sprite.js b/test/unit/pixi-v2/display/Sprite.js new file mode 100644 index 0000000..30c8076 --- /dev/null +++ b/test/unit/pixi-v2/display/Sprite.js @@ -0,0 +1,28 @@ +describe('pixi/display/Sprite', function () { + 'use strict'; + + var expect = chai.expect; + var Sprite = PIXI.Sprite; + var Texture = PIXI.Texture; + + it('Module exists', function () { + expect(Sprite).to.be.a('function'); + expect(PIXI).to.have.deep.property('blendModes.NORMAL', 0); + expect(PIXI).to.have.deep.property('blendModes.ADD', 1); + expect(PIXI).to.have.deep.property('blendModes.MULTIPLY', 2); + expect(PIXI).to.have.deep.property('blendModes.SCREEN', 3); + }); + + + it('Members exist', function () { + expect(Sprite).itself.to.respondTo('fromImage'); + expect(Sprite).itself.to.respondTo('fromFrame'); + }); + + it('Confirm new instance', function (done) { + var texture = Texture.fromImage('/base/test/textures/SpriteSheet-Aliens.png'); + var obj = new Sprite(texture); + + pixi_display_Sprite_confirmNew(obj, done); + }); +}); diff --git a/test/unit/pixi-v2/display/Stage.js b/test/unit/pixi-v2/display/Stage.js new file mode 100644 index 0000000..6974c2e --- /dev/null +++ b/test/unit/pixi-v2/display/Stage.js @@ -0,0 +1,49 @@ +describe('pixi/display/Stage', function () { + 'use strict'; + + var expect = chai.expect; + var Stage = PIXI.Stage; + var InteractionManager = PIXI.InteractionManager; + var Rectangle = PIXI.Rectangle; + + it('Module exists', function () { + expect(Stage).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Stage(null, true); + + pixi_display_DisplayObjectContainer_confirmNew(obj); + + expect(obj).to.be.an.instanceof(Stage); + expect(obj).to.respondTo('updateTransform'); + expect(obj).to.respondTo('setBackgroundColor'); + expect(obj).to.respondTo('getMousePosition'); + // FIXME: duplicate member in DisplayObject + pixi_core_Matrix_confirmNewMatrix(obj.worldTransform); + // FIXME: convert arg to bool in constructor + expect(obj).to.have.property('interactive', true); + + expect(obj).to.have.property('interactionManager') + .and.to.be.an.instanceof(InteractionManager) + .and.to.have.property('stage', obj); + + expect(obj).to.have.property('dirty', true); + + expect(obj).to.have.property('stage', obj); + + expect(obj).to.have.property('hitArea') + .and.to.be.an.instanceof(Rectangle); + pixi_core_Rectangle_confirm(obj.hitArea, 0, 0, 100000, 100000); + + expect(obj).to.have.property('backgroundColor', 0x000000); + expect(obj).to.have.deep.property('backgroundColorSplit.length', 3); + expect(obj).to.have.deep.property('backgroundColorSplit[0]', 0); + expect(obj).to.have.deep.property('backgroundColorSplit[1]', 0); + expect(obj).to.have.deep.property('backgroundColorSplit[2]', 0); + expect(obj).to.have.property('backgroundColorString', '#000000'); + + + expect(obj).to.have.property('worldVisible', true); + }); +}); diff --git a/test/unit/pixi-v2/extras/Rope.js b/test/unit/pixi-v2/extras/Rope.js new file mode 100644 index 0000000..05885ac --- /dev/null +++ b/test/unit/pixi-v2/extras/Rope.js @@ -0,0 +1,31 @@ +describe('pixi/extras/Rope', function () { + 'use strict'; + + var expect = chai.expect; + var Rope = PIXI.Rope; + var Texture = PIXI.Texture; + var Point = PIXI.Point; + + it('Module exists', function () { + expect(Rope).to.be.a('function'); + }); + + it('Confirm new instance', function () { + + var texture = Texture.fromImage('/base/test/textures/bunny.png'); + + // TODO-Alvin + // Same as Strip + + // var obj = new Rope(texture, [new Point(), new Point(5, 10), new Point(10, 20)]); + + // pixi_extras_Strip_confirmNew(obj); + + // expect(obj).to.be.an.instanceof(Rope); + // expect(obj).to.respondTo('refresh'); + // expect(obj).to.respondTo('updateTransform'); + // expect(obj).to.respondTo('setTexture'); + + // TODO: Test properties + }); +}); diff --git a/test/unit/pixi-v2/extras/Spine.js b/test/unit/pixi-v2/extras/Spine.js new file mode 100644 index 0000000..0708bc0 --- /dev/null +++ b/test/unit/pixi-v2/extras/Spine.js @@ -0,0 +1,10 @@ +describe('pixi/extras/Spine', function () { + 'use strict'; + + var expect = chai.expect; + var Spine = PIXI.Spine; + + it('Module exists', function () { + expect(Spine).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/extras/Strip.js b/test/unit/pixi-v2/extras/Strip.js new file mode 100644 index 0000000..230af90 --- /dev/null +++ b/test/unit/pixi-v2/extras/Strip.js @@ -0,0 +1,26 @@ +describe('pixi/extras/Strip', function () { + 'use strict'; + + var expect = chai.expect; + var Strip = PIXI.Strip; + var Texture = PIXI.Texture; + + it('Module exists', function () { + expect(Strip).to.be.a('function'); + }); + + it('Confirm new instance', function () { + + + // TODO-Alvin + // We tweaked it to make it pass the tests, but the whole strip class needs + // to be re-coded + + var texture = Texture.fromImage('/base/test/textures/bunny.png'); + + // var obj = new Strip(texture, 20, 10000); + + + // pixi_extras_Strip_confirmNew(obj); + }); +}); diff --git a/test/unit/pixi-v2/extras/TilingSprite.js b/test/unit/pixi-v2/extras/TilingSprite.js new file mode 100644 index 0000000..56aea14 --- /dev/null +++ b/test/unit/pixi-v2/extras/TilingSprite.js @@ -0,0 +1,24 @@ +describe('pixi/extras/TilingSprite', function () { + 'use strict'; + + var expect = chai.expect; + var TilingSprite = PIXI.TilingSprite; + var Texture = PIXI.Texture; + + it('Module exists', function () { + expect(TilingSprite).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var texture = Texture.fromImage('/base/test/textures/bunny.png'); + var obj = new TilingSprite(texture, 6000, 12000); + + pixi_display_DisplayObjectContainer_confirmNew(obj); + + expect(obj).to.be.an.instanceof(TilingSprite); + expect(obj).to.respondTo('setTexture'); + expect(obj).to.respondTo('onTextureUpdate'); + + // TODO: Test properties + }); +}); diff --git a/test/unit/pixi-v2/filters/FilterBlock.js b/test/unit/pixi-v2/filters/FilterBlock.js new file mode 100644 index 0000000..870cec0 --- /dev/null +++ b/test/unit/pixi-v2/filters/FilterBlock.js @@ -0,0 +1,10 @@ +describe('pixi/filters/FilterBlock', function () { + 'use strict'; + + var expect = chai.expect; + var FilterBlock = PIXI.FilterBlock; + + it('Module exists', function () { + expect(FilterBlock).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/AssetLoader.js b/test/unit/pixi-v2/loaders/AssetLoader.js new file mode 100644 index 0000000..a0aa0b5 --- /dev/null +++ b/test/unit/pixi-v2/loaders/AssetLoader.js @@ -0,0 +1,10 @@ +describe('pixi/loaders/AssetLoader', function () { + 'use strict'; + + var expect = chai.expect; + var AssetLoader = PIXI.AssetLoader; + + it('Module exists', function () { + expect(AssetLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/InteractionManager.js b/test/unit/pixi-v2/InteractionManager.js new file mode 100644 index 0000000..ed3001f --- /dev/null +++ b/test/unit/pixi-v2/InteractionManager.js @@ -0,0 +1,10 @@ +describe('pixi/InteractionManager', function () { + 'use strict'; + + var expect = chai.expect; + var InteractionManager = PIXI.InteractionManager; + + it('Module exists', function () { + expect(InteractionManager).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/Pixi.js b/test/unit/pixi-v2/Pixi.js new file mode 100644 index 0000000..27debc1 --- /dev/null +++ b/test/unit/pixi-v2/Pixi.js @@ -0,0 +1,9 @@ +describe('pixi/Pixi', function () { + 'use strict'; + + var expect = chai.expect; + + it('Module exists', function () { + expect(global).to.have.property('PIXI').and.to.be.an('object'); + }); +}); diff --git a/test/unit/pixi-v2/core/Circle.js b/test/unit/pixi-v2/core/Circle.js new file mode 100644 index 0000000..fbcfa17 --- /dev/null +++ b/test/unit/pixi-v2/core/Circle.js @@ -0,0 +1,21 @@ +describe('pixi/core/Circle', function () { + 'use strict'; + + var expect = chai.expect; + var Circle = PIXI.Circle; + + it('Module exists', function () { + expect(Circle).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Circle(); + pixi_core_Circle_confirmNewCircle(obj); + }); + + it("getBounds should return Rectangle that bounds the circle", function() { + var obj = new Circle(100, 250, 50); + var bounds = obj.getBounds(); + pixi_core_Circle_isBoundedByRectangle(obj, bounds); + }); +}); diff --git a/test/unit/pixi-v2/core/Ellipse.js b/test/unit/pixi-v2/core/Ellipse.js new file mode 100644 index 0000000..026b56f --- /dev/null +++ b/test/unit/pixi-v2/core/Ellipse.js @@ -0,0 +1,24 @@ +describe('pixi/core/Ellipse', function () { + 'use strict'; + + var expect = chai.expect; + var Ellipse = PIXI.Ellipse; + + it('Module exists', function () { + expect(Ellipse).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Ellipse(); + + expect(obj).to.be.an.instanceof(Ellipse); + expect(obj).to.respondTo('clone'); + expect(obj).to.respondTo('contains'); + expect(obj).to.respondTo('getBounds'); + + expect(obj).to.have.property('x', 0); + expect(obj).to.have.property('y', 0); + expect(obj).to.have.property('width', 0); + expect(obj).to.have.property('height', 0); + }); +}); diff --git a/test/unit/pixi-v2/core/Matrix.js b/test/unit/pixi-v2/core/Matrix.js new file mode 100644 index 0000000..da75e2e --- /dev/null +++ b/test/unit/pixi-v2/core/Matrix.js @@ -0,0 +1,14 @@ +describe('pixi/core/Matrix', function () { + 'use strict'; + + var expect = chai.expect; + + it('Matrix exists', function () { + expect(PIXI.Matrix).to.be.an('function'); + }); + + it('Confirm new Matrix', function () { + var matrix = new PIXI.Matrix(); + pixi_core_Matrix_confirmNewMatrix(matrix); + }); +}); diff --git a/test/unit/pixi-v2/core/Point.js b/test/unit/pixi-v2/core/Point.js new file mode 100644 index 0000000..c4d5163 --- /dev/null +++ b/test/unit/pixi-v2/core/Point.js @@ -0,0 +1,15 @@ +describe('pixi/core/Point', function () { + 'use strict'; + + var expect = chai.expect; + var Point = PIXI.Point; + + it('Module exists', function () { + expect(Point).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Point(); + pixi_core_Point_confirm(obj, 0, 0); + }); +}); diff --git a/test/unit/pixi-v2/core/Polygon.js b/test/unit/pixi-v2/core/Polygon.js new file mode 100644 index 0000000..dc8c918 --- /dev/null +++ b/test/unit/pixi-v2/core/Polygon.js @@ -0,0 +1,20 @@ +describe('pixi/core/Polygon', function () { + 'use strict'; + + var expect = chai.expect; + var Polygon = PIXI.Polygon; + + it('Module exists', function () { + expect(Polygon).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Polygon(); + + expect(obj).to.be.an.instanceof(Polygon); + expect(obj).to.respondTo('clone'); + expect(obj).to.respondTo('contains'); + + expect(obj).to.have.deep.property('points.length', 0); + }); +}); diff --git a/test/unit/pixi-v2/core/Rectangle.js b/test/unit/pixi-v2/core/Rectangle.js new file mode 100644 index 0000000..d43316e --- /dev/null +++ b/test/unit/pixi-v2/core/Rectangle.js @@ -0,0 +1,15 @@ +describe('pixi/core/Rectangle', function () { + 'use strict'; + + var expect = chai.expect; + var Rectangle = PIXI.Rectangle; + + it('Module exists', function () { + expect(Rectangle).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var rect = new Rectangle(); + pixi_core_Rectangle_confirm(rect, 0, 0, 0, 0); + }); +}); diff --git a/test/unit/pixi-v2/display/DisplayObject.js b/test/unit/pixi-v2/display/DisplayObject.js new file mode 100644 index 0000000..044acf8 --- /dev/null +++ b/test/unit/pixi-v2/display/DisplayObject.js @@ -0,0 +1,21 @@ +describe('pixi/display/DisplayObject', function () { + 'use strict'; + + var expect = chai.expect; + var DisplayObject = PIXI.DisplayObject; + + it('Module exists', function () { + expect(DisplayObject).to.be.a('function'); + // expect(PIXI).to.have.property('visibleCount', 0); + }); + + it('Confirm new instance', function () { + var obj = new DisplayObject(); + + pixi_display_DisplayObject_confirmNew(obj); + expect(obj).to.have.property('hitArea', null); + expect(obj).to.have.property('interactive', false); + expect(obj).to.have.property('renderable', false); + expect(obj).to.have.property('stage', null); + }); +}); diff --git a/test/unit/pixi-v2/display/DisplayObjectContainer.js b/test/unit/pixi-v2/display/DisplayObjectContainer.js new file mode 100644 index 0000000..15a3376 --- /dev/null +++ b/test/unit/pixi-v2/display/DisplayObjectContainer.js @@ -0,0 +1,67 @@ +describe('pixi/display/DisplayObjectContainer', function () { + 'use strict'; + + var expect = chai.expect; + var DisplayObjectContainer = PIXI.DisplayObjectContainer; + + it('Module exists', function () { + expect(DisplayObjectContainer).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new DisplayObjectContainer(); + + pixi_display_DisplayObjectContainer_confirmNew(obj); + expect(obj).to.have.property('hitArea', null); + expect(obj).to.have.property('interactive', false); + expect(obj).to.have.property('renderable', false); + expect(obj).to.have.property('stage', null); + }); + + it('Gets child index', function() { + var container = new PIXI.DisplayObjectContainer(); + var children = []; + for (var i = 0; i < 10; i++) { + var child = new PIXI.DisplayObject(); + children.push(child); + container.addChild(child); + } + + for (i = 0; i < children.length; i++) { + expect(i).to.eql(container.getChildIndex(children[i])); + } + }); + + it('throws error when trying to get index of not a child', function() { + var container = new PIXI.DisplayObjectContainer(); + var child = new PIXI.DisplayObject(); + + expect(function() { container.getChildIndex(child); }).to.throw(); + }); + + it('Sets child index', function() { + var container = new PIXI.DisplayObjectContainer(); + var children = []; + + for (var i = 0; i < 10; i++) { + var child = new PIXI.DisplayObject(); + children.push(child); + container.addChild(child); + } + children.reverse(); + + for (i = 0; i < children.length; i++) { + container.setChildIndex(children[i], i); + expect(i).to.eql(container.getChildIndex(children[i])); + } + }); + + it('throws error when trying to set incorect index', function() { + var container = new PIXI.DisplayObjectContainer(); + var child = new PIXI.DisplayObject(); + container.addChild(child); + + expect(function() { container.setChildIndex(child, -1); }).to.throw(); + expect(function() { container.setChildIndex(child, 1); }).to.throw(); + }); +}); diff --git a/test/unit/pixi-v2/display/MovieClip.js b/test/unit/pixi-v2/display/MovieClip.js new file mode 100644 index 0000000..f3c6c6a --- /dev/null +++ b/test/unit/pixi-v2/display/MovieClip.js @@ -0,0 +1,33 @@ +describe('pixi/display/MovieClip', function () { + 'use strict'; + + var expect = chai.expect; + var MovieClip = PIXI.MovieClip; + var Texture = PIXI.Texture; + + it('Module exists', function () { + expect(MovieClip).to.be.a('function'); + }); + + it('Confirm new instance', function (done) { + var texture = Texture.fromImage('/base/test/textures/SpriteSheet-Explosion.png'); + var obj = new MovieClip([texture]); + + pixi_display_Sprite_confirmNew(obj, done); + + expect(obj).to.be.an.instanceof(MovieClip); + expect(obj).to.respondTo('stop'); + expect(obj).to.respondTo('play'); + expect(obj).to.respondTo('gotoAndStop'); + expect(obj).to.respondTo('gotoAndPlay'); + expect(obj).to.respondTo('updateTransform'); + + expect(obj).to.have.deep.property('textures.length', 1); + expect(obj).to.have.deep.property('textures[0]', texture); + expect(obj).to.have.property('animationSpeed', 1); + expect(obj).to.have.property('loop', true); + expect(obj).to.have.property('onComplete', null); + expect(obj).to.have.property('currentFrame', 0); + expect(obj).to.have.property('playing', false); + }); +}); diff --git a/test/unit/pixi-v2/display/Sprite.js b/test/unit/pixi-v2/display/Sprite.js new file mode 100644 index 0000000..30c8076 --- /dev/null +++ b/test/unit/pixi-v2/display/Sprite.js @@ -0,0 +1,28 @@ +describe('pixi/display/Sprite', function () { + 'use strict'; + + var expect = chai.expect; + var Sprite = PIXI.Sprite; + var Texture = PIXI.Texture; + + it('Module exists', function () { + expect(Sprite).to.be.a('function'); + expect(PIXI).to.have.deep.property('blendModes.NORMAL', 0); + expect(PIXI).to.have.deep.property('blendModes.ADD', 1); + expect(PIXI).to.have.deep.property('blendModes.MULTIPLY', 2); + expect(PIXI).to.have.deep.property('blendModes.SCREEN', 3); + }); + + + it('Members exist', function () { + expect(Sprite).itself.to.respondTo('fromImage'); + expect(Sprite).itself.to.respondTo('fromFrame'); + }); + + it('Confirm new instance', function (done) { + var texture = Texture.fromImage('/base/test/textures/SpriteSheet-Aliens.png'); + var obj = new Sprite(texture); + + pixi_display_Sprite_confirmNew(obj, done); + }); +}); diff --git a/test/unit/pixi-v2/display/Stage.js b/test/unit/pixi-v2/display/Stage.js new file mode 100644 index 0000000..6974c2e --- /dev/null +++ b/test/unit/pixi-v2/display/Stage.js @@ -0,0 +1,49 @@ +describe('pixi/display/Stage', function () { + 'use strict'; + + var expect = chai.expect; + var Stage = PIXI.Stage; + var InteractionManager = PIXI.InteractionManager; + var Rectangle = PIXI.Rectangle; + + it('Module exists', function () { + expect(Stage).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Stage(null, true); + + pixi_display_DisplayObjectContainer_confirmNew(obj); + + expect(obj).to.be.an.instanceof(Stage); + expect(obj).to.respondTo('updateTransform'); + expect(obj).to.respondTo('setBackgroundColor'); + expect(obj).to.respondTo('getMousePosition'); + // FIXME: duplicate member in DisplayObject + pixi_core_Matrix_confirmNewMatrix(obj.worldTransform); + // FIXME: convert arg to bool in constructor + expect(obj).to.have.property('interactive', true); + + expect(obj).to.have.property('interactionManager') + .and.to.be.an.instanceof(InteractionManager) + .and.to.have.property('stage', obj); + + expect(obj).to.have.property('dirty', true); + + expect(obj).to.have.property('stage', obj); + + expect(obj).to.have.property('hitArea') + .and.to.be.an.instanceof(Rectangle); + pixi_core_Rectangle_confirm(obj.hitArea, 0, 0, 100000, 100000); + + expect(obj).to.have.property('backgroundColor', 0x000000); + expect(obj).to.have.deep.property('backgroundColorSplit.length', 3); + expect(obj).to.have.deep.property('backgroundColorSplit[0]', 0); + expect(obj).to.have.deep.property('backgroundColorSplit[1]', 0); + expect(obj).to.have.deep.property('backgroundColorSplit[2]', 0); + expect(obj).to.have.property('backgroundColorString', '#000000'); + + + expect(obj).to.have.property('worldVisible', true); + }); +}); diff --git a/test/unit/pixi-v2/extras/Rope.js b/test/unit/pixi-v2/extras/Rope.js new file mode 100644 index 0000000..05885ac --- /dev/null +++ b/test/unit/pixi-v2/extras/Rope.js @@ -0,0 +1,31 @@ +describe('pixi/extras/Rope', function () { + 'use strict'; + + var expect = chai.expect; + var Rope = PIXI.Rope; + var Texture = PIXI.Texture; + var Point = PIXI.Point; + + it('Module exists', function () { + expect(Rope).to.be.a('function'); + }); + + it('Confirm new instance', function () { + + var texture = Texture.fromImage('/base/test/textures/bunny.png'); + + // TODO-Alvin + // Same as Strip + + // var obj = new Rope(texture, [new Point(), new Point(5, 10), new Point(10, 20)]); + + // pixi_extras_Strip_confirmNew(obj); + + // expect(obj).to.be.an.instanceof(Rope); + // expect(obj).to.respondTo('refresh'); + // expect(obj).to.respondTo('updateTransform'); + // expect(obj).to.respondTo('setTexture'); + + // TODO: Test properties + }); +}); diff --git a/test/unit/pixi-v2/extras/Spine.js b/test/unit/pixi-v2/extras/Spine.js new file mode 100644 index 0000000..0708bc0 --- /dev/null +++ b/test/unit/pixi-v2/extras/Spine.js @@ -0,0 +1,10 @@ +describe('pixi/extras/Spine', function () { + 'use strict'; + + var expect = chai.expect; + var Spine = PIXI.Spine; + + it('Module exists', function () { + expect(Spine).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/extras/Strip.js b/test/unit/pixi-v2/extras/Strip.js new file mode 100644 index 0000000..230af90 --- /dev/null +++ b/test/unit/pixi-v2/extras/Strip.js @@ -0,0 +1,26 @@ +describe('pixi/extras/Strip', function () { + 'use strict'; + + var expect = chai.expect; + var Strip = PIXI.Strip; + var Texture = PIXI.Texture; + + it('Module exists', function () { + expect(Strip).to.be.a('function'); + }); + + it('Confirm new instance', function () { + + + // TODO-Alvin + // We tweaked it to make it pass the tests, but the whole strip class needs + // to be re-coded + + var texture = Texture.fromImage('/base/test/textures/bunny.png'); + + // var obj = new Strip(texture, 20, 10000); + + + // pixi_extras_Strip_confirmNew(obj); + }); +}); diff --git a/test/unit/pixi-v2/extras/TilingSprite.js b/test/unit/pixi-v2/extras/TilingSprite.js new file mode 100644 index 0000000..56aea14 --- /dev/null +++ b/test/unit/pixi-v2/extras/TilingSprite.js @@ -0,0 +1,24 @@ +describe('pixi/extras/TilingSprite', function () { + 'use strict'; + + var expect = chai.expect; + var TilingSprite = PIXI.TilingSprite; + var Texture = PIXI.Texture; + + it('Module exists', function () { + expect(TilingSprite).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var texture = Texture.fromImage('/base/test/textures/bunny.png'); + var obj = new TilingSprite(texture, 6000, 12000); + + pixi_display_DisplayObjectContainer_confirmNew(obj); + + expect(obj).to.be.an.instanceof(TilingSprite); + expect(obj).to.respondTo('setTexture'); + expect(obj).to.respondTo('onTextureUpdate'); + + // TODO: Test properties + }); +}); diff --git a/test/unit/pixi-v2/filters/FilterBlock.js b/test/unit/pixi-v2/filters/FilterBlock.js new file mode 100644 index 0000000..870cec0 --- /dev/null +++ b/test/unit/pixi-v2/filters/FilterBlock.js @@ -0,0 +1,10 @@ +describe('pixi/filters/FilterBlock', function () { + 'use strict'; + + var expect = chai.expect; + var FilterBlock = PIXI.FilterBlock; + + it('Module exists', function () { + expect(FilterBlock).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/AssetLoader.js b/test/unit/pixi-v2/loaders/AssetLoader.js new file mode 100644 index 0000000..a0aa0b5 --- /dev/null +++ b/test/unit/pixi-v2/loaders/AssetLoader.js @@ -0,0 +1,10 @@ +describe('pixi/loaders/AssetLoader', function () { + 'use strict'; + + var expect = chai.expect; + var AssetLoader = PIXI.AssetLoader; + + it('Module exists', function () { + expect(AssetLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/BitmapFontLoader.js b/test/unit/pixi-v2/loaders/BitmapFontLoader.js new file mode 100644 index 0000000..046f018 --- /dev/null +++ b/test/unit/pixi-v2/loaders/BitmapFontLoader.js @@ -0,0 +1,9 @@ +describe('pixi/loaders/BitmapFontLoader', function () { + 'use strict'; + + var expect = chai.expect; + + it('Module exists', function () { + expect(PIXI.BitmapFontLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/InteractionManager.js b/test/unit/pixi-v2/InteractionManager.js new file mode 100644 index 0000000..ed3001f --- /dev/null +++ b/test/unit/pixi-v2/InteractionManager.js @@ -0,0 +1,10 @@ +describe('pixi/InteractionManager', function () { + 'use strict'; + + var expect = chai.expect; + var InteractionManager = PIXI.InteractionManager; + + it('Module exists', function () { + expect(InteractionManager).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/Pixi.js b/test/unit/pixi-v2/Pixi.js new file mode 100644 index 0000000..27debc1 --- /dev/null +++ b/test/unit/pixi-v2/Pixi.js @@ -0,0 +1,9 @@ +describe('pixi/Pixi', function () { + 'use strict'; + + var expect = chai.expect; + + it('Module exists', function () { + expect(global).to.have.property('PIXI').and.to.be.an('object'); + }); +}); diff --git a/test/unit/pixi-v2/core/Circle.js b/test/unit/pixi-v2/core/Circle.js new file mode 100644 index 0000000..fbcfa17 --- /dev/null +++ b/test/unit/pixi-v2/core/Circle.js @@ -0,0 +1,21 @@ +describe('pixi/core/Circle', function () { + 'use strict'; + + var expect = chai.expect; + var Circle = PIXI.Circle; + + it('Module exists', function () { + expect(Circle).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Circle(); + pixi_core_Circle_confirmNewCircle(obj); + }); + + it("getBounds should return Rectangle that bounds the circle", function() { + var obj = new Circle(100, 250, 50); + var bounds = obj.getBounds(); + pixi_core_Circle_isBoundedByRectangle(obj, bounds); + }); +}); diff --git a/test/unit/pixi-v2/core/Ellipse.js b/test/unit/pixi-v2/core/Ellipse.js new file mode 100644 index 0000000..026b56f --- /dev/null +++ b/test/unit/pixi-v2/core/Ellipse.js @@ -0,0 +1,24 @@ +describe('pixi/core/Ellipse', function () { + 'use strict'; + + var expect = chai.expect; + var Ellipse = PIXI.Ellipse; + + it('Module exists', function () { + expect(Ellipse).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Ellipse(); + + expect(obj).to.be.an.instanceof(Ellipse); + expect(obj).to.respondTo('clone'); + expect(obj).to.respondTo('contains'); + expect(obj).to.respondTo('getBounds'); + + expect(obj).to.have.property('x', 0); + expect(obj).to.have.property('y', 0); + expect(obj).to.have.property('width', 0); + expect(obj).to.have.property('height', 0); + }); +}); diff --git a/test/unit/pixi-v2/core/Matrix.js b/test/unit/pixi-v2/core/Matrix.js new file mode 100644 index 0000000..da75e2e --- /dev/null +++ b/test/unit/pixi-v2/core/Matrix.js @@ -0,0 +1,14 @@ +describe('pixi/core/Matrix', function () { + 'use strict'; + + var expect = chai.expect; + + it('Matrix exists', function () { + expect(PIXI.Matrix).to.be.an('function'); + }); + + it('Confirm new Matrix', function () { + var matrix = new PIXI.Matrix(); + pixi_core_Matrix_confirmNewMatrix(matrix); + }); +}); diff --git a/test/unit/pixi-v2/core/Point.js b/test/unit/pixi-v2/core/Point.js new file mode 100644 index 0000000..c4d5163 --- /dev/null +++ b/test/unit/pixi-v2/core/Point.js @@ -0,0 +1,15 @@ +describe('pixi/core/Point', function () { + 'use strict'; + + var expect = chai.expect; + var Point = PIXI.Point; + + it('Module exists', function () { + expect(Point).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Point(); + pixi_core_Point_confirm(obj, 0, 0); + }); +}); diff --git a/test/unit/pixi-v2/core/Polygon.js b/test/unit/pixi-v2/core/Polygon.js new file mode 100644 index 0000000..dc8c918 --- /dev/null +++ b/test/unit/pixi-v2/core/Polygon.js @@ -0,0 +1,20 @@ +describe('pixi/core/Polygon', function () { + 'use strict'; + + var expect = chai.expect; + var Polygon = PIXI.Polygon; + + it('Module exists', function () { + expect(Polygon).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Polygon(); + + expect(obj).to.be.an.instanceof(Polygon); + expect(obj).to.respondTo('clone'); + expect(obj).to.respondTo('contains'); + + expect(obj).to.have.deep.property('points.length', 0); + }); +}); diff --git a/test/unit/pixi-v2/core/Rectangle.js b/test/unit/pixi-v2/core/Rectangle.js new file mode 100644 index 0000000..d43316e --- /dev/null +++ b/test/unit/pixi-v2/core/Rectangle.js @@ -0,0 +1,15 @@ +describe('pixi/core/Rectangle', function () { + 'use strict'; + + var expect = chai.expect; + var Rectangle = PIXI.Rectangle; + + it('Module exists', function () { + expect(Rectangle).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var rect = new Rectangle(); + pixi_core_Rectangle_confirm(rect, 0, 0, 0, 0); + }); +}); diff --git a/test/unit/pixi-v2/display/DisplayObject.js b/test/unit/pixi-v2/display/DisplayObject.js new file mode 100644 index 0000000..044acf8 --- /dev/null +++ b/test/unit/pixi-v2/display/DisplayObject.js @@ -0,0 +1,21 @@ +describe('pixi/display/DisplayObject', function () { + 'use strict'; + + var expect = chai.expect; + var DisplayObject = PIXI.DisplayObject; + + it('Module exists', function () { + expect(DisplayObject).to.be.a('function'); + // expect(PIXI).to.have.property('visibleCount', 0); + }); + + it('Confirm new instance', function () { + var obj = new DisplayObject(); + + pixi_display_DisplayObject_confirmNew(obj); + expect(obj).to.have.property('hitArea', null); + expect(obj).to.have.property('interactive', false); + expect(obj).to.have.property('renderable', false); + expect(obj).to.have.property('stage', null); + }); +}); diff --git a/test/unit/pixi-v2/display/DisplayObjectContainer.js b/test/unit/pixi-v2/display/DisplayObjectContainer.js new file mode 100644 index 0000000..15a3376 --- /dev/null +++ b/test/unit/pixi-v2/display/DisplayObjectContainer.js @@ -0,0 +1,67 @@ +describe('pixi/display/DisplayObjectContainer', function () { + 'use strict'; + + var expect = chai.expect; + var DisplayObjectContainer = PIXI.DisplayObjectContainer; + + it('Module exists', function () { + expect(DisplayObjectContainer).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new DisplayObjectContainer(); + + pixi_display_DisplayObjectContainer_confirmNew(obj); + expect(obj).to.have.property('hitArea', null); + expect(obj).to.have.property('interactive', false); + expect(obj).to.have.property('renderable', false); + expect(obj).to.have.property('stage', null); + }); + + it('Gets child index', function() { + var container = new PIXI.DisplayObjectContainer(); + var children = []; + for (var i = 0; i < 10; i++) { + var child = new PIXI.DisplayObject(); + children.push(child); + container.addChild(child); + } + + for (i = 0; i < children.length; i++) { + expect(i).to.eql(container.getChildIndex(children[i])); + } + }); + + it('throws error when trying to get index of not a child', function() { + var container = new PIXI.DisplayObjectContainer(); + var child = new PIXI.DisplayObject(); + + expect(function() { container.getChildIndex(child); }).to.throw(); + }); + + it('Sets child index', function() { + var container = new PIXI.DisplayObjectContainer(); + var children = []; + + for (var i = 0; i < 10; i++) { + var child = new PIXI.DisplayObject(); + children.push(child); + container.addChild(child); + } + children.reverse(); + + for (i = 0; i < children.length; i++) { + container.setChildIndex(children[i], i); + expect(i).to.eql(container.getChildIndex(children[i])); + } + }); + + it('throws error when trying to set incorect index', function() { + var container = new PIXI.DisplayObjectContainer(); + var child = new PIXI.DisplayObject(); + container.addChild(child); + + expect(function() { container.setChildIndex(child, -1); }).to.throw(); + expect(function() { container.setChildIndex(child, 1); }).to.throw(); + }); +}); diff --git a/test/unit/pixi-v2/display/MovieClip.js b/test/unit/pixi-v2/display/MovieClip.js new file mode 100644 index 0000000..f3c6c6a --- /dev/null +++ b/test/unit/pixi-v2/display/MovieClip.js @@ -0,0 +1,33 @@ +describe('pixi/display/MovieClip', function () { + 'use strict'; + + var expect = chai.expect; + var MovieClip = PIXI.MovieClip; + var Texture = PIXI.Texture; + + it('Module exists', function () { + expect(MovieClip).to.be.a('function'); + }); + + it('Confirm new instance', function (done) { + var texture = Texture.fromImage('/base/test/textures/SpriteSheet-Explosion.png'); + var obj = new MovieClip([texture]); + + pixi_display_Sprite_confirmNew(obj, done); + + expect(obj).to.be.an.instanceof(MovieClip); + expect(obj).to.respondTo('stop'); + expect(obj).to.respondTo('play'); + expect(obj).to.respondTo('gotoAndStop'); + expect(obj).to.respondTo('gotoAndPlay'); + expect(obj).to.respondTo('updateTransform'); + + expect(obj).to.have.deep.property('textures.length', 1); + expect(obj).to.have.deep.property('textures[0]', texture); + expect(obj).to.have.property('animationSpeed', 1); + expect(obj).to.have.property('loop', true); + expect(obj).to.have.property('onComplete', null); + expect(obj).to.have.property('currentFrame', 0); + expect(obj).to.have.property('playing', false); + }); +}); diff --git a/test/unit/pixi-v2/display/Sprite.js b/test/unit/pixi-v2/display/Sprite.js new file mode 100644 index 0000000..30c8076 --- /dev/null +++ b/test/unit/pixi-v2/display/Sprite.js @@ -0,0 +1,28 @@ +describe('pixi/display/Sprite', function () { + 'use strict'; + + var expect = chai.expect; + var Sprite = PIXI.Sprite; + var Texture = PIXI.Texture; + + it('Module exists', function () { + expect(Sprite).to.be.a('function'); + expect(PIXI).to.have.deep.property('blendModes.NORMAL', 0); + expect(PIXI).to.have.deep.property('blendModes.ADD', 1); + expect(PIXI).to.have.deep.property('blendModes.MULTIPLY', 2); + expect(PIXI).to.have.deep.property('blendModes.SCREEN', 3); + }); + + + it('Members exist', function () { + expect(Sprite).itself.to.respondTo('fromImage'); + expect(Sprite).itself.to.respondTo('fromFrame'); + }); + + it('Confirm new instance', function (done) { + var texture = Texture.fromImage('/base/test/textures/SpriteSheet-Aliens.png'); + var obj = new Sprite(texture); + + pixi_display_Sprite_confirmNew(obj, done); + }); +}); diff --git a/test/unit/pixi-v2/display/Stage.js b/test/unit/pixi-v2/display/Stage.js new file mode 100644 index 0000000..6974c2e --- /dev/null +++ b/test/unit/pixi-v2/display/Stage.js @@ -0,0 +1,49 @@ +describe('pixi/display/Stage', function () { + 'use strict'; + + var expect = chai.expect; + var Stage = PIXI.Stage; + var InteractionManager = PIXI.InteractionManager; + var Rectangle = PIXI.Rectangle; + + it('Module exists', function () { + expect(Stage).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Stage(null, true); + + pixi_display_DisplayObjectContainer_confirmNew(obj); + + expect(obj).to.be.an.instanceof(Stage); + expect(obj).to.respondTo('updateTransform'); + expect(obj).to.respondTo('setBackgroundColor'); + expect(obj).to.respondTo('getMousePosition'); + // FIXME: duplicate member in DisplayObject + pixi_core_Matrix_confirmNewMatrix(obj.worldTransform); + // FIXME: convert arg to bool in constructor + expect(obj).to.have.property('interactive', true); + + expect(obj).to.have.property('interactionManager') + .and.to.be.an.instanceof(InteractionManager) + .and.to.have.property('stage', obj); + + expect(obj).to.have.property('dirty', true); + + expect(obj).to.have.property('stage', obj); + + expect(obj).to.have.property('hitArea') + .and.to.be.an.instanceof(Rectangle); + pixi_core_Rectangle_confirm(obj.hitArea, 0, 0, 100000, 100000); + + expect(obj).to.have.property('backgroundColor', 0x000000); + expect(obj).to.have.deep.property('backgroundColorSplit.length', 3); + expect(obj).to.have.deep.property('backgroundColorSplit[0]', 0); + expect(obj).to.have.deep.property('backgroundColorSplit[1]', 0); + expect(obj).to.have.deep.property('backgroundColorSplit[2]', 0); + expect(obj).to.have.property('backgroundColorString', '#000000'); + + + expect(obj).to.have.property('worldVisible', true); + }); +}); diff --git a/test/unit/pixi-v2/extras/Rope.js b/test/unit/pixi-v2/extras/Rope.js new file mode 100644 index 0000000..05885ac --- /dev/null +++ b/test/unit/pixi-v2/extras/Rope.js @@ -0,0 +1,31 @@ +describe('pixi/extras/Rope', function () { + 'use strict'; + + var expect = chai.expect; + var Rope = PIXI.Rope; + var Texture = PIXI.Texture; + var Point = PIXI.Point; + + it('Module exists', function () { + expect(Rope).to.be.a('function'); + }); + + it('Confirm new instance', function () { + + var texture = Texture.fromImage('/base/test/textures/bunny.png'); + + // TODO-Alvin + // Same as Strip + + // var obj = new Rope(texture, [new Point(), new Point(5, 10), new Point(10, 20)]); + + // pixi_extras_Strip_confirmNew(obj); + + // expect(obj).to.be.an.instanceof(Rope); + // expect(obj).to.respondTo('refresh'); + // expect(obj).to.respondTo('updateTransform'); + // expect(obj).to.respondTo('setTexture'); + + // TODO: Test properties + }); +}); diff --git a/test/unit/pixi-v2/extras/Spine.js b/test/unit/pixi-v2/extras/Spine.js new file mode 100644 index 0000000..0708bc0 --- /dev/null +++ b/test/unit/pixi-v2/extras/Spine.js @@ -0,0 +1,10 @@ +describe('pixi/extras/Spine', function () { + 'use strict'; + + var expect = chai.expect; + var Spine = PIXI.Spine; + + it('Module exists', function () { + expect(Spine).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/extras/Strip.js b/test/unit/pixi-v2/extras/Strip.js new file mode 100644 index 0000000..230af90 --- /dev/null +++ b/test/unit/pixi-v2/extras/Strip.js @@ -0,0 +1,26 @@ +describe('pixi/extras/Strip', function () { + 'use strict'; + + var expect = chai.expect; + var Strip = PIXI.Strip; + var Texture = PIXI.Texture; + + it('Module exists', function () { + expect(Strip).to.be.a('function'); + }); + + it('Confirm new instance', function () { + + + // TODO-Alvin + // We tweaked it to make it pass the tests, but the whole strip class needs + // to be re-coded + + var texture = Texture.fromImage('/base/test/textures/bunny.png'); + + // var obj = new Strip(texture, 20, 10000); + + + // pixi_extras_Strip_confirmNew(obj); + }); +}); diff --git a/test/unit/pixi-v2/extras/TilingSprite.js b/test/unit/pixi-v2/extras/TilingSprite.js new file mode 100644 index 0000000..56aea14 --- /dev/null +++ b/test/unit/pixi-v2/extras/TilingSprite.js @@ -0,0 +1,24 @@ +describe('pixi/extras/TilingSprite', function () { + 'use strict'; + + var expect = chai.expect; + var TilingSprite = PIXI.TilingSprite; + var Texture = PIXI.Texture; + + it('Module exists', function () { + expect(TilingSprite).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var texture = Texture.fromImage('/base/test/textures/bunny.png'); + var obj = new TilingSprite(texture, 6000, 12000); + + pixi_display_DisplayObjectContainer_confirmNew(obj); + + expect(obj).to.be.an.instanceof(TilingSprite); + expect(obj).to.respondTo('setTexture'); + expect(obj).to.respondTo('onTextureUpdate'); + + // TODO: Test properties + }); +}); diff --git a/test/unit/pixi-v2/filters/FilterBlock.js b/test/unit/pixi-v2/filters/FilterBlock.js new file mode 100644 index 0000000..870cec0 --- /dev/null +++ b/test/unit/pixi-v2/filters/FilterBlock.js @@ -0,0 +1,10 @@ +describe('pixi/filters/FilterBlock', function () { + 'use strict'; + + var expect = chai.expect; + var FilterBlock = PIXI.FilterBlock; + + it('Module exists', function () { + expect(FilterBlock).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/AssetLoader.js b/test/unit/pixi-v2/loaders/AssetLoader.js new file mode 100644 index 0000000..a0aa0b5 --- /dev/null +++ b/test/unit/pixi-v2/loaders/AssetLoader.js @@ -0,0 +1,10 @@ +describe('pixi/loaders/AssetLoader', function () { + 'use strict'; + + var expect = chai.expect; + var AssetLoader = PIXI.AssetLoader; + + it('Module exists', function () { + expect(AssetLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/BitmapFontLoader.js b/test/unit/pixi-v2/loaders/BitmapFontLoader.js new file mode 100644 index 0000000..046f018 --- /dev/null +++ b/test/unit/pixi-v2/loaders/BitmapFontLoader.js @@ -0,0 +1,9 @@ +describe('pixi/loaders/BitmapFontLoader', function () { + 'use strict'; + + var expect = chai.expect; + + it('Module exists', function () { + expect(PIXI.BitmapFontLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/ImageLoader.js b/test/unit/pixi-v2/loaders/ImageLoader.js new file mode 100644 index 0000000..8b1f556 --- /dev/null +++ b/test/unit/pixi-v2/loaders/ImageLoader.js @@ -0,0 +1,10 @@ +describe('pixi/loaders/ImageLoader', function () { + 'use strict'; + + var expect = chai.expect; + var ImageLoader = PIXI.ImageLoader; + + it('Module exists', function () { + expect(ImageLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/InteractionManager.js b/test/unit/pixi-v2/InteractionManager.js new file mode 100644 index 0000000..ed3001f --- /dev/null +++ b/test/unit/pixi-v2/InteractionManager.js @@ -0,0 +1,10 @@ +describe('pixi/InteractionManager', function () { + 'use strict'; + + var expect = chai.expect; + var InteractionManager = PIXI.InteractionManager; + + it('Module exists', function () { + expect(InteractionManager).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/Pixi.js b/test/unit/pixi-v2/Pixi.js new file mode 100644 index 0000000..27debc1 --- /dev/null +++ b/test/unit/pixi-v2/Pixi.js @@ -0,0 +1,9 @@ +describe('pixi/Pixi', function () { + 'use strict'; + + var expect = chai.expect; + + it('Module exists', function () { + expect(global).to.have.property('PIXI').and.to.be.an('object'); + }); +}); diff --git a/test/unit/pixi-v2/core/Circle.js b/test/unit/pixi-v2/core/Circle.js new file mode 100644 index 0000000..fbcfa17 --- /dev/null +++ b/test/unit/pixi-v2/core/Circle.js @@ -0,0 +1,21 @@ +describe('pixi/core/Circle', function () { + 'use strict'; + + var expect = chai.expect; + var Circle = PIXI.Circle; + + it('Module exists', function () { + expect(Circle).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Circle(); + pixi_core_Circle_confirmNewCircle(obj); + }); + + it("getBounds should return Rectangle that bounds the circle", function() { + var obj = new Circle(100, 250, 50); + var bounds = obj.getBounds(); + pixi_core_Circle_isBoundedByRectangle(obj, bounds); + }); +}); diff --git a/test/unit/pixi-v2/core/Ellipse.js b/test/unit/pixi-v2/core/Ellipse.js new file mode 100644 index 0000000..026b56f --- /dev/null +++ b/test/unit/pixi-v2/core/Ellipse.js @@ -0,0 +1,24 @@ +describe('pixi/core/Ellipse', function () { + 'use strict'; + + var expect = chai.expect; + var Ellipse = PIXI.Ellipse; + + it('Module exists', function () { + expect(Ellipse).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Ellipse(); + + expect(obj).to.be.an.instanceof(Ellipse); + expect(obj).to.respondTo('clone'); + expect(obj).to.respondTo('contains'); + expect(obj).to.respondTo('getBounds'); + + expect(obj).to.have.property('x', 0); + expect(obj).to.have.property('y', 0); + expect(obj).to.have.property('width', 0); + expect(obj).to.have.property('height', 0); + }); +}); diff --git a/test/unit/pixi-v2/core/Matrix.js b/test/unit/pixi-v2/core/Matrix.js new file mode 100644 index 0000000..da75e2e --- /dev/null +++ b/test/unit/pixi-v2/core/Matrix.js @@ -0,0 +1,14 @@ +describe('pixi/core/Matrix', function () { + 'use strict'; + + var expect = chai.expect; + + it('Matrix exists', function () { + expect(PIXI.Matrix).to.be.an('function'); + }); + + it('Confirm new Matrix', function () { + var matrix = new PIXI.Matrix(); + pixi_core_Matrix_confirmNewMatrix(matrix); + }); +}); diff --git a/test/unit/pixi-v2/core/Point.js b/test/unit/pixi-v2/core/Point.js new file mode 100644 index 0000000..c4d5163 --- /dev/null +++ b/test/unit/pixi-v2/core/Point.js @@ -0,0 +1,15 @@ +describe('pixi/core/Point', function () { + 'use strict'; + + var expect = chai.expect; + var Point = PIXI.Point; + + it('Module exists', function () { + expect(Point).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Point(); + pixi_core_Point_confirm(obj, 0, 0); + }); +}); diff --git a/test/unit/pixi-v2/core/Polygon.js b/test/unit/pixi-v2/core/Polygon.js new file mode 100644 index 0000000..dc8c918 --- /dev/null +++ b/test/unit/pixi-v2/core/Polygon.js @@ -0,0 +1,20 @@ +describe('pixi/core/Polygon', function () { + 'use strict'; + + var expect = chai.expect; + var Polygon = PIXI.Polygon; + + it('Module exists', function () { + expect(Polygon).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Polygon(); + + expect(obj).to.be.an.instanceof(Polygon); + expect(obj).to.respondTo('clone'); + expect(obj).to.respondTo('contains'); + + expect(obj).to.have.deep.property('points.length', 0); + }); +}); diff --git a/test/unit/pixi-v2/core/Rectangle.js b/test/unit/pixi-v2/core/Rectangle.js new file mode 100644 index 0000000..d43316e --- /dev/null +++ b/test/unit/pixi-v2/core/Rectangle.js @@ -0,0 +1,15 @@ +describe('pixi/core/Rectangle', function () { + 'use strict'; + + var expect = chai.expect; + var Rectangle = PIXI.Rectangle; + + it('Module exists', function () { + expect(Rectangle).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var rect = new Rectangle(); + pixi_core_Rectangle_confirm(rect, 0, 0, 0, 0); + }); +}); diff --git a/test/unit/pixi-v2/display/DisplayObject.js b/test/unit/pixi-v2/display/DisplayObject.js new file mode 100644 index 0000000..044acf8 --- /dev/null +++ b/test/unit/pixi-v2/display/DisplayObject.js @@ -0,0 +1,21 @@ +describe('pixi/display/DisplayObject', function () { + 'use strict'; + + var expect = chai.expect; + var DisplayObject = PIXI.DisplayObject; + + it('Module exists', function () { + expect(DisplayObject).to.be.a('function'); + // expect(PIXI).to.have.property('visibleCount', 0); + }); + + it('Confirm new instance', function () { + var obj = new DisplayObject(); + + pixi_display_DisplayObject_confirmNew(obj); + expect(obj).to.have.property('hitArea', null); + expect(obj).to.have.property('interactive', false); + expect(obj).to.have.property('renderable', false); + expect(obj).to.have.property('stage', null); + }); +}); diff --git a/test/unit/pixi-v2/display/DisplayObjectContainer.js b/test/unit/pixi-v2/display/DisplayObjectContainer.js new file mode 100644 index 0000000..15a3376 --- /dev/null +++ b/test/unit/pixi-v2/display/DisplayObjectContainer.js @@ -0,0 +1,67 @@ +describe('pixi/display/DisplayObjectContainer', function () { + 'use strict'; + + var expect = chai.expect; + var DisplayObjectContainer = PIXI.DisplayObjectContainer; + + it('Module exists', function () { + expect(DisplayObjectContainer).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new DisplayObjectContainer(); + + pixi_display_DisplayObjectContainer_confirmNew(obj); + expect(obj).to.have.property('hitArea', null); + expect(obj).to.have.property('interactive', false); + expect(obj).to.have.property('renderable', false); + expect(obj).to.have.property('stage', null); + }); + + it('Gets child index', function() { + var container = new PIXI.DisplayObjectContainer(); + var children = []; + for (var i = 0; i < 10; i++) { + var child = new PIXI.DisplayObject(); + children.push(child); + container.addChild(child); + } + + for (i = 0; i < children.length; i++) { + expect(i).to.eql(container.getChildIndex(children[i])); + } + }); + + it('throws error when trying to get index of not a child', function() { + var container = new PIXI.DisplayObjectContainer(); + var child = new PIXI.DisplayObject(); + + expect(function() { container.getChildIndex(child); }).to.throw(); + }); + + it('Sets child index', function() { + var container = new PIXI.DisplayObjectContainer(); + var children = []; + + for (var i = 0; i < 10; i++) { + var child = new PIXI.DisplayObject(); + children.push(child); + container.addChild(child); + } + children.reverse(); + + for (i = 0; i < children.length; i++) { + container.setChildIndex(children[i], i); + expect(i).to.eql(container.getChildIndex(children[i])); + } + }); + + it('throws error when trying to set incorect index', function() { + var container = new PIXI.DisplayObjectContainer(); + var child = new PIXI.DisplayObject(); + container.addChild(child); + + expect(function() { container.setChildIndex(child, -1); }).to.throw(); + expect(function() { container.setChildIndex(child, 1); }).to.throw(); + }); +}); diff --git a/test/unit/pixi-v2/display/MovieClip.js b/test/unit/pixi-v2/display/MovieClip.js new file mode 100644 index 0000000..f3c6c6a --- /dev/null +++ b/test/unit/pixi-v2/display/MovieClip.js @@ -0,0 +1,33 @@ +describe('pixi/display/MovieClip', function () { + 'use strict'; + + var expect = chai.expect; + var MovieClip = PIXI.MovieClip; + var Texture = PIXI.Texture; + + it('Module exists', function () { + expect(MovieClip).to.be.a('function'); + }); + + it('Confirm new instance', function (done) { + var texture = Texture.fromImage('/base/test/textures/SpriteSheet-Explosion.png'); + var obj = new MovieClip([texture]); + + pixi_display_Sprite_confirmNew(obj, done); + + expect(obj).to.be.an.instanceof(MovieClip); + expect(obj).to.respondTo('stop'); + expect(obj).to.respondTo('play'); + expect(obj).to.respondTo('gotoAndStop'); + expect(obj).to.respondTo('gotoAndPlay'); + expect(obj).to.respondTo('updateTransform'); + + expect(obj).to.have.deep.property('textures.length', 1); + expect(obj).to.have.deep.property('textures[0]', texture); + expect(obj).to.have.property('animationSpeed', 1); + expect(obj).to.have.property('loop', true); + expect(obj).to.have.property('onComplete', null); + expect(obj).to.have.property('currentFrame', 0); + expect(obj).to.have.property('playing', false); + }); +}); diff --git a/test/unit/pixi-v2/display/Sprite.js b/test/unit/pixi-v2/display/Sprite.js new file mode 100644 index 0000000..30c8076 --- /dev/null +++ b/test/unit/pixi-v2/display/Sprite.js @@ -0,0 +1,28 @@ +describe('pixi/display/Sprite', function () { + 'use strict'; + + var expect = chai.expect; + var Sprite = PIXI.Sprite; + var Texture = PIXI.Texture; + + it('Module exists', function () { + expect(Sprite).to.be.a('function'); + expect(PIXI).to.have.deep.property('blendModes.NORMAL', 0); + expect(PIXI).to.have.deep.property('blendModes.ADD', 1); + expect(PIXI).to.have.deep.property('blendModes.MULTIPLY', 2); + expect(PIXI).to.have.deep.property('blendModes.SCREEN', 3); + }); + + + it('Members exist', function () { + expect(Sprite).itself.to.respondTo('fromImage'); + expect(Sprite).itself.to.respondTo('fromFrame'); + }); + + it('Confirm new instance', function (done) { + var texture = Texture.fromImage('/base/test/textures/SpriteSheet-Aliens.png'); + var obj = new Sprite(texture); + + pixi_display_Sprite_confirmNew(obj, done); + }); +}); diff --git a/test/unit/pixi-v2/display/Stage.js b/test/unit/pixi-v2/display/Stage.js new file mode 100644 index 0000000..6974c2e --- /dev/null +++ b/test/unit/pixi-v2/display/Stage.js @@ -0,0 +1,49 @@ +describe('pixi/display/Stage', function () { + 'use strict'; + + var expect = chai.expect; + var Stage = PIXI.Stage; + var InteractionManager = PIXI.InteractionManager; + var Rectangle = PIXI.Rectangle; + + it('Module exists', function () { + expect(Stage).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Stage(null, true); + + pixi_display_DisplayObjectContainer_confirmNew(obj); + + expect(obj).to.be.an.instanceof(Stage); + expect(obj).to.respondTo('updateTransform'); + expect(obj).to.respondTo('setBackgroundColor'); + expect(obj).to.respondTo('getMousePosition'); + // FIXME: duplicate member in DisplayObject + pixi_core_Matrix_confirmNewMatrix(obj.worldTransform); + // FIXME: convert arg to bool in constructor + expect(obj).to.have.property('interactive', true); + + expect(obj).to.have.property('interactionManager') + .and.to.be.an.instanceof(InteractionManager) + .and.to.have.property('stage', obj); + + expect(obj).to.have.property('dirty', true); + + expect(obj).to.have.property('stage', obj); + + expect(obj).to.have.property('hitArea') + .and.to.be.an.instanceof(Rectangle); + pixi_core_Rectangle_confirm(obj.hitArea, 0, 0, 100000, 100000); + + expect(obj).to.have.property('backgroundColor', 0x000000); + expect(obj).to.have.deep.property('backgroundColorSplit.length', 3); + expect(obj).to.have.deep.property('backgroundColorSplit[0]', 0); + expect(obj).to.have.deep.property('backgroundColorSplit[1]', 0); + expect(obj).to.have.deep.property('backgroundColorSplit[2]', 0); + expect(obj).to.have.property('backgroundColorString', '#000000'); + + + expect(obj).to.have.property('worldVisible', true); + }); +}); diff --git a/test/unit/pixi-v2/extras/Rope.js b/test/unit/pixi-v2/extras/Rope.js new file mode 100644 index 0000000..05885ac --- /dev/null +++ b/test/unit/pixi-v2/extras/Rope.js @@ -0,0 +1,31 @@ +describe('pixi/extras/Rope', function () { + 'use strict'; + + var expect = chai.expect; + var Rope = PIXI.Rope; + var Texture = PIXI.Texture; + var Point = PIXI.Point; + + it('Module exists', function () { + expect(Rope).to.be.a('function'); + }); + + it('Confirm new instance', function () { + + var texture = Texture.fromImage('/base/test/textures/bunny.png'); + + // TODO-Alvin + // Same as Strip + + // var obj = new Rope(texture, [new Point(), new Point(5, 10), new Point(10, 20)]); + + // pixi_extras_Strip_confirmNew(obj); + + // expect(obj).to.be.an.instanceof(Rope); + // expect(obj).to.respondTo('refresh'); + // expect(obj).to.respondTo('updateTransform'); + // expect(obj).to.respondTo('setTexture'); + + // TODO: Test properties + }); +}); diff --git a/test/unit/pixi-v2/extras/Spine.js b/test/unit/pixi-v2/extras/Spine.js new file mode 100644 index 0000000..0708bc0 --- /dev/null +++ b/test/unit/pixi-v2/extras/Spine.js @@ -0,0 +1,10 @@ +describe('pixi/extras/Spine', function () { + 'use strict'; + + var expect = chai.expect; + var Spine = PIXI.Spine; + + it('Module exists', function () { + expect(Spine).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/extras/Strip.js b/test/unit/pixi-v2/extras/Strip.js new file mode 100644 index 0000000..230af90 --- /dev/null +++ b/test/unit/pixi-v2/extras/Strip.js @@ -0,0 +1,26 @@ +describe('pixi/extras/Strip', function () { + 'use strict'; + + var expect = chai.expect; + var Strip = PIXI.Strip; + var Texture = PIXI.Texture; + + it('Module exists', function () { + expect(Strip).to.be.a('function'); + }); + + it('Confirm new instance', function () { + + + // TODO-Alvin + // We tweaked it to make it pass the tests, but the whole strip class needs + // to be re-coded + + var texture = Texture.fromImage('/base/test/textures/bunny.png'); + + // var obj = new Strip(texture, 20, 10000); + + + // pixi_extras_Strip_confirmNew(obj); + }); +}); diff --git a/test/unit/pixi-v2/extras/TilingSprite.js b/test/unit/pixi-v2/extras/TilingSprite.js new file mode 100644 index 0000000..56aea14 --- /dev/null +++ b/test/unit/pixi-v2/extras/TilingSprite.js @@ -0,0 +1,24 @@ +describe('pixi/extras/TilingSprite', function () { + 'use strict'; + + var expect = chai.expect; + var TilingSprite = PIXI.TilingSprite; + var Texture = PIXI.Texture; + + it('Module exists', function () { + expect(TilingSprite).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var texture = Texture.fromImage('/base/test/textures/bunny.png'); + var obj = new TilingSprite(texture, 6000, 12000); + + pixi_display_DisplayObjectContainer_confirmNew(obj); + + expect(obj).to.be.an.instanceof(TilingSprite); + expect(obj).to.respondTo('setTexture'); + expect(obj).to.respondTo('onTextureUpdate'); + + // TODO: Test properties + }); +}); diff --git a/test/unit/pixi-v2/filters/FilterBlock.js b/test/unit/pixi-v2/filters/FilterBlock.js new file mode 100644 index 0000000..870cec0 --- /dev/null +++ b/test/unit/pixi-v2/filters/FilterBlock.js @@ -0,0 +1,10 @@ +describe('pixi/filters/FilterBlock', function () { + 'use strict'; + + var expect = chai.expect; + var FilterBlock = PIXI.FilterBlock; + + it('Module exists', function () { + expect(FilterBlock).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/AssetLoader.js b/test/unit/pixi-v2/loaders/AssetLoader.js new file mode 100644 index 0000000..a0aa0b5 --- /dev/null +++ b/test/unit/pixi-v2/loaders/AssetLoader.js @@ -0,0 +1,10 @@ +describe('pixi/loaders/AssetLoader', function () { + 'use strict'; + + var expect = chai.expect; + var AssetLoader = PIXI.AssetLoader; + + it('Module exists', function () { + expect(AssetLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/BitmapFontLoader.js b/test/unit/pixi-v2/loaders/BitmapFontLoader.js new file mode 100644 index 0000000..046f018 --- /dev/null +++ b/test/unit/pixi-v2/loaders/BitmapFontLoader.js @@ -0,0 +1,9 @@ +describe('pixi/loaders/BitmapFontLoader', function () { + 'use strict'; + + var expect = chai.expect; + + it('Module exists', function () { + expect(PIXI.BitmapFontLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/ImageLoader.js b/test/unit/pixi-v2/loaders/ImageLoader.js new file mode 100644 index 0000000..8b1f556 --- /dev/null +++ b/test/unit/pixi-v2/loaders/ImageLoader.js @@ -0,0 +1,10 @@ +describe('pixi/loaders/ImageLoader', function () { + 'use strict'; + + var expect = chai.expect; + var ImageLoader = PIXI.ImageLoader; + + it('Module exists', function () { + expect(ImageLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/JsonLoader.js b/test/unit/pixi-v2/loaders/JsonLoader.js new file mode 100644 index 0000000..c577e83 --- /dev/null +++ b/test/unit/pixi-v2/loaders/JsonLoader.js @@ -0,0 +1,10 @@ +describe('pixi/loaders/JsonLoader', function () { + 'use strict'; + + var expect = chai.expect; + var JsonLoader = PIXI.JsonLoader; + + it('Module exists', function () { + expect(JsonLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/InteractionManager.js b/test/unit/pixi-v2/InteractionManager.js new file mode 100644 index 0000000..ed3001f --- /dev/null +++ b/test/unit/pixi-v2/InteractionManager.js @@ -0,0 +1,10 @@ +describe('pixi/InteractionManager', function () { + 'use strict'; + + var expect = chai.expect; + var InteractionManager = PIXI.InteractionManager; + + it('Module exists', function () { + expect(InteractionManager).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/Pixi.js b/test/unit/pixi-v2/Pixi.js new file mode 100644 index 0000000..27debc1 --- /dev/null +++ b/test/unit/pixi-v2/Pixi.js @@ -0,0 +1,9 @@ +describe('pixi/Pixi', function () { + 'use strict'; + + var expect = chai.expect; + + it('Module exists', function () { + expect(global).to.have.property('PIXI').and.to.be.an('object'); + }); +}); diff --git a/test/unit/pixi-v2/core/Circle.js b/test/unit/pixi-v2/core/Circle.js new file mode 100644 index 0000000..fbcfa17 --- /dev/null +++ b/test/unit/pixi-v2/core/Circle.js @@ -0,0 +1,21 @@ +describe('pixi/core/Circle', function () { + 'use strict'; + + var expect = chai.expect; + var Circle = PIXI.Circle; + + it('Module exists', function () { + expect(Circle).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Circle(); + pixi_core_Circle_confirmNewCircle(obj); + }); + + it("getBounds should return Rectangle that bounds the circle", function() { + var obj = new Circle(100, 250, 50); + var bounds = obj.getBounds(); + pixi_core_Circle_isBoundedByRectangle(obj, bounds); + }); +}); diff --git a/test/unit/pixi-v2/core/Ellipse.js b/test/unit/pixi-v2/core/Ellipse.js new file mode 100644 index 0000000..026b56f --- /dev/null +++ b/test/unit/pixi-v2/core/Ellipse.js @@ -0,0 +1,24 @@ +describe('pixi/core/Ellipse', function () { + 'use strict'; + + var expect = chai.expect; + var Ellipse = PIXI.Ellipse; + + it('Module exists', function () { + expect(Ellipse).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Ellipse(); + + expect(obj).to.be.an.instanceof(Ellipse); + expect(obj).to.respondTo('clone'); + expect(obj).to.respondTo('contains'); + expect(obj).to.respondTo('getBounds'); + + expect(obj).to.have.property('x', 0); + expect(obj).to.have.property('y', 0); + expect(obj).to.have.property('width', 0); + expect(obj).to.have.property('height', 0); + }); +}); diff --git a/test/unit/pixi-v2/core/Matrix.js b/test/unit/pixi-v2/core/Matrix.js new file mode 100644 index 0000000..da75e2e --- /dev/null +++ b/test/unit/pixi-v2/core/Matrix.js @@ -0,0 +1,14 @@ +describe('pixi/core/Matrix', function () { + 'use strict'; + + var expect = chai.expect; + + it('Matrix exists', function () { + expect(PIXI.Matrix).to.be.an('function'); + }); + + it('Confirm new Matrix', function () { + var matrix = new PIXI.Matrix(); + pixi_core_Matrix_confirmNewMatrix(matrix); + }); +}); diff --git a/test/unit/pixi-v2/core/Point.js b/test/unit/pixi-v2/core/Point.js new file mode 100644 index 0000000..c4d5163 --- /dev/null +++ b/test/unit/pixi-v2/core/Point.js @@ -0,0 +1,15 @@ +describe('pixi/core/Point', function () { + 'use strict'; + + var expect = chai.expect; + var Point = PIXI.Point; + + it('Module exists', function () { + expect(Point).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Point(); + pixi_core_Point_confirm(obj, 0, 0); + }); +}); diff --git a/test/unit/pixi-v2/core/Polygon.js b/test/unit/pixi-v2/core/Polygon.js new file mode 100644 index 0000000..dc8c918 --- /dev/null +++ b/test/unit/pixi-v2/core/Polygon.js @@ -0,0 +1,20 @@ +describe('pixi/core/Polygon', function () { + 'use strict'; + + var expect = chai.expect; + var Polygon = PIXI.Polygon; + + it('Module exists', function () { + expect(Polygon).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Polygon(); + + expect(obj).to.be.an.instanceof(Polygon); + expect(obj).to.respondTo('clone'); + expect(obj).to.respondTo('contains'); + + expect(obj).to.have.deep.property('points.length', 0); + }); +}); diff --git a/test/unit/pixi-v2/core/Rectangle.js b/test/unit/pixi-v2/core/Rectangle.js new file mode 100644 index 0000000..d43316e --- /dev/null +++ b/test/unit/pixi-v2/core/Rectangle.js @@ -0,0 +1,15 @@ +describe('pixi/core/Rectangle', function () { + 'use strict'; + + var expect = chai.expect; + var Rectangle = PIXI.Rectangle; + + it('Module exists', function () { + expect(Rectangle).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var rect = new Rectangle(); + pixi_core_Rectangle_confirm(rect, 0, 0, 0, 0); + }); +}); diff --git a/test/unit/pixi-v2/display/DisplayObject.js b/test/unit/pixi-v2/display/DisplayObject.js new file mode 100644 index 0000000..044acf8 --- /dev/null +++ b/test/unit/pixi-v2/display/DisplayObject.js @@ -0,0 +1,21 @@ +describe('pixi/display/DisplayObject', function () { + 'use strict'; + + var expect = chai.expect; + var DisplayObject = PIXI.DisplayObject; + + it('Module exists', function () { + expect(DisplayObject).to.be.a('function'); + // expect(PIXI).to.have.property('visibleCount', 0); + }); + + it('Confirm new instance', function () { + var obj = new DisplayObject(); + + pixi_display_DisplayObject_confirmNew(obj); + expect(obj).to.have.property('hitArea', null); + expect(obj).to.have.property('interactive', false); + expect(obj).to.have.property('renderable', false); + expect(obj).to.have.property('stage', null); + }); +}); diff --git a/test/unit/pixi-v2/display/DisplayObjectContainer.js b/test/unit/pixi-v2/display/DisplayObjectContainer.js new file mode 100644 index 0000000..15a3376 --- /dev/null +++ b/test/unit/pixi-v2/display/DisplayObjectContainer.js @@ -0,0 +1,67 @@ +describe('pixi/display/DisplayObjectContainer', function () { + 'use strict'; + + var expect = chai.expect; + var DisplayObjectContainer = PIXI.DisplayObjectContainer; + + it('Module exists', function () { + expect(DisplayObjectContainer).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new DisplayObjectContainer(); + + pixi_display_DisplayObjectContainer_confirmNew(obj); + expect(obj).to.have.property('hitArea', null); + expect(obj).to.have.property('interactive', false); + expect(obj).to.have.property('renderable', false); + expect(obj).to.have.property('stage', null); + }); + + it('Gets child index', function() { + var container = new PIXI.DisplayObjectContainer(); + var children = []; + for (var i = 0; i < 10; i++) { + var child = new PIXI.DisplayObject(); + children.push(child); + container.addChild(child); + } + + for (i = 0; i < children.length; i++) { + expect(i).to.eql(container.getChildIndex(children[i])); + } + }); + + it('throws error when trying to get index of not a child', function() { + var container = new PIXI.DisplayObjectContainer(); + var child = new PIXI.DisplayObject(); + + expect(function() { container.getChildIndex(child); }).to.throw(); + }); + + it('Sets child index', function() { + var container = new PIXI.DisplayObjectContainer(); + var children = []; + + for (var i = 0; i < 10; i++) { + var child = new PIXI.DisplayObject(); + children.push(child); + container.addChild(child); + } + children.reverse(); + + for (i = 0; i < children.length; i++) { + container.setChildIndex(children[i], i); + expect(i).to.eql(container.getChildIndex(children[i])); + } + }); + + it('throws error when trying to set incorect index', function() { + var container = new PIXI.DisplayObjectContainer(); + var child = new PIXI.DisplayObject(); + container.addChild(child); + + expect(function() { container.setChildIndex(child, -1); }).to.throw(); + expect(function() { container.setChildIndex(child, 1); }).to.throw(); + }); +}); diff --git a/test/unit/pixi-v2/display/MovieClip.js b/test/unit/pixi-v2/display/MovieClip.js new file mode 100644 index 0000000..f3c6c6a --- /dev/null +++ b/test/unit/pixi-v2/display/MovieClip.js @@ -0,0 +1,33 @@ +describe('pixi/display/MovieClip', function () { + 'use strict'; + + var expect = chai.expect; + var MovieClip = PIXI.MovieClip; + var Texture = PIXI.Texture; + + it('Module exists', function () { + expect(MovieClip).to.be.a('function'); + }); + + it('Confirm new instance', function (done) { + var texture = Texture.fromImage('/base/test/textures/SpriteSheet-Explosion.png'); + var obj = new MovieClip([texture]); + + pixi_display_Sprite_confirmNew(obj, done); + + expect(obj).to.be.an.instanceof(MovieClip); + expect(obj).to.respondTo('stop'); + expect(obj).to.respondTo('play'); + expect(obj).to.respondTo('gotoAndStop'); + expect(obj).to.respondTo('gotoAndPlay'); + expect(obj).to.respondTo('updateTransform'); + + expect(obj).to.have.deep.property('textures.length', 1); + expect(obj).to.have.deep.property('textures[0]', texture); + expect(obj).to.have.property('animationSpeed', 1); + expect(obj).to.have.property('loop', true); + expect(obj).to.have.property('onComplete', null); + expect(obj).to.have.property('currentFrame', 0); + expect(obj).to.have.property('playing', false); + }); +}); diff --git a/test/unit/pixi-v2/display/Sprite.js b/test/unit/pixi-v2/display/Sprite.js new file mode 100644 index 0000000..30c8076 --- /dev/null +++ b/test/unit/pixi-v2/display/Sprite.js @@ -0,0 +1,28 @@ +describe('pixi/display/Sprite', function () { + 'use strict'; + + var expect = chai.expect; + var Sprite = PIXI.Sprite; + var Texture = PIXI.Texture; + + it('Module exists', function () { + expect(Sprite).to.be.a('function'); + expect(PIXI).to.have.deep.property('blendModes.NORMAL', 0); + expect(PIXI).to.have.deep.property('blendModes.ADD', 1); + expect(PIXI).to.have.deep.property('blendModes.MULTIPLY', 2); + expect(PIXI).to.have.deep.property('blendModes.SCREEN', 3); + }); + + + it('Members exist', function () { + expect(Sprite).itself.to.respondTo('fromImage'); + expect(Sprite).itself.to.respondTo('fromFrame'); + }); + + it('Confirm new instance', function (done) { + var texture = Texture.fromImage('/base/test/textures/SpriteSheet-Aliens.png'); + var obj = new Sprite(texture); + + pixi_display_Sprite_confirmNew(obj, done); + }); +}); diff --git a/test/unit/pixi-v2/display/Stage.js b/test/unit/pixi-v2/display/Stage.js new file mode 100644 index 0000000..6974c2e --- /dev/null +++ b/test/unit/pixi-v2/display/Stage.js @@ -0,0 +1,49 @@ +describe('pixi/display/Stage', function () { + 'use strict'; + + var expect = chai.expect; + var Stage = PIXI.Stage; + var InteractionManager = PIXI.InteractionManager; + var Rectangle = PIXI.Rectangle; + + it('Module exists', function () { + expect(Stage).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Stage(null, true); + + pixi_display_DisplayObjectContainer_confirmNew(obj); + + expect(obj).to.be.an.instanceof(Stage); + expect(obj).to.respondTo('updateTransform'); + expect(obj).to.respondTo('setBackgroundColor'); + expect(obj).to.respondTo('getMousePosition'); + // FIXME: duplicate member in DisplayObject + pixi_core_Matrix_confirmNewMatrix(obj.worldTransform); + // FIXME: convert arg to bool in constructor + expect(obj).to.have.property('interactive', true); + + expect(obj).to.have.property('interactionManager') + .and.to.be.an.instanceof(InteractionManager) + .and.to.have.property('stage', obj); + + expect(obj).to.have.property('dirty', true); + + expect(obj).to.have.property('stage', obj); + + expect(obj).to.have.property('hitArea') + .and.to.be.an.instanceof(Rectangle); + pixi_core_Rectangle_confirm(obj.hitArea, 0, 0, 100000, 100000); + + expect(obj).to.have.property('backgroundColor', 0x000000); + expect(obj).to.have.deep.property('backgroundColorSplit.length', 3); + expect(obj).to.have.deep.property('backgroundColorSplit[0]', 0); + expect(obj).to.have.deep.property('backgroundColorSplit[1]', 0); + expect(obj).to.have.deep.property('backgroundColorSplit[2]', 0); + expect(obj).to.have.property('backgroundColorString', '#000000'); + + + expect(obj).to.have.property('worldVisible', true); + }); +}); diff --git a/test/unit/pixi-v2/extras/Rope.js b/test/unit/pixi-v2/extras/Rope.js new file mode 100644 index 0000000..05885ac --- /dev/null +++ b/test/unit/pixi-v2/extras/Rope.js @@ -0,0 +1,31 @@ +describe('pixi/extras/Rope', function () { + 'use strict'; + + var expect = chai.expect; + var Rope = PIXI.Rope; + var Texture = PIXI.Texture; + var Point = PIXI.Point; + + it('Module exists', function () { + expect(Rope).to.be.a('function'); + }); + + it('Confirm new instance', function () { + + var texture = Texture.fromImage('/base/test/textures/bunny.png'); + + // TODO-Alvin + // Same as Strip + + // var obj = new Rope(texture, [new Point(), new Point(5, 10), new Point(10, 20)]); + + // pixi_extras_Strip_confirmNew(obj); + + // expect(obj).to.be.an.instanceof(Rope); + // expect(obj).to.respondTo('refresh'); + // expect(obj).to.respondTo('updateTransform'); + // expect(obj).to.respondTo('setTexture'); + + // TODO: Test properties + }); +}); diff --git a/test/unit/pixi-v2/extras/Spine.js b/test/unit/pixi-v2/extras/Spine.js new file mode 100644 index 0000000..0708bc0 --- /dev/null +++ b/test/unit/pixi-v2/extras/Spine.js @@ -0,0 +1,10 @@ +describe('pixi/extras/Spine', function () { + 'use strict'; + + var expect = chai.expect; + var Spine = PIXI.Spine; + + it('Module exists', function () { + expect(Spine).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/extras/Strip.js b/test/unit/pixi-v2/extras/Strip.js new file mode 100644 index 0000000..230af90 --- /dev/null +++ b/test/unit/pixi-v2/extras/Strip.js @@ -0,0 +1,26 @@ +describe('pixi/extras/Strip', function () { + 'use strict'; + + var expect = chai.expect; + var Strip = PIXI.Strip; + var Texture = PIXI.Texture; + + it('Module exists', function () { + expect(Strip).to.be.a('function'); + }); + + it('Confirm new instance', function () { + + + // TODO-Alvin + // We tweaked it to make it pass the tests, but the whole strip class needs + // to be re-coded + + var texture = Texture.fromImage('/base/test/textures/bunny.png'); + + // var obj = new Strip(texture, 20, 10000); + + + // pixi_extras_Strip_confirmNew(obj); + }); +}); diff --git a/test/unit/pixi-v2/extras/TilingSprite.js b/test/unit/pixi-v2/extras/TilingSprite.js new file mode 100644 index 0000000..56aea14 --- /dev/null +++ b/test/unit/pixi-v2/extras/TilingSprite.js @@ -0,0 +1,24 @@ +describe('pixi/extras/TilingSprite', function () { + 'use strict'; + + var expect = chai.expect; + var TilingSprite = PIXI.TilingSprite; + var Texture = PIXI.Texture; + + it('Module exists', function () { + expect(TilingSprite).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var texture = Texture.fromImage('/base/test/textures/bunny.png'); + var obj = new TilingSprite(texture, 6000, 12000); + + pixi_display_DisplayObjectContainer_confirmNew(obj); + + expect(obj).to.be.an.instanceof(TilingSprite); + expect(obj).to.respondTo('setTexture'); + expect(obj).to.respondTo('onTextureUpdate'); + + // TODO: Test properties + }); +}); diff --git a/test/unit/pixi-v2/filters/FilterBlock.js b/test/unit/pixi-v2/filters/FilterBlock.js new file mode 100644 index 0000000..870cec0 --- /dev/null +++ b/test/unit/pixi-v2/filters/FilterBlock.js @@ -0,0 +1,10 @@ +describe('pixi/filters/FilterBlock', function () { + 'use strict'; + + var expect = chai.expect; + var FilterBlock = PIXI.FilterBlock; + + it('Module exists', function () { + expect(FilterBlock).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/AssetLoader.js b/test/unit/pixi-v2/loaders/AssetLoader.js new file mode 100644 index 0000000..a0aa0b5 --- /dev/null +++ b/test/unit/pixi-v2/loaders/AssetLoader.js @@ -0,0 +1,10 @@ +describe('pixi/loaders/AssetLoader', function () { + 'use strict'; + + var expect = chai.expect; + var AssetLoader = PIXI.AssetLoader; + + it('Module exists', function () { + expect(AssetLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/BitmapFontLoader.js b/test/unit/pixi-v2/loaders/BitmapFontLoader.js new file mode 100644 index 0000000..046f018 --- /dev/null +++ b/test/unit/pixi-v2/loaders/BitmapFontLoader.js @@ -0,0 +1,9 @@ +describe('pixi/loaders/BitmapFontLoader', function () { + 'use strict'; + + var expect = chai.expect; + + it('Module exists', function () { + expect(PIXI.BitmapFontLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/ImageLoader.js b/test/unit/pixi-v2/loaders/ImageLoader.js new file mode 100644 index 0000000..8b1f556 --- /dev/null +++ b/test/unit/pixi-v2/loaders/ImageLoader.js @@ -0,0 +1,10 @@ +describe('pixi/loaders/ImageLoader', function () { + 'use strict'; + + var expect = chai.expect; + var ImageLoader = PIXI.ImageLoader; + + it('Module exists', function () { + expect(ImageLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/JsonLoader.js b/test/unit/pixi-v2/loaders/JsonLoader.js new file mode 100644 index 0000000..c577e83 --- /dev/null +++ b/test/unit/pixi-v2/loaders/JsonLoader.js @@ -0,0 +1,10 @@ +describe('pixi/loaders/JsonLoader', function () { + 'use strict'; + + var expect = chai.expect; + var JsonLoader = PIXI.JsonLoader; + + it('Module exists', function () { + expect(JsonLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/SpineLoader.js b/test/unit/pixi-v2/loaders/SpineLoader.js new file mode 100644 index 0000000..fdcc0b8 --- /dev/null +++ b/test/unit/pixi-v2/loaders/SpineLoader.js @@ -0,0 +1,10 @@ +describe('pixi/loaders/SpineLoader', function () { + 'use strict'; + + var expect = chai.expect; + var SpineLoader = PIXI.SpineLoader; + + it('Module exists', function () { + expect(SpineLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/InteractionManager.js b/test/unit/pixi-v2/InteractionManager.js new file mode 100644 index 0000000..ed3001f --- /dev/null +++ b/test/unit/pixi-v2/InteractionManager.js @@ -0,0 +1,10 @@ +describe('pixi/InteractionManager', function () { + 'use strict'; + + var expect = chai.expect; + var InteractionManager = PIXI.InteractionManager; + + it('Module exists', function () { + expect(InteractionManager).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/Pixi.js b/test/unit/pixi-v2/Pixi.js new file mode 100644 index 0000000..27debc1 --- /dev/null +++ b/test/unit/pixi-v2/Pixi.js @@ -0,0 +1,9 @@ +describe('pixi/Pixi', function () { + 'use strict'; + + var expect = chai.expect; + + it('Module exists', function () { + expect(global).to.have.property('PIXI').and.to.be.an('object'); + }); +}); diff --git a/test/unit/pixi-v2/core/Circle.js b/test/unit/pixi-v2/core/Circle.js new file mode 100644 index 0000000..fbcfa17 --- /dev/null +++ b/test/unit/pixi-v2/core/Circle.js @@ -0,0 +1,21 @@ +describe('pixi/core/Circle', function () { + 'use strict'; + + var expect = chai.expect; + var Circle = PIXI.Circle; + + it('Module exists', function () { + expect(Circle).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Circle(); + pixi_core_Circle_confirmNewCircle(obj); + }); + + it("getBounds should return Rectangle that bounds the circle", function() { + var obj = new Circle(100, 250, 50); + var bounds = obj.getBounds(); + pixi_core_Circle_isBoundedByRectangle(obj, bounds); + }); +}); diff --git a/test/unit/pixi-v2/core/Ellipse.js b/test/unit/pixi-v2/core/Ellipse.js new file mode 100644 index 0000000..026b56f --- /dev/null +++ b/test/unit/pixi-v2/core/Ellipse.js @@ -0,0 +1,24 @@ +describe('pixi/core/Ellipse', function () { + 'use strict'; + + var expect = chai.expect; + var Ellipse = PIXI.Ellipse; + + it('Module exists', function () { + expect(Ellipse).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Ellipse(); + + expect(obj).to.be.an.instanceof(Ellipse); + expect(obj).to.respondTo('clone'); + expect(obj).to.respondTo('contains'); + expect(obj).to.respondTo('getBounds'); + + expect(obj).to.have.property('x', 0); + expect(obj).to.have.property('y', 0); + expect(obj).to.have.property('width', 0); + expect(obj).to.have.property('height', 0); + }); +}); diff --git a/test/unit/pixi-v2/core/Matrix.js b/test/unit/pixi-v2/core/Matrix.js new file mode 100644 index 0000000..da75e2e --- /dev/null +++ b/test/unit/pixi-v2/core/Matrix.js @@ -0,0 +1,14 @@ +describe('pixi/core/Matrix', function () { + 'use strict'; + + var expect = chai.expect; + + it('Matrix exists', function () { + expect(PIXI.Matrix).to.be.an('function'); + }); + + it('Confirm new Matrix', function () { + var matrix = new PIXI.Matrix(); + pixi_core_Matrix_confirmNewMatrix(matrix); + }); +}); diff --git a/test/unit/pixi-v2/core/Point.js b/test/unit/pixi-v2/core/Point.js new file mode 100644 index 0000000..c4d5163 --- /dev/null +++ b/test/unit/pixi-v2/core/Point.js @@ -0,0 +1,15 @@ +describe('pixi/core/Point', function () { + 'use strict'; + + var expect = chai.expect; + var Point = PIXI.Point; + + it('Module exists', function () { + expect(Point).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Point(); + pixi_core_Point_confirm(obj, 0, 0); + }); +}); diff --git a/test/unit/pixi-v2/core/Polygon.js b/test/unit/pixi-v2/core/Polygon.js new file mode 100644 index 0000000..dc8c918 --- /dev/null +++ b/test/unit/pixi-v2/core/Polygon.js @@ -0,0 +1,20 @@ +describe('pixi/core/Polygon', function () { + 'use strict'; + + var expect = chai.expect; + var Polygon = PIXI.Polygon; + + it('Module exists', function () { + expect(Polygon).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Polygon(); + + expect(obj).to.be.an.instanceof(Polygon); + expect(obj).to.respondTo('clone'); + expect(obj).to.respondTo('contains'); + + expect(obj).to.have.deep.property('points.length', 0); + }); +}); diff --git a/test/unit/pixi-v2/core/Rectangle.js b/test/unit/pixi-v2/core/Rectangle.js new file mode 100644 index 0000000..d43316e --- /dev/null +++ b/test/unit/pixi-v2/core/Rectangle.js @@ -0,0 +1,15 @@ +describe('pixi/core/Rectangle', function () { + 'use strict'; + + var expect = chai.expect; + var Rectangle = PIXI.Rectangle; + + it('Module exists', function () { + expect(Rectangle).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var rect = new Rectangle(); + pixi_core_Rectangle_confirm(rect, 0, 0, 0, 0); + }); +}); diff --git a/test/unit/pixi-v2/display/DisplayObject.js b/test/unit/pixi-v2/display/DisplayObject.js new file mode 100644 index 0000000..044acf8 --- /dev/null +++ b/test/unit/pixi-v2/display/DisplayObject.js @@ -0,0 +1,21 @@ +describe('pixi/display/DisplayObject', function () { + 'use strict'; + + var expect = chai.expect; + var DisplayObject = PIXI.DisplayObject; + + it('Module exists', function () { + expect(DisplayObject).to.be.a('function'); + // expect(PIXI).to.have.property('visibleCount', 0); + }); + + it('Confirm new instance', function () { + var obj = new DisplayObject(); + + pixi_display_DisplayObject_confirmNew(obj); + expect(obj).to.have.property('hitArea', null); + expect(obj).to.have.property('interactive', false); + expect(obj).to.have.property('renderable', false); + expect(obj).to.have.property('stage', null); + }); +}); diff --git a/test/unit/pixi-v2/display/DisplayObjectContainer.js b/test/unit/pixi-v2/display/DisplayObjectContainer.js new file mode 100644 index 0000000..15a3376 --- /dev/null +++ b/test/unit/pixi-v2/display/DisplayObjectContainer.js @@ -0,0 +1,67 @@ +describe('pixi/display/DisplayObjectContainer', function () { + 'use strict'; + + var expect = chai.expect; + var DisplayObjectContainer = PIXI.DisplayObjectContainer; + + it('Module exists', function () { + expect(DisplayObjectContainer).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new DisplayObjectContainer(); + + pixi_display_DisplayObjectContainer_confirmNew(obj); + expect(obj).to.have.property('hitArea', null); + expect(obj).to.have.property('interactive', false); + expect(obj).to.have.property('renderable', false); + expect(obj).to.have.property('stage', null); + }); + + it('Gets child index', function() { + var container = new PIXI.DisplayObjectContainer(); + var children = []; + for (var i = 0; i < 10; i++) { + var child = new PIXI.DisplayObject(); + children.push(child); + container.addChild(child); + } + + for (i = 0; i < children.length; i++) { + expect(i).to.eql(container.getChildIndex(children[i])); + } + }); + + it('throws error when trying to get index of not a child', function() { + var container = new PIXI.DisplayObjectContainer(); + var child = new PIXI.DisplayObject(); + + expect(function() { container.getChildIndex(child); }).to.throw(); + }); + + it('Sets child index', function() { + var container = new PIXI.DisplayObjectContainer(); + var children = []; + + for (var i = 0; i < 10; i++) { + var child = new PIXI.DisplayObject(); + children.push(child); + container.addChild(child); + } + children.reverse(); + + for (i = 0; i < children.length; i++) { + container.setChildIndex(children[i], i); + expect(i).to.eql(container.getChildIndex(children[i])); + } + }); + + it('throws error when trying to set incorect index', function() { + var container = new PIXI.DisplayObjectContainer(); + var child = new PIXI.DisplayObject(); + container.addChild(child); + + expect(function() { container.setChildIndex(child, -1); }).to.throw(); + expect(function() { container.setChildIndex(child, 1); }).to.throw(); + }); +}); diff --git a/test/unit/pixi-v2/display/MovieClip.js b/test/unit/pixi-v2/display/MovieClip.js new file mode 100644 index 0000000..f3c6c6a --- /dev/null +++ b/test/unit/pixi-v2/display/MovieClip.js @@ -0,0 +1,33 @@ +describe('pixi/display/MovieClip', function () { + 'use strict'; + + var expect = chai.expect; + var MovieClip = PIXI.MovieClip; + var Texture = PIXI.Texture; + + it('Module exists', function () { + expect(MovieClip).to.be.a('function'); + }); + + it('Confirm new instance', function (done) { + var texture = Texture.fromImage('/base/test/textures/SpriteSheet-Explosion.png'); + var obj = new MovieClip([texture]); + + pixi_display_Sprite_confirmNew(obj, done); + + expect(obj).to.be.an.instanceof(MovieClip); + expect(obj).to.respondTo('stop'); + expect(obj).to.respondTo('play'); + expect(obj).to.respondTo('gotoAndStop'); + expect(obj).to.respondTo('gotoAndPlay'); + expect(obj).to.respondTo('updateTransform'); + + expect(obj).to.have.deep.property('textures.length', 1); + expect(obj).to.have.deep.property('textures[0]', texture); + expect(obj).to.have.property('animationSpeed', 1); + expect(obj).to.have.property('loop', true); + expect(obj).to.have.property('onComplete', null); + expect(obj).to.have.property('currentFrame', 0); + expect(obj).to.have.property('playing', false); + }); +}); diff --git a/test/unit/pixi-v2/display/Sprite.js b/test/unit/pixi-v2/display/Sprite.js new file mode 100644 index 0000000..30c8076 --- /dev/null +++ b/test/unit/pixi-v2/display/Sprite.js @@ -0,0 +1,28 @@ +describe('pixi/display/Sprite', function () { + 'use strict'; + + var expect = chai.expect; + var Sprite = PIXI.Sprite; + var Texture = PIXI.Texture; + + it('Module exists', function () { + expect(Sprite).to.be.a('function'); + expect(PIXI).to.have.deep.property('blendModes.NORMAL', 0); + expect(PIXI).to.have.deep.property('blendModes.ADD', 1); + expect(PIXI).to.have.deep.property('blendModes.MULTIPLY', 2); + expect(PIXI).to.have.deep.property('blendModes.SCREEN', 3); + }); + + + it('Members exist', function () { + expect(Sprite).itself.to.respondTo('fromImage'); + expect(Sprite).itself.to.respondTo('fromFrame'); + }); + + it('Confirm new instance', function (done) { + var texture = Texture.fromImage('/base/test/textures/SpriteSheet-Aliens.png'); + var obj = new Sprite(texture); + + pixi_display_Sprite_confirmNew(obj, done); + }); +}); diff --git a/test/unit/pixi-v2/display/Stage.js b/test/unit/pixi-v2/display/Stage.js new file mode 100644 index 0000000..6974c2e --- /dev/null +++ b/test/unit/pixi-v2/display/Stage.js @@ -0,0 +1,49 @@ +describe('pixi/display/Stage', function () { + 'use strict'; + + var expect = chai.expect; + var Stage = PIXI.Stage; + var InteractionManager = PIXI.InteractionManager; + var Rectangle = PIXI.Rectangle; + + it('Module exists', function () { + expect(Stage).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Stage(null, true); + + pixi_display_DisplayObjectContainer_confirmNew(obj); + + expect(obj).to.be.an.instanceof(Stage); + expect(obj).to.respondTo('updateTransform'); + expect(obj).to.respondTo('setBackgroundColor'); + expect(obj).to.respondTo('getMousePosition'); + // FIXME: duplicate member in DisplayObject + pixi_core_Matrix_confirmNewMatrix(obj.worldTransform); + // FIXME: convert arg to bool in constructor + expect(obj).to.have.property('interactive', true); + + expect(obj).to.have.property('interactionManager') + .and.to.be.an.instanceof(InteractionManager) + .and.to.have.property('stage', obj); + + expect(obj).to.have.property('dirty', true); + + expect(obj).to.have.property('stage', obj); + + expect(obj).to.have.property('hitArea') + .and.to.be.an.instanceof(Rectangle); + pixi_core_Rectangle_confirm(obj.hitArea, 0, 0, 100000, 100000); + + expect(obj).to.have.property('backgroundColor', 0x000000); + expect(obj).to.have.deep.property('backgroundColorSplit.length', 3); + expect(obj).to.have.deep.property('backgroundColorSplit[0]', 0); + expect(obj).to.have.deep.property('backgroundColorSplit[1]', 0); + expect(obj).to.have.deep.property('backgroundColorSplit[2]', 0); + expect(obj).to.have.property('backgroundColorString', '#000000'); + + + expect(obj).to.have.property('worldVisible', true); + }); +}); diff --git a/test/unit/pixi-v2/extras/Rope.js b/test/unit/pixi-v2/extras/Rope.js new file mode 100644 index 0000000..05885ac --- /dev/null +++ b/test/unit/pixi-v2/extras/Rope.js @@ -0,0 +1,31 @@ +describe('pixi/extras/Rope', function () { + 'use strict'; + + var expect = chai.expect; + var Rope = PIXI.Rope; + var Texture = PIXI.Texture; + var Point = PIXI.Point; + + it('Module exists', function () { + expect(Rope).to.be.a('function'); + }); + + it('Confirm new instance', function () { + + var texture = Texture.fromImage('/base/test/textures/bunny.png'); + + // TODO-Alvin + // Same as Strip + + // var obj = new Rope(texture, [new Point(), new Point(5, 10), new Point(10, 20)]); + + // pixi_extras_Strip_confirmNew(obj); + + // expect(obj).to.be.an.instanceof(Rope); + // expect(obj).to.respondTo('refresh'); + // expect(obj).to.respondTo('updateTransform'); + // expect(obj).to.respondTo('setTexture'); + + // TODO: Test properties + }); +}); diff --git a/test/unit/pixi-v2/extras/Spine.js b/test/unit/pixi-v2/extras/Spine.js new file mode 100644 index 0000000..0708bc0 --- /dev/null +++ b/test/unit/pixi-v2/extras/Spine.js @@ -0,0 +1,10 @@ +describe('pixi/extras/Spine', function () { + 'use strict'; + + var expect = chai.expect; + var Spine = PIXI.Spine; + + it('Module exists', function () { + expect(Spine).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/extras/Strip.js b/test/unit/pixi-v2/extras/Strip.js new file mode 100644 index 0000000..230af90 --- /dev/null +++ b/test/unit/pixi-v2/extras/Strip.js @@ -0,0 +1,26 @@ +describe('pixi/extras/Strip', function () { + 'use strict'; + + var expect = chai.expect; + var Strip = PIXI.Strip; + var Texture = PIXI.Texture; + + it('Module exists', function () { + expect(Strip).to.be.a('function'); + }); + + it('Confirm new instance', function () { + + + // TODO-Alvin + // We tweaked it to make it pass the tests, but the whole strip class needs + // to be re-coded + + var texture = Texture.fromImage('/base/test/textures/bunny.png'); + + // var obj = new Strip(texture, 20, 10000); + + + // pixi_extras_Strip_confirmNew(obj); + }); +}); diff --git a/test/unit/pixi-v2/extras/TilingSprite.js b/test/unit/pixi-v2/extras/TilingSprite.js new file mode 100644 index 0000000..56aea14 --- /dev/null +++ b/test/unit/pixi-v2/extras/TilingSprite.js @@ -0,0 +1,24 @@ +describe('pixi/extras/TilingSprite', function () { + 'use strict'; + + var expect = chai.expect; + var TilingSprite = PIXI.TilingSprite; + var Texture = PIXI.Texture; + + it('Module exists', function () { + expect(TilingSprite).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var texture = Texture.fromImage('/base/test/textures/bunny.png'); + var obj = new TilingSprite(texture, 6000, 12000); + + pixi_display_DisplayObjectContainer_confirmNew(obj); + + expect(obj).to.be.an.instanceof(TilingSprite); + expect(obj).to.respondTo('setTexture'); + expect(obj).to.respondTo('onTextureUpdate'); + + // TODO: Test properties + }); +}); diff --git a/test/unit/pixi-v2/filters/FilterBlock.js b/test/unit/pixi-v2/filters/FilterBlock.js new file mode 100644 index 0000000..870cec0 --- /dev/null +++ b/test/unit/pixi-v2/filters/FilterBlock.js @@ -0,0 +1,10 @@ +describe('pixi/filters/FilterBlock', function () { + 'use strict'; + + var expect = chai.expect; + var FilterBlock = PIXI.FilterBlock; + + it('Module exists', function () { + expect(FilterBlock).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/AssetLoader.js b/test/unit/pixi-v2/loaders/AssetLoader.js new file mode 100644 index 0000000..a0aa0b5 --- /dev/null +++ b/test/unit/pixi-v2/loaders/AssetLoader.js @@ -0,0 +1,10 @@ +describe('pixi/loaders/AssetLoader', function () { + 'use strict'; + + var expect = chai.expect; + var AssetLoader = PIXI.AssetLoader; + + it('Module exists', function () { + expect(AssetLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/BitmapFontLoader.js b/test/unit/pixi-v2/loaders/BitmapFontLoader.js new file mode 100644 index 0000000..046f018 --- /dev/null +++ b/test/unit/pixi-v2/loaders/BitmapFontLoader.js @@ -0,0 +1,9 @@ +describe('pixi/loaders/BitmapFontLoader', function () { + 'use strict'; + + var expect = chai.expect; + + it('Module exists', function () { + expect(PIXI.BitmapFontLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/ImageLoader.js b/test/unit/pixi-v2/loaders/ImageLoader.js new file mode 100644 index 0000000..8b1f556 --- /dev/null +++ b/test/unit/pixi-v2/loaders/ImageLoader.js @@ -0,0 +1,10 @@ +describe('pixi/loaders/ImageLoader', function () { + 'use strict'; + + var expect = chai.expect; + var ImageLoader = PIXI.ImageLoader; + + it('Module exists', function () { + expect(ImageLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/JsonLoader.js b/test/unit/pixi-v2/loaders/JsonLoader.js new file mode 100644 index 0000000..c577e83 --- /dev/null +++ b/test/unit/pixi-v2/loaders/JsonLoader.js @@ -0,0 +1,10 @@ +describe('pixi/loaders/JsonLoader', function () { + 'use strict'; + + var expect = chai.expect; + var JsonLoader = PIXI.JsonLoader; + + it('Module exists', function () { + expect(JsonLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/SpineLoader.js b/test/unit/pixi-v2/loaders/SpineLoader.js new file mode 100644 index 0000000..fdcc0b8 --- /dev/null +++ b/test/unit/pixi-v2/loaders/SpineLoader.js @@ -0,0 +1,10 @@ +describe('pixi/loaders/SpineLoader', function () { + 'use strict'; + + var expect = chai.expect; + var SpineLoader = PIXI.SpineLoader; + + it('Module exists', function () { + expect(SpineLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/SpriteSheetLoader.js b/test/unit/pixi-v2/loaders/SpriteSheetLoader.js new file mode 100644 index 0000000..57beb27 --- /dev/null +++ b/test/unit/pixi-v2/loaders/SpriteSheetLoader.js @@ -0,0 +1,10 @@ +describe('pixi/loaders/SpriteSheetLoader', function () { + 'use strict'; + + var expect = chai.expect; + var SpriteSheetLoader = PIXI.SpriteSheetLoader; + + it('Module exists', function () { + expect(SpriteSheetLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/InteractionManager.js b/test/unit/pixi-v2/InteractionManager.js new file mode 100644 index 0000000..ed3001f --- /dev/null +++ b/test/unit/pixi-v2/InteractionManager.js @@ -0,0 +1,10 @@ +describe('pixi/InteractionManager', function () { + 'use strict'; + + var expect = chai.expect; + var InteractionManager = PIXI.InteractionManager; + + it('Module exists', function () { + expect(InteractionManager).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/Pixi.js b/test/unit/pixi-v2/Pixi.js new file mode 100644 index 0000000..27debc1 --- /dev/null +++ b/test/unit/pixi-v2/Pixi.js @@ -0,0 +1,9 @@ +describe('pixi/Pixi', function () { + 'use strict'; + + var expect = chai.expect; + + it('Module exists', function () { + expect(global).to.have.property('PIXI').and.to.be.an('object'); + }); +}); diff --git a/test/unit/pixi-v2/core/Circle.js b/test/unit/pixi-v2/core/Circle.js new file mode 100644 index 0000000..fbcfa17 --- /dev/null +++ b/test/unit/pixi-v2/core/Circle.js @@ -0,0 +1,21 @@ +describe('pixi/core/Circle', function () { + 'use strict'; + + var expect = chai.expect; + var Circle = PIXI.Circle; + + it('Module exists', function () { + expect(Circle).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Circle(); + pixi_core_Circle_confirmNewCircle(obj); + }); + + it("getBounds should return Rectangle that bounds the circle", function() { + var obj = new Circle(100, 250, 50); + var bounds = obj.getBounds(); + pixi_core_Circle_isBoundedByRectangle(obj, bounds); + }); +}); diff --git a/test/unit/pixi-v2/core/Ellipse.js b/test/unit/pixi-v2/core/Ellipse.js new file mode 100644 index 0000000..026b56f --- /dev/null +++ b/test/unit/pixi-v2/core/Ellipse.js @@ -0,0 +1,24 @@ +describe('pixi/core/Ellipse', function () { + 'use strict'; + + var expect = chai.expect; + var Ellipse = PIXI.Ellipse; + + it('Module exists', function () { + expect(Ellipse).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Ellipse(); + + expect(obj).to.be.an.instanceof(Ellipse); + expect(obj).to.respondTo('clone'); + expect(obj).to.respondTo('contains'); + expect(obj).to.respondTo('getBounds'); + + expect(obj).to.have.property('x', 0); + expect(obj).to.have.property('y', 0); + expect(obj).to.have.property('width', 0); + expect(obj).to.have.property('height', 0); + }); +}); diff --git a/test/unit/pixi-v2/core/Matrix.js b/test/unit/pixi-v2/core/Matrix.js new file mode 100644 index 0000000..da75e2e --- /dev/null +++ b/test/unit/pixi-v2/core/Matrix.js @@ -0,0 +1,14 @@ +describe('pixi/core/Matrix', function () { + 'use strict'; + + var expect = chai.expect; + + it('Matrix exists', function () { + expect(PIXI.Matrix).to.be.an('function'); + }); + + it('Confirm new Matrix', function () { + var matrix = new PIXI.Matrix(); + pixi_core_Matrix_confirmNewMatrix(matrix); + }); +}); diff --git a/test/unit/pixi-v2/core/Point.js b/test/unit/pixi-v2/core/Point.js new file mode 100644 index 0000000..c4d5163 --- /dev/null +++ b/test/unit/pixi-v2/core/Point.js @@ -0,0 +1,15 @@ +describe('pixi/core/Point', function () { + 'use strict'; + + var expect = chai.expect; + var Point = PIXI.Point; + + it('Module exists', function () { + expect(Point).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Point(); + pixi_core_Point_confirm(obj, 0, 0); + }); +}); diff --git a/test/unit/pixi-v2/core/Polygon.js b/test/unit/pixi-v2/core/Polygon.js new file mode 100644 index 0000000..dc8c918 --- /dev/null +++ b/test/unit/pixi-v2/core/Polygon.js @@ -0,0 +1,20 @@ +describe('pixi/core/Polygon', function () { + 'use strict'; + + var expect = chai.expect; + var Polygon = PIXI.Polygon; + + it('Module exists', function () { + expect(Polygon).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Polygon(); + + expect(obj).to.be.an.instanceof(Polygon); + expect(obj).to.respondTo('clone'); + expect(obj).to.respondTo('contains'); + + expect(obj).to.have.deep.property('points.length', 0); + }); +}); diff --git a/test/unit/pixi-v2/core/Rectangle.js b/test/unit/pixi-v2/core/Rectangle.js new file mode 100644 index 0000000..d43316e --- /dev/null +++ b/test/unit/pixi-v2/core/Rectangle.js @@ -0,0 +1,15 @@ +describe('pixi/core/Rectangle', function () { + 'use strict'; + + var expect = chai.expect; + var Rectangle = PIXI.Rectangle; + + it('Module exists', function () { + expect(Rectangle).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var rect = new Rectangle(); + pixi_core_Rectangle_confirm(rect, 0, 0, 0, 0); + }); +}); diff --git a/test/unit/pixi-v2/display/DisplayObject.js b/test/unit/pixi-v2/display/DisplayObject.js new file mode 100644 index 0000000..044acf8 --- /dev/null +++ b/test/unit/pixi-v2/display/DisplayObject.js @@ -0,0 +1,21 @@ +describe('pixi/display/DisplayObject', function () { + 'use strict'; + + var expect = chai.expect; + var DisplayObject = PIXI.DisplayObject; + + it('Module exists', function () { + expect(DisplayObject).to.be.a('function'); + // expect(PIXI).to.have.property('visibleCount', 0); + }); + + it('Confirm new instance', function () { + var obj = new DisplayObject(); + + pixi_display_DisplayObject_confirmNew(obj); + expect(obj).to.have.property('hitArea', null); + expect(obj).to.have.property('interactive', false); + expect(obj).to.have.property('renderable', false); + expect(obj).to.have.property('stage', null); + }); +}); diff --git a/test/unit/pixi-v2/display/DisplayObjectContainer.js b/test/unit/pixi-v2/display/DisplayObjectContainer.js new file mode 100644 index 0000000..15a3376 --- /dev/null +++ b/test/unit/pixi-v2/display/DisplayObjectContainer.js @@ -0,0 +1,67 @@ +describe('pixi/display/DisplayObjectContainer', function () { + 'use strict'; + + var expect = chai.expect; + var DisplayObjectContainer = PIXI.DisplayObjectContainer; + + it('Module exists', function () { + expect(DisplayObjectContainer).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new DisplayObjectContainer(); + + pixi_display_DisplayObjectContainer_confirmNew(obj); + expect(obj).to.have.property('hitArea', null); + expect(obj).to.have.property('interactive', false); + expect(obj).to.have.property('renderable', false); + expect(obj).to.have.property('stage', null); + }); + + it('Gets child index', function() { + var container = new PIXI.DisplayObjectContainer(); + var children = []; + for (var i = 0; i < 10; i++) { + var child = new PIXI.DisplayObject(); + children.push(child); + container.addChild(child); + } + + for (i = 0; i < children.length; i++) { + expect(i).to.eql(container.getChildIndex(children[i])); + } + }); + + it('throws error when trying to get index of not a child', function() { + var container = new PIXI.DisplayObjectContainer(); + var child = new PIXI.DisplayObject(); + + expect(function() { container.getChildIndex(child); }).to.throw(); + }); + + it('Sets child index', function() { + var container = new PIXI.DisplayObjectContainer(); + var children = []; + + for (var i = 0; i < 10; i++) { + var child = new PIXI.DisplayObject(); + children.push(child); + container.addChild(child); + } + children.reverse(); + + for (i = 0; i < children.length; i++) { + container.setChildIndex(children[i], i); + expect(i).to.eql(container.getChildIndex(children[i])); + } + }); + + it('throws error when trying to set incorect index', function() { + var container = new PIXI.DisplayObjectContainer(); + var child = new PIXI.DisplayObject(); + container.addChild(child); + + expect(function() { container.setChildIndex(child, -1); }).to.throw(); + expect(function() { container.setChildIndex(child, 1); }).to.throw(); + }); +}); diff --git a/test/unit/pixi-v2/display/MovieClip.js b/test/unit/pixi-v2/display/MovieClip.js new file mode 100644 index 0000000..f3c6c6a --- /dev/null +++ b/test/unit/pixi-v2/display/MovieClip.js @@ -0,0 +1,33 @@ +describe('pixi/display/MovieClip', function () { + 'use strict'; + + var expect = chai.expect; + var MovieClip = PIXI.MovieClip; + var Texture = PIXI.Texture; + + it('Module exists', function () { + expect(MovieClip).to.be.a('function'); + }); + + it('Confirm new instance', function (done) { + var texture = Texture.fromImage('/base/test/textures/SpriteSheet-Explosion.png'); + var obj = new MovieClip([texture]); + + pixi_display_Sprite_confirmNew(obj, done); + + expect(obj).to.be.an.instanceof(MovieClip); + expect(obj).to.respondTo('stop'); + expect(obj).to.respondTo('play'); + expect(obj).to.respondTo('gotoAndStop'); + expect(obj).to.respondTo('gotoAndPlay'); + expect(obj).to.respondTo('updateTransform'); + + expect(obj).to.have.deep.property('textures.length', 1); + expect(obj).to.have.deep.property('textures[0]', texture); + expect(obj).to.have.property('animationSpeed', 1); + expect(obj).to.have.property('loop', true); + expect(obj).to.have.property('onComplete', null); + expect(obj).to.have.property('currentFrame', 0); + expect(obj).to.have.property('playing', false); + }); +}); diff --git a/test/unit/pixi-v2/display/Sprite.js b/test/unit/pixi-v2/display/Sprite.js new file mode 100644 index 0000000..30c8076 --- /dev/null +++ b/test/unit/pixi-v2/display/Sprite.js @@ -0,0 +1,28 @@ +describe('pixi/display/Sprite', function () { + 'use strict'; + + var expect = chai.expect; + var Sprite = PIXI.Sprite; + var Texture = PIXI.Texture; + + it('Module exists', function () { + expect(Sprite).to.be.a('function'); + expect(PIXI).to.have.deep.property('blendModes.NORMAL', 0); + expect(PIXI).to.have.deep.property('blendModes.ADD', 1); + expect(PIXI).to.have.deep.property('blendModes.MULTIPLY', 2); + expect(PIXI).to.have.deep.property('blendModes.SCREEN', 3); + }); + + + it('Members exist', function () { + expect(Sprite).itself.to.respondTo('fromImage'); + expect(Sprite).itself.to.respondTo('fromFrame'); + }); + + it('Confirm new instance', function (done) { + var texture = Texture.fromImage('/base/test/textures/SpriteSheet-Aliens.png'); + var obj = new Sprite(texture); + + pixi_display_Sprite_confirmNew(obj, done); + }); +}); diff --git a/test/unit/pixi-v2/display/Stage.js b/test/unit/pixi-v2/display/Stage.js new file mode 100644 index 0000000..6974c2e --- /dev/null +++ b/test/unit/pixi-v2/display/Stage.js @@ -0,0 +1,49 @@ +describe('pixi/display/Stage', function () { + 'use strict'; + + var expect = chai.expect; + var Stage = PIXI.Stage; + var InteractionManager = PIXI.InteractionManager; + var Rectangle = PIXI.Rectangle; + + it('Module exists', function () { + expect(Stage).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Stage(null, true); + + pixi_display_DisplayObjectContainer_confirmNew(obj); + + expect(obj).to.be.an.instanceof(Stage); + expect(obj).to.respondTo('updateTransform'); + expect(obj).to.respondTo('setBackgroundColor'); + expect(obj).to.respondTo('getMousePosition'); + // FIXME: duplicate member in DisplayObject + pixi_core_Matrix_confirmNewMatrix(obj.worldTransform); + // FIXME: convert arg to bool in constructor + expect(obj).to.have.property('interactive', true); + + expect(obj).to.have.property('interactionManager') + .and.to.be.an.instanceof(InteractionManager) + .and.to.have.property('stage', obj); + + expect(obj).to.have.property('dirty', true); + + expect(obj).to.have.property('stage', obj); + + expect(obj).to.have.property('hitArea') + .and.to.be.an.instanceof(Rectangle); + pixi_core_Rectangle_confirm(obj.hitArea, 0, 0, 100000, 100000); + + expect(obj).to.have.property('backgroundColor', 0x000000); + expect(obj).to.have.deep.property('backgroundColorSplit.length', 3); + expect(obj).to.have.deep.property('backgroundColorSplit[0]', 0); + expect(obj).to.have.deep.property('backgroundColorSplit[1]', 0); + expect(obj).to.have.deep.property('backgroundColorSplit[2]', 0); + expect(obj).to.have.property('backgroundColorString', '#000000'); + + + expect(obj).to.have.property('worldVisible', true); + }); +}); diff --git a/test/unit/pixi-v2/extras/Rope.js b/test/unit/pixi-v2/extras/Rope.js new file mode 100644 index 0000000..05885ac --- /dev/null +++ b/test/unit/pixi-v2/extras/Rope.js @@ -0,0 +1,31 @@ +describe('pixi/extras/Rope', function () { + 'use strict'; + + var expect = chai.expect; + var Rope = PIXI.Rope; + var Texture = PIXI.Texture; + var Point = PIXI.Point; + + it('Module exists', function () { + expect(Rope).to.be.a('function'); + }); + + it('Confirm new instance', function () { + + var texture = Texture.fromImage('/base/test/textures/bunny.png'); + + // TODO-Alvin + // Same as Strip + + // var obj = new Rope(texture, [new Point(), new Point(5, 10), new Point(10, 20)]); + + // pixi_extras_Strip_confirmNew(obj); + + // expect(obj).to.be.an.instanceof(Rope); + // expect(obj).to.respondTo('refresh'); + // expect(obj).to.respondTo('updateTransform'); + // expect(obj).to.respondTo('setTexture'); + + // TODO: Test properties + }); +}); diff --git a/test/unit/pixi-v2/extras/Spine.js b/test/unit/pixi-v2/extras/Spine.js new file mode 100644 index 0000000..0708bc0 --- /dev/null +++ b/test/unit/pixi-v2/extras/Spine.js @@ -0,0 +1,10 @@ +describe('pixi/extras/Spine', function () { + 'use strict'; + + var expect = chai.expect; + var Spine = PIXI.Spine; + + it('Module exists', function () { + expect(Spine).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/extras/Strip.js b/test/unit/pixi-v2/extras/Strip.js new file mode 100644 index 0000000..230af90 --- /dev/null +++ b/test/unit/pixi-v2/extras/Strip.js @@ -0,0 +1,26 @@ +describe('pixi/extras/Strip', function () { + 'use strict'; + + var expect = chai.expect; + var Strip = PIXI.Strip; + var Texture = PIXI.Texture; + + it('Module exists', function () { + expect(Strip).to.be.a('function'); + }); + + it('Confirm new instance', function () { + + + // TODO-Alvin + // We tweaked it to make it pass the tests, but the whole strip class needs + // to be re-coded + + var texture = Texture.fromImage('/base/test/textures/bunny.png'); + + // var obj = new Strip(texture, 20, 10000); + + + // pixi_extras_Strip_confirmNew(obj); + }); +}); diff --git a/test/unit/pixi-v2/extras/TilingSprite.js b/test/unit/pixi-v2/extras/TilingSprite.js new file mode 100644 index 0000000..56aea14 --- /dev/null +++ b/test/unit/pixi-v2/extras/TilingSprite.js @@ -0,0 +1,24 @@ +describe('pixi/extras/TilingSprite', function () { + 'use strict'; + + var expect = chai.expect; + var TilingSprite = PIXI.TilingSprite; + var Texture = PIXI.Texture; + + it('Module exists', function () { + expect(TilingSprite).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var texture = Texture.fromImage('/base/test/textures/bunny.png'); + var obj = new TilingSprite(texture, 6000, 12000); + + pixi_display_DisplayObjectContainer_confirmNew(obj); + + expect(obj).to.be.an.instanceof(TilingSprite); + expect(obj).to.respondTo('setTexture'); + expect(obj).to.respondTo('onTextureUpdate'); + + // TODO: Test properties + }); +}); diff --git a/test/unit/pixi-v2/filters/FilterBlock.js b/test/unit/pixi-v2/filters/FilterBlock.js new file mode 100644 index 0000000..870cec0 --- /dev/null +++ b/test/unit/pixi-v2/filters/FilterBlock.js @@ -0,0 +1,10 @@ +describe('pixi/filters/FilterBlock', function () { + 'use strict'; + + var expect = chai.expect; + var FilterBlock = PIXI.FilterBlock; + + it('Module exists', function () { + expect(FilterBlock).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/AssetLoader.js b/test/unit/pixi-v2/loaders/AssetLoader.js new file mode 100644 index 0000000..a0aa0b5 --- /dev/null +++ b/test/unit/pixi-v2/loaders/AssetLoader.js @@ -0,0 +1,10 @@ +describe('pixi/loaders/AssetLoader', function () { + 'use strict'; + + var expect = chai.expect; + var AssetLoader = PIXI.AssetLoader; + + it('Module exists', function () { + expect(AssetLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/BitmapFontLoader.js b/test/unit/pixi-v2/loaders/BitmapFontLoader.js new file mode 100644 index 0000000..046f018 --- /dev/null +++ b/test/unit/pixi-v2/loaders/BitmapFontLoader.js @@ -0,0 +1,9 @@ +describe('pixi/loaders/BitmapFontLoader', function () { + 'use strict'; + + var expect = chai.expect; + + it('Module exists', function () { + expect(PIXI.BitmapFontLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/ImageLoader.js b/test/unit/pixi-v2/loaders/ImageLoader.js new file mode 100644 index 0000000..8b1f556 --- /dev/null +++ b/test/unit/pixi-v2/loaders/ImageLoader.js @@ -0,0 +1,10 @@ +describe('pixi/loaders/ImageLoader', function () { + 'use strict'; + + var expect = chai.expect; + var ImageLoader = PIXI.ImageLoader; + + it('Module exists', function () { + expect(ImageLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/JsonLoader.js b/test/unit/pixi-v2/loaders/JsonLoader.js new file mode 100644 index 0000000..c577e83 --- /dev/null +++ b/test/unit/pixi-v2/loaders/JsonLoader.js @@ -0,0 +1,10 @@ +describe('pixi/loaders/JsonLoader', function () { + 'use strict'; + + var expect = chai.expect; + var JsonLoader = PIXI.JsonLoader; + + it('Module exists', function () { + expect(JsonLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/SpineLoader.js b/test/unit/pixi-v2/loaders/SpineLoader.js new file mode 100644 index 0000000..fdcc0b8 --- /dev/null +++ b/test/unit/pixi-v2/loaders/SpineLoader.js @@ -0,0 +1,10 @@ +describe('pixi/loaders/SpineLoader', function () { + 'use strict'; + + var expect = chai.expect; + var SpineLoader = PIXI.SpineLoader; + + it('Module exists', function () { + expect(SpineLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/SpriteSheetLoader.js b/test/unit/pixi-v2/loaders/SpriteSheetLoader.js new file mode 100644 index 0000000..57beb27 --- /dev/null +++ b/test/unit/pixi-v2/loaders/SpriteSheetLoader.js @@ -0,0 +1,10 @@ +describe('pixi/loaders/SpriteSheetLoader', function () { + 'use strict'; + + var expect = chai.expect; + var SpriteSheetLoader = PIXI.SpriteSheetLoader; + + it('Module exists', function () { + expect(SpriteSheetLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/primitives/Graphics.js b/test/unit/pixi-v2/primitives/Graphics.js new file mode 100644 index 0000000..f3849eb --- /dev/null +++ b/test/unit/pixi-v2/primitives/Graphics.js @@ -0,0 +1,44 @@ +describe('pixi/primitives/Graphics', function () { + 'use strict'; + + var expect = chai.expect; + var Graphics = PIXI.Graphics; + + it('Module exists', function () { + expect(Graphics).to.be.a('function'); + + expect(Graphics).itself.to.have.property('POLY', 0); + expect(Graphics).itself.to.have.property('RECT', 1); + expect(Graphics).itself.to.have.property('CIRC', 2); + expect(Graphics).itself.to.have.property('ELIP', 3); + expect(Graphics).itself.to.have.property('RREC', 4); + }); + + it('Confirm new instance', function () { + var obj = new Graphics(); + + pixi_display_DisplayObjectContainer_confirmNew(obj); + + expect(obj).to.be.an.instanceof(Graphics); + expect(obj).to.respondTo('lineStyle'); + expect(obj).to.respondTo('lineStyle'); + expect(obj).to.respondTo('moveTo'); + expect(obj).to.respondTo('lineTo'); + expect(obj).to.respondTo('beginFill'); + expect(obj).to.respondTo('endFill'); + expect(obj).to.respondTo('drawRect'); + // expect(obj).to.respondTo('drawRoundedRect'); + expect(obj).to.respondTo('drawCircle'); + expect(obj).to.respondTo('drawEllipse'); + expect(obj).to.respondTo('clear'); + + expect(obj).to.have.property('renderable', true); + expect(obj).to.have.property('fillAlpha', 1); + expect(obj).to.have.property('lineWidth', 0); + expect(obj).to.have.property('width', 0); + expect(obj).to.have.property('height', 0); + expect(obj).to.have.property('lineColor', 0); + expect(obj).to.have.deep.property('graphicsData.length', 0); + // expect(obj).to.have.deep.property('currentPath.points.length', 0); + }); +}); diff --git a/test/unit/pixi-v2/InteractionManager.js b/test/unit/pixi-v2/InteractionManager.js new file mode 100644 index 0000000..ed3001f --- /dev/null +++ b/test/unit/pixi-v2/InteractionManager.js @@ -0,0 +1,10 @@ +describe('pixi/InteractionManager', function () { + 'use strict'; + + var expect = chai.expect; + var InteractionManager = PIXI.InteractionManager; + + it('Module exists', function () { + expect(InteractionManager).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/Pixi.js b/test/unit/pixi-v2/Pixi.js new file mode 100644 index 0000000..27debc1 --- /dev/null +++ b/test/unit/pixi-v2/Pixi.js @@ -0,0 +1,9 @@ +describe('pixi/Pixi', function () { + 'use strict'; + + var expect = chai.expect; + + it('Module exists', function () { + expect(global).to.have.property('PIXI').and.to.be.an('object'); + }); +}); diff --git a/test/unit/pixi-v2/core/Circle.js b/test/unit/pixi-v2/core/Circle.js new file mode 100644 index 0000000..fbcfa17 --- /dev/null +++ b/test/unit/pixi-v2/core/Circle.js @@ -0,0 +1,21 @@ +describe('pixi/core/Circle', function () { + 'use strict'; + + var expect = chai.expect; + var Circle = PIXI.Circle; + + it('Module exists', function () { + expect(Circle).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Circle(); + pixi_core_Circle_confirmNewCircle(obj); + }); + + it("getBounds should return Rectangle that bounds the circle", function() { + var obj = new Circle(100, 250, 50); + var bounds = obj.getBounds(); + pixi_core_Circle_isBoundedByRectangle(obj, bounds); + }); +}); diff --git a/test/unit/pixi-v2/core/Ellipse.js b/test/unit/pixi-v2/core/Ellipse.js new file mode 100644 index 0000000..026b56f --- /dev/null +++ b/test/unit/pixi-v2/core/Ellipse.js @@ -0,0 +1,24 @@ +describe('pixi/core/Ellipse', function () { + 'use strict'; + + var expect = chai.expect; + var Ellipse = PIXI.Ellipse; + + it('Module exists', function () { + expect(Ellipse).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Ellipse(); + + expect(obj).to.be.an.instanceof(Ellipse); + expect(obj).to.respondTo('clone'); + expect(obj).to.respondTo('contains'); + expect(obj).to.respondTo('getBounds'); + + expect(obj).to.have.property('x', 0); + expect(obj).to.have.property('y', 0); + expect(obj).to.have.property('width', 0); + expect(obj).to.have.property('height', 0); + }); +}); diff --git a/test/unit/pixi-v2/core/Matrix.js b/test/unit/pixi-v2/core/Matrix.js new file mode 100644 index 0000000..da75e2e --- /dev/null +++ b/test/unit/pixi-v2/core/Matrix.js @@ -0,0 +1,14 @@ +describe('pixi/core/Matrix', function () { + 'use strict'; + + var expect = chai.expect; + + it('Matrix exists', function () { + expect(PIXI.Matrix).to.be.an('function'); + }); + + it('Confirm new Matrix', function () { + var matrix = new PIXI.Matrix(); + pixi_core_Matrix_confirmNewMatrix(matrix); + }); +}); diff --git a/test/unit/pixi-v2/core/Point.js b/test/unit/pixi-v2/core/Point.js new file mode 100644 index 0000000..c4d5163 --- /dev/null +++ b/test/unit/pixi-v2/core/Point.js @@ -0,0 +1,15 @@ +describe('pixi/core/Point', function () { + 'use strict'; + + var expect = chai.expect; + var Point = PIXI.Point; + + it('Module exists', function () { + expect(Point).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Point(); + pixi_core_Point_confirm(obj, 0, 0); + }); +}); diff --git a/test/unit/pixi-v2/core/Polygon.js b/test/unit/pixi-v2/core/Polygon.js new file mode 100644 index 0000000..dc8c918 --- /dev/null +++ b/test/unit/pixi-v2/core/Polygon.js @@ -0,0 +1,20 @@ +describe('pixi/core/Polygon', function () { + 'use strict'; + + var expect = chai.expect; + var Polygon = PIXI.Polygon; + + it('Module exists', function () { + expect(Polygon).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Polygon(); + + expect(obj).to.be.an.instanceof(Polygon); + expect(obj).to.respondTo('clone'); + expect(obj).to.respondTo('contains'); + + expect(obj).to.have.deep.property('points.length', 0); + }); +}); diff --git a/test/unit/pixi-v2/core/Rectangle.js b/test/unit/pixi-v2/core/Rectangle.js new file mode 100644 index 0000000..d43316e --- /dev/null +++ b/test/unit/pixi-v2/core/Rectangle.js @@ -0,0 +1,15 @@ +describe('pixi/core/Rectangle', function () { + 'use strict'; + + var expect = chai.expect; + var Rectangle = PIXI.Rectangle; + + it('Module exists', function () { + expect(Rectangle).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var rect = new Rectangle(); + pixi_core_Rectangle_confirm(rect, 0, 0, 0, 0); + }); +}); diff --git a/test/unit/pixi-v2/display/DisplayObject.js b/test/unit/pixi-v2/display/DisplayObject.js new file mode 100644 index 0000000..044acf8 --- /dev/null +++ b/test/unit/pixi-v2/display/DisplayObject.js @@ -0,0 +1,21 @@ +describe('pixi/display/DisplayObject', function () { + 'use strict'; + + var expect = chai.expect; + var DisplayObject = PIXI.DisplayObject; + + it('Module exists', function () { + expect(DisplayObject).to.be.a('function'); + // expect(PIXI).to.have.property('visibleCount', 0); + }); + + it('Confirm new instance', function () { + var obj = new DisplayObject(); + + pixi_display_DisplayObject_confirmNew(obj); + expect(obj).to.have.property('hitArea', null); + expect(obj).to.have.property('interactive', false); + expect(obj).to.have.property('renderable', false); + expect(obj).to.have.property('stage', null); + }); +}); diff --git a/test/unit/pixi-v2/display/DisplayObjectContainer.js b/test/unit/pixi-v2/display/DisplayObjectContainer.js new file mode 100644 index 0000000..15a3376 --- /dev/null +++ b/test/unit/pixi-v2/display/DisplayObjectContainer.js @@ -0,0 +1,67 @@ +describe('pixi/display/DisplayObjectContainer', function () { + 'use strict'; + + var expect = chai.expect; + var DisplayObjectContainer = PIXI.DisplayObjectContainer; + + it('Module exists', function () { + expect(DisplayObjectContainer).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new DisplayObjectContainer(); + + pixi_display_DisplayObjectContainer_confirmNew(obj); + expect(obj).to.have.property('hitArea', null); + expect(obj).to.have.property('interactive', false); + expect(obj).to.have.property('renderable', false); + expect(obj).to.have.property('stage', null); + }); + + it('Gets child index', function() { + var container = new PIXI.DisplayObjectContainer(); + var children = []; + for (var i = 0; i < 10; i++) { + var child = new PIXI.DisplayObject(); + children.push(child); + container.addChild(child); + } + + for (i = 0; i < children.length; i++) { + expect(i).to.eql(container.getChildIndex(children[i])); + } + }); + + it('throws error when trying to get index of not a child', function() { + var container = new PIXI.DisplayObjectContainer(); + var child = new PIXI.DisplayObject(); + + expect(function() { container.getChildIndex(child); }).to.throw(); + }); + + it('Sets child index', function() { + var container = new PIXI.DisplayObjectContainer(); + var children = []; + + for (var i = 0; i < 10; i++) { + var child = new PIXI.DisplayObject(); + children.push(child); + container.addChild(child); + } + children.reverse(); + + for (i = 0; i < children.length; i++) { + container.setChildIndex(children[i], i); + expect(i).to.eql(container.getChildIndex(children[i])); + } + }); + + it('throws error when trying to set incorect index', function() { + var container = new PIXI.DisplayObjectContainer(); + var child = new PIXI.DisplayObject(); + container.addChild(child); + + expect(function() { container.setChildIndex(child, -1); }).to.throw(); + expect(function() { container.setChildIndex(child, 1); }).to.throw(); + }); +}); diff --git a/test/unit/pixi-v2/display/MovieClip.js b/test/unit/pixi-v2/display/MovieClip.js new file mode 100644 index 0000000..f3c6c6a --- /dev/null +++ b/test/unit/pixi-v2/display/MovieClip.js @@ -0,0 +1,33 @@ +describe('pixi/display/MovieClip', function () { + 'use strict'; + + var expect = chai.expect; + var MovieClip = PIXI.MovieClip; + var Texture = PIXI.Texture; + + it('Module exists', function () { + expect(MovieClip).to.be.a('function'); + }); + + it('Confirm new instance', function (done) { + var texture = Texture.fromImage('/base/test/textures/SpriteSheet-Explosion.png'); + var obj = new MovieClip([texture]); + + pixi_display_Sprite_confirmNew(obj, done); + + expect(obj).to.be.an.instanceof(MovieClip); + expect(obj).to.respondTo('stop'); + expect(obj).to.respondTo('play'); + expect(obj).to.respondTo('gotoAndStop'); + expect(obj).to.respondTo('gotoAndPlay'); + expect(obj).to.respondTo('updateTransform'); + + expect(obj).to.have.deep.property('textures.length', 1); + expect(obj).to.have.deep.property('textures[0]', texture); + expect(obj).to.have.property('animationSpeed', 1); + expect(obj).to.have.property('loop', true); + expect(obj).to.have.property('onComplete', null); + expect(obj).to.have.property('currentFrame', 0); + expect(obj).to.have.property('playing', false); + }); +}); diff --git a/test/unit/pixi-v2/display/Sprite.js b/test/unit/pixi-v2/display/Sprite.js new file mode 100644 index 0000000..30c8076 --- /dev/null +++ b/test/unit/pixi-v2/display/Sprite.js @@ -0,0 +1,28 @@ +describe('pixi/display/Sprite', function () { + 'use strict'; + + var expect = chai.expect; + var Sprite = PIXI.Sprite; + var Texture = PIXI.Texture; + + it('Module exists', function () { + expect(Sprite).to.be.a('function'); + expect(PIXI).to.have.deep.property('blendModes.NORMAL', 0); + expect(PIXI).to.have.deep.property('blendModes.ADD', 1); + expect(PIXI).to.have.deep.property('blendModes.MULTIPLY', 2); + expect(PIXI).to.have.deep.property('blendModes.SCREEN', 3); + }); + + + it('Members exist', function () { + expect(Sprite).itself.to.respondTo('fromImage'); + expect(Sprite).itself.to.respondTo('fromFrame'); + }); + + it('Confirm new instance', function (done) { + var texture = Texture.fromImage('/base/test/textures/SpriteSheet-Aliens.png'); + var obj = new Sprite(texture); + + pixi_display_Sprite_confirmNew(obj, done); + }); +}); diff --git a/test/unit/pixi-v2/display/Stage.js b/test/unit/pixi-v2/display/Stage.js new file mode 100644 index 0000000..6974c2e --- /dev/null +++ b/test/unit/pixi-v2/display/Stage.js @@ -0,0 +1,49 @@ +describe('pixi/display/Stage', function () { + 'use strict'; + + var expect = chai.expect; + var Stage = PIXI.Stage; + var InteractionManager = PIXI.InteractionManager; + var Rectangle = PIXI.Rectangle; + + it('Module exists', function () { + expect(Stage).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Stage(null, true); + + pixi_display_DisplayObjectContainer_confirmNew(obj); + + expect(obj).to.be.an.instanceof(Stage); + expect(obj).to.respondTo('updateTransform'); + expect(obj).to.respondTo('setBackgroundColor'); + expect(obj).to.respondTo('getMousePosition'); + // FIXME: duplicate member in DisplayObject + pixi_core_Matrix_confirmNewMatrix(obj.worldTransform); + // FIXME: convert arg to bool in constructor + expect(obj).to.have.property('interactive', true); + + expect(obj).to.have.property('interactionManager') + .and.to.be.an.instanceof(InteractionManager) + .and.to.have.property('stage', obj); + + expect(obj).to.have.property('dirty', true); + + expect(obj).to.have.property('stage', obj); + + expect(obj).to.have.property('hitArea') + .and.to.be.an.instanceof(Rectangle); + pixi_core_Rectangle_confirm(obj.hitArea, 0, 0, 100000, 100000); + + expect(obj).to.have.property('backgroundColor', 0x000000); + expect(obj).to.have.deep.property('backgroundColorSplit.length', 3); + expect(obj).to.have.deep.property('backgroundColorSplit[0]', 0); + expect(obj).to.have.deep.property('backgroundColorSplit[1]', 0); + expect(obj).to.have.deep.property('backgroundColorSplit[2]', 0); + expect(obj).to.have.property('backgroundColorString', '#000000'); + + + expect(obj).to.have.property('worldVisible', true); + }); +}); diff --git a/test/unit/pixi-v2/extras/Rope.js b/test/unit/pixi-v2/extras/Rope.js new file mode 100644 index 0000000..05885ac --- /dev/null +++ b/test/unit/pixi-v2/extras/Rope.js @@ -0,0 +1,31 @@ +describe('pixi/extras/Rope', function () { + 'use strict'; + + var expect = chai.expect; + var Rope = PIXI.Rope; + var Texture = PIXI.Texture; + var Point = PIXI.Point; + + it('Module exists', function () { + expect(Rope).to.be.a('function'); + }); + + it('Confirm new instance', function () { + + var texture = Texture.fromImage('/base/test/textures/bunny.png'); + + // TODO-Alvin + // Same as Strip + + // var obj = new Rope(texture, [new Point(), new Point(5, 10), new Point(10, 20)]); + + // pixi_extras_Strip_confirmNew(obj); + + // expect(obj).to.be.an.instanceof(Rope); + // expect(obj).to.respondTo('refresh'); + // expect(obj).to.respondTo('updateTransform'); + // expect(obj).to.respondTo('setTexture'); + + // TODO: Test properties + }); +}); diff --git a/test/unit/pixi-v2/extras/Spine.js b/test/unit/pixi-v2/extras/Spine.js new file mode 100644 index 0000000..0708bc0 --- /dev/null +++ b/test/unit/pixi-v2/extras/Spine.js @@ -0,0 +1,10 @@ +describe('pixi/extras/Spine', function () { + 'use strict'; + + var expect = chai.expect; + var Spine = PIXI.Spine; + + it('Module exists', function () { + expect(Spine).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/extras/Strip.js b/test/unit/pixi-v2/extras/Strip.js new file mode 100644 index 0000000..230af90 --- /dev/null +++ b/test/unit/pixi-v2/extras/Strip.js @@ -0,0 +1,26 @@ +describe('pixi/extras/Strip', function () { + 'use strict'; + + var expect = chai.expect; + var Strip = PIXI.Strip; + var Texture = PIXI.Texture; + + it('Module exists', function () { + expect(Strip).to.be.a('function'); + }); + + it('Confirm new instance', function () { + + + // TODO-Alvin + // We tweaked it to make it pass the tests, but the whole strip class needs + // to be re-coded + + var texture = Texture.fromImage('/base/test/textures/bunny.png'); + + // var obj = new Strip(texture, 20, 10000); + + + // pixi_extras_Strip_confirmNew(obj); + }); +}); diff --git a/test/unit/pixi-v2/extras/TilingSprite.js b/test/unit/pixi-v2/extras/TilingSprite.js new file mode 100644 index 0000000..56aea14 --- /dev/null +++ b/test/unit/pixi-v2/extras/TilingSprite.js @@ -0,0 +1,24 @@ +describe('pixi/extras/TilingSprite', function () { + 'use strict'; + + var expect = chai.expect; + var TilingSprite = PIXI.TilingSprite; + var Texture = PIXI.Texture; + + it('Module exists', function () { + expect(TilingSprite).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var texture = Texture.fromImage('/base/test/textures/bunny.png'); + var obj = new TilingSprite(texture, 6000, 12000); + + pixi_display_DisplayObjectContainer_confirmNew(obj); + + expect(obj).to.be.an.instanceof(TilingSprite); + expect(obj).to.respondTo('setTexture'); + expect(obj).to.respondTo('onTextureUpdate'); + + // TODO: Test properties + }); +}); diff --git a/test/unit/pixi-v2/filters/FilterBlock.js b/test/unit/pixi-v2/filters/FilterBlock.js new file mode 100644 index 0000000..870cec0 --- /dev/null +++ b/test/unit/pixi-v2/filters/FilterBlock.js @@ -0,0 +1,10 @@ +describe('pixi/filters/FilterBlock', function () { + 'use strict'; + + var expect = chai.expect; + var FilterBlock = PIXI.FilterBlock; + + it('Module exists', function () { + expect(FilterBlock).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/AssetLoader.js b/test/unit/pixi-v2/loaders/AssetLoader.js new file mode 100644 index 0000000..a0aa0b5 --- /dev/null +++ b/test/unit/pixi-v2/loaders/AssetLoader.js @@ -0,0 +1,10 @@ +describe('pixi/loaders/AssetLoader', function () { + 'use strict'; + + var expect = chai.expect; + var AssetLoader = PIXI.AssetLoader; + + it('Module exists', function () { + expect(AssetLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/BitmapFontLoader.js b/test/unit/pixi-v2/loaders/BitmapFontLoader.js new file mode 100644 index 0000000..046f018 --- /dev/null +++ b/test/unit/pixi-v2/loaders/BitmapFontLoader.js @@ -0,0 +1,9 @@ +describe('pixi/loaders/BitmapFontLoader', function () { + 'use strict'; + + var expect = chai.expect; + + it('Module exists', function () { + expect(PIXI.BitmapFontLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/ImageLoader.js b/test/unit/pixi-v2/loaders/ImageLoader.js new file mode 100644 index 0000000..8b1f556 --- /dev/null +++ b/test/unit/pixi-v2/loaders/ImageLoader.js @@ -0,0 +1,10 @@ +describe('pixi/loaders/ImageLoader', function () { + 'use strict'; + + var expect = chai.expect; + var ImageLoader = PIXI.ImageLoader; + + it('Module exists', function () { + expect(ImageLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/JsonLoader.js b/test/unit/pixi-v2/loaders/JsonLoader.js new file mode 100644 index 0000000..c577e83 --- /dev/null +++ b/test/unit/pixi-v2/loaders/JsonLoader.js @@ -0,0 +1,10 @@ +describe('pixi/loaders/JsonLoader', function () { + 'use strict'; + + var expect = chai.expect; + var JsonLoader = PIXI.JsonLoader; + + it('Module exists', function () { + expect(JsonLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/SpineLoader.js b/test/unit/pixi-v2/loaders/SpineLoader.js new file mode 100644 index 0000000..fdcc0b8 --- /dev/null +++ b/test/unit/pixi-v2/loaders/SpineLoader.js @@ -0,0 +1,10 @@ +describe('pixi/loaders/SpineLoader', function () { + 'use strict'; + + var expect = chai.expect; + var SpineLoader = PIXI.SpineLoader; + + it('Module exists', function () { + expect(SpineLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/SpriteSheetLoader.js b/test/unit/pixi-v2/loaders/SpriteSheetLoader.js new file mode 100644 index 0000000..57beb27 --- /dev/null +++ b/test/unit/pixi-v2/loaders/SpriteSheetLoader.js @@ -0,0 +1,10 @@ +describe('pixi/loaders/SpriteSheetLoader', function () { + 'use strict'; + + var expect = chai.expect; + var SpriteSheetLoader = PIXI.SpriteSheetLoader; + + it('Module exists', function () { + expect(SpriteSheetLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/primitives/Graphics.js b/test/unit/pixi-v2/primitives/Graphics.js new file mode 100644 index 0000000..f3849eb --- /dev/null +++ b/test/unit/pixi-v2/primitives/Graphics.js @@ -0,0 +1,44 @@ +describe('pixi/primitives/Graphics', function () { + 'use strict'; + + var expect = chai.expect; + var Graphics = PIXI.Graphics; + + it('Module exists', function () { + expect(Graphics).to.be.a('function'); + + expect(Graphics).itself.to.have.property('POLY', 0); + expect(Graphics).itself.to.have.property('RECT', 1); + expect(Graphics).itself.to.have.property('CIRC', 2); + expect(Graphics).itself.to.have.property('ELIP', 3); + expect(Graphics).itself.to.have.property('RREC', 4); + }); + + it('Confirm new instance', function () { + var obj = new Graphics(); + + pixi_display_DisplayObjectContainer_confirmNew(obj); + + expect(obj).to.be.an.instanceof(Graphics); + expect(obj).to.respondTo('lineStyle'); + expect(obj).to.respondTo('lineStyle'); + expect(obj).to.respondTo('moveTo'); + expect(obj).to.respondTo('lineTo'); + expect(obj).to.respondTo('beginFill'); + expect(obj).to.respondTo('endFill'); + expect(obj).to.respondTo('drawRect'); + // expect(obj).to.respondTo('drawRoundedRect'); + expect(obj).to.respondTo('drawCircle'); + expect(obj).to.respondTo('drawEllipse'); + expect(obj).to.respondTo('clear'); + + expect(obj).to.have.property('renderable', true); + expect(obj).to.have.property('fillAlpha', 1); + expect(obj).to.have.property('lineWidth', 0); + expect(obj).to.have.property('width', 0); + expect(obj).to.have.property('height', 0); + expect(obj).to.have.property('lineColor', 0); + expect(obj).to.have.deep.property('graphicsData.length', 0); + // expect(obj).to.have.deep.property('currentPath.points.length', 0); + }); +}); diff --git a/test/unit/pixi-v2/renderers/canvas/CanvasGraphics.js b/test/unit/pixi-v2/renderers/canvas/CanvasGraphics.js new file mode 100644 index 0000000..8f44472 --- /dev/null +++ b/test/unit/pixi-v2/renderers/canvas/CanvasGraphics.js @@ -0,0 +1,15 @@ +describe('renders/canvas/CanvasGraphics', function () { + 'use strict'; + + var expect = chai.expect; + var CanvasGraphics = PIXI.CanvasGraphics; + + it('Module exists', function () { + expect(CanvasGraphics).to.be.a('function'); + }); + + it('Members exist', function () { + expect(CanvasGraphics).itself.to.respondTo('renderGraphics'); + expect(CanvasGraphics).itself.to.respondTo('renderGraphicsMask'); + }); +}); diff --git a/test/unit/pixi-v2/InteractionManager.js b/test/unit/pixi-v2/InteractionManager.js new file mode 100644 index 0000000..ed3001f --- /dev/null +++ b/test/unit/pixi-v2/InteractionManager.js @@ -0,0 +1,10 @@ +describe('pixi/InteractionManager', function () { + 'use strict'; + + var expect = chai.expect; + var InteractionManager = PIXI.InteractionManager; + + it('Module exists', function () { + expect(InteractionManager).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/Pixi.js b/test/unit/pixi-v2/Pixi.js new file mode 100644 index 0000000..27debc1 --- /dev/null +++ b/test/unit/pixi-v2/Pixi.js @@ -0,0 +1,9 @@ +describe('pixi/Pixi', function () { + 'use strict'; + + var expect = chai.expect; + + it('Module exists', function () { + expect(global).to.have.property('PIXI').and.to.be.an('object'); + }); +}); diff --git a/test/unit/pixi-v2/core/Circle.js b/test/unit/pixi-v2/core/Circle.js new file mode 100644 index 0000000..fbcfa17 --- /dev/null +++ b/test/unit/pixi-v2/core/Circle.js @@ -0,0 +1,21 @@ +describe('pixi/core/Circle', function () { + 'use strict'; + + var expect = chai.expect; + var Circle = PIXI.Circle; + + it('Module exists', function () { + expect(Circle).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Circle(); + pixi_core_Circle_confirmNewCircle(obj); + }); + + it("getBounds should return Rectangle that bounds the circle", function() { + var obj = new Circle(100, 250, 50); + var bounds = obj.getBounds(); + pixi_core_Circle_isBoundedByRectangle(obj, bounds); + }); +}); diff --git a/test/unit/pixi-v2/core/Ellipse.js b/test/unit/pixi-v2/core/Ellipse.js new file mode 100644 index 0000000..026b56f --- /dev/null +++ b/test/unit/pixi-v2/core/Ellipse.js @@ -0,0 +1,24 @@ +describe('pixi/core/Ellipse', function () { + 'use strict'; + + var expect = chai.expect; + var Ellipse = PIXI.Ellipse; + + it('Module exists', function () { + expect(Ellipse).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Ellipse(); + + expect(obj).to.be.an.instanceof(Ellipse); + expect(obj).to.respondTo('clone'); + expect(obj).to.respondTo('contains'); + expect(obj).to.respondTo('getBounds'); + + expect(obj).to.have.property('x', 0); + expect(obj).to.have.property('y', 0); + expect(obj).to.have.property('width', 0); + expect(obj).to.have.property('height', 0); + }); +}); diff --git a/test/unit/pixi-v2/core/Matrix.js b/test/unit/pixi-v2/core/Matrix.js new file mode 100644 index 0000000..da75e2e --- /dev/null +++ b/test/unit/pixi-v2/core/Matrix.js @@ -0,0 +1,14 @@ +describe('pixi/core/Matrix', function () { + 'use strict'; + + var expect = chai.expect; + + it('Matrix exists', function () { + expect(PIXI.Matrix).to.be.an('function'); + }); + + it('Confirm new Matrix', function () { + var matrix = new PIXI.Matrix(); + pixi_core_Matrix_confirmNewMatrix(matrix); + }); +}); diff --git a/test/unit/pixi-v2/core/Point.js b/test/unit/pixi-v2/core/Point.js new file mode 100644 index 0000000..c4d5163 --- /dev/null +++ b/test/unit/pixi-v2/core/Point.js @@ -0,0 +1,15 @@ +describe('pixi/core/Point', function () { + 'use strict'; + + var expect = chai.expect; + var Point = PIXI.Point; + + it('Module exists', function () { + expect(Point).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Point(); + pixi_core_Point_confirm(obj, 0, 0); + }); +}); diff --git a/test/unit/pixi-v2/core/Polygon.js b/test/unit/pixi-v2/core/Polygon.js new file mode 100644 index 0000000..dc8c918 --- /dev/null +++ b/test/unit/pixi-v2/core/Polygon.js @@ -0,0 +1,20 @@ +describe('pixi/core/Polygon', function () { + 'use strict'; + + var expect = chai.expect; + var Polygon = PIXI.Polygon; + + it('Module exists', function () { + expect(Polygon).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Polygon(); + + expect(obj).to.be.an.instanceof(Polygon); + expect(obj).to.respondTo('clone'); + expect(obj).to.respondTo('contains'); + + expect(obj).to.have.deep.property('points.length', 0); + }); +}); diff --git a/test/unit/pixi-v2/core/Rectangle.js b/test/unit/pixi-v2/core/Rectangle.js new file mode 100644 index 0000000..d43316e --- /dev/null +++ b/test/unit/pixi-v2/core/Rectangle.js @@ -0,0 +1,15 @@ +describe('pixi/core/Rectangle', function () { + 'use strict'; + + var expect = chai.expect; + var Rectangle = PIXI.Rectangle; + + it('Module exists', function () { + expect(Rectangle).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var rect = new Rectangle(); + pixi_core_Rectangle_confirm(rect, 0, 0, 0, 0); + }); +}); diff --git a/test/unit/pixi-v2/display/DisplayObject.js b/test/unit/pixi-v2/display/DisplayObject.js new file mode 100644 index 0000000..044acf8 --- /dev/null +++ b/test/unit/pixi-v2/display/DisplayObject.js @@ -0,0 +1,21 @@ +describe('pixi/display/DisplayObject', function () { + 'use strict'; + + var expect = chai.expect; + var DisplayObject = PIXI.DisplayObject; + + it('Module exists', function () { + expect(DisplayObject).to.be.a('function'); + // expect(PIXI).to.have.property('visibleCount', 0); + }); + + it('Confirm new instance', function () { + var obj = new DisplayObject(); + + pixi_display_DisplayObject_confirmNew(obj); + expect(obj).to.have.property('hitArea', null); + expect(obj).to.have.property('interactive', false); + expect(obj).to.have.property('renderable', false); + expect(obj).to.have.property('stage', null); + }); +}); diff --git a/test/unit/pixi-v2/display/DisplayObjectContainer.js b/test/unit/pixi-v2/display/DisplayObjectContainer.js new file mode 100644 index 0000000..15a3376 --- /dev/null +++ b/test/unit/pixi-v2/display/DisplayObjectContainer.js @@ -0,0 +1,67 @@ +describe('pixi/display/DisplayObjectContainer', function () { + 'use strict'; + + var expect = chai.expect; + var DisplayObjectContainer = PIXI.DisplayObjectContainer; + + it('Module exists', function () { + expect(DisplayObjectContainer).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new DisplayObjectContainer(); + + pixi_display_DisplayObjectContainer_confirmNew(obj); + expect(obj).to.have.property('hitArea', null); + expect(obj).to.have.property('interactive', false); + expect(obj).to.have.property('renderable', false); + expect(obj).to.have.property('stage', null); + }); + + it('Gets child index', function() { + var container = new PIXI.DisplayObjectContainer(); + var children = []; + for (var i = 0; i < 10; i++) { + var child = new PIXI.DisplayObject(); + children.push(child); + container.addChild(child); + } + + for (i = 0; i < children.length; i++) { + expect(i).to.eql(container.getChildIndex(children[i])); + } + }); + + it('throws error when trying to get index of not a child', function() { + var container = new PIXI.DisplayObjectContainer(); + var child = new PIXI.DisplayObject(); + + expect(function() { container.getChildIndex(child); }).to.throw(); + }); + + it('Sets child index', function() { + var container = new PIXI.DisplayObjectContainer(); + var children = []; + + for (var i = 0; i < 10; i++) { + var child = new PIXI.DisplayObject(); + children.push(child); + container.addChild(child); + } + children.reverse(); + + for (i = 0; i < children.length; i++) { + container.setChildIndex(children[i], i); + expect(i).to.eql(container.getChildIndex(children[i])); + } + }); + + it('throws error when trying to set incorect index', function() { + var container = new PIXI.DisplayObjectContainer(); + var child = new PIXI.DisplayObject(); + container.addChild(child); + + expect(function() { container.setChildIndex(child, -1); }).to.throw(); + expect(function() { container.setChildIndex(child, 1); }).to.throw(); + }); +}); diff --git a/test/unit/pixi-v2/display/MovieClip.js b/test/unit/pixi-v2/display/MovieClip.js new file mode 100644 index 0000000..f3c6c6a --- /dev/null +++ b/test/unit/pixi-v2/display/MovieClip.js @@ -0,0 +1,33 @@ +describe('pixi/display/MovieClip', function () { + 'use strict'; + + var expect = chai.expect; + var MovieClip = PIXI.MovieClip; + var Texture = PIXI.Texture; + + it('Module exists', function () { + expect(MovieClip).to.be.a('function'); + }); + + it('Confirm new instance', function (done) { + var texture = Texture.fromImage('/base/test/textures/SpriteSheet-Explosion.png'); + var obj = new MovieClip([texture]); + + pixi_display_Sprite_confirmNew(obj, done); + + expect(obj).to.be.an.instanceof(MovieClip); + expect(obj).to.respondTo('stop'); + expect(obj).to.respondTo('play'); + expect(obj).to.respondTo('gotoAndStop'); + expect(obj).to.respondTo('gotoAndPlay'); + expect(obj).to.respondTo('updateTransform'); + + expect(obj).to.have.deep.property('textures.length', 1); + expect(obj).to.have.deep.property('textures[0]', texture); + expect(obj).to.have.property('animationSpeed', 1); + expect(obj).to.have.property('loop', true); + expect(obj).to.have.property('onComplete', null); + expect(obj).to.have.property('currentFrame', 0); + expect(obj).to.have.property('playing', false); + }); +}); diff --git a/test/unit/pixi-v2/display/Sprite.js b/test/unit/pixi-v2/display/Sprite.js new file mode 100644 index 0000000..30c8076 --- /dev/null +++ b/test/unit/pixi-v2/display/Sprite.js @@ -0,0 +1,28 @@ +describe('pixi/display/Sprite', function () { + 'use strict'; + + var expect = chai.expect; + var Sprite = PIXI.Sprite; + var Texture = PIXI.Texture; + + it('Module exists', function () { + expect(Sprite).to.be.a('function'); + expect(PIXI).to.have.deep.property('blendModes.NORMAL', 0); + expect(PIXI).to.have.deep.property('blendModes.ADD', 1); + expect(PIXI).to.have.deep.property('blendModes.MULTIPLY', 2); + expect(PIXI).to.have.deep.property('blendModes.SCREEN', 3); + }); + + + it('Members exist', function () { + expect(Sprite).itself.to.respondTo('fromImage'); + expect(Sprite).itself.to.respondTo('fromFrame'); + }); + + it('Confirm new instance', function (done) { + var texture = Texture.fromImage('/base/test/textures/SpriteSheet-Aliens.png'); + var obj = new Sprite(texture); + + pixi_display_Sprite_confirmNew(obj, done); + }); +}); diff --git a/test/unit/pixi-v2/display/Stage.js b/test/unit/pixi-v2/display/Stage.js new file mode 100644 index 0000000..6974c2e --- /dev/null +++ b/test/unit/pixi-v2/display/Stage.js @@ -0,0 +1,49 @@ +describe('pixi/display/Stage', function () { + 'use strict'; + + var expect = chai.expect; + var Stage = PIXI.Stage; + var InteractionManager = PIXI.InteractionManager; + var Rectangle = PIXI.Rectangle; + + it('Module exists', function () { + expect(Stage).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Stage(null, true); + + pixi_display_DisplayObjectContainer_confirmNew(obj); + + expect(obj).to.be.an.instanceof(Stage); + expect(obj).to.respondTo('updateTransform'); + expect(obj).to.respondTo('setBackgroundColor'); + expect(obj).to.respondTo('getMousePosition'); + // FIXME: duplicate member in DisplayObject + pixi_core_Matrix_confirmNewMatrix(obj.worldTransform); + // FIXME: convert arg to bool in constructor + expect(obj).to.have.property('interactive', true); + + expect(obj).to.have.property('interactionManager') + .and.to.be.an.instanceof(InteractionManager) + .and.to.have.property('stage', obj); + + expect(obj).to.have.property('dirty', true); + + expect(obj).to.have.property('stage', obj); + + expect(obj).to.have.property('hitArea') + .and.to.be.an.instanceof(Rectangle); + pixi_core_Rectangle_confirm(obj.hitArea, 0, 0, 100000, 100000); + + expect(obj).to.have.property('backgroundColor', 0x000000); + expect(obj).to.have.deep.property('backgroundColorSplit.length', 3); + expect(obj).to.have.deep.property('backgroundColorSplit[0]', 0); + expect(obj).to.have.deep.property('backgroundColorSplit[1]', 0); + expect(obj).to.have.deep.property('backgroundColorSplit[2]', 0); + expect(obj).to.have.property('backgroundColorString', '#000000'); + + + expect(obj).to.have.property('worldVisible', true); + }); +}); diff --git a/test/unit/pixi-v2/extras/Rope.js b/test/unit/pixi-v2/extras/Rope.js new file mode 100644 index 0000000..05885ac --- /dev/null +++ b/test/unit/pixi-v2/extras/Rope.js @@ -0,0 +1,31 @@ +describe('pixi/extras/Rope', function () { + 'use strict'; + + var expect = chai.expect; + var Rope = PIXI.Rope; + var Texture = PIXI.Texture; + var Point = PIXI.Point; + + it('Module exists', function () { + expect(Rope).to.be.a('function'); + }); + + it('Confirm new instance', function () { + + var texture = Texture.fromImage('/base/test/textures/bunny.png'); + + // TODO-Alvin + // Same as Strip + + // var obj = new Rope(texture, [new Point(), new Point(5, 10), new Point(10, 20)]); + + // pixi_extras_Strip_confirmNew(obj); + + // expect(obj).to.be.an.instanceof(Rope); + // expect(obj).to.respondTo('refresh'); + // expect(obj).to.respondTo('updateTransform'); + // expect(obj).to.respondTo('setTexture'); + + // TODO: Test properties + }); +}); diff --git a/test/unit/pixi-v2/extras/Spine.js b/test/unit/pixi-v2/extras/Spine.js new file mode 100644 index 0000000..0708bc0 --- /dev/null +++ b/test/unit/pixi-v2/extras/Spine.js @@ -0,0 +1,10 @@ +describe('pixi/extras/Spine', function () { + 'use strict'; + + var expect = chai.expect; + var Spine = PIXI.Spine; + + it('Module exists', function () { + expect(Spine).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/extras/Strip.js b/test/unit/pixi-v2/extras/Strip.js new file mode 100644 index 0000000..230af90 --- /dev/null +++ b/test/unit/pixi-v2/extras/Strip.js @@ -0,0 +1,26 @@ +describe('pixi/extras/Strip', function () { + 'use strict'; + + var expect = chai.expect; + var Strip = PIXI.Strip; + var Texture = PIXI.Texture; + + it('Module exists', function () { + expect(Strip).to.be.a('function'); + }); + + it('Confirm new instance', function () { + + + // TODO-Alvin + // We tweaked it to make it pass the tests, but the whole strip class needs + // to be re-coded + + var texture = Texture.fromImage('/base/test/textures/bunny.png'); + + // var obj = new Strip(texture, 20, 10000); + + + // pixi_extras_Strip_confirmNew(obj); + }); +}); diff --git a/test/unit/pixi-v2/extras/TilingSprite.js b/test/unit/pixi-v2/extras/TilingSprite.js new file mode 100644 index 0000000..56aea14 --- /dev/null +++ b/test/unit/pixi-v2/extras/TilingSprite.js @@ -0,0 +1,24 @@ +describe('pixi/extras/TilingSprite', function () { + 'use strict'; + + var expect = chai.expect; + var TilingSprite = PIXI.TilingSprite; + var Texture = PIXI.Texture; + + it('Module exists', function () { + expect(TilingSprite).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var texture = Texture.fromImage('/base/test/textures/bunny.png'); + var obj = new TilingSprite(texture, 6000, 12000); + + pixi_display_DisplayObjectContainer_confirmNew(obj); + + expect(obj).to.be.an.instanceof(TilingSprite); + expect(obj).to.respondTo('setTexture'); + expect(obj).to.respondTo('onTextureUpdate'); + + // TODO: Test properties + }); +}); diff --git a/test/unit/pixi-v2/filters/FilterBlock.js b/test/unit/pixi-v2/filters/FilterBlock.js new file mode 100644 index 0000000..870cec0 --- /dev/null +++ b/test/unit/pixi-v2/filters/FilterBlock.js @@ -0,0 +1,10 @@ +describe('pixi/filters/FilterBlock', function () { + 'use strict'; + + var expect = chai.expect; + var FilterBlock = PIXI.FilterBlock; + + it('Module exists', function () { + expect(FilterBlock).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/AssetLoader.js b/test/unit/pixi-v2/loaders/AssetLoader.js new file mode 100644 index 0000000..a0aa0b5 --- /dev/null +++ b/test/unit/pixi-v2/loaders/AssetLoader.js @@ -0,0 +1,10 @@ +describe('pixi/loaders/AssetLoader', function () { + 'use strict'; + + var expect = chai.expect; + var AssetLoader = PIXI.AssetLoader; + + it('Module exists', function () { + expect(AssetLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/BitmapFontLoader.js b/test/unit/pixi-v2/loaders/BitmapFontLoader.js new file mode 100644 index 0000000..046f018 --- /dev/null +++ b/test/unit/pixi-v2/loaders/BitmapFontLoader.js @@ -0,0 +1,9 @@ +describe('pixi/loaders/BitmapFontLoader', function () { + 'use strict'; + + var expect = chai.expect; + + it('Module exists', function () { + expect(PIXI.BitmapFontLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/ImageLoader.js b/test/unit/pixi-v2/loaders/ImageLoader.js new file mode 100644 index 0000000..8b1f556 --- /dev/null +++ b/test/unit/pixi-v2/loaders/ImageLoader.js @@ -0,0 +1,10 @@ +describe('pixi/loaders/ImageLoader', function () { + 'use strict'; + + var expect = chai.expect; + var ImageLoader = PIXI.ImageLoader; + + it('Module exists', function () { + expect(ImageLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/JsonLoader.js b/test/unit/pixi-v2/loaders/JsonLoader.js new file mode 100644 index 0000000..c577e83 --- /dev/null +++ b/test/unit/pixi-v2/loaders/JsonLoader.js @@ -0,0 +1,10 @@ +describe('pixi/loaders/JsonLoader', function () { + 'use strict'; + + var expect = chai.expect; + var JsonLoader = PIXI.JsonLoader; + + it('Module exists', function () { + expect(JsonLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/SpineLoader.js b/test/unit/pixi-v2/loaders/SpineLoader.js new file mode 100644 index 0000000..fdcc0b8 --- /dev/null +++ b/test/unit/pixi-v2/loaders/SpineLoader.js @@ -0,0 +1,10 @@ +describe('pixi/loaders/SpineLoader', function () { + 'use strict'; + + var expect = chai.expect; + var SpineLoader = PIXI.SpineLoader; + + it('Module exists', function () { + expect(SpineLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/SpriteSheetLoader.js b/test/unit/pixi-v2/loaders/SpriteSheetLoader.js new file mode 100644 index 0000000..57beb27 --- /dev/null +++ b/test/unit/pixi-v2/loaders/SpriteSheetLoader.js @@ -0,0 +1,10 @@ +describe('pixi/loaders/SpriteSheetLoader', function () { + 'use strict'; + + var expect = chai.expect; + var SpriteSheetLoader = PIXI.SpriteSheetLoader; + + it('Module exists', function () { + expect(SpriteSheetLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/primitives/Graphics.js b/test/unit/pixi-v2/primitives/Graphics.js new file mode 100644 index 0000000..f3849eb --- /dev/null +++ b/test/unit/pixi-v2/primitives/Graphics.js @@ -0,0 +1,44 @@ +describe('pixi/primitives/Graphics', function () { + 'use strict'; + + var expect = chai.expect; + var Graphics = PIXI.Graphics; + + it('Module exists', function () { + expect(Graphics).to.be.a('function'); + + expect(Graphics).itself.to.have.property('POLY', 0); + expect(Graphics).itself.to.have.property('RECT', 1); + expect(Graphics).itself.to.have.property('CIRC', 2); + expect(Graphics).itself.to.have.property('ELIP', 3); + expect(Graphics).itself.to.have.property('RREC', 4); + }); + + it('Confirm new instance', function () { + var obj = new Graphics(); + + pixi_display_DisplayObjectContainer_confirmNew(obj); + + expect(obj).to.be.an.instanceof(Graphics); + expect(obj).to.respondTo('lineStyle'); + expect(obj).to.respondTo('lineStyle'); + expect(obj).to.respondTo('moveTo'); + expect(obj).to.respondTo('lineTo'); + expect(obj).to.respondTo('beginFill'); + expect(obj).to.respondTo('endFill'); + expect(obj).to.respondTo('drawRect'); + // expect(obj).to.respondTo('drawRoundedRect'); + expect(obj).to.respondTo('drawCircle'); + expect(obj).to.respondTo('drawEllipse'); + expect(obj).to.respondTo('clear'); + + expect(obj).to.have.property('renderable', true); + expect(obj).to.have.property('fillAlpha', 1); + expect(obj).to.have.property('lineWidth', 0); + expect(obj).to.have.property('width', 0); + expect(obj).to.have.property('height', 0); + expect(obj).to.have.property('lineColor', 0); + expect(obj).to.have.deep.property('graphicsData.length', 0); + // expect(obj).to.have.deep.property('currentPath.points.length', 0); + }); +}); diff --git a/test/unit/pixi-v2/renderers/canvas/CanvasGraphics.js b/test/unit/pixi-v2/renderers/canvas/CanvasGraphics.js new file mode 100644 index 0000000..8f44472 --- /dev/null +++ b/test/unit/pixi-v2/renderers/canvas/CanvasGraphics.js @@ -0,0 +1,15 @@ +describe('renders/canvas/CanvasGraphics', function () { + 'use strict'; + + var expect = chai.expect; + var CanvasGraphics = PIXI.CanvasGraphics; + + it('Module exists', function () { + expect(CanvasGraphics).to.be.a('function'); + }); + + it('Members exist', function () { + expect(CanvasGraphics).itself.to.respondTo('renderGraphics'); + expect(CanvasGraphics).itself.to.respondTo('renderGraphicsMask'); + }); +}); diff --git a/test/unit/pixi-v2/renderers/canvas/CanvasRenderer.js b/test/unit/pixi-v2/renderers/canvas/CanvasRenderer.js new file mode 100644 index 0000000..1646444 --- /dev/null +++ b/test/unit/pixi-v2/renderers/canvas/CanvasRenderer.js @@ -0,0 +1,36 @@ +describe('renderers/canvas/CanvasRenderer', function () { + 'use strict'; + + var expect = chai.expect; + var CanvasRenderer = PIXI.CanvasRenderer; + + it('Module exists', function () { + expect(CanvasRenderer).to.be.a('function'); + }); + + describe('.autoResize', function () { + it('Should automatically resize view if enabled', function () { + var renderer = new CanvasRenderer(200, 200, { + autoResize: true + }); + + expect(renderer.view.style.width).to.equal('200px'); + }); + + it('Should not automatically resize view if disabled', function () { + var renderer = new CanvasRenderer(200, 200, { + autoResize: false + }); + + expect(renderer.view.style.width).to.equal(''); + }); + + it('Should not automatically resize view if not specified', function () { + var renderer = new CanvasRenderer(200, 200, { + resolution: 2 + }); + + expect(renderer.view.style.width).to.equal(''); + }); + }); +}); diff --git a/test/unit/pixi-v2/InteractionManager.js b/test/unit/pixi-v2/InteractionManager.js new file mode 100644 index 0000000..ed3001f --- /dev/null +++ b/test/unit/pixi-v2/InteractionManager.js @@ -0,0 +1,10 @@ +describe('pixi/InteractionManager', function () { + 'use strict'; + + var expect = chai.expect; + var InteractionManager = PIXI.InteractionManager; + + it('Module exists', function () { + expect(InteractionManager).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/Pixi.js b/test/unit/pixi-v2/Pixi.js new file mode 100644 index 0000000..27debc1 --- /dev/null +++ b/test/unit/pixi-v2/Pixi.js @@ -0,0 +1,9 @@ +describe('pixi/Pixi', function () { + 'use strict'; + + var expect = chai.expect; + + it('Module exists', function () { + expect(global).to.have.property('PIXI').and.to.be.an('object'); + }); +}); diff --git a/test/unit/pixi-v2/core/Circle.js b/test/unit/pixi-v2/core/Circle.js new file mode 100644 index 0000000..fbcfa17 --- /dev/null +++ b/test/unit/pixi-v2/core/Circle.js @@ -0,0 +1,21 @@ +describe('pixi/core/Circle', function () { + 'use strict'; + + var expect = chai.expect; + var Circle = PIXI.Circle; + + it('Module exists', function () { + expect(Circle).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Circle(); + pixi_core_Circle_confirmNewCircle(obj); + }); + + it("getBounds should return Rectangle that bounds the circle", function() { + var obj = new Circle(100, 250, 50); + var bounds = obj.getBounds(); + pixi_core_Circle_isBoundedByRectangle(obj, bounds); + }); +}); diff --git a/test/unit/pixi-v2/core/Ellipse.js b/test/unit/pixi-v2/core/Ellipse.js new file mode 100644 index 0000000..026b56f --- /dev/null +++ b/test/unit/pixi-v2/core/Ellipse.js @@ -0,0 +1,24 @@ +describe('pixi/core/Ellipse', function () { + 'use strict'; + + var expect = chai.expect; + var Ellipse = PIXI.Ellipse; + + it('Module exists', function () { + expect(Ellipse).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Ellipse(); + + expect(obj).to.be.an.instanceof(Ellipse); + expect(obj).to.respondTo('clone'); + expect(obj).to.respondTo('contains'); + expect(obj).to.respondTo('getBounds'); + + expect(obj).to.have.property('x', 0); + expect(obj).to.have.property('y', 0); + expect(obj).to.have.property('width', 0); + expect(obj).to.have.property('height', 0); + }); +}); diff --git a/test/unit/pixi-v2/core/Matrix.js b/test/unit/pixi-v2/core/Matrix.js new file mode 100644 index 0000000..da75e2e --- /dev/null +++ b/test/unit/pixi-v2/core/Matrix.js @@ -0,0 +1,14 @@ +describe('pixi/core/Matrix', function () { + 'use strict'; + + var expect = chai.expect; + + it('Matrix exists', function () { + expect(PIXI.Matrix).to.be.an('function'); + }); + + it('Confirm new Matrix', function () { + var matrix = new PIXI.Matrix(); + pixi_core_Matrix_confirmNewMatrix(matrix); + }); +}); diff --git a/test/unit/pixi-v2/core/Point.js b/test/unit/pixi-v2/core/Point.js new file mode 100644 index 0000000..c4d5163 --- /dev/null +++ b/test/unit/pixi-v2/core/Point.js @@ -0,0 +1,15 @@ +describe('pixi/core/Point', function () { + 'use strict'; + + var expect = chai.expect; + var Point = PIXI.Point; + + it('Module exists', function () { + expect(Point).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Point(); + pixi_core_Point_confirm(obj, 0, 0); + }); +}); diff --git a/test/unit/pixi-v2/core/Polygon.js b/test/unit/pixi-v2/core/Polygon.js new file mode 100644 index 0000000..dc8c918 --- /dev/null +++ b/test/unit/pixi-v2/core/Polygon.js @@ -0,0 +1,20 @@ +describe('pixi/core/Polygon', function () { + 'use strict'; + + var expect = chai.expect; + var Polygon = PIXI.Polygon; + + it('Module exists', function () { + expect(Polygon).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Polygon(); + + expect(obj).to.be.an.instanceof(Polygon); + expect(obj).to.respondTo('clone'); + expect(obj).to.respondTo('contains'); + + expect(obj).to.have.deep.property('points.length', 0); + }); +}); diff --git a/test/unit/pixi-v2/core/Rectangle.js b/test/unit/pixi-v2/core/Rectangle.js new file mode 100644 index 0000000..d43316e --- /dev/null +++ b/test/unit/pixi-v2/core/Rectangle.js @@ -0,0 +1,15 @@ +describe('pixi/core/Rectangle', function () { + 'use strict'; + + var expect = chai.expect; + var Rectangle = PIXI.Rectangle; + + it('Module exists', function () { + expect(Rectangle).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var rect = new Rectangle(); + pixi_core_Rectangle_confirm(rect, 0, 0, 0, 0); + }); +}); diff --git a/test/unit/pixi-v2/display/DisplayObject.js b/test/unit/pixi-v2/display/DisplayObject.js new file mode 100644 index 0000000..044acf8 --- /dev/null +++ b/test/unit/pixi-v2/display/DisplayObject.js @@ -0,0 +1,21 @@ +describe('pixi/display/DisplayObject', function () { + 'use strict'; + + var expect = chai.expect; + var DisplayObject = PIXI.DisplayObject; + + it('Module exists', function () { + expect(DisplayObject).to.be.a('function'); + // expect(PIXI).to.have.property('visibleCount', 0); + }); + + it('Confirm new instance', function () { + var obj = new DisplayObject(); + + pixi_display_DisplayObject_confirmNew(obj); + expect(obj).to.have.property('hitArea', null); + expect(obj).to.have.property('interactive', false); + expect(obj).to.have.property('renderable', false); + expect(obj).to.have.property('stage', null); + }); +}); diff --git a/test/unit/pixi-v2/display/DisplayObjectContainer.js b/test/unit/pixi-v2/display/DisplayObjectContainer.js new file mode 100644 index 0000000..15a3376 --- /dev/null +++ b/test/unit/pixi-v2/display/DisplayObjectContainer.js @@ -0,0 +1,67 @@ +describe('pixi/display/DisplayObjectContainer', function () { + 'use strict'; + + var expect = chai.expect; + var DisplayObjectContainer = PIXI.DisplayObjectContainer; + + it('Module exists', function () { + expect(DisplayObjectContainer).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new DisplayObjectContainer(); + + pixi_display_DisplayObjectContainer_confirmNew(obj); + expect(obj).to.have.property('hitArea', null); + expect(obj).to.have.property('interactive', false); + expect(obj).to.have.property('renderable', false); + expect(obj).to.have.property('stage', null); + }); + + it('Gets child index', function() { + var container = new PIXI.DisplayObjectContainer(); + var children = []; + for (var i = 0; i < 10; i++) { + var child = new PIXI.DisplayObject(); + children.push(child); + container.addChild(child); + } + + for (i = 0; i < children.length; i++) { + expect(i).to.eql(container.getChildIndex(children[i])); + } + }); + + it('throws error when trying to get index of not a child', function() { + var container = new PIXI.DisplayObjectContainer(); + var child = new PIXI.DisplayObject(); + + expect(function() { container.getChildIndex(child); }).to.throw(); + }); + + it('Sets child index', function() { + var container = new PIXI.DisplayObjectContainer(); + var children = []; + + for (var i = 0; i < 10; i++) { + var child = new PIXI.DisplayObject(); + children.push(child); + container.addChild(child); + } + children.reverse(); + + for (i = 0; i < children.length; i++) { + container.setChildIndex(children[i], i); + expect(i).to.eql(container.getChildIndex(children[i])); + } + }); + + it('throws error when trying to set incorect index', function() { + var container = new PIXI.DisplayObjectContainer(); + var child = new PIXI.DisplayObject(); + container.addChild(child); + + expect(function() { container.setChildIndex(child, -1); }).to.throw(); + expect(function() { container.setChildIndex(child, 1); }).to.throw(); + }); +}); diff --git a/test/unit/pixi-v2/display/MovieClip.js b/test/unit/pixi-v2/display/MovieClip.js new file mode 100644 index 0000000..f3c6c6a --- /dev/null +++ b/test/unit/pixi-v2/display/MovieClip.js @@ -0,0 +1,33 @@ +describe('pixi/display/MovieClip', function () { + 'use strict'; + + var expect = chai.expect; + var MovieClip = PIXI.MovieClip; + var Texture = PIXI.Texture; + + it('Module exists', function () { + expect(MovieClip).to.be.a('function'); + }); + + it('Confirm new instance', function (done) { + var texture = Texture.fromImage('/base/test/textures/SpriteSheet-Explosion.png'); + var obj = new MovieClip([texture]); + + pixi_display_Sprite_confirmNew(obj, done); + + expect(obj).to.be.an.instanceof(MovieClip); + expect(obj).to.respondTo('stop'); + expect(obj).to.respondTo('play'); + expect(obj).to.respondTo('gotoAndStop'); + expect(obj).to.respondTo('gotoAndPlay'); + expect(obj).to.respondTo('updateTransform'); + + expect(obj).to.have.deep.property('textures.length', 1); + expect(obj).to.have.deep.property('textures[0]', texture); + expect(obj).to.have.property('animationSpeed', 1); + expect(obj).to.have.property('loop', true); + expect(obj).to.have.property('onComplete', null); + expect(obj).to.have.property('currentFrame', 0); + expect(obj).to.have.property('playing', false); + }); +}); diff --git a/test/unit/pixi-v2/display/Sprite.js b/test/unit/pixi-v2/display/Sprite.js new file mode 100644 index 0000000..30c8076 --- /dev/null +++ b/test/unit/pixi-v2/display/Sprite.js @@ -0,0 +1,28 @@ +describe('pixi/display/Sprite', function () { + 'use strict'; + + var expect = chai.expect; + var Sprite = PIXI.Sprite; + var Texture = PIXI.Texture; + + it('Module exists', function () { + expect(Sprite).to.be.a('function'); + expect(PIXI).to.have.deep.property('blendModes.NORMAL', 0); + expect(PIXI).to.have.deep.property('blendModes.ADD', 1); + expect(PIXI).to.have.deep.property('blendModes.MULTIPLY', 2); + expect(PIXI).to.have.deep.property('blendModes.SCREEN', 3); + }); + + + it('Members exist', function () { + expect(Sprite).itself.to.respondTo('fromImage'); + expect(Sprite).itself.to.respondTo('fromFrame'); + }); + + it('Confirm new instance', function (done) { + var texture = Texture.fromImage('/base/test/textures/SpriteSheet-Aliens.png'); + var obj = new Sprite(texture); + + pixi_display_Sprite_confirmNew(obj, done); + }); +}); diff --git a/test/unit/pixi-v2/display/Stage.js b/test/unit/pixi-v2/display/Stage.js new file mode 100644 index 0000000..6974c2e --- /dev/null +++ b/test/unit/pixi-v2/display/Stage.js @@ -0,0 +1,49 @@ +describe('pixi/display/Stage', function () { + 'use strict'; + + var expect = chai.expect; + var Stage = PIXI.Stage; + var InteractionManager = PIXI.InteractionManager; + var Rectangle = PIXI.Rectangle; + + it('Module exists', function () { + expect(Stage).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Stage(null, true); + + pixi_display_DisplayObjectContainer_confirmNew(obj); + + expect(obj).to.be.an.instanceof(Stage); + expect(obj).to.respondTo('updateTransform'); + expect(obj).to.respondTo('setBackgroundColor'); + expect(obj).to.respondTo('getMousePosition'); + // FIXME: duplicate member in DisplayObject + pixi_core_Matrix_confirmNewMatrix(obj.worldTransform); + // FIXME: convert arg to bool in constructor + expect(obj).to.have.property('interactive', true); + + expect(obj).to.have.property('interactionManager') + .and.to.be.an.instanceof(InteractionManager) + .and.to.have.property('stage', obj); + + expect(obj).to.have.property('dirty', true); + + expect(obj).to.have.property('stage', obj); + + expect(obj).to.have.property('hitArea') + .and.to.be.an.instanceof(Rectangle); + pixi_core_Rectangle_confirm(obj.hitArea, 0, 0, 100000, 100000); + + expect(obj).to.have.property('backgroundColor', 0x000000); + expect(obj).to.have.deep.property('backgroundColorSplit.length', 3); + expect(obj).to.have.deep.property('backgroundColorSplit[0]', 0); + expect(obj).to.have.deep.property('backgroundColorSplit[1]', 0); + expect(obj).to.have.deep.property('backgroundColorSplit[2]', 0); + expect(obj).to.have.property('backgroundColorString', '#000000'); + + + expect(obj).to.have.property('worldVisible', true); + }); +}); diff --git a/test/unit/pixi-v2/extras/Rope.js b/test/unit/pixi-v2/extras/Rope.js new file mode 100644 index 0000000..05885ac --- /dev/null +++ b/test/unit/pixi-v2/extras/Rope.js @@ -0,0 +1,31 @@ +describe('pixi/extras/Rope', function () { + 'use strict'; + + var expect = chai.expect; + var Rope = PIXI.Rope; + var Texture = PIXI.Texture; + var Point = PIXI.Point; + + it('Module exists', function () { + expect(Rope).to.be.a('function'); + }); + + it('Confirm new instance', function () { + + var texture = Texture.fromImage('/base/test/textures/bunny.png'); + + // TODO-Alvin + // Same as Strip + + // var obj = new Rope(texture, [new Point(), new Point(5, 10), new Point(10, 20)]); + + // pixi_extras_Strip_confirmNew(obj); + + // expect(obj).to.be.an.instanceof(Rope); + // expect(obj).to.respondTo('refresh'); + // expect(obj).to.respondTo('updateTransform'); + // expect(obj).to.respondTo('setTexture'); + + // TODO: Test properties + }); +}); diff --git a/test/unit/pixi-v2/extras/Spine.js b/test/unit/pixi-v2/extras/Spine.js new file mode 100644 index 0000000..0708bc0 --- /dev/null +++ b/test/unit/pixi-v2/extras/Spine.js @@ -0,0 +1,10 @@ +describe('pixi/extras/Spine', function () { + 'use strict'; + + var expect = chai.expect; + var Spine = PIXI.Spine; + + it('Module exists', function () { + expect(Spine).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/extras/Strip.js b/test/unit/pixi-v2/extras/Strip.js new file mode 100644 index 0000000..230af90 --- /dev/null +++ b/test/unit/pixi-v2/extras/Strip.js @@ -0,0 +1,26 @@ +describe('pixi/extras/Strip', function () { + 'use strict'; + + var expect = chai.expect; + var Strip = PIXI.Strip; + var Texture = PIXI.Texture; + + it('Module exists', function () { + expect(Strip).to.be.a('function'); + }); + + it('Confirm new instance', function () { + + + // TODO-Alvin + // We tweaked it to make it pass the tests, but the whole strip class needs + // to be re-coded + + var texture = Texture.fromImage('/base/test/textures/bunny.png'); + + // var obj = new Strip(texture, 20, 10000); + + + // pixi_extras_Strip_confirmNew(obj); + }); +}); diff --git a/test/unit/pixi-v2/extras/TilingSprite.js b/test/unit/pixi-v2/extras/TilingSprite.js new file mode 100644 index 0000000..56aea14 --- /dev/null +++ b/test/unit/pixi-v2/extras/TilingSprite.js @@ -0,0 +1,24 @@ +describe('pixi/extras/TilingSprite', function () { + 'use strict'; + + var expect = chai.expect; + var TilingSprite = PIXI.TilingSprite; + var Texture = PIXI.Texture; + + it('Module exists', function () { + expect(TilingSprite).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var texture = Texture.fromImage('/base/test/textures/bunny.png'); + var obj = new TilingSprite(texture, 6000, 12000); + + pixi_display_DisplayObjectContainer_confirmNew(obj); + + expect(obj).to.be.an.instanceof(TilingSprite); + expect(obj).to.respondTo('setTexture'); + expect(obj).to.respondTo('onTextureUpdate'); + + // TODO: Test properties + }); +}); diff --git a/test/unit/pixi-v2/filters/FilterBlock.js b/test/unit/pixi-v2/filters/FilterBlock.js new file mode 100644 index 0000000..870cec0 --- /dev/null +++ b/test/unit/pixi-v2/filters/FilterBlock.js @@ -0,0 +1,10 @@ +describe('pixi/filters/FilterBlock', function () { + 'use strict'; + + var expect = chai.expect; + var FilterBlock = PIXI.FilterBlock; + + it('Module exists', function () { + expect(FilterBlock).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/AssetLoader.js b/test/unit/pixi-v2/loaders/AssetLoader.js new file mode 100644 index 0000000..a0aa0b5 --- /dev/null +++ b/test/unit/pixi-v2/loaders/AssetLoader.js @@ -0,0 +1,10 @@ +describe('pixi/loaders/AssetLoader', function () { + 'use strict'; + + var expect = chai.expect; + var AssetLoader = PIXI.AssetLoader; + + it('Module exists', function () { + expect(AssetLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/BitmapFontLoader.js b/test/unit/pixi-v2/loaders/BitmapFontLoader.js new file mode 100644 index 0000000..046f018 --- /dev/null +++ b/test/unit/pixi-v2/loaders/BitmapFontLoader.js @@ -0,0 +1,9 @@ +describe('pixi/loaders/BitmapFontLoader', function () { + 'use strict'; + + var expect = chai.expect; + + it('Module exists', function () { + expect(PIXI.BitmapFontLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/ImageLoader.js b/test/unit/pixi-v2/loaders/ImageLoader.js new file mode 100644 index 0000000..8b1f556 --- /dev/null +++ b/test/unit/pixi-v2/loaders/ImageLoader.js @@ -0,0 +1,10 @@ +describe('pixi/loaders/ImageLoader', function () { + 'use strict'; + + var expect = chai.expect; + var ImageLoader = PIXI.ImageLoader; + + it('Module exists', function () { + expect(ImageLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/JsonLoader.js b/test/unit/pixi-v2/loaders/JsonLoader.js new file mode 100644 index 0000000..c577e83 --- /dev/null +++ b/test/unit/pixi-v2/loaders/JsonLoader.js @@ -0,0 +1,10 @@ +describe('pixi/loaders/JsonLoader', function () { + 'use strict'; + + var expect = chai.expect; + var JsonLoader = PIXI.JsonLoader; + + it('Module exists', function () { + expect(JsonLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/SpineLoader.js b/test/unit/pixi-v2/loaders/SpineLoader.js new file mode 100644 index 0000000..fdcc0b8 --- /dev/null +++ b/test/unit/pixi-v2/loaders/SpineLoader.js @@ -0,0 +1,10 @@ +describe('pixi/loaders/SpineLoader', function () { + 'use strict'; + + var expect = chai.expect; + var SpineLoader = PIXI.SpineLoader; + + it('Module exists', function () { + expect(SpineLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/SpriteSheetLoader.js b/test/unit/pixi-v2/loaders/SpriteSheetLoader.js new file mode 100644 index 0000000..57beb27 --- /dev/null +++ b/test/unit/pixi-v2/loaders/SpriteSheetLoader.js @@ -0,0 +1,10 @@ +describe('pixi/loaders/SpriteSheetLoader', function () { + 'use strict'; + + var expect = chai.expect; + var SpriteSheetLoader = PIXI.SpriteSheetLoader; + + it('Module exists', function () { + expect(SpriteSheetLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/primitives/Graphics.js b/test/unit/pixi-v2/primitives/Graphics.js new file mode 100644 index 0000000..f3849eb --- /dev/null +++ b/test/unit/pixi-v2/primitives/Graphics.js @@ -0,0 +1,44 @@ +describe('pixi/primitives/Graphics', function () { + 'use strict'; + + var expect = chai.expect; + var Graphics = PIXI.Graphics; + + it('Module exists', function () { + expect(Graphics).to.be.a('function'); + + expect(Graphics).itself.to.have.property('POLY', 0); + expect(Graphics).itself.to.have.property('RECT', 1); + expect(Graphics).itself.to.have.property('CIRC', 2); + expect(Graphics).itself.to.have.property('ELIP', 3); + expect(Graphics).itself.to.have.property('RREC', 4); + }); + + it('Confirm new instance', function () { + var obj = new Graphics(); + + pixi_display_DisplayObjectContainer_confirmNew(obj); + + expect(obj).to.be.an.instanceof(Graphics); + expect(obj).to.respondTo('lineStyle'); + expect(obj).to.respondTo('lineStyle'); + expect(obj).to.respondTo('moveTo'); + expect(obj).to.respondTo('lineTo'); + expect(obj).to.respondTo('beginFill'); + expect(obj).to.respondTo('endFill'); + expect(obj).to.respondTo('drawRect'); + // expect(obj).to.respondTo('drawRoundedRect'); + expect(obj).to.respondTo('drawCircle'); + expect(obj).to.respondTo('drawEllipse'); + expect(obj).to.respondTo('clear'); + + expect(obj).to.have.property('renderable', true); + expect(obj).to.have.property('fillAlpha', 1); + expect(obj).to.have.property('lineWidth', 0); + expect(obj).to.have.property('width', 0); + expect(obj).to.have.property('height', 0); + expect(obj).to.have.property('lineColor', 0); + expect(obj).to.have.deep.property('graphicsData.length', 0); + // expect(obj).to.have.deep.property('currentPath.points.length', 0); + }); +}); diff --git a/test/unit/pixi-v2/renderers/canvas/CanvasGraphics.js b/test/unit/pixi-v2/renderers/canvas/CanvasGraphics.js new file mode 100644 index 0000000..8f44472 --- /dev/null +++ b/test/unit/pixi-v2/renderers/canvas/CanvasGraphics.js @@ -0,0 +1,15 @@ +describe('renders/canvas/CanvasGraphics', function () { + 'use strict'; + + var expect = chai.expect; + var CanvasGraphics = PIXI.CanvasGraphics; + + it('Module exists', function () { + expect(CanvasGraphics).to.be.a('function'); + }); + + it('Members exist', function () { + expect(CanvasGraphics).itself.to.respondTo('renderGraphics'); + expect(CanvasGraphics).itself.to.respondTo('renderGraphicsMask'); + }); +}); diff --git a/test/unit/pixi-v2/renderers/canvas/CanvasRenderer.js b/test/unit/pixi-v2/renderers/canvas/CanvasRenderer.js new file mode 100644 index 0000000..1646444 --- /dev/null +++ b/test/unit/pixi-v2/renderers/canvas/CanvasRenderer.js @@ -0,0 +1,36 @@ +describe('renderers/canvas/CanvasRenderer', function () { + 'use strict'; + + var expect = chai.expect; + var CanvasRenderer = PIXI.CanvasRenderer; + + it('Module exists', function () { + expect(CanvasRenderer).to.be.a('function'); + }); + + describe('.autoResize', function () { + it('Should automatically resize view if enabled', function () { + var renderer = new CanvasRenderer(200, 200, { + autoResize: true + }); + + expect(renderer.view.style.width).to.equal('200px'); + }); + + it('Should not automatically resize view if disabled', function () { + var renderer = new CanvasRenderer(200, 200, { + autoResize: false + }); + + expect(renderer.view.style.width).to.equal(''); + }); + + it('Should not automatically resize view if not specified', function () { + var renderer = new CanvasRenderer(200, 200, { + resolution: 2 + }); + + expect(renderer.view.style.width).to.equal(''); + }); + }); +}); diff --git a/test/unit/pixi-v2/renderers/webgl/WebGLGraphics.js b/test/unit/pixi-v2/renderers/webgl/WebGLGraphics.js new file mode 100644 index 0000000..5867b28 --- /dev/null +++ b/test/unit/pixi-v2/renderers/webgl/WebGLGraphics.js @@ -0,0 +1,20 @@ +describe('renderers/wegbl/WebGLGraphics', function () { + 'use strict'; + + var expect = chai.expect; + var WebGLGraphics = PIXI.WebGLGraphics; + + it('Module exists', function () { + expect(WebGLGraphics).to.be.a('function'); + }); + + it('Members exist', function () { + expect(WebGLGraphics).itself.to.respondTo('renderGraphics'); + expect(WebGLGraphics).itself.to.respondTo('updateGraphics'); + expect(WebGLGraphics).itself.to.respondTo('buildRectangle'); + expect(WebGLGraphics).itself.to.respondTo('buildRoundedRectangle'); + expect(WebGLGraphics).itself.to.respondTo('buildCircle'); + expect(WebGLGraphics).itself.to.respondTo('buildLine'); + expect(WebGLGraphics).itself.to.respondTo('buildPoly'); + }); +}); diff --git a/test/unit/pixi-v2/InteractionManager.js b/test/unit/pixi-v2/InteractionManager.js new file mode 100644 index 0000000..ed3001f --- /dev/null +++ b/test/unit/pixi-v2/InteractionManager.js @@ -0,0 +1,10 @@ +describe('pixi/InteractionManager', function () { + 'use strict'; + + var expect = chai.expect; + var InteractionManager = PIXI.InteractionManager; + + it('Module exists', function () { + expect(InteractionManager).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/Pixi.js b/test/unit/pixi-v2/Pixi.js new file mode 100644 index 0000000..27debc1 --- /dev/null +++ b/test/unit/pixi-v2/Pixi.js @@ -0,0 +1,9 @@ +describe('pixi/Pixi', function () { + 'use strict'; + + var expect = chai.expect; + + it('Module exists', function () { + expect(global).to.have.property('PIXI').and.to.be.an('object'); + }); +}); diff --git a/test/unit/pixi-v2/core/Circle.js b/test/unit/pixi-v2/core/Circle.js new file mode 100644 index 0000000..fbcfa17 --- /dev/null +++ b/test/unit/pixi-v2/core/Circle.js @@ -0,0 +1,21 @@ +describe('pixi/core/Circle', function () { + 'use strict'; + + var expect = chai.expect; + var Circle = PIXI.Circle; + + it('Module exists', function () { + expect(Circle).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Circle(); + pixi_core_Circle_confirmNewCircle(obj); + }); + + it("getBounds should return Rectangle that bounds the circle", function() { + var obj = new Circle(100, 250, 50); + var bounds = obj.getBounds(); + pixi_core_Circle_isBoundedByRectangle(obj, bounds); + }); +}); diff --git a/test/unit/pixi-v2/core/Ellipse.js b/test/unit/pixi-v2/core/Ellipse.js new file mode 100644 index 0000000..026b56f --- /dev/null +++ b/test/unit/pixi-v2/core/Ellipse.js @@ -0,0 +1,24 @@ +describe('pixi/core/Ellipse', function () { + 'use strict'; + + var expect = chai.expect; + var Ellipse = PIXI.Ellipse; + + it('Module exists', function () { + expect(Ellipse).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Ellipse(); + + expect(obj).to.be.an.instanceof(Ellipse); + expect(obj).to.respondTo('clone'); + expect(obj).to.respondTo('contains'); + expect(obj).to.respondTo('getBounds'); + + expect(obj).to.have.property('x', 0); + expect(obj).to.have.property('y', 0); + expect(obj).to.have.property('width', 0); + expect(obj).to.have.property('height', 0); + }); +}); diff --git a/test/unit/pixi-v2/core/Matrix.js b/test/unit/pixi-v2/core/Matrix.js new file mode 100644 index 0000000..da75e2e --- /dev/null +++ b/test/unit/pixi-v2/core/Matrix.js @@ -0,0 +1,14 @@ +describe('pixi/core/Matrix', function () { + 'use strict'; + + var expect = chai.expect; + + it('Matrix exists', function () { + expect(PIXI.Matrix).to.be.an('function'); + }); + + it('Confirm new Matrix', function () { + var matrix = new PIXI.Matrix(); + pixi_core_Matrix_confirmNewMatrix(matrix); + }); +}); diff --git a/test/unit/pixi-v2/core/Point.js b/test/unit/pixi-v2/core/Point.js new file mode 100644 index 0000000..c4d5163 --- /dev/null +++ b/test/unit/pixi-v2/core/Point.js @@ -0,0 +1,15 @@ +describe('pixi/core/Point', function () { + 'use strict'; + + var expect = chai.expect; + var Point = PIXI.Point; + + it('Module exists', function () { + expect(Point).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Point(); + pixi_core_Point_confirm(obj, 0, 0); + }); +}); diff --git a/test/unit/pixi-v2/core/Polygon.js b/test/unit/pixi-v2/core/Polygon.js new file mode 100644 index 0000000..dc8c918 --- /dev/null +++ b/test/unit/pixi-v2/core/Polygon.js @@ -0,0 +1,20 @@ +describe('pixi/core/Polygon', function () { + 'use strict'; + + var expect = chai.expect; + var Polygon = PIXI.Polygon; + + it('Module exists', function () { + expect(Polygon).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Polygon(); + + expect(obj).to.be.an.instanceof(Polygon); + expect(obj).to.respondTo('clone'); + expect(obj).to.respondTo('contains'); + + expect(obj).to.have.deep.property('points.length', 0); + }); +}); diff --git a/test/unit/pixi-v2/core/Rectangle.js b/test/unit/pixi-v2/core/Rectangle.js new file mode 100644 index 0000000..d43316e --- /dev/null +++ b/test/unit/pixi-v2/core/Rectangle.js @@ -0,0 +1,15 @@ +describe('pixi/core/Rectangle', function () { + 'use strict'; + + var expect = chai.expect; + var Rectangle = PIXI.Rectangle; + + it('Module exists', function () { + expect(Rectangle).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var rect = new Rectangle(); + pixi_core_Rectangle_confirm(rect, 0, 0, 0, 0); + }); +}); diff --git a/test/unit/pixi-v2/display/DisplayObject.js b/test/unit/pixi-v2/display/DisplayObject.js new file mode 100644 index 0000000..044acf8 --- /dev/null +++ b/test/unit/pixi-v2/display/DisplayObject.js @@ -0,0 +1,21 @@ +describe('pixi/display/DisplayObject', function () { + 'use strict'; + + var expect = chai.expect; + var DisplayObject = PIXI.DisplayObject; + + it('Module exists', function () { + expect(DisplayObject).to.be.a('function'); + // expect(PIXI).to.have.property('visibleCount', 0); + }); + + it('Confirm new instance', function () { + var obj = new DisplayObject(); + + pixi_display_DisplayObject_confirmNew(obj); + expect(obj).to.have.property('hitArea', null); + expect(obj).to.have.property('interactive', false); + expect(obj).to.have.property('renderable', false); + expect(obj).to.have.property('stage', null); + }); +}); diff --git a/test/unit/pixi-v2/display/DisplayObjectContainer.js b/test/unit/pixi-v2/display/DisplayObjectContainer.js new file mode 100644 index 0000000..15a3376 --- /dev/null +++ b/test/unit/pixi-v2/display/DisplayObjectContainer.js @@ -0,0 +1,67 @@ +describe('pixi/display/DisplayObjectContainer', function () { + 'use strict'; + + var expect = chai.expect; + var DisplayObjectContainer = PIXI.DisplayObjectContainer; + + it('Module exists', function () { + expect(DisplayObjectContainer).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new DisplayObjectContainer(); + + pixi_display_DisplayObjectContainer_confirmNew(obj); + expect(obj).to.have.property('hitArea', null); + expect(obj).to.have.property('interactive', false); + expect(obj).to.have.property('renderable', false); + expect(obj).to.have.property('stage', null); + }); + + it('Gets child index', function() { + var container = new PIXI.DisplayObjectContainer(); + var children = []; + for (var i = 0; i < 10; i++) { + var child = new PIXI.DisplayObject(); + children.push(child); + container.addChild(child); + } + + for (i = 0; i < children.length; i++) { + expect(i).to.eql(container.getChildIndex(children[i])); + } + }); + + it('throws error when trying to get index of not a child', function() { + var container = new PIXI.DisplayObjectContainer(); + var child = new PIXI.DisplayObject(); + + expect(function() { container.getChildIndex(child); }).to.throw(); + }); + + it('Sets child index', function() { + var container = new PIXI.DisplayObjectContainer(); + var children = []; + + for (var i = 0; i < 10; i++) { + var child = new PIXI.DisplayObject(); + children.push(child); + container.addChild(child); + } + children.reverse(); + + for (i = 0; i < children.length; i++) { + container.setChildIndex(children[i], i); + expect(i).to.eql(container.getChildIndex(children[i])); + } + }); + + it('throws error when trying to set incorect index', function() { + var container = new PIXI.DisplayObjectContainer(); + var child = new PIXI.DisplayObject(); + container.addChild(child); + + expect(function() { container.setChildIndex(child, -1); }).to.throw(); + expect(function() { container.setChildIndex(child, 1); }).to.throw(); + }); +}); diff --git a/test/unit/pixi-v2/display/MovieClip.js b/test/unit/pixi-v2/display/MovieClip.js new file mode 100644 index 0000000..f3c6c6a --- /dev/null +++ b/test/unit/pixi-v2/display/MovieClip.js @@ -0,0 +1,33 @@ +describe('pixi/display/MovieClip', function () { + 'use strict'; + + var expect = chai.expect; + var MovieClip = PIXI.MovieClip; + var Texture = PIXI.Texture; + + it('Module exists', function () { + expect(MovieClip).to.be.a('function'); + }); + + it('Confirm new instance', function (done) { + var texture = Texture.fromImage('/base/test/textures/SpriteSheet-Explosion.png'); + var obj = new MovieClip([texture]); + + pixi_display_Sprite_confirmNew(obj, done); + + expect(obj).to.be.an.instanceof(MovieClip); + expect(obj).to.respondTo('stop'); + expect(obj).to.respondTo('play'); + expect(obj).to.respondTo('gotoAndStop'); + expect(obj).to.respondTo('gotoAndPlay'); + expect(obj).to.respondTo('updateTransform'); + + expect(obj).to.have.deep.property('textures.length', 1); + expect(obj).to.have.deep.property('textures[0]', texture); + expect(obj).to.have.property('animationSpeed', 1); + expect(obj).to.have.property('loop', true); + expect(obj).to.have.property('onComplete', null); + expect(obj).to.have.property('currentFrame', 0); + expect(obj).to.have.property('playing', false); + }); +}); diff --git a/test/unit/pixi-v2/display/Sprite.js b/test/unit/pixi-v2/display/Sprite.js new file mode 100644 index 0000000..30c8076 --- /dev/null +++ b/test/unit/pixi-v2/display/Sprite.js @@ -0,0 +1,28 @@ +describe('pixi/display/Sprite', function () { + 'use strict'; + + var expect = chai.expect; + var Sprite = PIXI.Sprite; + var Texture = PIXI.Texture; + + it('Module exists', function () { + expect(Sprite).to.be.a('function'); + expect(PIXI).to.have.deep.property('blendModes.NORMAL', 0); + expect(PIXI).to.have.deep.property('blendModes.ADD', 1); + expect(PIXI).to.have.deep.property('blendModes.MULTIPLY', 2); + expect(PIXI).to.have.deep.property('blendModes.SCREEN', 3); + }); + + + it('Members exist', function () { + expect(Sprite).itself.to.respondTo('fromImage'); + expect(Sprite).itself.to.respondTo('fromFrame'); + }); + + it('Confirm new instance', function (done) { + var texture = Texture.fromImage('/base/test/textures/SpriteSheet-Aliens.png'); + var obj = new Sprite(texture); + + pixi_display_Sprite_confirmNew(obj, done); + }); +}); diff --git a/test/unit/pixi-v2/display/Stage.js b/test/unit/pixi-v2/display/Stage.js new file mode 100644 index 0000000..6974c2e --- /dev/null +++ b/test/unit/pixi-v2/display/Stage.js @@ -0,0 +1,49 @@ +describe('pixi/display/Stage', function () { + 'use strict'; + + var expect = chai.expect; + var Stage = PIXI.Stage; + var InteractionManager = PIXI.InteractionManager; + var Rectangle = PIXI.Rectangle; + + it('Module exists', function () { + expect(Stage).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Stage(null, true); + + pixi_display_DisplayObjectContainer_confirmNew(obj); + + expect(obj).to.be.an.instanceof(Stage); + expect(obj).to.respondTo('updateTransform'); + expect(obj).to.respondTo('setBackgroundColor'); + expect(obj).to.respondTo('getMousePosition'); + // FIXME: duplicate member in DisplayObject + pixi_core_Matrix_confirmNewMatrix(obj.worldTransform); + // FIXME: convert arg to bool in constructor + expect(obj).to.have.property('interactive', true); + + expect(obj).to.have.property('interactionManager') + .and.to.be.an.instanceof(InteractionManager) + .and.to.have.property('stage', obj); + + expect(obj).to.have.property('dirty', true); + + expect(obj).to.have.property('stage', obj); + + expect(obj).to.have.property('hitArea') + .and.to.be.an.instanceof(Rectangle); + pixi_core_Rectangle_confirm(obj.hitArea, 0, 0, 100000, 100000); + + expect(obj).to.have.property('backgroundColor', 0x000000); + expect(obj).to.have.deep.property('backgroundColorSplit.length', 3); + expect(obj).to.have.deep.property('backgroundColorSplit[0]', 0); + expect(obj).to.have.deep.property('backgroundColorSplit[1]', 0); + expect(obj).to.have.deep.property('backgroundColorSplit[2]', 0); + expect(obj).to.have.property('backgroundColorString', '#000000'); + + + expect(obj).to.have.property('worldVisible', true); + }); +}); diff --git a/test/unit/pixi-v2/extras/Rope.js b/test/unit/pixi-v2/extras/Rope.js new file mode 100644 index 0000000..05885ac --- /dev/null +++ b/test/unit/pixi-v2/extras/Rope.js @@ -0,0 +1,31 @@ +describe('pixi/extras/Rope', function () { + 'use strict'; + + var expect = chai.expect; + var Rope = PIXI.Rope; + var Texture = PIXI.Texture; + var Point = PIXI.Point; + + it('Module exists', function () { + expect(Rope).to.be.a('function'); + }); + + it('Confirm new instance', function () { + + var texture = Texture.fromImage('/base/test/textures/bunny.png'); + + // TODO-Alvin + // Same as Strip + + // var obj = new Rope(texture, [new Point(), new Point(5, 10), new Point(10, 20)]); + + // pixi_extras_Strip_confirmNew(obj); + + // expect(obj).to.be.an.instanceof(Rope); + // expect(obj).to.respondTo('refresh'); + // expect(obj).to.respondTo('updateTransform'); + // expect(obj).to.respondTo('setTexture'); + + // TODO: Test properties + }); +}); diff --git a/test/unit/pixi-v2/extras/Spine.js b/test/unit/pixi-v2/extras/Spine.js new file mode 100644 index 0000000..0708bc0 --- /dev/null +++ b/test/unit/pixi-v2/extras/Spine.js @@ -0,0 +1,10 @@ +describe('pixi/extras/Spine', function () { + 'use strict'; + + var expect = chai.expect; + var Spine = PIXI.Spine; + + it('Module exists', function () { + expect(Spine).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/extras/Strip.js b/test/unit/pixi-v2/extras/Strip.js new file mode 100644 index 0000000..230af90 --- /dev/null +++ b/test/unit/pixi-v2/extras/Strip.js @@ -0,0 +1,26 @@ +describe('pixi/extras/Strip', function () { + 'use strict'; + + var expect = chai.expect; + var Strip = PIXI.Strip; + var Texture = PIXI.Texture; + + it('Module exists', function () { + expect(Strip).to.be.a('function'); + }); + + it('Confirm new instance', function () { + + + // TODO-Alvin + // We tweaked it to make it pass the tests, but the whole strip class needs + // to be re-coded + + var texture = Texture.fromImage('/base/test/textures/bunny.png'); + + // var obj = new Strip(texture, 20, 10000); + + + // pixi_extras_Strip_confirmNew(obj); + }); +}); diff --git a/test/unit/pixi-v2/extras/TilingSprite.js b/test/unit/pixi-v2/extras/TilingSprite.js new file mode 100644 index 0000000..56aea14 --- /dev/null +++ b/test/unit/pixi-v2/extras/TilingSprite.js @@ -0,0 +1,24 @@ +describe('pixi/extras/TilingSprite', function () { + 'use strict'; + + var expect = chai.expect; + var TilingSprite = PIXI.TilingSprite; + var Texture = PIXI.Texture; + + it('Module exists', function () { + expect(TilingSprite).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var texture = Texture.fromImage('/base/test/textures/bunny.png'); + var obj = new TilingSprite(texture, 6000, 12000); + + pixi_display_DisplayObjectContainer_confirmNew(obj); + + expect(obj).to.be.an.instanceof(TilingSprite); + expect(obj).to.respondTo('setTexture'); + expect(obj).to.respondTo('onTextureUpdate'); + + // TODO: Test properties + }); +}); diff --git a/test/unit/pixi-v2/filters/FilterBlock.js b/test/unit/pixi-v2/filters/FilterBlock.js new file mode 100644 index 0000000..870cec0 --- /dev/null +++ b/test/unit/pixi-v2/filters/FilterBlock.js @@ -0,0 +1,10 @@ +describe('pixi/filters/FilterBlock', function () { + 'use strict'; + + var expect = chai.expect; + var FilterBlock = PIXI.FilterBlock; + + it('Module exists', function () { + expect(FilterBlock).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/AssetLoader.js b/test/unit/pixi-v2/loaders/AssetLoader.js new file mode 100644 index 0000000..a0aa0b5 --- /dev/null +++ b/test/unit/pixi-v2/loaders/AssetLoader.js @@ -0,0 +1,10 @@ +describe('pixi/loaders/AssetLoader', function () { + 'use strict'; + + var expect = chai.expect; + var AssetLoader = PIXI.AssetLoader; + + it('Module exists', function () { + expect(AssetLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/BitmapFontLoader.js b/test/unit/pixi-v2/loaders/BitmapFontLoader.js new file mode 100644 index 0000000..046f018 --- /dev/null +++ b/test/unit/pixi-v2/loaders/BitmapFontLoader.js @@ -0,0 +1,9 @@ +describe('pixi/loaders/BitmapFontLoader', function () { + 'use strict'; + + var expect = chai.expect; + + it('Module exists', function () { + expect(PIXI.BitmapFontLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/ImageLoader.js b/test/unit/pixi-v2/loaders/ImageLoader.js new file mode 100644 index 0000000..8b1f556 --- /dev/null +++ b/test/unit/pixi-v2/loaders/ImageLoader.js @@ -0,0 +1,10 @@ +describe('pixi/loaders/ImageLoader', function () { + 'use strict'; + + var expect = chai.expect; + var ImageLoader = PIXI.ImageLoader; + + it('Module exists', function () { + expect(ImageLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/JsonLoader.js b/test/unit/pixi-v2/loaders/JsonLoader.js new file mode 100644 index 0000000..c577e83 --- /dev/null +++ b/test/unit/pixi-v2/loaders/JsonLoader.js @@ -0,0 +1,10 @@ +describe('pixi/loaders/JsonLoader', function () { + 'use strict'; + + var expect = chai.expect; + var JsonLoader = PIXI.JsonLoader; + + it('Module exists', function () { + expect(JsonLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/SpineLoader.js b/test/unit/pixi-v2/loaders/SpineLoader.js new file mode 100644 index 0000000..fdcc0b8 --- /dev/null +++ b/test/unit/pixi-v2/loaders/SpineLoader.js @@ -0,0 +1,10 @@ +describe('pixi/loaders/SpineLoader', function () { + 'use strict'; + + var expect = chai.expect; + var SpineLoader = PIXI.SpineLoader; + + it('Module exists', function () { + expect(SpineLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/SpriteSheetLoader.js b/test/unit/pixi-v2/loaders/SpriteSheetLoader.js new file mode 100644 index 0000000..57beb27 --- /dev/null +++ b/test/unit/pixi-v2/loaders/SpriteSheetLoader.js @@ -0,0 +1,10 @@ +describe('pixi/loaders/SpriteSheetLoader', function () { + 'use strict'; + + var expect = chai.expect; + var SpriteSheetLoader = PIXI.SpriteSheetLoader; + + it('Module exists', function () { + expect(SpriteSheetLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/primitives/Graphics.js b/test/unit/pixi-v2/primitives/Graphics.js new file mode 100644 index 0000000..f3849eb --- /dev/null +++ b/test/unit/pixi-v2/primitives/Graphics.js @@ -0,0 +1,44 @@ +describe('pixi/primitives/Graphics', function () { + 'use strict'; + + var expect = chai.expect; + var Graphics = PIXI.Graphics; + + it('Module exists', function () { + expect(Graphics).to.be.a('function'); + + expect(Graphics).itself.to.have.property('POLY', 0); + expect(Graphics).itself.to.have.property('RECT', 1); + expect(Graphics).itself.to.have.property('CIRC', 2); + expect(Graphics).itself.to.have.property('ELIP', 3); + expect(Graphics).itself.to.have.property('RREC', 4); + }); + + it('Confirm new instance', function () { + var obj = new Graphics(); + + pixi_display_DisplayObjectContainer_confirmNew(obj); + + expect(obj).to.be.an.instanceof(Graphics); + expect(obj).to.respondTo('lineStyle'); + expect(obj).to.respondTo('lineStyle'); + expect(obj).to.respondTo('moveTo'); + expect(obj).to.respondTo('lineTo'); + expect(obj).to.respondTo('beginFill'); + expect(obj).to.respondTo('endFill'); + expect(obj).to.respondTo('drawRect'); + // expect(obj).to.respondTo('drawRoundedRect'); + expect(obj).to.respondTo('drawCircle'); + expect(obj).to.respondTo('drawEllipse'); + expect(obj).to.respondTo('clear'); + + expect(obj).to.have.property('renderable', true); + expect(obj).to.have.property('fillAlpha', 1); + expect(obj).to.have.property('lineWidth', 0); + expect(obj).to.have.property('width', 0); + expect(obj).to.have.property('height', 0); + expect(obj).to.have.property('lineColor', 0); + expect(obj).to.have.deep.property('graphicsData.length', 0); + // expect(obj).to.have.deep.property('currentPath.points.length', 0); + }); +}); diff --git a/test/unit/pixi-v2/renderers/canvas/CanvasGraphics.js b/test/unit/pixi-v2/renderers/canvas/CanvasGraphics.js new file mode 100644 index 0000000..8f44472 --- /dev/null +++ b/test/unit/pixi-v2/renderers/canvas/CanvasGraphics.js @@ -0,0 +1,15 @@ +describe('renders/canvas/CanvasGraphics', function () { + 'use strict'; + + var expect = chai.expect; + var CanvasGraphics = PIXI.CanvasGraphics; + + it('Module exists', function () { + expect(CanvasGraphics).to.be.a('function'); + }); + + it('Members exist', function () { + expect(CanvasGraphics).itself.to.respondTo('renderGraphics'); + expect(CanvasGraphics).itself.to.respondTo('renderGraphicsMask'); + }); +}); diff --git a/test/unit/pixi-v2/renderers/canvas/CanvasRenderer.js b/test/unit/pixi-v2/renderers/canvas/CanvasRenderer.js new file mode 100644 index 0000000..1646444 --- /dev/null +++ b/test/unit/pixi-v2/renderers/canvas/CanvasRenderer.js @@ -0,0 +1,36 @@ +describe('renderers/canvas/CanvasRenderer', function () { + 'use strict'; + + var expect = chai.expect; + var CanvasRenderer = PIXI.CanvasRenderer; + + it('Module exists', function () { + expect(CanvasRenderer).to.be.a('function'); + }); + + describe('.autoResize', function () { + it('Should automatically resize view if enabled', function () { + var renderer = new CanvasRenderer(200, 200, { + autoResize: true + }); + + expect(renderer.view.style.width).to.equal('200px'); + }); + + it('Should not automatically resize view if disabled', function () { + var renderer = new CanvasRenderer(200, 200, { + autoResize: false + }); + + expect(renderer.view.style.width).to.equal(''); + }); + + it('Should not automatically resize view if not specified', function () { + var renderer = new CanvasRenderer(200, 200, { + resolution: 2 + }); + + expect(renderer.view.style.width).to.equal(''); + }); + }); +}); diff --git a/test/unit/pixi-v2/renderers/webgl/WebGLGraphics.js b/test/unit/pixi-v2/renderers/webgl/WebGLGraphics.js new file mode 100644 index 0000000..5867b28 --- /dev/null +++ b/test/unit/pixi-v2/renderers/webgl/WebGLGraphics.js @@ -0,0 +1,20 @@ +describe('renderers/wegbl/WebGLGraphics', function () { + 'use strict'; + + var expect = chai.expect; + var WebGLGraphics = PIXI.WebGLGraphics; + + it('Module exists', function () { + expect(WebGLGraphics).to.be.a('function'); + }); + + it('Members exist', function () { + expect(WebGLGraphics).itself.to.respondTo('renderGraphics'); + expect(WebGLGraphics).itself.to.respondTo('updateGraphics'); + expect(WebGLGraphics).itself.to.respondTo('buildRectangle'); + expect(WebGLGraphics).itself.to.respondTo('buildRoundedRectangle'); + expect(WebGLGraphics).itself.to.respondTo('buildCircle'); + expect(WebGLGraphics).itself.to.respondTo('buildLine'); + expect(WebGLGraphics).itself.to.respondTo('buildPoly'); + }); +}); diff --git a/test/unit/pixi-v2/renderers/webgl/WebGLRenderer.js b/test/unit/pixi-v2/renderers/webgl/WebGLRenderer.js new file mode 100644 index 0000000..1680a80 --- /dev/null +++ b/test/unit/pixi-v2/renderers/webgl/WebGLRenderer.js @@ -0,0 +1,49 @@ +describe('renderers/webgl/WebGLRenderer', function () { + 'use strict'; + + var expect = chai.expect; + var WebGLRenderer = PIXI.WebGLRenderer; + + it('Module exists', function () { + expect(WebGLRenderer).to.be.a('function'); + }); + + // Skip tests if WebGL is not available (WebGL not supported in Travis CI) + try { + var renderer = new WebGLRenderer(400, 300, {}); + renderer.destroy(); + } catch (error) { + return; + } + + it('Destroy renderer', function () { + var renderer = new WebGLRenderer(400, 300, {}); + renderer.destroy(); + }); + + describe('.autoResize', function () { + it('Should automatically resize view if enabled', function () { + var renderer = new WebGLRenderer(200, 200, { + autoResize: true + }); + + expect(renderer.view.style.width).to.equal('200px'); + }); + + it('Should not automatically resize view if disabled', function () { + var renderer = new WebGLRenderer(200, 200, { + autoResize: false + }); + + expect(renderer.view.style.width).to.equal(''); + }); + + it('Should not automatically resize view if not specified', function () { + var renderer = new WebGLRenderer(200, 200, { + resolution: 2 + }); + + expect(renderer.view.style.width).to.equal(''); + }); + }); +}); diff --git a/test/unit/pixi-v2/InteractionManager.js b/test/unit/pixi-v2/InteractionManager.js new file mode 100644 index 0000000..ed3001f --- /dev/null +++ b/test/unit/pixi-v2/InteractionManager.js @@ -0,0 +1,10 @@ +describe('pixi/InteractionManager', function () { + 'use strict'; + + var expect = chai.expect; + var InteractionManager = PIXI.InteractionManager; + + it('Module exists', function () { + expect(InteractionManager).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/Pixi.js b/test/unit/pixi-v2/Pixi.js new file mode 100644 index 0000000..27debc1 --- /dev/null +++ b/test/unit/pixi-v2/Pixi.js @@ -0,0 +1,9 @@ +describe('pixi/Pixi', function () { + 'use strict'; + + var expect = chai.expect; + + it('Module exists', function () { + expect(global).to.have.property('PIXI').and.to.be.an('object'); + }); +}); diff --git a/test/unit/pixi-v2/core/Circle.js b/test/unit/pixi-v2/core/Circle.js new file mode 100644 index 0000000..fbcfa17 --- /dev/null +++ b/test/unit/pixi-v2/core/Circle.js @@ -0,0 +1,21 @@ +describe('pixi/core/Circle', function () { + 'use strict'; + + var expect = chai.expect; + var Circle = PIXI.Circle; + + it('Module exists', function () { + expect(Circle).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Circle(); + pixi_core_Circle_confirmNewCircle(obj); + }); + + it("getBounds should return Rectangle that bounds the circle", function() { + var obj = new Circle(100, 250, 50); + var bounds = obj.getBounds(); + pixi_core_Circle_isBoundedByRectangle(obj, bounds); + }); +}); diff --git a/test/unit/pixi-v2/core/Ellipse.js b/test/unit/pixi-v2/core/Ellipse.js new file mode 100644 index 0000000..026b56f --- /dev/null +++ b/test/unit/pixi-v2/core/Ellipse.js @@ -0,0 +1,24 @@ +describe('pixi/core/Ellipse', function () { + 'use strict'; + + var expect = chai.expect; + var Ellipse = PIXI.Ellipse; + + it('Module exists', function () { + expect(Ellipse).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Ellipse(); + + expect(obj).to.be.an.instanceof(Ellipse); + expect(obj).to.respondTo('clone'); + expect(obj).to.respondTo('contains'); + expect(obj).to.respondTo('getBounds'); + + expect(obj).to.have.property('x', 0); + expect(obj).to.have.property('y', 0); + expect(obj).to.have.property('width', 0); + expect(obj).to.have.property('height', 0); + }); +}); diff --git a/test/unit/pixi-v2/core/Matrix.js b/test/unit/pixi-v2/core/Matrix.js new file mode 100644 index 0000000..da75e2e --- /dev/null +++ b/test/unit/pixi-v2/core/Matrix.js @@ -0,0 +1,14 @@ +describe('pixi/core/Matrix', function () { + 'use strict'; + + var expect = chai.expect; + + it('Matrix exists', function () { + expect(PIXI.Matrix).to.be.an('function'); + }); + + it('Confirm new Matrix', function () { + var matrix = new PIXI.Matrix(); + pixi_core_Matrix_confirmNewMatrix(matrix); + }); +}); diff --git a/test/unit/pixi-v2/core/Point.js b/test/unit/pixi-v2/core/Point.js new file mode 100644 index 0000000..c4d5163 --- /dev/null +++ b/test/unit/pixi-v2/core/Point.js @@ -0,0 +1,15 @@ +describe('pixi/core/Point', function () { + 'use strict'; + + var expect = chai.expect; + var Point = PIXI.Point; + + it('Module exists', function () { + expect(Point).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Point(); + pixi_core_Point_confirm(obj, 0, 0); + }); +}); diff --git a/test/unit/pixi-v2/core/Polygon.js b/test/unit/pixi-v2/core/Polygon.js new file mode 100644 index 0000000..dc8c918 --- /dev/null +++ b/test/unit/pixi-v2/core/Polygon.js @@ -0,0 +1,20 @@ +describe('pixi/core/Polygon', function () { + 'use strict'; + + var expect = chai.expect; + var Polygon = PIXI.Polygon; + + it('Module exists', function () { + expect(Polygon).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Polygon(); + + expect(obj).to.be.an.instanceof(Polygon); + expect(obj).to.respondTo('clone'); + expect(obj).to.respondTo('contains'); + + expect(obj).to.have.deep.property('points.length', 0); + }); +}); diff --git a/test/unit/pixi-v2/core/Rectangle.js b/test/unit/pixi-v2/core/Rectangle.js new file mode 100644 index 0000000..d43316e --- /dev/null +++ b/test/unit/pixi-v2/core/Rectangle.js @@ -0,0 +1,15 @@ +describe('pixi/core/Rectangle', function () { + 'use strict'; + + var expect = chai.expect; + var Rectangle = PIXI.Rectangle; + + it('Module exists', function () { + expect(Rectangle).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var rect = new Rectangle(); + pixi_core_Rectangle_confirm(rect, 0, 0, 0, 0); + }); +}); diff --git a/test/unit/pixi-v2/display/DisplayObject.js b/test/unit/pixi-v2/display/DisplayObject.js new file mode 100644 index 0000000..044acf8 --- /dev/null +++ b/test/unit/pixi-v2/display/DisplayObject.js @@ -0,0 +1,21 @@ +describe('pixi/display/DisplayObject', function () { + 'use strict'; + + var expect = chai.expect; + var DisplayObject = PIXI.DisplayObject; + + it('Module exists', function () { + expect(DisplayObject).to.be.a('function'); + // expect(PIXI).to.have.property('visibleCount', 0); + }); + + it('Confirm new instance', function () { + var obj = new DisplayObject(); + + pixi_display_DisplayObject_confirmNew(obj); + expect(obj).to.have.property('hitArea', null); + expect(obj).to.have.property('interactive', false); + expect(obj).to.have.property('renderable', false); + expect(obj).to.have.property('stage', null); + }); +}); diff --git a/test/unit/pixi-v2/display/DisplayObjectContainer.js b/test/unit/pixi-v2/display/DisplayObjectContainer.js new file mode 100644 index 0000000..15a3376 --- /dev/null +++ b/test/unit/pixi-v2/display/DisplayObjectContainer.js @@ -0,0 +1,67 @@ +describe('pixi/display/DisplayObjectContainer', function () { + 'use strict'; + + var expect = chai.expect; + var DisplayObjectContainer = PIXI.DisplayObjectContainer; + + it('Module exists', function () { + expect(DisplayObjectContainer).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new DisplayObjectContainer(); + + pixi_display_DisplayObjectContainer_confirmNew(obj); + expect(obj).to.have.property('hitArea', null); + expect(obj).to.have.property('interactive', false); + expect(obj).to.have.property('renderable', false); + expect(obj).to.have.property('stage', null); + }); + + it('Gets child index', function() { + var container = new PIXI.DisplayObjectContainer(); + var children = []; + for (var i = 0; i < 10; i++) { + var child = new PIXI.DisplayObject(); + children.push(child); + container.addChild(child); + } + + for (i = 0; i < children.length; i++) { + expect(i).to.eql(container.getChildIndex(children[i])); + } + }); + + it('throws error when trying to get index of not a child', function() { + var container = new PIXI.DisplayObjectContainer(); + var child = new PIXI.DisplayObject(); + + expect(function() { container.getChildIndex(child); }).to.throw(); + }); + + it('Sets child index', function() { + var container = new PIXI.DisplayObjectContainer(); + var children = []; + + for (var i = 0; i < 10; i++) { + var child = new PIXI.DisplayObject(); + children.push(child); + container.addChild(child); + } + children.reverse(); + + for (i = 0; i < children.length; i++) { + container.setChildIndex(children[i], i); + expect(i).to.eql(container.getChildIndex(children[i])); + } + }); + + it('throws error when trying to set incorect index', function() { + var container = new PIXI.DisplayObjectContainer(); + var child = new PIXI.DisplayObject(); + container.addChild(child); + + expect(function() { container.setChildIndex(child, -1); }).to.throw(); + expect(function() { container.setChildIndex(child, 1); }).to.throw(); + }); +}); diff --git a/test/unit/pixi-v2/display/MovieClip.js b/test/unit/pixi-v2/display/MovieClip.js new file mode 100644 index 0000000..f3c6c6a --- /dev/null +++ b/test/unit/pixi-v2/display/MovieClip.js @@ -0,0 +1,33 @@ +describe('pixi/display/MovieClip', function () { + 'use strict'; + + var expect = chai.expect; + var MovieClip = PIXI.MovieClip; + var Texture = PIXI.Texture; + + it('Module exists', function () { + expect(MovieClip).to.be.a('function'); + }); + + it('Confirm new instance', function (done) { + var texture = Texture.fromImage('/base/test/textures/SpriteSheet-Explosion.png'); + var obj = new MovieClip([texture]); + + pixi_display_Sprite_confirmNew(obj, done); + + expect(obj).to.be.an.instanceof(MovieClip); + expect(obj).to.respondTo('stop'); + expect(obj).to.respondTo('play'); + expect(obj).to.respondTo('gotoAndStop'); + expect(obj).to.respondTo('gotoAndPlay'); + expect(obj).to.respondTo('updateTransform'); + + expect(obj).to.have.deep.property('textures.length', 1); + expect(obj).to.have.deep.property('textures[0]', texture); + expect(obj).to.have.property('animationSpeed', 1); + expect(obj).to.have.property('loop', true); + expect(obj).to.have.property('onComplete', null); + expect(obj).to.have.property('currentFrame', 0); + expect(obj).to.have.property('playing', false); + }); +}); diff --git a/test/unit/pixi-v2/display/Sprite.js b/test/unit/pixi-v2/display/Sprite.js new file mode 100644 index 0000000..30c8076 --- /dev/null +++ b/test/unit/pixi-v2/display/Sprite.js @@ -0,0 +1,28 @@ +describe('pixi/display/Sprite', function () { + 'use strict'; + + var expect = chai.expect; + var Sprite = PIXI.Sprite; + var Texture = PIXI.Texture; + + it('Module exists', function () { + expect(Sprite).to.be.a('function'); + expect(PIXI).to.have.deep.property('blendModes.NORMAL', 0); + expect(PIXI).to.have.deep.property('blendModes.ADD', 1); + expect(PIXI).to.have.deep.property('blendModes.MULTIPLY', 2); + expect(PIXI).to.have.deep.property('blendModes.SCREEN', 3); + }); + + + it('Members exist', function () { + expect(Sprite).itself.to.respondTo('fromImage'); + expect(Sprite).itself.to.respondTo('fromFrame'); + }); + + it('Confirm new instance', function (done) { + var texture = Texture.fromImage('/base/test/textures/SpriteSheet-Aliens.png'); + var obj = new Sprite(texture); + + pixi_display_Sprite_confirmNew(obj, done); + }); +}); diff --git a/test/unit/pixi-v2/display/Stage.js b/test/unit/pixi-v2/display/Stage.js new file mode 100644 index 0000000..6974c2e --- /dev/null +++ b/test/unit/pixi-v2/display/Stage.js @@ -0,0 +1,49 @@ +describe('pixi/display/Stage', function () { + 'use strict'; + + var expect = chai.expect; + var Stage = PIXI.Stage; + var InteractionManager = PIXI.InteractionManager; + var Rectangle = PIXI.Rectangle; + + it('Module exists', function () { + expect(Stage).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Stage(null, true); + + pixi_display_DisplayObjectContainer_confirmNew(obj); + + expect(obj).to.be.an.instanceof(Stage); + expect(obj).to.respondTo('updateTransform'); + expect(obj).to.respondTo('setBackgroundColor'); + expect(obj).to.respondTo('getMousePosition'); + // FIXME: duplicate member in DisplayObject + pixi_core_Matrix_confirmNewMatrix(obj.worldTransform); + // FIXME: convert arg to bool in constructor + expect(obj).to.have.property('interactive', true); + + expect(obj).to.have.property('interactionManager') + .and.to.be.an.instanceof(InteractionManager) + .and.to.have.property('stage', obj); + + expect(obj).to.have.property('dirty', true); + + expect(obj).to.have.property('stage', obj); + + expect(obj).to.have.property('hitArea') + .and.to.be.an.instanceof(Rectangle); + pixi_core_Rectangle_confirm(obj.hitArea, 0, 0, 100000, 100000); + + expect(obj).to.have.property('backgroundColor', 0x000000); + expect(obj).to.have.deep.property('backgroundColorSplit.length', 3); + expect(obj).to.have.deep.property('backgroundColorSplit[0]', 0); + expect(obj).to.have.deep.property('backgroundColorSplit[1]', 0); + expect(obj).to.have.deep.property('backgroundColorSplit[2]', 0); + expect(obj).to.have.property('backgroundColorString', '#000000'); + + + expect(obj).to.have.property('worldVisible', true); + }); +}); diff --git a/test/unit/pixi-v2/extras/Rope.js b/test/unit/pixi-v2/extras/Rope.js new file mode 100644 index 0000000..05885ac --- /dev/null +++ b/test/unit/pixi-v2/extras/Rope.js @@ -0,0 +1,31 @@ +describe('pixi/extras/Rope', function () { + 'use strict'; + + var expect = chai.expect; + var Rope = PIXI.Rope; + var Texture = PIXI.Texture; + var Point = PIXI.Point; + + it('Module exists', function () { + expect(Rope).to.be.a('function'); + }); + + it('Confirm new instance', function () { + + var texture = Texture.fromImage('/base/test/textures/bunny.png'); + + // TODO-Alvin + // Same as Strip + + // var obj = new Rope(texture, [new Point(), new Point(5, 10), new Point(10, 20)]); + + // pixi_extras_Strip_confirmNew(obj); + + // expect(obj).to.be.an.instanceof(Rope); + // expect(obj).to.respondTo('refresh'); + // expect(obj).to.respondTo('updateTransform'); + // expect(obj).to.respondTo('setTexture'); + + // TODO: Test properties + }); +}); diff --git a/test/unit/pixi-v2/extras/Spine.js b/test/unit/pixi-v2/extras/Spine.js new file mode 100644 index 0000000..0708bc0 --- /dev/null +++ b/test/unit/pixi-v2/extras/Spine.js @@ -0,0 +1,10 @@ +describe('pixi/extras/Spine', function () { + 'use strict'; + + var expect = chai.expect; + var Spine = PIXI.Spine; + + it('Module exists', function () { + expect(Spine).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/extras/Strip.js b/test/unit/pixi-v2/extras/Strip.js new file mode 100644 index 0000000..230af90 --- /dev/null +++ b/test/unit/pixi-v2/extras/Strip.js @@ -0,0 +1,26 @@ +describe('pixi/extras/Strip', function () { + 'use strict'; + + var expect = chai.expect; + var Strip = PIXI.Strip; + var Texture = PIXI.Texture; + + it('Module exists', function () { + expect(Strip).to.be.a('function'); + }); + + it('Confirm new instance', function () { + + + // TODO-Alvin + // We tweaked it to make it pass the tests, but the whole strip class needs + // to be re-coded + + var texture = Texture.fromImage('/base/test/textures/bunny.png'); + + // var obj = new Strip(texture, 20, 10000); + + + // pixi_extras_Strip_confirmNew(obj); + }); +}); diff --git a/test/unit/pixi-v2/extras/TilingSprite.js b/test/unit/pixi-v2/extras/TilingSprite.js new file mode 100644 index 0000000..56aea14 --- /dev/null +++ b/test/unit/pixi-v2/extras/TilingSprite.js @@ -0,0 +1,24 @@ +describe('pixi/extras/TilingSprite', function () { + 'use strict'; + + var expect = chai.expect; + var TilingSprite = PIXI.TilingSprite; + var Texture = PIXI.Texture; + + it('Module exists', function () { + expect(TilingSprite).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var texture = Texture.fromImage('/base/test/textures/bunny.png'); + var obj = new TilingSprite(texture, 6000, 12000); + + pixi_display_DisplayObjectContainer_confirmNew(obj); + + expect(obj).to.be.an.instanceof(TilingSprite); + expect(obj).to.respondTo('setTexture'); + expect(obj).to.respondTo('onTextureUpdate'); + + // TODO: Test properties + }); +}); diff --git a/test/unit/pixi-v2/filters/FilterBlock.js b/test/unit/pixi-v2/filters/FilterBlock.js new file mode 100644 index 0000000..870cec0 --- /dev/null +++ b/test/unit/pixi-v2/filters/FilterBlock.js @@ -0,0 +1,10 @@ +describe('pixi/filters/FilterBlock', function () { + 'use strict'; + + var expect = chai.expect; + var FilterBlock = PIXI.FilterBlock; + + it('Module exists', function () { + expect(FilterBlock).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/AssetLoader.js b/test/unit/pixi-v2/loaders/AssetLoader.js new file mode 100644 index 0000000..a0aa0b5 --- /dev/null +++ b/test/unit/pixi-v2/loaders/AssetLoader.js @@ -0,0 +1,10 @@ +describe('pixi/loaders/AssetLoader', function () { + 'use strict'; + + var expect = chai.expect; + var AssetLoader = PIXI.AssetLoader; + + it('Module exists', function () { + expect(AssetLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/BitmapFontLoader.js b/test/unit/pixi-v2/loaders/BitmapFontLoader.js new file mode 100644 index 0000000..046f018 --- /dev/null +++ b/test/unit/pixi-v2/loaders/BitmapFontLoader.js @@ -0,0 +1,9 @@ +describe('pixi/loaders/BitmapFontLoader', function () { + 'use strict'; + + var expect = chai.expect; + + it('Module exists', function () { + expect(PIXI.BitmapFontLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/ImageLoader.js b/test/unit/pixi-v2/loaders/ImageLoader.js new file mode 100644 index 0000000..8b1f556 --- /dev/null +++ b/test/unit/pixi-v2/loaders/ImageLoader.js @@ -0,0 +1,10 @@ +describe('pixi/loaders/ImageLoader', function () { + 'use strict'; + + var expect = chai.expect; + var ImageLoader = PIXI.ImageLoader; + + it('Module exists', function () { + expect(ImageLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/JsonLoader.js b/test/unit/pixi-v2/loaders/JsonLoader.js new file mode 100644 index 0000000..c577e83 --- /dev/null +++ b/test/unit/pixi-v2/loaders/JsonLoader.js @@ -0,0 +1,10 @@ +describe('pixi/loaders/JsonLoader', function () { + 'use strict'; + + var expect = chai.expect; + var JsonLoader = PIXI.JsonLoader; + + it('Module exists', function () { + expect(JsonLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/SpineLoader.js b/test/unit/pixi-v2/loaders/SpineLoader.js new file mode 100644 index 0000000..fdcc0b8 --- /dev/null +++ b/test/unit/pixi-v2/loaders/SpineLoader.js @@ -0,0 +1,10 @@ +describe('pixi/loaders/SpineLoader', function () { + 'use strict'; + + var expect = chai.expect; + var SpineLoader = PIXI.SpineLoader; + + it('Module exists', function () { + expect(SpineLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/SpriteSheetLoader.js b/test/unit/pixi-v2/loaders/SpriteSheetLoader.js new file mode 100644 index 0000000..57beb27 --- /dev/null +++ b/test/unit/pixi-v2/loaders/SpriteSheetLoader.js @@ -0,0 +1,10 @@ +describe('pixi/loaders/SpriteSheetLoader', function () { + 'use strict'; + + var expect = chai.expect; + var SpriteSheetLoader = PIXI.SpriteSheetLoader; + + it('Module exists', function () { + expect(SpriteSheetLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/primitives/Graphics.js b/test/unit/pixi-v2/primitives/Graphics.js new file mode 100644 index 0000000..f3849eb --- /dev/null +++ b/test/unit/pixi-v2/primitives/Graphics.js @@ -0,0 +1,44 @@ +describe('pixi/primitives/Graphics', function () { + 'use strict'; + + var expect = chai.expect; + var Graphics = PIXI.Graphics; + + it('Module exists', function () { + expect(Graphics).to.be.a('function'); + + expect(Graphics).itself.to.have.property('POLY', 0); + expect(Graphics).itself.to.have.property('RECT', 1); + expect(Graphics).itself.to.have.property('CIRC', 2); + expect(Graphics).itself.to.have.property('ELIP', 3); + expect(Graphics).itself.to.have.property('RREC', 4); + }); + + it('Confirm new instance', function () { + var obj = new Graphics(); + + pixi_display_DisplayObjectContainer_confirmNew(obj); + + expect(obj).to.be.an.instanceof(Graphics); + expect(obj).to.respondTo('lineStyle'); + expect(obj).to.respondTo('lineStyle'); + expect(obj).to.respondTo('moveTo'); + expect(obj).to.respondTo('lineTo'); + expect(obj).to.respondTo('beginFill'); + expect(obj).to.respondTo('endFill'); + expect(obj).to.respondTo('drawRect'); + // expect(obj).to.respondTo('drawRoundedRect'); + expect(obj).to.respondTo('drawCircle'); + expect(obj).to.respondTo('drawEllipse'); + expect(obj).to.respondTo('clear'); + + expect(obj).to.have.property('renderable', true); + expect(obj).to.have.property('fillAlpha', 1); + expect(obj).to.have.property('lineWidth', 0); + expect(obj).to.have.property('width', 0); + expect(obj).to.have.property('height', 0); + expect(obj).to.have.property('lineColor', 0); + expect(obj).to.have.deep.property('graphicsData.length', 0); + // expect(obj).to.have.deep.property('currentPath.points.length', 0); + }); +}); diff --git a/test/unit/pixi-v2/renderers/canvas/CanvasGraphics.js b/test/unit/pixi-v2/renderers/canvas/CanvasGraphics.js new file mode 100644 index 0000000..8f44472 --- /dev/null +++ b/test/unit/pixi-v2/renderers/canvas/CanvasGraphics.js @@ -0,0 +1,15 @@ +describe('renders/canvas/CanvasGraphics', function () { + 'use strict'; + + var expect = chai.expect; + var CanvasGraphics = PIXI.CanvasGraphics; + + it('Module exists', function () { + expect(CanvasGraphics).to.be.a('function'); + }); + + it('Members exist', function () { + expect(CanvasGraphics).itself.to.respondTo('renderGraphics'); + expect(CanvasGraphics).itself.to.respondTo('renderGraphicsMask'); + }); +}); diff --git a/test/unit/pixi-v2/renderers/canvas/CanvasRenderer.js b/test/unit/pixi-v2/renderers/canvas/CanvasRenderer.js new file mode 100644 index 0000000..1646444 --- /dev/null +++ b/test/unit/pixi-v2/renderers/canvas/CanvasRenderer.js @@ -0,0 +1,36 @@ +describe('renderers/canvas/CanvasRenderer', function () { + 'use strict'; + + var expect = chai.expect; + var CanvasRenderer = PIXI.CanvasRenderer; + + it('Module exists', function () { + expect(CanvasRenderer).to.be.a('function'); + }); + + describe('.autoResize', function () { + it('Should automatically resize view if enabled', function () { + var renderer = new CanvasRenderer(200, 200, { + autoResize: true + }); + + expect(renderer.view.style.width).to.equal('200px'); + }); + + it('Should not automatically resize view if disabled', function () { + var renderer = new CanvasRenderer(200, 200, { + autoResize: false + }); + + expect(renderer.view.style.width).to.equal(''); + }); + + it('Should not automatically resize view if not specified', function () { + var renderer = new CanvasRenderer(200, 200, { + resolution: 2 + }); + + expect(renderer.view.style.width).to.equal(''); + }); + }); +}); diff --git a/test/unit/pixi-v2/renderers/webgl/WebGLGraphics.js b/test/unit/pixi-v2/renderers/webgl/WebGLGraphics.js new file mode 100644 index 0000000..5867b28 --- /dev/null +++ b/test/unit/pixi-v2/renderers/webgl/WebGLGraphics.js @@ -0,0 +1,20 @@ +describe('renderers/wegbl/WebGLGraphics', function () { + 'use strict'; + + var expect = chai.expect; + var WebGLGraphics = PIXI.WebGLGraphics; + + it('Module exists', function () { + expect(WebGLGraphics).to.be.a('function'); + }); + + it('Members exist', function () { + expect(WebGLGraphics).itself.to.respondTo('renderGraphics'); + expect(WebGLGraphics).itself.to.respondTo('updateGraphics'); + expect(WebGLGraphics).itself.to.respondTo('buildRectangle'); + expect(WebGLGraphics).itself.to.respondTo('buildRoundedRectangle'); + expect(WebGLGraphics).itself.to.respondTo('buildCircle'); + expect(WebGLGraphics).itself.to.respondTo('buildLine'); + expect(WebGLGraphics).itself.to.respondTo('buildPoly'); + }); +}); diff --git a/test/unit/pixi-v2/renderers/webgl/WebGLRenderer.js b/test/unit/pixi-v2/renderers/webgl/WebGLRenderer.js new file mode 100644 index 0000000..1680a80 --- /dev/null +++ b/test/unit/pixi-v2/renderers/webgl/WebGLRenderer.js @@ -0,0 +1,49 @@ +describe('renderers/webgl/WebGLRenderer', function () { + 'use strict'; + + var expect = chai.expect; + var WebGLRenderer = PIXI.WebGLRenderer; + + it('Module exists', function () { + expect(WebGLRenderer).to.be.a('function'); + }); + + // Skip tests if WebGL is not available (WebGL not supported in Travis CI) + try { + var renderer = new WebGLRenderer(400, 300, {}); + renderer.destroy(); + } catch (error) { + return; + } + + it('Destroy renderer', function () { + var renderer = new WebGLRenderer(400, 300, {}); + renderer.destroy(); + }); + + describe('.autoResize', function () { + it('Should automatically resize view if enabled', function () { + var renderer = new WebGLRenderer(200, 200, { + autoResize: true + }); + + expect(renderer.view.style.width).to.equal('200px'); + }); + + it('Should not automatically resize view if disabled', function () { + var renderer = new WebGLRenderer(200, 200, { + autoResize: false + }); + + expect(renderer.view.style.width).to.equal(''); + }); + + it('Should not automatically resize view if not specified', function () { + var renderer = new WebGLRenderer(200, 200, { + resolution: 2 + }); + + expect(renderer.view.style.width).to.equal(''); + }); + }); +}); diff --git a/test/unit/pixi-v2/renderers/webgl/WebGLShaders.js b/test/unit/pixi-v2/renderers/webgl/WebGLShaders.js new file mode 100644 index 0000000..6e33e4f --- /dev/null +++ b/test/unit/pixi-v2/renderers/webgl/WebGLShaders.js @@ -0,0 +1,13 @@ +describe('renderers/webgl/WebGLShaders', function () { + 'use strict'; + + var expect = chai.expect; + + it('Module members exist', function () { + + expect(PIXI).to.respondTo('CompileVertexShader'); + expect(PIXI).to.respondTo('CompileFragmentShader'); + expect(PIXI).to.respondTo('_CompileShader'); + expect(PIXI).to.respondTo('compileProgram'); + }); +}); diff --git a/test/unit/pixi-v2/InteractionManager.js b/test/unit/pixi-v2/InteractionManager.js new file mode 100644 index 0000000..ed3001f --- /dev/null +++ b/test/unit/pixi-v2/InteractionManager.js @@ -0,0 +1,10 @@ +describe('pixi/InteractionManager', function () { + 'use strict'; + + var expect = chai.expect; + var InteractionManager = PIXI.InteractionManager; + + it('Module exists', function () { + expect(InteractionManager).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/Pixi.js b/test/unit/pixi-v2/Pixi.js new file mode 100644 index 0000000..27debc1 --- /dev/null +++ b/test/unit/pixi-v2/Pixi.js @@ -0,0 +1,9 @@ +describe('pixi/Pixi', function () { + 'use strict'; + + var expect = chai.expect; + + it('Module exists', function () { + expect(global).to.have.property('PIXI').and.to.be.an('object'); + }); +}); diff --git a/test/unit/pixi-v2/core/Circle.js b/test/unit/pixi-v2/core/Circle.js new file mode 100644 index 0000000..fbcfa17 --- /dev/null +++ b/test/unit/pixi-v2/core/Circle.js @@ -0,0 +1,21 @@ +describe('pixi/core/Circle', function () { + 'use strict'; + + var expect = chai.expect; + var Circle = PIXI.Circle; + + it('Module exists', function () { + expect(Circle).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Circle(); + pixi_core_Circle_confirmNewCircle(obj); + }); + + it("getBounds should return Rectangle that bounds the circle", function() { + var obj = new Circle(100, 250, 50); + var bounds = obj.getBounds(); + pixi_core_Circle_isBoundedByRectangle(obj, bounds); + }); +}); diff --git a/test/unit/pixi-v2/core/Ellipse.js b/test/unit/pixi-v2/core/Ellipse.js new file mode 100644 index 0000000..026b56f --- /dev/null +++ b/test/unit/pixi-v2/core/Ellipse.js @@ -0,0 +1,24 @@ +describe('pixi/core/Ellipse', function () { + 'use strict'; + + var expect = chai.expect; + var Ellipse = PIXI.Ellipse; + + it('Module exists', function () { + expect(Ellipse).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Ellipse(); + + expect(obj).to.be.an.instanceof(Ellipse); + expect(obj).to.respondTo('clone'); + expect(obj).to.respondTo('contains'); + expect(obj).to.respondTo('getBounds'); + + expect(obj).to.have.property('x', 0); + expect(obj).to.have.property('y', 0); + expect(obj).to.have.property('width', 0); + expect(obj).to.have.property('height', 0); + }); +}); diff --git a/test/unit/pixi-v2/core/Matrix.js b/test/unit/pixi-v2/core/Matrix.js new file mode 100644 index 0000000..da75e2e --- /dev/null +++ b/test/unit/pixi-v2/core/Matrix.js @@ -0,0 +1,14 @@ +describe('pixi/core/Matrix', function () { + 'use strict'; + + var expect = chai.expect; + + it('Matrix exists', function () { + expect(PIXI.Matrix).to.be.an('function'); + }); + + it('Confirm new Matrix', function () { + var matrix = new PIXI.Matrix(); + pixi_core_Matrix_confirmNewMatrix(matrix); + }); +}); diff --git a/test/unit/pixi-v2/core/Point.js b/test/unit/pixi-v2/core/Point.js new file mode 100644 index 0000000..c4d5163 --- /dev/null +++ b/test/unit/pixi-v2/core/Point.js @@ -0,0 +1,15 @@ +describe('pixi/core/Point', function () { + 'use strict'; + + var expect = chai.expect; + var Point = PIXI.Point; + + it('Module exists', function () { + expect(Point).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Point(); + pixi_core_Point_confirm(obj, 0, 0); + }); +}); diff --git a/test/unit/pixi-v2/core/Polygon.js b/test/unit/pixi-v2/core/Polygon.js new file mode 100644 index 0000000..dc8c918 --- /dev/null +++ b/test/unit/pixi-v2/core/Polygon.js @@ -0,0 +1,20 @@ +describe('pixi/core/Polygon', function () { + 'use strict'; + + var expect = chai.expect; + var Polygon = PIXI.Polygon; + + it('Module exists', function () { + expect(Polygon).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Polygon(); + + expect(obj).to.be.an.instanceof(Polygon); + expect(obj).to.respondTo('clone'); + expect(obj).to.respondTo('contains'); + + expect(obj).to.have.deep.property('points.length', 0); + }); +}); diff --git a/test/unit/pixi-v2/core/Rectangle.js b/test/unit/pixi-v2/core/Rectangle.js new file mode 100644 index 0000000..d43316e --- /dev/null +++ b/test/unit/pixi-v2/core/Rectangle.js @@ -0,0 +1,15 @@ +describe('pixi/core/Rectangle', function () { + 'use strict'; + + var expect = chai.expect; + var Rectangle = PIXI.Rectangle; + + it('Module exists', function () { + expect(Rectangle).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var rect = new Rectangle(); + pixi_core_Rectangle_confirm(rect, 0, 0, 0, 0); + }); +}); diff --git a/test/unit/pixi-v2/display/DisplayObject.js b/test/unit/pixi-v2/display/DisplayObject.js new file mode 100644 index 0000000..044acf8 --- /dev/null +++ b/test/unit/pixi-v2/display/DisplayObject.js @@ -0,0 +1,21 @@ +describe('pixi/display/DisplayObject', function () { + 'use strict'; + + var expect = chai.expect; + var DisplayObject = PIXI.DisplayObject; + + it('Module exists', function () { + expect(DisplayObject).to.be.a('function'); + // expect(PIXI).to.have.property('visibleCount', 0); + }); + + it('Confirm new instance', function () { + var obj = new DisplayObject(); + + pixi_display_DisplayObject_confirmNew(obj); + expect(obj).to.have.property('hitArea', null); + expect(obj).to.have.property('interactive', false); + expect(obj).to.have.property('renderable', false); + expect(obj).to.have.property('stage', null); + }); +}); diff --git a/test/unit/pixi-v2/display/DisplayObjectContainer.js b/test/unit/pixi-v2/display/DisplayObjectContainer.js new file mode 100644 index 0000000..15a3376 --- /dev/null +++ b/test/unit/pixi-v2/display/DisplayObjectContainer.js @@ -0,0 +1,67 @@ +describe('pixi/display/DisplayObjectContainer', function () { + 'use strict'; + + var expect = chai.expect; + var DisplayObjectContainer = PIXI.DisplayObjectContainer; + + it('Module exists', function () { + expect(DisplayObjectContainer).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new DisplayObjectContainer(); + + pixi_display_DisplayObjectContainer_confirmNew(obj); + expect(obj).to.have.property('hitArea', null); + expect(obj).to.have.property('interactive', false); + expect(obj).to.have.property('renderable', false); + expect(obj).to.have.property('stage', null); + }); + + it('Gets child index', function() { + var container = new PIXI.DisplayObjectContainer(); + var children = []; + for (var i = 0; i < 10; i++) { + var child = new PIXI.DisplayObject(); + children.push(child); + container.addChild(child); + } + + for (i = 0; i < children.length; i++) { + expect(i).to.eql(container.getChildIndex(children[i])); + } + }); + + it('throws error when trying to get index of not a child', function() { + var container = new PIXI.DisplayObjectContainer(); + var child = new PIXI.DisplayObject(); + + expect(function() { container.getChildIndex(child); }).to.throw(); + }); + + it('Sets child index', function() { + var container = new PIXI.DisplayObjectContainer(); + var children = []; + + for (var i = 0; i < 10; i++) { + var child = new PIXI.DisplayObject(); + children.push(child); + container.addChild(child); + } + children.reverse(); + + for (i = 0; i < children.length; i++) { + container.setChildIndex(children[i], i); + expect(i).to.eql(container.getChildIndex(children[i])); + } + }); + + it('throws error when trying to set incorect index', function() { + var container = new PIXI.DisplayObjectContainer(); + var child = new PIXI.DisplayObject(); + container.addChild(child); + + expect(function() { container.setChildIndex(child, -1); }).to.throw(); + expect(function() { container.setChildIndex(child, 1); }).to.throw(); + }); +}); diff --git a/test/unit/pixi-v2/display/MovieClip.js b/test/unit/pixi-v2/display/MovieClip.js new file mode 100644 index 0000000..f3c6c6a --- /dev/null +++ b/test/unit/pixi-v2/display/MovieClip.js @@ -0,0 +1,33 @@ +describe('pixi/display/MovieClip', function () { + 'use strict'; + + var expect = chai.expect; + var MovieClip = PIXI.MovieClip; + var Texture = PIXI.Texture; + + it('Module exists', function () { + expect(MovieClip).to.be.a('function'); + }); + + it('Confirm new instance', function (done) { + var texture = Texture.fromImage('/base/test/textures/SpriteSheet-Explosion.png'); + var obj = new MovieClip([texture]); + + pixi_display_Sprite_confirmNew(obj, done); + + expect(obj).to.be.an.instanceof(MovieClip); + expect(obj).to.respondTo('stop'); + expect(obj).to.respondTo('play'); + expect(obj).to.respondTo('gotoAndStop'); + expect(obj).to.respondTo('gotoAndPlay'); + expect(obj).to.respondTo('updateTransform'); + + expect(obj).to.have.deep.property('textures.length', 1); + expect(obj).to.have.deep.property('textures[0]', texture); + expect(obj).to.have.property('animationSpeed', 1); + expect(obj).to.have.property('loop', true); + expect(obj).to.have.property('onComplete', null); + expect(obj).to.have.property('currentFrame', 0); + expect(obj).to.have.property('playing', false); + }); +}); diff --git a/test/unit/pixi-v2/display/Sprite.js b/test/unit/pixi-v2/display/Sprite.js new file mode 100644 index 0000000..30c8076 --- /dev/null +++ b/test/unit/pixi-v2/display/Sprite.js @@ -0,0 +1,28 @@ +describe('pixi/display/Sprite', function () { + 'use strict'; + + var expect = chai.expect; + var Sprite = PIXI.Sprite; + var Texture = PIXI.Texture; + + it('Module exists', function () { + expect(Sprite).to.be.a('function'); + expect(PIXI).to.have.deep.property('blendModes.NORMAL', 0); + expect(PIXI).to.have.deep.property('blendModes.ADD', 1); + expect(PIXI).to.have.deep.property('blendModes.MULTIPLY', 2); + expect(PIXI).to.have.deep.property('blendModes.SCREEN', 3); + }); + + + it('Members exist', function () { + expect(Sprite).itself.to.respondTo('fromImage'); + expect(Sprite).itself.to.respondTo('fromFrame'); + }); + + it('Confirm new instance', function (done) { + var texture = Texture.fromImage('/base/test/textures/SpriteSheet-Aliens.png'); + var obj = new Sprite(texture); + + pixi_display_Sprite_confirmNew(obj, done); + }); +}); diff --git a/test/unit/pixi-v2/display/Stage.js b/test/unit/pixi-v2/display/Stage.js new file mode 100644 index 0000000..6974c2e --- /dev/null +++ b/test/unit/pixi-v2/display/Stage.js @@ -0,0 +1,49 @@ +describe('pixi/display/Stage', function () { + 'use strict'; + + var expect = chai.expect; + var Stage = PIXI.Stage; + var InteractionManager = PIXI.InteractionManager; + var Rectangle = PIXI.Rectangle; + + it('Module exists', function () { + expect(Stage).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Stage(null, true); + + pixi_display_DisplayObjectContainer_confirmNew(obj); + + expect(obj).to.be.an.instanceof(Stage); + expect(obj).to.respondTo('updateTransform'); + expect(obj).to.respondTo('setBackgroundColor'); + expect(obj).to.respondTo('getMousePosition'); + // FIXME: duplicate member in DisplayObject + pixi_core_Matrix_confirmNewMatrix(obj.worldTransform); + // FIXME: convert arg to bool in constructor + expect(obj).to.have.property('interactive', true); + + expect(obj).to.have.property('interactionManager') + .and.to.be.an.instanceof(InteractionManager) + .and.to.have.property('stage', obj); + + expect(obj).to.have.property('dirty', true); + + expect(obj).to.have.property('stage', obj); + + expect(obj).to.have.property('hitArea') + .and.to.be.an.instanceof(Rectangle); + pixi_core_Rectangle_confirm(obj.hitArea, 0, 0, 100000, 100000); + + expect(obj).to.have.property('backgroundColor', 0x000000); + expect(obj).to.have.deep.property('backgroundColorSplit.length', 3); + expect(obj).to.have.deep.property('backgroundColorSplit[0]', 0); + expect(obj).to.have.deep.property('backgroundColorSplit[1]', 0); + expect(obj).to.have.deep.property('backgroundColorSplit[2]', 0); + expect(obj).to.have.property('backgroundColorString', '#000000'); + + + expect(obj).to.have.property('worldVisible', true); + }); +}); diff --git a/test/unit/pixi-v2/extras/Rope.js b/test/unit/pixi-v2/extras/Rope.js new file mode 100644 index 0000000..05885ac --- /dev/null +++ b/test/unit/pixi-v2/extras/Rope.js @@ -0,0 +1,31 @@ +describe('pixi/extras/Rope', function () { + 'use strict'; + + var expect = chai.expect; + var Rope = PIXI.Rope; + var Texture = PIXI.Texture; + var Point = PIXI.Point; + + it('Module exists', function () { + expect(Rope).to.be.a('function'); + }); + + it('Confirm new instance', function () { + + var texture = Texture.fromImage('/base/test/textures/bunny.png'); + + // TODO-Alvin + // Same as Strip + + // var obj = new Rope(texture, [new Point(), new Point(5, 10), new Point(10, 20)]); + + // pixi_extras_Strip_confirmNew(obj); + + // expect(obj).to.be.an.instanceof(Rope); + // expect(obj).to.respondTo('refresh'); + // expect(obj).to.respondTo('updateTransform'); + // expect(obj).to.respondTo('setTexture'); + + // TODO: Test properties + }); +}); diff --git a/test/unit/pixi-v2/extras/Spine.js b/test/unit/pixi-v2/extras/Spine.js new file mode 100644 index 0000000..0708bc0 --- /dev/null +++ b/test/unit/pixi-v2/extras/Spine.js @@ -0,0 +1,10 @@ +describe('pixi/extras/Spine', function () { + 'use strict'; + + var expect = chai.expect; + var Spine = PIXI.Spine; + + it('Module exists', function () { + expect(Spine).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/extras/Strip.js b/test/unit/pixi-v2/extras/Strip.js new file mode 100644 index 0000000..230af90 --- /dev/null +++ b/test/unit/pixi-v2/extras/Strip.js @@ -0,0 +1,26 @@ +describe('pixi/extras/Strip', function () { + 'use strict'; + + var expect = chai.expect; + var Strip = PIXI.Strip; + var Texture = PIXI.Texture; + + it('Module exists', function () { + expect(Strip).to.be.a('function'); + }); + + it('Confirm new instance', function () { + + + // TODO-Alvin + // We tweaked it to make it pass the tests, but the whole strip class needs + // to be re-coded + + var texture = Texture.fromImage('/base/test/textures/bunny.png'); + + // var obj = new Strip(texture, 20, 10000); + + + // pixi_extras_Strip_confirmNew(obj); + }); +}); diff --git a/test/unit/pixi-v2/extras/TilingSprite.js b/test/unit/pixi-v2/extras/TilingSprite.js new file mode 100644 index 0000000..56aea14 --- /dev/null +++ b/test/unit/pixi-v2/extras/TilingSprite.js @@ -0,0 +1,24 @@ +describe('pixi/extras/TilingSprite', function () { + 'use strict'; + + var expect = chai.expect; + var TilingSprite = PIXI.TilingSprite; + var Texture = PIXI.Texture; + + it('Module exists', function () { + expect(TilingSprite).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var texture = Texture.fromImage('/base/test/textures/bunny.png'); + var obj = new TilingSprite(texture, 6000, 12000); + + pixi_display_DisplayObjectContainer_confirmNew(obj); + + expect(obj).to.be.an.instanceof(TilingSprite); + expect(obj).to.respondTo('setTexture'); + expect(obj).to.respondTo('onTextureUpdate'); + + // TODO: Test properties + }); +}); diff --git a/test/unit/pixi-v2/filters/FilterBlock.js b/test/unit/pixi-v2/filters/FilterBlock.js new file mode 100644 index 0000000..870cec0 --- /dev/null +++ b/test/unit/pixi-v2/filters/FilterBlock.js @@ -0,0 +1,10 @@ +describe('pixi/filters/FilterBlock', function () { + 'use strict'; + + var expect = chai.expect; + var FilterBlock = PIXI.FilterBlock; + + it('Module exists', function () { + expect(FilterBlock).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/AssetLoader.js b/test/unit/pixi-v2/loaders/AssetLoader.js new file mode 100644 index 0000000..a0aa0b5 --- /dev/null +++ b/test/unit/pixi-v2/loaders/AssetLoader.js @@ -0,0 +1,10 @@ +describe('pixi/loaders/AssetLoader', function () { + 'use strict'; + + var expect = chai.expect; + var AssetLoader = PIXI.AssetLoader; + + it('Module exists', function () { + expect(AssetLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/BitmapFontLoader.js b/test/unit/pixi-v2/loaders/BitmapFontLoader.js new file mode 100644 index 0000000..046f018 --- /dev/null +++ b/test/unit/pixi-v2/loaders/BitmapFontLoader.js @@ -0,0 +1,9 @@ +describe('pixi/loaders/BitmapFontLoader', function () { + 'use strict'; + + var expect = chai.expect; + + it('Module exists', function () { + expect(PIXI.BitmapFontLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/ImageLoader.js b/test/unit/pixi-v2/loaders/ImageLoader.js new file mode 100644 index 0000000..8b1f556 --- /dev/null +++ b/test/unit/pixi-v2/loaders/ImageLoader.js @@ -0,0 +1,10 @@ +describe('pixi/loaders/ImageLoader', function () { + 'use strict'; + + var expect = chai.expect; + var ImageLoader = PIXI.ImageLoader; + + it('Module exists', function () { + expect(ImageLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/JsonLoader.js b/test/unit/pixi-v2/loaders/JsonLoader.js new file mode 100644 index 0000000..c577e83 --- /dev/null +++ b/test/unit/pixi-v2/loaders/JsonLoader.js @@ -0,0 +1,10 @@ +describe('pixi/loaders/JsonLoader', function () { + 'use strict'; + + var expect = chai.expect; + var JsonLoader = PIXI.JsonLoader; + + it('Module exists', function () { + expect(JsonLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/SpineLoader.js b/test/unit/pixi-v2/loaders/SpineLoader.js new file mode 100644 index 0000000..fdcc0b8 --- /dev/null +++ b/test/unit/pixi-v2/loaders/SpineLoader.js @@ -0,0 +1,10 @@ +describe('pixi/loaders/SpineLoader', function () { + 'use strict'; + + var expect = chai.expect; + var SpineLoader = PIXI.SpineLoader; + + it('Module exists', function () { + expect(SpineLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/SpriteSheetLoader.js b/test/unit/pixi-v2/loaders/SpriteSheetLoader.js new file mode 100644 index 0000000..57beb27 --- /dev/null +++ b/test/unit/pixi-v2/loaders/SpriteSheetLoader.js @@ -0,0 +1,10 @@ +describe('pixi/loaders/SpriteSheetLoader', function () { + 'use strict'; + + var expect = chai.expect; + var SpriteSheetLoader = PIXI.SpriteSheetLoader; + + it('Module exists', function () { + expect(SpriteSheetLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/primitives/Graphics.js b/test/unit/pixi-v2/primitives/Graphics.js new file mode 100644 index 0000000..f3849eb --- /dev/null +++ b/test/unit/pixi-v2/primitives/Graphics.js @@ -0,0 +1,44 @@ +describe('pixi/primitives/Graphics', function () { + 'use strict'; + + var expect = chai.expect; + var Graphics = PIXI.Graphics; + + it('Module exists', function () { + expect(Graphics).to.be.a('function'); + + expect(Graphics).itself.to.have.property('POLY', 0); + expect(Graphics).itself.to.have.property('RECT', 1); + expect(Graphics).itself.to.have.property('CIRC', 2); + expect(Graphics).itself.to.have.property('ELIP', 3); + expect(Graphics).itself.to.have.property('RREC', 4); + }); + + it('Confirm new instance', function () { + var obj = new Graphics(); + + pixi_display_DisplayObjectContainer_confirmNew(obj); + + expect(obj).to.be.an.instanceof(Graphics); + expect(obj).to.respondTo('lineStyle'); + expect(obj).to.respondTo('lineStyle'); + expect(obj).to.respondTo('moveTo'); + expect(obj).to.respondTo('lineTo'); + expect(obj).to.respondTo('beginFill'); + expect(obj).to.respondTo('endFill'); + expect(obj).to.respondTo('drawRect'); + // expect(obj).to.respondTo('drawRoundedRect'); + expect(obj).to.respondTo('drawCircle'); + expect(obj).to.respondTo('drawEllipse'); + expect(obj).to.respondTo('clear'); + + expect(obj).to.have.property('renderable', true); + expect(obj).to.have.property('fillAlpha', 1); + expect(obj).to.have.property('lineWidth', 0); + expect(obj).to.have.property('width', 0); + expect(obj).to.have.property('height', 0); + expect(obj).to.have.property('lineColor', 0); + expect(obj).to.have.deep.property('graphicsData.length', 0); + // expect(obj).to.have.deep.property('currentPath.points.length', 0); + }); +}); diff --git a/test/unit/pixi-v2/renderers/canvas/CanvasGraphics.js b/test/unit/pixi-v2/renderers/canvas/CanvasGraphics.js new file mode 100644 index 0000000..8f44472 --- /dev/null +++ b/test/unit/pixi-v2/renderers/canvas/CanvasGraphics.js @@ -0,0 +1,15 @@ +describe('renders/canvas/CanvasGraphics', function () { + 'use strict'; + + var expect = chai.expect; + var CanvasGraphics = PIXI.CanvasGraphics; + + it('Module exists', function () { + expect(CanvasGraphics).to.be.a('function'); + }); + + it('Members exist', function () { + expect(CanvasGraphics).itself.to.respondTo('renderGraphics'); + expect(CanvasGraphics).itself.to.respondTo('renderGraphicsMask'); + }); +}); diff --git a/test/unit/pixi-v2/renderers/canvas/CanvasRenderer.js b/test/unit/pixi-v2/renderers/canvas/CanvasRenderer.js new file mode 100644 index 0000000..1646444 --- /dev/null +++ b/test/unit/pixi-v2/renderers/canvas/CanvasRenderer.js @@ -0,0 +1,36 @@ +describe('renderers/canvas/CanvasRenderer', function () { + 'use strict'; + + var expect = chai.expect; + var CanvasRenderer = PIXI.CanvasRenderer; + + it('Module exists', function () { + expect(CanvasRenderer).to.be.a('function'); + }); + + describe('.autoResize', function () { + it('Should automatically resize view if enabled', function () { + var renderer = new CanvasRenderer(200, 200, { + autoResize: true + }); + + expect(renderer.view.style.width).to.equal('200px'); + }); + + it('Should not automatically resize view if disabled', function () { + var renderer = new CanvasRenderer(200, 200, { + autoResize: false + }); + + expect(renderer.view.style.width).to.equal(''); + }); + + it('Should not automatically resize view if not specified', function () { + var renderer = new CanvasRenderer(200, 200, { + resolution: 2 + }); + + expect(renderer.view.style.width).to.equal(''); + }); + }); +}); diff --git a/test/unit/pixi-v2/renderers/webgl/WebGLGraphics.js b/test/unit/pixi-v2/renderers/webgl/WebGLGraphics.js new file mode 100644 index 0000000..5867b28 --- /dev/null +++ b/test/unit/pixi-v2/renderers/webgl/WebGLGraphics.js @@ -0,0 +1,20 @@ +describe('renderers/wegbl/WebGLGraphics', function () { + 'use strict'; + + var expect = chai.expect; + var WebGLGraphics = PIXI.WebGLGraphics; + + it('Module exists', function () { + expect(WebGLGraphics).to.be.a('function'); + }); + + it('Members exist', function () { + expect(WebGLGraphics).itself.to.respondTo('renderGraphics'); + expect(WebGLGraphics).itself.to.respondTo('updateGraphics'); + expect(WebGLGraphics).itself.to.respondTo('buildRectangle'); + expect(WebGLGraphics).itself.to.respondTo('buildRoundedRectangle'); + expect(WebGLGraphics).itself.to.respondTo('buildCircle'); + expect(WebGLGraphics).itself.to.respondTo('buildLine'); + expect(WebGLGraphics).itself.to.respondTo('buildPoly'); + }); +}); diff --git a/test/unit/pixi-v2/renderers/webgl/WebGLRenderer.js b/test/unit/pixi-v2/renderers/webgl/WebGLRenderer.js new file mode 100644 index 0000000..1680a80 --- /dev/null +++ b/test/unit/pixi-v2/renderers/webgl/WebGLRenderer.js @@ -0,0 +1,49 @@ +describe('renderers/webgl/WebGLRenderer', function () { + 'use strict'; + + var expect = chai.expect; + var WebGLRenderer = PIXI.WebGLRenderer; + + it('Module exists', function () { + expect(WebGLRenderer).to.be.a('function'); + }); + + // Skip tests if WebGL is not available (WebGL not supported in Travis CI) + try { + var renderer = new WebGLRenderer(400, 300, {}); + renderer.destroy(); + } catch (error) { + return; + } + + it('Destroy renderer', function () { + var renderer = new WebGLRenderer(400, 300, {}); + renderer.destroy(); + }); + + describe('.autoResize', function () { + it('Should automatically resize view if enabled', function () { + var renderer = new WebGLRenderer(200, 200, { + autoResize: true + }); + + expect(renderer.view.style.width).to.equal('200px'); + }); + + it('Should not automatically resize view if disabled', function () { + var renderer = new WebGLRenderer(200, 200, { + autoResize: false + }); + + expect(renderer.view.style.width).to.equal(''); + }); + + it('Should not automatically resize view if not specified', function () { + var renderer = new WebGLRenderer(200, 200, { + resolution: 2 + }); + + expect(renderer.view.style.width).to.equal(''); + }); + }); +}); diff --git a/test/unit/pixi-v2/renderers/webgl/WebGLShaders.js b/test/unit/pixi-v2/renderers/webgl/WebGLShaders.js new file mode 100644 index 0000000..6e33e4f --- /dev/null +++ b/test/unit/pixi-v2/renderers/webgl/WebGLShaders.js @@ -0,0 +1,13 @@ +describe('renderers/webgl/WebGLShaders', function () { + 'use strict'; + + var expect = chai.expect; + + it('Module members exist', function () { + + expect(PIXI).to.respondTo('CompileVertexShader'); + expect(PIXI).to.respondTo('CompileFragmentShader'); + expect(PIXI).to.respondTo('_CompileShader'); + expect(PIXI).to.respondTo('compileProgram'); + }); +}); diff --git a/test/unit/pixi-v2/renderers/webgl/WebGLSpriteBatch.js b/test/unit/pixi-v2/renderers/webgl/WebGLSpriteBatch.js new file mode 100644 index 0000000..e662b63 --- /dev/null +++ b/test/unit/pixi-v2/renderers/webgl/WebGLSpriteBatch.js @@ -0,0 +1,10 @@ +describe('renderers/webgl/utils/WebGLSpriteBatch', function () { + 'use strict'; + + var expect = chai.expect; + var WebGLSpriteBatch = PIXI.WebGLSpriteBatch; + + it('Module exists', function () { + expect(WebGLSpriteBatch).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/InteractionManager.js b/test/unit/pixi-v2/InteractionManager.js new file mode 100644 index 0000000..ed3001f --- /dev/null +++ b/test/unit/pixi-v2/InteractionManager.js @@ -0,0 +1,10 @@ +describe('pixi/InteractionManager', function () { + 'use strict'; + + var expect = chai.expect; + var InteractionManager = PIXI.InteractionManager; + + it('Module exists', function () { + expect(InteractionManager).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/Pixi.js b/test/unit/pixi-v2/Pixi.js new file mode 100644 index 0000000..27debc1 --- /dev/null +++ b/test/unit/pixi-v2/Pixi.js @@ -0,0 +1,9 @@ +describe('pixi/Pixi', function () { + 'use strict'; + + var expect = chai.expect; + + it('Module exists', function () { + expect(global).to.have.property('PIXI').and.to.be.an('object'); + }); +}); diff --git a/test/unit/pixi-v2/core/Circle.js b/test/unit/pixi-v2/core/Circle.js new file mode 100644 index 0000000..fbcfa17 --- /dev/null +++ b/test/unit/pixi-v2/core/Circle.js @@ -0,0 +1,21 @@ +describe('pixi/core/Circle', function () { + 'use strict'; + + var expect = chai.expect; + var Circle = PIXI.Circle; + + it('Module exists', function () { + expect(Circle).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Circle(); + pixi_core_Circle_confirmNewCircle(obj); + }); + + it("getBounds should return Rectangle that bounds the circle", function() { + var obj = new Circle(100, 250, 50); + var bounds = obj.getBounds(); + pixi_core_Circle_isBoundedByRectangle(obj, bounds); + }); +}); diff --git a/test/unit/pixi-v2/core/Ellipse.js b/test/unit/pixi-v2/core/Ellipse.js new file mode 100644 index 0000000..026b56f --- /dev/null +++ b/test/unit/pixi-v2/core/Ellipse.js @@ -0,0 +1,24 @@ +describe('pixi/core/Ellipse', function () { + 'use strict'; + + var expect = chai.expect; + var Ellipse = PIXI.Ellipse; + + it('Module exists', function () { + expect(Ellipse).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Ellipse(); + + expect(obj).to.be.an.instanceof(Ellipse); + expect(obj).to.respondTo('clone'); + expect(obj).to.respondTo('contains'); + expect(obj).to.respondTo('getBounds'); + + expect(obj).to.have.property('x', 0); + expect(obj).to.have.property('y', 0); + expect(obj).to.have.property('width', 0); + expect(obj).to.have.property('height', 0); + }); +}); diff --git a/test/unit/pixi-v2/core/Matrix.js b/test/unit/pixi-v2/core/Matrix.js new file mode 100644 index 0000000..da75e2e --- /dev/null +++ b/test/unit/pixi-v2/core/Matrix.js @@ -0,0 +1,14 @@ +describe('pixi/core/Matrix', function () { + 'use strict'; + + var expect = chai.expect; + + it('Matrix exists', function () { + expect(PIXI.Matrix).to.be.an('function'); + }); + + it('Confirm new Matrix', function () { + var matrix = new PIXI.Matrix(); + pixi_core_Matrix_confirmNewMatrix(matrix); + }); +}); diff --git a/test/unit/pixi-v2/core/Point.js b/test/unit/pixi-v2/core/Point.js new file mode 100644 index 0000000..c4d5163 --- /dev/null +++ b/test/unit/pixi-v2/core/Point.js @@ -0,0 +1,15 @@ +describe('pixi/core/Point', function () { + 'use strict'; + + var expect = chai.expect; + var Point = PIXI.Point; + + it('Module exists', function () { + expect(Point).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Point(); + pixi_core_Point_confirm(obj, 0, 0); + }); +}); diff --git a/test/unit/pixi-v2/core/Polygon.js b/test/unit/pixi-v2/core/Polygon.js new file mode 100644 index 0000000..dc8c918 --- /dev/null +++ b/test/unit/pixi-v2/core/Polygon.js @@ -0,0 +1,20 @@ +describe('pixi/core/Polygon', function () { + 'use strict'; + + var expect = chai.expect; + var Polygon = PIXI.Polygon; + + it('Module exists', function () { + expect(Polygon).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Polygon(); + + expect(obj).to.be.an.instanceof(Polygon); + expect(obj).to.respondTo('clone'); + expect(obj).to.respondTo('contains'); + + expect(obj).to.have.deep.property('points.length', 0); + }); +}); diff --git a/test/unit/pixi-v2/core/Rectangle.js b/test/unit/pixi-v2/core/Rectangle.js new file mode 100644 index 0000000..d43316e --- /dev/null +++ b/test/unit/pixi-v2/core/Rectangle.js @@ -0,0 +1,15 @@ +describe('pixi/core/Rectangle', function () { + 'use strict'; + + var expect = chai.expect; + var Rectangle = PIXI.Rectangle; + + it('Module exists', function () { + expect(Rectangle).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var rect = new Rectangle(); + pixi_core_Rectangle_confirm(rect, 0, 0, 0, 0); + }); +}); diff --git a/test/unit/pixi-v2/display/DisplayObject.js b/test/unit/pixi-v2/display/DisplayObject.js new file mode 100644 index 0000000..044acf8 --- /dev/null +++ b/test/unit/pixi-v2/display/DisplayObject.js @@ -0,0 +1,21 @@ +describe('pixi/display/DisplayObject', function () { + 'use strict'; + + var expect = chai.expect; + var DisplayObject = PIXI.DisplayObject; + + it('Module exists', function () { + expect(DisplayObject).to.be.a('function'); + // expect(PIXI).to.have.property('visibleCount', 0); + }); + + it('Confirm new instance', function () { + var obj = new DisplayObject(); + + pixi_display_DisplayObject_confirmNew(obj); + expect(obj).to.have.property('hitArea', null); + expect(obj).to.have.property('interactive', false); + expect(obj).to.have.property('renderable', false); + expect(obj).to.have.property('stage', null); + }); +}); diff --git a/test/unit/pixi-v2/display/DisplayObjectContainer.js b/test/unit/pixi-v2/display/DisplayObjectContainer.js new file mode 100644 index 0000000..15a3376 --- /dev/null +++ b/test/unit/pixi-v2/display/DisplayObjectContainer.js @@ -0,0 +1,67 @@ +describe('pixi/display/DisplayObjectContainer', function () { + 'use strict'; + + var expect = chai.expect; + var DisplayObjectContainer = PIXI.DisplayObjectContainer; + + it('Module exists', function () { + expect(DisplayObjectContainer).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new DisplayObjectContainer(); + + pixi_display_DisplayObjectContainer_confirmNew(obj); + expect(obj).to.have.property('hitArea', null); + expect(obj).to.have.property('interactive', false); + expect(obj).to.have.property('renderable', false); + expect(obj).to.have.property('stage', null); + }); + + it('Gets child index', function() { + var container = new PIXI.DisplayObjectContainer(); + var children = []; + for (var i = 0; i < 10; i++) { + var child = new PIXI.DisplayObject(); + children.push(child); + container.addChild(child); + } + + for (i = 0; i < children.length; i++) { + expect(i).to.eql(container.getChildIndex(children[i])); + } + }); + + it('throws error when trying to get index of not a child', function() { + var container = new PIXI.DisplayObjectContainer(); + var child = new PIXI.DisplayObject(); + + expect(function() { container.getChildIndex(child); }).to.throw(); + }); + + it('Sets child index', function() { + var container = new PIXI.DisplayObjectContainer(); + var children = []; + + for (var i = 0; i < 10; i++) { + var child = new PIXI.DisplayObject(); + children.push(child); + container.addChild(child); + } + children.reverse(); + + for (i = 0; i < children.length; i++) { + container.setChildIndex(children[i], i); + expect(i).to.eql(container.getChildIndex(children[i])); + } + }); + + it('throws error when trying to set incorect index', function() { + var container = new PIXI.DisplayObjectContainer(); + var child = new PIXI.DisplayObject(); + container.addChild(child); + + expect(function() { container.setChildIndex(child, -1); }).to.throw(); + expect(function() { container.setChildIndex(child, 1); }).to.throw(); + }); +}); diff --git a/test/unit/pixi-v2/display/MovieClip.js b/test/unit/pixi-v2/display/MovieClip.js new file mode 100644 index 0000000..f3c6c6a --- /dev/null +++ b/test/unit/pixi-v2/display/MovieClip.js @@ -0,0 +1,33 @@ +describe('pixi/display/MovieClip', function () { + 'use strict'; + + var expect = chai.expect; + var MovieClip = PIXI.MovieClip; + var Texture = PIXI.Texture; + + it('Module exists', function () { + expect(MovieClip).to.be.a('function'); + }); + + it('Confirm new instance', function (done) { + var texture = Texture.fromImage('/base/test/textures/SpriteSheet-Explosion.png'); + var obj = new MovieClip([texture]); + + pixi_display_Sprite_confirmNew(obj, done); + + expect(obj).to.be.an.instanceof(MovieClip); + expect(obj).to.respondTo('stop'); + expect(obj).to.respondTo('play'); + expect(obj).to.respondTo('gotoAndStop'); + expect(obj).to.respondTo('gotoAndPlay'); + expect(obj).to.respondTo('updateTransform'); + + expect(obj).to.have.deep.property('textures.length', 1); + expect(obj).to.have.deep.property('textures[0]', texture); + expect(obj).to.have.property('animationSpeed', 1); + expect(obj).to.have.property('loop', true); + expect(obj).to.have.property('onComplete', null); + expect(obj).to.have.property('currentFrame', 0); + expect(obj).to.have.property('playing', false); + }); +}); diff --git a/test/unit/pixi-v2/display/Sprite.js b/test/unit/pixi-v2/display/Sprite.js new file mode 100644 index 0000000..30c8076 --- /dev/null +++ b/test/unit/pixi-v2/display/Sprite.js @@ -0,0 +1,28 @@ +describe('pixi/display/Sprite', function () { + 'use strict'; + + var expect = chai.expect; + var Sprite = PIXI.Sprite; + var Texture = PIXI.Texture; + + it('Module exists', function () { + expect(Sprite).to.be.a('function'); + expect(PIXI).to.have.deep.property('blendModes.NORMAL', 0); + expect(PIXI).to.have.deep.property('blendModes.ADD', 1); + expect(PIXI).to.have.deep.property('blendModes.MULTIPLY', 2); + expect(PIXI).to.have.deep.property('blendModes.SCREEN', 3); + }); + + + it('Members exist', function () { + expect(Sprite).itself.to.respondTo('fromImage'); + expect(Sprite).itself.to.respondTo('fromFrame'); + }); + + it('Confirm new instance', function (done) { + var texture = Texture.fromImage('/base/test/textures/SpriteSheet-Aliens.png'); + var obj = new Sprite(texture); + + pixi_display_Sprite_confirmNew(obj, done); + }); +}); diff --git a/test/unit/pixi-v2/display/Stage.js b/test/unit/pixi-v2/display/Stage.js new file mode 100644 index 0000000..6974c2e --- /dev/null +++ b/test/unit/pixi-v2/display/Stage.js @@ -0,0 +1,49 @@ +describe('pixi/display/Stage', function () { + 'use strict'; + + var expect = chai.expect; + var Stage = PIXI.Stage; + var InteractionManager = PIXI.InteractionManager; + var Rectangle = PIXI.Rectangle; + + it('Module exists', function () { + expect(Stage).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Stage(null, true); + + pixi_display_DisplayObjectContainer_confirmNew(obj); + + expect(obj).to.be.an.instanceof(Stage); + expect(obj).to.respondTo('updateTransform'); + expect(obj).to.respondTo('setBackgroundColor'); + expect(obj).to.respondTo('getMousePosition'); + // FIXME: duplicate member in DisplayObject + pixi_core_Matrix_confirmNewMatrix(obj.worldTransform); + // FIXME: convert arg to bool in constructor + expect(obj).to.have.property('interactive', true); + + expect(obj).to.have.property('interactionManager') + .and.to.be.an.instanceof(InteractionManager) + .and.to.have.property('stage', obj); + + expect(obj).to.have.property('dirty', true); + + expect(obj).to.have.property('stage', obj); + + expect(obj).to.have.property('hitArea') + .and.to.be.an.instanceof(Rectangle); + pixi_core_Rectangle_confirm(obj.hitArea, 0, 0, 100000, 100000); + + expect(obj).to.have.property('backgroundColor', 0x000000); + expect(obj).to.have.deep.property('backgroundColorSplit.length', 3); + expect(obj).to.have.deep.property('backgroundColorSplit[0]', 0); + expect(obj).to.have.deep.property('backgroundColorSplit[1]', 0); + expect(obj).to.have.deep.property('backgroundColorSplit[2]', 0); + expect(obj).to.have.property('backgroundColorString', '#000000'); + + + expect(obj).to.have.property('worldVisible', true); + }); +}); diff --git a/test/unit/pixi-v2/extras/Rope.js b/test/unit/pixi-v2/extras/Rope.js new file mode 100644 index 0000000..05885ac --- /dev/null +++ b/test/unit/pixi-v2/extras/Rope.js @@ -0,0 +1,31 @@ +describe('pixi/extras/Rope', function () { + 'use strict'; + + var expect = chai.expect; + var Rope = PIXI.Rope; + var Texture = PIXI.Texture; + var Point = PIXI.Point; + + it('Module exists', function () { + expect(Rope).to.be.a('function'); + }); + + it('Confirm new instance', function () { + + var texture = Texture.fromImage('/base/test/textures/bunny.png'); + + // TODO-Alvin + // Same as Strip + + // var obj = new Rope(texture, [new Point(), new Point(5, 10), new Point(10, 20)]); + + // pixi_extras_Strip_confirmNew(obj); + + // expect(obj).to.be.an.instanceof(Rope); + // expect(obj).to.respondTo('refresh'); + // expect(obj).to.respondTo('updateTransform'); + // expect(obj).to.respondTo('setTexture'); + + // TODO: Test properties + }); +}); diff --git a/test/unit/pixi-v2/extras/Spine.js b/test/unit/pixi-v2/extras/Spine.js new file mode 100644 index 0000000..0708bc0 --- /dev/null +++ b/test/unit/pixi-v2/extras/Spine.js @@ -0,0 +1,10 @@ +describe('pixi/extras/Spine', function () { + 'use strict'; + + var expect = chai.expect; + var Spine = PIXI.Spine; + + it('Module exists', function () { + expect(Spine).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/extras/Strip.js b/test/unit/pixi-v2/extras/Strip.js new file mode 100644 index 0000000..230af90 --- /dev/null +++ b/test/unit/pixi-v2/extras/Strip.js @@ -0,0 +1,26 @@ +describe('pixi/extras/Strip', function () { + 'use strict'; + + var expect = chai.expect; + var Strip = PIXI.Strip; + var Texture = PIXI.Texture; + + it('Module exists', function () { + expect(Strip).to.be.a('function'); + }); + + it('Confirm new instance', function () { + + + // TODO-Alvin + // We tweaked it to make it pass the tests, but the whole strip class needs + // to be re-coded + + var texture = Texture.fromImage('/base/test/textures/bunny.png'); + + // var obj = new Strip(texture, 20, 10000); + + + // pixi_extras_Strip_confirmNew(obj); + }); +}); diff --git a/test/unit/pixi-v2/extras/TilingSprite.js b/test/unit/pixi-v2/extras/TilingSprite.js new file mode 100644 index 0000000..56aea14 --- /dev/null +++ b/test/unit/pixi-v2/extras/TilingSprite.js @@ -0,0 +1,24 @@ +describe('pixi/extras/TilingSprite', function () { + 'use strict'; + + var expect = chai.expect; + var TilingSprite = PIXI.TilingSprite; + var Texture = PIXI.Texture; + + it('Module exists', function () { + expect(TilingSprite).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var texture = Texture.fromImage('/base/test/textures/bunny.png'); + var obj = new TilingSprite(texture, 6000, 12000); + + pixi_display_DisplayObjectContainer_confirmNew(obj); + + expect(obj).to.be.an.instanceof(TilingSprite); + expect(obj).to.respondTo('setTexture'); + expect(obj).to.respondTo('onTextureUpdate'); + + // TODO: Test properties + }); +}); diff --git a/test/unit/pixi-v2/filters/FilterBlock.js b/test/unit/pixi-v2/filters/FilterBlock.js new file mode 100644 index 0000000..870cec0 --- /dev/null +++ b/test/unit/pixi-v2/filters/FilterBlock.js @@ -0,0 +1,10 @@ +describe('pixi/filters/FilterBlock', function () { + 'use strict'; + + var expect = chai.expect; + var FilterBlock = PIXI.FilterBlock; + + it('Module exists', function () { + expect(FilterBlock).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/AssetLoader.js b/test/unit/pixi-v2/loaders/AssetLoader.js new file mode 100644 index 0000000..a0aa0b5 --- /dev/null +++ b/test/unit/pixi-v2/loaders/AssetLoader.js @@ -0,0 +1,10 @@ +describe('pixi/loaders/AssetLoader', function () { + 'use strict'; + + var expect = chai.expect; + var AssetLoader = PIXI.AssetLoader; + + it('Module exists', function () { + expect(AssetLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/BitmapFontLoader.js b/test/unit/pixi-v2/loaders/BitmapFontLoader.js new file mode 100644 index 0000000..046f018 --- /dev/null +++ b/test/unit/pixi-v2/loaders/BitmapFontLoader.js @@ -0,0 +1,9 @@ +describe('pixi/loaders/BitmapFontLoader', function () { + 'use strict'; + + var expect = chai.expect; + + it('Module exists', function () { + expect(PIXI.BitmapFontLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/ImageLoader.js b/test/unit/pixi-v2/loaders/ImageLoader.js new file mode 100644 index 0000000..8b1f556 --- /dev/null +++ b/test/unit/pixi-v2/loaders/ImageLoader.js @@ -0,0 +1,10 @@ +describe('pixi/loaders/ImageLoader', function () { + 'use strict'; + + var expect = chai.expect; + var ImageLoader = PIXI.ImageLoader; + + it('Module exists', function () { + expect(ImageLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/JsonLoader.js b/test/unit/pixi-v2/loaders/JsonLoader.js new file mode 100644 index 0000000..c577e83 --- /dev/null +++ b/test/unit/pixi-v2/loaders/JsonLoader.js @@ -0,0 +1,10 @@ +describe('pixi/loaders/JsonLoader', function () { + 'use strict'; + + var expect = chai.expect; + var JsonLoader = PIXI.JsonLoader; + + it('Module exists', function () { + expect(JsonLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/SpineLoader.js b/test/unit/pixi-v2/loaders/SpineLoader.js new file mode 100644 index 0000000..fdcc0b8 --- /dev/null +++ b/test/unit/pixi-v2/loaders/SpineLoader.js @@ -0,0 +1,10 @@ +describe('pixi/loaders/SpineLoader', function () { + 'use strict'; + + var expect = chai.expect; + var SpineLoader = PIXI.SpineLoader; + + it('Module exists', function () { + expect(SpineLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/SpriteSheetLoader.js b/test/unit/pixi-v2/loaders/SpriteSheetLoader.js new file mode 100644 index 0000000..57beb27 --- /dev/null +++ b/test/unit/pixi-v2/loaders/SpriteSheetLoader.js @@ -0,0 +1,10 @@ +describe('pixi/loaders/SpriteSheetLoader', function () { + 'use strict'; + + var expect = chai.expect; + var SpriteSheetLoader = PIXI.SpriteSheetLoader; + + it('Module exists', function () { + expect(SpriteSheetLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/primitives/Graphics.js b/test/unit/pixi-v2/primitives/Graphics.js new file mode 100644 index 0000000..f3849eb --- /dev/null +++ b/test/unit/pixi-v2/primitives/Graphics.js @@ -0,0 +1,44 @@ +describe('pixi/primitives/Graphics', function () { + 'use strict'; + + var expect = chai.expect; + var Graphics = PIXI.Graphics; + + it('Module exists', function () { + expect(Graphics).to.be.a('function'); + + expect(Graphics).itself.to.have.property('POLY', 0); + expect(Graphics).itself.to.have.property('RECT', 1); + expect(Graphics).itself.to.have.property('CIRC', 2); + expect(Graphics).itself.to.have.property('ELIP', 3); + expect(Graphics).itself.to.have.property('RREC', 4); + }); + + it('Confirm new instance', function () { + var obj = new Graphics(); + + pixi_display_DisplayObjectContainer_confirmNew(obj); + + expect(obj).to.be.an.instanceof(Graphics); + expect(obj).to.respondTo('lineStyle'); + expect(obj).to.respondTo('lineStyle'); + expect(obj).to.respondTo('moveTo'); + expect(obj).to.respondTo('lineTo'); + expect(obj).to.respondTo('beginFill'); + expect(obj).to.respondTo('endFill'); + expect(obj).to.respondTo('drawRect'); + // expect(obj).to.respondTo('drawRoundedRect'); + expect(obj).to.respondTo('drawCircle'); + expect(obj).to.respondTo('drawEllipse'); + expect(obj).to.respondTo('clear'); + + expect(obj).to.have.property('renderable', true); + expect(obj).to.have.property('fillAlpha', 1); + expect(obj).to.have.property('lineWidth', 0); + expect(obj).to.have.property('width', 0); + expect(obj).to.have.property('height', 0); + expect(obj).to.have.property('lineColor', 0); + expect(obj).to.have.deep.property('graphicsData.length', 0); + // expect(obj).to.have.deep.property('currentPath.points.length', 0); + }); +}); diff --git a/test/unit/pixi-v2/renderers/canvas/CanvasGraphics.js b/test/unit/pixi-v2/renderers/canvas/CanvasGraphics.js new file mode 100644 index 0000000..8f44472 --- /dev/null +++ b/test/unit/pixi-v2/renderers/canvas/CanvasGraphics.js @@ -0,0 +1,15 @@ +describe('renders/canvas/CanvasGraphics', function () { + 'use strict'; + + var expect = chai.expect; + var CanvasGraphics = PIXI.CanvasGraphics; + + it('Module exists', function () { + expect(CanvasGraphics).to.be.a('function'); + }); + + it('Members exist', function () { + expect(CanvasGraphics).itself.to.respondTo('renderGraphics'); + expect(CanvasGraphics).itself.to.respondTo('renderGraphicsMask'); + }); +}); diff --git a/test/unit/pixi-v2/renderers/canvas/CanvasRenderer.js b/test/unit/pixi-v2/renderers/canvas/CanvasRenderer.js new file mode 100644 index 0000000..1646444 --- /dev/null +++ b/test/unit/pixi-v2/renderers/canvas/CanvasRenderer.js @@ -0,0 +1,36 @@ +describe('renderers/canvas/CanvasRenderer', function () { + 'use strict'; + + var expect = chai.expect; + var CanvasRenderer = PIXI.CanvasRenderer; + + it('Module exists', function () { + expect(CanvasRenderer).to.be.a('function'); + }); + + describe('.autoResize', function () { + it('Should automatically resize view if enabled', function () { + var renderer = new CanvasRenderer(200, 200, { + autoResize: true + }); + + expect(renderer.view.style.width).to.equal('200px'); + }); + + it('Should not automatically resize view if disabled', function () { + var renderer = new CanvasRenderer(200, 200, { + autoResize: false + }); + + expect(renderer.view.style.width).to.equal(''); + }); + + it('Should not automatically resize view if not specified', function () { + var renderer = new CanvasRenderer(200, 200, { + resolution: 2 + }); + + expect(renderer.view.style.width).to.equal(''); + }); + }); +}); diff --git a/test/unit/pixi-v2/renderers/webgl/WebGLGraphics.js b/test/unit/pixi-v2/renderers/webgl/WebGLGraphics.js new file mode 100644 index 0000000..5867b28 --- /dev/null +++ b/test/unit/pixi-v2/renderers/webgl/WebGLGraphics.js @@ -0,0 +1,20 @@ +describe('renderers/wegbl/WebGLGraphics', function () { + 'use strict'; + + var expect = chai.expect; + var WebGLGraphics = PIXI.WebGLGraphics; + + it('Module exists', function () { + expect(WebGLGraphics).to.be.a('function'); + }); + + it('Members exist', function () { + expect(WebGLGraphics).itself.to.respondTo('renderGraphics'); + expect(WebGLGraphics).itself.to.respondTo('updateGraphics'); + expect(WebGLGraphics).itself.to.respondTo('buildRectangle'); + expect(WebGLGraphics).itself.to.respondTo('buildRoundedRectangle'); + expect(WebGLGraphics).itself.to.respondTo('buildCircle'); + expect(WebGLGraphics).itself.to.respondTo('buildLine'); + expect(WebGLGraphics).itself.to.respondTo('buildPoly'); + }); +}); diff --git a/test/unit/pixi-v2/renderers/webgl/WebGLRenderer.js b/test/unit/pixi-v2/renderers/webgl/WebGLRenderer.js new file mode 100644 index 0000000..1680a80 --- /dev/null +++ b/test/unit/pixi-v2/renderers/webgl/WebGLRenderer.js @@ -0,0 +1,49 @@ +describe('renderers/webgl/WebGLRenderer', function () { + 'use strict'; + + var expect = chai.expect; + var WebGLRenderer = PIXI.WebGLRenderer; + + it('Module exists', function () { + expect(WebGLRenderer).to.be.a('function'); + }); + + // Skip tests if WebGL is not available (WebGL not supported in Travis CI) + try { + var renderer = new WebGLRenderer(400, 300, {}); + renderer.destroy(); + } catch (error) { + return; + } + + it('Destroy renderer', function () { + var renderer = new WebGLRenderer(400, 300, {}); + renderer.destroy(); + }); + + describe('.autoResize', function () { + it('Should automatically resize view if enabled', function () { + var renderer = new WebGLRenderer(200, 200, { + autoResize: true + }); + + expect(renderer.view.style.width).to.equal('200px'); + }); + + it('Should not automatically resize view if disabled', function () { + var renderer = new WebGLRenderer(200, 200, { + autoResize: false + }); + + expect(renderer.view.style.width).to.equal(''); + }); + + it('Should not automatically resize view if not specified', function () { + var renderer = new WebGLRenderer(200, 200, { + resolution: 2 + }); + + expect(renderer.view.style.width).to.equal(''); + }); + }); +}); diff --git a/test/unit/pixi-v2/renderers/webgl/WebGLShaders.js b/test/unit/pixi-v2/renderers/webgl/WebGLShaders.js new file mode 100644 index 0000000..6e33e4f --- /dev/null +++ b/test/unit/pixi-v2/renderers/webgl/WebGLShaders.js @@ -0,0 +1,13 @@ +describe('renderers/webgl/WebGLShaders', function () { + 'use strict'; + + var expect = chai.expect; + + it('Module members exist', function () { + + expect(PIXI).to.respondTo('CompileVertexShader'); + expect(PIXI).to.respondTo('CompileFragmentShader'); + expect(PIXI).to.respondTo('_CompileShader'); + expect(PIXI).to.respondTo('compileProgram'); + }); +}); diff --git a/test/unit/pixi-v2/renderers/webgl/WebGLSpriteBatch.js b/test/unit/pixi-v2/renderers/webgl/WebGLSpriteBatch.js new file mode 100644 index 0000000..e662b63 --- /dev/null +++ b/test/unit/pixi-v2/renderers/webgl/WebGLSpriteBatch.js @@ -0,0 +1,10 @@ +describe('renderers/webgl/utils/WebGLSpriteBatch', function () { + 'use strict'; + + var expect = chai.expect; + var WebGLSpriteBatch = PIXI.WebGLSpriteBatch; + + it('Module exists', function () { + expect(WebGLSpriteBatch).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/text/BitmapText.js b/test/unit/pixi-v2/text/BitmapText.js new file mode 100644 index 0000000..9388e3d --- /dev/null +++ b/test/unit/pixi-v2/text/BitmapText.js @@ -0,0 +1,10 @@ +describe('pixi/text/BitmapText', function () { + 'use strict'; + + var expect = chai.expect; + var BitmapText = PIXI.BitmapText; + + it('Module exists', function () { + expect(BitmapText).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/InteractionManager.js b/test/unit/pixi-v2/InteractionManager.js new file mode 100644 index 0000000..ed3001f --- /dev/null +++ b/test/unit/pixi-v2/InteractionManager.js @@ -0,0 +1,10 @@ +describe('pixi/InteractionManager', function () { + 'use strict'; + + var expect = chai.expect; + var InteractionManager = PIXI.InteractionManager; + + it('Module exists', function () { + expect(InteractionManager).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/Pixi.js b/test/unit/pixi-v2/Pixi.js new file mode 100644 index 0000000..27debc1 --- /dev/null +++ b/test/unit/pixi-v2/Pixi.js @@ -0,0 +1,9 @@ +describe('pixi/Pixi', function () { + 'use strict'; + + var expect = chai.expect; + + it('Module exists', function () { + expect(global).to.have.property('PIXI').and.to.be.an('object'); + }); +}); diff --git a/test/unit/pixi-v2/core/Circle.js b/test/unit/pixi-v2/core/Circle.js new file mode 100644 index 0000000..fbcfa17 --- /dev/null +++ b/test/unit/pixi-v2/core/Circle.js @@ -0,0 +1,21 @@ +describe('pixi/core/Circle', function () { + 'use strict'; + + var expect = chai.expect; + var Circle = PIXI.Circle; + + it('Module exists', function () { + expect(Circle).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Circle(); + pixi_core_Circle_confirmNewCircle(obj); + }); + + it("getBounds should return Rectangle that bounds the circle", function() { + var obj = new Circle(100, 250, 50); + var bounds = obj.getBounds(); + pixi_core_Circle_isBoundedByRectangle(obj, bounds); + }); +}); diff --git a/test/unit/pixi-v2/core/Ellipse.js b/test/unit/pixi-v2/core/Ellipse.js new file mode 100644 index 0000000..026b56f --- /dev/null +++ b/test/unit/pixi-v2/core/Ellipse.js @@ -0,0 +1,24 @@ +describe('pixi/core/Ellipse', function () { + 'use strict'; + + var expect = chai.expect; + var Ellipse = PIXI.Ellipse; + + it('Module exists', function () { + expect(Ellipse).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Ellipse(); + + expect(obj).to.be.an.instanceof(Ellipse); + expect(obj).to.respondTo('clone'); + expect(obj).to.respondTo('contains'); + expect(obj).to.respondTo('getBounds'); + + expect(obj).to.have.property('x', 0); + expect(obj).to.have.property('y', 0); + expect(obj).to.have.property('width', 0); + expect(obj).to.have.property('height', 0); + }); +}); diff --git a/test/unit/pixi-v2/core/Matrix.js b/test/unit/pixi-v2/core/Matrix.js new file mode 100644 index 0000000..da75e2e --- /dev/null +++ b/test/unit/pixi-v2/core/Matrix.js @@ -0,0 +1,14 @@ +describe('pixi/core/Matrix', function () { + 'use strict'; + + var expect = chai.expect; + + it('Matrix exists', function () { + expect(PIXI.Matrix).to.be.an('function'); + }); + + it('Confirm new Matrix', function () { + var matrix = new PIXI.Matrix(); + pixi_core_Matrix_confirmNewMatrix(matrix); + }); +}); diff --git a/test/unit/pixi-v2/core/Point.js b/test/unit/pixi-v2/core/Point.js new file mode 100644 index 0000000..c4d5163 --- /dev/null +++ b/test/unit/pixi-v2/core/Point.js @@ -0,0 +1,15 @@ +describe('pixi/core/Point', function () { + 'use strict'; + + var expect = chai.expect; + var Point = PIXI.Point; + + it('Module exists', function () { + expect(Point).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Point(); + pixi_core_Point_confirm(obj, 0, 0); + }); +}); diff --git a/test/unit/pixi-v2/core/Polygon.js b/test/unit/pixi-v2/core/Polygon.js new file mode 100644 index 0000000..dc8c918 --- /dev/null +++ b/test/unit/pixi-v2/core/Polygon.js @@ -0,0 +1,20 @@ +describe('pixi/core/Polygon', function () { + 'use strict'; + + var expect = chai.expect; + var Polygon = PIXI.Polygon; + + it('Module exists', function () { + expect(Polygon).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Polygon(); + + expect(obj).to.be.an.instanceof(Polygon); + expect(obj).to.respondTo('clone'); + expect(obj).to.respondTo('contains'); + + expect(obj).to.have.deep.property('points.length', 0); + }); +}); diff --git a/test/unit/pixi-v2/core/Rectangle.js b/test/unit/pixi-v2/core/Rectangle.js new file mode 100644 index 0000000..d43316e --- /dev/null +++ b/test/unit/pixi-v2/core/Rectangle.js @@ -0,0 +1,15 @@ +describe('pixi/core/Rectangle', function () { + 'use strict'; + + var expect = chai.expect; + var Rectangle = PIXI.Rectangle; + + it('Module exists', function () { + expect(Rectangle).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var rect = new Rectangle(); + pixi_core_Rectangle_confirm(rect, 0, 0, 0, 0); + }); +}); diff --git a/test/unit/pixi-v2/display/DisplayObject.js b/test/unit/pixi-v2/display/DisplayObject.js new file mode 100644 index 0000000..044acf8 --- /dev/null +++ b/test/unit/pixi-v2/display/DisplayObject.js @@ -0,0 +1,21 @@ +describe('pixi/display/DisplayObject', function () { + 'use strict'; + + var expect = chai.expect; + var DisplayObject = PIXI.DisplayObject; + + it('Module exists', function () { + expect(DisplayObject).to.be.a('function'); + // expect(PIXI).to.have.property('visibleCount', 0); + }); + + it('Confirm new instance', function () { + var obj = new DisplayObject(); + + pixi_display_DisplayObject_confirmNew(obj); + expect(obj).to.have.property('hitArea', null); + expect(obj).to.have.property('interactive', false); + expect(obj).to.have.property('renderable', false); + expect(obj).to.have.property('stage', null); + }); +}); diff --git a/test/unit/pixi-v2/display/DisplayObjectContainer.js b/test/unit/pixi-v2/display/DisplayObjectContainer.js new file mode 100644 index 0000000..15a3376 --- /dev/null +++ b/test/unit/pixi-v2/display/DisplayObjectContainer.js @@ -0,0 +1,67 @@ +describe('pixi/display/DisplayObjectContainer', function () { + 'use strict'; + + var expect = chai.expect; + var DisplayObjectContainer = PIXI.DisplayObjectContainer; + + it('Module exists', function () { + expect(DisplayObjectContainer).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new DisplayObjectContainer(); + + pixi_display_DisplayObjectContainer_confirmNew(obj); + expect(obj).to.have.property('hitArea', null); + expect(obj).to.have.property('interactive', false); + expect(obj).to.have.property('renderable', false); + expect(obj).to.have.property('stage', null); + }); + + it('Gets child index', function() { + var container = new PIXI.DisplayObjectContainer(); + var children = []; + for (var i = 0; i < 10; i++) { + var child = new PIXI.DisplayObject(); + children.push(child); + container.addChild(child); + } + + for (i = 0; i < children.length; i++) { + expect(i).to.eql(container.getChildIndex(children[i])); + } + }); + + it('throws error when trying to get index of not a child', function() { + var container = new PIXI.DisplayObjectContainer(); + var child = new PIXI.DisplayObject(); + + expect(function() { container.getChildIndex(child); }).to.throw(); + }); + + it('Sets child index', function() { + var container = new PIXI.DisplayObjectContainer(); + var children = []; + + for (var i = 0; i < 10; i++) { + var child = new PIXI.DisplayObject(); + children.push(child); + container.addChild(child); + } + children.reverse(); + + for (i = 0; i < children.length; i++) { + container.setChildIndex(children[i], i); + expect(i).to.eql(container.getChildIndex(children[i])); + } + }); + + it('throws error when trying to set incorect index', function() { + var container = new PIXI.DisplayObjectContainer(); + var child = new PIXI.DisplayObject(); + container.addChild(child); + + expect(function() { container.setChildIndex(child, -1); }).to.throw(); + expect(function() { container.setChildIndex(child, 1); }).to.throw(); + }); +}); diff --git a/test/unit/pixi-v2/display/MovieClip.js b/test/unit/pixi-v2/display/MovieClip.js new file mode 100644 index 0000000..f3c6c6a --- /dev/null +++ b/test/unit/pixi-v2/display/MovieClip.js @@ -0,0 +1,33 @@ +describe('pixi/display/MovieClip', function () { + 'use strict'; + + var expect = chai.expect; + var MovieClip = PIXI.MovieClip; + var Texture = PIXI.Texture; + + it('Module exists', function () { + expect(MovieClip).to.be.a('function'); + }); + + it('Confirm new instance', function (done) { + var texture = Texture.fromImage('/base/test/textures/SpriteSheet-Explosion.png'); + var obj = new MovieClip([texture]); + + pixi_display_Sprite_confirmNew(obj, done); + + expect(obj).to.be.an.instanceof(MovieClip); + expect(obj).to.respondTo('stop'); + expect(obj).to.respondTo('play'); + expect(obj).to.respondTo('gotoAndStop'); + expect(obj).to.respondTo('gotoAndPlay'); + expect(obj).to.respondTo('updateTransform'); + + expect(obj).to.have.deep.property('textures.length', 1); + expect(obj).to.have.deep.property('textures[0]', texture); + expect(obj).to.have.property('animationSpeed', 1); + expect(obj).to.have.property('loop', true); + expect(obj).to.have.property('onComplete', null); + expect(obj).to.have.property('currentFrame', 0); + expect(obj).to.have.property('playing', false); + }); +}); diff --git a/test/unit/pixi-v2/display/Sprite.js b/test/unit/pixi-v2/display/Sprite.js new file mode 100644 index 0000000..30c8076 --- /dev/null +++ b/test/unit/pixi-v2/display/Sprite.js @@ -0,0 +1,28 @@ +describe('pixi/display/Sprite', function () { + 'use strict'; + + var expect = chai.expect; + var Sprite = PIXI.Sprite; + var Texture = PIXI.Texture; + + it('Module exists', function () { + expect(Sprite).to.be.a('function'); + expect(PIXI).to.have.deep.property('blendModes.NORMAL', 0); + expect(PIXI).to.have.deep.property('blendModes.ADD', 1); + expect(PIXI).to.have.deep.property('blendModes.MULTIPLY', 2); + expect(PIXI).to.have.deep.property('blendModes.SCREEN', 3); + }); + + + it('Members exist', function () { + expect(Sprite).itself.to.respondTo('fromImage'); + expect(Sprite).itself.to.respondTo('fromFrame'); + }); + + it('Confirm new instance', function (done) { + var texture = Texture.fromImage('/base/test/textures/SpriteSheet-Aliens.png'); + var obj = new Sprite(texture); + + pixi_display_Sprite_confirmNew(obj, done); + }); +}); diff --git a/test/unit/pixi-v2/display/Stage.js b/test/unit/pixi-v2/display/Stage.js new file mode 100644 index 0000000..6974c2e --- /dev/null +++ b/test/unit/pixi-v2/display/Stage.js @@ -0,0 +1,49 @@ +describe('pixi/display/Stage', function () { + 'use strict'; + + var expect = chai.expect; + var Stage = PIXI.Stage; + var InteractionManager = PIXI.InteractionManager; + var Rectangle = PIXI.Rectangle; + + it('Module exists', function () { + expect(Stage).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Stage(null, true); + + pixi_display_DisplayObjectContainer_confirmNew(obj); + + expect(obj).to.be.an.instanceof(Stage); + expect(obj).to.respondTo('updateTransform'); + expect(obj).to.respondTo('setBackgroundColor'); + expect(obj).to.respondTo('getMousePosition'); + // FIXME: duplicate member in DisplayObject + pixi_core_Matrix_confirmNewMatrix(obj.worldTransform); + // FIXME: convert arg to bool in constructor + expect(obj).to.have.property('interactive', true); + + expect(obj).to.have.property('interactionManager') + .and.to.be.an.instanceof(InteractionManager) + .and.to.have.property('stage', obj); + + expect(obj).to.have.property('dirty', true); + + expect(obj).to.have.property('stage', obj); + + expect(obj).to.have.property('hitArea') + .and.to.be.an.instanceof(Rectangle); + pixi_core_Rectangle_confirm(obj.hitArea, 0, 0, 100000, 100000); + + expect(obj).to.have.property('backgroundColor', 0x000000); + expect(obj).to.have.deep.property('backgroundColorSplit.length', 3); + expect(obj).to.have.deep.property('backgroundColorSplit[0]', 0); + expect(obj).to.have.deep.property('backgroundColorSplit[1]', 0); + expect(obj).to.have.deep.property('backgroundColorSplit[2]', 0); + expect(obj).to.have.property('backgroundColorString', '#000000'); + + + expect(obj).to.have.property('worldVisible', true); + }); +}); diff --git a/test/unit/pixi-v2/extras/Rope.js b/test/unit/pixi-v2/extras/Rope.js new file mode 100644 index 0000000..05885ac --- /dev/null +++ b/test/unit/pixi-v2/extras/Rope.js @@ -0,0 +1,31 @@ +describe('pixi/extras/Rope', function () { + 'use strict'; + + var expect = chai.expect; + var Rope = PIXI.Rope; + var Texture = PIXI.Texture; + var Point = PIXI.Point; + + it('Module exists', function () { + expect(Rope).to.be.a('function'); + }); + + it('Confirm new instance', function () { + + var texture = Texture.fromImage('/base/test/textures/bunny.png'); + + // TODO-Alvin + // Same as Strip + + // var obj = new Rope(texture, [new Point(), new Point(5, 10), new Point(10, 20)]); + + // pixi_extras_Strip_confirmNew(obj); + + // expect(obj).to.be.an.instanceof(Rope); + // expect(obj).to.respondTo('refresh'); + // expect(obj).to.respondTo('updateTransform'); + // expect(obj).to.respondTo('setTexture'); + + // TODO: Test properties + }); +}); diff --git a/test/unit/pixi-v2/extras/Spine.js b/test/unit/pixi-v2/extras/Spine.js new file mode 100644 index 0000000..0708bc0 --- /dev/null +++ b/test/unit/pixi-v2/extras/Spine.js @@ -0,0 +1,10 @@ +describe('pixi/extras/Spine', function () { + 'use strict'; + + var expect = chai.expect; + var Spine = PIXI.Spine; + + it('Module exists', function () { + expect(Spine).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/extras/Strip.js b/test/unit/pixi-v2/extras/Strip.js new file mode 100644 index 0000000..230af90 --- /dev/null +++ b/test/unit/pixi-v2/extras/Strip.js @@ -0,0 +1,26 @@ +describe('pixi/extras/Strip', function () { + 'use strict'; + + var expect = chai.expect; + var Strip = PIXI.Strip; + var Texture = PIXI.Texture; + + it('Module exists', function () { + expect(Strip).to.be.a('function'); + }); + + it('Confirm new instance', function () { + + + // TODO-Alvin + // We tweaked it to make it pass the tests, but the whole strip class needs + // to be re-coded + + var texture = Texture.fromImage('/base/test/textures/bunny.png'); + + // var obj = new Strip(texture, 20, 10000); + + + // pixi_extras_Strip_confirmNew(obj); + }); +}); diff --git a/test/unit/pixi-v2/extras/TilingSprite.js b/test/unit/pixi-v2/extras/TilingSprite.js new file mode 100644 index 0000000..56aea14 --- /dev/null +++ b/test/unit/pixi-v2/extras/TilingSprite.js @@ -0,0 +1,24 @@ +describe('pixi/extras/TilingSprite', function () { + 'use strict'; + + var expect = chai.expect; + var TilingSprite = PIXI.TilingSprite; + var Texture = PIXI.Texture; + + it('Module exists', function () { + expect(TilingSprite).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var texture = Texture.fromImage('/base/test/textures/bunny.png'); + var obj = new TilingSprite(texture, 6000, 12000); + + pixi_display_DisplayObjectContainer_confirmNew(obj); + + expect(obj).to.be.an.instanceof(TilingSprite); + expect(obj).to.respondTo('setTexture'); + expect(obj).to.respondTo('onTextureUpdate'); + + // TODO: Test properties + }); +}); diff --git a/test/unit/pixi-v2/filters/FilterBlock.js b/test/unit/pixi-v2/filters/FilterBlock.js new file mode 100644 index 0000000..870cec0 --- /dev/null +++ b/test/unit/pixi-v2/filters/FilterBlock.js @@ -0,0 +1,10 @@ +describe('pixi/filters/FilterBlock', function () { + 'use strict'; + + var expect = chai.expect; + var FilterBlock = PIXI.FilterBlock; + + it('Module exists', function () { + expect(FilterBlock).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/AssetLoader.js b/test/unit/pixi-v2/loaders/AssetLoader.js new file mode 100644 index 0000000..a0aa0b5 --- /dev/null +++ b/test/unit/pixi-v2/loaders/AssetLoader.js @@ -0,0 +1,10 @@ +describe('pixi/loaders/AssetLoader', function () { + 'use strict'; + + var expect = chai.expect; + var AssetLoader = PIXI.AssetLoader; + + it('Module exists', function () { + expect(AssetLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/BitmapFontLoader.js b/test/unit/pixi-v2/loaders/BitmapFontLoader.js new file mode 100644 index 0000000..046f018 --- /dev/null +++ b/test/unit/pixi-v2/loaders/BitmapFontLoader.js @@ -0,0 +1,9 @@ +describe('pixi/loaders/BitmapFontLoader', function () { + 'use strict'; + + var expect = chai.expect; + + it('Module exists', function () { + expect(PIXI.BitmapFontLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/ImageLoader.js b/test/unit/pixi-v2/loaders/ImageLoader.js new file mode 100644 index 0000000..8b1f556 --- /dev/null +++ b/test/unit/pixi-v2/loaders/ImageLoader.js @@ -0,0 +1,10 @@ +describe('pixi/loaders/ImageLoader', function () { + 'use strict'; + + var expect = chai.expect; + var ImageLoader = PIXI.ImageLoader; + + it('Module exists', function () { + expect(ImageLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/JsonLoader.js b/test/unit/pixi-v2/loaders/JsonLoader.js new file mode 100644 index 0000000..c577e83 --- /dev/null +++ b/test/unit/pixi-v2/loaders/JsonLoader.js @@ -0,0 +1,10 @@ +describe('pixi/loaders/JsonLoader', function () { + 'use strict'; + + var expect = chai.expect; + var JsonLoader = PIXI.JsonLoader; + + it('Module exists', function () { + expect(JsonLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/SpineLoader.js b/test/unit/pixi-v2/loaders/SpineLoader.js new file mode 100644 index 0000000..fdcc0b8 --- /dev/null +++ b/test/unit/pixi-v2/loaders/SpineLoader.js @@ -0,0 +1,10 @@ +describe('pixi/loaders/SpineLoader', function () { + 'use strict'; + + var expect = chai.expect; + var SpineLoader = PIXI.SpineLoader; + + it('Module exists', function () { + expect(SpineLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/SpriteSheetLoader.js b/test/unit/pixi-v2/loaders/SpriteSheetLoader.js new file mode 100644 index 0000000..57beb27 --- /dev/null +++ b/test/unit/pixi-v2/loaders/SpriteSheetLoader.js @@ -0,0 +1,10 @@ +describe('pixi/loaders/SpriteSheetLoader', function () { + 'use strict'; + + var expect = chai.expect; + var SpriteSheetLoader = PIXI.SpriteSheetLoader; + + it('Module exists', function () { + expect(SpriteSheetLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/primitives/Graphics.js b/test/unit/pixi-v2/primitives/Graphics.js new file mode 100644 index 0000000..f3849eb --- /dev/null +++ b/test/unit/pixi-v2/primitives/Graphics.js @@ -0,0 +1,44 @@ +describe('pixi/primitives/Graphics', function () { + 'use strict'; + + var expect = chai.expect; + var Graphics = PIXI.Graphics; + + it('Module exists', function () { + expect(Graphics).to.be.a('function'); + + expect(Graphics).itself.to.have.property('POLY', 0); + expect(Graphics).itself.to.have.property('RECT', 1); + expect(Graphics).itself.to.have.property('CIRC', 2); + expect(Graphics).itself.to.have.property('ELIP', 3); + expect(Graphics).itself.to.have.property('RREC', 4); + }); + + it('Confirm new instance', function () { + var obj = new Graphics(); + + pixi_display_DisplayObjectContainer_confirmNew(obj); + + expect(obj).to.be.an.instanceof(Graphics); + expect(obj).to.respondTo('lineStyle'); + expect(obj).to.respondTo('lineStyle'); + expect(obj).to.respondTo('moveTo'); + expect(obj).to.respondTo('lineTo'); + expect(obj).to.respondTo('beginFill'); + expect(obj).to.respondTo('endFill'); + expect(obj).to.respondTo('drawRect'); + // expect(obj).to.respondTo('drawRoundedRect'); + expect(obj).to.respondTo('drawCircle'); + expect(obj).to.respondTo('drawEllipse'); + expect(obj).to.respondTo('clear'); + + expect(obj).to.have.property('renderable', true); + expect(obj).to.have.property('fillAlpha', 1); + expect(obj).to.have.property('lineWidth', 0); + expect(obj).to.have.property('width', 0); + expect(obj).to.have.property('height', 0); + expect(obj).to.have.property('lineColor', 0); + expect(obj).to.have.deep.property('graphicsData.length', 0); + // expect(obj).to.have.deep.property('currentPath.points.length', 0); + }); +}); diff --git a/test/unit/pixi-v2/renderers/canvas/CanvasGraphics.js b/test/unit/pixi-v2/renderers/canvas/CanvasGraphics.js new file mode 100644 index 0000000..8f44472 --- /dev/null +++ b/test/unit/pixi-v2/renderers/canvas/CanvasGraphics.js @@ -0,0 +1,15 @@ +describe('renders/canvas/CanvasGraphics', function () { + 'use strict'; + + var expect = chai.expect; + var CanvasGraphics = PIXI.CanvasGraphics; + + it('Module exists', function () { + expect(CanvasGraphics).to.be.a('function'); + }); + + it('Members exist', function () { + expect(CanvasGraphics).itself.to.respondTo('renderGraphics'); + expect(CanvasGraphics).itself.to.respondTo('renderGraphicsMask'); + }); +}); diff --git a/test/unit/pixi-v2/renderers/canvas/CanvasRenderer.js b/test/unit/pixi-v2/renderers/canvas/CanvasRenderer.js new file mode 100644 index 0000000..1646444 --- /dev/null +++ b/test/unit/pixi-v2/renderers/canvas/CanvasRenderer.js @@ -0,0 +1,36 @@ +describe('renderers/canvas/CanvasRenderer', function () { + 'use strict'; + + var expect = chai.expect; + var CanvasRenderer = PIXI.CanvasRenderer; + + it('Module exists', function () { + expect(CanvasRenderer).to.be.a('function'); + }); + + describe('.autoResize', function () { + it('Should automatically resize view if enabled', function () { + var renderer = new CanvasRenderer(200, 200, { + autoResize: true + }); + + expect(renderer.view.style.width).to.equal('200px'); + }); + + it('Should not automatically resize view if disabled', function () { + var renderer = new CanvasRenderer(200, 200, { + autoResize: false + }); + + expect(renderer.view.style.width).to.equal(''); + }); + + it('Should not automatically resize view if not specified', function () { + var renderer = new CanvasRenderer(200, 200, { + resolution: 2 + }); + + expect(renderer.view.style.width).to.equal(''); + }); + }); +}); diff --git a/test/unit/pixi-v2/renderers/webgl/WebGLGraphics.js b/test/unit/pixi-v2/renderers/webgl/WebGLGraphics.js new file mode 100644 index 0000000..5867b28 --- /dev/null +++ b/test/unit/pixi-v2/renderers/webgl/WebGLGraphics.js @@ -0,0 +1,20 @@ +describe('renderers/wegbl/WebGLGraphics', function () { + 'use strict'; + + var expect = chai.expect; + var WebGLGraphics = PIXI.WebGLGraphics; + + it('Module exists', function () { + expect(WebGLGraphics).to.be.a('function'); + }); + + it('Members exist', function () { + expect(WebGLGraphics).itself.to.respondTo('renderGraphics'); + expect(WebGLGraphics).itself.to.respondTo('updateGraphics'); + expect(WebGLGraphics).itself.to.respondTo('buildRectangle'); + expect(WebGLGraphics).itself.to.respondTo('buildRoundedRectangle'); + expect(WebGLGraphics).itself.to.respondTo('buildCircle'); + expect(WebGLGraphics).itself.to.respondTo('buildLine'); + expect(WebGLGraphics).itself.to.respondTo('buildPoly'); + }); +}); diff --git a/test/unit/pixi-v2/renderers/webgl/WebGLRenderer.js b/test/unit/pixi-v2/renderers/webgl/WebGLRenderer.js new file mode 100644 index 0000000..1680a80 --- /dev/null +++ b/test/unit/pixi-v2/renderers/webgl/WebGLRenderer.js @@ -0,0 +1,49 @@ +describe('renderers/webgl/WebGLRenderer', function () { + 'use strict'; + + var expect = chai.expect; + var WebGLRenderer = PIXI.WebGLRenderer; + + it('Module exists', function () { + expect(WebGLRenderer).to.be.a('function'); + }); + + // Skip tests if WebGL is not available (WebGL not supported in Travis CI) + try { + var renderer = new WebGLRenderer(400, 300, {}); + renderer.destroy(); + } catch (error) { + return; + } + + it('Destroy renderer', function () { + var renderer = new WebGLRenderer(400, 300, {}); + renderer.destroy(); + }); + + describe('.autoResize', function () { + it('Should automatically resize view if enabled', function () { + var renderer = new WebGLRenderer(200, 200, { + autoResize: true + }); + + expect(renderer.view.style.width).to.equal('200px'); + }); + + it('Should not automatically resize view if disabled', function () { + var renderer = new WebGLRenderer(200, 200, { + autoResize: false + }); + + expect(renderer.view.style.width).to.equal(''); + }); + + it('Should not automatically resize view if not specified', function () { + var renderer = new WebGLRenderer(200, 200, { + resolution: 2 + }); + + expect(renderer.view.style.width).to.equal(''); + }); + }); +}); diff --git a/test/unit/pixi-v2/renderers/webgl/WebGLShaders.js b/test/unit/pixi-v2/renderers/webgl/WebGLShaders.js new file mode 100644 index 0000000..6e33e4f --- /dev/null +++ b/test/unit/pixi-v2/renderers/webgl/WebGLShaders.js @@ -0,0 +1,13 @@ +describe('renderers/webgl/WebGLShaders', function () { + 'use strict'; + + var expect = chai.expect; + + it('Module members exist', function () { + + expect(PIXI).to.respondTo('CompileVertexShader'); + expect(PIXI).to.respondTo('CompileFragmentShader'); + expect(PIXI).to.respondTo('_CompileShader'); + expect(PIXI).to.respondTo('compileProgram'); + }); +}); diff --git a/test/unit/pixi-v2/renderers/webgl/WebGLSpriteBatch.js b/test/unit/pixi-v2/renderers/webgl/WebGLSpriteBatch.js new file mode 100644 index 0000000..e662b63 --- /dev/null +++ b/test/unit/pixi-v2/renderers/webgl/WebGLSpriteBatch.js @@ -0,0 +1,10 @@ +describe('renderers/webgl/utils/WebGLSpriteBatch', function () { + 'use strict'; + + var expect = chai.expect; + var WebGLSpriteBatch = PIXI.WebGLSpriteBatch; + + it('Module exists', function () { + expect(WebGLSpriteBatch).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/text/BitmapText.js b/test/unit/pixi-v2/text/BitmapText.js new file mode 100644 index 0000000..9388e3d --- /dev/null +++ b/test/unit/pixi-v2/text/BitmapText.js @@ -0,0 +1,10 @@ +describe('pixi/text/BitmapText', function () { + 'use strict'; + + var expect = chai.expect; + var BitmapText = PIXI.BitmapText; + + it('Module exists', function () { + expect(BitmapText).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/text/Text.js b/test/unit/pixi-v2/text/Text.js new file mode 100644 index 0000000..9bc9ac5 --- /dev/null +++ b/test/unit/pixi-v2/text/Text.js @@ -0,0 +1,10 @@ +describe('pixi/text/Text', function () { + 'use strict'; + + var expect = chai.expect; + var Text = PIXI.Text; + + it('Module exists', function () { + expect(Text).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/InteractionManager.js b/test/unit/pixi-v2/InteractionManager.js new file mode 100644 index 0000000..ed3001f --- /dev/null +++ b/test/unit/pixi-v2/InteractionManager.js @@ -0,0 +1,10 @@ +describe('pixi/InteractionManager', function () { + 'use strict'; + + var expect = chai.expect; + var InteractionManager = PIXI.InteractionManager; + + it('Module exists', function () { + expect(InteractionManager).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/Pixi.js b/test/unit/pixi-v2/Pixi.js new file mode 100644 index 0000000..27debc1 --- /dev/null +++ b/test/unit/pixi-v2/Pixi.js @@ -0,0 +1,9 @@ +describe('pixi/Pixi', function () { + 'use strict'; + + var expect = chai.expect; + + it('Module exists', function () { + expect(global).to.have.property('PIXI').and.to.be.an('object'); + }); +}); diff --git a/test/unit/pixi-v2/core/Circle.js b/test/unit/pixi-v2/core/Circle.js new file mode 100644 index 0000000..fbcfa17 --- /dev/null +++ b/test/unit/pixi-v2/core/Circle.js @@ -0,0 +1,21 @@ +describe('pixi/core/Circle', function () { + 'use strict'; + + var expect = chai.expect; + var Circle = PIXI.Circle; + + it('Module exists', function () { + expect(Circle).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Circle(); + pixi_core_Circle_confirmNewCircle(obj); + }); + + it("getBounds should return Rectangle that bounds the circle", function() { + var obj = new Circle(100, 250, 50); + var bounds = obj.getBounds(); + pixi_core_Circle_isBoundedByRectangle(obj, bounds); + }); +}); diff --git a/test/unit/pixi-v2/core/Ellipse.js b/test/unit/pixi-v2/core/Ellipse.js new file mode 100644 index 0000000..026b56f --- /dev/null +++ b/test/unit/pixi-v2/core/Ellipse.js @@ -0,0 +1,24 @@ +describe('pixi/core/Ellipse', function () { + 'use strict'; + + var expect = chai.expect; + var Ellipse = PIXI.Ellipse; + + it('Module exists', function () { + expect(Ellipse).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Ellipse(); + + expect(obj).to.be.an.instanceof(Ellipse); + expect(obj).to.respondTo('clone'); + expect(obj).to.respondTo('contains'); + expect(obj).to.respondTo('getBounds'); + + expect(obj).to.have.property('x', 0); + expect(obj).to.have.property('y', 0); + expect(obj).to.have.property('width', 0); + expect(obj).to.have.property('height', 0); + }); +}); diff --git a/test/unit/pixi-v2/core/Matrix.js b/test/unit/pixi-v2/core/Matrix.js new file mode 100644 index 0000000..da75e2e --- /dev/null +++ b/test/unit/pixi-v2/core/Matrix.js @@ -0,0 +1,14 @@ +describe('pixi/core/Matrix', function () { + 'use strict'; + + var expect = chai.expect; + + it('Matrix exists', function () { + expect(PIXI.Matrix).to.be.an('function'); + }); + + it('Confirm new Matrix', function () { + var matrix = new PIXI.Matrix(); + pixi_core_Matrix_confirmNewMatrix(matrix); + }); +}); diff --git a/test/unit/pixi-v2/core/Point.js b/test/unit/pixi-v2/core/Point.js new file mode 100644 index 0000000..c4d5163 --- /dev/null +++ b/test/unit/pixi-v2/core/Point.js @@ -0,0 +1,15 @@ +describe('pixi/core/Point', function () { + 'use strict'; + + var expect = chai.expect; + var Point = PIXI.Point; + + it('Module exists', function () { + expect(Point).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Point(); + pixi_core_Point_confirm(obj, 0, 0); + }); +}); diff --git a/test/unit/pixi-v2/core/Polygon.js b/test/unit/pixi-v2/core/Polygon.js new file mode 100644 index 0000000..dc8c918 --- /dev/null +++ b/test/unit/pixi-v2/core/Polygon.js @@ -0,0 +1,20 @@ +describe('pixi/core/Polygon', function () { + 'use strict'; + + var expect = chai.expect; + var Polygon = PIXI.Polygon; + + it('Module exists', function () { + expect(Polygon).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Polygon(); + + expect(obj).to.be.an.instanceof(Polygon); + expect(obj).to.respondTo('clone'); + expect(obj).to.respondTo('contains'); + + expect(obj).to.have.deep.property('points.length', 0); + }); +}); diff --git a/test/unit/pixi-v2/core/Rectangle.js b/test/unit/pixi-v2/core/Rectangle.js new file mode 100644 index 0000000..d43316e --- /dev/null +++ b/test/unit/pixi-v2/core/Rectangle.js @@ -0,0 +1,15 @@ +describe('pixi/core/Rectangle', function () { + 'use strict'; + + var expect = chai.expect; + var Rectangle = PIXI.Rectangle; + + it('Module exists', function () { + expect(Rectangle).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var rect = new Rectangle(); + pixi_core_Rectangle_confirm(rect, 0, 0, 0, 0); + }); +}); diff --git a/test/unit/pixi-v2/display/DisplayObject.js b/test/unit/pixi-v2/display/DisplayObject.js new file mode 100644 index 0000000..044acf8 --- /dev/null +++ b/test/unit/pixi-v2/display/DisplayObject.js @@ -0,0 +1,21 @@ +describe('pixi/display/DisplayObject', function () { + 'use strict'; + + var expect = chai.expect; + var DisplayObject = PIXI.DisplayObject; + + it('Module exists', function () { + expect(DisplayObject).to.be.a('function'); + // expect(PIXI).to.have.property('visibleCount', 0); + }); + + it('Confirm new instance', function () { + var obj = new DisplayObject(); + + pixi_display_DisplayObject_confirmNew(obj); + expect(obj).to.have.property('hitArea', null); + expect(obj).to.have.property('interactive', false); + expect(obj).to.have.property('renderable', false); + expect(obj).to.have.property('stage', null); + }); +}); diff --git a/test/unit/pixi-v2/display/DisplayObjectContainer.js b/test/unit/pixi-v2/display/DisplayObjectContainer.js new file mode 100644 index 0000000..15a3376 --- /dev/null +++ b/test/unit/pixi-v2/display/DisplayObjectContainer.js @@ -0,0 +1,67 @@ +describe('pixi/display/DisplayObjectContainer', function () { + 'use strict'; + + var expect = chai.expect; + var DisplayObjectContainer = PIXI.DisplayObjectContainer; + + it('Module exists', function () { + expect(DisplayObjectContainer).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new DisplayObjectContainer(); + + pixi_display_DisplayObjectContainer_confirmNew(obj); + expect(obj).to.have.property('hitArea', null); + expect(obj).to.have.property('interactive', false); + expect(obj).to.have.property('renderable', false); + expect(obj).to.have.property('stage', null); + }); + + it('Gets child index', function() { + var container = new PIXI.DisplayObjectContainer(); + var children = []; + for (var i = 0; i < 10; i++) { + var child = new PIXI.DisplayObject(); + children.push(child); + container.addChild(child); + } + + for (i = 0; i < children.length; i++) { + expect(i).to.eql(container.getChildIndex(children[i])); + } + }); + + it('throws error when trying to get index of not a child', function() { + var container = new PIXI.DisplayObjectContainer(); + var child = new PIXI.DisplayObject(); + + expect(function() { container.getChildIndex(child); }).to.throw(); + }); + + it('Sets child index', function() { + var container = new PIXI.DisplayObjectContainer(); + var children = []; + + for (var i = 0; i < 10; i++) { + var child = new PIXI.DisplayObject(); + children.push(child); + container.addChild(child); + } + children.reverse(); + + for (i = 0; i < children.length; i++) { + container.setChildIndex(children[i], i); + expect(i).to.eql(container.getChildIndex(children[i])); + } + }); + + it('throws error when trying to set incorect index', function() { + var container = new PIXI.DisplayObjectContainer(); + var child = new PIXI.DisplayObject(); + container.addChild(child); + + expect(function() { container.setChildIndex(child, -1); }).to.throw(); + expect(function() { container.setChildIndex(child, 1); }).to.throw(); + }); +}); diff --git a/test/unit/pixi-v2/display/MovieClip.js b/test/unit/pixi-v2/display/MovieClip.js new file mode 100644 index 0000000..f3c6c6a --- /dev/null +++ b/test/unit/pixi-v2/display/MovieClip.js @@ -0,0 +1,33 @@ +describe('pixi/display/MovieClip', function () { + 'use strict'; + + var expect = chai.expect; + var MovieClip = PIXI.MovieClip; + var Texture = PIXI.Texture; + + it('Module exists', function () { + expect(MovieClip).to.be.a('function'); + }); + + it('Confirm new instance', function (done) { + var texture = Texture.fromImage('/base/test/textures/SpriteSheet-Explosion.png'); + var obj = new MovieClip([texture]); + + pixi_display_Sprite_confirmNew(obj, done); + + expect(obj).to.be.an.instanceof(MovieClip); + expect(obj).to.respondTo('stop'); + expect(obj).to.respondTo('play'); + expect(obj).to.respondTo('gotoAndStop'); + expect(obj).to.respondTo('gotoAndPlay'); + expect(obj).to.respondTo('updateTransform'); + + expect(obj).to.have.deep.property('textures.length', 1); + expect(obj).to.have.deep.property('textures[0]', texture); + expect(obj).to.have.property('animationSpeed', 1); + expect(obj).to.have.property('loop', true); + expect(obj).to.have.property('onComplete', null); + expect(obj).to.have.property('currentFrame', 0); + expect(obj).to.have.property('playing', false); + }); +}); diff --git a/test/unit/pixi-v2/display/Sprite.js b/test/unit/pixi-v2/display/Sprite.js new file mode 100644 index 0000000..30c8076 --- /dev/null +++ b/test/unit/pixi-v2/display/Sprite.js @@ -0,0 +1,28 @@ +describe('pixi/display/Sprite', function () { + 'use strict'; + + var expect = chai.expect; + var Sprite = PIXI.Sprite; + var Texture = PIXI.Texture; + + it('Module exists', function () { + expect(Sprite).to.be.a('function'); + expect(PIXI).to.have.deep.property('blendModes.NORMAL', 0); + expect(PIXI).to.have.deep.property('blendModes.ADD', 1); + expect(PIXI).to.have.deep.property('blendModes.MULTIPLY', 2); + expect(PIXI).to.have.deep.property('blendModes.SCREEN', 3); + }); + + + it('Members exist', function () { + expect(Sprite).itself.to.respondTo('fromImage'); + expect(Sprite).itself.to.respondTo('fromFrame'); + }); + + it('Confirm new instance', function (done) { + var texture = Texture.fromImage('/base/test/textures/SpriteSheet-Aliens.png'); + var obj = new Sprite(texture); + + pixi_display_Sprite_confirmNew(obj, done); + }); +}); diff --git a/test/unit/pixi-v2/display/Stage.js b/test/unit/pixi-v2/display/Stage.js new file mode 100644 index 0000000..6974c2e --- /dev/null +++ b/test/unit/pixi-v2/display/Stage.js @@ -0,0 +1,49 @@ +describe('pixi/display/Stage', function () { + 'use strict'; + + var expect = chai.expect; + var Stage = PIXI.Stage; + var InteractionManager = PIXI.InteractionManager; + var Rectangle = PIXI.Rectangle; + + it('Module exists', function () { + expect(Stage).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Stage(null, true); + + pixi_display_DisplayObjectContainer_confirmNew(obj); + + expect(obj).to.be.an.instanceof(Stage); + expect(obj).to.respondTo('updateTransform'); + expect(obj).to.respondTo('setBackgroundColor'); + expect(obj).to.respondTo('getMousePosition'); + // FIXME: duplicate member in DisplayObject + pixi_core_Matrix_confirmNewMatrix(obj.worldTransform); + // FIXME: convert arg to bool in constructor + expect(obj).to.have.property('interactive', true); + + expect(obj).to.have.property('interactionManager') + .and.to.be.an.instanceof(InteractionManager) + .and.to.have.property('stage', obj); + + expect(obj).to.have.property('dirty', true); + + expect(obj).to.have.property('stage', obj); + + expect(obj).to.have.property('hitArea') + .and.to.be.an.instanceof(Rectangle); + pixi_core_Rectangle_confirm(obj.hitArea, 0, 0, 100000, 100000); + + expect(obj).to.have.property('backgroundColor', 0x000000); + expect(obj).to.have.deep.property('backgroundColorSplit.length', 3); + expect(obj).to.have.deep.property('backgroundColorSplit[0]', 0); + expect(obj).to.have.deep.property('backgroundColorSplit[1]', 0); + expect(obj).to.have.deep.property('backgroundColorSplit[2]', 0); + expect(obj).to.have.property('backgroundColorString', '#000000'); + + + expect(obj).to.have.property('worldVisible', true); + }); +}); diff --git a/test/unit/pixi-v2/extras/Rope.js b/test/unit/pixi-v2/extras/Rope.js new file mode 100644 index 0000000..05885ac --- /dev/null +++ b/test/unit/pixi-v2/extras/Rope.js @@ -0,0 +1,31 @@ +describe('pixi/extras/Rope', function () { + 'use strict'; + + var expect = chai.expect; + var Rope = PIXI.Rope; + var Texture = PIXI.Texture; + var Point = PIXI.Point; + + it('Module exists', function () { + expect(Rope).to.be.a('function'); + }); + + it('Confirm new instance', function () { + + var texture = Texture.fromImage('/base/test/textures/bunny.png'); + + // TODO-Alvin + // Same as Strip + + // var obj = new Rope(texture, [new Point(), new Point(5, 10), new Point(10, 20)]); + + // pixi_extras_Strip_confirmNew(obj); + + // expect(obj).to.be.an.instanceof(Rope); + // expect(obj).to.respondTo('refresh'); + // expect(obj).to.respondTo('updateTransform'); + // expect(obj).to.respondTo('setTexture'); + + // TODO: Test properties + }); +}); diff --git a/test/unit/pixi-v2/extras/Spine.js b/test/unit/pixi-v2/extras/Spine.js new file mode 100644 index 0000000..0708bc0 --- /dev/null +++ b/test/unit/pixi-v2/extras/Spine.js @@ -0,0 +1,10 @@ +describe('pixi/extras/Spine', function () { + 'use strict'; + + var expect = chai.expect; + var Spine = PIXI.Spine; + + it('Module exists', function () { + expect(Spine).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/extras/Strip.js b/test/unit/pixi-v2/extras/Strip.js new file mode 100644 index 0000000..230af90 --- /dev/null +++ b/test/unit/pixi-v2/extras/Strip.js @@ -0,0 +1,26 @@ +describe('pixi/extras/Strip', function () { + 'use strict'; + + var expect = chai.expect; + var Strip = PIXI.Strip; + var Texture = PIXI.Texture; + + it('Module exists', function () { + expect(Strip).to.be.a('function'); + }); + + it('Confirm new instance', function () { + + + // TODO-Alvin + // We tweaked it to make it pass the tests, but the whole strip class needs + // to be re-coded + + var texture = Texture.fromImage('/base/test/textures/bunny.png'); + + // var obj = new Strip(texture, 20, 10000); + + + // pixi_extras_Strip_confirmNew(obj); + }); +}); diff --git a/test/unit/pixi-v2/extras/TilingSprite.js b/test/unit/pixi-v2/extras/TilingSprite.js new file mode 100644 index 0000000..56aea14 --- /dev/null +++ b/test/unit/pixi-v2/extras/TilingSprite.js @@ -0,0 +1,24 @@ +describe('pixi/extras/TilingSprite', function () { + 'use strict'; + + var expect = chai.expect; + var TilingSprite = PIXI.TilingSprite; + var Texture = PIXI.Texture; + + it('Module exists', function () { + expect(TilingSprite).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var texture = Texture.fromImage('/base/test/textures/bunny.png'); + var obj = new TilingSprite(texture, 6000, 12000); + + pixi_display_DisplayObjectContainer_confirmNew(obj); + + expect(obj).to.be.an.instanceof(TilingSprite); + expect(obj).to.respondTo('setTexture'); + expect(obj).to.respondTo('onTextureUpdate'); + + // TODO: Test properties + }); +}); diff --git a/test/unit/pixi-v2/filters/FilterBlock.js b/test/unit/pixi-v2/filters/FilterBlock.js new file mode 100644 index 0000000..870cec0 --- /dev/null +++ b/test/unit/pixi-v2/filters/FilterBlock.js @@ -0,0 +1,10 @@ +describe('pixi/filters/FilterBlock', function () { + 'use strict'; + + var expect = chai.expect; + var FilterBlock = PIXI.FilterBlock; + + it('Module exists', function () { + expect(FilterBlock).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/AssetLoader.js b/test/unit/pixi-v2/loaders/AssetLoader.js new file mode 100644 index 0000000..a0aa0b5 --- /dev/null +++ b/test/unit/pixi-v2/loaders/AssetLoader.js @@ -0,0 +1,10 @@ +describe('pixi/loaders/AssetLoader', function () { + 'use strict'; + + var expect = chai.expect; + var AssetLoader = PIXI.AssetLoader; + + it('Module exists', function () { + expect(AssetLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/BitmapFontLoader.js b/test/unit/pixi-v2/loaders/BitmapFontLoader.js new file mode 100644 index 0000000..046f018 --- /dev/null +++ b/test/unit/pixi-v2/loaders/BitmapFontLoader.js @@ -0,0 +1,9 @@ +describe('pixi/loaders/BitmapFontLoader', function () { + 'use strict'; + + var expect = chai.expect; + + it('Module exists', function () { + expect(PIXI.BitmapFontLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/ImageLoader.js b/test/unit/pixi-v2/loaders/ImageLoader.js new file mode 100644 index 0000000..8b1f556 --- /dev/null +++ b/test/unit/pixi-v2/loaders/ImageLoader.js @@ -0,0 +1,10 @@ +describe('pixi/loaders/ImageLoader', function () { + 'use strict'; + + var expect = chai.expect; + var ImageLoader = PIXI.ImageLoader; + + it('Module exists', function () { + expect(ImageLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/JsonLoader.js b/test/unit/pixi-v2/loaders/JsonLoader.js new file mode 100644 index 0000000..c577e83 --- /dev/null +++ b/test/unit/pixi-v2/loaders/JsonLoader.js @@ -0,0 +1,10 @@ +describe('pixi/loaders/JsonLoader', function () { + 'use strict'; + + var expect = chai.expect; + var JsonLoader = PIXI.JsonLoader; + + it('Module exists', function () { + expect(JsonLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/SpineLoader.js b/test/unit/pixi-v2/loaders/SpineLoader.js new file mode 100644 index 0000000..fdcc0b8 --- /dev/null +++ b/test/unit/pixi-v2/loaders/SpineLoader.js @@ -0,0 +1,10 @@ +describe('pixi/loaders/SpineLoader', function () { + 'use strict'; + + var expect = chai.expect; + var SpineLoader = PIXI.SpineLoader; + + it('Module exists', function () { + expect(SpineLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/SpriteSheetLoader.js b/test/unit/pixi-v2/loaders/SpriteSheetLoader.js new file mode 100644 index 0000000..57beb27 --- /dev/null +++ b/test/unit/pixi-v2/loaders/SpriteSheetLoader.js @@ -0,0 +1,10 @@ +describe('pixi/loaders/SpriteSheetLoader', function () { + 'use strict'; + + var expect = chai.expect; + var SpriteSheetLoader = PIXI.SpriteSheetLoader; + + it('Module exists', function () { + expect(SpriteSheetLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/primitives/Graphics.js b/test/unit/pixi-v2/primitives/Graphics.js new file mode 100644 index 0000000..f3849eb --- /dev/null +++ b/test/unit/pixi-v2/primitives/Graphics.js @@ -0,0 +1,44 @@ +describe('pixi/primitives/Graphics', function () { + 'use strict'; + + var expect = chai.expect; + var Graphics = PIXI.Graphics; + + it('Module exists', function () { + expect(Graphics).to.be.a('function'); + + expect(Graphics).itself.to.have.property('POLY', 0); + expect(Graphics).itself.to.have.property('RECT', 1); + expect(Graphics).itself.to.have.property('CIRC', 2); + expect(Graphics).itself.to.have.property('ELIP', 3); + expect(Graphics).itself.to.have.property('RREC', 4); + }); + + it('Confirm new instance', function () { + var obj = new Graphics(); + + pixi_display_DisplayObjectContainer_confirmNew(obj); + + expect(obj).to.be.an.instanceof(Graphics); + expect(obj).to.respondTo('lineStyle'); + expect(obj).to.respondTo('lineStyle'); + expect(obj).to.respondTo('moveTo'); + expect(obj).to.respondTo('lineTo'); + expect(obj).to.respondTo('beginFill'); + expect(obj).to.respondTo('endFill'); + expect(obj).to.respondTo('drawRect'); + // expect(obj).to.respondTo('drawRoundedRect'); + expect(obj).to.respondTo('drawCircle'); + expect(obj).to.respondTo('drawEllipse'); + expect(obj).to.respondTo('clear'); + + expect(obj).to.have.property('renderable', true); + expect(obj).to.have.property('fillAlpha', 1); + expect(obj).to.have.property('lineWidth', 0); + expect(obj).to.have.property('width', 0); + expect(obj).to.have.property('height', 0); + expect(obj).to.have.property('lineColor', 0); + expect(obj).to.have.deep.property('graphicsData.length', 0); + // expect(obj).to.have.deep.property('currentPath.points.length', 0); + }); +}); diff --git a/test/unit/pixi-v2/renderers/canvas/CanvasGraphics.js b/test/unit/pixi-v2/renderers/canvas/CanvasGraphics.js new file mode 100644 index 0000000..8f44472 --- /dev/null +++ b/test/unit/pixi-v2/renderers/canvas/CanvasGraphics.js @@ -0,0 +1,15 @@ +describe('renders/canvas/CanvasGraphics', function () { + 'use strict'; + + var expect = chai.expect; + var CanvasGraphics = PIXI.CanvasGraphics; + + it('Module exists', function () { + expect(CanvasGraphics).to.be.a('function'); + }); + + it('Members exist', function () { + expect(CanvasGraphics).itself.to.respondTo('renderGraphics'); + expect(CanvasGraphics).itself.to.respondTo('renderGraphicsMask'); + }); +}); diff --git a/test/unit/pixi-v2/renderers/canvas/CanvasRenderer.js b/test/unit/pixi-v2/renderers/canvas/CanvasRenderer.js new file mode 100644 index 0000000..1646444 --- /dev/null +++ b/test/unit/pixi-v2/renderers/canvas/CanvasRenderer.js @@ -0,0 +1,36 @@ +describe('renderers/canvas/CanvasRenderer', function () { + 'use strict'; + + var expect = chai.expect; + var CanvasRenderer = PIXI.CanvasRenderer; + + it('Module exists', function () { + expect(CanvasRenderer).to.be.a('function'); + }); + + describe('.autoResize', function () { + it('Should automatically resize view if enabled', function () { + var renderer = new CanvasRenderer(200, 200, { + autoResize: true + }); + + expect(renderer.view.style.width).to.equal('200px'); + }); + + it('Should not automatically resize view if disabled', function () { + var renderer = new CanvasRenderer(200, 200, { + autoResize: false + }); + + expect(renderer.view.style.width).to.equal(''); + }); + + it('Should not automatically resize view if not specified', function () { + var renderer = new CanvasRenderer(200, 200, { + resolution: 2 + }); + + expect(renderer.view.style.width).to.equal(''); + }); + }); +}); diff --git a/test/unit/pixi-v2/renderers/webgl/WebGLGraphics.js b/test/unit/pixi-v2/renderers/webgl/WebGLGraphics.js new file mode 100644 index 0000000..5867b28 --- /dev/null +++ b/test/unit/pixi-v2/renderers/webgl/WebGLGraphics.js @@ -0,0 +1,20 @@ +describe('renderers/wegbl/WebGLGraphics', function () { + 'use strict'; + + var expect = chai.expect; + var WebGLGraphics = PIXI.WebGLGraphics; + + it('Module exists', function () { + expect(WebGLGraphics).to.be.a('function'); + }); + + it('Members exist', function () { + expect(WebGLGraphics).itself.to.respondTo('renderGraphics'); + expect(WebGLGraphics).itself.to.respondTo('updateGraphics'); + expect(WebGLGraphics).itself.to.respondTo('buildRectangle'); + expect(WebGLGraphics).itself.to.respondTo('buildRoundedRectangle'); + expect(WebGLGraphics).itself.to.respondTo('buildCircle'); + expect(WebGLGraphics).itself.to.respondTo('buildLine'); + expect(WebGLGraphics).itself.to.respondTo('buildPoly'); + }); +}); diff --git a/test/unit/pixi-v2/renderers/webgl/WebGLRenderer.js b/test/unit/pixi-v2/renderers/webgl/WebGLRenderer.js new file mode 100644 index 0000000..1680a80 --- /dev/null +++ b/test/unit/pixi-v2/renderers/webgl/WebGLRenderer.js @@ -0,0 +1,49 @@ +describe('renderers/webgl/WebGLRenderer', function () { + 'use strict'; + + var expect = chai.expect; + var WebGLRenderer = PIXI.WebGLRenderer; + + it('Module exists', function () { + expect(WebGLRenderer).to.be.a('function'); + }); + + // Skip tests if WebGL is not available (WebGL not supported in Travis CI) + try { + var renderer = new WebGLRenderer(400, 300, {}); + renderer.destroy(); + } catch (error) { + return; + } + + it('Destroy renderer', function () { + var renderer = new WebGLRenderer(400, 300, {}); + renderer.destroy(); + }); + + describe('.autoResize', function () { + it('Should automatically resize view if enabled', function () { + var renderer = new WebGLRenderer(200, 200, { + autoResize: true + }); + + expect(renderer.view.style.width).to.equal('200px'); + }); + + it('Should not automatically resize view if disabled', function () { + var renderer = new WebGLRenderer(200, 200, { + autoResize: false + }); + + expect(renderer.view.style.width).to.equal(''); + }); + + it('Should not automatically resize view if not specified', function () { + var renderer = new WebGLRenderer(200, 200, { + resolution: 2 + }); + + expect(renderer.view.style.width).to.equal(''); + }); + }); +}); diff --git a/test/unit/pixi-v2/renderers/webgl/WebGLShaders.js b/test/unit/pixi-v2/renderers/webgl/WebGLShaders.js new file mode 100644 index 0000000..6e33e4f --- /dev/null +++ b/test/unit/pixi-v2/renderers/webgl/WebGLShaders.js @@ -0,0 +1,13 @@ +describe('renderers/webgl/WebGLShaders', function () { + 'use strict'; + + var expect = chai.expect; + + it('Module members exist', function () { + + expect(PIXI).to.respondTo('CompileVertexShader'); + expect(PIXI).to.respondTo('CompileFragmentShader'); + expect(PIXI).to.respondTo('_CompileShader'); + expect(PIXI).to.respondTo('compileProgram'); + }); +}); diff --git a/test/unit/pixi-v2/renderers/webgl/WebGLSpriteBatch.js b/test/unit/pixi-v2/renderers/webgl/WebGLSpriteBatch.js new file mode 100644 index 0000000..e662b63 --- /dev/null +++ b/test/unit/pixi-v2/renderers/webgl/WebGLSpriteBatch.js @@ -0,0 +1,10 @@ +describe('renderers/webgl/utils/WebGLSpriteBatch', function () { + 'use strict'; + + var expect = chai.expect; + var WebGLSpriteBatch = PIXI.WebGLSpriteBatch; + + it('Module exists', function () { + expect(WebGLSpriteBatch).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/text/BitmapText.js b/test/unit/pixi-v2/text/BitmapText.js new file mode 100644 index 0000000..9388e3d --- /dev/null +++ b/test/unit/pixi-v2/text/BitmapText.js @@ -0,0 +1,10 @@ +describe('pixi/text/BitmapText', function () { + 'use strict'; + + var expect = chai.expect; + var BitmapText = PIXI.BitmapText; + + it('Module exists', function () { + expect(BitmapText).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/text/Text.js b/test/unit/pixi-v2/text/Text.js new file mode 100644 index 0000000..9bc9ac5 --- /dev/null +++ b/test/unit/pixi-v2/text/Text.js @@ -0,0 +1,10 @@ +describe('pixi/text/Text', function () { + 'use strict'; + + var expect = chai.expect; + var Text = PIXI.Text; + + it('Module exists', function () { + expect(Text).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/textures/BaseTexture.js b/test/unit/pixi-v2/textures/BaseTexture.js new file mode 100644 index 0000000..502b724 --- /dev/null +++ b/test/unit/pixi-v2/textures/BaseTexture.js @@ -0,0 +1,11 @@ +describe('pixi/textures/BaseTexture', function () { + 'use strict'; + + var expect = chai.expect; + var BaseTexture = PIXI.BaseTexture; + + it('Module exists', function () { + expect(BaseTexture).to.be.a('function'); + expect(PIXI).to.have.property('BaseTextureCache').and.to.be.an('object'); + }); +}); diff --git a/test/unit/pixi-v2/InteractionManager.js b/test/unit/pixi-v2/InteractionManager.js new file mode 100644 index 0000000..ed3001f --- /dev/null +++ b/test/unit/pixi-v2/InteractionManager.js @@ -0,0 +1,10 @@ +describe('pixi/InteractionManager', function () { + 'use strict'; + + var expect = chai.expect; + var InteractionManager = PIXI.InteractionManager; + + it('Module exists', function () { + expect(InteractionManager).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/Pixi.js b/test/unit/pixi-v2/Pixi.js new file mode 100644 index 0000000..27debc1 --- /dev/null +++ b/test/unit/pixi-v2/Pixi.js @@ -0,0 +1,9 @@ +describe('pixi/Pixi', function () { + 'use strict'; + + var expect = chai.expect; + + it('Module exists', function () { + expect(global).to.have.property('PIXI').and.to.be.an('object'); + }); +}); diff --git a/test/unit/pixi-v2/core/Circle.js b/test/unit/pixi-v2/core/Circle.js new file mode 100644 index 0000000..fbcfa17 --- /dev/null +++ b/test/unit/pixi-v2/core/Circle.js @@ -0,0 +1,21 @@ +describe('pixi/core/Circle', function () { + 'use strict'; + + var expect = chai.expect; + var Circle = PIXI.Circle; + + it('Module exists', function () { + expect(Circle).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Circle(); + pixi_core_Circle_confirmNewCircle(obj); + }); + + it("getBounds should return Rectangle that bounds the circle", function() { + var obj = new Circle(100, 250, 50); + var bounds = obj.getBounds(); + pixi_core_Circle_isBoundedByRectangle(obj, bounds); + }); +}); diff --git a/test/unit/pixi-v2/core/Ellipse.js b/test/unit/pixi-v2/core/Ellipse.js new file mode 100644 index 0000000..026b56f --- /dev/null +++ b/test/unit/pixi-v2/core/Ellipse.js @@ -0,0 +1,24 @@ +describe('pixi/core/Ellipse', function () { + 'use strict'; + + var expect = chai.expect; + var Ellipse = PIXI.Ellipse; + + it('Module exists', function () { + expect(Ellipse).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Ellipse(); + + expect(obj).to.be.an.instanceof(Ellipse); + expect(obj).to.respondTo('clone'); + expect(obj).to.respondTo('contains'); + expect(obj).to.respondTo('getBounds'); + + expect(obj).to.have.property('x', 0); + expect(obj).to.have.property('y', 0); + expect(obj).to.have.property('width', 0); + expect(obj).to.have.property('height', 0); + }); +}); diff --git a/test/unit/pixi-v2/core/Matrix.js b/test/unit/pixi-v2/core/Matrix.js new file mode 100644 index 0000000..da75e2e --- /dev/null +++ b/test/unit/pixi-v2/core/Matrix.js @@ -0,0 +1,14 @@ +describe('pixi/core/Matrix', function () { + 'use strict'; + + var expect = chai.expect; + + it('Matrix exists', function () { + expect(PIXI.Matrix).to.be.an('function'); + }); + + it('Confirm new Matrix', function () { + var matrix = new PIXI.Matrix(); + pixi_core_Matrix_confirmNewMatrix(matrix); + }); +}); diff --git a/test/unit/pixi-v2/core/Point.js b/test/unit/pixi-v2/core/Point.js new file mode 100644 index 0000000..c4d5163 --- /dev/null +++ b/test/unit/pixi-v2/core/Point.js @@ -0,0 +1,15 @@ +describe('pixi/core/Point', function () { + 'use strict'; + + var expect = chai.expect; + var Point = PIXI.Point; + + it('Module exists', function () { + expect(Point).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Point(); + pixi_core_Point_confirm(obj, 0, 0); + }); +}); diff --git a/test/unit/pixi-v2/core/Polygon.js b/test/unit/pixi-v2/core/Polygon.js new file mode 100644 index 0000000..dc8c918 --- /dev/null +++ b/test/unit/pixi-v2/core/Polygon.js @@ -0,0 +1,20 @@ +describe('pixi/core/Polygon', function () { + 'use strict'; + + var expect = chai.expect; + var Polygon = PIXI.Polygon; + + it('Module exists', function () { + expect(Polygon).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Polygon(); + + expect(obj).to.be.an.instanceof(Polygon); + expect(obj).to.respondTo('clone'); + expect(obj).to.respondTo('contains'); + + expect(obj).to.have.deep.property('points.length', 0); + }); +}); diff --git a/test/unit/pixi-v2/core/Rectangle.js b/test/unit/pixi-v2/core/Rectangle.js new file mode 100644 index 0000000..d43316e --- /dev/null +++ b/test/unit/pixi-v2/core/Rectangle.js @@ -0,0 +1,15 @@ +describe('pixi/core/Rectangle', function () { + 'use strict'; + + var expect = chai.expect; + var Rectangle = PIXI.Rectangle; + + it('Module exists', function () { + expect(Rectangle).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var rect = new Rectangle(); + pixi_core_Rectangle_confirm(rect, 0, 0, 0, 0); + }); +}); diff --git a/test/unit/pixi-v2/display/DisplayObject.js b/test/unit/pixi-v2/display/DisplayObject.js new file mode 100644 index 0000000..044acf8 --- /dev/null +++ b/test/unit/pixi-v2/display/DisplayObject.js @@ -0,0 +1,21 @@ +describe('pixi/display/DisplayObject', function () { + 'use strict'; + + var expect = chai.expect; + var DisplayObject = PIXI.DisplayObject; + + it('Module exists', function () { + expect(DisplayObject).to.be.a('function'); + // expect(PIXI).to.have.property('visibleCount', 0); + }); + + it('Confirm new instance', function () { + var obj = new DisplayObject(); + + pixi_display_DisplayObject_confirmNew(obj); + expect(obj).to.have.property('hitArea', null); + expect(obj).to.have.property('interactive', false); + expect(obj).to.have.property('renderable', false); + expect(obj).to.have.property('stage', null); + }); +}); diff --git a/test/unit/pixi-v2/display/DisplayObjectContainer.js b/test/unit/pixi-v2/display/DisplayObjectContainer.js new file mode 100644 index 0000000..15a3376 --- /dev/null +++ b/test/unit/pixi-v2/display/DisplayObjectContainer.js @@ -0,0 +1,67 @@ +describe('pixi/display/DisplayObjectContainer', function () { + 'use strict'; + + var expect = chai.expect; + var DisplayObjectContainer = PIXI.DisplayObjectContainer; + + it('Module exists', function () { + expect(DisplayObjectContainer).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new DisplayObjectContainer(); + + pixi_display_DisplayObjectContainer_confirmNew(obj); + expect(obj).to.have.property('hitArea', null); + expect(obj).to.have.property('interactive', false); + expect(obj).to.have.property('renderable', false); + expect(obj).to.have.property('stage', null); + }); + + it('Gets child index', function() { + var container = new PIXI.DisplayObjectContainer(); + var children = []; + for (var i = 0; i < 10; i++) { + var child = new PIXI.DisplayObject(); + children.push(child); + container.addChild(child); + } + + for (i = 0; i < children.length; i++) { + expect(i).to.eql(container.getChildIndex(children[i])); + } + }); + + it('throws error when trying to get index of not a child', function() { + var container = new PIXI.DisplayObjectContainer(); + var child = new PIXI.DisplayObject(); + + expect(function() { container.getChildIndex(child); }).to.throw(); + }); + + it('Sets child index', function() { + var container = new PIXI.DisplayObjectContainer(); + var children = []; + + for (var i = 0; i < 10; i++) { + var child = new PIXI.DisplayObject(); + children.push(child); + container.addChild(child); + } + children.reverse(); + + for (i = 0; i < children.length; i++) { + container.setChildIndex(children[i], i); + expect(i).to.eql(container.getChildIndex(children[i])); + } + }); + + it('throws error when trying to set incorect index', function() { + var container = new PIXI.DisplayObjectContainer(); + var child = new PIXI.DisplayObject(); + container.addChild(child); + + expect(function() { container.setChildIndex(child, -1); }).to.throw(); + expect(function() { container.setChildIndex(child, 1); }).to.throw(); + }); +}); diff --git a/test/unit/pixi-v2/display/MovieClip.js b/test/unit/pixi-v2/display/MovieClip.js new file mode 100644 index 0000000..f3c6c6a --- /dev/null +++ b/test/unit/pixi-v2/display/MovieClip.js @@ -0,0 +1,33 @@ +describe('pixi/display/MovieClip', function () { + 'use strict'; + + var expect = chai.expect; + var MovieClip = PIXI.MovieClip; + var Texture = PIXI.Texture; + + it('Module exists', function () { + expect(MovieClip).to.be.a('function'); + }); + + it('Confirm new instance', function (done) { + var texture = Texture.fromImage('/base/test/textures/SpriteSheet-Explosion.png'); + var obj = new MovieClip([texture]); + + pixi_display_Sprite_confirmNew(obj, done); + + expect(obj).to.be.an.instanceof(MovieClip); + expect(obj).to.respondTo('stop'); + expect(obj).to.respondTo('play'); + expect(obj).to.respondTo('gotoAndStop'); + expect(obj).to.respondTo('gotoAndPlay'); + expect(obj).to.respondTo('updateTransform'); + + expect(obj).to.have.deep.property('textures.length', 1); + expect(obj).to.have.deep.property('textures[0]', texture); + expect(obj).to.have.property('animationSpeed', 1); + expect(obj).to.have.property('loop', true); + expect(obj).to.have.property('onComplete', null); + expect(obj).to.have.property('currentFrame', 0); + expect(obj).to.have.property('playing', false); + }); +}); diff --git a/test/unit/pixi-v2/display/Sprite.js b/test/unit/pixi-v2/display/Sprite.js new file mode 100644 index 0000000..30c8076 --- /dev/null +++ b/test/unit/pixi-v2/display/Sprite.js @@ -0,0 +1,28 @@ +describe('pixi/display/Sprite', function () { + 'use strict'; + + var expect = chai.expect; + var Sprite = PIXI.Sprite; + var Texture = PIXI.Texture; + + it('Module exists', function () { + expect(Sprite).to.be.a('function'); + expect(PIXI).to.have.deep.property('blendModes.NORMAL', 0); + expect(PIXI).to.have.deep.property('blendModes.ADD', 1); + expect(PIXI).to.have.deep.property('blendModes.MULTIPLY', 2); + expect(PIXI).to.have.deep.property('blendModes.SCREEN', 3); + }); + + + it('Members exist', function () { + expect(Sprite).itself.to.respondTo('fromImage'); + expect(Sprite).itself.to.respondTo('fromFrame'); + }); + + it('Confirm new instance', function (done) { + var texture = Texture.fromImage('/base/test/textures/SpriteSheet-Aliens.png'); + var obj = new Sprite(texture); + + pixi_display_Sprite_confirmNew(obj, done); + }); +}); diff --git a/test/unit/pixi-v2/display/Stage.js b/test/unit/pixi-v2/display/Stage.js new file mode 100644 index 0000000..6974c2e --- /dev/null +++ b/test/unit/pixi-v2/display/Stage.js @@ -0,0 +1,49 @@ +describe('pixi/display/Stage', function () { + 'use strict'; + + var expect = chai.expect; + var Stage = PIXI.Stage; + var InteractionManager = PIXI.InteractionManager; + var Rectangle = PIXI.Rectangle; + + it('Module exists', function () { + expect(Stage).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Stage(null, true); + + pixi_display_DisplayObjectContainer_confirmNew(obj); + + expect(obj).to.be.an.instanceof(Stage); + expect(obj).to.respondTo('updateTransform'); + expect(obj).to.respondTo('setBackgroundColor'); + expect(obj).to.respondTo('getMousePosition'); + // FIXME: duplicate member in DisplayObject + pixi_core_Matrix_confirmNewMatrix(obj.worldTransform); + // FIXME: convert arg to bool in constructor + expect(obj).to.have.property('interactive', true); + + expect(obj).to.have.property('interactionManager') + .and.to.be.an.instanceof(InteractionManager) + .and.to.have.property('stage', obj); + + expect(obj).to.have.property('dirty', true); + + expect(obj).to.have.property('stage', obj); + + expect(obj).to.have.property('hitArea') + .and.to.be.an.instanceof(Rectangle); + pixi_core_Rectangle_confirm(obj.hitArea, 0, 0, 100000, 100000); + + expect(obj).to.have.property('backgroundColor', 0x000000); + expect(obj).to.have.deep.property('backgroundColorSplit.length', 3); + expect(obj).to.have.deep.property('backgroundColorSplit[0]', 0); + expect(obj).to.have.deep.property('backgroundColorSplit[1]', 0); + expect(obj).to.have.deep.property('backgroundColorSplit[2]', 0); + expect(obj).to.have.property('backgroundColorString', '#000000'); + + + expect(obj).to.have.property('worldVisible', true); + }); +}); diff --git a/test/unit/pixi-v2/extras/Rope.js b/test/unit/pixi-v2/extras/Rope.js new file mode 100644 index 0000000..05885ac --- /dev/null +++ b/test/unit/pixi-v2/extras/Rope.js @@ -0,0 +1,31 @@ +describe('pixi/extras/Rope', function () { + 'use strict'; + + var expect = chai.expect; + var Rope = PIXI.Rope; + var Texture = PIXI.Texture; + var Point = PIXI.Point; + + it('Module exists', function () { + expect(Rope).to.be.a('function'); + }); + + it('Confirm new instance', function () { + + var texture = Texture.fromImage('/base/test/textures/bunny.png'); + + // TODO-Alvin + // Same as Strip + + // var obj = new Rope(texture, [new Point(), new Point(5, 10), new Point(10, 20)]); + + // pixi_extras_Strip_confirmNew(obj); + + // expect(obj).to.be.an.instanceof(Rope); + // expect(obj).to.respondTo('refresh'); + // expect(obj).to.respondTo('updateTransform'); + // expect(obj).to.respondTo('setTexture'); + + // TODO: Test properties + }); +}); diff --git a/test/unit/pixi-v2/extras/Spine.js b/test/unit/pixi-v2/extras/Spine.js new file mode 100644 index 0000000..0708bc0 --- /dev/null +++ b/test/unit/pixi-v2/extras/Spine.js @@ -0,0 +1,10 @@ +describe('pixi/extras/Spine', function () { + 'use strict'; + + var expect = chai.expect; + var Spine = PIXI.Spine; + + it('Module exists', function () { + expect(Spine).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/extras/Strip.js b/test/unit/pixi-v2/extras/Strip.js new file mode 100644 index 0000000..230af90 --- /dev/null +++ b/test/unit/pixi-v2/extras/Strip.js @@ -0,0 +1,26 @@ +describe('pixi/extras/Strip', function () { + 'use strict'; + + var expect = chai.expect; + var Strip = PIXI.Strip; + var Texture = PIXI.Texture; + + it('Module exists', function () { + expect(Strip).to.be.a('function'); + }); + + it('Confirm new instance', function () { + + + // TODO-Alvin + // We tweaked it to make it pass the tests, but the whole strip class needs + // to be re-coded + + var texture = Texture.fromImage('/base/test/textures/bunny.png'); + + // var obj = new Strip(texture, 20, 10000); + + + // pixi_extras_Strip_confirmNew(obj); + }); +}); diff --git a/test/unit/pixi-v2/extras/TilingSprite.js b/test/unit/pixi-v2/extras/TilingSprite.js new file mode 100644 index 0000000..56aea14 --- /dev/null +++ b/test/unit/pixi-v2/extras/TilingSprite.js @@ -0,0 +1,24 @@ +describe('pixi/extras/TilingSprite', function () { + 'use strict'; + + var expect = chai.expect; + var TilingSprite = PIXI.TilingSprite; + var Texture = PIXI.Texture; + + it('Module exists', function () { + expect(TilingSprite).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var texture = Texture.fromImage('/base/test/textures/bunny.png'); + var obj = new TilingSprite(texture, 6000, 12000); + + pixi_display_DisplayObjectContainer_confirmNew(obj); + + expect(obj).to.be.an.instanceof(TilingSprite); + expect(obj).to.respondTo('setTexture'); + expect(obj).to.respondTo('onTextureUpdate'); + + // TODO: Test properties + }); +}); diff --git a/test/unit/pixi-v2/filters/FilterBlock.js b/test/unit/pixi-v2/filters/FilterBlock.js new file mode 100644 index 0000000..870cec0 --- /dev/null +++ b/test/unit/pixi-v2/filters/FilterBlock.js @@ -0,0 +1,10 @@ +describe('pixi/filters/FilterBlock', function () { + 'use strict'; + + var expect = chai.expect; + var FilterBlock = PIXI.FilterBlock; + + it('Module exists', function () { + expect(FilterBlock).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/AssetLoader.js b/test/unit/pixi-v2/loaders/AssetLoader.js new file mode 100644 index 0000000..a0aa0b5 --- /dev/null +++ b/test/unit/pixi-v2/loaders/AssetLoader.js @@ -0,0 +1,10 @@ +describe('pixi/loaders/AssetLoader', function () { + 'use strict'; + + var expect = chai.expect; + var AssetLoader = PIXI.AssetLoader; + + it('Module exists', function () { + expect(AssetLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/BitmapFontLoader.js b/test/unit/pixi-v2/loaders/BitmapFontLoader.js new file mode 100644 index 0000000..046f018 --- /dev/null +++ b/test/unit/pixi-v2/loaders/BitmapFontLoader.js @@ -0,0 +1,9 @@ +describe('pixi/loaders/BitmapFontLoader', function () { + 'use strict'; + + var expect = chai.expect; + + it('Module exists', function () { + expect(PIXI.BitmapFontLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/ImageLoader.js b/test/unit/pixi-v2/loaders/ImageLoader.js new file mode 100644 index 0000000..8b1f556 --- /dev/null +++ b/test/unit/pixi-v2/loaders/ImageLoader.js @@ -0,0 +1,10 @@ +describe('pixi/loaders/ImageLoader', function () { + 'use strict'; + + var expect = chai.expect; + var ImageLoader = PIXI.ImageLoader; + + it('Module exists', function () { + expect(ImageLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/JsonLoader.js b/test/unit/pixi-v2/loaders/JsonLoader.js new file mode 100644 index 0000000..c577e83 --- /dev/null +++ b/test/unit/pixi-v2/loaders/JsonLoader.js @@ -0,0 +1,10 @@ +describe('pixi/loaders/JsonLoader', function () { + 'use strict'; + + var expect = chai.expect; + var JsonLoader = PIXI.JsonLoader; + + it('Module exists', function () { + expect(JsonLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/SpineLoader.js b/test/unit/pixi-v2/loaders/SpineLoader.js new file mode 100644 index 0000000..fdcc0b8 --- /dev/null +++ b/test/unit/pixi-v2/loaders/SpineLoader.js @@ -0,0 +1,10 @@ +describe('pixi/loaders/SpineLoader', function () { + 'use strict'; + + var expect = chai.expect; + var SpineLoader = PIXI.SpineLoader; + + it('Module exists', function () { + expect(SpineLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/SpriteSheetLoader.js b/test/unit/pixi-v2/loaders/SpriteSheetLoader.js new file mode 100644 index 0000000..57beb27 --- /dev/null +++ b/test/unit/pixi-v2/loaders/SpriteSheetLoader.js @@ -0,0 +1,10 @@ +describe('pixi/loaders/SpriteSheetLoader', function () { + 'use strict'; + + var expect = chai.expect; + var SpriteSheetLoader = PIXI.SpriteSheetLoader; + + it('Module exists', function () { + expect(SpriteSheetLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/primitives/Graphics.js b/test/unit/pixi-v2/primitives/Graphics.js new file mode 100644 index 0000000..f3849eb --- /dev/null +++ b/test/unit/pixi-v2/primitives/Graphics.js @@ -0,0 +1,44 @@ +describe('pixi/primitives/Graphics', function () { + 'use strict'; + + var expect = chai.expect; + var Graphics = PIXI.Graphics; + + it('Module exists', function () { + expect(Graphics).to.be.a('function'); + + expect(Graphics).itself.to.have.property('POLY', 0); + expect(Graphics).itself.to.have.property('RECT', 1); + expect(Graphics).itself.to.have.property('CIRC', 2); + expect(Graphics).itself.to.have.property('ELIP', 3); + expect(Graphics).itself.to.have.property('RREC', 4); + }); + + it('Confirm new instance', function () { + var obj = new Graphics(); + + pixi_display_DisplayObjectContainer_confirmNew(obj); + + expect(obj).to.be.an.instanceof(Graphics); + expect(obj).to.respondTo('lineStyle'); + expect(obj).to.respondTo('lineStyle'); + expect(obj).to.respondTo('moveTo'); + expect(obj).to.respondTo('lineTo'); + expect(obj).to.respondTo('beginFill'); + expect(obj).to.respondTo('endFill'); + expect(obj).to.respondTo('drawRect'); + // expect(obj).to.respondTo('drawRoundedRect'); + expect(obj).to.respondTo('drawCircle'); + expect(obj).to.respondTo('drawEllipse'); + expect(obj).to.respondTo('clear'); + + expect(obj).to.have.property('renderable', true); + expect(obj).to.have.property('fillAlpha', 1); + expect(obj).to.have.property('lineWidth', 0); + expect(obj).to.have.property('width', 0); + expect(obj).to.have.property('height', 0); + expect(obj).to.have.property('lineColor', 0); + expect(obj).to.have.deep.property('graphicsData.length', 0); + // expect(obj).to.have.deep.property('currentPath.points.length', 0); + }); +}); diff --git a/test/unit/pixi-v2/renderers/canvas/CanvasGraphics.js b/test/unit/pixi-v2/renderers/canvas/CanvasGraphics.js new file mode 100644 index 0000000..8f44472 --- /dev/null +++ b/test/unit/pixi-v2/renderers/canvas/CanvasGraphics.js @@ -0,0 +1,15 @@ +describe('renders/canvas/CanvasGraphics', function () { + 'use strict'; + + var expect = chai.expect; + var CanvasGraphics = PIXI.CanvasGraphics; + + it('Module exists', function () { + expect(CanvasGraphics).to.be.a('function'); + }); + + it('Members exist', function () { + expect(CanvasGraphics).itself.to.respondTo('renderGraphics'); + expect(CanvasGraphics).itself.to.respondTo('renderGraphicsMask'); + }); +}); diff --git a/test/unit/pixi-v2/renderers/canvas/CanvasRenderer.js b/test/unit/pixi-v2/renderers/canvas/CanvasRenderer.js new file mode 100644 index 0000000..1646444 --- /dev/null +++ b/test/unit/pixi-v2/renderers/canvas/CanvasRenderer.js @@ -0,0 +1,36 @@ +describe('renderers/canvas/CanvasRenderer', function () { + 'use strict'; + + var expect = chai.expect; + var CanvasRenderer = PIXI.CanvasRenderer; + + it('Module exists', function () { + expect(CanvasRenderer).to.be.a('function'); + }); + + describe('.autoResize', function () { + it('Should automatically resize view if enabled', function () { + var renderer = new CanvasRenderer(200, 200, { + autoResize: true + }); + + expect(renderer.view.style.width).to.equal('200px'); + }); + + it('Should not automatically resize view if disabled', function () { + var renderer = new CanvasRenderer(200, 200, { + autoResize: false + }); + + expect(renderer.view.style.width).to.equal(''); + }); + + it('Should not automatically resize view if not specified', function () { + var renderer = new CanvasRenderer(200, 200, { + resolution: 2 + }); + + expect(renderer.view.style.width).to.equal(''); + }); + }); +}); diff --git a/test/unit/pixi-v2/renderers/webgl/WebGLGraphics.js b/test/unit/pixi-v2/renderers/webgl/WebGLGraphics.js new file mode 100644 index 0000000..5867b28 --- /dev/null +++ b/test/unit/pixi-v2/renderers/webgl/WebGLGraphics.js @@ -0,0 +1,20 @@ +describe('renderers/wegbl/WebGLGraphics', function () { + 'use strict'; + + var expect = chai.expect; + var WebGLGraphics = PIXI.WebGLGraphics; + + it('Module exists', function () { + expect(WebGLGraphics).to.be.a('function'); + }); + + it('Members exist', function () { + expect(WebGLGraphics).itself.to.respondTo('renderGraphics'); + expect(WebGLGraphics).itself.to.respondTo('updateGraphics'); + expect(WebGLGraphics).itself.to.respondTo('buildRectangle'); + expect(WebGLGraphics).itself.to.respondTo('buildRoundedRectangle'); + expect(WebGLGraphics).itself.to.respondTo('buildCircle'); + expect(WebGLGraphics).itself.to.respondTo('buildLine'); + expect(WebGLGraphics).itself.to.respondTo('buildPoly'); + }); +}); diff --git a/test/unit/pixi-v2/renderers/webgl/WebGLRenderer.js b/test/unit/pixi-v2/renderers/webgl/WebGLRenderer.js new file mode 100644 index 0000000..1680a80 --- /dev/null +++ b/test/unit/pixi-v2/renderers/webgl/WebGLRenderer.js @@ -0,0 +1,49 @@ +describe('renderers/webgl/WebGLRenderer', function () { + 'use strict'; + + var expect = chai.expect; + var WebGLRenderer = PIXI.WebGLRenderer; + + it('Module exists', function () { + expect(WebGLRenderer).to.be.a('function'); + }); + + // Skip tests if WebGL is not available (WebGL not supported in Travis CI) + try { + var renderer = new WebGLRenderer(400, 300, {}); + renderer.destroy(); + } catch (error) { + return; + } + + it('Destroy renderer', function () { + var renderer = new WebGLRenderer(400, 300, {}); + renderer.destroy(); + }); + + describe('.autoResize', function () { + it('Should automatically resize view if enabled', function () { + var renderer = new WebGLRenderer(200, 200, { + autoResize: true + }); + + expect(renderer.view.style.width).to.equal('200px'); + }); + + it('Should not automatically resize view if disabled', function () { + var renderer = new WebGLRenderer(200, 200, { + autoResize: false + }); + + expect(renderer.view.style.width).to.equal(''); + }); + + it('Should not automatically resize view if not specified', function () { + var renderer = new WebGLRenderer(200, 200, { + resolution: 2 + }); + + expect(renderer.view.style.width).to.equal(''); + }); + }); +}); diff --git a/test/unit/pixi-v2/renderers/webgl/WebGLShaders.js b/test/unit/pixi-v2/renderers/webgl/WebGLShaders.js new file mode 100644 index 0000000..6e33e4f --- /dev/null +++ b/test/unit/pixi-v2/renderers/webgl/WebGLShaders.js @@ -0,0 +1,13 @@ +describe('renderers/webgl/WebGLShaders', function () { + 'use strict'; + + var expect = chai.expect; + + it('Module members exist', function () { + + expect(PIXI).to.respondTo('CompileVertexShader'); + expect(PIXI).to.respondTo('CompileFragmentShader'); + expect(PIXI).to.respondTo('_CompileShader'); + expect(PIXI).to.respondTo('compileProgram'); + }); +}); diff --git a/test/unit/pixi-v2/renderers/webgl/WebGLSpriteBatch.js b/test/unit/pixi-v2/renderers/webgl/WebGLSpriteBatch.js new file mode 100644 index 0000000..e662b63 --- /dev/null +++ b/test/unit/pixi-v2/renderers/webgl/WebGLSpriteBatch.js @@ -0,0 +1,10 @@ +describe('renderers/webgl/utils/WebGLSpriteBatch', function () { + 'use strict'; + + var expect = chai.expect; + var WebGLSpriteBatch = PIXI.WebGLSpriteBatch; + + it('Module exists', function () { + expect(WebGLSpriteBatch).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/text/BitmapText.js b/test/unit/pixi-v2/text/BitmapText.js new file mode 100644 index 0000000..9388e3d --- /dev/null +++ b/test/unit/pixi-v2/text/BitmapText.js @@ -0,0 +1,10 @@ +describe('pixi/text/BitmapText', function () { + 'use strict'; + + var expect = chai.expect; + var BitmapText = PIXI.BitmapText; + + it('Module exists', function () { + expect(BitmapText).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/text/Text.js b/test/unit/pixi-v2/text/Text.js new file mode 100644 index 0000000..9bc9ac5 --- /dev/null +++ b/test/unit/pixi-v2/text/Text.js @@ -0,0 +1,10 @@ +describe('pixi/text/Text', function () { + 'use strict'; + + var expect = chai.expect; + var Text = PIXI.Text; + + it('Module exists', function () { + expect(Text).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/textures/BaseTexture.js b/test/unit/pixi-v2/textures/BaseTexture.js new file mode 100644 index 0000000..502b724 --- /dev/null +++ b/test/unit/pixi-v2/textures/BaseTexture.js @@ -0,0 +1,11 @@ +describe('pixi/textures/BaseTexture', function () { + 'use strict'; + + var expect = chai.expect; + var BaseTexture = PIXI.BaseTexture; + + it('Module exists', function () { + expect(BaseTexture).to.be.a('function'); + expect(PIXI).to.have.property('BaseTextureCache').and.to.be.an('object'); + }); +}); diff --git a/test/unit/pixi-v2/textures/RenderTexture.js b/test/unit/pixi-v2/textures/RenderTexture.js new file mode 100644 index 0000000..96acdb4 --- /dev/null +++ b/test/unit/pixi-v2/textures/RenderTexture.js @@ -0,0 +1,15 @@ +describe('pixi/textures/RenderTexture', function () { + 'use strict'; + + var expect = chai.expect; + var RenderTexture = PIXI.RenderTexture; + + it('Module exists', function () { + expect(RenderTexture).to.be.a('function'); + }); + + it('Confirm new instance', function (done) { + var texture = new RenderTexture(100, 100, new PIXI.CanvasRenderer()); + pixi_textures_RenderTexture_confirmNew(texture, done); + }); +}); diff --git a/test/unit/pixi-v2/InteractionManager.js b/test/unit/pixi-v2/InteractionManager.js new file mode 100644 index 0000000..ed3001f --- /dev/null +++ b/test/unit/pixi-v2/InteractionManager.js @@ -0,0 +1,10 @@ +describe('pixi/InteractionManager', function () { + 'use strict'; + + var expect = chai.expect; + var InteractionManager = PIXI.InteractionManager; + + it('Module exists', function () { + expect(InteractionManager).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/Pixi.js b/test/unit/pixi-v2/Pixi.js new file mode 100644 index 0000000..27debc1 --- /dev/null +++ b/test/unit/pixi-v2/Pixi.js @@ -0,0 +1,9 @@ +describe('pixi/Pixi', function () { + 'use strict'; + + var expect = chai.expect; + + it('Module exists', function () { + expect(global).to.have.property('PIXI').and.to.be.an('object'); + }); +}); diff --git a/test/unit/pixi-v2/core/Circle.js b/test/unit/pixi-v2/core/Circle.js new file mode 100644 index 0000000..fbcfa17 --- /dev/null +++ b/test/unit/pixi-v2/core/Circle.js @@ -0,0 +1,21 @@ +describe('pixi/core/Circle', function () { + 'use strict'; + + var expect = chai.expect; + var Circle = PIXI.Circle; + + it('Module exists', function () { + expect(Circle).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Circle(); + pixi_core_Circle_confirmNewCircle(obj); + }); + + it("getBounds should return Rectangle that bounds the circle", function() { + var obj = new Circle(100, 250, 50); + var bounds = obj.getBounds(); + pixi_core_Circle_isBoundedByRectangle(obj, bounds); + }); +}); diff --git a/test/unit/pixi-v2/core/Ellipse.js b/test/unit/pixi-v2/core/Ellipse.js new file mode 100644 index 0000000..026b56f --- /dev/null +++ b/test/unit/pixi-v2/core/Ellipse.js @@ -0,0 +1,24 @@ +describe('pixi/core/Ellipse', function () { + 'use strict'; + + var expect = chai.expect; + var Ellipse = PIXI.Ellipse; + + it('Module exists', function () { + expect(Ellipse).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Ellipse(); + + expect(obj).to.be.an.instanceof(Ellipse); + expect(obj).to.respondTo('clone'); + expect(obj).to.respondTo('contains'); + expect(obj).to.respondTo('getBounds'); + + expect(obj).to.have.property('x', 0); + expect(obj).to.have.property('y', 0); + expect(obj).to.have.property('width', 0); + expect(obj).to.have.property('height', 0); + }); +}); diff --git a/test/unit/pixi-v2/core/Matrix.js b/test/unit/pixi-v2/core/Matrix.js new file mode 100644 index 0000000..da75e2e --- /dev/null +++ b/test/unit/pixi-v2/core/Matrix.js @@ -0,0 +1,14 @@ +describe('pixi/core/Matrix', function () { + 'use strict'; + + var expect = chai.expect; + + it('Matrix exists', function () { + expect(PIXI.Matrix).to.be.an('function'); + }); + + it('Confirm new Matrix', function () { + var matrix = new PIXI.Matrix(); + pixi_core_Matrix_confirmNewMatrix(matrix); + }); +}); diff --git a/test/unit/pixi-v2/core/Point.js b/test/unit/pixi-v2/core/Point.js new file mode 100644 index 0000000..c4d5163 --- /dev/null +++ b/test/unit/pixi-v2/core/Point.js @@ -0,0 +1,15 @@ +describe('pixi/core/Point', function () { + 'use strict'; + + var expect = chai.expect; + var Point = PIXI.Point; + + it('Module exists', function () { + expect(Point).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Point(); + pixi_core_Point_confirm(obj, 0, 0); + }); +}); diff --git a/test/unit/pixi-v2/core/Polygon.js b/test/unit/pixi-v2/core/Polygon.js new file mode 100644 index 0000000..dc8c918 --- /dev/null +++ b/test/unit/pixi-v2/core/Polygon.js @@ -0,0 +1,20 @@ +describe('pixi/core/Polygon', function () { + 'use strict'; + + var expect = chai.expect; + var Polygon = PIXI.Polygon; + + it('Module exists', function () { + expect(Polygon).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Polygon(); + + expect(obj).to.be.an.instanceof(Polygon); + expect(obj).to.respondTo('clone'); + expect(obj).to.respondTo('contains'); + + expect(obj).to.have.deep.property('points.length', 0); + }); +}); diff --git a/test/unit/pixi-v2/core/Rectangle.js b/test/unit/pixi-v2/core/Rectangle.js new file mode 100644 index 0000000..d43316e --- /dev/null +++ b/test/unit/pixi-v2/core/Rectangle.js @@ -0,0 +1,15 @@ +describe('pixi/core/Rectangle', function () { + 'use strict'; + + var expect = chai.expect; + var Rectangle = PIXI.Rectangle; + + it('Module exists', function () { + expect(Rectangle).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var rect = new Rectangle(); + pixi_core_Rectangle_confirm(rect, 0, 0, 0, 0); + }); +}); diff --git a/test/unit/pixi-v2/display/DisplayObject.js b/test/unit/pixi-v2/display/DisplayObject.js new file mode 100644 index 0000000..044acf8 --- /dev/null +++ b/test/unit/pixi-v2/display/DisplayObject.js @@ -0,0 +1,21 @@ +describe('pixi/display/DisplayObject', function () { + 'use strict'; + + var expect = chai.expect; + var DisplayObject = PIXI.DisplayObject; + + it('Module exists', function () { + expect(DisplayObject).to.be.a('function'); + // expect(PIXI).to.have.property('visibleCount', 0); + }); + + it('Confirm new instance', function () { + var obj = new DisplayObject(); + + pixi_display_DisplayObject_confirmNew(obj); + expect(obj).to.have.property('hitArea', null); + expect(obj).to.have.property('interactive', false); + expect(obj).to.have.property('renderable', false); + expect(obj).to.have.property('stage', null); + }); +}); diff --git a/test/unit/pixi-v2/display/DisplayObjectContainer.js b/test/unit/pixi-v2/display/DisplayObjectContainer.js new file mode 100644 index 0000000..15a3376 --- /dev/null +++ b/test/unit/pixi-v2/display/DisplayObjectContainer.js @@ -0,0 +1,67 @@ +describe('pixi/display/DisplayObjectContainer', function () { + 'use strict'; + + var expect = chai.expect; + var DisplayObjectContainer = PIXI.DisplayObjectContainer; + + it('Module exists', function () { + expect(DisplayObjectContainer).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new DisplayObjectContainer(); + + pixi_display_DisplayObjectContainer_confirmNew(obj); + expect(obj).to.have.property('hitArea', null); + expect(obj).to.have.property('interactive', false); + expect(obj).to.have.property('renderable', false); + expect(obj).to.have.property('stage', null); + }); + + it('Gets child index', function() { + var container = new PIXI.DisplayObjectContainer(); + var children = []; + for (var i = 0; i < 10; i++) { + var child = new PIXI.DisplayObject(); + children.push(child); + container.addChild(child); + } + + for (i = 0; i < children.length; i++) { + expect(i).to.eql(container.getChildIndex(children[i])); + } + }); + + it('throws error when trying to get index of not a child', function() { + var container = new PIXI.DisplayObjectContainer(); + var child = new PIXI.DisplayObject(); + + expect(function() { container.getChildIndex(child); }).to.throw(); + }); + + it('Sets child index', function() { + var container = new PIXI.DisplayObjectContainer(); + var children = []; + + for (var i = 0; i < 10; i++) { + var child = new PIXI.DisplayObject(); + children.push(child); + container.addChild(child); + } + children.reverse(); + + for (i = 0; i < children.length; i++) { + container.setChildIndex(children[i], i); + expect(i).to.eql(container.getChildIndex(children[i])); + } + }); + + it('throws error when trying to set incorect index', function() { + var container = new PIXI.DisplayObjectContainer(); + var child = new PIXI.DisplayObject(); + container.addChild(child); + + expect(function() { container.setChildIndex(child, -1); }).to.throw(); + expect(function() { container.setChildIndex(child, 1); }).to.throw(); + }); +}); diff --git a/test/unit/pixi-v2/display/MovieClip.js b/test/unit/pixi-v2/display/MovieClip.js new file mode 100644 index 0000000..f3c6c6a --- /dev/null +++ b/test/unit/pixi-v2/display/MovieClip.js @@ -0,0 +1,33 @@ +describe('pixi/display/MovieClip', function () { + 'use strict'; + + var expect = chai.expect; + var MovieClip = PIXI.MovieClip; + var Texture = PIXI.Texture; + + it('Module exists', function () { + expect(MovieClip).to.be.a('function'); + }); + + it('Confirm new instance', function (done) { + var texture = Texture.fromImage('/base/test/textures/SpriteSheet-Explosion.png'); + var obj = new MovieClip([texture]); + + pixi_display_Sprite_confirmNew(obj, done); + + expect(obj).to.be.an.instanceof(MovieClip); + expect(obj).to.respondTo('stop'); + expect(obj).to.respondTo('play'); + expect(obj).to.respondTo('gotoAndStop'); + expect(obj).to.respondTo('gotoAndPlay'); + expect(obj).to.respondTo('updateTransform'); + + expect(obj).to.have.deep.property('textures.length', 1); + expect(obj).to.have.deep.property('textures[0]', texture); + expect(obj).to.have.property('animationSpeed', 1); + expect(obj).to.have.property('loop', true); + expect(obj).to.have.property('onComplete', null); + expect(obj).to.have.property('currentFrame', 0); + expect(obj).to.have.property('playing', false); + }); +}); diff --git a/test/unit/pixi-v2/display/Sprite.js b/test/unit/pixi-v2/display/Sprite.js new file mode 100644 index 0000000..30c8076 --- /dev/null +++ b/test/unit/pixi-v2/display/Sprite.js @@ -0,0 +1,28 @@ +describe('pixi/display/Sprite', function () { + 'use strict'; + + var expect = chai.expect; + var Sprite = PIXI.Sprite; + var Texture = PIXI.Texture; + + it('Module exists', function () { + expect(Sprite).to.be.a('function'); + expect(PIXI).to.have.deep.property('blendModes.NORMAL', 0); + expect(PIXI).to.have.deep.property('blendModes.ADD', 1); + expect(PIXI).to.have.deep.property('blendModes.MULTIPLY', 2); + expect(PIXI).to.have.deep.property('blendModes.SCREEN', 3); + }); + + + it('Members exist', function () { + expect(Sprite).itself.to.respondTo('fromImage'); + expect(Sprite).itself.to.respondTo('fromFrame'); + }); + + it('Confirm new instance', function (done) { + var texture = Texture.fromImage('/base/test/textures/SpriteSheet-Aliens.png'); + var obj = new Sprite(texture); + + pixi_display_Sprite_confirmNew(obj, done); + }); +}); diff --git a/test/unit/pixi-v2/display/Stage.js b/test/unit/pixi-v2/display/Stage.js new file mode 100644 index 0000000..6974c2e --- /dev/null +++ b/test/unit/pixi-v2/display/Stage.js @@ -0,0 +1,49 @@ +describe('pixi/display/Stage', function () { + 'use strict'; + + var expect = chai.expect; + var Stage = PIXI.Stage; + var InteractionManager = PIXI.InteractionManager; + var Rectangle = PIXI.Rectangle; + + it('Module exists', function () { + expect(Stage).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Stage(null, true); + + pixi_display_DisplayObjectContainer_confirmNew(obj); + + expect(obj).to.be.an.instanceof(Stage); + expect(obj).to.respondTo('updateTransform'); + expect(obj).to.respondTo('setBackgroundColor'); + expect(obj).to.respondTo('getMousePosition'); + // FIXME: duplicate member in DisplayObject + pixi_core_Matrix_confirmNewMatrix(obj.worldTransform); + // FIXME: convert arg to bool in constructor + expect(obj).to.have.property('interactive', true); + + expect(obj).to.have.property('interactionManager') + .and.to.be.an.instanceof(InteractionManager) + .and.to.have.property('stage', obj); + + expect(obj).to.have.property('dirty', true); + + expect(obj).to.have.property('stage', obj); + + expect(obj).to.have.property('hitArea') + .and.to.be.an.instanceof(Rectangle); + pixi_core_Rectangle_confirm(obj.hitArea, 0, 0, 100000, 100000); + + expect(obj).to.have.property('backgroundColor', 0x000000); + expect(obj).to.have.deep.property('backgroundColorSplit.length', 3); + expect(obj).to.have.deep.property('backgroundColorSplit[0]', 0); + expect(obj).to.have.deep.property('backgroundColorSplit[1]', 0); + expect(obj).to.have.deep.property('backgroundColorSplit[2]', 0); + expect(obj).to.have.property('backgroundColorString', '#000000'); + + + expect(obj).to.have.property('worldVisible', true); + }); +}); diff --git a/test/unit/pixi-v2/extras/Rope.js b/test/unit/pixi-v2/extras/Rope.js new file mode 100644 index 0000000..05885ac --- /dev/null +++ b/test/unit/pixi-v2/extras/Rope.js @@ -0,0 +1,31 @@ +describe('pixi/extras/Rope', function () { + 'use strict'; + + var expect = chai.expect; + var Rope = PIXI.Rope; + var Texture = PIXI.Texture; + var Point = PIXI.Point; + + it('Module exists', function () { + expect(Rope).to.be.a('function'); + }); + + it('Confirm new instance', function () { + + var texture = Texture.fromImage('/base/test/textures/bunny.png'); + + // TODO-Alvin + // Same as Strip + + // var obj = new Rope(texture, [new Point(), new Point(5, 10), new Point(10, 20)]); + + // pixi_extras_Strip_confirmNew(obj); + + // expect(obj).to.be.an.instanceof(Rope); + // expect(obj).to.respondTo('refresh'); + // expect(obj).to.respondTo('updateTransform'); + // expect(obj).to.respondTo('setTexture'); + + // TODO: Test properties + }); +}); diff --git a/test/unit/pixi-v2/extras/Spine.js b/test/unit/pixi-v2/extras/Spine.js new file mode 100644 index 0000000..0708bc0 --- /dev/null +++ b/test/unit/pixi-v2/extras/Spine.js @@ -0,0 +1,10 @@ +describe('pixi/extras/Spine', function () { + 'use strict'; + + var expect = chai.expect; + var Spine = PIXI.Spine; + + it('Module exists', function () { + expect(Spine).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/extras/Strip.js b/test/unit/pixi-v2/extras/Strip.js new file mode 100644 index 0000000..230af90 --- /dev/null +++ b/test/unit/pixi-v2/extras/Strip.js @@ -0,0 +1,26 @@ +describe('pixi/extras/Strip', function () { + 'use strict'; + + var expect = chai.expect; + var Strip = PIXI.Strip; + var Texture = PIXI.Texture; + + it('Module exists', function () { + expect(Strip).to.be.a('function'); + }); + + it('Confirm new instance', function () { + + + // TODO-Alvin + // We tweaked it to make it pass the tests, but the whole strip class needs + // to be re-coded + + var texture = Texture.fromImage('/base/test/textures/bunny.png'); + + // var obj = new Strip(texture, 20, 10000); + + + // pixi_extras_Strip_confirmNew(obj); + }); +}); diff --git a/test/unit/pixi-v2/extras/TilingSprite.js b/test/unit/pixi-v2/extras/TilingSprite.js new file mode 100644 index 0000000..56aea14 --- /dev/null +++ b/test/unit/pixi-v2/extras/TilingSprite.js @@ -0,0 +1,24 @@ +describe('pixi/extras/TilingSprite', function () { + 'use strict'; + + var expect = chai.expect; + var TilingSprite = PIXI.TilingSprite; + var Texture = PIXI.Texture; + + it('Module exists', function () { + expect(TilingSprite).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var texture = Texture.fromImage('/base/test/textures/bunny.png'); + var obj = new TilingSprite(texture, 6000, 12000); + + pixi_display_DisplayObjectContainer_confirmNew(obj); + + expect(obj).to.be.an.instanceof(TilingSprite); + expect(obj).to.respondTo('setTexture'); + expect(obj).to.respondTo('onTextureUpdate'); + + // TODO: Test properties + }); +}); diff --git a/test/unit/pixi-v2/filters/FilterBlock.js b/test/unit/pixi-v2/filters/FilterBlock.js new file mode 100644 index 0000000..870cec0 --- /dev/null +++ b/test/unit/pixi-v2/filters/FilterBlock.js @@ -0,0 +1,10 @@ +describe('pixi/filters/FilterBlock', function () { + 'use strict'; + + var expect = chai.expect; + var FilterBlock = PIXI.FilterBlock; + + it('Module exists', function () { + expect(FilterBlock).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/AssetLoader.js b/test/unit/pixi-v2/loaders/AssetLoader.js new file mode 100644 index 0000000..a0aa0b5 --- /dev/null +++ b/test/unit/pixi-v2/loaders/AssetLoader.js @@ -0,0 +1,10 @@ +describe('pixi/loaders/AssetLoader', function () { + 'use strict'; + + var expect = chai.expect; + var AssetLoader = PIXI.AssetLoader; + + it('Module exists', function () { + expect(AssetLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/BitmapFontLoader.js b/test/unit/pixi-v2/loaders/BitmapFontLoader.js new file mode 100644 index 0000000..046f018 --- /dev/null +++ b/test/unit/pixi-v2/loaders/BitmapFontLoader.js @@ -0,0 +1,9 @@ +describe('pixi/loaders/BitmapFontLoader', function () { + 'use strict'; + + var expect = chai.expect; + + it('Module exists', function () { + expect(PIXI.BitmapFontLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/ImageLoader.js b/test/unit/pixi-v2/loaders/ImageLoader.js new file mode 100644 index 0000000..8b1f556 --- /dev/null +++ b/test/unit/pixi-v2/loaders/ImageLoader.js @@ -0,0 +1,10 @@ +describe('pixi/loaders/ImageLoader', function () { + 'use strict'; + + var expect = chai.expect; + var ImageLoader = PIXI.ImageLoader; + + it('Module exists', function () { + expect(ImageLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/JsonLoader.js b/test/unit/pixi-v2/loaders/JsonLoader.js new file mode 100644 index 0000000..c577e83 --- /dev/null +++ b/test/unit/pixi-v2/loaders/JsonLoader.js @@ -0,0 +1,10 @@ +describe('pixi/loaders/JsonLoader', function () { + 'use strict'; + + var expect = chai.expect; + var JsonLoader = PIXI.JsonLoader; + + it('Module exists', function () { + expect(JsonLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/SpineLoader.js b/test/unit/pixi-v2/loaders/SpineLoader.js new file mode 100644 index 0000000..fdcc0b8 --- /dev/null +++ b/test/unit/pixi-v2/loaders/SpineLoader.js @@ -0,0 +1,10 @@ +describe('pixi/loaders/SpineLoader', function () { + 'use strict'; + + var expect = chai.expect; + var SpineLoader = PIXI.SpineLoader; + + it('Module exists', function () { + expect(SpineLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/SpriteSheetLoader.js b/test/unit/pixi-v2/loaders/SpriteSheetLoader.js new file mode 100644 index 0000000..57beb27 --- /dev/null +++ b/test/unit/pixi-v2/loaders/SpriteSheetLoader.js @@ -0,0 +1,10 @@ +describe('pixi/loaders/SpriteSheetLoader', function () { + 'use strict'; + + var expect = chai.expect; + var SpriteSheetLoader = PIXI.SpriteSheetLoader; + + it('Module exists', function () { + expect(SpriteSheetLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/primitives/Graphics.js b/test/unit/pixi-v2/primitives/Graphics.js new file mode 100644 index 0000000..f3849eb --- /dev/null +++ b/test/unit/pixi-v2/primitives/Graphics.js @@ -0,0 +1,44 @@ +describe('pixi/primitives/Graphics', function () { + 'use strict'; + + var expect = chai.expect; + var Graphics = PIXI.Graphics; + + it('Module exists', function () { + expect(Graphics).to.be.a('function'); + + expect(Graphics).itself.to.have.property('POLY', 0); + expect(Graphics).itself.to.have.property('RECT', 1); + expect(Graphics).itself.to.have.property('CIRC', 2); + expect(Graphics).itself.to.have.property('ELIP', 3); + expect(Graphics).itself.to.have.property('RREC', 4); + }); + + it('Confirm new instance', function () { + var obj = new Graphics(); + + pixi_display_DisplayObjectContainer_confirmNew(obj); + + expect(obj).to.be.an.instanceof(Graphics); + expect(obj).to.respondTo('lineStyle'); + expect(obj).to.respondTo('lineStyle'); + expect(obj).to.respondTo('moveTo'); + expect(obj).to.respondTo('lineTo'); + expect(obj).to.respondTo('beginFill'); + expect(obj).to.respondTo('endFill'); + expect(obj).to.respondTo('drawRect'); + // expect(obj).to.respondTo('drawRoundedRect'); + expect(obj).to.respondTo('drawCircle'); + expect(obj).to.respondTo('drawEllipse'); + expect(obj).to.respondTo('clear'); + + expect(obj).to.have.property('renderable', true); + expect(obj).to.have.property('fillAlpha', 1); + expect(obj).to.have.property('lineWidth', 0); + expect(obj).to.have.property('width', 0); + expect(obj).to.have.property('height', 0); + expect(obj).to.have.property('lineColor', 0); + expect(obj).to.have.deep.property('graphicsData.length', 0); + // expect(obj).to.have.deep.property('currentPath.points.length', 0); + }); +}); diff --git a/test/unit/pixi-v2/renderers/canvas/CanvasGraphics.js b/test/unit/pixi-v2/renderers/canvas/CanvasGraphics.js new file mode 100644 index 0000000..8f44472 --- /dev/null +++ b/test/unit/pixi-v2/renderers/canvas/CanvasGraphics.js @@ -0,0 +1,15 @@ +describe('renders/canvas/CanvasGraphics', function () { + 'use strict'; + + var expect = chai.expect; + var CanvasGraphics = PIXI.CanvasGraphics; + + it('Module exists', function () { + expect(CanvasGraphics).to.be.a('function'); + }); + + it('Members exist', function () { + expect(CanvasGraphics).itself.to.respondTo('renderGraphics'); + expect(CanvasGraphics).itself.to.respondTo('renderGraphicsMask'); + }); +}); diff --git a/test/unit/pixi-v2/renderers/canvas/CanvasRenderer.js b/test/unit/pixi-v2/renderers/canvas/CanvasRenderer.js new file mode 100644 index 0000000..1646444 --- /dev/null +++ b/test/unit/pixi-v2/renderers/canvas/CanvasRenderer.js @@ -0,0 +1,36 @@ +describe('renderers/canvas/CanvasRenderer', function () { + 'use strict'; + + var expect = chai.expect; + var CanvasRenderer = PIXI.CanvasRenderer; + + it('Module exists', function () { + expect(CanvasRenderer).to.be.a('function'); + }); + + describe('.autoResize', function () { + it('Should automatically resize view if enabled', function () { + var renderer = new CanvasRenderer(200, 200, { + autoResize: true + }); + + expect(renderer.view.style.width).to.equal('200px'); + }); + + it('Should not automatically resize view if disabled', function () { + var renderer = new CanvasRenderer(200, 200, { + autoResize: false + }); + + expect(renderer.view.style.width).to.equal(''); + }); + + it('Should not automatically resize view if not specified', function () { + var renderer = new CanvasRenderer(200, 200, { + resolution: 2 + }); + + expect(renderer.view.style.width).to.equal(''); + }); + }); +}); diff --git a/test/unit/pixi-v2/renderers/webgl/WebGLGraphics.js b/test/unit/pixi-v2/renderers/webgl/WebGLGraphics.js new file mode 100644 index 0000000..5867b28 --- /dev/null +++ b/test/unit/pixi-v2/renderers/webgl/WebGLGraphics.js @@ -0,0 +1,20 @@ +describe('renderers/wegbl/WebGLGraphics', function () { + 'use strict'; + + var expect = chai.expect; + var WebGLGraphics = PIXI.WebGLGraphics; + + it('Module exists', function () { + expect(WebGLGraphics).to.be.a('function'); + }); + + it('Members exist', function () { + expect(WebGLGraphics).itself.to.respondTo('renderGraphics'); + expect(WebGLGraphics).itself.to.respondTo('updateGraphics'); + expect(WebGLGraphics).itself.to.respondTo('buildRectangle'); + expect(WebGLGraphics).itself.to.respondTo('buildRoundedRectangle'); + expect(WebGLGraphics).itself.to.respondTo('buildCircle'); + expect(WebGLGraphics).itself.to.respondTo('buildLine'); + expect(WebGLGraphics).itself.to.respondTo('buildPoly'); + }); +}); diff --git a/test/unit/pixi-v2/renderers/webgl/WebGLRenderer.js b/test/unit/pixi-v2/renderers/webgl/WebGLRenderer.js new file mode 100644 index 0000000..1680a80 --- /dev/null +++ b/test/unit/pixi-v2/renderers/webgl/WebGLRenderer.js @@ -0,0 +1,49 @@ +describe('renderers/webgl/WebGLRenderer', function () { + 'use strict'; + + var expect = chai.expect; + var WebGLRenderer = PIXI.WebGLRenderer; + + it('Module exists', function () { + expect(WebGLRenderer).to.be.a('function'); + }); + + // Skip tests if WebGL is not available (WebGL not supported in Travis CI) + try { + var renderer = new WebGLRenderer(400, 300, {}); + renderer.destroy(); + } catch (error) { + return; + } + + it('Destroy renderer', function () { + var renderer = new WebGLRenderer(400, 300, {}); + renderer.destroy(); + }); + + describe('.autoResize', function () { + it('Should automatically resize view if enabled', function () { + var renderer = new WebGLRenderer(200, 200, { + autoResize: true + }); + + expect(renderer.view.style.width).to.equal('200px'); + }); + + it('Should not automatically resize view if disabled', function () { + var renderer = new WebGLRenderer(200, 200, { + autoResize: false + }); + + expect(renderer.view.style.width).to.equal(''); + }); + + it('Should not automatically resize view if not specified', function () { + var renderer = new WebGLRenderer(200, 200, { + resolution: 2 + }); + + expect(renderer.view.style.width).to.equal(''); + }); + }); +}); diff --git a/test/unit/pixi-v2/renderers/webgl/WebGLShaders.js b/test/unit/pixi-v2/renderers/webgl/WebGLShaders.js new file mode 100644 index 0000000..6e33e4f --- /dev/null +++ b/test/unit/pixi-v2/renderers/webgl/WebGLShaders.js @@ -0,0 +1,13 @@ +describe('renderers/webgl/WebGLShaders', function () { + 'use strict'; + + var expect = chai.expect; + + it('Module members exist', function () { + + expect(PIXI).to.respondTo('CompileVertexShader'); + expect(PIXI).to.respondTo('CompileFragmentShader'); + expect(PIXI).to.respondTo('_CompileShader'); + expect(PIXI).to.respondTo('compileProgram'); + }); +}); diff --git a/test/unit/pixi-v2/renderers/webgl/WebGLSpriteBatch.js b/test/unit/pixi-v2/renderers/webgl/WebGLSpriteBatch.js new file mode 100644 index 0000000..e662b63 --- /dev/null +++ b/test/unit/pixi-v2/renderers/webgl/WebGLSpriteBatch.js @@ -0,0 +1,10 @@ +describe('renderers/webgl/utils/WebGLSpriteBatch', function () { + 'use strict'; + + var expect = chai.expect; + var WebGLSpriteBatch = PIXI.WebGLSpriteBatch; + + it('Module exists', function () { + expect(WebGLSpriteBatch).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/text/BitmapText.js b/test/unit/pixi-v2/text/BitmapText.js new file mode 100644 index 0000000..9388e3d --- /dev/null +++ b/test/unit/pixi-v2/text/BitmapText.js @@ -0,0 +1,10 @@ +describe('pixi/text/BitmapText', function () { + 'use strict'; + + var expect = chai.expect; + var BitmapText = PIXI.BitmapText; + + it('Module exists', function () { + expect(BitmapText).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/text/Text.js b/test/unit/pixi-v2/text/Text.js new file mode 100644 index 0000000..9bc9ac5 --- /dev/null +++ b/test/unit/pixi-v2/text/Text.js @@ -0,0 +1,10 @@ +describe('pixi/text/Text', function () { + 'use strict'; + + var expect = chai.expect; + var Text = PIXI.Text; + + it('Module exists', function () { + expect(Text).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/textures/BaseTexture.js b/test/unit/pixi-v2/textures/BaseTexture.js new file mode 100644 index 0000000..502b724 --- /dev/null +++ b/test/unit/pixi-v2/textures/BaseTexture.js @@ -0,0 +1,11 @@ +describe('pixi/textures/BaseTexture', function () { + 'use strict'; + + var expect = chai.expect; + var BaseTexture = PIXI.BaseTexture; + + it('Module exists', function () { + expect(BaseTexture).to.be.a('function'); + expect(PIXI).to.have.property('BaseTextureCache').and.to.be.an('object'); + }); +}); diff --git a/test/unit/pixi-v2/textures/RenderTexture.js b/test/unit/pixi-v2/textures/RenderTexture.js new file mode 100644 index 0000000..96acdb4 --- /dev/null +++ b/test/unit/pixi-v2/textures/RenderTexture.js @@ -0,0 +1,15 @@ +describe('pixi/textures/RenderTexture', function () { + 'use strict'; + + var expect = chai.expect; + var RenderTexture = PIXI.RenderTexture; + + it('Module exists', function () { + expect(RenderTexture).to.be.a('function'); + }); + + it('Confirm new instance', function (done) { + var texture = new RenderTexture(100, 100, new PIXI.CanvasRenderer()); + pixi_textures_RenderTexture_confirmNew(texture, done); + }); +}); diff --git a/test/unit/pixi-v2/textures/Texture.js b/test/unit/pixi-v2/textures/Texture.js new file mode 100644 index 0000000..090f64d --- /dev/null +++ b/test/unit/pixi-v2/textures/Texture.js @@ -0,0 +1,26 @@ +describe('pixi/textures/Texture', function () { + 'use strict'; + + var expect = chai.expect; + var Texture = PIXI.Texture; + + it('Module exists', function () { + expect(Texture).to.be.a('function'); + expect(PIXI).to.have.property('TextureCache').and.to.be.an('object'); + }); + + it('Members exist', function () { + expect(Texture).itself.to.respondTo('fromImage'); + expect(Texture).itself.to.respondTo('fromFrame'); + expect(Texture).itself.to.respondTo('fromCanvas'); + expect(Texture).itself.to.respondTo('addTextureToCache'); + expect(Texture).itself.to.respondTo('removeTextureFromCache'); + + // expect(Texture).itself.to.have.deep.property('frameUpdates.length', 0); + }); + + it('Confirm new instance', function (done) { + var texture = Texture.fromImage('/base/test/textures/bunny.png'); + pixi_textures_Texture_confirmNew(texture, done); + }); +}); diff --git a/test/unit/pixi-v2/InteractionManager.js b/test/unit/pixi-v2/InteractionManager.js new file mode 100644 index 0000000..ed3001f --- /dev/null +++ b/test/unit/pixi-v2/InteractionManager.js @@ -0,0 +1,10 @@ +describe('pixi/InteractionManager', function () { + 'use strict'; + + var expect = chai.expect; + var InteractionManager = PIXI.InteractionManager; + + it('Module exists', function () { + expect(InteractionManager).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/Pixi.js b/test/unit/pixi-v2/Pixi.js new file mode 100644 index 0000000..27debc1 --- /dev/null +++ b/test/unit/pixi-v2/Pixi.js @@ -0,0 +1,9 @@ +describe('pixi/Pixi', function () { + 'use strict'; + + var expect = chai.expect; + + it('Module exists', function () { + expect(global).to.have.property('PIXI').and.to.be.an('object'); + }); +}); diff --git a/test/unit/pixi-v2/core/Circle.js b/test/unit/pixi-v2/core/Circle.js new file mode 100644 index 0000000..fbcfa17 --- /dev/null +++ b/test/unit/pixi-v2/core/Circle.js @@ -0,0 +1,21 @@ +describe('pixi/core/Circle', function () { + 'use strict'; + + var expect = chai.expect; + var Circle = PIXI.Circle; + + it('Module exists', function () { + expect(Circle).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Circle(); + pixi_core_Circle_confirmNewCircle(obj); + }); + + it("getBounds should return Rectangle that bounds the circle", function() { + var obj = new Circle(100, 250, 50); + var bounds = obj.getBounds(); + pixi_core_Circle_isBoundedByRectangle(obj, bounds); + }); +}); diff --git a/test/unit/pixi-v2/core/Ellipse.js b/test/unit/pixi-v2/core/Ellipse.js new file mode 100644 index 0000000..026b56f --- /dev/null +++ b/test/unit/pixi-v2/core/Ellipse.js @@ -0,0 +1,24 @@ +describe('pixi/core/Ellipse', function () { + 'use strict'; + + var expect = chai.expect; + var Ellipse = PIXI.Ellipse; + + it('Module exists', function () { + expect(Ellipse).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Ellipse(); + + expect(obj).to.be.an.instanceof(Ellipse); + expect(obj).to.respondTo('clone'); + expect(obj).to.respondTo('contains'); + expect(obj).to.respondTo('getBounds'); + + expect(obj).to.have.property('x', 0); + expect(obj).to.have.property('y', 0); + expect(obj).to.have.property('width', 0); + expect(obj).to.have.property('height', 0); + }); +}); diff --git a/test/unit/pixi-v2/core/Matrix.js b/test/unit/pixi-v2/core/Matrix.js new file mode 100644 index 0000000..da75e2e --- /dev/null +++ b/test/unit/pixi-v2/core/Matrix.js @@ -0,0 +1,14 @@ +describe('pixi/core/Matrix', function () { + 'use strict'; + + var expect = chai.expect; + + it('Matrix exists', function () { + expect(PIXI.Matrix).to.be.an('function'); + }); + + it('Confirm new Matrix', function () { + var matrix = new PIXI.Matrix(); + pixi_core_Matrix_confirmNewMatrix(matrix); + }); +}); diff --git a/test/unit/pixi-v2/core/Point.js b/test/unit/pixi-v2/core/Point.js new file mode 100644 index 0000000..c4d5163 --- /dev/null +++ b/test/unit/pixi-v2/core/Point.js @@ -0,0 +1,15 @@ +describe('pixi/core/Point', function () { + 'use strict'; + + var expect = chai.expect; + var Point = PIXI.Point; + + it('Module exists', function () { + expect(Point).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Point(); + pixi_core_Point_confirm(obj, 0, 0); + }); +}); diff --git a/test/unit/pixi-v2/core/Polygon.js b/test/unit/pixi-v2/core/Polygon.js new file mode 100644 index 0000000..dc8c918 --- /dev/null +++ b/test/unit/pixi-v2/core/Polygon.js @@ -0,0 +1,20 @@ +describe('pixi/core/Polygon', function () { + 'use strict'; + + var expect = chai.expect; + var Polygon = PIXI.Polygon; + + it('Module exists', function () { + expect(Polygon).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Polygon(); + + expect(obj).to.be.an.instanceof(Polygon); + expect(obj).to.respondTo('clone'); + expect(obj).to.respondTo('contains'); + + expect(obj).to.have.deep.property('points.length', 0); + }); +}); diff --git a/test/unit/pixi-v2/core/Rectangle.js b/test/unit/pixi-v2/core/Rectangle.js new file mode 100644 index 0000000..d43316e --- /dev/null +++ b/test/unit/pixi-v2/core/Rectangle.js @@ -0,0 +1,15 @@ +describe('pixi/core/Rectangle', function () { + 'use strict'; + + var expect = chai.expect; + var Rectangle = PIXI.Rectangle; + + it('Module exists', function () { + expect(Rectangle).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var rect = new Rectangle(); + pixi_core_Rectangle_confirm(rect, 0, 0, 0, 0); + }); +}); diff --git a/test/unit/pixi-v2/display/DisplayObject.js b/test/unit/pixi-v2/display/DisplayObject.js new file mode 100644 index 0000000..044acf8 --- /dev/null +++ b/test/unit/pixi-v2/display/DisplayObject.js @@ -0,0 +1,21 @@ +describe('pixi/display/DisplayObject', function () { + 'use strict'; + + var expect = chai.expect; + var DisplayObject = PIXI.DisplayObject; + + it('Module exists', function () { + expect(DisplayObject).to.be.a('function'); + // expect(PIXI).to.have.property('visibleCount', 0); + }); + + it('Confirm new instance', function () { + var obj = new DisplayObject(); + + pixi_display_DisplayObject_confirmNew(obj); + expect(obj).to.have.property('hitArea', null); + expect(obj).to.have.property('interactive', false); + expect(obj).to.have.property('renderable', false); + expect(obj).to.have.property('stage', null); + }); +}); diff --git a/test/unit/pixi-v2/display/DisplayObjectContainer.js b/test/unit/pixi-v2/display/DisplayObjectContainer.js new file mode 100644 index 0000000..15a3376 --- /dev/null +++ b/test/unit/pixi-v2/display/DisplayObjectContainer.js @@ -0,0 +1,67 @@ +describe('pixi/display/DisplayObjectContainer', function () { + 'use strict'; + + var expect = chai.expect; + var DisplayObjectContainer = PIXI.DisplayObjectContainer; + + it('Module exists', function () { + expect(DisplayObjectContainer).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new DisplayObjectContainer(); + + pixi_display_DisplayObjectContainer_confirmNew(obj); + expect(obj).to.have.property('hitArea', null); + expect(obj).to.have.property('interactive', false); + expect(obj).to.have.property('renderable', false); + expect(obj).to.have.property('stage', null); + }); + + it('Gets child index', function() { + var container = new PIXI.DisplayObjectContainer(); + var children = []; + for (var i = 0; i < 10; i++) { + var child = new PIXI.DisplayObject(); + children.push(child); + container.addChild(child); + } + + for (i = 0; i < children.length; i++) { + expect(i).to.eql(container.getChildIndex(children[i])); + } + }); + + it('throws error when trying to get index of not a child', function() { + var container = new PIXI.DisplayObjectContainer(); + var child = new PIXI.DisplayObject(); + + expect(function() { container.getChildIndex(child); }).to.throw(); + }); + + it('Sets child index', function() { + var container = new PIXI.DisplayObjectContainer(); + var children = []; + + for (var i = 0; i < 10; i++) { + var child = new PIXI.DisplayObject(); + children.push(child); + container.addChild(child); + } + children.reverse(); + + for (i = 0; i < children.length; i++) { + container.setChildIndex(children[i], i); + expect(i).to.eql(container.getChildIndex(children[i])); + } + }); + + it('throws error when trying to set incorect index', function() { + var container = new PIXI.DisplayObjectContainer(); + var child = new PIXI.DisplayObject(); + container.addChild(child); + + expect(function() { container.setChildIndex(child, -1); }).to.throw(); + expect(function() { container.setChildIndex(child, 1); }).to.throw(); + }); +}); diff --git a/test/unit/pixi-v2/display/MovieClip.js b/test/unit/pixi-v2/display/MovieClip.js new file mode 100644 index 0000000..f3c6c6a --- /dev/null +++ b/test/unit/pixi-v2/display/MovieClip.js @@ -0,0 +1,33 @@ +describe('pixi/display/MovieClip', function () { + 'use strict'; + + var expect = chai.expect; + var MovieClip = PIXI.MovieClip; + var Texture = PIXI.Texture; + + it('Module exists', function () { + expect(MovieClip).to.be.a('function'); + }); + + it('Confirm new instance', function (done) { + var texture = Texture.fromImage('/base/test/textures/SpriteSheet-Explosion.png'); + var obj = new MovieClip([texture]); + + pixi_display_Sprite_confirmNew(obj, done); + + expect(obj).to.be.an.instanceof(MovieClip); + expect(obj).to.respondTo('stop'); + expect(obj).to.respondTo('play'); + expect(obj).to.respondTo('gotoAndStop'); + expect(obj).to.respondTo('gotoAndPlay'); + expect(obj).to.respondTo('updateTransform'); + + expect(obj).to.have.deep.property('textures.length', 1); + expect(obj).to.have.deep.property('textures[0]', texture); + expect(obj).to.have.property('animationSpeed', 1); + expect(obj).to.have.property('loop', true); + expect(obj).to.have.property('onComplete', null); + expect(obj).to.have.property('currentFrame', 0); + expect(obj).to.have.property('playing', false); + }); +}); diff --git a/test/unit/pixi-v2/display/Sprite.js b/test/unit/pixi-v2/display/Sprite.js new file mode 100644 index 0000000..30c8076 --- /dev/null +++ b/test/unit/pixi-v2/display/Sprite.js @@ -0,0 +1,28 @@ +describe('pixi/display/Sprite', function () { + 'use strict'; + + var expect = chai.expect; + var Sprite = PIXI.Sprite; + var Texture = PIXI.Texture; + + it('Module exists', function () { + expect(Sprite).to.be.a('function'); + expect(PIXI).to.have.deep.property('blendModes.NORMAL', 0); + expect(PIXI).to.have.deep.property('blendModes.ADD', 1); + expect(PIXI).to.have.deep.property('blendModes.MULTIPLY', 2); + expect(PIXI).to.have.deep.property('blendModes.SCREEN', 3); + }); + + + it('Members exist', function () { + expect(Sprite).itself.to.respondTo('fromImage'); + expect(Sprite).itself.to.respondTo('fromFrame'); + }); + + it('Confirm new instance', function (done) { + var texture = Texture.fromImage('/base/test/textures/SpriteSheet-Aliens.png'); + var obj = new Sprite(texture); + + pixi_display_Sprite_confirmNew(obj, done); + }); +}); diff --git a/test/unit/pixi-v2/display/Stage.js b/test/unit/pixi-v2/display/Stage.js new file mode 100644 index 0000000..6974c2e --- /dev/null +++ b/test/unit/pixi-v2/display/Stage.js @@ -0,0 +1,49 @@ +describe('pixi/display/Stage', function () { + 'use strict'; + + var expect = chai.expect; + var Stage = PIXI.Stage; + var InteractionManager = PIXI.InteractionManager; + var Rectangle = PIXI.Rectangle; + + it('Module exists', function () { + expect(Stage).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Stage(null, true); + + pixi_display_DisplayObjectContainer_confirmNew(obj); + + expect(obj).to.be.an.instanceof(Stage); + expect(obj).to.respondTo('updateTransform'); + expect(obj).to.respondTo('setBackgroundColor'); + expect(obj).to.respondTo('getMousePosition'); + // FIXME: duplicate member in DisplayObject + pixi_core_Matrix_confirmNewMatrix(obj.worldTransform); + // FIXME: convert arg to bool in constructor + expect(obj).to.have.property('interactive', true); + + expect(obj).to.have.property('interactionManager') + .and.to.be.an.instanceof(InteractionManager) + .and.to.have.property('stage', obj); + + expect(obj).to.have.property('dirty', true); + + expect(obj).to.have.property('stage', obj); + + expect(obj).to.have.property('hitArea') + .and.to.be.an.instanceof(Rectangle); + pixi_core_Rectangle_confirm(obj.hitArea, 0, 0, 100000, 100000); + + expect(obj).to.have.property('backgroundColor', 0x000000); + expect(obj).to.have.deep.property('backgroundColorSplit.length', 3); + expect(obj).to.have.deep.property('backgroundColorSplit[0]', 0); + expect(obj).to.have.deep.property('backgroundColorSplit[1]', 0); + expect(obj).to.have.deep.property('backgroundColorSplit[2]', 0); + expect(obj).to.have.property('backgroundColorString', '#000000'); + + + expect(obj).to.have.property('worldVisible', true); + }); +}); diff --git a/test/unit/pixi-v2/extras/Rope.js b/test/unit/pixi-v2/extras/Rope.js new file mode 100644 index 0000000..05885ac --- /dev/null +++ b/test/unit/pixi-v2/extras/Rope.js @@ -0,0 +1,31 @@ +describe('pixi/extras/Rope', function () { + 'use strict'; + + var expect = chai.expect; + var Rope = PIXI.Rope; + var Texture = PIXI.Texture; + var Point = PIXI.Point; + + it('Module exists', function () { + expect(Rope).to.be.a('function'); + }); + + it('Confirm new instance', function () { + + var texture = Texture.fromImage('/base/test/textures/bunny.png'); + + // TODO-Alvin + // Same as Strip + + // var obj = new Rope(texture, [new Point(), new Point(5, 10), new Point(10, 20)]); + + // pixi_extras_Strip_confirmNew(obj); + + // expect(obj).to.be.an.instanceof(Rope); + // expect(obj).to.respondTo('refresh'); + // expect(obj).to.respondTo('updateTransform'); + // expect(obj).to.respondTo('setTexture'); + + // TODO: Test properties + }); +}); diff --git a/test/unit/pixi-v2/extras/Spine.js b/test/unit/pixi-v2/extras/Spine.js new file mode 100644 index 0000000..0708bc0 --- /dev/null +++ b/test/unit/pixi-v2/extras/Spine.js @@ -0,0 +1,10 @@ +describe('pixi/extras/Spine', function () { + 'use strict'; + + var expect = chai.expect; + var Spine = PIXI.Spine; + + it('Module exists', function () { + expect(Spine).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/extras/Strip.js b/test/unit/pixi-v2/extras/Strip.js new file mode 100644 index 0000000..230af90 --- /dev/null +++ b/test/unit/pixi-v2/extras/Strip.js @@ -0,0 +1,26 @@ +describe('pixi/extras/Strip', function () { + 'use strict'; + + var expect = chai.expect; + var Strip = PIXI.Strip; + var Texture = PIXI.Texture; + + it('Module exists', function () { + expect(Strip).to.be.a('function'); + }); + + it('Confirm new instance', function () { + + + // TODO-Alvin + // We tweaked it to make it pass the tests, but the whole strip class needs + // to be re-coded + + var texture = Texture.fromImage('/base/test/textures/bunny.png'); + + // var obj = new Strip(texture, 20, 10000); + + + // pixi_extras_Strip_confirmNew(obj); + }); +}); diff --git a/test/unit/pixi-v2/extras/TilingSprite.js b/test/unit/pixi-v2/extras/TilingSprite.js new file mode 100644 index 0000000..56aea14 --- /dev/null +++ b/test/unit/pixi-v2/extras/TilingSprite.js @@ -0,0 +1,24 @@ +describe('pixi/extras/TilingSprite', function () { + 'use strict'; + + var expect = chai.expect; + var TilingSprite = PIXI.TilingSprite; + var Texture = PIXI.Texture; + + it('Module exists', function () { + expect(TilingSprite).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var texture = Texture.fromImage('/base/test/textures/bunny.png'); + var obj = new TilingSprite(texture, 6000, 12000); + + pixi_display_DisplayObjectContainer_confirmNew(obj); + + expect(obj).to.be.an.instanceof(TilingSprite); + expect(obj).to.respondTo('setTexture'); + expect(obj).to.respondTo('onTextureUpdate'); + + // TODO: Test properties + }); +}); diff --git a/test/unit/pixi-v2/filters/FilterBlock.js b/test/unit/pixi-v2/filters/FilterBlock.js new file mode 100644 index 0000000..870cec0 --- /dev/null +++ b/test/unit/pixi-v2/filters/FilterBlock.js @@ -0,0 +1,10 @@ +describe('pixi/filters/FilterBlock', function () { + 'use strict'; + + var expect = chai.expect; + var FilterBlock = PIXI.FilterBlock; + + it('Module exists', function () { + expect(FilterBlock).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/AssetLoader.js b/test/unit/pixi-v2/loaders/AssetLoader.js new file mode 100644 index 0000000..a0aa0b5 --- /dev/null +++ b/test/unit/pixi-v2/loaders/AssetLoader.js @@ -0,0 +1,10 @@ +describe('pixi/loaders/AssetLoader', function () { + 'use strict'; + + var expect = chai.expect; + var AssetLoader = PIXI.AssetLoader; + + it('Module exists', function () { + expect(AssetLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/BitmapFontLoader.js b/test/unit/pixi-v2/loaders/BitmapFontLoader.js new file mode 100644 index 0000000..046f018 --- /dev/null +++ b/test/unit/pixi-v2/loaders/BitmapFontLoader.js @@ -0,0 +1,9 @@ +describe('pixi/loaders/BitmapFontLoader', function () { + 'use strict'; + + var expect = chai.expect; + + it('Module exists', function () { + expect(PIXI.BitmapFontLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/ImageLoader.js b/test/unit/pixi-v2/loaders/ImageLoader.js new file mode 100644 index 0000000..8b1f556 --- /dev/null +++ b/test/unit/pixi-v2/loaders/ImageLoader.js @@ -0,0 +1,10 @@ +describe('pixi/loaders/ImageLoader', function () { + 'use strict'; + + var expect = chai.expect; + var ImageLoader = PIXI.ImageLoader; + + it('Module exists', function () { + expect(ImageLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/JsonLoader.js b/test/unit/pixi-v2/loaders/JsonLoader.js new file mode 100644 index 0000000..c577e83 --- /dev/null +++ b/test/unit/pixi-v2/loaders/JsonLoader.js @@ -0,0 +1,10 @@ +describe('pixi/loaders/JsonLoader', function () { + 'use strict'; + + var expect = chai.expect; + var JsonLoader = PIXI.JsonLoader; + + it('Module exists', function () { + expect(JsonLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/SpineLoader.js b/test/unit/pixi-v2/loaders/SpineLoader.js new file mode 100644 index 0000000..fdcc0b8 --- /dev/null +++ b/test/unit/pixi-v2/loaders/SpineLoader.js @@ -0,0 +1,10 @@ +describe('pixi/loaders/SpineLoader', function () { + 'use strict'; + + var expect = chai.expect; + var SpineLoader = PIXI.SpineLoader; + + it('Module exists', function () { + expect(SpineLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/SpriteSheetLoader.js b/test/unit/pixi-v2/loaders/SpriteSheetLoader.js new file mode 100644 index 0000000..57beb27 --- /dev/null +++ b/test/unit/pixi-v2/loaders/SpriteSheetLoader.js @@ -0,0 +1,10 @@ +describe('pixi/loaders/SpriteSheetLoader', function () { + 'use strict'; + + var expect = chai.expect; + var SpriteSheetLoader = PIXI.SpriteSheetLoader; + + it('Module exists', function () { + expect(SpriteSheetLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/primitives/Graphics.js b/test/unit/pixi-v2/primitives/Graphics.js new file mode 100644 index 0000000..f3849eb --- /dev/null +++ b/test/unit/pixi-v2/primitives/Graphics.js @@ -0,0 +1,44 @@ +describe('pixi/primitives/Graphics', function () { + 'use strict'; + + var expect = chai.expect; + var Graphics = PIXI.Graphics; + + it('Module exists', function () { + expect(Graphics).to.be.a('function'); + + expect(Graphics).itself.to.have.property('POLY', 0); + expect(Graphics).itself.to.have.property('RECT', 1); + expect(Graphics).itself.to.have.property('CIRC', 2); + expect(Graphics).itself.to.have.property('ELIP', 3); + expect(Graphics).itself.to.have.property('RREC', 4); + }); + + it('Confirm new instance', function () { + var obj = new Graphics(); + + pixi_display_DisplayObjectContainer_confirmNew(obj); + + expect(obj).to.be.an.instanceof(Graphics); + expect(obj).to.respondTo('lineStyle'); + expect(obj).to.respondTo('lineStyle'); + expect(obj).to.respondTo('moveTo'); + expect(obj).to.respondTo('lineTo'); + expect(obj).to.respondTo('beginFill'); + expect(obj).to.respondTo('endFill'); + expect(obj).to.respondTo('drawRect'); + // expect(obj).to.respondTo('drawRoundedRect'); + expect(obj).to.respondTo('drawCircle'); + expect(obj).to.respondTo('drawEllipse'); + expect(obj).to.respondTo('clear'); + + expect(obj).to.have.property('renderable', true); + expect(obj).to.have.property('fillAlpha', 1); + expect(obj).to.have.property('lineWidth', 0); + expect(obj).to.have.property('width', 0); + expect(obj).to.have.property('height', 0); + expect(obj).to.have.property('lineColor', 0); + expect(obj).to.have.deep.property('graphicsData.length', 0); + // expect(obj).to.have.deep.property('currentPath.points.length', 0); + }); +}); diff --git a/test/unit/pixi-v2/renderers/canvas/CanvasGraphics.js b/test/unit/pixi-v2/renderers/canvas/CanvasGraphics.js new file mode 100644 index 0000000..8f44472 --- /dev/null +++ b/test/unit/pixi-v2/renderers/canvas/CanvasGraphics.js @@ -0,0 +1,15 @@ +describe('renders/canvas/CanvasGraphics', function () { + 'use strict'; + + var expect = chai.expect; + var CanvasGraphics = PIXI.CanvasGraphics; + + it('Module exists', function () { + expect(CanvasGraphics).to.be.a('function'); + }); + + it('Members exist', function () { + expect(CanvasGraphics).itself.to.respondTo('renderGraphics'); + expect(CanvasGraphics).itself.to.respondTo('renderGraphicsMask'); + }); +}); diff --git a/test/unit/pixi-v2/renderers/canvas/CanvasRenderer.js b/test/unit/pixi-v2/renderers/canvas/CanvasRenderer.js new file mode 100644 index 0000000..1646444 --- /dev/null +++ b/test/unit/pixi-v2/renderers/canvas/CanvasRenderer.js @@ -0,0 +1,36 @@ +describe('renderers/canvas/CanvasRenderer', function () { + 'use strict'; + + var expect = chai.expect; + var CanvasRenderer = PIXI.CanvasRenderer; + + it('Module exists', function () { + expect(CanvasRenderer).to.be.a('function'); + }); + + describe('.autoResize', function () { + it('Should automatically resize view if enabled', function () { + var renderer = new CanvasRenderer(200, 200, { + autoResize: true + }); + + expect(renderer.view.style.width).to.equal('200px'); + }); + + it('Should not automatically resize view if disabled', function () { + var renderer = new CanvasRenderer(200, 200, { + autoResize: false + }); + + expect(renderer.view.style.width).to.equal(''); + }); + + it('Should not automatically resize view if not specified', function () { + var renderer = new CanvasRenderer(200, 200, { + resolution: 2 + }); + + expect(renderer.view.style.width).to.equal(''); + }); + }); +}); diff --git a/test/unit/pixi-v2/renderers/webgl/WebGLGraphics.js b/test/unit/pixi-v2/renderers/webgl/WebGLGraphics.js new file mode 100644 index 0000000..5867b28 --- /dev/null +++ b/test/unit/pixi-v2/renderers/webgl/WebGLGraphics.js @@ -0,0 +1,20 @@ +describe('renderers/wegbl/WebGLGraphics', function () { + 'use strict'; + + var expect = chai.expect; + var WebGLGraphics = PIXI.WebGLGraphics; + + it('Module exists', function () { + expect(WebGLGraphics).to.be.a('function'); + }); + + it('Members exist', function () { + expect(WebGLGraphics).itself.to.respondTo('renderGraphics'); + expect(WebGLGraphics).itself.to.respondTo('updateGraphics'); + expect(WebGLGraphics).itself.to.respondTo('buildRectangle'); + expect(WebGLGraphics).itself.to.respondTo('buildRoundedRectangle'); + expect(WebGLGraphics).itself.to.respondTo('buildCircle'); + expect(WebGLGraphics).itself.to.respondTo('buildLine'); + expect(WebGLGraphics).itself.to.respondTo('buildPoly'); + }); +}); diff --git a/test/unit/pixi-v2/renderers/webgl/WebGLRenderer.js b/test/unit/pixi-v2/renderers/webgl/WebGLRenderer.js new file mode 100644 index 0000000..1680a80 --- /dev/null +++ b/test/unit/pixi-v2/renderers/webgl/WebGLRenderer.js @@ -0,0 +1,49 @@ +describe('renderers/webgl/WebGLRenderer', function () { + 'use strict'; + + var expect = chai.expect; + var WebGLRenderer = PIXI.WebGLRenderer; + + it('Module exists', function () { + expect(WebGLRenderer).to.be.a('function'); + }); + + // Skip tests if WebGL is not available (WebGL not supported in Travis CI) + try { + var renderer = new WebGLRenderer(400, 300, {}); + renderer.destroy(); + } catch (error) { + return; + } + + it('Destroy renderer', function () { + var renderer = new WebGLRenderer(400, 300, {}); + renderer.destroy(); + }); + + describe('.autoResize', function () { + it('Should automatically resize view if enabled', function () { + var renderer = new WebGLRenderer(200, 200, { + autoResize: true + }); + + expect(renderer.view.style.width).to.equal('200px'); + }); + + it('Should not automatically resize view if disabled', function () { + var renderer = new WebGLRenderer(200, 200, { + autoResize: false + }); + + expect(renderer.view.style.width).to.equal(''); + }); + + it('Should not automatically resize view if not specified', function () { + var renderer = new WebGLRenderer(200, 200, { + resolution: 2 + }); + + expect(renderer.view.style.width).to.equal(''); + }); + }); +}); diff --git a/test/unit/pixi-v2/renderers/webgl/WebGLShaders.js b/test/unit/pixi-v2/renderers/webgl/WebGLShaders.js new file mode 100644 index 0000000..6e33e4f --- /dev/null +++ b/test/unit/pixi-v2/renderers/webgl/WebGLShaders.js @@ -0,0 +1,13 @@ +describe('renderers/webgl/WebGLShaders', function () { + 'use strict'; + + var expect = chai.expect; + + it('Module members exist', function () { + + expect(PIXI).to.respondTo('CompileVertexShader'); + expect(PIXI).to.respondTo('CompileFragmentShader'); + expect(PIXI).to.respondTo('_CompileShader'); + expect(PIXI).to.respondTo('compileProgram'); + }); +}); diff --git a/test/unit/pixi-v2/renderers/webgl/WebGLSpriteBatch.js b/test/unit/pixi-v2/renderers/webgl/WebGLSpriteBatch.js new file mode 100644 index 0000000..e662b63 --- /dev/null +++ b/test/unit/pixi-v2/renderers/webgl/WebGLSpriteBatch.js @@ -0,0 +1,10 @@ +describe('renderers/webgl/utils/WebGLSpriteBatch', function () { + 'use strict'; + + var expect = chai.expect; + var WebGLSpriteBatch = PIXI.WebGLSpriteBatch; + + it('Module exists', function () { + expect(WebGLSpriteBatch).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/text/BitmapText.js b/test/unit/pixi-v2/text/BitmapText.js new file mode 100644 index 0000000..9388e3d --- /dev/null +++ b/test/unit/pixi-v2/text/BitmapText.js @@ -0,0 +1,10 @@ +describe('pixi/text/BitmapText', function () { + 'use strict'; + + var expect = chai.expect; + var BitmapText = PIXI.BitmapText; + + it('Module exists', function () { + expect(BitmapText).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/text/Text.js b/test/unit/pixi-v2/text/Text.js new file mode 100644 index 0000000..9bc9ac5 --- /dev/null +++ b/test/unit/pixi-v2/text/Text.js @@ -0,0 +1,10 @@ +describe('pixi/text/Text', function () { + 'use strict'; + + var expect = chai.expect; + var Text = PIXI.Text; + + it('Module exists', function () { + expect(Text).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/textures/BaseTexture.js b/test/unit/pixi-v2/textures/BaseTexture.js new file mode 100644 index 0000000..502b724 --- /dev/null +++ b/test/unit/pixi-v2/textures/BaseTexture.js @@ -0,0 +1,11 @@ +describe('pixi/textures/BaseTexture', function () { + 'use strict'; + + var expect = chai.expect; + var BaseTexture = PIXI.BaseTexture; + + it('Module exists', function () { + expect(BaseTexture).to.be.a('function'); + expect(PIXI).to.have.property('BaseTextureCache').and.to.be.an('object'); + }); +}); diff --git a/test/unit/pixi-v2/textures/RenderTexture.js b/test/unit/pixi-v2/textures/RenderTexture.js new file mode 100644 index 0000000..96acdb4 --- /dev/null +++ b/test/unit/pixi-v2/textures/RenderTexture.js @@ -0,0 +1,15 @@ +describe('pixi/textures/RenderTexture', function () { + 'use strict'; + + var expect = chai.expect; + var RenderTexture = PIXI.RenderTexture; + + it('Module exists', function () { + expect(RenderTexture).to.be.a('function'); + }); + + it('Confirm new instance', function (done) { + var texture = new RenderTexture(100, 100, new PIXI.CanvasRenderer()); + pixi_textures_RenderTexture_confirmNew(texture, done); + }); +}); diff --git a/test/unit/pixi-v2/textures/Texture.js b/test/unit/pixi-v2/textures/Texture.js new file mode 100644 index 0000000..090f64d --- /dev/null +++ b/test/unit/pixi-v2/textures/Texture.js @@ -0,0 +1,26 @@ +describe('pixi/textures/Texture', function () { + 'use strict'; + + var expect = chai.expect; + var Texture = PIXI.Texture; + + it('Module exists', function () { + expect(Texture).to.be.a('function'); + expect(PIXI).to.have.property('TextureCache').and.to.be.an('object'); + }); + + it('Members exist', function () { + expect(Texture).itself.to.respondTo('fromImage'); + expect(Texture).itself.to.respondTo('fromFrame'); + expect(Texture).itself.to.respondTo('fromCanvas'); + expect(Texture).itself.to.respondTo('addTextureToCache'); + expect(Texture).itself.to.respondTo('removeTextureFromCache'); + + // expect(Texture).itself.to.have.deep.property('frameUpdates.length', 0); + }); + + it('Confirm new instance', function (done) { + var texture = Texture.fromImage('/base/test/textures/bunny.png'); + pixi_textures_Texture_confirmNew(texture, done); + }); +}); diff --git a/test/unit/pixi-v2/utils/Detector.js b/test/unit/pixi-v2/utils/Detector.js new file mode 100644 index 0000000..4cf6008 --- /dev/null +++ b/test/unit/pixi-v2/utils/Detector.js @@ -0,0 +1,10 @@ +describe('pixi/utils/Detector', function () { + 'use strict'; + + var expect = chai.expect; + var autoDetectRenderer = PIXI.autoDetectRenderer; + + it('Module exists', function () { + expect(autoDetectRenderer).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/InteractionManager.js b/test/unit/pixi-v2/InteractionManager.js new file mode 100644 index 0000000..ed3001f --- /dev/null +++ b/test/unit/pixi-v2/InteractionManager.js @@ -0,0 +1,10 @@ +describe('pixi/InteractionManager', function () { + 'use strict'; + + var expect = chai.expect; + var InteractionManager = PIXI.InteractionManager; + + it('Module exists', function () { + expect(InteractionManager).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/Pixi.js b/test/unit/pixi-v2/Pixi.js new file mode 100644 index 0000000..27debc1 --- /dev/null +++ b/test/unit/pixi-v2/Pixi.js @@ -0,0 +1,9 @@ +describe('pixi/Pixi', function () { + 'use strict'; + + var expect = chai.expect; + + it('Module exists', function () { + expect(global).to.have.property('PIXI').and.to.be.an('object'); + }); +}); diff --git a/test/unit/pixi-v2/core/Circle.js b/test/unit/pixi-v2/core/Circle.js new file mode 100644 index 0000000..fbcfa17 --- /dev/null +++ b/test/unit/pixi-v2/core/Circle.js @@ -0,0 +1,21 @@ +describe('pixi/core/Circle', function () { + 'use strict'; + + var expect = chai.expect; + var Circle = PIXI.Circle; + + it('Module exists', function () { + expect(Circle).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Circle(); + pixi_core_Circle_confirmNewCircle(obj); + }); + + it("getBounds should return Rectangle that bounds the circle", function() { + var obj = new Circle(100, 250, 50); + var bounds = obj.getBounds(); + pixi_core_Circle_isBoundedByRectangle(obj, bounds); + }); +}); diff --git a/test/unit/pixi-v2/core/Ellipse.js b/test/unit/pixi-v2/core/Ellipse.js new file mode 100644 index 0000000..026b56f --- /dev/null +++ b/test/unit/pixi-v2/core/Ellipse.js @@ -0,0 +1,24 @@ +describe('pixi/core/Ellipse', function () { + 'use strict'; + + var expect = chai.expect; + var Ellipse = PIXI.Ellipse; + + it('Module exists', function () { + expect(Ellipse).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Ellipse(); + + expect(obj).to.be.an.instanceof(Ellipse); + expect(obj).to.respondTo('clone'); + expect(obj).to.respondTo('contains'); + expect(obj).to.respondTo('getBounds'); + + expect(obj).to.have.property('x', 0); + expect(obj).to.have.property('y', 0); + expect(obj).to.have.property('width', 0); + expect(obj).to.have.property('height', 0); + }); +}); diff --git a/test/unit/pixi-v2/core/Matrix.js b/test/unit/pixi-v2/core/Matrix.js new file mode 100644 index 0000000..da75e2e --- /dev/null +++ b/test/unit/pixi-v2/core/Matrix.js @@ -0,0 +1,14 @@ +describe('pixi/core/Matrix', function () { + 'use strict'; + + var expect = chai.expect; + + it('Matrix exists', function () { + expect(PIXI.Matrix).to.be.an('function'); + }); + + it('Confirm new Matrix', function () { + var matrix = new PIXI.Matrix(); + pixi_core_Matrix_confirmNewMatrix(matrix); + }); +}); diff --git a/test/unit/pixi-v2/core/Point.js b/test/unit/pixi-v2/core/Point.js new file mode 100644 index 0000000..c4d5163 --- /dev/null +++ b/test/unit/pixi-v2/core/Point.js @@ -0,0 +1,15 @@ +describe('pixi/core/Point', function () { + 'use strict'; + + var expect = chai.expect; + var Point = PIXI.Point; + + it('Module exists', function () { + expect(Point).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Point(); + pixi_core_Point_confirm(obj, 0, 0); + }); +}); diff --git a/test/unit/pixi-v2/core/Polygon.js b/test/unit/pixi-v2/core/Polygon.js new file mode 100644 index 0000000..dc8c918 --- /dev/null +++ b/test/unit/pixi-v2/core/Polygon.js @@ -0,0 +1,20 @@ +describe('pixi/core/Polygon', function () { + 'use strict'; + + var expect = chai.expect; + var Polygon = PIXI.Polygon; + + it('Module exists', function () { + expect(Polygon).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Polygon(); + + expect(obj).to.be.an.instanceof(Polygon); + expect(obj).to.respondTo('clone'); + expect(obj).to.respondTo('contains'); + + expect(obj).to.have.deep.property('points.length', 0); + }); +}); diff --git a/test/unit/pixi-v2/core/Rectangle.js b/test/unit/pixi-v2/core/Rectangle.js new file mode 100644 index 0000000..d43316e --- /dev/null +++ b/test/unit/pixi-v2/core/Rectangle.js @@ -0,0 +1,15 @@ +describe('pixi/core/Rectangle', function () { + 'use strict'; + + var expect = chai.expect; + var Rectangle = PIXI.Rectangle; + + it('Module exists', function () { + expect(Rectangle).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var rect = new Rectangle(); + pixi_core_Rectangle_confirm(rect, 0, 0, 0, 0); + }); +}); diff --git a/test/unit/pixi-v2/display/DisplayObject.js b/test/unit/pixi-v2/display/DisplayObject.js new file mode 100644 index 0000000..044acf8 --- /dev/null +++ b/test/unit/pixi-v2/display/DisplayObject.js @@ -0,0 +1,21 @@ +describe('pixi/display/DisplayObject', function () { + 'use strict'; + + var expect = chai.expect; + var DisplayObject = PIXI.DisplayObject; + + it('Module exists', function () { + expect(DisplayObject).to.be.a('function'); + // expect(PIXI).to.have.property('visibleCount', 0); + }); + + it('Confirm new instance', function () { + var obj = new DisplayObject(); + + pixi_display_DisplayObject_confirmNew(obj); + expect(obj).to.have.property('hitArea', null); + expect(obj).to.have.property('interactive', false); + expect(obj).to.have.property('renderable', false); + expect(obj).to.have.property('stage', null); + }); +}); diff --git a/test/unit/pixi-v2/display/DisplayObjectContainer.js b/test/unit/pixi-v2/display/DisplayObjectContainer.js new file mode 100644 index 0000000..15a3376 --- /dev/null +++ b/test/unit/pixi-v2/display/DisplayObjectContainer.js @@ -0,0 +1,67 @@ +describe('pixi/display/DisplayObjectContainer', function () { + 'use strict'; + + var expect = chai.expect; + var DisplayObjectContainer = PIXI.DisplayObjectContainer; + + it('Module exists', function () { + expect(DisplayObjectContainer).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new DisplayObjectContainer(); + + pixi_display_DisplayObjectContainer_confirmNew(obj); + expect(obj).to.have.property('hitArea', null); + expect(obj).to.have.property('interactive', false); + expect(obj).to.have.property('renderable', false); + expect(obj).to.have.property('stage', null); + }); + + it('Gets child index', function() { + var container = new PIXI.DisplayObjectContainer(); + var children = []; + for (var i = 0; i < 10; i++) { + var child = new PIXI.DisplayObject(); + children.push(child); + container.addChild(child); + } + + for (i = 0; i < children.length; i++) { + expect(i).to.eql(container.getChildIndex(children[i])); + } + }); + + it('throws error when trying to get index of not a child', function() { + var container = new PIXI.DisplayObjectContainer(); + var child = new PIXI.DisplayObject(); + + expect(function() { container.getChildIndex(child); }).to.throw(); + }); + + it('Sets child index', function() { + var container = new PIXI.DisplayObjectContainer(); + var children = []; + + for (var i = 0; i < 10; i++) { + var child = new PIXI.DisplayObject(); + children.push(child); + container.addChild(child); + } + children.reverse(); + + for (i = 0; i < children.length; i++) { + container.setChildIndex(children[i], i); + expect(i).to.eql(container.getChildIndex(children[i])); + } + }); + + it('throws error when trying to set incorect index', function() { + var container = new PIXI.DisplayObjectContainer(); + var child = new PIXI.DisplayObject(); + container.addChild(child); + + expect(function() { container.setChildIndex(child, -1); }).to.throw(); + expect(function() { container.setChildIndex(child, 1); }).to.throw(); + }); +}); diff --git a/test/unit/pixi-v2/display/MovieClip.js b/test/unit/pixi-v2/display/MovieClip.js new file mode 100644 index 0000000..f3c6c6a --- /dev/null +++ b/test/unit/pixi-v2/display/MovieClip.js @@ -0,0 +1,33 @@ +describe('pixi/display/MovieClip', function () { + 'use strict'; + + var expect = chai.expect; + var MovieClip = PIXI.MovieClip; + var Texture = PIXI.Texture; + + it('Module exists', function () { + expect(MovieClip).to.be.a('function'); + }); + + it('Confirm new instance', function (done) { + var texture = Texture.fromImage('/base/test/textures/SpriteSheet-Explosion.png'); + var obj = new MovieClip([texture]); + + pixi_display_Sprite_confirmNew(obj, done); + + expect(obj).to.be.an.instanceof(MovieClip); + expect(obj).to.respondTo('stop'); + expect(obj).to.respondTo('play'); + expect(obj).to.respondTo('gotoAndStop'); + expect(obj).to.respondTo('gotoAndPlay'); + expect(obj).to.respondTo('updateTransform'); + + expect(obj).to.have.deep.property('textures.length', 1); + expect(obj).to.have.deep.property('textures[0]', texture); + expect(obj).to.have.property('animationSpeed', 1); + expect(obj).to.have.property('loop', true); + expect(obj).to.have.property('onComplete', null); + expect(obj).to.have.property('currentFrame', 0); + expect(obj).to.have.property('playing', false); + }); +}); diff --git a/test/unit/pixi-v2/display/Sprite.js b/test/unit/pixi-v2/display/Sprite.js new file mode 100644 index 0000000..30c8076 --- /dev/null +++ b/test/unit/pixi-v2/display/Sprite.js @@ -0,0 +1,28 @@ +describe('pixi/display/Sprite', function () { + 'use strict'; + + var expect = chai.expect; + var Sprite = PIXI.Sprite; + var Texture = PIXI.Texture; + + it('Module exists', function () { + expect(Sprite).to.be.a('function'); + expect(PIXI).to.have.deep.property('blendModes.NORMAL', 0); + expect(PIXI).to.have.deep.property('blendModes.ADD', 1); + expect(PIXI).to.have.deep.property('blendModes.MULTIPLY', 2); + expect(PIXI).to.have.deep.property('blendModes.SCREEN', 3); + }); + + + it('Members exist', function () { + expect(Sprite).itself.to.respondTo('fromImage'); + expect(Sprite).itself.to.respondTo('fromFrame'); + }); + + it('Confirm new instance', function (done) { + var texture = Texture.fromImage('/base/test/textures/SpriteSheet-Aliens.png'); + var obj = new Sprite(texture); + + pixi_display_Sprite_confirmNew(obj, done); + }); +}); diff --git a/test/unit/pixi-v2/display/Stage.js b/test/unit/pixi-v2/display/Stage.js new file mode 100644 index 0000000..6974c2e --- /dev/null +++ b/test/unit/pixi-v2/display/Stage.js @@ -0,0 +1,49 @@ +describe('pixi/display/Stage', function () { + 'use strict'; + + var expect = chai.expect; + var Stage = PIXI.Stage; + var InteractionManager = PIXI.InteractionManager; + var Rectangle = PIXI.Rectangle; + + it('Module exists', function () { + expect(Stage).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Stage(null, true); + + pixi_display_DisplayObjectContainer_confirmNew(obj); + + expect(obj).to.be.an.instanceof(Stage); + expect(obj).to.respondTo('updateTransform'); + expect(obj).to.respondTo('setBackgroundColor'); + expect(obj).to.respondTo('getMousePosition'); + // FIXME: duplicate member in DisplayObject + pixi_core_Matrix_confirmNewMatrix(obj.worldTransform); + // FIXME: convert arg to bool in constructor + expect(obj).to.have.property('interactive', true); + + expect(obj).to.have.property('interactionManager') + .and.to.be.an.instanceof(InteractionManager) + .and.to.have.property('stage', obj); + + expect(obj).to.have.property('dirty', true); + + expect(obj).to.have.property('stage', obj); + + expect(obj).to.have.property('hitArea') + .and.to.be.an.instanceof(Rectangle); + pixi_core_Rectangle_confirm(obj.hitArea, 0, 0, 100000, 100000); + + expect(obj).to.have.property('backgroundColor', 0x000000); + expect(obj).to.have.deep.property('backgroundColorSplit.length', 3); + expect(obj).to.have.deep.property('backgroundColorSplit[0]', 0); + expect(obj).to.have.deep.property('backgroundColorSplit[1]', 0); + expect(obj).to.have.deep.property('backgroundColorSplit[2]', 0); + expect(obj).to.have.property('backgroundColorString', '#000000'); + + + expect(obj).to.have.property('worldVisible', true); + }); +}); diff --git a/test/unit/pixi-v2/extras/Rope.js b/test/unit/pixi-v2/extras/Rope.js new file mode 100644 index 0000000..05885ac --- /dev/null +++ b/test/unit/pixi-v2/extras/Rope.js @@ -0,0 +1,31 @@ +describe('pixi/extras/Rope', function () { + 'use strict'; + + var expect = chai.expect; + var Rope = PIXI.Rope; + var Texture = PIXI.Texture; + var Point = PIXI.Point; + + it('Module exists', function () { + expect(Rope).to.be.a('function'); + }); + + it('Confirm new instance', function () { + + var texture = Texture.fromImage('/base/test/textures/bunny.png'); + + // TODO-Alvin + // Same as Strip + + // var obj = new Rope(texture, [new Point(), new Point(5, 10), new Point(10, 20)]); + + // pixi_extras_Strip_confirmNew(obj); + + // expect(obj).to.be.an.instanceof(Rope); + // expect(obj).to.respondTo('refresh'); + // expect(obj).to.respondTo('updateTransform'); + // expect(obj).to.respondTo('setTexture'); + + // TODO: Test properties + }); +}); diff --git a/test/unit/pixi-v2/extras/Spine.js b/test/unit/pixi-v2/extras/Spine.js new file mode 100644 index 0000000..0708bc0 --- /dev/null +++ b/test/unit/pixi-v2/extras/Spine.js @@ -0,0 +1,10 @@ +describe('pixi/extras/Spine', function () { + 'use strict'; + + var expect = chai.expect; + var Spine = PIXI.Spine; + + it('Module exists', function () { + expect(Spine).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/extras/Strip.js b/test/unit/pixi-v2/extras/Strip.js new file mode 100644 index 0000000..230af90 --- /dev/null +++ b/test/unit/pixi-v2/extras/Strip.js @@ -0,0 +1,26 @@ +describe('pixi/extras/Strip', function () { + 'use strict'; + + var expect = chai.expect; + var Strip = PIXI.Strip; + var Texture = PIXI.Texture; + + it('Module exists', function () { + expect(Strip).to.be.a('function'); + }); + + it('Confirm new instance', function () { + + + // TODO-Alvin + // We tweaked it to make it pass the tests, but the whole strip class needs + // to be re-coded + + var texture = Texture.fromImage('/base/test/textures/bunny.png'); + + // var obj = new Strip(texture, 20, 10000); + + + // pixi_extras_Strip_confirmNew(obj); + }); +}); diff --git a/test/unit/pixi-v2/extras/TilingSprite.js b/test/unit/pixi-v2/extras/TilingSprite.js new file mode 100644 index 0000000..56aea14 --- /dev/null +++ b/test/unit/pixi-v2/extras/TilingSprite.js @@ -0,0 +1,24 @@ +describe('pixi/extras/TilingSprite', function () { + 'use strict'; + + var expect = chai.expect; + var TilingSprite = PIXI.TilingSprite; + var Texture = PIXI.Texture; + + it('Module exists', function () { + expect(TilingSprite).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var texture = Texture.fromImage('/base/test/textures/bunny.png'); + var obj = new TilingSprite(texture, 6000, 12000); + + pixi_display_DisplayObjectContainer_confirmNew(obj); + + expect(obj).to.be.an.instanceof(TilingSprite); + expect(obj).to.respondTo('setTexture'); + expect(obj).to.respondTo('onTextureUpdate'); + + // TODO: Test properties + }); +}); diff --git a/test/unit/pixi-v2/filters/FilterBlock.js b/test/unit/pixi-v2/filters/FilterBlock.js new file mode 100644 index 0000000..870cec0 --- /dev/null +++ b/test/unit/pixi-v2/filters/FilterBlock.js @@ -0,0 +1,10 @@ +describe('pixi/filters/FilterBlock', function () { + 'use strict'; + + var expect = chai.expect; + var FilterBlock = PIXI.FilterBlock; + + it('Module exists', function () { + expect(FilterBlock).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/AssetLoader.js b/test/unit/pixi-v2/loaders/AssetLoader.js new file mode 100644 index 0000000..a0aa0b5 --- /dev/null +++ b/test/unit/pixi-v2/loaders/AssetLoader.js @@ -0,0 +1,10 @@ +describe('pixi/loaders/AssetLoader', function () { + 'use strict'; + + var expect = chai.expect; + var AssetLoader = PIXI.AssetLoader; + + it('Module exists', function () { + expect(AssetLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/BitmapFontLoader.js b/test/unit/pixi-v2/loaders/BitmapFontLoader.js new file mode 100644 index 0000000..046f018 --- /dev/null +++ b/test/unit/pixi-v2/loaders/BitmapFontLoader.js @@ -0,0 +1,9 @@ +describe('pixi/loaders/BitmapFontLoader', function () { + 'use strict'; + + var expect = chai.expect; + + it('Module exists', function () { + expect(PIXI.BitmapFontLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/ImageLoader.js b/test/unit/pixi-v2/loaders/ImageLoader.js new file mode 100644 index 0000000..8b1f556 --- /dev/null +++ b/test/unit/pixi-v2/loaders/ImageLoader.js @@ -0,0 +1,10 @@ +describe('pixi/loaders/ImageLoader', function () { + 'use strict'; + + var expect = chai.expect; + var ImageLoader = PIXI.ImageLoader; + + it('Module exists', function () { + expect(ImageLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/JsonLoader.js b/test/unit/pixi-v2/loaders/JsonLoader.js new file mode 100644 index 0000000..c577e83 --- /dev/null +++ b/test/unit/pixi-v2/loaders/JsonLoader.js @@ -0,0 +1,10 @@ +describe('pixi/loaders/JsonLoader', function () { + 'use strict'; + + var expect = chai.expect; + var JsonLoader = PIXI.JsonLoader; + + it('Module exists', function () { + expect(JsonLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/SpineLoader.js b/test/unit/pixi-v2/loaders/SpineLoader.js new file mode 100644 index 0000000..fdcc0b8 --- /dev/null +++ b/test/unit/pixi-v2/loaders/SpineLoader.js @@ -0,0 +1,10 @@ +describe('pixi/loaders/SpineLoader', function () { + 'use strict'; + + var expect = chai.expect; + var SpineLoader = PIXI.SpineLoader; + + it('Module exists', function () { + expect(SpineLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/SpriteSheetLoader.js b/test/unit/pixi-v2/loaders/SpriteSheetLoader.js new file mode 100644 index 0000000..57beb27 --- /dev/null +++ b/test/unit/pixi-v2/loaders/SpriteSheetLoader.js @@ -0,0 +1,10 @@ +describe('pixi/loaders/SpriteSheetLoader', function () { + 'use strict'; + + var expect = chai.expect; + var SpriteSheetLoader = PIXI.SpriteSheetLoader; + + it('Module exists', function () { + expect(SpriteSheetLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/primitives/Graphics.js b/test/unit/pixi-v2/primitives/Graphics.js new file mode 100644 index 0000000..f3849eb --- /dev/null +++ b/test/unit/pixi-v2/primitives/Graphics.js @@ -0,0 +1,44 @@ +describe('pixi/primitives/Graphics', function () { + 'use strict'; + + var expect = chai.expect; + var Graphics = PIXI.Graphics; + + it('Module exists', function () { + expect(Graphics).to.be.a('function'); + + expect(Graphics).itself.to.have.property('POLY', 0); + expect(Graphics).itself.to.have.property('RECT', 1); + expect(Graphics).itself.to.have.property('CIRC', 2); + expect(Graphics).itself.to.have.property('ELIP', 3); + expect(Graphics).itself.to.have.property('RREC', 4); + }); + + it('Confirm new instance', function () { + var obj = new Graphics(); + + pixi_display_DisplayObjectContainer_confirmNew(obj); + + expect(obj).to.be.an.instanceof(Graphics); + expect(obj).to.respondTo('lineStyle'); + expect(obj).to.respondTo('lineStyle'); + expect(obj).to.respondTo('moveTo'); + expect(obj).to.respondTo('lineTo'); + expect(obj).to.respondTo('beginFill'); + expect(obj).to.respondTo('endFill'); + expect(obj).to.respondTo('drawRect'); + // expect(obj).to.respondTo('drawRoundedRect'); + expect(obj).to.respondTo('drawCircle'); + expect(obj).to.respondTo('drawEllipse'); + expect(obj).to.respondTo('clear'); + + expect(obj).to.have.property('renderable', true); + expect(obj).to.have.property('fillAlpha', 1); + expect(obj).to.have.property('lineWidth', 0); + expect(obj).to.have.property('width', 0); + expect(obj).to.have.property('height', 0); + expect(obj).to.have.property('lineColor', 0); + expect(obj).to.have.deep.property('graphicsData.length', 0); + // expect(obj).to.have.deep.property('currentPath.points.length', 0); + }); +}); diff --git a/test/unit/pixi-v2/renderers/canvas/CanvasGraphics.js b/test/unit/pixi-v2/renderers/canvas/CanvasGraphics.js new file mode 100644 index 0000000..8f44472 --- /dev/null +++ b/test/unit/pixi-v2/renderers/canvas/CanvasGraphics.js @@ -0,0 +1,15 @@ +describe('renders/canvas/CanvasGraphics', function () { + 'use strict'; + + var expect = chai.expect; + var CanvasGraphics = PIXI.CanvasGraphics; + + it('Module exists', function () { + expect(CanvasGraphics).to.be.a('function'); + }); + + it('Members exist', function () { + expect(CanvasGraphics).itself.to.respondTo('renderGraphics'); + expect(CanvasGraphics).itself.to.respondTo('renderGraphicsMask'); + }); +}); diff --git a/test/unit/pixi-v2/renderers/canvas/CanvasRenderer.js b/test/unit/pixi-v2/renderers/canvas/CanvasRenderer.js new file mode 100644 index 0000000..1646444 --- /dev/null +++ b/test/unit/pixi-v2/renderers/canvas/CanvasRenderer.js @@ -0,0 +1,36 @@ +describe('renderers/canvas/CanvasRenderer', function () { + 'use strict'; + + var expect = chai.expect; + var CanvasRenderer = PIXI.CanvasRenderer; + + it('Module exists', function () { + expect(CanvasRenderer).to.be.a('function'); + }); + + describe('.autoResize', function () { + it('Should automatically resize view if enabled', function () { + var renderer = new CanvasRenderer(200, 200, { + autoResize: true + }); + + expect(renderer.view.style.width).to.equal('200px'); + }); + + it('Should not automatically resize view if disabled', function () { + var renderer = new CanvasRenderer(200, 200, { + autoResize: false + }); + + expect(renderer.view.style.width).to.equal(''); + }); + + it('Should not automatically resize view if not specified', function () { + var renderer = new CanvasRenderer(200, 200, { + resolution: 2 + }); + + expect(renderer.view.style.width).to.equal(''); + }); + }); +}); diff --git a/test/unit/pixi-v2/renderers/webgl/WebGLGraphics.js b/test/unit/pixi-v2/renderers/webgl/WebGLGraphics.js new file mode 100644 index 0000000..5867b28 --- /dev/null +++ b/test/unit/pixi-v2/renderers/webgl/WebGLGraphics.js @@ -0,0 +1,20 @@ +describe('renderers/wegbl/WebGLGraphics', function () { + 'use strict'; + + var expect = chai.expect; + var WebGLGraphics = PIXI.WebGLGraphics; + + it('Module exists', function () { + expect(WebGLGraphics).to.be.a('function'); + }); + + it('Members exist', function () { + expect(WebGLGraphics).itself.to.respondTo('renderGraphics'); + expect(WebGLGraphics).itself.to.respondTo('updateGraphics'); + expect(WebGLGraphics).itself.to.respondTo('buildRectangle'); + expect(WebGLGraphics).itself.to.respondTo('buildRoundedRectangle'); + expect(WebGLGraphics).itself.to.respondTo('buildCircle'); + expect(WebGLGraphics).itself.to.respondTo('buildLine'); + expect(WebGLGraphics).itself.to.respondTo('buildPoly'); + }); +}); diff --git a/test/unit/pixi-v2/renderers/webgl/WebGLRenderer.js b/test/unit/pixi-v2/renderers/webgl/WebGLRenderer.js new file mode 100644 index 0000000..1680a80 --- /dev/null +++ b/test/unit/pixi-v2/renderers/webgl/WebGLRenderer.js @@ -0,0 +1,49 @@ +describe('renderers/webgl/WebGLRenderer', function () { + 'use strict'; + + var expect = chai.expect; + var WebGLRenderer = PIXI.WebGLRenderer; + + it('Module exists', function () { + expect(WebGLRenderer).to.be.a('function'); + }); + + // Skip tests if WebGL is not available (WebGL not supported in Travis CI) + try { + var renderer = new WebGLRenderer(400, 300, {}); + renderer.destroy(); + } catch (error) { + return; + } + + it('Destroy renderer', function () { + var renderer = new WebGLRenderer(400, 300, {}); + renderer.destroy(); + }); + + describe('.autoResize', function () { + it('Should automatically resize view if enabled', function () { + var renderer = new WebGLRenderer(200, 200, { + autoResize: true + }); + + expect(renderer.view.style.width).to.equal('200px'); + }); + + it('Should not automatically resize view if disabled', function () { + var renderer = new WebGLRenderer(200, 200, { + autoResize: false + }); + + expect(renderer.view.style.width).to.equal(''); + }); + + it('Should not automatically resize view if not specified', function () { + var renderer = new WebGLRenderer(200, 200, { + resolution: 2 + }); + + expect(renderer.view.style.width).to.equal(''); + }); + }); +}); diff --git a/test/unit/pixi-v2/renderers/webgl/WebGLShaders.js b/test/unit/pixi-v2/renderers/webgl/WebGLShaders.js new file mode 100644 index 0000000..6e33e4f --- /dev/null +++ b/test/unit/pixi-v2/renderers/webgl/WebGLShaders.js @@ -0,0 +1,13 @@ +describe('renderers/webgl/WebGLShaders', function () { + 'use strict'; + + var expect = chai.expect; + + it('Module members exist', function () { + + expect(PIXI).to.respondTo('CompileVertexShader'); + expect(PIXI).to.respondTo('CompileFragmentShader'); + expect(PIXI).to.respondTo('_CompileShader'); + expect(PIXI).to.respondTo('compileProgram'); + }); +}); diff --git a/test/unit/pixi-v2/renderers/webgl/WebGLSpriteBatch.js b/test/unit/pixi-v2/renderers/webgl/WebGLSpriteBatch.js new file mode 100644 index 0000000..e662b63 --- /dev/null +++ b/test/unit/pixi-v2/renderers/webgl/WebGLSpriteBatch.js @@ -0,0 +1,10 @@ +describe('renderers/webgl/utils/WebGLSpriteBatch', function () { + 'use strict'; + + var expect = chai.expect; + var WebGLSpriteBatch = PIXI.WebGLSpriteBatch; + + it('Module exists', function () { + expect(WebGLSpriteBatch).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/text/BitmapText.js b/test/unit/pixi-v2/text/BitmapText.js new file mode 100644 index 0000000..9388e3d --- /dev/null +++ b/test/unit/pixi-v2/text/BitmapText.js @@ -0,0 +1,10 @@ +describe('pixi/text/BitmapText', function () { + 'use strict'; + + var expect = chai.expect; + var BitmapText = PIXI.BitmapText; + + it('Module exists', function () { + expect(BitmapText).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/text/Text.js b/test/unit/pixi-v2/text/Text.js new file mode 100644 index 0000000..9bc9ac5 --- /dev/null +++ b/test/unit/pixi-v2/text/Text.js @@ -0,0 +1,10 @@ +describe('pixi/text/Text', function () { + 'use strict'; + + var expect = chai.expect; + var Text = PIXI.Text; + + it('Module exists', function () { + expect(Text).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/textures/BaseTexture.js b/test/unit/pixi-v2/textures/BaseTexture.js new file mode 100644 index 0000000..502b724 --- /dev/null +++ b/test/unit/pixi-v2/textures/BaseTexture.js @@ -0,0 +1,11 @@ +describe('pixi/textures/BaseTexture', function () { + 'use strict'; + + var expect = chai.expect; + var BaseTexture = PIXI.BaseTexture; + + it('Module exists', function () { + expect(BaseTexture).to.be.a('function'); + expect(PIXI).to.have.property('BaseTextureCache').and.to.be.an('object'); + }); +}); diff --git a/test/unit/pixi-v2/textures/RenderTexture.js b/test/unit/pixi-v2/textures/RenderTexture.js new file mode 100644 index 0000000..96acdb4 --- /dev/null +++ b/test/unit/pixi-v2/textures/RenderTexture.js @@ -0,0 +1,15 @@ +describe('pixi/textures/RenderTexture', function () { + 'use strict'; + + var expect = chai.expect; + var RenderTexture = PIXI.RenderTexture; + + it('Module exists', function () { + expect(RenderTexture).to.be.a('function'); + }); + + it('Confirm new instance', function (done) { + var texture = new RenderTexture(100, 100, new PIXI.CanvasRenderer()); + pixi_textures_RenderTexture_confirmNew(texture, done); + }); +}); diff --git a/test/unit/pixi-v2/textures/Texture.js b/test/unit/pixi-v2/textures/Texture.js new file mode 100644 index 0000000..090f64d --- /dev/null +++ b/test/unit/pixi-v2/textures/Texture.js @@ -0,0 +1,26 @@ +describe('pixi/textures/Texture', function () { + 'use strict'; + + var expect = chai.expect; + var Texture = PIXI.Texture; + + it('Module exists', function () { + expect(Texture).to.be.a('function'); + expect(PIXI).to.have.property('TextureCache').and.to.be.an('object'); + }); + + it('Members exist', function () { + expect(Texture).itself.to.respondTo('fromImage'); + expect(Texture).itself.to.respondTo('fromFrame'); + expect(Texture).itself.to.respondTo('fromCanvas'); + expect(Texture).itself.to.respondTo('addTextureToCache'); + expect(Texture).itself.to.respondTo('removeTextureFromCache'); + + // expect(Texture).itself.to.have.deep.property('frameUpdates.length', 0); + }); + + it('Confirm new instance', function (done) { + var texture = Texture.fromImage('/base/test/textures/bunny.png'); + pixi_textures_Texture_confirmNew(texture, done); + }); +}); diff --git a/test/unit/pixi-v2/utils/Detector.js b/test/unit/pixi-v2/utils/Detector.js new file mode 100644 index 0000000..4cf6008 --- /dev/null +++ b/test/unit/pixi-v2/utils/Detector.js @@ -0,0 +1,10 @@ +describe('pixi/utils/Detector', function () { + 'use strict'; + + var expect = chai.expect; + var autoDetectRenderer = PIXI.autoDetectRenderer; + + it('Module exists', function () { + expect(autoDetectRenderer).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/utils/EventTarget.js b/test/unit/pixi-v2/utils/EventTarget.js new file mode 100644 index 0000000..1cfc3a4 --- /dev/null +++ b/test/unit/pixi-v2/utils/EventTarget.js @@ -0,0 +1,361 @@ +describe('pixi/utils/EventTarget', function () { + 'use strict'; + + var expect = chai.expect; + + var Clazz, PClazz, obj, pobj, obj2; + beforeEach(function () { + Clazz = function () {}; + PClazz = function () {}; + + PIXI.EventTarget.mixin(Clazz.prototype); + PIXI.EventTarget.mixin(PClazz.prototype); + + obj = new Clazz(); + obj2 = new Clazz(); + pobj = new PClazz(); + + obj.parent = pobj; + obj2.parent = obj; + }); + + it('Module exists', function () { + expect(PIXI.EventTarget).to.be.an('object'); + }); + + it('Confirm new instance', function () { + pixi_utils_EventTarget_confirm(obj); + }); + + it('simple on/emit case works', function () { + var myData = {}; + + obj.on('myevent', function (event) { + pixi_utils_EventTarget_Event_confirm(event, obj, myData); + }); + + obj.emit('myevent', myData); + }); + + it('simple once case works', function () { + var called = 0; + + obj.once('myevent', function() { called++; }); + + obj.emit('myevent'); + obj.emit('myevent'); + obj.emit('myevent'); + obj.emit('myevent'); + obj.emit('myevent'); + + expect(called).to.equal(1); + }); + + it('simple off case works', function (done) { + function onMyEvent() { + done(new Error('Event listener should not have been called')); + } + + obj.on('myevent', onMyEvent); + obj.off('myevent', onMyEvent); + obj.emit('myevent'); + + done(); + }); + + it('simple propagation case works', function (done) { + var myData = {}; + + pobj.on('myevent', function () { + done(); + }); + + obj.emit('myevent'); + }); + + it('simple stopPropagation case works', function (done) { + var myData = {}; + + pobj.on('myevent', function () { + done(new Error('Event listener should not have been called on the parent element')); + }); + + obj.on('myevent', function (evt) { + evt.stopPropagation(); + }); + + obj.emit('myevent'); + + done(); + }); + + it('simple stopImmediatePropagation case works', function (done) { + var myData = {}; + + pobj.on('myevent', function () { + done(new Error('Event listener should not have been called on the parent')); + }); + + obj.on('myevent', function (evt) { + evt.stopImmediatePropagation(); + }); + + obj.on('myevent', function () { + done(new Error('Event listener should not have been called on the second')); + }); + + obj.emit('myevent'); + + done(); + }); + + it('multiple dispatches work properly', function () { + var called = 0; + + function onMyEvent() { + called++; + } + + obj.on('myevent', onMyEvent); + obj.emit('myevent'); + obj.emit('myevent'); + obj.emit('myevent'); + obj.emit('myevent'); + + expect(called).to.equal(4); + }); + + it('multiple events work properly', function () { + var called = 0; + + function onMyEvent() { + called++; + } + + obj.on('myevent1', onMyEvent); + obj.on('myevent2', onMyEvent); + obj.on('myevent3', onMyEvent); + obj.emit('myevent1'); + obj.emit('myevent2'); + obj.emit('myevent3'); + + expect(called).to.equal(3); + }); + + it('multiple events one removed works properly', function () { + var called = 0; + + function onMyEvent() { + called++; + } + + obj.on('myevent1', onMyEvent); + obj.on('myevent2', onMyEvent); + obj.on('myevent3', onMyEvent); + + obj.emit('myevent1'); + obj.emit('myevent2'); + obj.emit('myevent3'); + + obj.off('myevent2', onMyEvent); + + obj.emit('myevent1'); + obj.emit('myevent2'); + obj.emit('myevent3'); + + expect(called).to.equal(5); + }); + + it('multiple handlers for one event with some removed', function () { + var called = 0; + + var onMyEvent = function () { + called++; + }, + onMyEvent2 = function () { + called++; + }; + + // add 2 handlers and confirm they both get called + obj.on('myevent', onMyEvent); + obj.on('myevent', onMyEvent); + obj.on('myevent', onMyEvent2); + obj.on('myevent', onMyEvent2); + + obj.emit('myevent'); + + expect(called).to.equal(4); + + // remove one of the handlers, emit again, then ensure 1 more call is made + obj.off('myevent', onMyEvent); + + obj.emit('myevent'); + + expect(called).to.equal(6); + }); + + it('calls to off without a handler do nothing', function () { + var called = 0; + + var onMyEvent = function () { + called++; + }; + + obj.on('myevent', onMyEvent); + obj.on('myevent', onMyEvent); + + obj.emit('myevent'); + + expect(called).to.equal(2); + + obj.off('myevent'); + + obj.emit('myevent'); + + expect(called).to.equal(4); + + obj.off('myevent', onMyEvent); + + obj.emit('myevent'); + + expect(called).to.equal(4); + }); + + it('handles multiple instances with the same prototype', function () { + var called = 0; + + function onMyEvent(e) { + called++; + } + + obj.on('myevent1', onMyEvent); + obj.on('myevent2', onMyEvent); + + obj2.istwo = true; + obj2.on('myevent1', onMyEvent); + obj2.on('myevent2', onMyEvent); + + obj.emit('myevent1'); + obj.emit('myevent2'); + obj2.emit('myevent1'); + obj2.emit('myevent2'); + + //we emit 4 times, but since obj2 is a child of obj the event should bubble + //up to obj and show up there as well. So the obj2.emit() calls each increment + //the counter twice. + expect(called).to.equal(6); + }); + + it('is backwards compatible with older .dispatchEvent({})', function () { + var called = 0, + data = { + some: 'thing', + hello: true + }; + + function onMyEvent(event) { + pixi_utils_EventTarget_Event_confirm(event, obj, data); + + called++; + } + + obj.on('myevent1', onMyEvent); + obj.on('myevent2', onMyEvent); + obj.on('myevent3', onMyEvent); + + data.type = 'myevent1'; + obj.emit(data); + + data.type = 'myevent2'; + obj.emit(data); + + data.type = 'myevent3'; + obj.emit(data); + + obj.off('myevent2', onMyEvent); + + data.type = 'myevent1'; + obj.emit(data); + + data.type = 'myevent2'; + obj.emit(data); + + data.type = 'myevent3'; + obj.emit(data); + + expect(called).to.equal(5); + }); + + it('is backwards compatible with older .call(this)', function () { + var Fn = function() { + PIXI.EventTarget.call(this); + }, + o = new Fn(); + + pixi_utils_EventTarget_confirm(o); + }); + + it('is backwards compatible with older .addEventListener("")', function () { + var called = 0, + data = { + some: 'thing', + hello: true + }; + + function onMyEvent(event) { + pixi_utils_EventTarget_Event_confirm(event, obj, data); + + called++; + } + + obj.addEventListener('myevent1', onMyEvent); + obj.addEventListener('myevent2', onMyEvent); + obj.addEventListener('myevent3', onMyEvent); + + data.type = 'myevent1'; + obj.emit(data); + + data.type = 'myevent2'; + obj.emit(data); + + data.type = 'myevent3'; + obj.emit(data); + + obj.off('myevent2', onMyEvent); + + data.type = 'myevent1'; + obj.emit(data); + + data.type = 'myevent2'; + obj.emit(data); + + data.type = 'myevent3'; + obj.emit(data); + + expect(called).to.equal(5); + }); + + it('event remove during emit call properly', function () { + var called = 0; + + function cb1() { + called++; + obj.off('myevent', cb1); + } + function cb2() { + called++; + obj.off('myevent', cb2); + } + function cb3() { + called++; + obj.off('myevent', cb3); + } + + obj.on('myevent', cb1); + obj.on('myevent', cb2); + obj.on('myevent', cb3); + obj.emit('myevent', ''); + + expect(called).to.equal(3); + }); +}); diff --git a/test/unit/pixi-v2/InteractionManager.js b/test/unit/pixi-v2/InteractionManager.js new file mode 100644 index 0000000..ed3001f --- /dev/null +++ b/test/unit/pixi-v2/InteractionManager.js @@ -0,0 +1,10 @@ +describe('pixi/InteractionManager', function () { + 'use strict'; + + var expect = chai.expect; + var InteractionManager = PIXI.InteractionManager; + + it('Module exists', function () { + expect(InteractionManager).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/Pixi.js b/test/unit/pixi-v2/Pixi.js new file mode 100644 index 0000000..27debc1 --- /dev/null +++ b/test/unit/pixi-v2/Pixi.js @@ -0,0 +1,9 @@ +describe('pixi/Pixi', function () { + 'use strict'; + + var expect = chai.expect; + + it('Module exists', function () { + expect(global).to.have.property('PIXI').and.to.be.an('object'); + }); +}); diff --git a/test/unit/pixi-v2/core/Circle.js b/test/unit/pixi-v2/core/Circle.js new file mode 100644 index 0000000..fbcfa17 --- /dev/null +++ b/test/unit/pixi-v2/core/Circle.js @@ -0,0 +1,21 @@ +describe('pixi/core/Circle', function () { + 'use strict'; + + var expect = chai.expect; + var Circle = PIXI.Circle; + + it('Module exists', function () { + expect(Circle).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Circle(); + pixi_core_Circle_confirmNewCircle(obj); + }); + + it("getBounds should return Rectangle that bounds the circle", function() { + var obj = new Circle(100, 250, 50); + var bounds = obj.getBounds(); + pixi_core_Circle_isBoundedByRectangle(obj, bounds); + }); +}); diff --git a/test/unit/pixi-v2/core/Ellipse.js b/test/unit/pixi-v2/core/Ellipse.js new file mode 100644 index 0000000..026b56f --- /dev/null +++ b/test/unit/pixi-v2/core/Ellipse.js @@ -0,0 +1,24 @@ +describe('pixi/core/Ellipse', function () { + 'use strict'; + + var expect = chai.expect; + var Ellipse = PIXI.Ellipse; + + it('Module exists', function () { + expect(Ellipse).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Ellipse(); + + expect(obj).to.be.an.instanceof(Ellipse); + expect(obj).to.respondTo('clone'); + expect(obj).to.respondTo('contains'); + expect(obj).to.respondTo('getBounds'); + + expect(obj).to.have.property('x', 0); + expect(obj).to.have.property('y', 0); + expect(obj).to.have.property('width', 0); + expect(obj).to.have.property('height', 0); + }); +}); diff --git a/test/unit/pixi-v2/core/Matrix.js b/test/unit/pixi-v2/core/Matrix.js new file mode 100644 index 0000000..da75e2e --- /dev/null +++ b/test/unit/pixi-v2/core/Matrix.js @@ -0,0 +1,14 @@ +describe('pixi/core/Matrix', function () { + 'use strict'; + + var expect = chai.expect; + + it('Matrix exists', function () { + expect(PIXI.Matrix).to.be.an('function'); + }); + + it('Confirm new Matrix', function () { + var matrix = new PIXI.Matrix(); + pixi_core_Matrix_confirmNewMatrix(matrix); + }); +}); diff --git a/test/unit/pixi-v2/core/Point.js b/test/unit/pixi-v2/core/Point.js new file mode 100644 index 0000000..c4d5163 --- /dev/null +++ b/test/unit/pixi-v2/core/Point.js @@ -0,0 +1,15 @@ +describe('pixi/core/Point', function () { + 'use strict'; + + var expect = chai.expect; + var Point = PIXI.Point; + + it('Module exists', function () { + expect(Point).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Point(); + pixi_core_Point_confirm(obj, 0, 0); + }); +}); diff --git a/test/unit/pixi-v2/core/Polygon.js b/test/unit/pixi-v2/core/Polygon.js new file mode 100644 index 0000000..dc8c918 --- /dev/null +++ b/test/unit/pixi-v2/core/Polygon.js @@ -0,0 +1,20 @@ +describe('pixi/core/Polygon', function () { + 'use strict'; + + var expect = chai.expect; + var Polygon = PIXI.Polygon; + + it('Module exists', function () { + expect(Polygon).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Polygon(); + + expect(obj).to.be.an.instanceof(Polygon); + expect(obj).to.respondTo('clone'); + expect(obj).to.respondTo('contains'); + + expect(obj).to.have.deep.property('points.length', 0); + }); +}); diff --git a/test/unit/pixi-v2/core/Rectangle.js b/test/unit/pixi-v2/core/Rectangle.js new file mode 100644 index 0000000..d43316e --- /dev/null +++ b/test/unit/pixi-v2/core/Rectangle.js @@ -0,0 +1,15 @@ +describe('pixi/core/Rectangle', function () { + 'use strict'; + + var expect = chai.expect; + var Rectangle = PIXI.Rectangle; + + it('Module exists', function () { + expect(Rectangle).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var rect = new Rectangle(); + pixi_core_Rectangle_confirm(rect, 0, 0, 0, 0); + }); +}); diff --git a/test/unit/pixi-v2/display/DisplayObject.js b/test/unit/pixi-v2/display/DisplayObject.js new file mode 100644 index 0000000..044acf8 --- /dev/null +++ b/test/unit/pixi-v2/display/DisplayObject.js @@ -0,0 +1,21 @@ +describe('pixi/display/DisplayObject', function () { + 'use strict'; + + var expect = chai.expect; + var DisplayObject = PIXI.DisplayObject; + + it('Module exists', function () { + expect(DisplayObject).to.be.a('function'); + // expect(PIXI).to.have.property('visibleCount', 0); + }); + + it('Confirm new instance', function () { + var obj = new DisplayObject(); + + pixi_display_DisplayObject_confirmNew(obj); + expect(obj).to.have.property('hitArea', null); + expect(obj).to.have.property('interactive', false); + expect(obj).to.have.property('renderable', false); + expect(obj).to.have.property('stage', null); + }); +}); diff --git a/test/unit/pixi-v2/display/DisplayObjectContainer.js b/test/unit/pixi-v2/display/DisplayObjectContainer.js new file mode 100644 index 0000000..15a3376 --- /dev/null +++ b/test/unit/pixi-v2/display/DisplayObjectContainer.js @@ -0,0 +1,67 @@ +describe('pixi/display/DisplayObjectContainer', function () { + 'use strict'; + + var expect = chai.expect; + var DisplayObjectContainer = PIXI.DisplayObjectContainer; + + it('Module exists', function () { + expect(DisplayObjectContainer).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new DisplayObjectContainer(); + + pixi_display_DisplayObjectContainer_confirmNew(obj); + expect(obj).to.have.property('hitArea', null); + expect(obj).to.have.property('interactive', false); + expect(obj).to.have.property('renderable', false); + expect(obj).to.have.property('stage', null); + }); + + it('Gets child index', function() { + var container = new PIXI.DisplayObjectContainer(); + var children = []; + for (var i = 0; i < 10; i++) { + var child = new PIXI.DisplayObject(); + children.push(child); + container.addChild(child); + } + + for (i = 0; i < children.length; i++) { + expect(i).to.eql(container.getChildIndex(children[i])); + } + }); + + it('throws error when trying to get index of not a child', function() { + var container = new PIXI.DisplayObjectContainer(); + var child = new PIXI.DisplayObject(); + + expect(function() { container.getChildIndex(child); }).to.throw(); + }); + + it('Sets child index', function() { + var container = new PIXI.DisplayObjectContainer(); + var children = []; + + for (var i = 0; i < 10; i++) { + var child = new PIXI.DisplayObject(); + children.push(child); + container.addChild(child); + } + children.reverse(); + + for (i = 0; i < children.length; i++) { + container.setChildIndex(children[i], i); + expect(i).to.eql(container.getChildIndex(children[i])); + } + }); + + it('throws error when trying to set incorect index', function() { + var container = new PIXI.DisplayObjectContainer(); + var child = new PIXI.DisplayObject(); + container.addChild(child); + + expect(function() { container.setChildIndex(child, -1); }).to.throw(); + expect(function() { container.setChildIndex(child, 1); }).to.throw(); + }); +}); diff --git a/test/unit/pixi-v2/display/MovieClip.js b/test/unit/pixi-v2/display/MovieClip.js new file mode 100644 index 0000000..f3c6c6a --- /dev/null +++ b/test/unit/pixi-v2/display/MovieClip.js @@ -0,0 +1,33 @@ +describe('pixi/display/MovieClip', function () { + 'use strict'; + + var expect = chai.expect; + var MovieClip = PIXI.MovieClip; + var Texture = PIXI.Texture; + + it('Module exists', function () { + expect(MovieClip).to.be.a('function'); + }); + + it('Confirm new instance', function (done) { + var texture = Texture.fromImage('/base/test/textures/SpriteSheet-Explosion.png'); + var obj = new MovieClip([texture]); + + pixi_display_Sprite_confirmNew(obj, done); + + expect(obj).to.be.an.instanceof(MovieClip); + expect(obj).to.respondTo('stop'); + expect(obj).to.respondTo('play'); + expect(obj).to.respondTo('gotoAndStop'); + expect(obj).to.respondTo('gotoAndPlay'); + expect(obj).to.respondTo('updateTransform'); + + expect(obj).to.have.deep.property('textures.length', 1); + expect(obj).to.have.deep.property('textures[0]', texture); + expect(obj).to.have.property('animationSpeed', 1); + expect(obj).to.have.property('loop', true); + expect(obj).to.have.property('onComplete', null); + expect(obj).to.have.property('currentFrame', 0); + expect(obj).to.have.property('playing', false); + }); +}); diff --git a/test/unit/pixi-v2/display/Sprite.js b/test/unit/pixi-v2/display/Sprite.js new file mode 100644 index 0000000..30c8076 --- /dev/null +++ b/test/unit/pixi-v2/display/Sprite.js @@ -0,0 +1,28 @@ +describe('pixi/display/Sprite', function () { + 'use strict'; + + var expect = chai.expect; + var Sprite = PIXI.Sprite; + var Texture = PIXI.Texture; + + it('Module exists', function () { + expect(Sprite).to.be.a('function'); + expect(PIXI).to.have.deep.property('blendModes.NORMAL', 0); + expect(PIXI).to.have.deep.property('blendModes.ADD', 1); + expect(PIXI).to.have.deep.property('blendModes.MULTIPLY', 2); + expect(PIXI).to.have.deep.property('blendModes.SCREEN', 3); + }); + + + it('Members exist', function () { + expect(Sprite).itself.to.respondTo('fromImage'); + expect(Sprite).itself.to.respondTo('fromFrame'); + }); + + it('Confirm new instance', function (done) { + var texture = Texture.fromImage('/base/test/textures/SpriteSheet-Aliens.png'); + var obj = new Sprite(texture); + + pixi_display_Sprite_confirmNew(obj, done); + }); +}); diff --git a/test/unit/pixi-v2/display/Stage.js b/test/unit/pixi-v2/display/Stage.js new file mode 100644 index 0000000..6974c2e --- /dev/null +++ b/test/unit/pixi-v2/display/Stage.js @@ -0,0 +1,49 @@ +describe('pixi/display/Stage', function () { + 'use strict'; + + var expect = chai.expect; + var Stage = PIXI.Stage; + var InteractionManager = PIXI.InteractionManager; + var Rectangle = PIXI.Rectangle; + + it('Module exists', function () { + expect(Stage).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Stage(null, true); + + pixi_display_DisplayObjectContainer_confirmNew(obj); + + expect(obj).to.be.an.instanceof(Stage); + expect(obj).to.respondTo('updateTransform'); + expect(obj).to.respondTo('setBackgroundColor'); + expect(obj).to.respondTo('getMousePosition'); + // FIXME: duplicate member in DisplayObject + pixi_core_Matrix_confirmNewMatrix(obj.worldTransform); + // FIXME: convert arg to bool in constructor + expect(obj).to.have.property('interactive', true); + + expect(obj).to.have.property('interactionManager') + .and.to.be.an.instanceof(InteractionManager) + .and.to.have.property('stage', obj); + + expect(obj).to.have.property('dirty', true); + + expect(obj).to.have.property('stage', obj); + + expect(obj).to.have.property('hitArea') + .and.to.be.an.instanceof(Rectangle); + pixi_core_Rectangle_confirm(obj.hitArea, 0, 0, 100000, 100000); + + expect(obj).to.have.property('backgroundColor', 0x000000); + expect(obj).to.have.deep.property('backgroundColorSplit.length', 3); + expect(obj).to.have.deep.property('backgroundColorSplit[0]', 0); + expect(obj).to.have.deep.property('backgroundColorSplit[1]', 0); + expect(obj).to.have.deep.property('backgroundColorSplit[2]', 0); + expect(obj).to.have.property('backgroundColorString', '#000000'); + + + expect(obj).to.have.property('worldVisible', true); + }); +}); diff --git a/test/unit/pixi-v2/extras/Rope.js b/test/unit/pixi-v2/extras/Rope.js new file mode 100644 index 0000000..05885ac --- /dev/null +++ b/test/unit/pixi-v2/extras/Rope.js @@ -0,0 +1,31 @@ +describe('pixi/extras/Rope', function () { + 'use strict'; + + var expect = chai.expect; + var Rope = PIXI.Rope; + var Texture = PIXI.Texture; + var Point = PIXI.Point; + + it('Module exists', function () { + expect(Rope).to.be.a('function'); + }); + + it('Confirm new instance', function () { + + var texture = Texture.fromImage('/base/test/textures/bunny.png'); + + // TODO-Alvin + // Same as Strip + + // var obj = new Rope(texture, [new Point(), new Point(5, 10), new Point(10, 20)]); + + // pixi_extras_Strip_confirmNew(obj); + + // expect(obj).to.be.an.instanceof(Rope); + // expect(obj).to.respondTo('refresh'); + // expect(obj).to.respondTo('updateTransform'); + // expect(obj).to.respondTo('setTexture'); + + // TODO: Test properties + }); +}); diff --git a/test/unit/pixi-v2/extras/Spine.js b/test/unit/pixi-v2/extras/Spine.js new file mode 100644 index 0000000..0708bc0 --- /dev/null +++ b/test/unit/pixi-v2/extras/Spine.js @@ -0,0 +1,10 @@ +describe('pixi/extras/Spine', function () { + 'use strict'; + + var expect = chai.expect; + var Spine = PIXI.Spine; + + it('Module exists', function () { + expect(Spine).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/extras/Strip.js b/test/unit/pixi-v2/extras/Strip.js new file mode 100644 index 0000000..230af90 --- /dev/null +++ b/test/unit/pixi-v2/extras/Strip.js @@ -0,0 +1,26 @@ +describe('pixi/extras/Strip', function () { + 'use strict'; + + var expect = chai.expect; + var Strip = PIXI.Strip; + var Texture = PIXI.Texture; + + it('Module exists', function () { + expect(Strip).to.be.a('function'); + }); + + it('Confirm new instance', function () { + + + // TODO-Alvin + // We tweaked it to make it pass the tests, but the whole strip class needs + // to be re-coded + + var texture = Texture.fromImage('/base/test/textures/bunny.png'); + + // var obj = new Strip(texture, 20, 10000); + + + // pixi_extras_Strip_confirmNew(obj); + }); +}); diff --git a/test/unit/pixi-v2/extras/TilingSprite.js b/test/unit/pixi-v2/extras/TilingSprite.js new file mode 100644 index 0000000..56aea14 --- /dev/null +++ b/test/unit/pixi-v2/extras/TilingSprite.js @@ -0,0 +1,24 @@ +describe('pixi/extras/TilingSprite', function () { + 'use strict'; + + var expect = chai.expect; + var TilingSprite = PIXI.TilingSprite; + var Texture = PIXI.Texture; + + it('Module exists', function () { + expect(TilingSprite).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var texture = Texture.fromImage('/base/test/textures/bunny.png'); + var obj = new TilingSprite(texture, 6000, 12000); + + pixi_display_DisplayObjectContainer_confirmNew(obj); + + expect(obj).to.be.an.instanceof(TilingSprite); + expect(obj).to.respondTo('setTexture'); + expect(obj).to.respondTo('onTextureUpdate'); + + // TODO: Test properties + }); +}); diff --git a/test/unit/pixi-v2/filters/FilterBlock.js b/test/unit/pixi-v2/filters/FilterBlock.js new file mode 100644 index 0000000..870cec0 --- /dev/null +++ b/test/unit/pixi-v2/filters/FilterBlock.js @@ -0,0 +1,10 @@ +describe('pixi/filters/FilterBlock', function () { + 'use strict'; + + var expect = chai.expect; + var FilterBlock = PIXI.FilterBlock; + + it('Module exists', function () { + expect(FilterBlock).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/AssetLoader.js b/test/unit/pixi-v2/loaders/AssetLoader.js new file mode 100644 index 0000000..a0aa0b5 --- /dev/null +++ b/test/unit/pixi-v2/loaders/AssetLoader.js @@ -0,0 +1,10 @@ +describe('pixi/loaders/AssetLoader', function () { + 'use strict'; + + var expect = chai.expect; + var AssetLoader = PIXI.AssetLoader; + + it('Module exists', function () { + expect(AssetLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/BitmapFontLoader.js b/test/unit/pixi-v2/loaders/BitmapFontLoader.js new file mode 100644 index 0000000..046f018 --- /dev/null +++ b/test/unit/pixi-v2/loaders/BitmapFontLoader.js @@ -0,0 +1,9 @@ +describe('pixi/loaders/BitmapFontLoader', function () { + 'use strict'; + + var expect = chai.expect; + + it('Module exists', function () { + expect(PIXI.BitmapFontLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/ImageLoader.js b/test/unit/pixi-v2/loaders/ImageLoader.js new file mode 100644 index 0000000..8b1f556 --- /dev/null +++ b/test/unit/pixi-v2/loaders/ImageLoader.js @@ -0,0 +1,10 @@ +describe('pixi/loaders/ImageLoader', function () { + 'use strict'; + + var expect = chai.expect; + var ImageLoader = PIXI.ImageLoader; + + it('Module exists', function () { + expect(ImageLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/JsonLoader.js b/test/unit/pixi-v2/loaders/JsonLoader.js new file mode 100644 index 0000000..c577e83 --- /dev/null +++ b/test/unit/pixi-v2/loaders/JsonLoader.js @@ -0,0 +1,10 @@ +describe('pixi/loaders/JsonLoader', function () { + 'use strict'; + + var expect = chai.expect; + var JsonLoader = PIXI.JsonLoader; + + it('Module exists', function () { + expect(JsonLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/SpineLoader.js b/test/unit/pixi-v2/loaders/SpineLoader.js new file mode 100644 index 0000000..fdcc0b8 --- /dev/null +++ b/test/unit/pixi-v2/loaders/SpineLoader.js @@ -0,0 +1,10 @@ +describe('pixi/loaders/SpineLoader', function () { + 'use strict'; + + var expect = chai.expect; + var SpineLoader = PIXI.SpineLoader; + + it('Module exists', function () { + expect(SpineLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/SpriteSheetLoader.js b/test/unit/pixi-v2/loaders/SpriteSheetLoader.js new file mode 100644 index 0000000..57beb27 --- /dev/null +++ b/test/unit/pixi-v2/loaders/SpriteSheetLoader.js @@ -0,0 +1,10 @@ +describe('pixi/loaders/SpriteSheetLoader', function () { + 'use strict'; + + var expect = chai.expect; + var SpriteSheetLoader = PIXI.SpriteSheetLoader; + + it('Module exists', function () { + expect(SpriteSheetLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/primitives/Graphics.js b/test/unit/pixi-v2/primitives/Graphics.js new file mode 100644 index 0000000..f3849eb --- /dev/null +++ b/test/unit/pixi-v2/primitives/Graphics.js @@ -0,0 +1,44 @@ +describe('pixi/primitives/Graphics', function () { + 'use strict'; + + var expect = chai.expect; + var Graphics = PIXI.Graphics; + + it('Module exists', function () { + expect(Graphics).to.be.a('function'); + + expect(Graphics).itself.to.have.property('POLY', 0); + expect(Graphics).itself.to.have.property('RECT', 1); + expect(Graphics).itself.to.have.property('CIRC', 2); + expect(Graphics).itself.to.have.property('ELIP', 3); + expect(Graphics).itself.to.have.property('RREC', 4); + }); + + it('Confirm new instance', function () { + var obj = new Graphics(); + + pixi_display_DisplayObjectContainer_confirmNew(obj); + + expect(obj).to.be.an.instanceof(Graphics); + expect(obj).to.respondTo('lineStyle'); + expect(obj).to.respondTo('lineStyle'); + expect(obj).to.respondTo('moveTo'); + expect(obj).to.respondTo('lineTo'); + expect(obj).to.respondTo('beginFill'); + expect(obj).to.respondTo('endFill'); + expect(obj).to.respondTo('drawRect'); + // expect(obj).to.respondTo('drawRoundedRect'); + expect(obj).to.respondTo('drawCircle'); + expect(obj).to.respondTo('drawEllipse'); + expect(obj).to.respondTo('clear'); + + expect(obj).to.have.property('renderable', true); + expect(obj).to.have.property('fillAlpha', 1); + expect(obj).to.have.property('lineWidth', 0); + expect(obj).to.have.property('width', 0); + expect(obj).to.have.property('height', 0); + expect(obj).to.have.property('lineColor', 0); + expect(obj).to.have.deep.property('graphicsData.length', 0); + // expect(obj).to.have.deep.property('currentPath.points.length', 0); + }); +}); diff --git a/test/unit/pixi-v2/renderers/canvas/CanvasGraphics.js b/test/unit/pixi-v2/renderers/canvas/CanvasGraphics.js new file mode 100644 index 0000000..8f44472 --- /dev/null +++ b/test/unit/pixi-v2/renderers/canvas/CanvasGraphics.js @@ -0,0 +1,15 @@ +describe('renders/canvas/CanvasGraphics', function () { + 'use strict'; + + var expect = chai.expect; + var CanvasGraphics = PIXI.CanvasGraphics; + + it('Module exists', function () { + expect(CanvasGraphics).to.be.a('function'); + }); + + it('Members exist', function () { + expect(CanvasGraphics).itself.to.respondTo('renderGraphics'); + expect(CanvasGraphics).itself.to.respondTo('renderGraphicsMask'); + }); +}); diff --git a/test/unit/pixi-v2/renderers/canvas/CanvasRenderer.js b/test/unit/pixi-v2/renderers/canvas/CanvasRenderer.js new file mode 100644 index 0000000..1646444 --- /dev/null +++ b/test/unit/pixi-v2/renderers/canvas/CanvasRenderer.js @@ -0,0 +1,36 @@ +describe('renderers/canvas/CanvasRenderer', function () { + 'use strict'; + + var expect = chai.expect; + var CanvasRenderer = PIXI.CanvasRenderer; + + it('Module exists', function () { + expect(CanvasRenderer).to.be.a('function'); + }); + + describe('.autoResize', function () { + it('Should automatically resize view if enabled', function () { + var renderer = new CanvasRenderer(200, 200, { + autoResize: true + }); + + expect(renderer.view.style.width).to.equal('200px'); + }); + + it('Should not automatically resize view if disabled', function () { + var renderer = new CanvasRenderer(200, 200, { + autoResize: false + }); + + expect(renderer.view.style.width).to.equal(''); + }); + + it('Should not automatically resize view if not specified', function () { + var renderer = new CanvasRenderer(200, 200, { + resolution: 2 + }); + + expect(renderer.view.style.width).to.equal(''); + }); + }); +}); diff --git a/test/unit/pixi-v2/renderers/webgl/WebGLGraphics.js b/test/unit/pixi-v2/renderers/webgl/WebGLGraphics.js new file mode 100644 index 0000000..5867b28 --- /dev/null +++ b/test/unit/pixi-v2/renderers/webgl/WebGLGraphics.js @@ -0,0 +1,20 @@ +describe('renderers/wegbl/WebGLGraphics', function () { + 'use strict'; + + var expect = chai.expect; + var WebGLGraphics = PIXI.WebGLGraphics; + + it('Module exists', function () { + expect(WebGLGraphics).to.be.a('function'); + }); + + it('Members exist', function () { + expect(WebGLGraphics).itself.to.respondTo('renderGraphics'); + expect(WebGLGraphics).itself.to.respondTo('updateGraphics'); + expect(WebGLGraphics).itself.to.respondTo('buildRectangle'); + expect(WebGLGraphics).itself.to.respondTo('buildRoundedRectangle'); + expect(WebGLGraphics).itself.to.respondTo('buildCircle'); + expect(WebGLGraphics).itself.to.respondTo('buildLine'); + expect(WebGLGraphics).itself.to.respondTo('buildPoly'); + }); +}); diff --git a/test/unit/pixi-v2/renderers/webgl/WebGLRenderer.js b/test/unit/pixi-v2/renderers/webgl/WebGLRenderer.js new file mode 100644 index 0000000..1680a80 --- /dev/null +++ b/test/unit/pixi-v2/renderers/webgl/WebGLRenderer.js @@ -0,0 +1,49 @@ +describe('renderers/webgl/WebGLRenderer', function () { + 'use strict'; + + var expect = chai.expect; + var WebGLRenderer = PIXI.WebGLRenderer; + + it('Module exists', function () { + expect(WebGLRenderer).to.be.a('function'); + }); + + // Skip tests if WebGL is not available (WebGL not supported in Travis CI) + try { + var renderer = new WebGLRenderer(400, 300, {}); + renderer.destroy(); + } catch (error) { + return; + } + + it('Destroy renderer', function () { + var renderer = new WebGLRenderer(400, 300, {}); + renderer.destroy(); + }); + + describe('.autoResize', function () { + it('Should automatically resize view if enabled', function () { + var renderer = new WebGLRenderer(200, 200, { + autoResize: true + }); + + expect(renderer.view.style.width).to.equal('200px'); + }); + + it('Should not automatically resize view if disabled', function () { + var renderer = new WebGLRenderer(200, 200, { + autoResize: false + }); + + expect(renderer.view.style.width).to.equal(''); + }); + + it('Should not automatically resize view if not specified', function () { + var renderer = new WebGLRenderer(200, 200, { + resolution: 2 + }); + + expect(renderer.view.style.width).to.equal(''); + }); + }); +}); diff --git a/test/unit/pixi-v2/renderers/webgl/WebGLShaders.js b/test/unit/pixi-v2/renderers/webgl/WebGLShaders.js new file mode 100644 index 0000000..6e33e4f --- /dev/null +++ b/test/unit/pixi-v2/renderers/webgl/WebGLShaders.js @@ -0,0 +1,13 @@ +describe('renderers/webgl/WebGLShaders', function () { + 'use strict'; + + var expect = chai.expect; + + it('Module members exist', function () { + + expect(PIXI).to.respondTo('CompileVertexShader'); + expect(PIXI).to.respondTo('CompileFragmentShader'); + expect(PIXI).to.respondTo('_CompileShader'); + expect(PIXI).to.respondTo('compileProgram'); + }); +}); diff --git a/test/unit/pixi-v2/renderers/webgl/WebGLSpriteBatch.js b/test/unit/pixi-v2/renderers/webgl/WebGLSpriteBatch.js new file mode 100644 index 0000000..e662b63 --- /dev/null +++ b/test/unit/pixi-v2/renderers/webgl/WebGLSpriteBatch.js @@ -0,0 +1,10 @@ +describe('renderers/webgl/utils/WebGLSpriteBatch', function () { + 'use strict'; + + var expect = chai.expect; + var WebGLSpriteBatch = PIXI.WebGLSpriteBatch; + + it('Module exists', function () { + expect(WebGLSpriteBatch).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/text/BitmapText.js b/test/unit/pixi-v2/text/BitmapText.js new file mode 100644 index 0000000..9388e3d --- /dev/null +++ b/test/unit/pixi-v2/text/BitmapText.js @@ -0,0 +1,10 @@ +describe('pixi/text/BitmapText', function () { + 'use strict'; + + var expect = chai.expect; + var BitmapText = PIXI.BitmapText; + + it('Module exists', function () { + expect(BitmapText).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/text/Text.js b/test/unit/pixi-v2/text/Text.js new file mode 100644 index 0000000..9bc9ac5 --- /dev/null +++ b/test/unit/pixi-v2/text/Text.js @@ -0,0 +1,10 @@ +describe('pixi/text/Text', function () { + 'use strict'; + + var expect = chai.expect; + var Text = PIXI.Text; + + it('Module exists', function () { + expect(Text).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/textures/BaseTexture.js b/test/unit/pixi-v2/textures/BaseTexture.js new file mode 100644 index 0000000..502b724 --- /dev/null +++ b/test/unit/pixi-v2/textures/BaseTexture.js @@ -0,0 +1,11 @@ +describe('pixi/textures/BaseTexture', function () { + 'use strict'; + + var expect = chai.expect; + var BaseTexture = PIXI.BaseTexture; + + it('Module exists', function () { + expect(BaseTexture).to.be.a('function'); + expect(PIXI).to.have.property('BaseTextureCache').and.to.be.an('object'); + }); +}); diff --git a/test/unit/pixi-v2/textures/RenderTexture.js b/test/unit/pixi-v2/textures/RenderTexture.js new file mode 100644 index 0000000..96acdb4 --- /dev/null +++ b/test/unit/pixi-v2/textures/RenderTexture.js @@ -0,0 +1,15 @@ +describe('pixi/textures/RenderTexture', function () { + 'use strict'; + + var expect = chai.expect; + var RenderTexture = PIXI.RenderTexture; + + it('Module exists', function () { + expect(RenderTexture).to.be.a('function'); + }); + + it('Confirm new instance', function (done) { + var texture = new RenderTexture(100, 100, new PIXI.CanvasRenderer()); + pixi_textures_RenderTexture_confirmNew(texture, done); + }); +}); diff --git a/test/unit/pixi-v2/textures/Texture.js b/test/unit/pixi-v2/textures/Texture.js new file mode 100644 index 0000000..090f64d --- /dev/null +++ b/test/unit/pixi-v2/textures/Texture.js @@ -0,0 +1,26 @@ +describe('pixi/textures/Texture', function () { + 'use strict'; + + var expect = chai.expect; + var Texture = PIXI.Texture; + + it('Module exists', function () { + expect(Texture).to.be.a('function'); + expect(PIXI).to.have.property('TextureCache').and.to.be.an('object'); + }); + + it('Members exist', function () { + expect(Texture).itself.to.respondTo('fromImage'); + expect(Texture).itself.to.respondTo('fromFrame'); + expect(Texture).itself.to.respondTo('fromCanvas'); + expect(Texture).itself.to.respondTo('addTextureToCache'); + expect(Texture).itself.to.respondTo('removeTextureFromCache'); + + // expect(Texture).itself.to.have.deep.property('frameUpdates.length', 0); + }); + + it('Confirm new instance', function (done) { + var texture = Texture.fromImage('/base/test/textures/bunny.png'); + pixi_textures_Texture_confirmNew(texture, done); + }); +}); diff --git a/test/unit/pixi-v2/utils/Detector.js b/test/unit/pixi-v2/utils/Detector.js new file mode 100644 index 0000000..4cf6008 --- /dev/null +++ b/test/unit/pixi-v2/utils/Detector.js @@ -0,0 +1,10 @@ +describe('pixi/utils/Detector', function () { + 'use strict'; + + var expect = chai.expect; + var autoDetectRenderer = PIXI.autoDetectRenderer; + + it('Module exists', function () { + expect(autoDetectRenderer).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/utils/EventTarget.js b/test/unit/pixi-v2/utils/EventTarget.js new file mode 100644 index 0000000..1cfc3a4 --- /dev/null +++ b/test/unit/pixi-v2/utils/EventTarget.js @@ -0,0 +1,361 @@ +describe('pixi/utils/EventTarget', function () { + 'use strict'; + + var expect = chai.expect; + + var Clazz, PClazz, obj, pobj, obj2; + beforeEach(function () { + Clazz = function () {}; + PClazz = function () {}; + + PIXI.EventTarget.mixin(Clazz.prototype); + PIXI.EventTarget.mixin(PClazz.prototype); + + obj = new Clazz(); + obj2 = new Clazz(); + pobj = new PClazz(); + + obj.parent = pobj; + obj2.parent = obj; + }); + + it('Module exists', function () { + expect(PIXI.EventTarget).to.be.an('object'); + }); + + it('Confirm new instance', function () { + pixi_utils_EventTarget_confirm(obj); + }); + + it('simple on/emit case works', function () { + var myData = {}; + + obj.on('myevent', function (event) { + pixi_utils_EventTarget_Event_confirm(event, obj, myData); + }); + + obj.emit('myevent', myData); + }); + + it('simple once case works', function () { + var called = 0; + + obj.once('myevent', function() { called++; }); + + obj.emit('myevent'); + obj.emit('myevent'); + obj.emit('myevent'); + obj.emit('myevent'); + obj.emit('myevent'); + + expect(called).to.equal(1); + }); + + it('simple off case works', function (done) { + function onMyEvent() { + done(new Error('Event listener should not have been called')); + } + + obj.on('myevent', onMyEvent); + obj.off('myevent', onMyEvent); + obj.emit('myevent'); + + done(); + }); + + it('simple propagation case works', function (done) { + var myData = {}; + + pobj.on('myevent', function () { + done(); + }); + + obj.emit('myevent'); + }); + + it('simple stopPropagation case works', function (done) { + var myData = {}; + + pobj.on('myevent', function () { + done(new Error('Event listener should not have been called on the parent element')); + }); + + obj.on('myevent', function (evt) { + evt.stopPropagation(); + }); + + obj.emit('myevent'); + + done(); + }); + + it('simple stopImmediatePropagation case works', function (done) { + var myData = {}; + + pobj.on('myevent', function () { + done(new Error('Event listener should not have been called on the parent')); + }); + + obj.on('myevent', function (evt) { + evt.stopImmediatePropagation(); + }); + + obj.on('myevent', function () { + done(new Error('Event listener should not have been called on the second')); + }); + + obj.emit('myevent'); + + done(); + }); + + it('multiple dispatches work properly', function () { + var called = 0; + + function onMyEvent() { + called++; + } + + obj.on('myevent', onMyEvent); + obj.emit('myevent'); + obj.emit('myevent'); + obj.emit('myevent'); + obj.emit('myevent'); + + expect(called).to.equal(4); + }); + + it('multiple events work properly', function () { + var called = 0; + + function onMyEvent() { + called++; + } + + obj.on('myevent1', onMyEvent); + obj.on('myevent2', onMyEvent); + obj.on('myevent3', onMyEvent); + obj.emit('myevent1'); + obj.emit('myevent2'); + obj.emit('myevent3'); + + expect(called).to.equal(3); + }); + + it('multiple events one removed works properly', function () { + var called = 0; + + function onMyEvent() { + called++; + } + + obj.on('myevent1', onMyEvent); + obj.on('myevent2', onMyEvent); + obj.on('myevent3', onMyEvent); + + obj.emit('myevent1'); + obj.emit('myevent2'); + obj.emit('myevent3'); + + obj.off('myevent2', onMyEvent); + + obj.emit('myevent1'); + obj.emit('myevent2'); + obj.emit('myevent3'); + + expect(called).to.equal(5); + }); + + it('multiple handlers for one event with some removed', function () { + var called = 0; + + var onMyEvent = function () { + called++; + }, + onMyEvent2 = function () { + called++; + }; + + // add 2 handlers and confirm they both get called + obj.on('myevent', onMyEvent); + obj.on('myevent', onMyEvent); + obj.on('myevent', onMyEvent2); + obj.on('myevent', onMyEvent2); + + obj.emit('myevent'); + + expect(called).to.equal(4); + + // remove one of the handlers, emit again, then ensure 1 more call is made + obj.off('myevent', onMyEvent); + + obj.emit('myevent'); + + expect(called).to.equal(6); + }); + + it('calls to off without a handler do nothing', function () { + var called = 0; + + var onMyEvent = function () { + called++; + }; + + obj.on('myevent', onMyEvent); + obj.on('myevent', onMyEvent); + + obj.emit('myevent'); + + expect(called).to.equal(2); + + obj.off('myevent'); + + obj.emit('myevent'); + + expect(called).to.equal(4); + + obj.off('myevent', onMyEvent); + + obj.emit('myevent'); + + expect(called).to.equal(4); + }); + + it('handles multiple instances with the same prototype', function () { + var called = 0; + + function onMyEvent(e) { + called++; + } + + obj.on('myevent1', onMyEvent); + obj.on('myevent2', onMyEvent); + + obj2.istwo = true; + obj2.on('myevent1', onMyEvent); + obj2.on('myevent2', onMyEvent); + + obj.emit('myevent1'); + obj.emit('myevent2'); + obj2.emit('myevent1'); + obj2.emit('myevent2'); + + //we emit 4 times, but since obj2 is a child of obj the event should bubble + //up to obj and show up there as well. So the obj2.emit() calls each increment + //the counter twice. + expect(called).to.equal(6); + }); + + it('is backwards compatible with older .dispatchEvent({})', function () { + var called = 0, + data = { + some: 'thing', + hello: true + }; + + function onMyEvent(event) { + pixi_utils_EventTarget_Event_confirm(event, obj, data); + + called++; + } + + obj.on('myevent1', onMyEvent); + obj.on('myevent2', onMyEvent); + obj.on('myevent3', onMyEvent); + + data.type = 'myevent1'; + obj.emit(data); + + data.type = 'myevent2'; + obj.emit(data); + + data.type = 'myevent3'; + obj.emit(data); + + obj.off('myevent2', onMyEvent); + + data.type = 'myevent1'; + obj.emit(data); + + data.type = 'myevent2'; + obj.emit(data); + + data.type = 'myevent3'; + obj.emit(data); + + expect(called).to.equal(5); + }); + + it('is backwards compatible with older .call(this)', function () { + var Fn = function() { + PIXI.EventTarget.call(this); + }, + o = new Fn(); + + pixi_utils_EventTarget_confirm(o); + }); + + it('is backwards compatible with older .addEventListener("")', function () { + var called = 0, + data = { + some: 'thing', + hello: true + }; + + function onMyEvent(event) { + pixi_utils_EventTarget_Event_confirm(event, obj, data); + + called++; + } + + obj.addEventListener('myevent1', onMyEvent); + obj.addEventListener('myevent2', onMyEvent); + obj.addEventListener('myevent3', onMyEvent); + + data.type = 'myevent1'; + obj.emit(data); + + data.type = 'myevent2'; + obj.emit(data); + + data.type = 'myevent3'; + obj.emit(data); + + obj.off('myevent2', onMyEvent); + + data.type = 'myevent1'; + obj.emit(data); + + data.type = 'myevent2'; + obj.emit(data); + + data.type = 'myevent3'; + obj.emit(data); + + expect(called).to.equal(5); + }); + + it('event remove during emit call properly', function () { + var called = 0; + + function cb1() { + called++; + obj.off('myevent', cb1); + } + function cb2() { + called++; + obj.off('myevent', cb2); + } + function cb3() { + called++; + obj.off('myevent', cb3); + } + + obj.on('myevent', cb1); + obj.on('myevent', cb2); + obj.on('myevent', cb3); + obj.emit('myevent', ''); + + expect(called).to.equal(3); + }); +}); diff --git a/test/unit/pixi-v2/utils/Polyk.js b/test/unit/pixi-v2/utils/Polyk.js new file mode 100644 index 0000000..dfc7128 --- /dev/null +++ b/test/unit/pixi-v2/utils/Polyk.js @@ -0,0 +1,14 @@ +describe('pixi/utils/Polyk', function () { + 'use strict'; + + var expect = chai.expect; + var PolyK = PIXI.PolyK; + + it('Module exists', function () { + expect(PolyK).to.be.an('object'); + }); + + it('Members exist', function () { + expect(PolyK).to.respondTo('Triangulate'); + }); +}); diff --git a/test/unit/pixi-v2/InteractionManager.js b/test/unit/pixi-v2/InteractionManager.js new file mode 100644 index 0000000..ed3001f --- /dev/null +++ b/test/unit/pixi-v2/InteractionManager.js @@ -0,0 +1,10 @@ +describe('pixi/InteractionManager', function () { + 'use strict'; + + var expect = chai.expect; + var InteractionManager = PIXI.InteractionManager; + + it('Module exists', function () { + expect(InteractionManager).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/Pixi.js b/test/unit/pixi-v2/Pixi.js new file mode 100644 index 0000000..27debc1 --- /dev/null +++ b/test/unit/pixi-v2/Pixi.js @@ -0,0 +1,9 @@ +describe('pixi/Pixi', function () { + 'use strict'; + + var expect = chai.expect; + + it('Module exists', function () { + expect(global).to.have.property('PIXI').and.to.be.an('object'); + }); +}); diff --git a/test/unit/pixi-v2/core/Circle.js b/test/unit/pixi-v2/core/Circle.js new file mode 100644 index 0000000..fbcfa17 --- /dev/null +++ b/test/unit/pixi-v2/core/Circle.js @@ -0,0 +1,21 @@ +describe('pixi/core/Circle', function () { + 'use strict'; + + var expect = chai.expect; + var Circle = PIXI.Circle; + + it('Module exists', function () { + expect(Circle).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Circle(); + pixi_core_Circle_confirmNewCircle(obj); + }); + + it("getBounds should return Rectangle that bounds the circle", function() { + var obj = new Circle(100, 250, 50); + var bounds = obj.getBounds(); + pixi_core_Circle_isBoundedByRectangle(obj, bounds); + }); +}); diff --git a/test/unit/pixi-v2/core/Ellipse.js b/test/unit/pixi-v2/core/Ellipse.js new file mode 100644 index 0000000..026b56f --- /dev/null +++ b/test/unit/pixi-v2/core/Ellipse.js @@ -0,0 +1,24 @@ +describe('pixi/core/Ellipse', function () { + 'use strict'; + + var expect = chai.expect; + var Ellipse = PIXI.Ellipse; + + it('Module exists', function () { + expect(Ellipse).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Ellipse(); + + expect(obj).to.be.an.instanceof(Ellipse); + expect(obj).to.respondTo('clone'); + expect(obj).to.respondTo('contains'); + expect(obj).to.respondTo('getBounds'); + + expect(obj).to.have.property('x', 0); + expect(obj).to.have.property('y', 0); + expect(obj).to.have.property('width', 0); + expect(obj).to.have.property('height', 0); + }); +}); diff --git a/test/unit/pixi-v2/core/Matrix.js b/test/unit/pixi-v2/core/Matrix.js new file mode 100644 index 0000000..da75e2e --- /dev/null +++ b/test/unit/pixi-v2/core/Matrix.js @@ -0,0 +1,14 @@ +describe('pixi/core/Matrix', function () { + 'use strict'; + + var expect = chai.expect; + + it('Matrix exists', function () { + expect(PIXI.Matrix).to.be.an('function'); + }); + + it('Confirm new Matrix', function () { + var matrix = new PIXI.Matrix(); + pixi_core_Matrix_confirmNewMatrix(matrix); + }); +}); diff --git a/test/unit/pixi-v2/core/Point.js b/test/unit/pixi-v2/core/Point.js new file mode 100644 index 0000000..c4d5163 --- /dev/null +++ b/test/unit/pixi-v2/core/Point.js @@ -0,0 +1,15 @@ +describe('pixi/core/Point', function () { + 'use strict'; + + var expect = chai.expect; + var Point = PIXI.Point; + + it('Module exists', function () { + expect(Point).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Point(); + pixi_core_Point_confirm(obj, 0, 0); + }); +}); diff --git a/test/unit/pixi-v2/core/Polygon.js b/test/unit/pixi-v2/core/Polygon.js new file mode 100644 index 0000000..dc8c918 --- /dev/null +++ b/test/unit/pixi-v2/core/Polygon.js @@ -0,0 +1,20 @@ +describe('pixi/core/Polygon', function () { + 'use strict'; + + var expect = chai.expect; + var Polygon = PIXI.Polygon; + + it('Module exists', function () { + expect(Polygon).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Polygon(); + + expect(obj).to.be.an.instanceof(Polygon); + expect(obj).to.respondTo('clone'); + expect(obj).to.respondTo('contains'); + + expect(obj).to.have.deep.property('points.length', 0); + }); +}); diff --git a/test/unit/pixi-v2/core/Rectangle.js b/test/unit/pixi-v2/core/Rectangle.js new file mode 100644 index 0000000..d43316e --- /dev/null +++ b/test/unit/pixi-v2/core/Rectangle.js @@ -0,0 +1,15 @@ +describe('pixi/core/Rectangle', function () { + 'use strict'; + + var expect = chai.expect; + var Rectangle = PIXI.Rectangle; + + it('Module exists', function () { + expect(Rectangle).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var rect = new Rectangle(); + pixi_core_Rectangle_confirm(rect, 0, 0, 0, 0); + }); +}); diff --git a/test/unit/pixi-v2/display/DisplayObject.js b/test/unit/pixi-v2/display/DisplayObject.js new file mode 100644 index 0000000..044acf8 --- /dev/null +++ b/test/unit/pixi-v2/display/DisplayObject.js @@ -0,0 +1,21 @@ +describe('pixi/display/DisplayObject', function () { + 'use strict'; + + var expect = chai.expect; + var DisplayObject = PIXI.DisplayObject; + + it('Module exists', function () { + expect(DisplayObject).to.be.a('function'); + // expect(PIXI).to.have.property('visibleCount', 0); + }); + + it('Confirm new instance', function () { + var obj = new DisplayObject(); + + pixi_display_DisplayObject_confirmNew(obj); + expect(obj).to.have.property('hitArea', null); + expect(obj).to.have.property('interactive', false); + expect(obj).to.have.property('renderable', false); + expect(obj).to.have.property('stage', null); + }); +}); diff --git a/test/unit/pixi-v2/display/DisplayObjectContainer.js b/test/unit/pixi-v2/display/DisplayObjectContainer.js new file mode 100644 index 0000000..15a3376 --- /dev/null +++ b/test/unit/pixi-v2/display/DisplayObjectContainer.js @@ -0,0 +1,67 @@ +describe('pixi/display/DisplayObjectContainer', function () { + 'use strict'; + + var expect = chai.expect; + var DisplayObjectContainer = PIXI.DisplayObjectContainer; + + it('Module exists', function () { + expect(DisplayObjectContainer).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new DisplayObjectContainer(); + + pixi_display_DisplayObjectContainer_confirmNew(obj); + expect(obj).to.have.property('hitArea', null); + expect(obj).to.have.property('interactive', false); + expect(obj).to.have.property('renderable', false); + expect(obj).to.have.property('stage', null); + }); + + it('Gets child index', function() { + var container = new PIXI.DisplayObjectContainer(); + var children = []; + for (var i = 0; i < 10; i++) { + var child = new PIXI.DisplayObject(); + children.push(child); + container.addChild(child); + } + + for (i = 0; i < children.length; i++) { + expect(i).to.eql(container.getChildIndex(children[i])); + } + }); + + it('throws error when trying to get index of not a child', function() { + var container = new PIXI.DisplayObjectContainer(); + var child = new PIXI.DisplayObject(); + + expect(function() { container.getChildIndex(child); }).to.throw(); + }); + + it('Sets child index', function() { + var container = new PIXI.DisplayObjectContainer(); + var children = []; + + for (var i = 0; i < 10; i++) { + var child = new PIXI.DisplayObject(); + children.push(child); + container.addChild(child); + } + children.reverse(); + + for (i = 0; i < children.length; i++) { + container.setChildIndex(children[i], i); + expect(i).to.eql(container.getChildIndex(children[i])); + } + }); + + it('throws error when trying to set incorect index', function() { + var container = new PIXI.DisplayObjectContainer(); + var child = new PIXI.DisplayObject(); + container.addChild(child); + + expect(function() { container.setChildIndex(child, -1); }).to.throw(); + expect(function() { container.setChildIndex(child, 1); }).to.throw(); + }); +}); diff --git a/test/unit/pixi-v2/display/MovieClip.js b/test/unit/pixi-v2/display/MovieClip.js new file mode 100644 index 0000000..f3c6c6a --- /dev/null +++ b/test/unit/pixi-v2/display/MovieClip.js @@ -0,0 +1,33 @@ +describe('pixi/display/MovieClip', function () { + 'use strict'; + + var expect = chai.expect; + var MovieClip = PIXI.MovieClip; + var Texture = PIXI.Texture; + + it('Module exists', function () { + expect(MovieClip).to.be.a('function'); + }); + + it('Confirm new instance', function (done) { + var texture = Texture.fromImage('/base/test/textures/SpriteSheet-Explosion.png'); + var obj = new MovieClip([texture]); + + pixi_display_Sprite_confirmNew(obj, done); + + expect(obj).to.be.an.instanceof(MovieClip); + expect(obj).to.respondTo('stop'); + expect(obj).to.respondTo('play'); + expect(obj).to.respondTo('gotoAndStop'); + expect(obj).to.respondTo('gotoAndPlay'); + expect(obj).to.respondTo('updateTransform'); + + expect(obj).to.have.deep.property('textures.length', 1); + expect(obj).to.have.deep.property('textures[0]', texture); + expect(obj).to.have.property('animationSpeed', 1); + expect(obj).to.have.property('loop', true); + expect(obj).to.have.property('onComplete', null); + expect(obj).to.have.property('currentFrame', 0); + expect(obj).to.have.property('playing', false); + }); +}); diff --git a/test/unit/pixi-v2/display/Sprite.js b/test/unit/pixi-v2/display/Sprite.js new file mode 100644 index 0000000..30c8076 --- /dev/null +++ b/test/unit/pixi-v2/display/Sprite.js @@ -0,0 +1,28 @@ +describe('pixi/display/Sprite', function () { + 'use strict'; + + var expect = chai.expect; + var Sprite = PIXI.Sprite; + var Texture = PIXI.Texture; + + it('Module exists', function () { + expect(Sprite).to.be.a('function'); + expect(PIXI).to.have.deep.property('blendModes.NORMAL', 0); + expect(PIXI).to.have.deep.property('blendModes.ADD', 1); + expect(PIXI).to.have.deep.property('blendModes.MULTIPLY', 2); + expect(PIXI).to.have.deep.property('blendModes.SCREEN', 3); + }); + + + it('Members exist', function () { + expect(Sprite).itself.to.respondTo('fromImage'); + expect(Sprite).itself.to.respondTo('fromFrame'); + }); + + it('Confirm new instance', function (done) { + var texture = Texture.fromImage('/base/test/textures/SpriteSheet-Aliens.png'); + var obj = new Sprite(texture); + + pixi_display_Sprite_confirmNew(obj, done); + }); +}); diff --git a/test/unit/pixi-v2/display/Stage.js b/test/unit/pixi-v2/display/Stage.js new file mode 100644 index 0000000..6974c2e --- /dev/null +++ b/test/unit/pixi-v2/display/Stage.js @@ -0,0 +1,49 @@ +describe('pixi/display/Stage', function () { + 'use strict'; + + var expect = chai.expect; + var Stage = PIXI.Stage; + var InteractionManager = PIXI.InteractionManager; + var Rectangle = PIXI.Rectangle; + + it('Module exists', function () { + expect(Stage).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Stage(null, true); + + pixi_display_DisplayObjectContainer_confirmNew(obj); + + expect(obj).to.be.an.instanceof(Stage); + expect(obj).to.respondTo('updateTransform'); + expect(obj).to.respondTo('setBackgroundColor'); + expect(obj).to.respondTo('getMousePosition'); + // FIXME: duplicate member in DisplayObject + pixi_core_Matrix_confirmNewMatrix(obj.worldTransform); + // FIXME: convert arg to bool in constructor + expect(obj).to.have.property('interactive', true); + + expect(obj).to.have.property('interactionManager') + .and.to.be.an.instanceof(InteractionManager) + .and.to.have.property('stage', obj); + + expect(obj).to.have.property('dirty', true); + + expect(obj).to.have.property('stage', obj); + + expect(obj).to.have.property('hitArea') + .and.to.be.an.instanceof(Rectangle); + pixi_core_Rectangle_confirm(obj.hitArea, 0, 0, 100000, 100000); + + expect(obj).to.have.property('backgroundColor', 0x000000); + expect(obj).to.have.deep.property('backgroundColorSplit.length', 3); + expect(obj).to.have.deep.property('backgroundColorSplit[0]', 0); + expect(obj).to.have.deep.property('backgroundColorSplit[1]', 0); + expect(obj).to.have.deep.property('backgroundColorSplit[2]', 0); + expect(obj).to.have.property('backgroundColorString', '#000000'); + + + expect(obj).to.have.property('worldVisible', true); + }); +}); diff --git a/test/unit/pixi-v2/extras/Rope.js b/test/unit/pixi-v2/extras/Rope.js new file mode 100644 index 0000000..05885ac --- /dev/null +++ b/test/unit/pixi-v2/extras/Rope.js @@ -0,0 +1,31 @@ +describe('pixi/extras/Rope', function () { + 'use strict'; + + var expect = chai.expect; + var Rope = PIXI.Rope; + var Texture = PIXI.Texture; + var Point = PIXI.Point; + + it('Module exists', function () { + expect(Rope).to.be.a('function'); + }); + + it('Confirm new instance', function () { + + var texture = Texture.fromImage('/base/test/textures/bunny.png'); + + // TODO-Alvin + // Same as Strip + + // var obj = new Rope(texture, [new Point(), new Point(5, 10), new Point(10, 20)]); + + // pixi_extras_Strip_confirmNew(obj); + + // expect(obj).to.be.an.instanceof(Rope); + // expect(obj).to.respondTo('refresh'); + // expect(obj).to.respondTo('updateTransform'); + // expect(obj).to.respondTo('setTexture'); + + // TODO: Test properties + }); +}); diff --git a/test/unit/pixi-v2/extras/Spine.js b/test/unit/pixi-v2/extras/Spine.js new file mode 100644 index 0000000..0708bc0 --- /dev/null +++ b/test/unit/pixi-v2/extras/Spine.js @@ -0,0 +1,10 @@ +describe('pixi/extras/Spine', function () { + 'use strict'; + + var expect = chai.expect; + var Spine = PIXI.Spine; + + it('Module exists', function () { + expect(Spine).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/extras/Strip.js b/test/unit/pixi-v2/extras/Strip.js new file mode 100644 index 0000000..230af90 --- /dev/null +++ b/test/unit/pixi-v2/extras/Strip.js @@ -0,0 +1,26 @@ +describe('pixi/extras/Strip', function () { + 'use strict'; + + var expect = chai.expect; + var Strip = PIXI.Strip; + var Texture = PIXI.Texture; + + it('Module exists', function () { + expect(Strip).to.be.a('function'); + }); + + it('Confirm new instance', function () { + + + // TODO-Alvin + // We tweaked it to make it pass the tests, but the whole strip class needs + // to be re-coded + + var texture = Texture.fromImage('/base/test/textures/bunny.png'); + + // var obj = new Strip(texture, 20, 10000); + + + // pixi_extras_Strip_confirmNew(obj); + }); +}); diff --git a/test/unit/pixi-v2/extras/TilingSprite.js b/test/unit/pixi-v2/extras/TilingSprite.js new file mode 100644 index 0000000..56aea14 --- /dev/null +++ b/test/unit/pixi-v2/extras/TilingSprite.js @@ -0,0 +1,24 @@ +describe('pixi/extras/TilingSprite', function () { + 'use strict'; + + var expect = chai.expect; + var TilingSprite = PIXI.TilingSprite; + var Texture = PIXI.Texture; + + it('Module exists', function () { + expect(TilingSprite).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var texture = Texture.fromImage('/base/test/textures/bunny.png'); + var obj = new TilingSprite(texture, 6000, 12000); + + pixi_display_DisplayObjectContainer_confirmNew(obj); + + expect(obj).to.be.an.instanceof(TilingSprite); + expect(obj).to.respondTo('setTexture'); + expect(obj).to.respondTo('onTextureUpdate'); + + // TODO: Test properties + }); +}); diff --git a/test/unit/pixi-v2/filters/FilterBlock.js b/test/unit/pixi-v2/filters/FilterBlock.js new file mode 100644 index 0000000..870cec0 --- /dev/null +++ b/test/unit/pixi-v2/filters/FilterBlock.js @@ -0,0 +1,10 @@ +describe('pixi/filters/FilterBlock', function () { + 'use strict'; + + var expect = chai.expect; + var FilterBlock = PIXI.FilterBlock; + + it('Module exists', function () { + expect(FilterBlock).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/AssetLoader.js b/test/unit/pixi-v2/loaders/AssetLoader.js new file mode 100644 index 0000000..a0aa0b5 --- /dev/null +++ b/test/unit/pixi-v2/loaders/AssetLoader.js @@ -0,0 +1,10 @@ +describe('pixi/loaders/AssetLoader', function () { + 'use strict'; + + var expect = chai.expect; + var AssetLoader = PIXI.AssetLoader; + + it('Module exists', function () { + expect(AssetLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/BitmapFontLoader.js b/test/unit/pixi-v2/loaders/BitmapFontLoader.js new file mode 100644 index 0000000..046f018 --- /dev/null +++ b/test/unit/pixi-v2/loaders/BitmapFontLoader.js @@ -0,0 +1,9 @@ +describe('pixi/loaders/BitmapFontLoader', function () { + 'use strict'; + + var expect = chai.expect; + + it('Module exists', function () { + expect(PIXI.BitmapFontLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/ImageLoader.js b/test/unit/pixi-v2/loaders/ImageLoader.js new file mode 100644 index 0000000..8b1f556 --- /dev/null +++ b/test/unit/pixi-v2/loaders/ImageLoader.js @@ -0,0 +1,10 @@ +describe('pixi/loaders/ImageLoader', function () { + 'use strict'; + + var expect = chai.expect; + var ImageLoader = PIXI.ImageLoader; + + it('Module exists', function () { + expect(ImageLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/JsonLoader.js b/test/unit/pixi-v2/loaders/JsonLoader.js new file mode 100644 index 0000000..c577e83 --- /dev/null +++ b/test/unit/pixi-v2/loaders/JsonLoader.js @@ -0,0 +1,10 @@ +describe('pixi/loaders/JsonLoader', function () { + 'use strict'; + + var expect = chai.expect; + var JsonLoader = PIXI.JsonLoader; + + it('Module exists', function () { + expect(JsonLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/SpineLoader.js b/test/unit/pixi-v2/loaders/SpineLoader.js new file mode 100644 index 0000000..fdcc0b8 --- /dev/null +++ b/test/unit/pixi-v2/loaders/SpineLoader.js @@ -0,0 +1,10 @@ +describe('pixi/loaders/SpineLoader', function () { + 'use strict'; + + var expect = chai.expect; + var SpineLoader = PIXI.SpineLoader; + + it('Module exists', function () { + expect(SpineLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/SpriteSheetLoader.js b/test/unit/pixi-v2/loaders/SpriteSheetLoader.js new file mode 100644 index 0000000..57beb27 --- /dev/null +++ b/test/unit/pixi-v2/loaders/SpriteSheetLoader.js @@ -0,0 +1,10 @@ +describe('pixi/loaders/SpriteSheetLoader', function () { + 'use strict'; + + var expect = chai.expect; + var SpriteSheetLoader = PIXI.SpriteSheetLoader; + + it('Module exists', function () { + expect(SpriteSheetLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/primitives/Graphics.js b/test/unit/pixi-v2/primitives/Graphics.js new file mode 100644 index 0000000..f3849eb --- /dev/null +++ b/test/unit/pixi-v2/primitives/Graphics.js @@ -0,0 +1,44 @@ +describe('pixi/primitives/Graphics', function () { + 'use strict'; + + var expect = chai.expect; + var Graphics = PIXI.Graphics; + + it('Module exists', function () { + expect(Graphics).to.be.a('function'); + + expect(Graphics).itself.to.have.property('POLY', 0); + expect(Graphics).itself.to.have.property('RECT', 1); + expect(Graphics).itself.to.have.property('CIRC', 2); + expect(Graphics).itself.to.have.property('ELIP', 3); + expect(Graphics).itself.to.have.property('RREC', 4); + }); + + it('Confirm new instance', function () { + var obj = new Graphics(); + + pixi_display_DisplayObjectContainer_confirmNew(obj); + + expect(obj).to.be.an.instanceof(Graphics); + expect(obj).to.respondTo('lineStyle'); + expect(obj).to.respondTo('lineStyle'); + expect(obj).to.respondTo('moveTo'); + expect(obj).to.respondTo('lineTo'); + expect(obj).to.respondTo('beginFill'); + expect(obj).to.respondTo('endFill'); + expect(obj).to.respondTo('drawRect'); + // expect(obj).to.respondTo('drawRoundedRect'); + expect(obj).to.respondTo('drawCircle'); + expect(obj).to.respondTo('drawEllipse'); + expect(obj).to.respondTo('clear'); + + expect(obj).to.have.property('renderable', true); + expect(obj).to.have.property('fillAlpha', 1); + expect(obj).to.have.property('lineWidth', 0); + expect(obj).to.have.property('width', 0); + expect(obj).to.have.property('height', 0); + expect(obj).to.have.property('lineColor', 0); + expect(obj).to.have.deep.property('graphicsData.length', 0); + // expect(obj).to.have.deep.property('currentPath.points.length', 0); + }); +}); diff --git a/test/unit/pixi-v2/renderers/canvas/CanvasGraphics.js b/test/unit/pixi-v2/renderers/canvas/CanvasGraphics.js new file mode 100644 index 0000000..8f44472 --- /dev/null +++ b/test/unit/pixi-v2/renderers/canvas/CanvasGraphics.js @@ -0,0 +1,15 @@ +describe('renders/canvas/CanvasGraphics', function () { + 'use strict'; + + var expect = chai.expect; + var CanvasGraphics = PIXI.CanvasGraphics; + + it('Module exists', function () { + expect(CanvasGraphics).to.be.a('function'); + }); + + it('Members exist', function () { + expect(CanvasGraphics).itself.to.respondTo('renderGraphics'); + expect(CanvasGraphics).itself.to.respondTo('renderGraphicsMask'); + }); +}); diff --git a/test/unit/pixi-v2/renderers/canvas/CanvasRenderer.js b/test/unit/pixi-v2/renderers/canvas/CanvasRenderer.js new file mode 100644 index 0000000..1646444 --- /dev/null +++ b/test/unit/pixi-v2/renderers/canvas/CanvasRenderer.js @@ -0,0 +1,36 @@ +describe('renderers/canvas/CanvasRenderer', function () { + 'use strict'; + + var expect = chai.expect; + var CanvasRenderer = PIXI.CanvasRenderer; + + it('Module exists', function () { + expect(CanvasRenderer).to.be.a('function'); + }); + + describe('.autoResize', function () { + it('Should automatically resize view if enabled', function () { + var renderer = new CanvasRenderer(200, 200, { + autoResize: true + }); + + expect(renderer.view.style.width).to.equal('200px'); + }); + + it('Should not automatically resize view if disabled', function () { + var renderer = new CanvasRenderer(200, 200, { + autoResize: false + }); + + expect(renderer.view.style.width).to.equal(''); + }); + + it('Should not automatically resize view if not specified', function () { + var renderer = new CanvasRenderer(200, 200, { + resolution: 2 + }); + + expect(renderer.view.style.width).to.equal(''); + }); + }); +}); diff --git a/test/unit/pixi-v2/renderers/webgl/WebGLGraphics.js b/test/unit/pixi-v2/renderers/webgl/WebGLGraphics.js new file mode 100644 index 0000000..5867b28 --- /dev/null +++ b/test/unit/pixi-v2/renderers/webgl/WebGLGraphics.js @@ -0,0 +1,20 @@ +describe('renderers/wegbl/WebGLGraphics', function () { + 'use strict'; + + var expect = chai.expect; + var WebGLGraphics = PIXI.WebGLGraphics; + + it('Module exists', function () { + expect(WebGLGraphics).to.be.a('function'); + }); + + it('Members exist', function () { + expect(WebGLGraphics).itself.to.respondTo('renderGraphics'); + expect(WebGLGraphics).itself.to.respondTo('updateGraphics'); + expect(WebGLGraphics).itself.to.respondTo('buildRectangle'); + expect(WebGLGraphics).itself.to.respondTo('buildRoundedRectangle'); + expect(WebGLGraphics).itself.to.respondTo('buildCircle'); + expect(WebGLGraphics).itself.to.respondTo('buildLine'); + expect(WebGLGraphics).itself.to.respondTo('buildPoly'); + }); +}); diff --git a/test/unit/pixi-v2/renderers/webgl/WebGLRenderer.js b/test/unit/pixi-v2/renderers/webgl/WebGLRenderer.js new file mode 100644 index 0000000..1680a80 --- /dev/null +++ b/test/unit/pixi-v2/renderers/webgl/WebGLRenderer.js @@ -0,0 +1,49 @@ +describe('renderers/webgl/WebGLRenderer', function () { + 'use strict'; + + var expect = chai.expect; + var WebGLRenderer = PIXI.WebGLRenderer; + + it('Module exists', function () { + expect(WebGLRenderer).to.be.a('function'); + }); + + // Skip tests if WebGL is not available (WebGL not supported in Travis CI) + try { + var renderer = new WebGLRenderer(400, 300, {}); + renderer.destroy(); + } catch (error) { + return; + } + + it('Destroy renderer', function () { + var renderer = new WebGLRenderer(400, 300, {}); + renderer.destroy(); + }); + + describe('.autoResize', function () { + it('Should automatically resize view if enabled', function () { + var renderer = new WebGLRenderer(200, 200, { + autoResize: true + }); + + expect(renderer.view.style.width).to.equal('200px'); + }); + + it('Should not automatically resize view if disabled', function () { + var renderer = new WebGLRenderer(200, 200, { + autoResize: false + }); + + expect(renderer.view.style.width).to.equal(''); + }); + + it('Should not automatically resize view if not specified', function () { + var renderer = new WebGLRenderer(200, 200, { + resolution: 2 + }); + + expect(renderer.view.style.width).to.equal(''); + }); + }); +}); diff --git a/test/unit/pixi-v2/renderers/webgl/WebGLShaders.js b/test/unit/pixi-v2/renderers/webgl/WebGLShaders.js new file mode 100644 index 0000000..6e33e4f --- /dev/null +++ b/test/unit/pixi-v2/renderers/webgl/WebGLShaders.js @@ -0,0 +1,13 @@ +describe('renderers/webgl/WebGLShaders', function () { + 'use strict'; + + var expect = chai.expect; + + it('Module members exist', function () { + + expect(PIXI).to.respondTo('CompileVertexShader'); + expect(PIXI).to.respondTo('CompileFragmentShader'); + expect(PIXI).to.respondTo('_CompileShader'); + expect(PIXI).to.respondTo('compileProgram'); + }); +}); diff --git a/test/unit/pixi-v2/renderers/webgl/WebGLSpriteBatch.js b/test/unit/pixi-v2/renderers/webgl/WebGLSpriteBatch.js new file mode 100644 index 0000000..e662b63 --- /dev/null +++ b/test/unit/pixi-v2/renderers/webgl/WebGLSpriteBatch.js @@ -0,0 +1,10 @@ +describe('renderers/webgl/utils/WebGLSpriteBatch', function () { + 'use strict'; + + var expect = chai.expect; + var WebGLSpriteBatch = PIXI.WebGLSpriteBatch; + + it('Module exists', function () { + expect(WebGLSpriteBatch).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/text/BitmapText.js b/test/unit/pixi-v2/text/BitmapText.js new file mode 100644 index 0000000..9388e3d --- /dev/null +++ b/test/unit/pixi-v2/text/BitmapText.js @@ -0,0 +1,10 @@ +describe('pixi/text/BitmapText', function () { + 'use strict'; + + var expect = chai.expect; + var BitmapText = PIXI.BitmapText; + + it('Module exists', function () { + expect(BitmapText).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/text/Text.js b/test/unit/pixi-v2/text/Text.js new file mode 100644 index 0000000..9bc9ac5 --- /dev/null +++ b/test/unit/pixi-v2/text/Text.js @@ -0,0 +1,10 @@ +describe('pixi/text/Text', function () { + 'use strict'; + + var expect = chai.expect; + var Text = PIXI.Text; + + it('Module exists', function () { + expect(Text).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/textures/BaseTexture.js b/test/unit/pixi-v2/textures/BaseTexture.js new file mode 100644 index 0000000..502b724 --- /dev/null +++ b/test/unit/pixi-v2/textures/BaseTexture.js @@ -0,0 +1,11 @@ +describe('pixi/textures/BaseTexture', function () { + 'use strict'; + + var expect = chai.expect; + var BaseTexture = PIXI.BaseTexture; + + it('Module exists', function () { + expect(BaseTexture).to.be.a('function'); + expect(PIXI).to.have.property('BaseTextureCache').and.to.be.an('object'); + }); +}); diff --git a/test/unit/pixi-v2/textures/RenderTexture.js b/test/unit/pixi-v2/textures/RenderTexture.js new file mode 100644 index 0000000..96acdb4 --- /dev/null +++ b/test/unit/pixi-v2/textures/RenderTexture.js @@ -0,0 +1,15 @@ +describe('pixi/textures/RenderTexture', function () { + 'use strict'; + + var expect = chai.expect; + var RenderTexture = PIXI.RenderTexture; + + it('Module exists', function () { + expect(RenderTexture).to.be.a('function'); + }); + + it('Confirm new instance', function (done) { + var texture = new RenderTexture(100, 100, new PIXI.CanvasRenderer()); + pixi_textures_RenderTexture_confirmNew(texture, done); + }); +}); diff --git a/test/unit/pixi-v2/textures/Texture.js b/test/unit/pixi-v2/textures/Texture.js new file mode 100644 index 0000000..090f64d --- /dev/null +++ b/test/unit/pixi-v2/textures/Texture.js @@ -0,0 +1,26 @@ +describe('pixi/textures/Texture', function () { + 'use strict'; + + var expect = chai.expect; + var Texture = PIXI.Texture; + + it('Module exists', function () { + expect(Texture).to.be.a('function'); + expect(PIXI).to.have.property('TextureCache').and.to.be.an('object'); + }); + + it('Members exist', function () { + expect(Texture).itself.to.respondTo('fromImage'); + expect(Texture).itself.to.respondTo('fromFrame'); + expect(Texture).itself.to.respondTo('fromCanvas'); + expect(Texture).itself.to.respondTo('addTextureToCache'); + expect(Texture).itself.to.respondTo('removeTextureFromCache'); + + // expect(Texture).itself.to.have.deep.property('frameUpdates.length', 0); + }); + + it('Confirm new instance', function (done) { + var texture = Texture.fromImage('/base/test/textures/bunny.png'); + pixi_textures_Texture_confirmNew(texture, done); + }); +}); diff --git a/test/unit/pixi-v2/utils/Detector.js b/test/unit/pixi-v2/utils/Detector.js new file mode 100644 index 0000000..4cf6008 --- /dev/null +++ b/test/unit/pixi-v2/utils/Detector.js @@ -0,0 +1,10 @@ +describe('pixi/utils/Detector', function () { + 'use strict'; + + var expect = chai.expect; + var autoDetectRenderer = PIXI.autoDetectRenderer; + + it('Module exists', function () { + expect(autoDetectRenderer).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/utils/EventTarget.js b/test/unit/pixi-v2/utils/EventTarget.js new file mode 100644 index 0000000..1cfc3a4 --- /dev/null +++ b/test/unit/pixi-v2/utils/EventTarget.js @@ -0,0 +1,361 @@ +describe('pixi/utils/EventTarget', function () { + 'use strict'; + + var expect = chai.expect; + + var Clazz, PClazz, obj, pobj, obj2; + beforeEach(function () { + Clazz = function () {}; + PClazz = function () {}; + + PIXI.EventTarget.mixin(Clazz.prototype); + PIXI.EventTarget.mixin(PClazz.prototype); + + obj = new Clazz(); + obj2 = new Clazz(); + pobj = new PClazz(); + + obj.parent = pobj; + obj2.parent = obj; + }); + + it('Module exists', function () { + expect(PIXI.EventTarget).to.be.an('object'); + }); + + it('Confirm new instance', function () { + pixi_utils_EventTarget_confirm(obj); + }); + + it('simple on/emit case works', function () { + var myData = {}; + + obj.on('myevent', function (event) { + pixi_utils_EventTarget_Event_confirm(event, obj, myData); + }); + + obj.emit('myevent', myData); + }); + + it('simple once case works', function () { + var called = 0; + + obj.once('myevent', function() { called++; }); + + obj.emit('myevent'); + obj.emit('myevent'); + obj.emit('myevent'); + obj.emit('myevent'); + obj.emit('myevent'); + + expect(called).to.equal(1); + }); + + it('simple off case works', function (done) { + function onMyEvent() { + done(new Error('Event listener should not have been called')); + } + + obj.on('myevent', onMyEvent); + obj.off('myevent', onMyEvent); + obj.emit('myevent'); + + done(); + }); + + it('simple propagation case works', function (done) { + var myData = {}; + + pobj.on('myevent', function () { + done(); + }); + + obj.emit('myevent'); + }); + + it('simple stopPropagation case works', function (done) { + var myData = {}; + + pobj.on('myevent', function () { + done(new Error('Event listener should not have been called on the parent element')); + }); + + obj.on('myevent', function (evt) { + evt.stopPropagation(); + }); + + obj.emit('myevent'); + + done(); + }); + + it('simple stopImmediatePropagation case works', function (done) { + var myData = {}; + + pobj.on('myevent', function () { + done(new Error('Event listener should not have been called on the parent')); + }); + + obj.on('myevent', function (evt) { + evt.stopImmediatePropagation(); + }); + + obj.on('myevent', function () { + done(new Error('Event listener should not have been called on the second')); + }); + + obj.emit('myevent'); + + done(); + }); + + it('multiple dispatches work properly', function () { + var called = 0; + + function onMyEvent() { + called++; + } + + obj.on('myevent', onMyEvent); + obj.emit('myevent'); + obj.emit('myevent'); + obj.emit('myevent'); + obj.emit('myevent'); + + expect(called).to.equal(4); + }); + + it('multiple events work properly', function () { + var called = 0; + + function onMyEvent() { + called++; + } + + obj.on('myevent1', onMyEvent); + obj.on('myevent2', onMyEvent); + obj.on('myevent3', onMyEvent); + obj.emit('myevent1'); + obj.emit('myevent2'); + obj.emit('myevent3'); + + expect(called).to.equal(3); + }); + + it('multiple events one removed works properly', function () { + var called = 0; + + function onMyEvent() { + called++; + } + + obj.on('myevent1', onMyEvent); + obj.on('myevent2', onMyEvent); + obj.on('myevent3', onMyEvent); + + obj.emit('myevent1'); + obj.emit('myevent2'); + obj.emit('myevent3'); + + obj.off('myevent2', onMyEvent); + + obj.emit('myevent1'); + obj.emit('myevent2'); + obj.emit('myevent3'); + + expect(called).to.equal(5); + }); + + it('multiple handlers for one event with some removed', function () { + var called = 0; + + var onMyEvent = function () { + called++; + }, + onMyEvent2 = function () { + called++; + }; + + // add 2 handlers and confirm they both get called + obj.on('myevent', onMyEvent); + obj.on('myevent', onMyEvent); + obj.on('myevent', onMyEvent2); + obj.on('myevent', onMyEvent2); + + obj.emit('myevent'); + + expect(called).to.equal(4); + + // remove one of the handlers, emit again, then ensure 1 more call is made + obj.off('myevent', onMyEvent); + + obj.emit('myevent'); + + expect(called).to.equal(6); + }); + + it('calls to off without a handler do nothing', function () { + var called = 0; + + var onMyEvent = function () { + called++; + }; + + obj.on('myevent', onMyEvent); + obj.on('myevent', onMyEvent); + + obj.emit('myevent'); + + expect(called).to.equal(2); + + obj.off('myevent'); + + obj.emit('myevent'); + + expect(called).to.equal(4); + + obj.off('myevent', onMyEvent); + + obj.emit('myevent'); + + expect(called).to.equal(4); + }); + + it('handles multiple instances with the same prototype', function () { + var called = 0; + + function onMyEvent(e) { + called++; + } + + obj.on('myevent1', onMyEvent); + obj.on('myevent2', onMyEvent); + + obj2.istwo = true; + obj2.on('myevent1', onMyEvent); + obj2.on('myevent2', onMyEvent); + + obj.emit('myevent1'); + obj.emit('myevent2'); + obj2.emit('myevent1'); + obj2.emit('myevent2'); + + //we emit 4 times, but since obj2 is a child of obj the event should bubble + //up to obj and show up there as well. So the obj2.emit() calls each increment + //the counter twice. + expect(called).to.equal(6); + }); + + it('is backwards compatible with older .dispatchEvent({})', function () { + var called = 0, + data = { + some: 'thing', + hello: true + }; + + function onMyEvent(event) { + pixi_utils_EventTarget_Event_confirm(event, obj, data); + + called++; + } + + obj.on('myevent1', onMyEvent); + obj.on('myevent2', onMyEvent); + obj.on('myevent3', onMyEvent); + + data.type = 'myevent1'; + obj.emit(data); + + data.type = 'myevent2'; + obj.emit(data); + + data.type = 'myevent3'; + obj.emit(data); + + obj.off('myevent2', onMyEvent); + + data.type = 'myevent1'; + obj.emit(data); + + data.type = 'myevent2'; + obj.emit(data); + + data.type = 'myevent3'; + obj.emit(data); + + expect(called).to.equal(5); + }); + + it('is backwards compatible with older .call(this)', function () { + var Fn = function() { + PIXI.EventTarget.call(this); + }, + o = new Fn(); + + pixi_utils_EventTarget_confirm(o); + }); + + it('is backwards compatible with older .addEventListener("")', function () { + var called = 0, + data = { + some: 'thing', + hello: true + }; + + function onMyEvent(event) { + pixi_utils_EventTarget_Event_confirm(event, obj, data); + + called++; + } + + obj.addEventListener('myevent1', onMyEvent); + obj.addEventListener('myevent2', onMyEvent); + obj.addEventListener('myevent3', onMyEvent); + + data.type = 'myevent1'; + obj.emit(data); + + data.type = 'myevent2'; + obj.emit(data); + + data.type = 'myevent3'; + obj.emit(data); + + obj.off('myevent2', onMyEvent); + + data.type = 'myevent1'; + obj.emit(data); + + data.type = 'myevent2'; + obj.emit(data); + + data.type = 'myevent3'; + obj.emit(data); + + expect(called).to.equal(5); + }); + + it('event remove during emit call properly', function () { + var called = 0; + + function cb1() { + called++; + obj.off('myevent', cb1); + } + function cb2() { + called++; + obj.off('myevent', cb2); + } + function cb3() { + called++; + obj.off('myevent', cb3); + } + + obj.on('myevent', cb1); + obj.on('myevent', cb2); + obj.on('myevent', cb3); + obj.emit('myevent', ''); + + expect(called).to.equal(3); + }); +}); diff --git a/test/unit/pixi-v2/utils/Polyk.js b/test/unit/pixi-v2/utils/Polyk.js new file mode 100644 index 0000000..dfc7128 --- /dev/null +++ b/test/unit/pixi-v2/utils/Polyk.js @@ -0,0 +1,14 @@ +describe('pixi/utils/Polyk', function () { + 'use strict'; + + var expect = chai.expect; + var PolyK = PIXI.PolyK; + + it('Module exists', function () { + expect(PolyK).to.be.an('object'); + }); + + it('Members exist', function () { + expect(PolyK).to.respondTo('Triangulate'); + }); +}); diff --git a/test/unit/pixi-v2/utils/Utils.js b/test/unit/pixi-v2/utils/Utils.js new file mode 100644 index 0000000..c97b3c6 --- /dev/null +++ b/test/unit/pixi-v2/utils/Utils.js @@ -0,0 +1,17 @@ +describe('Utils', function () { + 'use strict'; + + var expect = chai.expect; + + it('requestAnimationFrame exists', function () { + expect(global).to.respondTo('requestAnimationFrame'); + }); + + it('cancelAnimationFrame exists', function () { + expect(global).to.respondTo('cancelAnimationFrame'); + }); + + it('requestAnimFrame exists', function () { + expect(global).to.respondTo('requestAnimFrame'); + }); +}); diff --git a/test/unit/pixi-v2/InteractionManager.js b/test/unit/pixi-v2/InteractionManager.js new file mode 100644 index 0000000..ed3001f --- /dev/null +++ b/test/unit/pixi-v2/InteractionManager.js @@ -0,0 +1,10 @@ +describe('pixi/InteractionManager', function () { + 'use strict'; + + var expect = chai.expect; + var InteractionManager = PIXI.InteractionManager; + + it('Module exists', function () { + expect(InteractionManager).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/Pixi.js b/test/unit/pixi-v2/Pixi.js new file mode 100644 index 0000000..27debc1 --- /dev/null +++ b/test/unit/pixi-v2/Pixi.js @@ -0,0 +1,9 @@ +describe('pixi/Pixi', function () { + 'use strict'; + + var expect = chai.expect; + + it('Module exists', function () { + expect(global).to.have.property('PIXI').and.to.be.an('object'); + }); +}); diff --git a/test/unit/pixi-v2/core/Circle.js b/test/unit/pixi-v2/core/Circle.js new file mode 100644 index 0000000..fbcfa17 --- /dev/null +++ b/test/unit/pixi-v2/core/Circle.js @@ -0,0 +1,21 @@ +describe('pixi/core/Circle', function () { + 'use strict'; + + var expect = chai.expect; + var Circle = PIXI.Circle; + + it('Module exists', function () { + expect(Circle).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Circle(); + pixi_core_Circle_confirmNewCircle(obj); + }); + + it("getBounds should return Rectangle that bounds the circle", function() { + var obj = new Circle(100, 250, 50); + var bounds = obj.getBounds(); + pixi_core_Circle_isBoundedByRectangle(obj, bounds); + }); +}); diff --git a/test/unit/pixi-v2/core/Ellipse.js b/test/unit/pixi-v2/core/Ellipse.js new file mode 100644 index 0000000..026b56f --- /dev/null +++ b/test/unit/pixi-v2/core/Ellipse.js @@ -0,0 +1,24 @@ +describe('pixi/core/Ellipse', function () { + 'use strict'; + + var expect = chai.expect; + var Ellipse = PIXI.Ellipse; + + it('Module exists', function () { + expect(Ellipse).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Ellipse(); + + expect(obj).to.be.an.instanceof(Ellipse); + expect(obj).to.respondTo('clone'); + expect(obj).to.respondTo('contains'); + expect(obj).to.respondTo('getBounds'); + + expect(obj).to.have.property('x', 0); + expect(obj).to.have.property('y', 0); + expect(obj).to.have.property('width', 0); + expect(obj).to.have.property('height', 0); + }); +}); diff --git a/test/unit/pixi-v2/core/Matrix.js b/test/unit/pixi-v2/core/Matrix.js new file mode 100644 index 0000000..da75e2e --- /dev/null +++ b/test/unit/pixi-v2/core/Matrix.js @@ -0,0 +1,14 @@ +describe('pixi/core/Matrix', function () { + 'use strict'; + + var expect = chai.expect; + + it('Matrix exists', function () { + expect(PIXI.Matrix).to.be.an('function'); + }); + + it('Confirm new Matrix', function () { + var matrix = new PIXI.Matrix(); + pixi_core_Matrix_confirmNewMatrix(matrix); + }); +}); diff --git a/test/unit/pixi-v2/core/Point.js b/test/unit/pixi-v2/core/Point.js new file mode 100644 index 0000000..c4d5163 --- /dev/null +++ b/test/unit/pixi-v2/core/Point.js @@ -0,0 +1,15 @@ +describe('pixi/core/Point', function () { + 'use strict'; + + var expect = chai.expect; + var Point = PIXI.Point; + + it('Module exists', function () { + expect(Point).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Point(); + pixi_core_Point_confirm(obj, 0, 0); + }); +}); diff --git a/test/unit/pixi-v2/core/Polygon.js b/test/unit/pixi-v2/core/Polygon.js new file mode 100644 index 0000000..dc8c918 --- /dev/null +++ b/test/unit/pixi-v2/core/Polygon.js @@ -0,0 +1,20 @@ +describe('pixi/core/Polygon', function () { + 'use strict'; + + var expect = chai.expect; + var Polygon = PIXI.Polygon; + + it('Module exists', function () { + expect(Polygon).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Polygon(); + + expect(obj).to.be.an.instanceof(Polygon); + expect(obj).to.respondTo('clone'); + expect(obj).to.respondTo('contains'); + + expect(obj).to.have.deep.property('points.length', 0); + }); +}); diff --git a/test/unit/pixi-v2/core/Rectangle.js b/test/unit/pixi-v2/core/Rectangle.js new file mode 100644 index 0000000..d43316e --- /dev/null +++ b/test/unit/pixi-v2/core/Rectangle.js @@ -0,0 +1,15 @@ +describe('pixi/core/Rectangle', function () { + 'use strict'; + + var expect = chai.expect; + var Rectangle = PIXI.Rectangle; + + it('Module exists', function () { + expect(Rectangle).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var rect = new Rectangle(); + pixi_core_Rectangle_confirm(rect, 0, 0, 0, 0); + }); +}); diff --git a/test/unit/pixi-v2/display/DisplayObject.js b/test/unit/pixi-v2/display/DisplayObject.js new file mode 100644 index 0000000..044acf8 --- /dev/null +++ b/test/unit/pixi-v2/display/DisplayObject.js @@ -0,0 +1,21 @@ +describe('pixi/display/DisplayObject', function () { + 'use strict'; + + var expect = chai.expect; + var DisplayObject = PIXI.DisplayObject; + + it('Module exists', function () { + expect(DisplayObject).to.be.a('function'); + // expect(PIXI).to.have.property('visibleCount', 0); + }); + + it('Confirm new instance', function () { + var obj = new DisplayObject(); + + pixi_display_DisplayObject_confirmNew(obj); + expect(obj).to.have.property('hitArea', null); + expect(obj).to.have.property('interactive', false); + expect(obj).to.have.property('renderable', false); + expect(obj).to.have.property('stage', null); + }); +}); diff --git a/test/unit/pixi-v2/display/DisplayObjectContainer.js b/test/unit/pixi-v2/display/DisplayObjectContainer.js new file mode 100644 index 0000000..15a3376 --- /dev/null +++ b/test/unit/pixi-v2/display/DisplayObjectContainer.js @@ -0,0 +1,67 @@ +describe('pixi/display/DisplayObjectContainer', function () { + 'use strict'; + + var expect = chai.expect; + var DisplayObjectContainer = PIXI.DisplayObjectContainer; + + it('Module exists', function () { + expect(DisplayObjectContainer).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new DisplayObjectContainer(); + + pixi_display_DisplayObjectContainer_confirmNew(obj); + expect(obj).to.have.property('hitArea', null); + expect(obj).to.have.property('interactive', false); + expect(obj).to.have.property('renderable', false); + expect(obj).to.have.property('stage', null); + }); + + it('Gets child index', function() { + var container = new PIXI.DisplayObjectContainer(); + var children = []; + for (var i = 0; i < 10; i++) { + var child = new PIXI.DisplayObject(); + children.push(child); + container.addChild(child); + } + + for (i = 0; i < children.length; i++) { + expect(i).to.eql(container.getChildIndex(children[i])); + } + }); + + it('throws error when trying to get index of not a child', function() { + var container = new PIXI.DisplayObjectContainer(); + var child = new PIXI.DisplayObject(); + + expect(function() { container.getChildIndex(child); }).to.throw(); + }); + + it('Sets child index', function() { + var container = new PIXI.DisplayObjectContainer(); + var children = []; + + for (var i = 0; i < 10; i++) { + var child = new PIXI.DisplayObject(); + children.push(child); + container.addChild(child); + } + children.reverse(); + + for (i = 0; i < children.length; i++) { + container.setChildIndex(children[i], i); + expect(i).to.eql(container.getChildIndex(children[i])); + } + }); + + it('throws error when trying to set incorect index', function() { + var container = new PIXI.DisplayObjectContainer(); + var child = new PIXI.DisplayObject(); + container.addChild(child); + + expect(function() { container.setChildIndex(child, -1); }).to.throw(); + expect(function() { container.setChildIndex(child, 1); }).to.throw(); + }); +}); diff --git a/test/unit/pixi-v2/display/MovieClip.js b/test/unit/pixi-v2/display/MovieClip.js new file mode 100644 index 0000000..f3c6c6a --- /dev/null +++ b/test/unit/pixi-v2/display/MovieClip.js @@ -0,0 +1,33 @@ +describe('pixi/display/MovieClip', function () { + 'use strict'; + + var expect = chai.expect; + var MovieClip = PIXI.MovieClip; + var Texture = PIXI.Texture; + + it('Module exists', function () { + expect(MovieClip).to.be.a('function'); + }); + + it('Confirm new instance', function (done) { + var texture = Texture.fromImage('/base/test/textures/SpriteSheet-Explosion.png'); + var obj = new MovieClip([texture]); + + pixi_display_Sprite_confirmNew(obj, done); + + expect(obj).to.be.an.instanceof(MovieClip); + expect(obj).to.respondTo('stop'); + expect(obj).to.respondTo('play'); + expect(obj).to.respondTo('gotoAndStop'); + expect(obj).to.respondTo('gotoAndPlay'); + expect(obj).to.respondTo('updateTransform'); + + expect(obj).to.have.deep.property('textures.length', 1); + expect(obj).to.have.deep.property('textures[0]', texture); + expect(obj).to.have.property('animationSpeed', 1); + expect(obj).to.have.property('loop', true); + expect(obj).to.have.property('onComplete', null); + expect(obj).to.have.property('currentFrame', 0); + expect(obj).to.have.property('playing', false); + }); +}); diff --git a/test/unit/pixi-v2/display/Sprite.js b/test/unit/pixi-v2/display/Sprite.js new file mode 100644 index 0000000..30c8076 --- /dev/null +++ b/test/unit/pixi-v2/display/Sprite.js @@ -0,0 +1,28 @@ +describe('pixi/display/Sprite', function () { + 'use strict'; + + var expect = chai.expect; + var Sprite = PIXI.Sprite; + var Texture = PIXI.Texture; + + it('Module exists', function () { + expect(Sprite).to.be.a('function'); + expect(PIXI).to.have.deep.property('blendModes.NORMAL', 0); + expect(PIXI).to.have.deep.property('blendModes.ADD', 1); + expect(PIXI).to.have.deep.property('blendModes.MULTIPLY', 2); + expect(PIXI).to.have.deep.property('blendModes.SCREEN', 3); + }); + + + it('Members exist', function () { + expect(Sprite).itself.to.respondTo('fromImage'); + expect(Sprite).itself.to.respondTo('fromFrame'); + }); + + it('Confirm new instance', function (done) { + var texture = Texture.fromImage('/base/test/textures/SpriteSheet-Aliens.png'); + var obj = new Sprite(texture); + + pixi_display_Sprite_confirmNew(obj, done); + }); +}); diff --git a/test/unit/pixi-v2/display/Stage.js b/test/unit/pixi-v2/display/Stage.js new file mode 100644 index 0000000..6974c2e --- /dev/null +++ b/test/unit/pixi-v2/display/Stage.js @@ -0,0 +1,49 @@ +describe('pixi/display/Stage', function () { + 'use strict'; + + var expect = chai.expect; + var Stage = PIXI.Stage; + var InteractionManager = PIXI.InteractionManager; + var Rectangle = PIXI.Rectangle; + + it('Module exists', function () { + expect(Stage).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Stage(null, true); + + pixi_display_DisplayObjectContainer_confirmNew(obj); + + expect(obj).to.be.an.instanceof(Stage); + expect(obj).to.respondTo('updateTransform'); + expect(obj).to.respondTo('setBackgroundColor'); + expect(obj).to.respondTo('getMousePosition'); + // FIXME: duplicate member in DisplayObject + pixi_core_Matrix_confirmNewMatrix(obj.worldTransform); + // FIXME: convert arg to bool in constructor + expect(obj).to.have.property('interactive', true); + + expect(obj).to.have.property('interactionManager') + .and.to.be.an.instanceof(InteractionManager) + .and.to.have.property('stage', obj); + + expect(obj).to.have.property('dirty', true); + + expect(obj).to.have.property('stage', obj); + + expect(obj).to.have.property('hitArea') + .and.to.be.an.instanceof(Rectangle); + pixi_core_Rectangle_confirm(obj.hitArea, 0, 0, 100000, 100000); + + expect(obj).to.have.property('backgroundColor', 0x000000); + expect(obj).to.have.deep.property('backgroundColorSplit.length', 3); + expect(obj).to.have.deep.property('backgroundColorSplit[0]', 0); + expect(obj).to.have.deep.property('backgroundColorSplit[1]', 0); + expect(obj).to.have.deep.property('backgroundColorSplit[2]', 0); + expect(obj).to.have.property('backgroundColorString', '#000000'); + + + expect(obj).to.have.property('worldVisible', true); + }); +}); diff --git a/test/unit/pixi-v2/extras/Rope.js b/test/unit/pixi-v2/extras/Rope.js new file mode 100644 index 0000000..05885ac --- /dev/null +++ b/test/unit/pixi-v2/extras/Rope.js @@ -0,0 +1,31 @@ +describe('pixi/extras/Rope', function () { + 'use strict'; + + var expect = chai.expect; + var Rope = PIXI.Rope; + var Texture = PIXI.Texture; + var Point = PIXI.Point; + + it('Module exists', function () { + expect(Rope).to.be.a('function'); + }); + + it('Confirm new instance', function () { + + var texture = Texture.fromImage('/base/test/textures/bunny.png'); + + // TODO-Alvin + // Same as Strip + + // var obj = new Rope(texture, [new Point(), new Point(5, 10), new Point(10, 20)]); + + // pixi_extras_Strip_confirmNew(obj); + + // expect(obj).to.be.an.instanceof(Rope); + // expect(obj).to.respondTo('refresh'); + // expect(obj).to.respondTo('updateTransform'); + // expect(obj).to.respondTo('setTexture'); + + // TODO: Test properties + }); +}); diff --git a/test/unit/pixi-v2/extras/Spine.js b/test/unit/pixi-v2/extras/Spine.js new file mode 100644 index 0000000..0708bc0 --- /dev/null +++ b/test/unit/pixi-v2/extras/Spine.js @@ -0,0 +1,10 @@ +describe('pixi/extras/Spine', function () { + 'use strict'; + + var expect = chai.expect; + var Spine = PIXI.Spine; + + it('Module exists', function () { + expect(Spine).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/extras/Strip.js b/test/unit/pixi-v2/extras/Strip.js new file mode 100644 index 0000000..230af90 --- /dev/null +++ b/test/unit/pixi-v2/extras/Strip.js @@ -0,0 +1,26 @@ +describe('pixi/extras/Strip', function () { + 'use strict'; + + var expect = chai.expect; + var Strip = PIXI.Strip; + var Texture = PIXI.Texture; + + it('Module exists', function () { + expect(Strip).to.be.a('function'); + }); + + it('Confirm new instance', function () { + + + // TODO-Alvin + // We tweaked it to make it pass the tests, but the whole strip class needs + // to be re-coded + + var texture = Texture.fromImage('/base/test/textures/bunny.png'); + + // var obj = new Strip(texture, 20, 10000); + + + // pixi_extras_Strip_confirmNew(obj); + }); +}); diff --git a/test/unit/pixi-v2/extras/TilingSprite.js b/test/unit/pixi-v2/extras/TilingSprite.js new file mode 100644 index 0000000..56aea14 --- /dev/null +++ b/test/unit/pixi-v2/extras/TilingSprite.js @@ -0,0 +1,24 @@ +describe('pixi/extras/TilingSprite', function () { + 'use strict'; + + var expect = chai.expect; + var TilingSprite = PIXI.TilingSprite; + var Texture = PIXI.Texture; + + it('Module exists', function () { + expect(TilingSprite).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var texture = Texture.fromImage('/base/test/textures/bunny.png'); + var obj = new TilingSprite(texture, 6000, 12000); + + pixi_display_DisplayObjectContainer_confirmNew(obj); + + expect(obj).to.be.an.instanceof(TilingSprite); + expect(obj).to.respondTo('setTexture'); + expect(obj).to.respondTo('onTextureUpdate'); + + // TODO: Test properties + }); +}); diff --git a/test/unit/pixi-v2/filters/FilterBlock.js b/test/unit/pixi-v2/filters/FilterBlock.js new file mode 100644 index 0000000..870cec0 --- /dev/null +++ b/test/unit/pixi-v2/filters/FilterBlock.js @@ -0,0 +1,10 @@ +describe('pixi/filters/FilterBlock', function () { + 'use strict'; + + var expect = chai.expect; + var FilterBlock = PIXI.FilterBlock; + + it('Module exists', function () { + expect(FilterBlock).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/AssetLoader.js b/test/unit/pixi-v2/loaders/AssetLoader.js new file mode 100644 index 0000000..a0aa0b5 --- /dev/null +++ b/test/unit/pixi-v2/loaders/AssetLoader.js @@ -0,0 +1,10 @@ +describe('pixi/loaders/AssetLoader', function () { + 'use strict'; + + var expect = chai.expect; + var AssetLoader = PIXI.AssetLoader; + + it('Module exists', function () { + expect(AssetLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/BitmapFontLoader.js b/test/unit/pixi-v2/loaders/BitmapFontLoader.js new file mode 100644 index 0000000..046f018 --- /dev/null +++ b/test/unit/pixi-v2/loaders/BitmapFontLoader.js @@ -0,0 +1,9 @@ +describe('pixi/loaders/BitmapFontLoader', function () { + 'use strict'; + + var expect = chai.expect; + + it('Module exists', function () { + expect(PIXI.BitmapFontLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/ImageLoader.js b/test/unit/pixi-v2/loaders/ImageLoader.js new file mode 100644 index 0000000..8b1f556 --- /dev/null +++ b/test/unit/pixi-v2/loaders/ImageLoader.js @@ -0,0 +1,10 @@ +describe('pixi/loaders/ImageLoader', function () { + 'use strict'; + + var expect = chai.expect; + var ImageLoader = PIXI.ImageLoader; + + it('Module exists', function () { + expect(ImageLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/JsonLoader.js b/test/unit/pixi-v2/loaders/JsonLoader.js new file mode 100644 index 0000000..c577e83 --- /dev/null +++ b/test/unit/pixi-v2/loaders/JsonLoader.js @@ -0,0 +1,10 @@ +describe('pixi/loaders/JsonLoader', function () { + 'use strict'; + + var expect = chai.expect; + var JsonLoader = PIXI.JsonLoader; + + it('Module exists', function () { + expect(JsonLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/SpineLoader.js b/test/unit/pixi-v2/loaders/SpineLoader.js new file mode 100644 index 0000000..fdcc0b8 --- /dev/null +++ b/test/unit/pixi-v2/loaders/SpineLoader.js @@ -0,0 +1,10 @@ +describe('pixi/loaders/SpineLoader', function () { + 'use strict'; + + var expect = chai.expect; + var SpineLoader = PIXI.SpineLoader; + + it('Module exists', function () { + expect(SpineLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/SpriteSheetLoader.js b/test/unit/pixi-v2/loaders/SpriteSheetLoader.js new file mode 100644 index 0000000..57beb27 --- /dev/null +++ b/test/unit/pixi-v2/loaders/SpriteSheetLoader.js @@ -0,0 +1,10 @@ +describe('pixi/loaders/SpriteSheetLoader', function () { + 'use strict'; + + var expect = chai.expect; + var SpriteSheetLoader = PIXI.SpriteSheetLoader; + + it('Module exists', function () { + expect(SpriteSheetLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/primitives/Graphics.js b/test/unit/pixi-v2/primitives/Graphics.js new file mode 100644 index 0000000..f3849eb --- /dev/null +++ b/test/unit/pixi-v2/primitives/Graphics.js @@ -0,0 +1,44 @@ +describe('pixi/primitives/Graphics', function () { + 'use strict'; + + var expect = chai.expect; + var Graphics = PIXI.Graphics; + + it('Module exists', function () { + expect(Graphics).to.be.a('function'); + + expect(Graphics).itself.to.have.property('POLY', 0); + expect(Graphics).itself.to.have.property('RECT', 1); + expect(Graphics).itself.to.have.property('CIRC', 2); + expect(Graphics).itself.to.have.property('ELIP', 3); + expect(Graphics).itself.to.have.property('RREC', 4); + }); + + it('Confirm new instance', function () { + var obj = new Graphics(); + + pixi_display_DisplayObjectContainer_confirmNew(obj); + + expect(obj).to.be.an.instanceof(Graphics); + expect(obj).to.respondTo('lineStyle'); + expect(obj).to.respondTo('lineStyle'); + expect(obj).to.respondTo('moveTo'); + expect(obj).to.respondTo('lineTo'); + expect(obj).to.respondTo('beginFill'); + expect(obj).to.respondTo('endFill'); + expect(obj).to.respondTo('drawRect'); + // expect(obj).to.respondTo('drawRoundedRect'); + expect(obj).to.respondTo('drawCircle'); + expect(obj).to.respondTo('drawEllipse'); + expect(obj).to.respondTo('clear'); + + expect(obj).to.have.property('renderable', true); + expect(obj).to.have.property('fillAlpha', 1); + expect(obj).to.have.property('lineWidth', 0); + expect(obj).to.have.property('width', 0); + expect(obj).to.have.property('height', 0); + expect(obj).to.have.property('lineColor', 0); + expect(obj).to.have.deep.property('graphicsData.length', 0); + // expect(obj).to.have.deep.property('currentPath.points.length', 0); + }); +}); diff --git a/test/unit/pixi-v2/renderers/canvas/CanvasGraphics.js b/test/unit/pixi-v2/renderers/canvas/CanvasGraphics.js new file mode 100644 index 0000000..8f44472 --- /dev/null +++ b/test/unit/pixi-v2/renderers/canvas/CanvasGraphics.js @@ -0,0 +1,15 @@ +describe('renders/canvas/CanvasGraphics', function () { + 'use strict'; + + var expect = chai.expect; + var CanvasGraphics = PIXI.CanvasGraphics; + + it('Module exists', function () { + expect(CanvasGraphics).to.be.a('function'); + }); + + it('Members exist', function () { + expect(CanvasGraphics).itself.to.respondTo('renderGraphics'); + expect(CanvasGraphics).itself.to.respondTo('renderGraphicsMask'); + }); +}); diff --git a/test/unit/pixi-v2/renderers/canvas/CanvasRenderer.js b/test/unit/pixi-v2/renderers/canvas/CanvasRenderer.js new file mode 100644 index 0000000..1646444 --- /dev/null +++ b/test/unit/pixi-v2/renderers/canvas/CanvasRenderer.js @@ -0,0 +1,36 @@ +describe('renderers/canvas/CanvasRenderer', function () { + 'use strict'; + + var expect = chai.expect; + var CanvasRenderer = PIXI.CanvasRenderer; + + it('Module exists', function () { + expect(CanvasRenderer).to.be.a('function'); + }); + + describe('.autoResize', function () { + it('Should automatically resize view if enabled', function () { + var renderer = new CanvasRenderer(200, 200, { + autoResize: true + }); + + expect(renderer.view.style.width).to.equal('200px'); + }); + + it('Should not automatically resize view if disabled', function () { + var renderer = new CanvasRenderer(200, 200, { + autoResize: false + }); + + expect(renderer.view.style.width).to.equal(''); + }); + + it('Should not automatically resize view if not specified', function () { + var renderer = new CanvasRenderer(200, 200, { + resolution: 2 + }); + + expect(renderer.view.style.width).to.equal(''); + }); + }); +}); diff --git a/test/unit/pixi-v2/renderers/webgl/WebGLGraphics.js b/test/unit/pixi-v2/renderers/webgl/WebGLGraphics.js new file mode 100644 index 0000000..5867b28 --- /dev/null +++ b/test/unit/pixi-v2/renderers/webgl/WebGLGraphics.js @@ -0,0 +1,20 @@ +describe('renderers/wegbl/WebGLGraphics', function () { + 'use strict'; + + var expect = chai.expect; + var WebGLGraphics = PIXI.WebGLGraphics; + + it('Module exists', function () { + expect(WebGLGraphics).to.be.a('function'); + }); + + it('Members exist', function () { + expect(WebGLGraphics).itself.to.respondTo('renderGraphics'); + expect(WebGLGraphics).itself.to.respondTo('updateGraphics'); + expect(WebGLGraphics).itself.to.respondTo('buildRectangle'); + expect(WebGLGraphics).itself.to.respondTo('buildRoundedRectangle'); + expect(WebGLGraphics).itself.to.respondTo('buildCircle'); + expect(WebGLGraphics).itself.to.respondTo('buildLine'); + expect(WebGLGraphics).itself.to.respondTo('buildPoly'); + }); +}); diff --git a/test/unit/pixi-v2/renderers/webgl/WebGLRenderer.js b/test/unit/pixi-v2/renderers/webgl/WebGLRenderer.js new file mode 100644 index 0000000..1680a80 --- /dev/null +++ b/test/unit/pixi-v2/renderers/webgl/WebGLRenderer.js @@ -0,0 +1,49 @@ +describe('renderers/webgl/WebGLRenderer', function () { + 'use strict'; + + var expect = chai.expect; + var WebGLRenderer = PIXI.WebGLRenderer; + + it('Module exists', function () { + expect(WebGLRenderer).to.be.a('function'); + }); + + // Skip tests if WebGL is not available (WebGL not supported in Travis CI) + try { + var renderer = new WebGLRenderer(400, 300, {}); + renderer.destroy(); + } catch (error) { + return; + } + + it('Destroy renderer', function () { + var renderer = new WebGLRenderer(400, 300, {}); + renderer.destroy(); + }); + + describe('.autoResize', function () { + it('Should automatically resize view if enabled', function () { + var renderer = new WebGLRenderer(200, 200, { + autoResize: true + }); + + expect(renderer.view.style.width).to.equal('200px'); + }); + + it('Should not automatically resize view if disabled', function () { + var renderer = new WebGLRenderer(200, 200, { + autoResize: false + }); + + expect(renderer.view.style.width).to.equal(''); + }); + + it('Should not automatically resize view if not specified', function () { + var renderer = new WebGLRenderer(200, 200, { + resolution: 2 + }); + + expect(renderer.view.style.width).to.equal(''); + }); + }); +}); diff --git a/test/unit/pixi-v2/renderers/webgl/WebGLShaders.js b/test/unit/pixi-v2/renderers/webgl/WebGLShaders.js new file mode 100644 index 0000000..6e33e4f --- /dev/null +++ b/test/unit/pixi-v2/renderers/webgl/WebGLShaders.js @@ -0,0 +1,13 @@ +describe('renderers/webgl/WebGLShaders', function () { + 'use strict'; + + var expect = chai.expect; + + it('Module members exist', function () { + + expect(PIXI).to.respondTo('CompileVertexShader'); + expect(PIXI).to.respondTo('CompileFragmentShader'); + expect(PIXI).to.respondTo('_CompileShader'); + expect(PIXI).to.respondTo('compileProgram'); + }); +}); diff --git a/test/unit/pixi-v2/renderers/webgl/WebGLSpriteBatch.js b/test/unit/pixi-v2/renderers/webgl/WebGLSpriteBatch.js new file mode 100644 index 0000000..e662b63 --- /dev/null +++ b/test/unit/pixi-v2/renderers/webgl/WebGLSpriteBatch.js @@ -0,0 +1,10 @@ +describe('renderers/webgl/utils/WebGLSpriteBatch', function () { + 'use strict'; + + var expect = chai.expect; + var WebGLSpriteBatch = PIXI.WebGLSpriteBatch; + + it('Module exists', function () { + expect(WebGLSpriteBatch).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/text/BitmapText.js b/test/unit/pixi-v2/text/BitmapText.js new file mode 100644 index 0000000..9388e3d --- /dev/null +++ b/test/unit/pixi-v2/text/BitmapText.js @@ -0,0 +1,10 @@ +describe('pixi/text/BitmapText', function () { + 'use strict'; + + var expect = chai.expect; + var BitmapText = PIXI.BitmapText; + + it('Module exists', function () { + expect(BitmapText).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/text/Text.js b/test/unit/pixi-v2/text/Text.js new file mode 100644 index 0000000..9bc9ac5 --- /dev/null +++ b/test/unit/pixi-v2/text/Text.js @@ -0,0 +1,10 @@ +describe('pixi/text/Text', function () { + 'use strict'; + + var expect = chai.expect; + var Text = PIXI.Text; + + it('Module exists', function () { + expect(Text).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/textures/BaseTexture.js b/test/unit/pixi-v2/textures/BaseTexture.js new file mode 100644 index 0000000..502b724 --- /dev/null +++ b/test/unit/pixi-v2/textures/BaseTexture.js @@ -0,0 +1,11 @@ +describe('pixi/textures/BaseTexture', function () { + 'use strict'; + + var expect = chai.expect; + var BaseTexture = PIXI.BaseTexture; + + it('Module exists', function () { + expect(BaseTexture).to.be.a('function'); + expect(PIXI).to.have.property('BaseTextureCache').and.to.be.an('object'); + }); +}); diff --git a/test/unit/pixi-v2/textures/RenderTexture.js b/test/unit/pixi-v2/textures/RenderTexture.js new file mode 100644 index 0000000..96acdb4 --- /dev/null +++ b/test/unit/pixi-v2/textures/RenderTexture.js @@ -0,0 +1,15 @@ +describe('pixi/textures/RenderTexture', function () { + 'use strict'; + + var expect = chai.expect; + var RenderTexture = PIXI.RenderTexture; + + it('Module exists', function () { + expect(RenderTexture).to.be.a('function'); + }); + + it('Confirm new instance', function (done) { + var texture = new RenderTexture(100, 100, new PIXI.CanvasRenderer()); + pixi_textures_RenderTexture_confirmNew(texture, done); + }); +}); diff --git a/test/unit/pixi-v2/textures/Texture.js b/test/unit/pixi-v2/textures/Texture.js new file mode 100644 index 0000000..090f64d --- /dev/null +++ b/test/unit/pixi-v2/textures/Texture.js @@ -0,0 +1,26 @@ +describe('pixi/textures/Texture', function () { + 'use strict'; + + var expect = chai.expect; + var Texture = PIXI.Texture; + + it('Module exists', function () { + expect(Texture).to.be.a('function'); + expect(PIXI).to.have.property('TextureCache').and.to.be.an('object'); + }); + + it('Members exist', function () { + expect(Texture).itself.to.respondTo('fromImage'); + expect(Texture).itself.to.respondTo('fromFrame'); + expect(Texture).itself.to.respondTo('fromCanvas'); + expect(Texture).itself.to.respondTo('addTextureToCache'); + expect(Texture).itself.to.respondTo('removeTextureFromCache'); + + // expect(Texture).itself.to.have.deep.property('frameUpdates.length', 0); + }); + + it('Confirm new instance', function (done) { + var texture = Texture.fromImage('/base/test/textures/bunny.png'); + pixi_textures_Texture_confirmNew(texture, done); + }); +}); diff --git a/test/unit/pixi-v2/utils/Detector.js b/test/unit/pixi-v2/utils/Detector.js new file mode 100644 index 0000000..4cf6008 --- /dev/null +++ b/test/unit/pixi-v2/utils/Detector.js @@ -0,0 +1,10 @@ +describe('pixi/utils/Detector', function () { + 'use strict'; + + var expect = chai.expect; + var autoDetectRenderer = PIXI.autoDetectRenderer; + + it('Module exists', function () { + expect(autoDetectRenderer).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/utils/EventTarget.js b/test/unit/pixi-v2/utils/EventTarget.js new file mode 100644 index 0000000..1cfc3a4 --- /dev/null +++ b/test/unit/pixi-v2/utils/EventTarget.js @@ -0,0 +1,361 @@ +describe('pixi/utils/EventTarget', function () { + 'use strict'; + + var expect = chai.expect; + + var Clazz, PClazz, obj, pobj, obj2; + beforeEach(function () { + Clazz = function () {}; + PClazz = function () {}; + + PIXI.EventTarget.mixin(Clazz.prototype); + PIXI.EventTarget.mixin(PClazz.prototype); + + obj = new Clazz(); + obj2 = new Clazz(); + pobj = new PClazz(); + + obj.parent = pobj; + obj2.parent = obj; + }); + + it('Module exists', function () { + expect(PIXI.EventTarget).to.be.an('object'); + }); + + it('Confirm new instance', function () { + pixi_utils_EventTarget_confirm(obj); + }); + + it('simple on/emit case works', function () { + var myData = {}; + + obj.on('myevent', function (event) { + pixi_utils_EventTarget_Event_confirm(event, obj, myData); + }); + + obj.emit('myevent', myData); + }); + + it('simple once case works', function () { + var called = 0; + + obj.once('myevent', function() { called++; }); + + obj.emit('myevent'); + obj.emit('myevent'); + obj.emit('myevent'); + obj.emit('myevent'); + obj.emit('myevent'); + + expect(called).to.equal(1); + }); + + it('simple off case works', function (done) { + function onMyEvent() { + done(new Error('Event listener should not have been called')); + } + + obj.on('myevent', onMyEvent); + obj.off('myevent', onMyEvent); + obj.emit('myevent'); + + done(); + }); + + it('simple propagation case works', function (done) { + var myData = {}; + + pobj.on('myevent', function () { + done(); + }); + + obj.emit('myevent'); + }); + + it('simple stopPropagation case works', function (done) { + var myData = {}; + + pobj.on('myevent', function () { + done(new Error('Event listener should not have been called on the parent element')); + }); + + obj.on('myevent', function (evt) { + evt.stopPropagation(); + }); + + obj.emit('myevent'); + + done(); + }); + + it('simple stopImmediatePropagation case works', function (done) { + var myData = {}; + + pobj.on('myevent', function () { + done(new Error('Event listener should not have been called on the parent')); + }); + + obj.on('myevent', function (evt) { + evt.stopImmediatePropagation(); + }); + + obj.on('myevent', function () { + done(new Error('Event listener should not have been called on the second')); + }); + + obj.emit('myevent'); + + done(); + }); + + it('multiple dispatches work properly', function () { + var called = 0; + + function onMyEvent() { + called++; + } + + obj.on('myevent', onMyEvent); + obj.emit('myevent'); + obj.emit('myevent'); + obj.emit('myevent'); + obj.emit('myevent'); + + expect(called).to.equal(4); + }); + + it('multiple events work properly', function () { + var called = 0; + + function onMyEvent() { + called++; + } + + obj.on('myevent1', onMyEvent); + obj.on('myevent2', onMyEvent); + obj.on('myevent3', onMyEvent); + obj.emit('myevent1'); + obj.emit('myevent2'); + obj.emit('myevent3'); + + expect(called).to.equal(3); + }); + + it('multiple events one removed works properly', function () { + var called = 0; + + function onMyEvent() { + called++; + } + + obj.on('myevent1', onMyEvent); + obj.on('myevent2', onMyEvent); + obj.on('myevent3', onMyEvent); + + obj.emit('myevent1'); + obj.emit('myevent2'); + obj.emit('myevent3'); + + obj.off('myevent2', onMyEvent); + + obj.emit('myevent1'); + obj.emit('myevent2'); + obj.emit('myevent3'); + + expect(called).to.equal(5); + }); + + it('multiple handlers for one event with some removed', function () { + var called = 0; + + var onMyEvent = function () { + called++; + }, + onMyEvent2 = function () { + called++; + }; + + // add 2 handlers and confirm they both get called + obj.on('myevent', onMyEvent); + obj.on('myevent', onMyEvent); + obj.on('myevent', onMyEvent2); + obj.on('myevent', onMyEvent2); + + obj.emit('myevent'); + + expect(called).to.equal(4); + + // remove one of the handlers, emit again, then ensure 1 more call is made + obj.off('myevent', onMyEvent); + + obj.emit('myevent'); + + expect(called).to.equal(6); + }); + + it('calls to off without a handler do nothing', function () { + var called = 0; + + var onMyEvent = function () { + called++; + }; + + obj.on('myevent', onMyEvent); + obj.on('myevent', onMyEvent); + + obj.emit('myevent'); + + expect(called).to.equal(2); + + obj.off('myevent'); + + obj.emit('myevent'); + + expect(called).to.equal(4); + + obj.off('myevent', onMyEvent); + + obj.emit('myevent'); + + expect(called).to.equal(4); + }); + + it('handles multiple instances with the same prototype', function () { + var called = 0; + + function onMyEvent(e) { + called++; + } + + obj.on('myevent1', onMyEvent); + obj.on('myevent2', onMyEvent); + + obj2.istwo = true; + obj2.on('myevent1', onMyEvent); + obj2.on('myevent2', onMyEvent); + + obj.emit('myevent1'); + obj.emit('myevent2'); + obj2.emit('myevent1'); + obj2.emit('myevent2'); + + //we emit 4 times, but since obj2 is a child of obj the event should bubble + //up to obj and show up there as well. So the obj2.emit() calls each increment + //the counter twice. + expect(called).to.equal(6); + }); + + it('is backwards compatible with older .dispatchEvent({})', function () { + var called = 0, + data = { + some: 'thing', + hello: true + }; + + function onMyEvent(event) { + pixi_utils_EventTarget_Event_confirm(event, obj, data); + + called++; + } + + obj.on('myevent1', onMyEvent); + obj.on('myevent2', onMyEvent); + obj.on('myevent3', onMyEvent); + + data.type = 'myevent1'; + obj.emit(data); + + data.type = 'myevent2'; + obj.emit(data); + + data.type = 'myevent3'; + obj.emit(data); + + obj.off('myevent2', onMyEvent); + + data.type = 'myevent1'; + obj.emit(data); + + data.type = 'myevent2'; + obj.emit(data); + + data.type = 'myevent3'; + obj.emit(data); + + expect(called).to.equal(5); + }); + + it('is backwards compatible with older .call(this)', function () { + var Fn = function() { + PIXI.EventTarget.call(this); + }, + o = new Fn(); + + pixi_utils_EventTarget_confirm(o); + }); + + it('is backwards compatible with older .addEventListener("")', function () { + var called = 0, + data = { + some: 'thing', + hello: true + }; + + function onMyEvent(event) { + pixi_utils_EventTarget_Event_confirm(event, obj, data); + + called++; + } + + obj.addEventListener('myevent1', onMyEvent); + obj.addEventListener('myevent2', onMyEvent); + obj.addEventListener('myevent3', onMyEvent); + + data.type = 'myevent1'; + obj.emit(data); + + data.type = 'myevent2'; + obj.emit(data); + + data.type = 'myevent3'; + obj.emit(data); + + obj.off('myevent2', onMyEvent); + + data.type = 'myevent1'; + obj.emit(data); + + data.type = 'myevent2'; + obj.emit(data); + + data.type = 'myevent3'; + obj.emit(data); + + expect(called).to.equal(5); + }); + + it('event remove during emit call properly', function () { + var called = 0; + + function cb1() { + called++; + obj.off('myevent', cb1); + } + function cb2() { + called++; + obj.off('myevent', cb2); + } + function cb3() { + called++; + obj.off('myevent', cb3); + } + + obj.on('myevent', cb1); + obj.on('myevent', cb2); + obj.on('myevent', cb3); + obj.emit('myevent', ''); + + expect(called).to.equal(3); + }); +}); diff --git a/test/unit/pixi-v2/utils/Polyk.js b/test/unit/pixi-v2/utils/Polyk.js new file mode 100644 index 0000000..dfc7128 --- /dev/null +++ b/test/unit/pixi-v2/utils/Polyk.js @@ -0,0 +1,14 @@ +describe('pixi/utils/Polyk', function () { + 'use strict'; + + var expect = chai.expect; + var PolyK = PIXI.PolyK; + + it('Module exists', function () { + expect(PolyK).to.be.an('object'); + }); + + it('Members exist', function () { + expect(PolyK).to.respondTo('Triangulate'); + }); +}); diff --git a/test/unit/pixi-v2/utils/Utils.js b/test/unit/pixi-v2/utils/Utils.js new file mode 100644 index 0000000..c97b3c6 --- /dev/null +++ b/test/unit/pixi-v2/utils/Utils.js @@ -0,0 +1,17 @@ +describe('Utils', function () { + 'use strict'; + + var expect = chai.expect; + + it('requestAnimationFrame exists', function () { + expect(global).to.respondTo('requestAnimationFrame'); + }); + + it('cancelAnimationFrame exists', function () { + expect(global).to.respondTo('cancelAnimationFrame'); + }); + + it('requestAnimFrame exists', function () { + expect(global).to.respondTo('requestAnimFrame'); + }); +}); diff --git a/test/unit/pixi/InteractionManager.js b/test/unit/pixi/InteractionManager.js deleted file mode 100644 index ed3001f..0000000 --- a/test/unit/pixi/InteractionManager.js +++ /dev/null @@ -1,10 +0,0 @@ -describe('pixi/InteractionManager', function () { - 'use strict'; - - var expect = chai.expect; - var InteractionManager = PIXI.InteractionManager; - - it('Module exists', function () { - expect(InteractionManager).to.be.a('function'); - }); -}); diff --git a/test/unit/pixi-v2/InteractionManager.js b/test/unit/pixi-v2/InteractionManager.js new file mode 100644 index 0000000..ed3001f --- /dev/null +++ b/test/unit/pixi-v2/InteractionManager.js @@ -0,0 +1,10 @@ +describe('pixi/InteractionManager', function () { + 'use strict'; + + var expect = chai.expect; + var InteractionManager = PIXI.InteractionManager; + + it('Module exists', function () { + expect(InteractionManager).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/Pixi.js b/test/unit/pixi-v2/Pixi.js new file mode 100644 index 0000000..27debc1 --- /dev/null +++ b/test/unit/pixi-v2/Pixi.js @@ -0,0 +1,9 @@ +describe('pixi/Pixi', function () { + 'use strict'; + + var expect = chai.expect; + + it('Module exists', function () { + expect(global).to.have.property('PIXI').and.to.be.an('object'); + }); +}); diff --git a/test/unit/pixi-v2/core/Circle.js b/test/unit/pixi-v2/core/Circle.js new file mode 100644 index 0000000..fbcfa17 --- /dev/null +++ b/test/unit/pixi-v2/core/Circle.js @@ -0,0 +1,21 @@ +describe('pixi/core/Circle', function () { + 'use strict'; + + var expect = chai.expect; + var Circle = PIXI.Circle; + + it('Module exists', function () { + expect(Circle).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Circle(); + pixi_core_Circle_confirmNewCircle(obj); + }); + + it("getBounds should return Rectangle that bounds the circle", function() { + var obj = new Circle(100, 250, 50); + var bounds = obj.getBounds(); + pixi_core_Circle_isBoundedByRectangle(obj, bounds); + }); +}); diff --git a/test/unit/pixi-v2/core/Ellipse.js b/test/unit/pixi-v2/core/Ellipse.js new file mode 100644 index 0000000..026b56f --- /dev/null +++ b/test/unit/pixi-v2/core/Ellipse.js @@ -0,0 +1,24 @@ +describe('pixi/core/Ellipse', function () { + 'use strict'; + + var expect = chai.expect; + var Ellipse = PIXI.Ellipse; + + it('Module exists', function () { + expect(Ellipse).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Ellipse(); + + expect(obj).to.be.an.instanceof(Ellipse); + expect(obj).to.respondTo('clone'); + expect(obj).to.respondTo('contains'); + expect(obj).to.respondTo('getBounds'); + + expect(obj).to.have.property('x', 0); + expect(obj).to.have.property('y', 0); + expect(obj).to.have.property('width', 0); + expect(obj).to.have.property('height', 0); + }); +}); diff --git a/test/unit/pixi-v2/core/Matrix.js b/test/unit/pixi-v2/core/Matrix.js new file mode 100644 index 0000000..da75e2e --- /dev/null +++ b/test/unit/pixi-v2/core/Matrix.js @@ -0,0 +1,14 @@ +describe('pixi/core/Matrix', function () { + 'use strict'; + + var expect = chai.expect; + + it('Matrix exists', function () { + expect(PIXI.Matrix).to.be.an('function'); + }); + + it('Confirm new Matrix', function () { + var matrix = new PIXI.Matrix(); + pixi_core_Matrix_confirmNewMatrix(matrix); + }); +}); diff --git a/test/unit/pixi-v2/core/Point.js b/test/unit/pixi-v2/core/Point.js new file mode 100644 index 0000000..c4d5163 --- /dev/null +++ b/test/unit/pixi-v2/core/Point.js @@ -0,0 +1,15 @@ +describe('pixi/core/Point', function () { + 'use strict'; + + var expect = chai.expect; + var Point = PIXI.Point; + + it('Module exists', function () { + expect(Point).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Point(); + pixi_core_Point_confirm(obj, 0, 0); + }); +}); diff --git a/test/unit/pixi-v2/core/Polygon.js b/test/unit/pixi-v2/core/Polygon.js new file mode 100644 index 0000000..dc8c918 --- /dev/null +++ b/test/unit/pixi-v2/core/Polygon.js @@ -0,0 +1,20 @@ +describe('pixi/core/Polygon', function () { + 'use strict'; + + var expect = chai.expect; + var Polygon = PIXI.Polygon; + + it('Module exists', function () { + expect(Polygon).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Polygon(); + + expect(obj).to.be.an.instanceof(Polygon); + expect(obj).to.respondTo('clone'); + expect(obj).to.respondTo('contains'); + + expect(obj).to.have.deep.property('points.length', 0); + }); +}); diff --git a/test/unit/pixi-v2/core/Rectangle.js b/test/unit/pixi-v2/core/Rectangle.js new file mode 100644 index 0000000..d43316e --- /dev/null +++ b/test/unit/pixi-v2/core/Rectangle.js @@ -0,0 +1,15 @@ +describe('pixi/core/Rectangle', function () { + 'use strict'; + + var expect = chai.expect; + var Rectangle = PIXI.Rectangle; + + it('Module exists', function () { + expect(Rectangle).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var rect = new Rectangle(); + pixi_core_Rectangle_confirm(rect, 0, 0, 0, 0); + }); +}); diff --git a/test/unit/pixi-v2/display/DisplayObject.js b/test/unit/pixi-v2/display/DisplayObject.js new file mode 100644 index 0000000..044acf8 --- /dev/null +++ b/test/unit/pixi-v2/display/DisplayObject.js @@ -0,0 +1,21 @@ +describe('pixi/display/DisplayObject', function () { + 'use strict'; + + var expect = chai.expect; + var DisplayObject = PIXI.DisplayObject; + + it('Module exists', function () { + expect(DisplayObject).to.be.a('function'); + // expect(PIXI).to.have.property('visibleCount', 0); + }); + + it('Confirm new instance', function () { + var obj = new DisplayObject(); + + pixi_display_DisplayObject_confirmNew(obj); + expect(obj).to.have.property('hitArea', null); + expect(obj).to.have.property('interactive', false); + expect(obj).to.have.property('renderable', false); + expect(obj).to.have.property('stage', null); + }); +}); diff --git a/test/unit/pixi-v2/display/DisplayObjectContainer.js b/test/unit/pixi-v2/display/DisplayObjectContainer.js new file mode 100644 index 0000000..15a3376 --- /dev/null +++ b/test/unit/pixi-v2/display/DisplayObjectContainer.js @@ -0,0 +1,67 @@ +describe('pixi/display/DisplayObjectContainer', function () { + 'use strict'; + + var expect = chai.expect; + var DisplayObjectContainer = PIXI.DisplayObjectContainer; + + it('Module exists', function () { + expect(DisplayObjectContainer).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new DisplayObjectContainer(); + + pixi_display_DisplayObjectContainer_confirmNew(obj); + expect(obj).to.have.property('hitArea', null); + expect(obj).to.have.property('interactive', false); + expect(obj).to.have.property('renderable', false); + expect(obj).to.have.property('stage', null); + }); + + it('Gets child index', function() { + var container = new PIXI.DisplayObjectContainer(); + var children = []; + for (var i = 0; i < 10; i++) { + var child = new PIXI.DisplayObject(); + children.push(child); + container.addChild(child); + } + + for (i = 0; i < children.length; i++) { + expect(i).to.eql(container.getChildIndex(children[i])); + } + }); + + it('throws error when trying to get index of not a child', function() { + var container = new PIXI.DisplayObjectContainer(); + var child = new PIXI.DisplayObject(); + + expect(function() { container.getChildIndex(child); }).to.throw(); + }); + + it('Sets child index', function() { + var container = new PIXI.DisplayObjectContainer(); + var children = []; + + for (var i = 0; i < 10; i++) { + var child = new PIXI.DisplayObject(); + children.push(child); + container.addChild(child); + } + children.reverse(); + + for (i = 0; i < children.length; i++) { + container.setChildIndex(children[i], i); + expect(i).to.eql(container.getChildIndex(children[i])); + } + }); + + it('throws error when trying to set incorect index', function() { + var container = new PIXI.DisplayObjectContainer(); + var child = new PIXI.DisplayObject(); + container.addChild(child); + + expect(function() { container.setChildIndex(child, -1); }).to.throw(); + expect(function() { container.setChildIndex(child, 1); }).to.throw(); + }); +}); diff --git a/test/unit/pixi-v2/display/MovieClip.js b/test/unit/pixi-v2/display/MovieClip.js new file mode 100644 index 0000000..f3c6c6a --- /dev/null +++ b/test/unit/pixi-v2/display/MovieClip.js @@ -0,0 +1,33 @@ +describe('pixi/display/MovieClip', function () { + 'use strict'; + + var expect = chai.expect; + var MovieClip = PIXI.MovieClip; + var Texture = PIXI.Texture; + + it('Module exists', function () { + expect(MovieClip).to.be.a('function'); + }); + + it('Confirm new instance', function (done) { + var texture = Texture.fromImage('/base/test/textures/SpriteSheet-Explosion.png'); + var obj = new MovieClip([texture]); + + pixi_display_Sprite_confirmNew(obj, done); + + expect(obj).to.be.an.instanceof(MovieClip); + expect(obj).to.respondTo('stop'); + expect(obj).to.respondTo('play'); + expect(obj).to.respondTo('gotoAndStop'); + expect(obj).to.respondTo('gotoAndPlay'); + expect(obj).to.respondTo('updateTransform'); + + expect(obj).to.have.deep.property('textures.length', 1); + expect(obj).to.have.deep.property('textures[0]', texture); + expect(obj).to.have.property('animationSpeed', 1); + expect(obj).to.have.property('loop', true); + expect(obj).to.have.property('onComplete', null); + expect(obj).to.have.property('currentFrame', 0); + expect(obj).to.have.property('playing', false); + }); +}); diff --git a/test/unit/pixi-v2/display/Sprite.js b/test/unit/pixi-v2/display/Sprite.js new file mode 100644 index 0000000..30c8076 --- /dev/null +++ b/test/unit/pixi-v2/display/Sprite.js @@ -0,0 +1,28 @@ +describe('pixi/display/Sprite', function () { + 'use strict'; + + var expect = chai.expect; + var Sprite = PIXI.Sprite; + var Texture = PIXI.Texture; + + it('Module exists', function () { + expect(Sprite).to.be.a('function'); + expect(PIXI).to.have.deep.property('blendModes.NORMAL', 0); + expect(PIXI).to.have.deep.property('blendModes.ADD', 1); + expect(PIXI).to.have.deep.property('blendModes.MULTIPLY', 2); + expect(PIXI).to.have.deep.property('blendModes.SCREEN', 3); + }); + + + it('Members exist', function () { + expect(Sprite).itself.to.respondTo('fromImage'); + expect(Sprite).itself.to.respondTo('fromFrame'); + }); + + it('Confirm new instance', function (done) { + var texture = Texture.fromImage('/base/test/textures/SpriteSheet-Aliens.png'); + var obj = new Sprite(texture); + + pixi_display_Sprite_confirmNew(obj, done); + }); +}); diff --git a/test/unit/pixi-v2/display/Stage.js b/test/unit/pixi-v2/display/Stage.js new file mode 100644 index 0000000..6974c2e --- /dev/null +++ b/test/unit/pixi-v2/display/Stage.js @@ -0,0 +1,49 @@ +describe('pixi/display/Stage', function () { + 'use strict'; + + var expect = chai.expect; + var Stage = PIXI.Stage; + var InteractionManager = PIXI.InteractionManager; + var Rectangle = PIXI.Rectangle; + + it('Module exists', function () { + expect(Stage).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Stage(null, true); + + pixi_display_DisplayObjectContainer_confirmNew(obj); + + expect(obj).to.be.an.instanceof(Stage); + expect(obj).to.respondTo('updateTransform'); + expect(obj).to.respondTo('setBackgroundColor'); + expect(obj).to.respondTo('getMousePosition'); + // FIXME: duplicate member in DisplayObject + pixi_core_Matrix_confirmNewMatrix(obj.worldTransform); + // FIXME: convert arg to bool in constructor + expect(obj).to.have.property('interactive', true); + + expect(obj).to.have.property('interactionManager') + .and.to.be.an.instanceof(InteractionManager) + .and.to.have.property('stage', obj); + + expect(obj).to.have.property('dirty', true); + + expect(obj).to.have.property('stage', obj); + + expect(obj).to.have.property('hitArea') + .and.to.be.an.instanceof(Rectangle); + pixi_core_Rectangle_confirm(obj.hitArea, 0, 0, 100000, 100000); + + expect(obj).to.have.property('backgroundColor', 0x000000); + expect(obj).to.have.deep.property('backgroundColorSplit.length', 3); + expect(obj).to.have.deep.property('backgroundColorSplit[0]', 0); + expect(obj).to.have.deep.property('backgroundColorSplit[1]', 0); + expect(obj).to.have.deep.property('backgroundColorSplit[2]', 0); + expect(obj).to.have.property('backgroundColorString', '#000000'); + + + expect(obj).to.have.property('worldVisible', true); + }); +}); diff --git a/test/unit/pixi-v2/extras/Rope.js b/test/unit/pixi-v2/extras/Rope.js new file mode 100644 index 0000000..05885ac --- /dev/null +++ b/test/unit/pixi-v2/extras/Rope.js @@ -0,0 +1,31 @@ +describe('pixi/extras/Rope', function () { + 'use strict'; + + var expect = chai.expect; + var Rope = PIXI.Rope; + var Texture = PIXI.Texture; + var Point = PIXI.Point; + + it('Module exists', function () { + expect(Rope).to.be.a('function'); + }); + + it('Confirm new instance', function () { + + var texture = Texture.fromImage('/base/test/textures/bunny.png'); + + // TODO-Alvin + // Same as Strip + + // var obj = new Rope(texture, [new Point(), new Point(5, 10), new Point(10, 20)]); + + // pixi_extras_Strip_confirmNew(obj); + + // expect(obj).to.be.an.instanceof(Rope); + // expect(obj).to.respondTo('refresh'); + // expect(obj).to.respondTo('updateTransform'); + // expect(obj).to.respondTo('setTexture'); + + // TODO: Test properties + }); +}); diff --git a/test/unit/pixi-v2/extras/Spine.js b/test/unit/pixi-v2/extras/Spine.js new file mode 100644 index 0000000..0708bc0 --- /dev/null +++ b/test/unit/pixi-v2/extras/Spine.js @@ -0,0 +1,10 @@ +describe('pixi/extras/Spine', function () { + 'use strict'; + + var expect = chai.expect; + var Spine = PIXI.Spine; + + it('Module exists', function () { + expect(Spine).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/extras/Strip.js b/test/unit/pixi-v2/extras/Strip.js new file mode 100644 index 0000000..230af90 --- /dev/null +++ b/test/unit/pixi-v2/extras/Strip.js @@ -0,0 +1,26 @@ +describe('pixi/extras/Strip', function () { + 'use strict'; + + var expect = chai.expect; + var Strip = PIXI.Strip; + var Texture = PIXI.Texture; + + it('Module exists', function () { + expect(Strip).to.be.a('function'); + }); + + it('Confirm new instance', function () { + + + // TODO-Alvin + // We tweaked it to make it pass the tests, but the whole strip class needs + // to be re-coded + + var texture = Texture.fromImage('/base/test/textures/bunny.png'); + + // var obj = new Strip(texture, 20, 10000); + + + // pixi_extras_Strip_confirmNew(obj); + }); +}); diff --git a/test/unit/pixi-v2/extras/TilingSprite.js b/test/unit/pixi-v2/extras/TilingSprite.js new file mode 100644 index 0000000..56aea14 --- /dev/null +++ b/test/unit/pixi-v2/extras/TilingSprite.js @@ -0,0 +1,24 @@ +describe('pixi/extras/TilingSprite', function () { + 'use strict'; + + var expect = chai.expect; + var TilingSprite = PIXI.TilingSprite; + var Texture = PIXI.Texture; + + it('Module exists', function () { + expect(TilingSprite).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var texture = Texture.fromImage('/base/test/textures/bunny.png'); + var obj = new TilingSprite(texture, 6000, 12000); + + pixi_display_DisplayObjectContainer_confirmNew(obj); + + expect(obj).to.be.an.instanceof(TilingSprite); + expect(obj).to.respondTo('setTexture'); + expect(obj).to.respondTo('onTextureUpdate'); + + // TODO: Test properties + }); +}); diff --git a/test/unit/pixi-v2/filters/FilterBlock.js b/test/unit/pixi-v2/filters/FilterBlock.js new file mode 100644 index 0000000..870cec0 --- /dev/null +++ b/test/unit/pixi-v2/filters/FilterBlock.js @@ -0,0 +1,10 @@ +describe('pixi/filters/FilterBlock', function () { + 'use strict'; + + var expect = chai.expect; + var FilterBlock = PIXI.FilterBlock; + + it('Module exists', function () { + expect(FilterBlock).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/AssetLoader.js b/test/unit/pixi-v2/loaders/AssetLoader.js new file mode 100644 index 0000000..a0aa0b5 --- /dev/null +++ b/test/unit/pixi-v2/loaders/AssetLoader.js @@ -0,0 +1,10 @@ +describe('pixi/loaders/AssetLoader', function () { + 'use strict'; + + var expect = chai.expect; + var AssetLoader = PIXI.AssetLoader; + + it('Module exists', function () { + expect(AssetLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/BitmapFontLoader.js b/test/unit/pixi-v2/loaders/BitmapFontLoader.js new file mode 100644 index 0000000..046f018 --- /dev/null +++ b/test/unit/pixi-v2/loaders/BitmapFontLoader.js @@ -0,0 +1,9 @@ +describe('pixi/loaders/BitmapFontLoader', function () { + 'use strict'; + + var expect = chai.expect; + + it('Module exists', function () { + expect(PIXI.BitmapFontLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/ImageLoader.js b/test/unit/pixi-v2/loaders/ImageLoader.js new file mode 100644 index 0000000..8b1f556 --- /dev/null +++ b/test/unit/pixi-v2/loaders/ImageLoader.js @@ -0,0 +1,10 @@ +describe('pixi/loaders/ImageLoader', function () { + 'use strict'; + + var expect = chai.expect; + var ImageLoader = PIXI.ImageLoader; + + it('Module exists', function () { + expect(ImageLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/JsonLoader.js b/test/unit/pixi-v2/loaders/JsonLoader.js new file mode 100644 index 0000000..c577e83 --- /dev/null +++ b/test/unit/pixi-v2/loaders/JsonLoader.js @@ -0,0 +1,10 @@ +describe('pixi/loaders/JsonLoader', function () { + 'use strict'; + + var expect = chai.expect; + var JsonLoader = PIXI.JsonLoader; + + it('Module exists', function () { + expect(JsonLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/SpineLoader.js b/test/unit/pixi-v2/loaders/SpineLoader.js new file mode 100644 index 0000000..fdcc0b8 --- /dev/null +++ b/test/unit/pixi-v2/loaders/SpineLoader.js @@ -0,0 +1,10 @@ +describe('pixi/loaders/SpineLoader', function () { + 'use strict'; + + var expect = chai.expect; + var SpineLoader = PIXI.SpineLoader; + + it('Module exists', function () { + expect(SpineLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/SpriteSheetLoader.js b/test/unit/pixi-v2/loaders/SpriteSheetLoader.js new file mode 100644 index 0000000..57beb27 --- /dev/null +++ b/test/unit/pixi-v2/loaders/SpriteSheetLoader.js @@ -0,0 +1,10 @@ +describe('pixi/loaders/SpriteSheetLoader', function () { + 'use strict'; + + var expect = chai.expect; + var SpriteSheetLoader = PIXI.SpriteSheetLoader; + + it('Module exists', function () { + expect(SpriteSheetLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/primitives/Graphics.js b/test/unit/pixi-v2/primitives/Graphics.js new file mode 100644 index 0000000..f3849eb --- /dev/null +++ b/test/unit/pixi-v2/primitives/Graphics.js @@ -0,0 +1,44 @@ +describe('pixi/primitives/Graphics', function () { + 'use strict'; + + var expect = chai.expect; + var Graphics = PIXI.Graphics; + + it('Module exists', function () { + expect(Graphics).to.be.a('function'); + + expect(Graphics).itself.to.have.property('POLY', 0); + expect(Graphics).itself.to.have.property('RECT', 1); + expect(Graphics).itself.to.have.property('CIRC', 2); + expect(Graphics).itself.to.have.property('ELIP', 3); + expect(Graphics).itself.to.have.property('RREC', 4); + }); + + it('Confirm new instance', function () { + var obj = new Graphics(); + + pixi_display_DisplayObjectContainer_confirmNew(obj); + + expect(obj).to.be.an.instanceof(Graphics); + expect(obj).to.respondTo('lineStyle'); + expect(obj).to.respondTo('lineStyle'); + expect(obj).to.respondTo('moveTo'); + expect(obj).to.respondTo('lineTo'); + expect(obj).to.respondTo('beginFill'); + expect(obj).to.respondTo('endFill'); + expect(obj).to.respondTo('drawRect'); + // expect(obj).to.respondTo('drawRoundedRect'); + expect(obj).to.respondTo('drawCircle'); + expect(obj).to.respondTo('drawEllipse'); + expect(obj).to.respondTo('clear'); + + expect(obj).to.have.property('renderable', true); + expect(obj).to.have.property('fillAlpha', 1); + expect(obj).to.have.property('lineWidth', 0); + expect(obj).to.have.property('width', 0); + expect(obj).to.have.property('height', 0); + expect(obj).to.have.property('lineColor', 0); + expect(obj).to.have.deep.property('graphicsData.length', 0); + // expect(obj).to.have.deep.property('currentPath.points.length', 0); + }); +}); diff --git a/test/unit/pixi-v2/renderers/canvas/CanvasGraphics.js b/test/unit/pixi-v2/renderers/canvas/CanvasGraphics.js new file mode 100644 index 0000000..8f44472 --- /dev/null +++ b/test/unit/pixi-v2/renderers/canvas/CanvasGraphics.js @@ -0,0 +1,15 @@ +describe('renders/canvas/CanvasGraphics', function () { + 'use strict'; + + var expect = chai.expect; + var CanvasGraphics = PIXI.CanvasGraphics; + + it('Module exists', function () { + expect(CanvasGraphics).to.be.a('function'); + }); + + it('Members exist', function () { + expect(CanvasGraphics).itself.to.respondTo('renderGraphics'); + expect(CanvasGraphics).itself.to.respondTo('renderGraphicsMask'); + }); +}); diff --git a/test/unit/pixi-v2/renderers/canvas/CanvasRenderer.js b/test/unit/pixi-v2/renderers/canvas/CanvasRenderer.js new file mode 100644 index 0000000..1646444 --- /dev/null +++ b/test/unit/pixi-v2/renderers/canvas/CanvasRenderer.js @@ -0,0 +1,36 @@ +describe('renderers/canvas/CanvasRenderer', function () { + 'use strict'; + + var expect = chai.expect; + var CanvasRenderer = PIXI.CanvasRenderer; + + it('Module exists', function () { + expect(CanvasRenderer).to.be.a('function'); + }); + + describe('.autoResize', function () { + it('Should automatically resize view if enabled', function () { + var renderer = new CanvasRenderer(200, 200, { + autoResize: true + }); + + expect(renderer.view.style.width).to.equal('200px'); + }); + + it('Should not automatically resize view if disabled', function () { + var renderer = new CanvasRenderer(200, 200, { + autoResize: false + }); + + expect(renderer.view.style.width).to.equal(''); + }); + + it('Should not automatically resize view if not specified', function () { + var renderer = new CanvasRenderer(200, 200, { + resolution: 2 + }); + + expect(renderer.view.style.width).to.equal(''); + }); + }); +}); diff --git a/test/unit/pixi-v2/renderers/webgl/WebGLGraphics.js b/test/unit/pixi-v2/renderers/webgl/WebGLGraphics.js new file mode 100644 index 0000000..5867b28 --- /dev/null +++ b/test/unit/pixi-v2/renderers/webgl/WebGLGraphics.js @@ -0,0 +1,20 @@ +describe('renderers/wegbl/WebGLGraphics', function () { + 'use strict'; + + var expect = chai.expect; + var WebGLGraphics = PIXI.WebGLGraphics; + + it('Module exists', function () { + expect(WebGLGraphics).to.be.a('function'); + }); + + it('Members exist', function () { + expect(WebGLGraphics).itself.to.respondTo('renderGraphics'); + expect(WebGLGraphics).itself.to.respondTo('updateGraphics'); + expect(WebGLGraphics).itself.to.respondTo('buildRectangle'); + expect(WebGLGraphics).itself.to.respondTo('buildRoundedRectangle'); + expect(WebGLGraphics).itself.to.respondTo('buildCircle'); + expect(WebGLGraphics).itself.to.respondTo('buildLine'); + expect(WebGLGraphics).itself.to.respondTo('buildPoly'); + }); +}); diff --git a/test/unit/pixi-v2/renderers/webgl/WebGLRenderer.js b/test/unit/pixi-v2/renderers/webgl/WebGLRenderer.js new file mode 100644 index 0000000..1680a80 --- /dev/null +++ b/test/unit/pixi-v2/renderers/webgl/WebGLRenderer.js @@ -0,0 +1,49 @@ +describe('renderers/webgl/WebGLRenderer', function () { + 'use strict'; + + var expect = chai.expect; + var WebGLRenderer = PIXI.WebGLRenderer; + + it('Module exists', function () { + expect(WebGLRenderer).to.be.a('function'); + }); + + // Skip tests if WebGL is not available (WebGL not supported in Travis CI) + try { + var renderer = new WebGLRenderer(400, 300, {}); + renderer.destroy(); + } catch (error) { + return; + } + + it('Destroy renderer', function () { + var renderer = new WebGLRenderer(400, 300, {}); + renderer.destroy(); + }); + + describe('.autoResize', function () { + it('Should automatically resize view if enabled', function () { + var renderer = new WebGLRenderer(200, 200, { + autoResize: true + }); + + expect(renderer.view.style.width).to.equal('200px'); + }); + + it('Should not automatically resize view if disabled', function () { + var renderer = new WebGLRenderer(200, 200, { + autoResize: false + }); + + expect(renderer.view.style.width).to.equal(''); + }); + + it('Should not automatically resize view if not specified', function () { + var renderer = new WebGLRenderer(200, 200, { + resolution: 2 + }); + + expect(renderer.view.style.width).to.equal(''); + }); + }); +}); diff --git a/test/unit/pixi-v2/renderers/webgl/WebGLShaders.js b/test/unit/pixi-v2/renderers/webgl/WebGLShaders.js new file mode 100644 index 0000000..6e33e4f --- /dev/null +++ b/test/unit/pixi-v2/renderers/webgl/WebGLShaders.js @@ -0,0 +1,13 @@ +describe('renderers/webgl/WebGLShaders', function () { + 'use strict'; + + var expect = chai.expect; + + it('Module members exist', function () { + + expect(PIXI).to.respondTo('CompileVertexShader'); + expect(PIXI).to.respondTo('CompileFragmentShader'); + expect(PIXI).to.respondTo('_CompileShader'); + expect(PIXI).to.respondTo('compileProgram'); + }); +}); diff --git a/test/unit/pixi-v2/renderers/webgl/WebGLSpriteBatch.js b/test/unit/pixi-v2/renderers/webgl/WebGLSpriteBatch.js new file mode 100644 index 0000000..e662b63 --- /dev/null +++ b/test/unit/pixi-v2/renderers/webgl/WebGLSpriteBatch.js @@ -0,0 +1,10 @@ +describe('renderers/webgl/utils/WebGLSpriteBatch', function () { + 'use strict'; + + var expect = chai.expect; + var WebGLSpriteBatch = PIXI.WebGLSpriteBatch; + + it('Module exists', function () { + expect(WebGLSpriteBatch).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/text/BitmapText.js b/test/unit/pixi-v2/text/BitmapText.js new file mode 100644 index 0000000..9388e3d --- /dev/null +++ b/test/unit/pixi-v2/text/BitmapText.js @@ -0,0 +1,10 @@ +describe('pixi/text/BitmapText', function () { + 'use strict'; + + var expect = chai.expect; + var BitmapText = PIXI.BitmapText; + + it('Module exists', function () { + expect(BitmapText).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/text/Text.js b/test/unit/pixi-v2/text/Text.js new file mode 100644 index 0000000..9bc9ac5 --- /dev/null +++ b/test/unit/pixi-v2/text/Text.js @@ -0,0 +1,10 @@ +describe('pixi/text/Text', function () { + 'use strict'; + + var expect = chai.expect; + var Text = PIXI.Text; + + it('Module exists', function () { + expect(Text).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/textures/BaseTexture.js b/test/unit/pixi-v2/textures/BaseTexture.js new file mode 100644 index 0000000..502b724 --- /dev/null +++ b/test/unit/pixi-v2/textures/BaseTexture.js @@ -0,0 +1,11 @@ +describe('pixi/textures/BaseTexture', function () { + 'use strict'; + + var expect = chai.expect; + var BaseTexture = PIXI.BaseTexture; + + it('Module exists', function () { + expect(BaseTexture).to.be.a('function'); + expect(PIXI).to.have.property('BaseTextureCache').and.to.be.an('object'); + }); +}); diff --git a/test/unit/pixi-v2/textures/RenderTexture.js b/test/unit/pixi-v2/textures/RenderTexture.js new file mode 100644 index 0000000..96acdb4 --- /dev/null +++ b/test/unit/pixi-v2/textures/RenderTexture.js @@ -0,0 +1,15 @@ +describe('pixi/textures/RenderTexture', function () { + 'use strict'; + + var expect = chai.expect; + var RenderTexture = PIXI.RenderTexture; + + it('Module exists', function () { + expect(RenderTexture).to.be.a('function'); + }); + + it('Confirm new instance', function (done) { + var texture = new RenderTexture(100, 100, new PIXI.CanvasRenderer()); + pixi_textures_RenderTexture_confirmNew(texture, done); + }); +}); diff --git a/test/unit/pixi-v2/textures/Texture.js b/test/unit/pixi-v2/textures/Texture.js new file mode 100644 index 0000000..090f64d --- /dev/null +++ b/test/unit/pixi-v2/textures/Texture.js @@ -0,0 +1,26 @@ +describe('pixi/textures/Texture', function () { + 'use strict'; + + var expect = chai.expect; + var Texture = PIXI.Texture; + + it('Module exists', function () { + expect(Texture).to.be.a('function'); + expect(PIXI).to.have.property('TextureCache').and.to.be.an('object'); + }); + + it('Members exist', function () { + expect(Texture).itself.to.respondTo('fromImage'); + expect(Texture).itself.to.respondTo('fromFrame'); + expect(Texture).itself.to.respondTo('fromCanvas'); + expect(Texture).itself.to.respondTo('addTextureToCache'); + expect(Texture).itself.to.respondTo('removeTextureFromCache'); + + // expect(Texture).itself.to.have.deep.property('frameUpdates.length', 0); + }); + + it('Confirm new instance', function (done) { + var texture = Texture.fromImage('/base/test/textures/bunny.png'); + pixi_textures_Texture_confirmNew(texture, done); + }); +}); diff --git a/test/unit/pixi-v2/utils/Detector.js b/test/unit/pixi-v2/utils/Detector.js new file mode 100644 index 0000000..4cf6008 --- /dev/null +++ b/test/unit/pixi-v2/utils/Detector.js @@ -0,0 +1,10 @@ +describe('pixi/utils/Detector', function () { + 'use strict'; + + var expect = chai.expect; + var autoDetectRenderer = PIXI.autoDetectRenderer; + + it('Module exists', function () { + expect(autoDetectRenderer).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/utils/EventTarget.js b/test/unit/pixi-v2/utils/EventTarget.js new file mode 100644 index 0000000..1cfc3a4 --- /dev/null +++ b/test/unit/pixi-v2/utils/EventTarget.js @@ -0,0 +1,361 @@ +describe('pixi/utils/EventTarget', function () { + 'use strict'; + + var expect = chai.expect; + + var Clazz, PClazz, obj, pobj, obj2; + beforeEach(function () { + Clazz = function () {}; + PClazz = function () {}; + + PIXI.EventTarget.mixin(Clazz.prototype); + PIXI.EventTarget.mixin(PClazz.prototype); + + obj = new Clazz(); + obj2 = new Clazz(); + pobj = new PClazz(); + + obj.parent = pobj; + obj2.parent = obj; + }); + + it('Module exists', function () { + expect(PIXI.EventTarget).to.be.an('object'); + }); + + it('Confirm new instance', function () { + pixi_utils_EventTarget_confirm(obj); + }); + + it('simple on/emit case works', function () { + var myData = {}; + + obj.on('myevent', function (event) { + pixi_utils_EventTarget_Event_confirm(event, obj, myData); + }); + + obj.emit('myevent', myData); + }); + + it('simple once case works', function () { + var called = 0; + + obj.once('myevent', function() { called++; }); + + obj.emit('myevent'); + obj.emit('myevent'); + obj.emit('myevent'); + obj.emit('myevent'); + obj.emit('myevent'); + + expect(called).to.equal(1); + }); + + it('simple off case works', function (done) { + function onMyEvent() { + done(new Error('Event listener should not have been called')); + } + + obj.on('myevent', onMyEvent); + obj.off('myevent', onMyEvent); + obj.emit('myevent'); + + done(); + }); + + it('simple propagation case works', function (done) { + var myData = {}; + + pobj.on('myevent', function () { + done(); + }); + + obj.emit('myevent'); + }); + + it('simple stopPropagation case works', function (done) { + var myData = {}; + + pobj.on('myevent', function () { + done(new Error('Event listener should not have been called on the parent element')); + }); + + obj.on('myevent', function (evt) { + evt.stopPropagation(); + }); + + obj.emit('myevent'); + + done(); + }); + + it('simple stopImmediatePropagation case works', function (done) { + var myData = {}; + + pobj.on('myevent', function () { + done(new Error('Event listener should not have been called on the parent')); + }); + + obj.on('myevent', function (evt) { + evt.stopImmediatePropagation(); + }); + + obj.on('myevent', function () { + done(new Error('Event listener should not have been called on the second')); + }); + + obj.emit('myevent'); + + done(); + }); + + it('multiple dispatches work properly', function () { + var called = 0; + + function onMyEvent() { + called++; + } + + obj.on('myevent', onMyEvent); + obj.emit('myevent'); + obj.emit('myevent'); + obj.emit('myevent'); + obj.emit('myevent'); + + expect(called).to.equal(4); + }); + + it('multiple events work properly', function () { + var called = 0; + + function onMyEvent() { + called++; + } + + obj.on('myevent1', onMyEvent); + obj.on('myevent2', onMyEvent); + obj.on('myevent3', onMyEvent); + obj.emit('myevent1'); + obj.emit('myevent2'); + obj.emit('myevent3'); + + expect(called).to.equal(3); + }); + + it('multiple events one removed works properly', function () { + var called = 0; + + function onMyEvent() { + called++; + } + + obj.on('myevent1', onMyEvent); + obj.on('myevent2', onMyEvent); + obj.on('myevent3', onMyEvent); + + obj.emit('myevent1'); + obj.emit('myevent2'); + obj.emit('myevent3'); + + obj.off('myevent2', onMyEvent); + + obj.emit('myevent1'); + obj.emit('myevent2'); + obj.emit('myevent3'); + + expect(called).to.equal(5); + }); + + it('multiple handlers for one event with some removed', function () { + var called = 0; + + var onMyEvent = function () { + called++; + }, + onMyEvent2 = function () { + called++; + }; + + // add 2 handlers and confirm they both get called + obj.on('myevent', onMyEvent); + obj.on('myevent', onMyEvent); + obj.on('myevent', onMyEvent2); + obj.on('myevent', onMyEvent2); + + obj.emit('myevent'); + + expect(called).to.equal(4); + + // remove one of the handlers, emit again, then ensure 1 more call is made + obj.off('myevent', onMyEvent); + + obj.emit('myevent'); + + expect(called).to.equal(6); + }); + + it('calls to off without a handler do nothing', function () { + var called = 0; + + var onMyEvent = function () { + called++; + }; + + obj.on('myevent', onMyEvent); + obj.on('myevent', onMyEvent); + + obj.emit('myevent'); + + expect(called).to.equal(2); + + obj.off('myevent'); + + obj.emit('myevent'); + + expect(called).to.equal(4); + + obj.off('myevent', onMyEvent); + + obj.emit('myevent'); + + expect(called).to.equal(4); + }); + + it('handles multiple instances with the same prototype', function () { + var called = 0; + + function onMyEvent(e) { + called++; + } + + obj.on('myevent1', onMyEvent); + obj.on('myevent2', onMyEvent); + + obj2.istwo = true; + obj2.on('myevent1', onMyEvent); + obj2.on('myevent2', onMyEvent); + + obj.emit('myevent1'); + obj.emit('myevent2'); + obj2.emit('myevent1'); + obj2.emit('myevent2'); + + //we emit 4 times, but since obj2 is a child of obj the event should bubble + //up to obj and show up there as well. So the obj2.emit() calls each increment + //the counter twice. + expect(called).to.equal(6); + }); + + it('is backwards compatible with older .dispatchEvent({})', function () { + var called = 0, + data = { + some: 'thing', + hello: true + }; + + function onMyEvent(event) { + pixi_utils_EventTarget_Event_confirm(event, obj, data); + + called++; + } + + obj.on('myevent1', onMyEvent); + obj.on('myevent2', onMyEvent); + obj.on('myevent3', onMyEvent); + + data.type = 'myevent1'; + obj.emit(data); + + data.type = 'myevent2'; + obj.emit(data); + + data.type = 'myevent3'; + obj.emit(data); + + obj.off('myevent2', onMyEvent); + + data.type = 'myevent1'; + obj.emit(data); + + data.type = 'myevent2'; + obj.emit(data); + + data.type = 'myevent3'; + obj.emit(data); + + expect(called).to.equal(5); + }); + + it('is backwards compatible with older .call(this)', function () { + var Fn = function() { + PIXI.EventTarget.call(this); + }, + o = new Fn(); + + pixi_utils_EventTarget_confirm(o); + }); + + it('is backwards compatible with older .addEventListener("")', function () { + var called = 0, + data = { + some: 'thing', + hello: true + }; + + function onMyEvent(event) { + pixi_utils_EventTarget_Event_confirm(event, obj, data); + + called++; + } + + obj.addEventListener('myevent1', onMyEvent); + obj.addEventListener('myevent2', onMyEvent); + obj.addEventListener('myevent3', onMyEvent); + + data.type = 'myevent1'; + obj.emit(data); + + data.type = 'myevent2'; + obj.emit(data); + + data.type = 'myevent3'; + obj.emit(data); + + obj.off('myevent2', onMyEvent); + + data.type = 'myevent1'; + obj.emit(data); + + data.type = 'myevent2'; + obj.emit(data); + + data.type = 'myevent3'; + obj.emit(data); + + expect(called).to.equal(5); + }); + + it('event remove during emit call properly', function () { + var called = 0; + + function cb1() { + called++; + obj.off('myevent', cb1); + } + function cb2() { + called++; + obj.off('myevent', cb2); + } + function cb3() { + called++; + obj.off('myevent', cb3); + } + + obj.on('myevent', cb1); + obj.on('myevent', cb2); + obj.on('myevent', cb3); + obj.emit('myevent', ''); + + expect(called).to.equal(3); + }); +}); diff --git a/test/unit/pixi-v2/utils/Polyk.js b/test/unit/pixi-v2/utils/Polyk.js new file mode 100644 index 0000000..dfc7128 --- /dev/null +++ b/test/unit/pixi-v2/utils/Polyk.js @@ -0,0 +1,14 @@ +describe('pixi/utils/Polyk', function () { + 'use strict'; + + var expect = chai.expect; + var PolyK = PIXI.PolyK; + + it('Module exists', function () { + expect(PolyK).to.be.an('object'); + }); + + it('Members exist', function () { + expect(PolyK).to.respondTo('Triangulate'); + }); +}); diff --git a/test/unit/pixi-v2/utils/Utils.js b/test/unit/pixi-v2/utils/Utils.js new file mode 100644 index 0000000..c97b3c6 --- /dev/null +++ b/test/unit/pixi-v2/utils/Utils.js @@ -0,0 +1,17 @@ +describe('Utils', function () { + 'use strict'; + + var expect = chai.expect; + + it('requestAnimationFrame exists', function () { + expect(global).to.respondTo('requestAnimationFrame'); + }); + + it('cancelAnimationFrame exists', function () { + expect(global).to.respondTo('cancelAnimationFrame'); + }); + + it('requestAnimFrame exists', function () { + expect(global).to.respondTo('requestAnimFrame'); + }); +}); diff --git a/test/unit/pixi/InteractionManager.js b/test/unit/pixi/InteractionManager.js deleted file mode 100644 index ed3001f..0000000 --- a/test/unit/pixi/InteractionManager.js +++ /dev/null @@ -1,10 +0,0 @@ -describe('pixi/InteractionManager', function () { - 'use strict'; - - var expect = chai.expect; - var InteractionManager = PIXI.InteractionManager; - - it('Module exists', function () { - expect(InteractionManager).to.be.a('function'); - }); -}); diff --git a/test/unit/pixi/Pixi.js b/test/unit/pixi/Pixi.js deleted file mode 100644 index 27debc1..0000000 --- a/test/unit/pixi/Pixi.js +++ /dev/null @@ -1,9 +0,0 @@ -describe('pixi/Pixi', function () { - 'use strict'; - - var expect = chai.expect; - - it('Module exists', function () { - expect(global).to.have.property('PIXI').and.to.be.an('object'); - }); -}); diff --git a/test/unit/pixi-v2/InteractionManager.js b/test/unit/pixi-v2/InteractionManager.js new file mode 100644 index 0000000..ed3001f --- /dev/null +++ b/test/unit/pixi-v2/InteractionManager.js @@ -0,0 +1,10 @@ +describe('pixi/InteractionManager', function () { + 'use strict'; + + var expect = chai.expect; + var InteractionManager = PIXI.InteractionManager; + + it('Module exists', function () { + expect(InteractionManager).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/Pixi.js b/test/unit/pixi-v2/Pixi.js new file mode 100644 index 0000000..27debc1 --- /dev/null +++ b/test/unit/pixi-v2/Pixi.js @@ -0,0 +1,9 @@ +describe('pixi/Pixi', function () { + 'use strict'; + + var expect = chai.expect; + + it('Module exists', function () { + expect(global).to.have.property('PIXI').and.to.be.an('object'); + }); +}); diff --git a/test/unit/pixi-v2/core/Circle.js b/test/unit/pixi-v2/core/Circle.js new file mode 100644 index 0000000..fbcfa17 --- /dev/null +++ b/test/unit/pixi-v2/core/Circle.js @@ -0,0 +1,21 @@ +describe('pixi/core/Circle', function () { + 'use strict'; + + var expect = chai.expect; + var Circle = PIXI.Circle; + + it('Module exists', function () { + expect(Circle).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Circle(); + pixi_core_Circle_confirmNewCircle(obj); + }); + + it("getBounds should return Rectangle that bounds the circle", function() { + var obj = new Circle(100, 250, 50); + var bounds = obj.getBounds(); + pixi_core_Circle_isBoundedByRectangle(obj, bounds); + }); +}); diff --git a/test/unit/pixi-v2/core/Ellipse.js b/test/unit/pixi-v2/core/Ellipse.js new file mode 100644 index 0000000..026b56f --- /dev/null +++ b/test/unit/pixi-v2/core/Ellipse.js @@ -0,0 +1,24 @@ +describe('pixi/core/Ellipse', function () { + 'use strict'; + + var expect = chai.expect; + var Ellipse = PIXI.Ellipse; + + it('Module exists', function () { + expect(Ellipse).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Ellipse(); + + expect(obj).to.be.an.instanceof(Ellipse); + expect(obj).to.respondTo('clone'); + expect(obj).to.respondTo('contains'); + expect(obj).to.respondTo('getBounds'); + + expect(obj).to.have.property('x', 0); + expect(obj).to.have.property('y', 0); + expect(obj).to.have.property('width', 0); + expect(obj).to.have.property('height', 0); + }); +}); diff --git a/test/unit/pixi-v2/core/Matrix.js b/test/unit/pixi-v2/core/Matrix.js new file mode 100644 index 0000000..da75e2e --- /dev/null +++ b/test/unit/pixi-v2/core/Matrix.js @@ -0,0 +1,14 @@ +describe('pixi/core/Matrix', function () { + 'use strict'; + + var expect = chai.expect; + + it('Matrix exists', function () { + expect(PIXI.Matrix).to.be.an('function'); + }); + + it('Confirm new Matrix', function () { + var matrix = new PIXI.Matrix(); + pixi_core_Matrix_confirmNewMatrix(matrix); + }); +}); diff --git a/test/unit/pixi-v2/core/Point.js b/test/unit/pixi-v2/core/Point.js new file mode 100644 index 0000000..c4d5163 --- /dev/null +++ b/test/unit/pixi-v2/core/Point.js @@ -0,0 +1,15 @@ +describe('pixi/core/Point', function () { + 'use strict'; + + var expect = chai.expect; + var Point = PIXI.Point; + + it('Module exists', function () { + expect(Point).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Point(); + pixi_core_Point_confirm(obj, 0, 0); + }); +}); diff --git a/test/unit/pixi-v2/core/Polygon.js b/test/unit/pixi-v2/core/Polygon.js new file mode 100644 index 0000000..dc8c918 --- /dev/null +++ b/test/unit/pixi-v2/core/Polygon.js @@ -0,0 +1,20 @@ +describe('pixi/core/Polygon', function () { + 'use strict'; + + var expect = chai.expect; + var Polygon = PIXI.Polygon; + + it('Module exists', function () { + expect(Polygon).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Polygon(); + + expect(obj).to.be.an.instanceof(Polygon); + expect(obj).to.respondTo('clone'); + expect(obj).to.respondTo('contains'); + + expect(obj).to.have.deep.property('points.length', 0); + }); +}); diff --git a/test/unit/pixi-v2/core/Rectangle.js b/test/unit/pixi-v2/core/Rectangle.js new file mode 100644 index 0000000..d43316e --- /dev/null +++ b/test/unit/pixi-v2/core/Rectangle.js @@ -0,0 +1,15 @@ +describe('pixi/core/Rectangle', function () { + 'use strict'; + + var expect = chai.expect; + var Rectangle = PIXI.Rectangle; + + it('Module exists', function () { + expect(Rectangle).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var rect = new Rectangle(); + pixi_core_Rectangle_confirm(rect, 0, 0, 0, 0); + }); +}); diff --git a/test/unit/pixi-v2/display/DisplayObject.js b/test/unit/pixi-v2/display/DisplayObject.js new file mode 100644 index 0000000..044acf8 --- /dev/null +++ b/test/unit/pixi-v2/display/DisplayObject.js @@ -0,0 +1,21 @@ +describe('pixi/display/DisplayObject', function () { + 'use strict'; + + var expect = chai.expect; + var DisplayObject = PIXI.DisplayObject; + + it('Module exists', function () { + expect(DisplayObject).to.be.a('function'); + // expect(PIXI).to.have.property('visibleCount', 0); + }); + + it('Confirm new instance', function () { + var obj = new DisplayObject(); + + pixi_display_DisplayObject_confirmNew(obj); + expect(obj).to.have.property('hitArea', null); + expect(obj).to.have.property('interactive', false); + expect(obj).to.have.property('renderable', false); + expect(obj).to.have.property('stage', null); + }); +}); diff --git a/test/unit/pixi-v2/display/DisplayObjectContainer.js b/test/unit/pixi-v2/display/DisplayObjectContainer.js new file mode 100644 index 0000000..15a3376 --- /dev/null +++ b/test/unit/pixi-v2/display/DisplayObjectContainer.js @@ -0,0 +1,67 @@ +describe('pixi/display/DisplayObjectContainer', function () { + 'use strict'; + + var expect = chai.expect; + var DisplayObjectContainer = PIXI.DisplayObjectContainer; + + it('Module exists', function () { + expect(DisplayObjectContainer).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new DisplayObjectContainer(); + + pixi_display_DisplayObjectContainer_confirmNew(obj); + expect(obj).to.have.property('hitArea', null); + expect(obj).to.have.property('interactive', false); + expect(obj).to.have.property('renderable', false); + expect(obj).to.have.property('stage', null); + }); + + it('Gets child index', function() { + var container = new PIXI.DisplayObjectContainer(); + var children = []; + for (var i = 0; i < 10; i++) { + var child = new PIXI.DisplayObject(); + children.push(child); + container.addChild(child); + } + + for (i = 0; i < children.length; i++) { + expect(i).to.eql(container.getChildIndex(children[i])); + } + }); + + it('throws error when trying to get index of not a child', function() { + var container = new PIXI.DisplayObjectContainer(); + var child = new PIXI.DisplayObject(); + + expect(function() { container.getChildIndex(child); }).to.throw(); + }); + + it('Sets child index', function() { + var container = new PIXI.DisplayObjectContainer(); + var children = []; + + for (var i = 0; i < 10; i++) { + var child = new PIXI.DisplayObject(); + children.push(child); + container.addChild(child); + } + children.reverse(); + + for (i = 0; i < children.length; i++) { + container.setChildIndex(children[i], i); + expect(i).to.eql(container.getChildIndex(children[i])); + } + }); + + it('throws error when trying to set incorect index', function() { + var container = new PIXI.DisplayObjectContainer(); + var child = new PIXI.DisplayObject(); + container.addChild(child); + + expect(function() { container.setChildIndex(child, -1); }).to.throw(); + expect(function() { container.setChildIndex(child, 1); }).to.throw(); + }); +}); diff --git a/test/unit/pixi-v2/display/MovieClip.js b/test/unit/pixi-v2/display/MovieClip.js new file mode 100644 index 0000000..f3c6c6a --- /dev/null +++ b/test/unit/pixi-v2/display/MovieClip.js @@ -0,0 +1,33 @@ +describe('pixi/display/MovieClip', function () { + 'use strict'; + + var expect = chai.expect; + var MovieClip = PIXI.MovieClip; + var Texture = PIXI.Texture; + + it('Module exists', function () { + expect(MovieClip).to.be.a('function'); + }); + + it('Confirm new instance', function (done) { + var texture = Texture.fromImage('/base/test/textures/SpriteSheet-Explosion.png'); + var obj = new MovieClip([texture]); + + pixi_display_Sprite_confirmNew(obj, done); + + expect(obj).to.be.an.instanceof(MovieClip); + expect(obj).to.respondTo('stop'); + expect(obj).to.respondTo('play'); + expect(obj).to.respondTo('gotoAndStop'); + expect(obj).to.respondTo('gotoAndPlay'); + expect(obj).to.respondTo('updateTransform'); + + expect(obj).to.have.deep.property('textures.length', 1); + expect(obj).to.have.deep.property('textures[0]', texture); + expect(obj).to.have.property('animationSpeed', 1); + expect(obj).to.have.property('loop', true); + expect(obj).to.have.property('onComplete', null); + expect(obj).to.have.property('currentFrame', 0); + expect(obj).to.have.property('playing', false); + }); +}); diff --git a/test/unit/pixi-v2/display/Sprite.js b/test/unit/pixi-v2/display/Sprite.js new file mode 100644 index 0000000..30c8076 --- /dev/null +++ b/test/unit/pixi-v2/display/Sprite.js @@ -0,0 +1,28 @@ +describe('pixi/display/Sprite', function () { + 'use strict'; + + var expect = chai.expect; + var Sprite = PIXI.Sprite; + var Texture = PIXI.Texture; + + it('Module exists', function () { + expect(Sprite).to.be.a('function'); + expect(PIXI).to.have.deep.property('blendModes.NORMAL', 0); + expect(PIXI).to.have.deep.property('blendModes.ADD', 1); + expect(PIXI).to.have.deep.property('blendModes.MULTIPLY', 2); + expect(PIXI).to.have.deep.property('blendModes.SCREEN', 3); + }); + + + it('Members exist', function () { + expect(Sprite).itself.to.respondTo('fromImage'); + expect(Sprite).itself.to.respondTo('fromFrame'); + }); + + it('Confirm new instance', function (done) { + var texture = Texture.fromImage('/base/test/textures/SpriteSheet-Aliens.png'); + var obj = new Sprite(texture); + + pixi_display_Sprite_confirmNew(obj, done); + }); +}); diff --git a/test/unit/pixi-v2/display/Stage.js b/test/unit/pixi-v2/display/Stage.js new file mode 100644 index 0000000..6974c2e --- /dev/null +++ b/test/unit/pixi-v2/display/Stage.js @@ -0,0 +1,49 @@ +describe('pixi/display/Stage', function () { + 'use strict'; + + var expect = chai.expect; + var Stage = PIXI.Stage; + var InteractionManager = PIXI.InteractionManager; + var Rectangle = PIXI.Rectangle; + + it('Module exists', function () { + expect(Stage).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Stage(null, true); + + pixi_display_DisplayObjectContainer_confirmNew(obj); + + expect(obj).to.be.an.instanceof(Stage); + expect(obj).to.respondTo('updateTransform'); + expect(obj).to.respondTo('setBackgroundColor'); + expect(obj).to.respondTo('getMousePosition'); + // FIXME: duplicate member in DisplayObject + pixi_core_Matrix_confirmNewMatrix(obj.worldTransform); + // FIXME: convert arg to bool in constructor + expect(obj).to.have.property('interactive', true); + + expect(obj).to.have.property('interactionManager') + .and.to.be.an.instanceof(InteractionManager) + .and.to.have.property('stage', obj); + + expect(obj).to.have.property('dirty', true); + + expect(obj).to.have.property('stage', obj); + + expect(obj).to.have.property('hitArea') + .and.to.be.an.instanceof(Rectangle); + pixi_core_Rectangle_confirm(obj.hitArea, 0, 0, 100000, 100000); + + expect(obj).to.have.property('backgroundColor', 0x000000); + expect(obj).to.have.deep.property('backgroundColorSplit.length', 3); + expect(obj).to.have.deep.property('backgroundColorSplit[0]', 0); + expect(obj).to.have.deep.property('backgroundColorSplit[1]', 0); + expect(obj).to.have.deep.property('backgroundColorSplit[2]', 0); + expect(obj).to.have.property('backgroundColorString', '#000000'); + + + expect(obj).to.have.property('worldVisible', true); + }); +}); diff --git a/test/unit/pixi-v2/extras/Rope.js b/test/unit/pixi-v2/extras/Rope.js new file mode 100644 index 0000000..05885ac --- /dev/null +++ b/test/unit/pixi-v2/extras/Rope.js @@ -0,0 +1,31 @@ +describe('pixi/extras/Rope', function () { + 'use strict'; + + var expect = chai.expect; + var Rope = PIXI.Rope; + var Texture = PIXI.Texture; + var Point = PIXI.Point; + + it('Module exists', function () { + expect(Rope).to.be.a('function'); + }); + + it('Confirm new instance', function () { + + var texture = Texture.fromImage('/base/test/textures/bunny.png'); + + // TODO-Alvin + // Same as Strip + + // var obj = new Rope(texture, [new Point(), new Point(5, 10), new Point(10, 20)]); + + // pixi_extras_Strip_confirmNew(obj); + + // expect(obj).to.be.an.instanceof(Rope); + // expect(obj).to.respondTo('refresh'); + // expect(obj).to.respondTo('updateTransform'); + // expect(obj).to.respondTo('setTexture'); + + // TODO: Test properties + }); +}); diff --git a/test/unit/pixi-v2/extras/Spine.js b/test/unit/pixi-v2/extras/Spine.js new file mode 100644 index 0000000..0708bc0 --- /dev/null +++ b/test/unit/pixi-v2/extras/Spine.js @@ -0,0 +1,10 @@ +describe('pixi/extras/Spine', function () { + 'use strict'; + + var expect = chai.expect; + var Spine = PIXI.Spine; + + it('Module exists', function () { + expect(Spine).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/extras/Strip.js b/test/unit/pixi-v2/extras/Strip.js new file mode 100644 index 0000000..230af90 --- /dev/null +++ b/test/unit/pixi-v2/extras/Strip.js @@ -0,0 +1,26 @@ +describe('pixi/extras/Strip', function () { + 'use strict'; + + var expect = chai.expect; + var Strip = PIXI.Strip; + var Texture = PIXI.Texture; + + it('Module exists', function () { + expect(Strip).to.be.a('function'); + }); + + it('Confirm new instance', function () { + + + // TODO-Alvin + // We tweaked it to make it pass the tests, but the whole strip class needs + // to be re-coded + + var texture = Texture.fromImage('/base/test/textures/bunny.png'); + + // var obj = new Strip(texture, 20, 10000); + + + // pixi_extras_Strip_confirmNew(obj); + }); +}); diff --git a/test/unit/pixi-v2/extras/TilingSprite.js b/test/unit/pixi-v2/extras/TilingSprite.js new file mode 100644 index 0000000..56aea14 --- /dev/null +++ b/test/unit/pixi-v2/extras/TilingSprite.js @@ -0,0 +1,24 @@ +describe('pixi/extras/TilingSprite', function () { + 'use strict'; + + var expect = chai.expect; + var TilingSprite = PIXI.TilingSprite; + var Texture = PIXI.Texture; + + it('Module exists', function () { + expect(TilingSprite).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var texture = Texture.fromImage('/base/test/textures/bunny.png'); + var obj = new TilingSprite(texture, 6000, 12000); + + pixi_display_DisplayObjectContainer_confirmNew(obj); + + expect(obj).to.be.an.instanceof(TilingSprite); + expect(obj).to.respondTo('setTexture'); + expect(obj).to.respondTo('onTextureUpdate'); + + // TODO: Test properties + }); +}); diff --git a/test/unit/pixi-v2/filters/FilterBlock.js b/test/unit/pixi-v2/filters/FilterBlock.js new file mode 100644 index 0000000..870cec0 --- /dev/null +++ b/test/unit/pixi-v2/filters/FilterBlock.js @@ -0,0 +1,10 @@ +describe('pixi/filters/FilterBlock', function () { + 'use strict'; + + var expect = chai.expect; + var FilterBlock = PIXI.FilterBlock; + + it('Module exists', function () { + expect(FilterBlock).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/AssetLoader.js b/test/unit/pixi-v2/loaders/AssetLoader.js new file mode 100644 index 0000000..a0aa0b5 --- /dev/null +++ b/test/unit/pixi-v2/loaders/AssetLoader.js @@ -0,0 +1,10 @@ +describe('pixi/loaders/AssetLoader', function () { + 'use strict'; + + var expect = chai.expect; + var AssetLoader = PIXI.AssetLoader; + + it('Module exists', function () { + expect(AssetLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/BitmapFontLoader.js b/test/unit/pixi-v2/loaders/BitmapFontLoader.js new file mode 100644 index 0000000..046f018 --- /dev/null +++ b/test/unit/pixi-v2/loaders/BitmapFontLoader.js @@ -0,0 +1,9 @@ +describe('pixi/loaders/BitmapFontLoader', function () { + 'use strict'; + + var expect = chai.expect; + + it('Module exists', function () { + expect(PIXI.BitmapFontLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/ImageLoader.js b/test/unit/pixi-v2/loaders/ImageLoader.js new file mode 100644 index 0000000..8b1f556 --- /dev/null +++ b/test/unit/pixi-v2/loaders/ImageLoader.js @@ -0,0 +1,10 @@ +describe('pixi/loaders/ImageLoader', function () { + 'use strict'; + + var expect = chai.expect; + var ImageLoader = PIXI.ImageLoader; + + it('Module exists', function () { + expect(ImageLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/JsonLoader.js b/test/unit/pixi-v2/loaders/JsonLoader.js new file mode 100644 index 0000000..c577e83 --- /dev/null +++ b/test/unit/pixi-v2/loaders/JsonLoader.js @@ -0,0 +1,10 @@ +describe('pixi/loaders/JsonLoader', function () { + 'use strict'; + + var expect = chai.expect; + var JsonLoader = PIXI.JsonLoader; + + it('Module exists', function () { + expect(JsonLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/SpineLoader.js b/test/unit/pixi-v2/loaders/SpineLoader.js new file mode 100644 index 0000000..fdcc0b8 --- /dev/null +++ b/test/unit/pixi-v2/loaders/SpineLoader.js @@ -0,0 +1,10 @@ +describe('pixi/loaders/SpineLoader', function () { + 'use strict'; + + var expect = chai.expect; + var SpineLoader = PIXI.SpineLoader; + + it('Module exists', function () { + expect(SpineLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/SpriteSheetLoader.js b/test/unit/pixi-v2/loaders/SpriteSheetLoader.js new file mode 100644 index 0000000..57beb27 --- /dev/null +++ b/test/unit/pixi-v2/loaders/SpriteSheetLoader.js @@ -0,0 +1,10 @@ +describe('pixi/loaders/SpriteSheetLoader', function () { + 'use strict'; + + var expect = chai.expect; + var SpriteSheetLoader = PIXI.SpriteSheetLoader; + + it('Module exists', function () { + expect(SpriteSheetLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/primitives/Graphics.js b/test/unit/pixi-v2/primitives/Graphics.js new file mode 100644 index 0000000..f3849eb --- /dev/null +++ b/test/unit/pixi-v2/primitives/Graphics.js @@ -0,0 +1,44 @@ +describe('pixi/primitives/Graphics', function () { + 'use strict'; + + var expect = chai.expect; + var Graphics = PIXI.Graphics; + + it('Module exists', function () { + expect(Graphics).to.be.a('function'); + + expect(Graphics).itself.to.have.property('POLY', 0); + expect(Graphics).itself.to.have.property('RECT', 1); + expect(Graphics).itself.to.have.property('CIRC', 2); + expect(Graphics).itself.to.have.property('ELIP', 3); + expect(Graphics).itself.to.have.property('RREC', 4); + }); + + it('Confirm new instance', function () { + var obj = new Graphics(); + + pixi_display_DisplayObjectContainer_confirmNew(obj); + + expect(obj).to.be.an.instanceof(Graphics); + expect(obj).to.respondTo('lineStyle'); + expect(obj).to.respondTo('lineStyle'); + expect(obj).to.respondTo('moveTo'); + expect(obj).to.respondTo('lineTo'); + expect(obj).to.respondTo('beginFill'); + expect(obj).to.respondTo('endFill'); + expect(obj).to.respondTo('drawRect'); + // expect(obj).to.respondTo('drawRoundedRect'); + expect(obj).to.respondTo('drawCircle'); + expect(obj).to.respondTo('drawEllipse'); + expect(obj).to.respondTo('clear'); + + expect(obj).to.have.property('renderable', true); + expect(obj).to.have.property('fillAlpha', 1); + expect(obj).to.have.property('lineWidth', 0); + expect(obj).to.have.property('width', 0); + expect(obj).to.have.property('height', 0); + expect(obj).to.have.property('lineColor', 0); + expect(obj).to.have.deep.property('graphicsData.length', 0); + // expect(obj).to.have.deep.property('currentPath.points.length', 0); + }); +}); diff --git a/test/unit/pixi-v2/renderers/canvas/CanvasGraphics.js b/test/unit/pixi-v2/renderers/canvas/CanvasGraphics.js new file mode 100644 index 0000000..8f44472 --- /dev/null +++ b/test/unit/pixi-v2/renderers/canvas/CanvasGraphics.js @@ -0,0 +1,15 @@ +describe('renders/canvas/CanvasGraphics', function () { + 'use strict'; + + var expect = chai.expect; + var CanvasGraphics = PIXI.CanvasGraphics; + + it('Module exists', function () { + expect(CanvasGraphics).to.be.a('function'); + }); + + it('Members exist', function () { + expect(CanvasGraphics).itself.to.respondTo('renderGraphics'); + expect(CanvasGraphics).itself.to.respondTo('renderGraphicsMask'); + }); +}); diff --git a/test/unit/pixi-v2/renderers/canvas/CanvasRenderer.js b/test/unit/pixi-v2/renderers/canvas/CanvasRenderer.js new file mode 100644 index 0000000..1646444 --- /dev/null +++ b/test/unit/pixi-v2/renderers/canvas/CanvasRenderer.js @@ -0,0 +1,36 @@ +describe('renderers/canvas/CanvasRenderer', function () { + 'use strict'; + + var expect = chai.expect; + var CanvasRenderer = PIXI.CanvasRenderer; + + it('Module exists', function () { + expect(CanvasRenderer).to.be.a('function'); + }); + + describe('.autoResize', function () { + it('Should automatically resize view if enabled', function () { + var renderer = new CanvasRenderer(200, 200, { + autoResize: true + }); + + expect(renderer.view.style.width).to.equal('200px'); + }); + + it('Should not automatically resize view if disabled', function () { + var renderer = new CanvasRenderer(200, 200, { + autoResize: false + }); + + expect(renderer.view.style.width).to.equal(''); + }); + + it('Should not automatically resize view if not specified', function () { + var renderer = new CanvasRenderer(200, 200, { + resolution: 2 + }); + + expect(renderer.view.style.width).to.equal(''); + }); + }); +}); diff --git a/test/unit/pixi-v2/renderers/webgl/WebGLGraphics.js b/test/unit/pixi-v2/renderers/webgl/WebGLGraphics.js new file mode 100644 index 0000000..5867b28 --- /dev/null +++ b/test/unit/pixi-v2/renderers/webgl/WebGLGraphics.js @@ -0,0 +1,20 @@ +describe('renderers/wegbl/WebGLGraphics', function () { + 'use strict'; + + var expect = chai.expect; + var WebGLGraphics = PIXI.WebGLGraphics; + + it('Module exists', function () { + expect(WebGLGraphics).to.be.a('function'); + }); + + it('Members exist', function () { + expect(WebGLGraphics).itself.to.respondTo('renderGraphics'); + expect(WebGLGraphics).itself.to.respondTo('updateGraphics'); + expect(WebGLGraphics).itself.to.respondTo('buildRectangle'); + expect(WebGLGraphics).itself.to.respondTo('buildRoundedRectangle'); + expect(WebGLGraphics).itself.to.respondTo('buildCircle'); + expect(WebGLGraphics).itself.to.respondTo('buildLine'); + expect(WebGLGraphics).itself.to.respondTo('buildPoly'); + }); +}); diff --git a/test/unit/pixi-v2/renderers/webgl/WebGLRenderer.js b/test/unit/pixi-v2/renderers/webgl/WebGLRenderer.js new file mode 100644 index 0000000..1680a80 --- /dev/null +++ b/test/unit/pixi-v2/renderers/webgl/WebGLRenderer.js @@ -0,0 +1,49 @@ +describe('renderers/webgl/WebGLRenderer', function () { + 'use strict'; + + var expect = chai.expect; + var WebGLRenderer = PIXI.WebGLRenderer; + + it('Module exists', function () { + expect(WebGLRenderer).to.be.a('function'); + }); + + // Skip tests if WebGL is not available (WebGL not supported in Travis CI) + try { + var renderer = new WebGLRenderer(400, 300, {}); + renderer.destroy(); + } catch (error) { + return; + } + + it('Destroy renderer', function () { + var renderer = new WebGLRenderer(400, 300, {}); + renderer.destroy(); + }); + + describe('.autoResize', function () { + it('Should automatically resize view if enabled', function () { + var renderer = new WebGLRenderer(200, 200, { + autoResize: true + }); + + expect(renderer.view.style.width).to.equal('200px'); + }); + + it('Should not automatically resize view if disabled', function () { + var renderer = new WebGLRenderer(200, 200, { + autoResize: false + }); + + expect(renderer.view.style.width).to.equal(''); + }); + + it('Should not automatically resize view if not specified', function () { + var renderer = new WebGLRenderer(200, 200, { + resolution: 2 + }); + + expect(renderer.view.style.width).to.equal(''); + }); + }); +}); diff --git a/test/unit/pixi-v2/renderers/webgl/WebGLShaders.js b/test/unit/pixi-v2/renderers/webgl/WebGLShaders.js new file mode 100644 index 0000000..6e33e4f --- /dev/null +++ b/test/unit/pixi-v2/renderers/webgl/WebGLShaders.js @@ -0,0 +1,13 @@ +describe('renderers/webgl/WebGLShaders', function () { + 'use strict'; + + var expect = chai.expect; + + it('Module members exist', function () { + + expect(PIXI).to.respondTo('CompileVertexShader'); + expect(PIXI).to.respondTo('CompileFragmentShader'); + expect(PIXI).to.respondTo('_CompileShader'); + expect(PIXI).to.respondTo('compileProgram'); + }); +}); diff --git a/test/unit/pixi-v2/renderers/webgl/WebGLSpriteBatch.js b/test/unit/pixi-v2/renderers/webgl/WebGLSpriteBatch.js new file mode 100644 index 0000000..e662b63 --- /dev/null +++ b/test/unit/pixi-v2/renderers/webgl/WebGLSpriteBatch.js @@ -0,0 +1,10 @@ +describe('renderers/webgl/utils/WebGLSpriteBatch', function () { + 'use strict'; + + var expect = chai.expect; + var WebGLSpriteBatch = PIXI.WebGLSpriteBatch; + + it('Module exists', function () { + expect(WebGLSpriteBatch).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/text/BitmapText.js b/test/unit/pixi-v2/text/BitmapText.js new file mode 100644 index 0000000..9388e3d --- /dev/null +++ b/test/unit/pixi-v2/text/BitmapText.js @@ -0,0 +1,10 @@ +describe('pixi/text/BitmapText', function () { + 'use strict'; + + var expect = chai.expect; + var BitmapText = PIXI.BitmapText; + + it('Module exists', function () { + expect(BitmapText).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/text/Text.js b/test/unit/pixi-v2/text/Text.js new file mode 100644 index 0000000..9bc9ac5 --- /dev/null +++ b/test/unit/pixi-v2/text/Text.js @@ -0,0 +1,10 @@ +describe('pixi/text/Text', function () { + 'use strict'; + + var expect = chai.expect; + var Text = PIXI.Text; + + it('Module exists', function () { + expect(Text).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/textures/BaseTexture.js b/test/unit/pixi-v2/textures/BaseTexture.js new file mode 100644 index 0000000..502b724 --- /dev/null +++ b/test/unit/pixi-v2/textures/BaseTexture.js @@ -0,0 +1,11 @@ +describe('pixi/textures/BaseTexture', function () { + 'use strict'; + + var expect = chai.expect; + var BaseTexture = PIXI.BaseTexture; + + it('Module exists', function () { + expect(BaseTexture).to.be.a('function'); + expect(PIXI).to.have.property('BaseTextureCache').and.to.be.an('object'); + }); +}); diff --git a/test/unit/pixi-v2/textures/RenderTexture.js b/test/unit/pixi-v2/textures/RenderTexture.js new file mode 100644 index 0000000..96acdb4 --- /dev/null +++ b/test/unit/pixi-v2/textures/RenderTexture.js @@ -0,0 +1,15 @@ +describe('pixi/textures/RenderTexture', function () { + 'use strict'; + + var expect = chai.expect; + var RenderTexture = PIXI.RenderTexture; + + it('Module exists', function () { + expect(RenderTexture).to.be.a('function'); + }); + + it('Confirm new instance', function (done) { + var texture = new RenderTexture(100, 100, new PIXI.CanvasRenderer()); + pixi_textures_RenderTexture_confirmNew(texture, done); + }); +}); diff --git a/test/unit/pixi-v2/textures/Texture.js b/test/unit/pixi-v2/textures/Texture.js new file mode 100644 index 0000000..090f64d --- /dev/null +++ b/test/unit/pixi-v2/textures/Texture.js @@ -0,0 +1,26 @@ +describe('pixi/textures/Texture', function () { + 'use strict'; + + var expect = chai.expect; + var Texture = PIXI.Texture; + + it('Module exists', function () { + expect(Texture).to.be.a('function'); + expect(PIXI).to.have.property('TextureCache').and.to.be.an('object'); + }); + + it('Members exist', function () { + expect(Texture).itself.to.respondTo('fromImage'); + expect(Texture).itself.to.respondTo('fromFrame'); + expect(Texture).itself.to.respondTo('fromCanvas'); + expect(Texture).itself.to.respondTo('addTextureToCache'); + expect(Texture).itself.to.respondTo('removeTextureFromCache'); + + // expect(Texture).itself.to.have.deep.property('frameUpdates.length', 0); + }); + + it('Confirm new instance', function (done) { + var texture = Texture.fromImage('/base/test/textures/bunny.png'); + pixi_textures_Texture_confirmNew(texture, done); + }); +}); diff --git a/test/unit/pixi-v2/utils/Detector.js b/test/unit/pixi-v2/utils/Detector.js new file mode 100644 index 0000000..4cf6008 --- /dev/null +++ b/test/unit/pixi-v2/utils/Detector.js @@ -0,0 +1,10 @@ +describe('pixi/utils/Detector', function () { + 'use strict'; + + var expect = chai.expect; + var autoDetectRenderer = PIXI.autoDetectRenderer; + + it('Module exists', function () { + expect(autoDetectRenderer).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/utils/EventTarget.js b/test/unit/pixi-v2/utils/EventTarget.js new file mode 100644 index 0000000..1cfc3a4 --- /dev/null +++ b/test/unit/pixi-v2/utils/EventTarget.js @@ -0,0 +1,361 @@ +describe('pixi/utils/EventTarget', function () { + 'use strict'; + + var expect = chai.expect; + + var Clazz, PClazz, obj, pobj, obj2; + beforeEach(function () { + Clazz = function () {}; + PClazz = function () {}; + + PIXI.EventTarget.mixin(Clazz.prototype); + PIXI.EventTarget.mixin(PClazz.prototype); + + obj = new Clazz(); + obj2 = new Clazz(); + pobj = new PClazz(); + + obj.parent = pobj; + obj2.parent = obj; + }); + + it('Module exists', function () { + expect(PIXI.EventTarget).to.be.an('object'); + }); + + it('Confirm new instance', function () { + pixi_utils_EventTarget_confirm(obj); + }); + + it('simple on/emit case works', function () { + var myData = {}; + + obj.on('myevent', function (event) { + pixi_utils_EventTarget_Event_confirm(event, obj, myData); + }); + + obj.emit('myevent', myData); + }); + + it('simple once case works', function () { + var called = 0; + + obj.once('myevent', function() { called++; }); + + obj.emit('myevent'); + obj.emit('myevent'); + obj.emit('myevent'); + obj.emit('myevent'); + obj.emit('myevent'); + + expect(called).to.equal(1); + }); + + it('simple off case works', function (done) { + function onMyEvent() { + done(new Error('Event listener should not have been called')); + } + + obj.on('myevent', onMyEvent); + obj.off('myevent', onMyEvent); + obj.emit('myevent'); + + done(); + }); + + it('simple propagation case works', function (done) { + var myData = {}; + + pobj.on('myevent', function () { + done(); + }); + + obj.emit('myevent'); + }); + + it('simple stopPropagation case works', function (done) { + var myData = {}; + + pobj.on('myevent', function () { + done(new Error('Event listener should not have been called on the parent element')); + }); + + obj.on('myevent', function (evt) { + evt.stopPropagation(); + }); + + obj.emit('myevent'); + + done(); + }); + + it('simple stopImmediatePropagation case works', function (done) { + var myData = {}; + + pobj.on('myevent', function () { + done(new Error('Event listener should not have been called on the parent')); + }); + + obj.on('myevent', function (evt) { + evt.stopImmediatePropagation(); + }); + + obj.on('myevent', function () { + done(new Error('Event listener should not have been called on the second')); + }); + + obj.emit('myevent'); + + done(); + }); + + it('multiple dispatches work properly', function () { + var called = 0; + + function onMyEvent() { + called++; + } + + obj.on('myevent', onMyEvent); + obj.emit('myevent'); + obj.emit('myevent'); + obj.emit('myevent'); + obj.emit('myevent'); + + expect(called).to.equal(4); + }); + + it('multiple events work properly', function () { + var called = 0; + + function onMyEvent() { + called++; + } + + obj.on('myevent1', onMyEvent); + obj.on('myevent2', onMyEvent); + obj.on('myevent3', onMyEvent); + obj.emit('myevent1'); + obj.emit('myevent2'); + obj.emit('myevent3'); + + expect(called).to.equal(3); + }); + + it('multiple events one removed works properly', function () { + var called = 0; + + function onMyEvent() { + called++; + } + + obj.on('myevent1', onMyEvent); + obj.on('myevent2', onMyEvent); + obj.on('myevent3', onMyEvent); + + obj.emit('myevent1'); + obj.emit('myevent2'); + obj.emit('myevent3'); + + obj.off('myevent2', onMyEvent); + + obj.emit('myevent1'); + obj.emit('myevent2'); + obj.emit('myevent3'); + + expect(called).to.equal(5); + }); + + it('multiple handlers for one event with some removed', function () { + var called = 0; + + var onMyEvent = function () { + called++; + }, + onMyEvent2 = function () { + called++; + }; + + // add 2 handlers and confirm they both get called + obj.on('myevent', onMyEvent); + obj.on('myevent', onMyEvent); + obj.on('myevent', onMyEvent2); + obj.on('myevent', onMyEvent2); + + obj.emit('myevent'); + + expect(called).to.equal(4); + + // remove one of the handlers, emit again, then ensure 1 more call is made + obj.off('myevent', onMyEvent); + + obj.emit('myevent'); + + expect(called).to.equal(6); + }); + + it('calls to off without a handler do nothing', function () { + var called = 0; + + var onMyEvent = function () { + called++; + }; + + obj.on('myevent', onMyEvent); + obj.on('myevent', onMyEvent); + + obj.emit('myevent'); + + expect(called).to.equal(2); + + obj.off('myevent'); + + obj.emit('myevent'); + + expect(called).to.equal(4); + + obj.off('myevent', onMyEvent); + + obj.emit('myevent'); + + expect(called).to.equal(4); + }); + + it('handles multiple instances with the same prototype', function () { + var called = 0; + + function onMyEvent(e) { + called++; + } + + obj.on('myevent1', onMyEvent); + obj.on('myevent2', onMyEvent); + + obj2.istwo = true; + obj2.on('myevent1', onMyEvent); + obj2.on('myevent2', onMyEvent); + + obj.emit('myevent1'); + obj.emit('myevent2'); + obj2.emit('myevent1'); + obj2.emit('myevent2'); + + //we emit 4 times, but since obj2 is a child of obj the event should bubble + //up to obj and show up there as well. So the obj2.emit() calls each increment + //the counter twice. + expect(called).to.equal(6); + }); + + it('is backwards compatible with older .dispatchEvent({})', function () { + var called = 0, + data = { + some: 'thing', + hello: true + }; + + function onMyEvent(event) { + pixi_utils_EventTarget_Event_confirm(event, obj, data); + + called++; + } + + obj.on('myevent1', onMyEvent); + obj.on('myevent2', onMyEvent); + obj.on('myevent3', onMyEvent); + + data.type = 'myevent1'; + obj.emit(data); + + data.type = 'myevent2'; + obj.emit(data); + + data.type = 'myevent3'; + obj.emit(data); + + obj.off('myevent2', onMyEvent); + + data.type = 'myevent1'; + obj.emit(data); + + data.type = 'myevent2'; + obj.emit(data); + + data.type = 'myevent3'; + obj.emit(data); + + expect(called).to.equal(5); + }); + + it('is backwards compatible with older .call(this)', function () { + var Fn = function() { + PIXI.EventTarget.call(this); + }, + o = new Fn(); + + pixi_utils_EventTarget_confirm(o); + }); + + it('is backwards compatible with older .addEventListener("")', function () { + var called = 0, + data = { + some: 'thing', + hello: true + }; + + function onMyEvent(event) { + pixi_utils_EventTarget_Event_confirm(event, obj, data); + + called++; + } + + obj.addEventListener('myevent1', onMyEvent); + obj.addEventListener('myevent2', onMyEvent); + obj.addEventListener('myevent3', onMyEvent); + + data.type = 'myevent1'; + obj.emit(data); + + data.type = 'myevent2'; + obj.emit(data); + + data.type = 'myevent3'; + obj.emit(data); + + obj.off('myevent2', onMyEvent); + + data.type = 'myevent1'; + obj.emit(data); + + data.type = 'myevent2'; + obj.emit(data); + + data.type = 'myevent3'; + obj.emit(data); + + expect(called).to.equal(5); + }); + + it('event remove during emit call properly', function () { + var called = 0; + + function cb1() { + called++; + obj.off('myevent', cb1); + } + function cb2() { + called++; + obj.off('myevent', cb2); + } + function cb3() { + called++; + obj.off('myevent', cb3); + } + + obj.on('myevent', cb1); + obj.on('myevent', cb2); + obj.on('myevent', cb3); + obj.emit('myevent', ''); + + expect(called).to.equal(3); + }); +}); diff --git a/test/unit/pixi-v2/utils/Polyk.js b/test/unit/pixi-v2/utils/Polyk.js new file mode 100644 index 0000000..dfc7128 --- /dev/null +++ b/test/unit/pixi-v2/utils/Polyk.js @@ -0,0 +1,14 @@ +describe('pixi/utils/Polyk', function () { + 'use strict'; + + var expect = chai.expect; + var PolyK = PIXI.PolyK; + + it('Module exists', function () { + expect(PolyK).to.be.an('object'); + }); + + it('Members exist', function () { + expect(PolyK).to.respondTo('Triangulate'); + }); +}); diff --git a/test/unit/pixi-v2/utils/Utils.js b/test/unit/pixi-v2/utils/Utils.js new file mode 100644 index 0000000..c97b3c6 --- /dev/null +++ b/test/unit/pixi-v2/utils/Utils.js @@ -0,0 +1,17 @@ +describe('Utils', function () { + 'use strict'; + + var expect = chai.expect; + + it('requestAnimationFrame exists', function () { + expect(global).to.respondTo('requestAnimationFrame'); + }); + + it('cancelAnimationFrame exists', function () { + expect(global).to.respondTo('cancelAnimationFrame'); + }); + + it('requestAnimFrame exists', function () { + expect(global).to.respondTo('requestAnimFrame'); + }); +}); diff --git a/test/unit/pixi/InteractionManager.js b/test/unit/pixi/InteractionManager.js deleted file mode 100644 index ed3001f..0000000 --- a/test/unit/pixi/InteractionManager.js +++ /dev/null @@ -1,10 +0,0 @@ -describe('pixi/InteractionManager', function () { - 'use strict'; - - var expect = chai.expect; - var InteractionManager = PIXI.InteractionManager; - - it('Module exists', function () { - expect(InteractionManager).to.be.a('function'); - }); -}); diff --git a/test/unit/pixi/Pixi.js b/test/unit/pixi/Pixi.js deleted file mode 100644 index 27debc1..0000000 --- a/test/unit/pixi/Pixi.js +++ /dev/null @@ -1,9 +0,0 @@ -describe('pixi/Pixi', function () { - 'use strict'; - - var expect = chai.expect; - - it('Module exists', function () { - expect(global).to.have.property('PIXI').and.to.be.an('object'); - }); -}); diff --git a/test/unit/pixi/core/Circle.js b/test/unit/pixi/core/Circle.js deleted file mode 100644 index fbcfa17..0000000 --- a/test/unit/pixi/core/Circle.js +++ /dev/null @@ -1,21 +0,0 @@ -describe('pixi/core/Circle', function () { - 'use strict'; - - var expect = chai.expect; - var Circle = PIXI.Circle; - - it('Module exists', function () { - expect(Circle).to.be.a('function'); - }); - - it('Confirm new instance', function () { - var obj = new Circle(); - pixi_core_Circle_confirmNewCircle(obj); - }); - - it("getBounds should return Rectangle that bounds the circle", function() { - var obj = new Circle(100, 250, 50); - var bounds = obj.getBounds(); - pixi_core_Circle_isBoundedByRectangle(obj, bounds); - }); -}); diff --git a/test/unit/pixi-v2/InteractionManager.js b/test/unit/pixi-v2/InteractionManager.js new file mode 100644 index 0000000..ed3001f --- /dev/null +++ b/test/unit/pixi-v2/InteractionManager.js @@ -0,0 +1,10 @@ +describe('pixi/InteractionManager', function () { + 'use strict'; + + var expect = chai.expect; + var InteractionManager = PIXI.InteractionManager; + + it('Module exists', function () { + expect(InteractionManager).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/Pixi.js b/test/unit/pixi-v2/Pixi.js new file mode 100644 index 0000000..27debc1 --- /dev/null +++ b/test/unit/pixi-v2/Pixi.js @@ -0,0 +1,9 @@ +describe('pixi/Pixi', function () { + 'use strict'; + + var expect = chai.expect; + + it('Module exists', function () { + expect(global).to.have.property('PIXI').and.to.be.an('object'); + }); +}); diff --git a/test/unit/pixi-v2/core/Circle.js b/test/unit/pixi-v2/core/Circle.js new file mode 100644 index 0000000..fbcfa17 --- /dev/null +++ b/test/unit/pixi-v2/core/Circle.js @@ -0,0 +1,21 @@ +describe('pixi/core/Circle', function () { + 'use strict'; + + var expect = chai.expect; + var Circle = PIXI.Circle; + + it('Module exists', function () { + expect(Circle).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Circle(); + pixi_core_Circle_confirmNewCircle(obj); + }); + + it("getBounds should return Rectangle that bounds the circle", function() { + var obj = new Circle(100, 250, 50); + var bounds = obj.getBounds(); + pixi_core_Circle_isBoundedByRectangle(obj, bounds); + }); +}); diff --git a/test/unit/pixi-v2/core/Ellipse.js b/test/unit/pixi-v2/core/Ellipse.js new file mode 100644 index 0000000..026b56f --- /dev/null +++ b/test/unit/pixi-v2/core/Ellipse.js @@ -0,0 +1,24 @@ +describe('pixi/core/Ellipse', function () { + 'use strict'; + + var expect = chai.expect; + var Ellipse = PIXI.Ellipse; + + it('Module exists', function () { + expect(Ellipse).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Ellipse(); + + expect(obj).to.be.an.instanceof(Ellipse); + expect(obj).to.respondTo('clone'); + expect(obj).to.respondTo('contains'); + expect(obj).to.respondTo('getBounds'); + + expect(obj).to.have.property('x', 0); + expect(obj).to.have.property('y', 0); + expect(obj).to.have.property('width', 0); + expect(obj).to.have.property('height', 0); + }); +}); diff --git a/test/unit/pixi-v2/core/Matrix.js b/test/unit/pixi-v2/core/Matrix.js new file mode 100644 index 0000000..da75e2e --- /dev/null +++ b/test/unit/pixi-v2/core/Matrix.js @@ -0,0 +1,14 @@ +describe('pixi/core/Matrix', function () { + 'use strict'; + + var expect = chai.expect; + + it('Matrix exists', function () { + expect(PIXI.Matrix).to.be.an('function'); + }); + + it('Confirm new Matrix', function () { + var matrix = new PIXI.Matrix(); + pixi_core_Matrix_confirmNewMatrix(matrix); + }); +}); diff --git a/test/unit/pixi-v2/core/Point.js b/test/unit/pixi-v2/core/Point.js new file mode 100644 index 0000000..c4d5163 --- /dev/null +++ b/test/unit/pixi-v2/core/Point.js @@ -0,0 +1,15 @@ +describe('pixi/core/Point', function () { + 'use strict'; + + var expect = chai.expect; + var Point = PIXI.Point; + + it('Module exists', function () { + expect(Point).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Point(); + pixi_core_Point_confirm(obj, 0, 0); + }); +}); diff --git a/test/unit/pixi-v2/core/Polygon.js b/test/unit/pixi-v2/core/Polygon.js new file mode 100644 index 0000000..dc8c918 --- /dev/null +++ b/test/unit/pixi-v2/core/Polygon.js @@ -0,0 +1,20 @@ +describe('pixi/core/Polygon', function () { + 'use strict'; + + var expect = chai.expect; + var Polygon = PIXI.Polygon; + + it('Module exists', function () { + expect(Polygon).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Polygon(); + + expect(obj).to.be.an.instanceof(Polygon); + expect(obj).to.respondTo('clone'); + expect(obj).to.respondTo('contains'); + + expect(obj).to.have.deep.property('points.length', 0); + }); +}); diff --git a/test/unit/pixi-v2/core/Rectangle.js b/test/unit/pixi-v2/core/Rectangle.js new file mode 100644 index 0000000..d43316e --- /dev/null +++ b/test/unit/pixi-v2/core/Rectangle.js @@ -0,0 +1,15 @@ +describe('pixi/core/Rectangle', function () { + 'use strict'; + + var expect = chai.expect; + var Rectangle = PIXI.Rectangle; + + it('Module exists', function () { + expect(Rectangle).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var rect = new Rectangle(); + pixi_core_Rectangle_confirm(rect, 0, 0, 0, 0); + }); +}); diff --git a/test/unit/pixi-v2/display/DisplayObject.js b/test/unit/pixi-v2/display/DisplayObject.js new file mode 100644 index 0000000..044acf8 --- /dev/null +++ b/test/unit/pixi-v2/display/DisplayObject.js @@ -0,0 +1,21 @@ +describe('pixi/display/DisplayObject', function () { + 'use strict'; + + var expect = chai.expect; + var DisplayObject = PIXI.DisplayObject; + + it('Module exists', function () { + expect(DisplayObject).to.be.a('function'); + // expect(PIXI).to.have.property('visibleCount', 0); + }); + + it('Confirm new instance', function () { + var obj = new DisplayObject(); + + pixi_display_DisplayObject_confirmNew(obj); + expect(obj).to.have.property('hitArea', null); + expect(obj).to.have.property('interactive', false); + expect(obj).to.have.property('renderable', false); + expect(obj).to.have.property('stage', null); + }); +}); diff --git a/test/unit/pixi-v2/display/DisplayObjectContainer.js b/test/unit/pixi-v2/display/DisplayObjectContainer.js new file mode 100644 index 0000000..15a3376 --- /dev/null +++ b/test/unit/pixi-v2/display/DisplayObjectContainer.js @@ -0,0 +1,67 @@ +describe('pixi/display/DisplayObjectContainer', function () { + 'use strict'; + + var expect = chai.expect; + var DisplayObjectContainer = PIXI.DisplayObjectContainer; + + it('Module exists', function () { + expect(DisplayObjectContainer).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new DisplayObjectContainer(); + + pixi_display_DisplayObjectContainer_confirmNew(obj); + expect(obj).to.have.property('hitArea', null); + expect(obj).to.have.property('interactive', false); + expect(obj).to.have.property('renderable', false); + expect(obj).to.have.property('stage', null); + }); + + it('Gets child index', function() { + var container = new PIXI.DisplayObjectContainer(); + var children = []; + for (var i = 0; i < 10; i++) { + var child = new PIXI.DisplayObject(); + children.push(child); + container.addChild(child); + } + + for (i = 0; i < children.length; i++) { + expect(i).to.eql(container.getChildIndex(children[i])); + } + }); + + it('throws error when trying to get index of not a child', function() { + var container = new PIXI.DisplayObjectContainer(); + var child = new PIXI.DisplayObject(); + + expect(function() { container.getChildIndex(child); }).to.throw(); + }); + + it('Sets child index', function() { + var container = new PIXI.DisplayObjectContainer(); + var children = []; + + for (var i = 0; i < 10; i++) { + var child = new PIXI.DisplayObject(); + children.push(child); + container.addChild(child); + } + children.reverse(); + + for (i = 0; i < children.length; i++) { + container.setChildIndex(children[i], i); + expect(i).to.eql(container.getChildIndex(children[i])); + } + }); + + it('throws error when trying to set incorect index', function() { + var container = new PIXI.DisplayObjectContainer(); + var child = new PIXI.DisplayObject(); + container.addChild(child); + + expect(function() { container.setChildIndex(child, -1); }).to.throw(); + expect(function() { container.setChildIndex(child, 1); }).to.throw(); + }); +}); diff --git a/test/unit/pixi-v2/display/MovieClip.js b/test/unit/pixi-v2/display/MovieClip.js new file mode 100644 index 0000000..f3c6c6a --- /dev/null +++ b/test/unit/pixi-v2/display/MovieClip.js @@ -0,0 +1,33 @@ +describe('pixi/display/MovieClip', function () { + 'use strict'; + + var expect = chai.expect; + var MovieClip = PIXI.MovieClip; + var Texture = PIXI.Texture; + + it('Module exists', function () { + expect(MovieClip).to.be.a('function'); + }); + + it('Confirm new instance', function (done) { + var texture = Texture.fromImage('/base/test/textures/SpriteSheet-Explosion.png'); + var obj = new MovieClip([texture]); + + pixi_display_Sprite_confirmNew(obj, done); + + expect(obj).to.be.an.instanceof(MovieClip); + expect(obj).to.respondTo('stop'); + expect(obj).to.respondTo('play'); + expect(obj).to.respondTo('gotoAndStop'); + expect(obj).to.respondTo('gotoAndPlay'); + expect(obj).to.respondTo('updateTransform'); + + expect(obj).to.have.deep.property('textures.length', 1); + expect(obj).to.have.deep.property('textures[0]', texture); + expect(obj).to.have.property('animationSpeed', 1); + expect(obj).to.have.property('loop', true); + expect(obj).to.have.property('onComplete', null); + expect(obj).to.have.property('currentFrame', 0); + expect(obj).to.have.property('playing', false); + }); +}); diff --git a/test/unit/pixi-v2/display/Sprite.js b/test/unit/pixi-v2/display/Sprite.js new file mode 100644 index 0000000..30c8076 --- /dev/null +++ b/test/unit/pixi-v2/display/Sprite.js @@ -0,0 +1,28 @@ +describe('pixi/display/Sprite', function () { + 'use strict'; + + var expect = chai.expect; + var Sprite = PIXI.Sprite; + var Texture = PIXI.Texture; + + it('Module exists', function () { + expect(Sprite).to.be.a('function'); + expect(PIXI).to.have.deep.property('blendModes.NORMAL', 0); + expect(PIXI).to.have.deep.property('blendModes.ADD', 1); + expect(PIXI).to.have.deep.property('blendModes.MULTIPLY', 2); + expect(PIXI).to.have.deep.property('blendModes.SCREEN', 3); + }); + + + it('Members exist', function () { + expect(Sprite).itself.to.respondTo('fromImage'); + expect(Sprite).itself.to.respondTo('fromFrame'); + }); + + it('Confirm new instance', function (done) { + var texture = Texture.fromImage('/base/test/textures/SpriteSheet-Aliens.png'); + var obj = new Sprite(texture); + + pixi_display_Sprite_confirmNew(obj, done); + }); +}); diff --git a/test/unit/pixi-v2/display/Stage.js b/test/unit/pixi-v2/display/Stage.js new file mode 100644 index 0000000..6974c2e --- /dev/null +++ b/test/unit/pixi-v2/display/Stage.js @@ -0,0 +1,49 @@ +describe('pixi/display/Stage', function () { + 'use strict'; + + var expect = chai.expect; + var Stage = PIXI.Stage; + var InteractionManager = PIXI.InteractionManager; + var Rectangle = PIXI.Rectangle; + + it('Module exists', function () { + expect(Stage).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Stage(null, true); + + pixi_display_DisplayObjectContainer_confirmNew(obj); + + expect(obj).to.be.an.instanceof(Stage); + expect(obj).to.respondTo('updateTransform'); + expect(obj).to.respondTo('setBackgroundColor'); + expect(obj).to.respondTo('getMousePosition'); + // FIXME: duplicate member in DisplayObject + pixi_core_Matrix_confirmNewMatrix(obj.worldTransform); + // FIXME: convert arg to bool in constructor + expect(obj).to.have.property('interactive', true); + + expect(obj).to.have.property('interactionManager') + .and.to.be.an.instanceof(InteractionManager) + .and.to.have.property('stage', obj); + + expect(obj).to.have.property('dirty', true); + + expect(obj).to.have.property('stage', obj); + + expect(obj).to.have.property('hitArea') + .and.to.be.an.instanceof(Rectangle); + pixi_core_Rectangle_confirm(obj.hitArea, 0, 0, 100000, 100000); + + expect(obj).to.have.property('backgroundColor', 0x000000); + expect(obj).to.have.deep.property('backgroundColorSplit.length', 3); + expect(obj).to.have.deep.property('backgroundColorSplit[0]', 0); + expect(obj).to.have.deep.property('backgroundColorSplit[1]', 0); + expect(obj).to.have.deep.property('backgroundColorSplit[2]', 0); + expect(obj).to.have.property('backgroundColorString', '#000000'); + + + expect(obj).to.have.property('worldVisible', true); + }); +}); diff --git a/test/unit/pixi-v2/extras/Rope.js b/test/unit/pixi-v2/extras/Rope.js new file mode 100644 index 0000000..05885ac --- /dev/null +++ b/test/unit/pixi-v2/extras/Rope.js @@ -0,0 +1,31 @@ +describe('pixi/extras/Rope', function () { + 'use strict'; + + var expect = chai.expect; + var Rope = PIXI.Rope; + var Texture = PIXI.Texture; + var Point = PIXI.Point; + + it('Module exists', function () { + expect(Rope).to.be.a('function'); + }); + + it('Confirm new instance', function () { + + var texture = Texture.fromImage('/base/test/textures/bunny.png'); + + // TODO-Alvin + // Same as Strip + + // var obj = new Rope(texture, [new Point(), new Point(5, 10), new Point(10, 20)]); + + // pixi_extras_Strip_confirmNew(obj); + + // expect(obj).to.be.an.instanceof(Rope); + // expect(obj).to.respondTo('refresh'); + // expect(obj).to.respondTo('updateTransform'); + // expect(obj).to.respondTo('setTexture'); + + // TODO: Test properties + }); +}); diff --git a/test/unit/pixi-v2/extras/Spine.js b/test/unit/pixi-v2/extras/Spine.js new file mode 100644 index 0000000..0708bc0 --- /dev/null +++ b/test/unit/pixi-v2/extras/Spine.js @@ -0,0 +1,10 @@ +describe('pixi/extras/Spine', function () { + 'use strict'; + + var expect = chai.expect; + var Spine = PIXI.Spine; + + it('Module exists', function () { + expect(Spine).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/extras/Strip.js b/test/unit/pixi-v2/extras/Strip.js new file mode 100644 index 0000000..230af90 --- /dev/null +++ b/test/unit/pixi-v2/extras/Strip.js @@ -0,0 +1,26 @@ +describe('pixi/extras/Strip', function () { + 'use strict'; + + var expect = chai.expect; + var Strip = PIXI.Strip; + var Texture = PIXI.Texture; + + it('Module exists', function () { + expect(Strip).to.be.a('function'); + }); + + it('Confirm new instance', function () { + + + // TODO-Alvin + // We tweaked it to make it pass the tests, but the whole strip class needs + // to be re-coded + + var texture = Texture.fromImage('/base/test/textures/bunny.png'); + + // var obj = new Strip(texture, 20, 10000); + + + // pixi_extras_Strip_confirmNew(obj); + }); +}); diff --git a/test/unit/pixi-v2/extras/TilingSprite.js b/test/unit/pixi-v2/extras/TilingSprite.js new file mode 100644 index 0000000..56aea14 --- /dev/null +++ b/test/unit/pixi-v2/extras/TilingSprite.js @@ -0,0 +1,24 @@ +describe('pixi/extras/TilingSprite', function () { + 'use strict'; + + var expect = chai.expect; + var TilingSprite = PIXI.TilingSprite; + var Texture = PIXI.Texture; + + it('Module exists', function () { + expect(TilingSprite).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var texture = Texture.fromImage('/base/test/textures/bunny.png'); + var obj = new TilingSprite(texture, 6000, 12000); + + pixi_display_DisplayObjectContainer_confirmNew(obj); + + expect(obj).to.be.an.instanceof(TilingSprite); + expect(obj).to.respondTo('setTexture'); + expect(obj).to.respondTo('onTextureUpdate'); + + // TODO: Test properties + }); +}); diff --git a/test/unit/pixi-v2/filters/FilterBlock.js b/test/unit/pixi-v2/filters/FilterBlock.js new file mode 100644 index 0000000..870cec0 --- /dev/null +++ b/test/unit/pixi-v2/filters/FilterBlock.js @@ -0,0 +1,10 @@ +describe('pixi/filters/FilterBlock', function () { + 'use strict'; + + var expect = chai.expect; + var FilterBlock = PIXI.FilterBlock; + + it('Module exists', function () { + expect(FilterBlock).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/AssetLoader.js b/test/unit/pixi-v2/loaders/AssetLoader.js new file mode 100644 index 0000000..a0aa0b5 --- /dev/null +++ b/test/unit/pixi-v2/loaders/AssetLoader.js @@ -0,0 +1,10 @@ +describe('pixi/loaders/AssetLoader', function () { + 'use strict'; + + var expect = chai.expect; + var AssetLoader = PIXI.AssetLoader; + + it('Module exists', function () { + expect(AssetLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/BitmapFontLoader.js b/test/unit/pixi-v2/loaders/BitmapFontLoader.js new file mode 100644 index 0000000..046f018 --- /dev/null +++ b/test/unit/pixi-v2/loaders/BitmapFontLoader.js @@ -0,0 +1,9 @@ +describe('pixi/loaders/BitmapFontLoader', function () { + 'use strict'; + + var expect = chai.expect; + + it('Module exists', function () { + expect(PIXI.BitmapFontLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/ImageLoader.js b/test/unit/pixi-v2/loaders/ImageLoader.js new file mode 100644 index 0000000..8b1f556 --- /dev/null +++ b/test/unit/pixi-v2/loaders/ImageLoader.js @@ -0,0 +1,10 @@ +describe('pixi/loaders/ImageLoader', function () { + 'use strict'; + + var expect = chai.expect; + var ImageLoader = PIXI.ImageLoader; + + it('Module exists', function () { + expect(ImageLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/JsonLoader.js b/test/unit/pixi-v2/loaders/JsonLoader.js new file mode 100644 index 0000000..c577e83 --- /dev/null +++ b/test/unit/pixi-v2/loaders/JsonLoader.js @@ -0,0 +1,10 @@ +describe('pixi/loaders/JsonLoader', function () { + 'use strict'; + + var expect = chai.expect; + var JsonLoader = PIXI.JsonLoader; + + it('Module exists', function () { + expect(JsonLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/SpineLoader.js b/test/unit/pixi-v2/loaders/SpineLoader.js new file mode 100644 index 0000000..fdcc0b8 --- /dev/null +++ b/test/unit/pixi-v2/loaders/SpineLoader.js @@ -0,0 +1,10 @@ +describe('pixi/loaders/SpineLoader', function () { + 'use strict'; + + var expect = chai.expect; + var SpineLoader = PIXI.SpineLoader; + + it('Module exists', function () { + expect(SpineLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/SpriteSheetLoader.js b/test/unit/pixi-v2/loaders/SpriteSheetLoader.js new file mode 100644 index 0000000..57beb27 --- /dev/null +++ b/test/unit/pixi-v2/loaders/SpriteSheetLoader.js @@ -0,0 +1,10 @@ +describe('pixi/loaders/SpriteSheetLoader', function () { + 'use strict'; + + var expect = chai.expect; + var SpriteSheetLoader = PIXI.SpriteSheetLoader; + + it('Module exists', function () { + expect(SpriteSheetLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/primitives/Graphics.js b/test/unit/pixi-v2/primitives/Graphics.js new file mode 100644 index 0000000..f3849eb --- /dev/null +++ b/test/unit/pixi-v2/primitives/Graphics.js @@ -0,0 +1,44 @@ +describe('pixi/primitives/Graphics', function () { + 'use strict'; + + var expect = chai.expect; + var Graphics = PIXI.Graphics; + + it('Module exists', function () { + expect(Graphics).to.be.a('function'); + + expect(Graphics).itself.to.have.property('POLY', 0); + expect(Graphics).itself.to.have.property('RECT', 1); + expect(Graphics).itself.to.have.property('CIRC', 2); + expect(Graphics).itself.to.have.property('ELIP', 3); + expect(Graphics).itself.to.have.property('RREC', 4); + }); + + it('Confirm new instance', function () { + var obj = new Graphics(); + + pixi_display_DisplayObjectContainer_confirmNew(obj); + + expect(obj).to.be.an.instanceof(Graphics); + expect(obj).to.respondTo('lineStyle'); + expect(obj).to.respondTo('lineStyle'); + expect(obj).to.respondTo('moveTo'); + expect(obj).to.respondTo('lineTo'); + expect(obj).to.respondTo('beginFill'); + expect(obj).to.respondTo('endFill'); + expect(obj).to.respondTo('drawRect'); + // expect(obj).to.respondTo('drawRoundedRect'); + expect(obj).to.respondTo('drawCircle'); + expect(obj).to.respondTo('drawEllipse'); + expect(obj).to.respondTo('clear'); + + expect(obj).to.have.property('renderable', true); + expect(obj).to.have.property('fillAlpha', 1); + expect(obj).to.have.property('lineWidth', 0); + expect(obj).to.have.property('width', 0); + expect(obj).to.have.property('height', 0); + expect(obj).to.have.property('lineColor', 0); + expect(obj).to.have.deep.property('graphicsData.length', 0); + // expect(obj).to.have.deep.property('currentPath.points.length', 0); + }); +}); diff --git a/test/unit/pixi-v2/renderers/canvas/CanvasGraphics.js b/test/unit/pixi-v2/renderers/canvas/CanvasGraphics.js new file mode 100644 index 0000000..8f44472 --- /dev/null +++ b/test/unit/pixi-v2/renderers/canvas/CanvasGraphics.js @@ -0,0 +1,15 @@ +describe('renders/canvas/CanvasGraphics', function () { + 'use strict'; + + var expect = chai.expect; + var CanvasGraphics = PIXI.CanvasGraphics; + + it('Module exists', function () { + expect(CanvasGraphics).to.be.a('function'); + }); + + it('Members exist', function () { + expect(CanvasGraphics).itself.to.respondTo('renderGraphics'); + expect(CanvasGraphics).itself.to.respondTo('renderGraphicsMask'); + }); +}); diff --git a/test/unit/pixi-v2/renderers/canvas/CanvasRenderer.js b/test/unit/pixi-v2/renderers/canvas/CanvasRenderer.js new file mode 100644 index 0000000..1646444 --- /dev/null +++ b/test/unit/pixi-v2/renderers/canvas/CanvasRenderer.js @@ -0,0 +1,36 @@ +describe('renderers/canvas/CanvasRenderer', function () { + 'use strict'; + + var expect = chai.expect; + var CanvasRenderer = PIXI.CanvasRenderer; + + it('Module exists', function () { + expect(CanvasRenderer).to.be.a('function'); + }); + + describe('.autoResize', function () { + it('Should automatically resize view if enabled', function () { + var renderer = new CanvasRenderer(200, 200, { + autoResize: true + }); + + expect(renderer.view.style.width).to.equal('200px'); + }); + + it('Should not automatically resize view if disabled', function () { + var renderer = new CanvasRenderer(200, 200, { + autoResize: false + }); + + expect(renderer.view.style.width).to.equal(''); + }); + + it('Should not automatically resize view if not specified', function () { + var renderer = new CanvasRenderer(200, 200, { + resolution: 2 + }); + + expect(renderer.view.style.width).to.equal(''); + }); + }); +}); diff --git a/test/unit/pixi-v2/renderers/webgl/WebGLGraphics.js b/test/unit/pixi-v2/renderers/webgl/WebGLGraphics.js new file mode 100644 index 0000000..5867b28 --- /dev/null +++ b/test/unit/pixi-v2/renderers/webgl/WebGLGraphics.js @@ -0,0 +1,20 @@ +describe('renderers/wegbl/WebGLGraphics', function () { + 'use strict'; + + var expect = chai.expect; + var WebGLGraphics = PIXI.WebGLGraphics; + + it('Module exists', function () { + expect(WebGLGraphics).to.be.a('function'); + }); + + it('Members exist', function () { + expect(WebGLGraphics).itself.to.respondTo('renderGraphics'); + expect(WebGLGraphics).itself.to.respondTo('updateGraphics'); + expect(WebGLGraphics).itself.to.respondTo('buildRectangle'); + expect(WebGLGraphics).itself.to.respondTo('buildRoundedRectangle'); + expect(WebGLGraphics).itself.to.respondTo('buildCircle'); + expect(WebGLGraphics).itself.to.respondTo('buildLine'); + expect(WebGLGraphics).itself.to.respondTo('buildPoly'); + }); +}); diff --git a/test/unit/pixi-v2/renderers/webgl/WebGLRenderer.js b/test/unit/pixi-v2/renderers/webgl/WebGLRenderer.js new file mode 100644 index 0000000..1680a80 --- /dev/null +++ b/test/unit/pixi-v2/renderers/webgl/WebGLRenderer.js @@ -0,0 +1,49 @@ +describe('renderers/webgl/WebGLRenderer', function () { + 'use strict'; + + var expect = chai.expect; + var WebGLRenderer = PIXI.WebGLRenderer; + + it('Module exists', function () { + expect(WebGLRenderer).to.be.a('function'); + }); + + // Skip tests if WebGL is not available (WebGL not supported in Travis CI) + try { + var renderer = new WebGLRenderer(400, 300, {}); + renderer.destroy(); + } catch (error) { + return; + } + + it('Destroy renderer', function () { + var renderer = new WebGLRenderer(400, 300, {}); + renderer.destroy(); + }); + + describe('.autoResize', function () { + it('Should automatically resize view if enabled', function () { + var renderer = new WebGLRenderer(200, 200, { + autoResize: true + }); + + expect(renderer.view.style.width).to.equal('200px'); + }); + + it('Should not automatically resize view if disabled', function () { + var renderer = new WebGLRenderer(200, 200, { + autoResize: false + }); + + expect(renderer.view.style.width).to.equal(''); + }); + + it('Should not automatically resize view if not specified', function () { + var renderer = new WebGLRenderer(200, 200, { + resolution: 2 + }); + + expect(renderer.view.style.width).to.equal(''); + }); + }); +}); diff --git a/test/unit/pixi-v2/renderers/webgl/WebGLShaders.js b/test/unit/pixi-v2/renderers/webgl/WebGLShaders.js new file mode 100644 index 0000000..6e33e4f --- /dev/null +++ b/test/unit/pixi-v2/renderers/webgl/WebGLShaders.js @@ -0,0 +1,13 @@ +describe('renderers/webgl/WebGLShaders', function () { + 'use strict'; + + var expect = chai.expect; + + it('Module members exist', function () { + + expect(PIXI).to.respondTo('CompileVertexShader'); + expect(PIXI).to.respondTo('CompileFragmentShader'); + expect(PIXI).to.respondTo('_CompileShader'); + expect(PIXI).to.respondTo('compileProgram'); + }); +}); diff --git a/test/unit/pixi-v2/renderers/webgl/WebGLSpriteBatch.js b/test/unit/pixi-v2/renderers/webgl/WebGLSpriteBatch.js new file mode 100644 index 0000000..e662b63 --- /dev/null +++ b/test/unit/pixi-v2/renderers/webgl/WebGLSpriteBatch.js @@ -0,0 +1,10 @@ +describe('renderers/webgl/utils/WebGLSpriteBatch', function () { + 'use strict'; + + var expect = chai.expect; + var WebGLSpriteBatch = PIXI.WebGLSpriteBatch; + + it('Module exists', function () { + expect(WebGLSpriteBatch).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/text/BitmapText.js b/test/unit/pixi-v2/text/BitmapText.js new file mode 100644 index 0000000..9388e3d --- /dev/null +++ b/test/unit/pixi-v2/text/BitmapText.js @@ -0,0 +1,10 @@ +describe('pixi/text/BitmapText', function () { + 'use strict'; + + var expect = chai.expect; + var BitmapText = PIXI.BitmapText; + + it('Module exists', function () { + expect(BitmapText).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/text/Text.js b/test/unit/pixi-v2/text/Text.js new file mode 100644 index 0000000..9bc9ac5 --- /dev/null +++ b/test/unit/pixi-v2/text/Text.js @@ -0,0 +1,10 @@ +describe('pixi/text/Text', function () { + 'use strict'; + + var expect = chai.expect; + var Text = PIXI.Text; + + it('Module exists', function () { + expect(Text).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/textures/BaseTexture.js b/test/unit/pixi-v2/textures/BaseTexture.js new file mode 100644 index 0000000..502b724 --- /dev/null +++ b/test/unit/pixi-v2/textures/BaseTexture.js @@ -0,0 +1,11 @@ +describe('pixi/textures/BaseTexture', function () { + 'use strict'; + + var expect = chai.expect; + var BaseTexture = PIXI.BaseTexture; + + it('Module exists', function () { + expect(BaseTexture).to.be.a('function'); + expect(PIXI).to.have.property('BaseTextureCache').and.to.be.an('object'); + }); +}); diff --git a/test/unit/pixi-v2/textures/RenderTexture.js b/test/unit/pixi-v2/textures/RenderTexture.js new file mode 100644 index 0000000..96acdb4 --- /dev/null +++ b/test/unit/pixi-v2/textures/RenderTexture.js @@ -0,0 +1,15 @@ +describe('pixi/textures/RenderTexture', function () { + 'use strict'; + + var expect = chai.expect; + var RenderTexture = PIXI.RenderTexture; + + it('Module exists', function () { + expect(RenderTexture).to.be.a('function'); + }); + + it('Confirm new instance', function (done) { + var texture = new RenderTexture(100, 100, new PIXI.CanvasRenderer()); + pixi_textures_RenderTexture_confirmNew(texture, done); + }); +}); diff --git a/test/unit/pixi-v2/textures/Texture.js b/test/unit/pixi-v2/textures/Texture.js new file mode 100644 index 0000000..090f64d --- /dev/null +++ b/test/unit/pixi-v2/textures/Texture.js @@ -0,0 +1,26 @@ +describe('pixi/textures/Texture', function () { + 'use strict'; + + var expect = chai.expect; + var Texture = PIXI.Texture; + + it('Module exists', function () { + expect(Texture).to.be.a('function'); + expect(PIXI).to.have.property('TextureCache').and.to.be.an('object'); + }); + + it('Members exist', function () { + expect(Texture).itself.to.respondTo('fromImage'); + expect(Texture).itself.to.respondTo('fromFrame'); + expect(Texture).itself.to.respondTo('fromCanvas'); + expect(Texture).itself.to.respondTo('addTextureToCache'); + expect(Texture).itself.to.respondTo('removeTextureFromCache'); + + // expect(Texture).itself.to.have.deep.property('frameUpdates.length', 0); + }); + + it('Confirm new instance', function (done) { + var texture = Texture.fromImage('/base/test/textures/bunny.png'); + pixi_textures_Texture_confirmNew(texture, done); + }); +}); diff --git a/test/unit/pixi-v2/utils/Detector.js b/test/unit/pixi-v2/utils/Detector.js new file mode 100644 index 0000000..4cf6008 --- /dev/null +++ b/test/unit/pixi-v2/utils/Detector.js @@ -0,0 +1,10 @@ +describe('pixi/utils/Detector', function () { + 'use strict'; + + var expect = chai.expect; + var autoDetectRenderer = PIXI.autoDetectRenderer; + + it('Module exists', function () { + expect(autoDetectRenderer).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/utils/EventTarget.js b/test/unit/pixi-v2/utils/EventTarget.js new file mode 100644 index 0000000..1cfc3a4 --- /dev/null +++ b/test/unit/pixi-v2/utils/EventTarget.js @@ -0,0 +1,361 @@ +describe('pixi/utils/EventTarget', function () { + 'use strict'; + + var expect = chai.expect; + + var Clazz, PClazz, obj, pobj, obj2; + beforeEach(function () { + Clazz = function () {}; + PClazz = function () {}; + + PIXI.EventTarget.mixin(Clazz.prototype); + PIXI.EventTarget.mixin(PClazz.prototype); + + obj = new Clazz(); + obj2 = new Clazz(); + pobj = new PClazz(); + + obj.parent = pobj; + obj2.parent = obj; + }); + + it('Module exists', function () { + expect(PIXI.EventTarget).to.be.an('object'); + }); + + it('Confirm new instance', function () { + pixi_utils_EventTarget_confirm(obj); + }); + + it('simple on/emit case works', function () { + var myData = {}; + + obj.on('myevent', function (event) { + pixi_utils_EventTarget_Event_confirm(event, obj, myData); + }); + + obj.emit('myevent', myData); + }); + + it('simple once case works', function () { + var called = 0; + + obj.once('myevent', function() { called++; }); + + obj.emit('myevent'); + obj.emit('myevent'); + obj.emit('myevent'); + obj.emit('myevent'); + obj.emit('myevent'); + + expect(called).to.equal(1); + }); + + it('simple off case works', function (done) { + function onMyEvent() { + done(new Error('Event listener should not have been called')); + } + + obj.on('myevent', onMyEvent); + obj.off('myevent', onMyEvent); + obj.emit('myevent'); + + done(); + }); + + it('simple propagation case works', function (done) { + var myData = {}; + + pobj.on('myevent', function () { + done(); + }); + + obj.emit('myevent'); + }); + + it('simple stopPropagation case works', function (done) { + var myData = {}; + + pobj.on('myevent', function () { + done(new Error('Event listener should not have been called on the parent element')); + }); + + obj.on('myevent', function (evt) { + evt.stopPropagation(); + }); + + obj.emit('myevent'); + + done(); + }); + + it('simple stopImmediatePropagation case works', function (done) { + var myData = {}; + + pobj.on('myevent', function () { + done(new Error('Event listener should not have been called on the parent')); + }); + + obj.on('myevent', function (evt) { + evt.stopImmediatePropagation(); + }); + + obj.on('myevent', function () { + done(new Error('Event listener should not have been called on the second')); + }); + + obj.emit('myevent'); + + done(); + }); + + it('multiple dispatches work properly', function () { + var called = 0; + + function onMyEvent() { + called++; + } + + obj.on('myevent', onMyEvent); + obj.emit('myevent'); + obj.emit('myevent'); + obj.emit('myevent'); + obj.emit('myevent'); + + expect(called).to.equal(4); + }); + + it('multiple events work properly', function () { + var called = 0; + + function onMyEvent() { + called++; + } + + obj.on('myevent1', onMyEvent); + obj.on('myevent2', onMyEvent); + obj.on('myevent3', onMyEvent); + obj.emit('myevent1'); + obj.emit('myevent2'); + obj.emit('myevent3'); + + expect(called).to.equal(3); + }); + + it('multiple events one removed works properly', function () { + var called = 0; + + function onMyEvent() { + called++; + } + + obj.on('myevent1', onMyEvent); + obj.on('myevent2', onMyEvent); + obj.on('myevent3', onMyEvent); + + obj.emit('myevent1'); + obj.emit('myevent2'); + obj.emit('myevent3'); + + obj.off('myevent2', onMyEvent); + + obj.emit('myevent1'); + obj.emit('myevent2'); + obj.emit('myevent3'); + + expect(called).to.equal(5); + }); + + it('multiple handlers for one event with some removed', function () { + var called = 0; + + var onMyEvent = function () { + called++; + }, + onMyEvent2 = function () { + called++; + }; + + // add 2 handlers and confirm they both get called + obj.on('myevent', onMyEvent); + obj.on('myevent', onMyEvent); + obj.on('myevent', onMyEvent2); + obj.on('myevent', onMyEvent2); + + obj.emit('myevent'); + + expect(called).to.equal(4); + + // remove one of the handlers, emit again, then ensure 1 more call is made + obj.off('myevent', onMyEvent); + + obj.emit('myevent'); + + expect(called).to.equal(6); + }); + + it('calls to off without a handler do nothing', function () { + var called = 0; + + var onMyEvent = function () { + called++; + }; + + obj.on('myevent', onMyEvent); + obj.on('myevent', onMyEvent); + + obj.emit('myevent'); + + expect(called).to.equal(2); + + obj.off('myevent'); + + obj.emit('myevent'); + + expect(called).to.equal(4); + + obj.off('myevent', onMyEvent); + + obj.emit('myevent'); + + expect(called).to.equal(4); + }); + + it('handles multiple instances with the same prototype', function () { + var called = 0; + + function onMyEvent(e) { + called++; + } + + obj.on('myevent1', onMyEvent); + obj.on('myevent2', onMyEvent); + + obj2.istwo = true; + obj2.on('myevent1', onMyEvent); + obj2.on('myevent2', onMyEvent); + + obj.emit('myevent1'); + obj.emit('myevent2'); + obj2.emit('myevent1'); + obj2.emit('myevent2'); + + //we emit 4 times, but since obj2 is a child of obj the event should bubble + //up to obj and show up there as well. So the obj2.emit() calls each increment + //the counter twice. + expect(called).to.equal(6); + }); + + it('is backwards compatible with older .dispatchEvent({})', function () { + var called = 0, + data = { + some: 'thing', + hello: true + }; + + function onMyEvent(event) { + pixi_utils_EventTarget_Event_confirm(event, obj, data); + + called++; + } + + obj.on('myevent1', onMyEvent); + obj.on('myevent2', onMyEvent); + obj.on('myevent3', onMyEvent); + + data.type = 'myevent1'; + obj.emit(data); + + data.type = 'myevent2'; + obj.emit(data); + + data.type = 'myevent3'; + obj.emit(data); + + obj.off('myevent2', onMyEvent); + + data.type = 'myevent1'; + obj.emit(data); + + data.type = 'myevent2'; + obj.emit(data); + + data.type = 'myevent3'; + obj.emit(data); + + expect(called).to.equal(5); + }); + + it('is backwards compatible with older .call(this)', function () { + var Fn = function() { + PIXI.EventTarget.call(this); + }, + o = new Fn(); + + pixi_utils_EventTarget_confirm(o); + }); + + it('is backwards compatible with older .addEventListener("")', function () { + var called = 0, + data = { + some: 'thing', + hello: true + }; + + function onMyEvent(event) { + pixi_utils_EventTarget_Event_confirm(event, obj, data); + + called++; + } + + obj.addEventListener('myevent1', onMyEvent); + obj.addEventListener('myevent2', onMyEvent); + obj.addEventListener('myevent3', onMyEvent); + + data.type = 'myevent1'; + obj.emit(data); + + data.type = 'myevent2'; + obj.emit(data); + + data.type = 'myevent3'; + obj.emit(data); + + obj.off('myevent2', onMyEvent); + + data.type = 'myevent1'; + obj.emit(data); + + data.type = 'myevent2'; + obj.emit(data); + + data.type = 'myevent3'; + obj.emit(data); + + expect(called).to.equal(5); + }); + + it('event remove during emit call properly', function () { + var called = 0; + + function cb1() { + called++; + obj.off('myevent', cb1); + } + function cb2() { + called++; + obj.off('myevent', cb2); + } + function cb3() { + called++; + obj.off('myevent', cb3); + } + + obj.on('myevent', cb1); + obj.on('myevent', cb2); + obj.on('myevent', cb3); + obj.emit('myevent', ''); + + expect(called).to.equal(3); + }); +}); diff --git a/test/unit/pixi-v2/utils/Polyk.js b/test/unit/pixi-v2/utils/Polyk.js new file mode 100644 index 0000000..dfc7128 --- /dev/null +++ b/test/unit/pixi-v2/utils/Polyk.js @@ -0,0 +1,14 @@ +describe('pixi/utils/Polyk', function () { + 'use strict'; + + var expect = chai.expect; + var PolyK = PIXI.PolyK; + + it('Module exists', function () { + expect(PolyK).to.be.an('object'); + }); + + it('Members exist', function () { + expect(PolyK).to.respondTo('Triangulate'); + }); +}); diff --git a/test/unit/pixi-v2/utils/Utils.js b/test/unit/pixi-v2/utils/Utils.js new file mode 100644 index 0000000..c97b3c6 --- /dev/null +++ b/test/unit/pixi-v2/utils/Utils.js @@ -0,0 +1,17 @@ +describe('Utils', function () { + 'use strict'; + + var expect = chai.expect; + + it('requestAnimationFrame exists', function () { + expect(global).to.respondTo('requestAnimationFrame'); + }); + + it('cancelAnimationFrame exists', function () { + expect(global).to.respondTo('cancelAnimationFrame'); + }); + + it('requestAnimFrame exists', function () { + expect(global).to.respondTo('requestAnimFrame'); + }); +}); diff --git a/test/unit/pixi/InteractionManager.js b/test/unit/pixi/InteractionManager.js deleted file mode 100644 index ed3001f..0000000 --- a/test/unit/pixi/InteractionManager.js +++ /dev/null @@ -1,10 +0,0 @@ -describe('pixi/InteractionManager', function () { - 'use strict'; - - var expect = chai.expect; - var InteractionManager = PIXI.InteractionManager; - - it('Module exists', function () { - expect(InteractionManager).to.be.a('function'); - }); -}); diff --git a/test/unit/pixi/Pixi.js b/test/unit/pixi/Pixi.js deleted file mode 100644 index 27debc1..0000000 --- a/test/unit/pixi/Pixi.js +++ /dev/null @@ -1,9 +0,0 @@ -describe('pixi/Pixi', function () { - 'use strict'; - - var expect = chai.expect; - - it('Module exists', function () { - expect(global).to.have.property('PIXI').and.to.be.an('object'); - }); -}); diff --git a/test/unit/pixi/core/Circle.js b/test/unit/pixi/core/Circle.js deleted file mode 100644 index fbcfa17..0000000 --- a/test/unit/pixi/core/Circle.js +++ /dev/null @@ -1,21 +0,0 @@ -describe('pixi/core/Circle', function () { - 'use strict'; - - var expect = chai.expect; - var Circle = PIXI.Circle; - - it('Module exists', function () { - expect(Circle).to.be.a('function'); - }); - - it('Confirm new instance', function () { - var obj = new Circle(); - pixi_core_Circle_confirmNewCircle(obj); - }); - - it("getBounds should return Rectangle that bounds the circle", function() { - var obj = new Circle(100, 250, 50); - var bounds = obj.getBounds(); - pixi_core_Circle_isBoundedByRectangle(obj, bounds); - }); -}); diff --git a/test/unit/pixi/core/Ellipse.js b/test/unit/pixi/core/Ellipse.js deleted file mode 100644 index 026b56f..0000000 --- a/test/unit/pixi/core/Ellipse.js +++ /dev/null @@ -1,24 +0,0 @@ -describe('pixi/core/Ellipse', function () { - 'use strict'; - - var expect = chai.expect; - var Ellipse = PIXI.Ellipse; - - it('Module exists', function () { - expect(Ellipse).to.be.a('function'); - }); - - it('Confirm new instance', function () { - var obj = new Ellipse(); - - expect(obj).to.be.an.instanceof(Ellipse); - expect(obj).to.respondTo('clone'); - expect(obj).to.respondTo('contains'); - expect(obj).to.respondTo('getBounds'); - - expect(obj).to.have.property('x', 0); - expect(obj).to.have.property('y', 0); - expect(obj).to.have.property('width', 0); - expect(obj).to.have.property('height', 0); - }); -}); diff --git a/test/unit/pixi-v2/InteractionManager.js b/test/unit/pixi-v2/InteractionManager.js new file mode 100644 index 0000000..ed3001f --- /dev/null +++ b/test/unit/pixi-v2/InteractionManager.js @@ -0,0 +1,10 @@ +describe('pixi/InteractionManager', function () { + 'use strict'; + + var expect = chai.expect; + var InteractionManager = PIXI.InteractionManager; + + it('Module exists', function () { + expect(InteractionManager).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/Pixi.js b/test/unit/pixi-v2/Pixi.js new file mode 100644 index 0000000..27debc1 --- /dev/null +++ b/test/unit/pixi-v2/Pixi.js @@ -0,0 +1,9 @@ +describe('pixi/Pixi', function () { + 'use strict'; + + var expect = chai.expect; + + it('Module exists', function () { + expect(global).to.have.property('PIXI').and.to.be.an('object'); + }); +}); diff --git a/test/unit/pixi-v2/core/Circle.js b/test/unit/pixi-v2/core/Circle.js new file mode 100644 index 0000000..fbcfa17 --- /dev/null +++ b/test/unit/pixi-v2/core/Circle.js @@ -0,0 +1,21 @@ +describe('pixi/core/Circle', function () { + 'use strict'; + + var expect = chai.expect; + var Circle = PIXI.Circle; + + it('Module exists', function () { + expect(Circle).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Circle(); + pixi_core_Circle_confirmNewCircle(obj); + }); + + it("getBounds should return Rectangle that bounds the circle", function() { + var obj = new Circle(100, 250, 50); + var bounds = obj.getBounds(); + pixi_core_Circle_isBoundedByRectangle(obj, bounds); + }); +}); diff --git a/test/unit/pixi-v2/core/Ellipse.js b/test/unit/pixi-v2/core/Ellipse.js new file mode 100644 index 0000000..026b56f --- /dev/null +++ b/test/unit/pixi-v2/core/Ellipse.js @@ -0,0 +1,24 @@ +describe('pixi/core/Ellipse', function () { + 'use strict'; + + var expect = chai.expect; + var Ellipse = PIXI.Ellipse; + + it('Module exists', function () { + expect(Ellipse).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Ellipse(); + + expect(obj).to.be.an.instanceof(Ellipse); + expect(obj).to.respondTo('clone'); + expect(obj).to.respondTo('contains'); + expect(obj).to.respondTo('getBounds'); + + expect(obj).to.have.property('x', 0); + expect(obj).to.have.property('y', 0); + expect(obj).to.have.property('width', 0); + expect(obj).to.have.property('height', 0); + }); +}); diff --git a/test/unit/pixi-v2/core/Matrix.js b/test/unit/pixi-v2/core/Matrix.js new file mode 100644 index 0000000..da75e2e --- /dev/null +++ b/test/unit/pixi-v2/core/Matrix.js @@ -0,0 +1,14 @@ +describe('pixi/core/Matrix', function () { + 'use strict'; + + var expect = chai.expect; + + it('Matrix exists', function () { + expect(PIXI.Matrix).to.be.an('function'); + }); + + it('Confirm new Matrix', function () { + var matrix = new PIXI.Matrix(); + pixi_core_Matrix_confirmNewMatrix(matrix); + }); +}); diff --git a/test/unit/pixi-v2/core/Point.js b/test/unit/pixi-v2/core/Point.js new file mode 100644 index 0000000..c4d5163 --- /dev/null +++ b/test/unit/pixi-v2/core/Point.js @@ -0,0 +1,15 @@ +describe('pixi/core/Point', function () { + 'use strict'; + + var expect = chai.expect; + var Point = PIXI.Point; + + it('Module exists', function () { + expect(Point).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Point(); + pixi_core_Point_confirm(obj, 0, 0); + }); +}); diff --git a/test/unit/pixi-v2/core/Polygon.js b/test/unit/pixi-v2/core/Polygon.js new file mode 100644 index 0000000..dc8c918 --- /dev/null +++ b/test/unit/pixi-v2/core/Polygon.js @@ -0,0 +1,20 @@ +describe('pixi/core/Polygon', function () { + 'use strict'; + + var expect = chai.expect; + var Polygon = PIXI.Polygon; + + it('Module exists', function () { + expect(Polygon).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Polygon(); + + expect(obj).to.be.an.instanceof(Polygon); + expect(obj).to.respondTo('clone'); + expect(obj).to.respondTo('contains'); + + expect(obj).to.have.deep.property('points.length', 0); + }); +}); diff --git a/test/unit/pixi-v2/core/Rectangle.js b/test/unit/pixi-v2/core/Rectangle.js new file mode 100644 index 0000000..d43316e --- /dev/null +++ b/test/unit/pixi-v2/core/Rectangle.js @@ -0,0 +1,15 @@ +describe('pixi/core/Rectangle', function () { + 'use strict'; + + var expect = chai.expect; + var Rectangle = PIXI.Rectangle; + + it('Module exists', function () { + expect(Rectangle).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var rect = new Rectangle(); + pixi_core_Rectangle_confirm(rect, 0, 0, 0, 0); + }); +}); diff --git a/test/unit/pixi-v2/display/DisplayObject.js b/test/unit/pixi-v2/display/DisplayObject.js new file mode 100644 index 0000000..044acf8 --- /dev/null +++ b/test/unit/pixi-v2/display/DisplayObject.js @@ -0,0 +1,21 @@ +describe('pixi/display/DisplayObject', function () { + 'use strict'; + + var expect = chai.expect; + var DisplayObject = PIXI.DisplayObject; + + it('Module exists', function () { + expect(DisplayObject).to.be.a('function'); + // expect(PIXI).to.have.property('visibleCount', 0); + }); + + it('Confirm new instance', function () { + var obj = new DisplayObject(); + + pixi_display_DisplayObject_confirmNew(obj); + expect(obj).to.have.property('hitArea', null); + expect(obj).to.have.property('interactive', false); + expect(obj).to.have.property('renderable', false); + expect(obj).to.have.property('stage', null); + }); +}); diff --git a/test/unit/pixi-v2/display/DisplayObjectContainer.js b/test/unit/pixi-v2/display/DisplayObjectContainer.js new file mode 100644 index 0000000..15a3376 --- /dev/null +++ b/test/unit/pixi-v2/display/DisplayObjectContainer.js @@ -0,0 +1,67 @@ +describe('pixi/display/DisplayObjectContainer', function () { + 'use strict'; + + var expect = chai.expect; + var DisplayObjectContainer = PIXI.DisplayObjectContainer; + + it('Module exists', function () { + expect(DisplayObjectContainer).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new DisplayObjectContainer(); + + pixi_display_DisplayObjectContainer_confirmNew(obj); + expect(obj).to.have.property('hitArea', null); + expect(obj).to.have.property('interactive', false); + expect(obj).to.have.property('renderable', false); + expect(obj).to.have.property('stage', null); + }); + + it('Gets child index', function() { + var container = new PIXI.DisplayObjectContainer(); + var children = []; + for (var i = 0; i < 10; i++) { + var child = new PIXI.DisplayObject(); + children.push(child); + container.addChild(child); + } + + for (i = 0; i < children.length; i++) { + expect(i).to.eql(container.getChildIndex(children[i])); + } + }); + + it('throws error when trying to get index of not a child', function() { + var container = new PIXI.DisplayObjectContainer(); + var child = new PIXI.DisplayObject(); + + expect(function() { container.getChildIndex(child); }).to.throw(); + }); + + it('Sets child index', function() { + var container = new PIXI.DisplayObjectContainer(); + var children = []; + + for (var i = 0; i < 10; i++) { + var child = new PIXI.DisplayObject(); + children.push(child); + container.addChild(child); + } + children.reverse(); + + for (i = 0; i < children.length; i++) { + container.setChildIndex(children[i], i); + expect(i).to.eql(container.getChildIndex(children[i])); + } + }); + + it('throws error when trying to set incorect index', function() { + var container = new PIXI.DisplayObjectContainer(); + var child = new PIXI.DisplayObject(); + container.addChild(child); + + expect(function() { container.setChildIndex(child, -1); }).to.throw(); + expect(function() { container.setChildIndex(child, 1); }).to.throw(); + }); +}); diff --git a/test/unit/pixi-v2/display/MovieClip.js b/test/unit/pixi-v2/display/MovieClip.js new file mode 100644 index 0000000..f3c6c6a --- /dev/null +++ b/test/unit/pixi-v2/display/MovieClip.js @@ -0,0 +1,33 @@ +describe('pixi/display/MovieClip', function () { + 'use strict'; + + var expect = chai.expect; + var MovieClip = PIXI.MovieClip; + var Texture = PIXI.Texture; + + it('Module exists', function () { + expect(MovieClip).to.be.a('function'); + }); + + it('Confirm new instance', function (done) { + var texture = Texture.fromImage('/base/test/textures/SpriteSheet-Explosion.png'); + var obj = new MovieClip([texture]); + + pixi_display_Sprite_confirmNew(obj, done); + + expect(obj).to.be.an.instanceof(MovieClip); + expect(obj).to.respondTo('stop'); + expect(obj).to.respondTo('play'); + expect(obj).to.respondTo('gotoAndStop'); + expect(obj).to.respondTo('gotoAndPlay'); + expect(obj).to.respondTo('updateTransform'); + + expect(obj).to.have.deep.property('textures.length', 1); + expect(obj).to.have.deep.property('textures[0]', texture); + expect(obj).to.have.property('animationSpeed', 1); + expect(obj).to.have.property('loop', true); + expect(obj).to.have.property('onComplete', null); + expect(obj).to.have.property('currentFrame', 0); + expect(obj).to.have.property('playing', false); + }); +}); diff --git a/test/unit/pixi-v2/display/Sprite.js b/test/unit/pixi-v2/display/Sprite.js new file mode 100644 index 0000000..30c8076 --- /dev/null +++ b/test/unit/pixi-v2/display/Sprite.js @@ -0,0 +1,28 @@ +describe('pixi/display/Sprite', function () { + 'use strict'; + + var expect = chai.expect; + var Sprite = PIXI.Sprite; + var Texture = PIXI.Texture; + + it('Module exists', function () { + expect(Sprite).to.be.a('function'); + expect(PIXI).to.have.deep.property('blendModes.NORMAL', 0); + expect(PIXI).to.have.deep.property('blendModes.ADD', 1); + expect(PIXI).to.have.deep.property('blendModes.MULTIPLY', 2); + expect(PIXI).to.have.deep.property('blendModes.SCREEN', 3); + }); + + + it('Members exist', function () { + expect(Sprite).itself.to.respondTo('fromImage'); + expect(Sprite).itself.to.respondTo('fromFrame'); + }); + + it('Confirm new instance', function (done) { + var texture = Texture.fromImage('/base/test/textures/SpriteSheet-Aliens.png'); + var obj = new Sprite(texture); + + pixi_display_Sprite_confirmNew(obj, done); + }); +}); diff --git a/test/unit/pixi-v2/display/Stage.js b/test/unit/pixi-v2/display/Stage.js new file mode 100644 index 0000000..6974c2e --- /dev/null +++ b/test/unit/pixi-v2/display/Stage.js @@ -0,0 +1,49 @@ +describe('pixi/display/Stage', function () { + 'use strict'; + + var expect = chai.expect; + var Stage = PIXI.Stage; + var InteractionManager = PIXI.InteractionManager; + var Rectangle = PIXI.Rectangle; + + it('Module exists', function () { + expect(Stage).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Stage(null, true); + + pixi_display_DisplayObjectContainer_confirmNew(obj); + + expect(obj).to.be.an.instanceof(Stage); + expect(obj).to.respondTo('updateTransform'); + expect(obj).to.respondTo('setBackgroundColor'); + expect(obj).to.respondTo('getMousePosition'); + // FIXME: duplicate member in DisplayObject + pixi_core_Matrix_confirmNewMatrix(obj.worldTransform); + // FIXME: convert arg to bool in constructor + expect(obj).to.have.property('interactive', true); + + expect(obj).to.have.property('interactionManager') + .and.to.be.an.instanceof(InteractionManager) + .and.to.have.property('stage', obj); + + expect(obj).to.have.property('dirty', true); + + expect(obj).to.have.property('stage', obj); + + expect(obj).to.have.property('hitArea') + .and.to.be.an.instanceof(Rectangle); + pixi_core_Rectangle_confirm(obj.hitArea, 0, 0, 100000, 100000); + + expect(obj).to.have.property('backgroundColor', 0x000000); + expect(obj).to.have.deep.property('backgroundColorSplit.length', 3); + expect(obj).to.have.deep.property('backgroundColorSplit[0]', 0); + expect(obj).to.have.deep.property('backgroundColorSplit[1]', 0); + expect(obj).to.have.deep.property('backgroundColorSplit[2]', 0); + expect(obj).to.have.property('backgroundColorString', '#000000'); + + + expect(obj).to.have.property('worldVisible', true); + }); +}); diff --git a/test/unit/pixi-v2/extras/Rope.js b/test/unit/pixi-v2/extras/Rope.js new file mode 100644 index 0000000..05885ac --- /dev/null +++ b/test/unit/pixi-v2/extras/Rope.js @@ -0,0 +1,31 @@ +describe('pixi/extras/Rope', function () { + 'use strict'; + + var expect = chai.expect; + var Rope = PIXI.Rope; + var Texture = PIXI.Texture; + var Point = PIXI.Point; + + it('Module exists', function () { + expect(Rope).to.be.a('function'); + }); + + it('Confirm new instance', function () { + + var texture = Texture.fromImage('/base/test/textures/bunny.png'); + + // TODO-Alvin + // Same as Strip + + // var obj = new Rope(texture, [new Point(), new Point(5, 10), new Point(10, 20)]); + + // pixi_extras_Strip_confirmNew(obj); + + // expect(obj).to.be.an.instanceof(Rope); + // expect(obj).to.respondTo('refresh'); + // expect(obj).to.respondTo('updateTransform'); + // expect(obj).to.respondTo('setTexture'); + + // TODO: Test properties + }); +}); diff --git a/test/unit/pixi-v2/extras/Spine.js b/test/unit/pixi-v2/extras/Spine.js new file mode 100644 index 0000000..0708bc0 --- /dev/null +++ b/test/unit/pixi-v2/extras/Spine.js @@ -0,0 +1,10 @@ +describe('pixi/extras/Spine', function () { + 'use strict'; + + var expect = chai.expect; + var Spine = PIXI.Spine; + + it('Module exists', function () { + expect(Spine).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/extras/Strip.js b/test/unit/pixi-v2/extras/Strip.js new file mode 100644 index 0000000..230af90 --- /dev/null +++ b/test/unit/pixi-v2/extras/Strip.js @@ -0,0 +1,26 @@ +describe('pixi/extras/Strip', function () { + 'use strict'; + + var expect = chai.expect; + var Strip = PIXI.Strip; + var Texture = PIXI.Texture; + + it('Module exists', function () { + expect(Strip).to.be.a('function'); + }); + + it('Confirm new instance', function () { + + + // TODO-Alvin + // We tweaked it to make it pass the tests, but the whole strip class needs + // to be re-coded + + var texture = Texture.fromImage('/base/test/textures/bunny.png'); + + // var obj = new Strip(texture, 20, 10000); + + + // pixi_extras_Strip_confirmNew(obj); + }); +}); diff --git a/test/unit/pixi-v2/extras/TilingSprite.js b/test/unit/pixi-v2/extras/TilingSprite.js new file mode 100644 index 0000000..56aea14 --- /dev/null +++ b/test/unit/pixi-v2/extras/TilingSprite.js @@ -0,0 +1,24 @@ +describe('pixi/extras/TilingSprite', function () { + 'use strict'; + + var expect = chai.expect; + var TilingSprite = PIXI.TilingSprite; + var Texture = PIXI.Texture; + + it('Module exists', function () { + expect(TilingSprite).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var texture = Texture.fromImage('/base/test/textures/bunny.png'); + var obj = new TilingSprite(texture, 6000, 12000); + + pixi_display_DisplayObjectContainer_confirmNew(obj); + + expect(obj).to.be.an.instanceof(TilingSprite); + expect(obj).to.respondTo('setTexture'); + expect(obj).to.respondTo('onTextureUpdate'); + + // TODO: Test properties + }); +}); diff --git a/test/unit/pixi-v2/filters/FilterBlock.js b/test/unit/pixi-v2/filters/FilterBlock.js new file mode 100644 index 0000000..870cec0 --- /dev/null +++ b/test/unit/pixi-v2/filters/FilterBlock.js @@ -0,0 +1,10 @@ +describe('pixi/filters/FilterBlock', function () { + 'use strict'; + + var expect = chai.expect; + var FilterBlock = PIXI.FilterBlock; + + it('Module exists', function () { + expect(FilterBlock).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/AssetLoader.js b/test/unit/pixi-v2/loaders/AssetLoader.js new file mode 100644 index 0000000..a0aa0b5 --- /dev/null +++ b/test/unit/pixi-v2/loaders/AssetLoader.js @@ -0,0 +1,10 @@ +describe('pixi/loaders/AssetLoader', function () { + 'use strict'; + + var expect = chai.expect; + var AssetLoader = PIXI.AssetLoader; + + it('Module exists', function () { + expect(AssetLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/BitmapFontLoader.js b/test/unit/pixi-v2/loaders/BitmapFontLoader.js new file mode 100644 index 0000000..046f018 --- /dev/null +++ b/test/unit/pixi-v2/loaders/BitmapFontLoader.js @@ -0,0 +1,9 @@ +describe('pixi/loaders/BitmapFontLoader', function () { + 'use strict'; + + var expect = chai.expect; + + it('Module exists', function () { + expect(PIXI.BitmapFontLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/ImageLoader.js b/test/unit/pixi-v2/loaders/ImageLoader.js new file mode 100644 index 0000000..8b1f556 --- /dev/null +++ b/test/unit/pixi-v2/loaders/ImageLoader.js @@ -0,0 +1,10 @@ +describe('pixi/loaders/ImageLoader', function () { + 'use strict'; + + var expect = chai.expect; + var ImageLoader = PIXI.ImageLoader; + + it('Module exists', function () { + expect(ImageLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/JsonLoader.js b/test/unit/pixi-v2/loaders/JsonLoader.js new file mode 100644 index 0000000..c577e83 --- /dev/null +++ b/test/unit/pixi-v2/loaders/JsonLoader.js @@ -0,0 +1,10 @@ +describe('pixi/loaders/JsonLoader', function () { + 'use strict'; + + var expect = chai.expect; + var JsonLoader = PIXI.JsonLoader; + + it('Module exists', function () { + expect(JsonLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/SpineLoader.js b/test/unit/pixi-v2/loaders/SpineLoader.js new file mode 100644 index 0000000..fdcc0b8 --- /dev/null +++ b/test/unit/pixi-v2/loaders/SpineLoader.js @@ -0,0 +1,10 @@ +describe('pixi/loaders/SpineLoader', function () { + 'use strict'; + + var expect = chai.expect; + var SpineLoader = PIXI.SpineLoader; + + it('Module exists', function () { + expect(SpineLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/SpriteSheetLoader.js b/test/unit/pixi-v2/loaders/SpriteSheetLoader.js new file mode 100644 index 0000000..57beb27 --- /dev/null +++ b/test/unit/pixi-v2/loaders/SpriteSheetLoader.js @@ -0,0 +1,10 @@ +describe('pixi/loaders/SpriteSheetLoader', function () { + 'use strict'; + + var expect = chai.expect; + var SpriteSheetLoader = PIXI.SpriteSheetLoader; + + it('Module exists', function () { + expect(SpriteSheetLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/primitives/Graphics.js b/test/unit/pixi-v2/primitives/Graphics.js new file mode 100644 index 0000000..f3849eb --- /dev/null +++ b/test/unit/pixi-v2/primitives/Graphics.js @@ -0,0 +1,44 @@ +describe('pixi/primitives/Graphics', function () { + 'use strict'; + + var expect = chai.expect; + var Graphics = PIXI.Graphics; + + it('Module exists', function () { + expect(Graphics).to.be.a('function'); + + expect(Graphics).itself.to.have.property('POLY', 0); + expect(Graphics).itself.to.have.property('RECT', 1); + expect(Graphics).itself.to.have.property('CIRC', 2); + expect(Graphics).itself.to.have.property('ELIP', 3); + expect(Graphics).itself.to.have.property('RREC', 4); + }); + + it('Confirm new instance', function () { + var obj = new Graphics(); + + pixi_display_DisplayObjectContainer_confirmNew(obj); + + expect(obj).to.be.an.instanceof(Graphics); + expect(obj).to.respondTo('lineStyle'); + expect(obj).to.respondTo('lineStyle'); + expect(obj).to.respondTo('moveTo'); + expect(obj).to.respondTo('lineTo'); + expect(obj).to.respondTo('beginFill'); + expect(obj).to.respondTo('endFill'); + expect(obj).to.respondTo('drawRect'); + // expect(obj).to.respondTo('drawRoundedRect'); + expect(obj).to.respondTo('drawCircle'); + expect(obj).to.respondTo('drawEllipse'); + expect(obj).to.respondTo('clear'); + + expect(obj).to.have.property('renderable', true); + expect(obj).to.have.property('fillAlpha', 1); + expect(obj).to.have.property('lineWidth', 0); + expect(obj).to.have.property('width', 0); + expect(obj).to.have.property('height', 0); + expect(obj).to.have.property('lineColor', 0); + expect(obj).to.have.deep.property('graphicsData.length', 0); + // expect(obj).to.have.deep.property('currentPath.points.length', 0); + }); +}); diff --git a/test/unit/pixi-v2/renderers/canvas/CanvasGraphics.js b/test/unit/pixi-v2/renderers/canvas/CanvasGraphics.js new file mode 100644 index 0000000..8f44472 --- /dev/null +++ b/test/unit/pixi-v2/renderers/canvas/CanvasGraphics.js @@ -0,0 +1,15 @@ +describe('renders/canvas/CanvasGraphics', function () { + 'use strict'; + + var expect = chai.expect; + var CanvasGraphics = PIXI.CanvasGraphics; + + it('Module exists', function () { + expect(CanvasGraphics).to.be.a('function'); + }); + + it('Members exist', function () { + expect(CanvasGraphics).itself.to.respondTo('renderGraphics'); + expect(CanvasGraphics).itself.to.respondTo('renderGraphicsMask'); + }); +}); diff --git a/test/unit/pixi-v2/renderers/canvas/CanvasRenderer.js b/test/unit/pixi-v2/renderers/canvas/CanvasRenderer.js new file mode 100644 index 0000000..1646444 --- /dev/null +++ b/test/unit/pixi-v2/renderers/canvas/CanvasRenderer.js @@ -0,0 +1,36 @@ +describe('renderers/canvas/CanvasRenderer', function () { + 'use strict'; + + var expect = chai.expect; + var CanvasRenderer = PIXI.CanvasRenderer; + + it('Module exists', function () { + expect(CanvasRenderer).to.be.a('function'); + }); + + describe('.autoResize', function () { + it('Should automatically resize view if enabled', function () { + var renderer = new CanvasRenderer(200, 200, { + autoResize: true + }); + + expect(renderer.view.style.width).to.equal('200px'); + }); + + it('Should not automatically resize view if disabled', function () { + var renderer = new CanvasRenderer(200, 200, { + autoResize: false + }); + + expect(renderer.view.style.width).to.equal(''); + }); + + it('Should not automatically resize view if not specified', function () { + var renderer = new CanvasRenderer(200, 200, { + resolution: 2 + }); + + expect(renderer.view.style.width).to.equal(''); + }); + }); +}); diff --git a/test/unit/pixi-v2/renderers/webgl/WebGLGraphics.js b/test/unit/pixi-v2/renderers/webgl/WebGLGraphics.js new file mode 100644 index 0000000..5867b28 --- /dev/null +++ b/test/unit/pixi-v2/renderers/webgl/WebGLGraphics.js @@ -0,0 +1,20 @@ +describe('renderers/wegbl/WebGLGraphics', function () { + 'use strict'; + + var expect = chai.expect; + var WebGLGraphics = PIXI.WebGLGraphics; + + it('Module exists', function () { + expect(WebGLGraphics).to.be.a('function'); + }); + + it('Members exist', function () { + expect(WebGLGraphics).itself.to.respondTo('renderGraphics'); + expect(WebGLGraphics).itself.to.respondTo('updateGraphics'); + expect(WebGLGraphics).itself.to.respondTo('buildRectangle'); + expect(WebGLGraphics).itself.to.respondTo('buildRoundedRectangle'); + expect(WebGLGraphics).itself.to.respondTo('buildCircle'); + expect(WebGLGraphics).itself.to.respondTo('buildLine'); + expect(WebGLGraphics).itself.to.respondTo('buildPoly'); + }); +}); diff --git a/test/unit/pixi-v2/renderers/webgl/WebGLRenderer.js b/test/unit/pixi-v2/renderers/webgl/WebGLRenderer.js new file mode 100644 index 0000000..1680a80 --- /dev/null +++ b/test/unit/pixi-v2/renderers/webgl/WebGLRenderer.js @@ -0,0 +1,49 @@ +describe('renderers/webgl/WebGLRenderer', function () { + 'use strict'; + + var expect = chai.expect; + var WebGLRenderer = PIXI.WebGLRenderer; + + it('Module exists', function () { + expect(WebGLRenderer).to.be.a('function'); + }); + + // Skip tests if WebGL is not available (WebGL not supported in Travis CI) + try { + var renderer = new WebGLRenderer(400, 300, {}); + renderer.destroy(); + } catch (error) { + return; + } + + it('Destroy renderer', function () { + var renderer = new WebGLRenderer(400, 300, {}); + renderer.destroy(); + }); + + describe('.autoResize', function () { + it('Should automatically resize view if enabled', function () { + var renderer = new WebGLRenderer(200, 200, { + autoResize: true + }); + + expect(renderer.view.style.width).to.equal('200px'); + }); + + it('Should not automatically resize view if disabled', function () { + var renderer = new WebGLRenderer(200, 200, { + autoResize: false + }); + + expect(renderer.view.style.width).to.equal(''); + }); + + it('Should not automatically resize view if not specified', function () { + var renderer = new WebGLRenderer(200, 200, { + resolution: 2 + }); + + expect(renderer.view.style.width).to.equal(''); + }); + }); +}); diff --git a/test/unit/pixi-v2/renderers/webgl/WebGLShaders.js b/test/unit/pixi-v2/renderers/webgl/WebGLShaders.js new file mode 100644 index 0000000..6e33e4f --- /dev/null +++ b/test/unit/pixi-v2/renderers/webgl/WebGLShaders.js @@ -0,0 +1,13 @@ +describe('renderers/webgl/WebGLShaders', function () { + 'use strict'; + + var expect = chai.expect; + + it('Module members exist', function () { + + expect(PIXI).to.respondTo('CompileVertexShader'); + expect(PIXI).to.respondTo('CompileFragmentShader'); + expect(PIXI).to.respondTo('_CompileShader'); + expect(PIXI).to.respondTo('compileProgram'); + }); +}); diff --git a/test/unit/pixi-v2/renderers/webgl/WebGLSpriteBatch.js b/test/unit/pixi-v2/renderers/webgl/WebGLSpriteBatch.js new file mode 100644 index 0000000..e662b63 --- /dev/null +++ b/test/unit/pixi-v2/renderers/webgl/WebGLSpriteBatch.js @@ -0,0 +1,10 @@ +describe('renderers/webgl/utils/WebGLSpriteBatch', function () { + 'use strict'; + + var expect = chai.expect; + var WebGLSpriteBatch = PIXI.WebGLSpriteBatch; + + it('Module exists', function () { + expect(WebGLSpriteBatch).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/text/BitmapText.js b/test/unit/pixi-v2/text/BitmapText.js new file mode 100644 index 0000000..9388e3d --- /dev/null +++ b/test/unit/pixi-v2/text/BitmapText.js @@ -0,0 +1,10 @@ +describe('pixi/text/BitmapText', function () { + 'use strict'; + + var expect = chai.expect; + var BitmapText = PIXI.BitmapText; + + it('Module exists', function () { + expect(BitmapText).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/text/Text.js b/test/unit/pixi-v2/text/Text.js new file mode 100644 index 0000000..9bc9ac5 --- /dev/null +++ b/test/unit/pixi-v2/text/Text.js @@ -0,0 +1,10 @@ +describe('pixi/text/Text', function () { + 'use strict'; + + var expect = chai.expect; + var Text = PIXI.Text; + + it('Module exists', function () { + expect(Text).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/textures/BaseTexture.js b/test/unit/pixi-v2/textures/BaseTexture.js new file mode 100644 index 0000000..502b724 --- /dev/null +++ b/test/unit/pixi-v2/textures/BaseTexture.js @@ -0,0 +1,11 @@ +describe('pixi/textures/BaseTexture', function () { + 'use strict'; + + var expect = chai.expect; + var BaseTexture = PIXI.BaseTexture; + + it('Module exists', function () { + expect(BaseTexture).to.be.a('function'); + expect(PIXI).to.have.property('BaseTextureCache').and.to.be.an('object'); + }); +}); diff --git a/test/unit/pixi-v2/textures/RenderTexture.js b/test/unit/pixi-v2/textures/RenderTexture.js new file mode 100644 index 0000000..96acdb4 --- /dev/null +++ b/test/unit/pixi-v2/textures/RenderTexture.js @@ -0,0 +1,15 @@ +describe('pixi/textures/RenderTexture', function () { + 'use strict'; + + var expect = chai.expect; + var RenderTexture = PIXI.RenderTexture; + + it('Module exists', function () { + expect(RenderTexture).to.be.a('function'); + }); + + it('Confirm new instance', function (done) { + var texture = new RenderTexture(100, 100, new PIXI.CanvasRenderer()); + pixi_textures_RenderTexture_confirmNew(texture, done); + }); +}); diff --git a/test/unit/pixi-v2/textures/Texture.js b/test/unit/pixi-v2/textures/Texture.js new file mode 100644 index 0000000..090f64d --- /dev/null +++ b/test/unit/pixi-v2/textures/Texture.js @@ -0,0 +1,26 @@ +describe('pixi/textures/Texture', function () { + 'use strict'; + + var expect = chai.expect; + var Texture = PIXI.Texture; + + it('Module exists', function () { + expect(Texture).to.be.a('function'); + expect(PIXI).to.have.property('TextureCache').and.to.be.an('object'); + }); + + it('Members exist', function () { + expect(Texture).itself.to.respondTo('fromImage'); + expect(Texture).itself.to.respondTo('fromFrame'); + expect(Texture).itself.to.respondTo('fromCanvas'); + expect(Texture).itself.to.respondTo('addTextureToCache'); + expect(Texture).itself.to.respondTo('removeTextureFromCache'); + + // expect(Texture).itself.to.have.deep.property('frameUpdates.length', 0); + }); + + it('Confirm new instance', function (done) { + var texture = Texture.fromImage('/base/test/textures/bunny.png'); + pixi_textures_Texture_confirmNew(texture, done); + }); +}); diff --git a/test/unit/pixi-v2/utils/Detector.js b/test/unit/pixi-v2/utils/Detector.js new file mode 100644 index 0000000..4cf6008 --- /dev/null +++ b/test/unit/pixi-v2/utils/Detector.js @@ -0,0 +1,10 @@ +describe('pixi/utils/Detector', function () { + 'use strict'; + + var expect = chai.expect; + var autoDetectRenderer = PIXI.autoDetectRenderer; + + it('Module exists', function () { + expect(autoDetectRenderer).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/utils/EventTarget.js b/test/unit/pixi-v2/utils/EventTarget.js new file mode 100644 index 0000000..1cfc3a4 --- /dev/null +++ b/test/unit/pixi-v2/utils/EventTarget.js @@ -0,0 +1,361 @@ +describe('pixi/utils/EventTarget', function () { + 'use strict'; + + var expect = chai.expect; + + var Clazz, PClazz, obj, pobj, obj2; + beforeEach(function () { + Clazz = function () {}; + PClazz = function () {}; + + PIXI.EventTarget.mixin(Clazz.prototype); + PIXI.EventTarget.mixin(PClazz.prototype); + + obj = new Clazz(); + obj2 = new Clazz(); + pobj = new PClazz(); + + obj.parent = pobj; + obj2.parent = obj; + }); + + it('Module exists', function () { + expect(PIXI.EventTarget).to.be.an('object'); + }); + + it('Confirm new instance', function () { + pixi_utils_EventTarget_confirm(obj); + }); + + it('simple on/emit case works', function () { + var myData = {}; + + obj.on('myevent', function (event) { + pixi_utils_EventTarget_Event_confirm(event, obj, myData); + }); + + obj.emit('myevent', myData); + }); + + it('simple once case works', function () { + var called = 0; + + obj.once('myevent', function() { called++; }); + + obj.emit('myevent'); + obj.emit('myevent'); + obj.emit('myevent'); + obj.emit('myevent'); + obj.emit('myevent'); + + expect(called).to.equal(1); + }); + + it('simple off case works', function (done) { + function onMyEvent() { + done(new Error('Event listener should not have been called')); + } + + obj.on('myevent', onMyEvent); + obj.off('myevent', onMyEvent); + obj.emit('myevent'); + + done(); + }); + + it('simple propagation case works', function (done) { + var myData = {}; + + pobj.on('myevent', function () { + done(); + }); + + obj.emit('myevent'); + }); + + it('simple stopPropagation case works', function (done) { + var myData = {}; + + pobj.on('myevent', function () { + done(new Error('Event listener should not have been called on the parent element')); + }); + + obj.on('myevent', function (evt) { + evt.stopPropagation(); + }); + + obj.emit('myevent'); + + done(); + }); + + it('simple stopImmediatePropagation case works', function (done) { + var myData = {}; + + pobj.on('myevent', function () { + done(new Error('Event listener should not have been called on the parent')); + }); + + obj.on('myevent', function (evt) { + evt.stopImmediatePropagation(); + }); + + obj.on('myevent', function () { + done(new Error('Event listener should not have been called on the second')); + }); + + obj.emit('myevent'); + + done(); + }); + + it('multiple dispatches work properly', function () { + var called = 0; + + function onMyEvent() { + called++; + } + + obj.on('myevent', onMyEvent); + obj.emit('myevent'); + obj.emit('myevent'); + obj.emit('myevent'); + obj.emit('myevent'); + + expect(called).to.equal(4); + }); + + it('multiple events work properly', function () { + var called = 0; + + function onMyEvent() { + called++; + } + + obj.on('myevent1', onMyEvent); + obj.on('myevent2', onMyEvent); + obj.on('myevent3', onMyEvent); + obj.emit('myevent1'); + obj.emit('myevent2'); + obj.emit('myevent3'); + + expect(called).to.equal(3); + }); + + it('multiple events one removed works properly', function () { + var called = 0; + + function onMyEvent() { + called++; + } + + obj.on('myevent1', onMyEvent); + obj.on('myevent2', onMyEvent); + obj.on('myevent3', onMyEvent); + + obj.emit('myevent1'); + obj.emit('myevent2'); + obj.emit('myevent3'); + + obj.off('myevent2', onMyEvent); + + obj.emit('myevent1'); + obj.emit('myevent2'); + obj.emit('myevent3'); + + expect(called).to.equal(5); + }); + + it('multiple handlers for one event with some removed', function () { + var called = 0; + + var onMyEvent = function () { + called++; + }, + onMyEvent2 = function () { + called++; + }; + + // add 2 handlers and confirm they both get called + obj.on('myevent', onMyEvent); + obj.on('myevent', onMyEvent); + obj.on('myevent', onMyEvent2); + obj.on('myevent', onMyEvent2); + + obj.emit('myevent'); + + expect(called).to.equal(4); + + // remove one of the handlers, emit again, then ensure 1 more call is made + obj.off('myevent', onMyEvent); + + obj.emit('myevent'); + + expect(called).to.equal(6); + }); + + it('calls to off without a handler do nothing', function () { + var called = 0; + + var onMyEvent = function () { + called++; + }; + + obj.on('myevent', onMyEvent); + obj.on('myevent', onMyEvent); + + obj.emit('myevent'); + + expect(called).to.equal(2); + + obj.off('myevent'); + + obj.emit('myevent'); + + expect(called).to.equal(4); + + obj.off('myevent', onMyEvent); + + obj.emit('myevent'); + + expect(called).to.equal(4); + }); + + it('handles multiple instances with the same prototype', function () { + var called = 0; + + function onMyEvent(e) { + called++; + } + + obj.on('myevent1', onMyEvent); + obj.on('myevent2', onMyEvent); + + obj2.istwo = true; + obj2.on('myevent1', onMyEvent); + obj2.on('myevent2', onMyEvent); + + obj.emit('myevent1'); + obj.emit('myevent2'); + obj2.emit('myevent1'); + obj2.emit('myevent2'); + + //we emit 4 times, but since obj2 is a child of obj the event should bubble + //up to obj and show up there as well. So the obj2.emit() calls each increment + //the counter twice. + expect(called).to.equal(6); + }); + + it('is backwards compatible with older .dispatchEvent({})', function () { + var called = 0, + data = { + some: 'thing', + hello: true + }; + + function onMyEvent(event) { + pixi_utils_EventTarget_Event_confirm(event, obj, data); + + called++; + } + + obj.on('myevent1', onMyEvent); + obj.on('myevent2', onMyEvent); + obj.on('myevent3', onMyEvent); + + data.type = 'myevent1'; + obj.emit(data); + + data.type = 'myevent2'; + obj.emit(data); + + data.type = 'myevent3'; + obj.emit(data); + + obj.off('myevent2', onMyEvent); + + data.type = 'myevent1'; + obj.emit(data); + + data.type = 'myevent2'; + obj.emit(data); + + data.type = 'myevent3'; + obj.emit(data); + + expect(called).to.equal(5); + }); + + it('is backwards compatible with older .call(this)', function () { + var Fn = function() { + PIXI.EventTarget.call(this); + }, + o = new Fn(); + + pixi_utils_EventTarget_confirm(o); + }); + + it('is backwards compatible with older .addEventListener("")', function () { + var called = 0, + data = { + some: 'thing', + hello: true + }; + + function onMyEvent(event) { + pixi_utils_EventTarget_Event_confirm(event, obj, data); + + called++; + } + + obj.addEventListener('myevent1', onMyEvent); + obj.addEventListener('myevent2', onMyEvent); + obj.addEventListener('myevent3', onMyEvent); + + data.type = 'myevent1'; + obj.emit(data); + + data.type = 'myevent2'; + obj.emit(data); + + data.type = 'myevent3'; + obj.emit(data); + + obj.off('myevent2', onMyEvent); + + data.type = 'myevent1'; + obj.emit(data); + + data.type = 'myevent2'; + obj.emit(data); + + data.type = 'myevent3'; + obj.emit(data); + + expect(called).to.equal(5); + }); + + it('event remove during emit call properly', function () { + var called = 0; + + function cb1() { + called++; + obj.off('myevent', cb1); + } + function cb2() { + called++; + obj.off('myevent', cb2); + } + function cb3() { + called++; + obj.off('myevent', cb3); + } + + obj.on('myevent', cb1); + obj.on('myevent', cb2); + obj.on('myevent', cb3); + obj.emit('myevent', ''); + + expect(called).to.equal(3); + }); +}); diff --git a/test/unit/pixi-v2/utils/Polyk.js b/test/unit/pixi-v2/utils/Polyk.js new file mode 100644 index 0000000..dfc7128 --- /dev/null +++ b/test/unit/pixi-v2/utils/Polyk.js @@ -0,0 +1,14 @@ +describe('pixi/utils/Polyk', function () { + 'use strict'; + + var expect = chai.expect; + var PolyK = PIXI.PolyK; + + it('Module exists', function () { + expect(PolyK).to.be.an('object'); + }); + + it('Members exist', function () { + expect(PolyK).to.respondTo('Triangulate'); + }); +}); diff --git a/test/unit/pixi-v2/utils/Utils.js b/test/unit/pixi-v2/utils/Utils.js new file mode 100644 index 0000000..c97b3c6 --- /dev/null +++ b/test/unit/pixi-v2/utils/Utils.js @@ -0,0 +1,17 @@ +describe('Utils', function () { + 'use strict'; + + var expect = chai.expect; + + it('requestAnimationFrame exists', function () { + expect(global).to.respondTo('requestAnimationFrame'); + }); + + it('cancelAnimationFrame exists', function () { + expect(global).to.respondTo('cancelAnimationFrame'); + }); + + it('requestAnimFrame exists', function () { + expect(global).to.respondTo('requestAnimFrame'); + }); +}); diff --git a/test/unit/pixi/InteractionManager.js b/test/unit/pixi/InteractionManager.js deleted file mode 100644 index ed3001f..0000000 --- a/test/unit/pixi/InteractionManager.js +++ /dev/null @@ -1,10 +0,0 @@ -describe('pixi/InteractionManager', function () { - 'use strict'; - - var expect = chai.expect; - var InteractionManager = PIXI.InteractionManager; - - it('Module exists', function () { - expect(InteractionManager).to.be.a('function'); - }); -}); diff --git a/test/unit/pixi/Pixi.js b/test/unit/pixi/Pixi.js deleted file mode 100644 index 27debc1..0000000 --- a/test/unit/pixi/Pixi.js +++ /dev/null @@ -1,9 +0,0 @@ -describe('pixi/Pixi', function () { - 'use strict'; - - var expect = chai.expect; - - it('Module exists', function () { - expect(global).to.have.property('PIXI').and.to.be.an('object'); - }); -}); diff --git a/test/unit/pixi/core/Circle.js b/test/unit/pixi/core/Circle.js deleted file mode 100644 index fbcfa17..0000000 --- a/test/unit/pixi/core/Circle.js +++ /dev/null @@ -1,21 +0,0 @@ -describe('pixi/core/Circle', function () { - 'use strict'; - - var expect = chai.expect; - var Circle = PIXI.Circle; - - it('Module exists', function () { - expect(Circle).to.be.a('function'); - }); - - it('Confirm new instance', function () { - var obj = new Circle(); - pixi_core_Circle_confirmNewCircle(obj); - }); - - it("getBounds should return Rectangle that bounds the circle", function() { - var obj = new Circle(100, 250, 50); - var bounds = obj.getBounds(); - pixi_core_Circle_isBoundedByRectangle(obj, bounds); - }); -}); diff --git a/test/unit/pixi/core/Ellipse.js b/test/unit/pixi/core/Ellipse.js deleted file mode 100644 index 026b56f..0000000 --- a/test/unit/pixi/core/Ellipse.js +++ /dev/null @@ -1,24 +0,0 @@ -describe('pixi/core/Ellipse', function () { - 'use strict'; - - var expect = chai.expect; - var Ellipse = PIXI.Ellipse; - - it('Module exists', function () { - expect(Ellipse).to.be.a('function'); - }); - - it('Confirm new instance', function () { - var obj = new Ellipse(); - - expect(obj).to.be.an.instanceof(Ellipse); - expect(obj).to.respondTo('clone'); - expect(obj).to.respondTo('contains'); - expect(obj).to.respondTo('getBounds'); - - expect(obj).to.have.property('x', 0); - expect(obj).to.have.property('y', 0); - expect(obj).to.have.property('width', 0); - expect(obj).to.have.property('height', 0); - }); -}); diff --git a/test/unit/pixi/core/Matrix.js b/test/unit/pixi/core/Matrix.js deleted file mode 100644 index da75e2e..0000000 --- a/test/unit/pixi/core/Matrix.js +++ /dev/null @@ -1,14 +0,0 @@ -describe('pixi/core/Matrix', function () { - 'use strict'; - - var expect = chai.expect; - - it('Matrix exists', function () { - expect(PIXI.Matrix).to.be.an('function'); - }); - - it('Confirm new Matrix', function () { - var matrix = new PIXI.Matrix(); - pixi_core_Matrix_confirmNewMatrix(matrix); - }); -}); diff --git a/test/unit/pixi-v2/InteractionManager.js b/test/unit/pixi-v2/InteractionManager.js new file mode 100644 index 0000000..ed3001f --- /dev/null +++ b/test/unit/pixi-v2/InteractionManager.js @@ -0,0 +1,10 @@ +describe('pixi/InteractionManager', function () { + 'use strict'; + + var expect = chai.expect; + var InteractionManager = PIXI.InteractionManager; + + it('Module exists', function () { + expect(InteractionManager).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/Pixi.js b/test/unit/pixi-v2/Pixi.js new file mode 100644 index 0000000..27debc1 --- /dev/null +++ b/test/unit/pixi-v2/Pixi.js @@ -0,0 +1,9 @@ +describe('pixi/Pixi', function () { + 'use strict'; + + var expect = chai.expect; + + it('Module exists', function () { + expect(global).to.have.property('PIXI').and.to.be.an('object'); + }); +}); diff --git a/test/unit/pixi-v2/core/Circle.js b/test/unit/pixi-v2/core/Circle.js new file mode 100644 index 0000000..fbcfa17 --- /dev/null +++ b/test/unit/pixi-v2/core/Circle.js @@ -0,0 +1,21 @@ +describe('pixi/core/Circle', function () { + 'use strict'; + + var expect = chai.expect; + var Circle = PIXI.Circle; + + it('Module exists', function () { + expect(Circle).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Circle(); + pixi_core_Circle_confirmNewCircle(obj); + }); + + it("getBounds should return Rectangle that bounds the circle", function() { + var obj = new Circle(100, 250, 50); + var bounds = obj.getBounds(); + pixi_core_Circle_isBoundedByRectangle(obj, bounds); + }); +}); diff --git a/test/unit/pixi-v2/core/Ellipse.js b/test/unit/pixi-v2/core/Ellipse.js new file mode 100644 index 0000000..026b56f --- /dev/null +++ b/test/unit/pixi-v2/core/Ellipse.js @@ -0,0 +1,24 @@ +describe('pixi/core/Ellipse', function () { + 'use strict'; + + var expect = chai.expect; + var Ellipse = PIXI.Ellipse; + + it('Module exists', function () { + expect(Ellipse).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Ellipse(); + + expect(obj).to.be.an.instanceof(Ellipse); + expect(obj).to.respondTo('clone'); + expect(obj).to.respondTo('contains'); + expect(obj).to.respondTo('getBounds'); + + expect(obj).to.have.property('x', 0); + expect(obj).to.have.property('y', 0); + expect(obj).to.have.property('width', 0); + expect(obj).to.have.property('height', 0); + }); +}); diff --git a/test/unit/pixi-v2/core/Matrix.js b/test/unit/pixi-v2/core/Matrix.js new file mode 100644 index 0000000..da75e2e --- /dev/null +++ b/test/unit/pixi-v2/core/Matrix.js @@ -0,0 +1,14 @@ +describe('pixi/core/Matrix', function () { + 'use strict'; + + var expect = chai.expect; + + it('Matrix exists', function () { + expect(PIXI.Matrix).to.be.an('function'); + }); + + it('Confirm new Matrix', function () { + var matrix = new PIXI.Matrix(); + pixi_core_Matrix_confirmNewMatrix(matrix); + }); +}); diff --git a/test/unit/pixi-v2/core/Point.js b/test/unit/pixi-v2/core/Point.js new file mode 100644 index 0000000..c4d5163 --- /dev/null +++ b/test/unit/pixi-v2/core/Point.js @@ -0,0 +1,15 @@ +describe('pixi/core/Point', function () { + 'use strict'; + + var expect = chai.expect; + var Point = PIXI.Point; + + it('Module exists', function () { + expect(Point).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Point(); + pixi_core_Point_confirm(obj, 0, 0); + }); +}); diff --git a/test/unit/pixi-v2/core/Polygon.js b/test/unit/pixi-v2/core/Polygon.js new file mode 100644 index 0000000..dc8c918 --- /dev/null +++ b/test/unit/pixi-v2/core/Polygon.js @@ -0,0 +1,20 @@ +describe('pixi/core/Polygon', function () { + 'use strict'; + + var expect = chai.expect; + var Polygon = PIXI.Polygon; + + it('Module exists', function () { + expect(Polygon).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Polygon(); + + expect(obj).to.be.an.instanceof(Polygon); + expect(obj).to.respondTo('clone'); + expect(obj).to.respondTo('contains'); + + expect(obj).to.have.deep.property('points.length', 0); + }); +}); diff --git a/test/unit/pixi-v2/core/Rectangle.js b/test/unit/pixi-v2/core/Rectangle.js new file mode 100644 index 0000000..d43316e --- /dev/null +++ b/test/unit/pixi-v2/core/Rectangle.js @@ -0,0 +1,15 @@ +describe('pixi/core/Rectangle', function () { + 'use strict'; + + var expect = chai.expect; + var Rectangle = PIXI.Rectangle; + + it('Module exists', function () { + expect(Rectangle).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var rect = new Rectangle(); + pixi_core_Rectangle_confirm(rect, 0, 0, 0, 0); + }); +}); diff --git a/test/unit/pixi-v2/display/DisplayObject.js b/test/unit/pixi-v2/display/DisplayObject.js new file mode 100644 index 0000000..044acf8 --- /dev/null +++ b/test/unit/pixi-v2/display/DisplayObject.js @@ -0,0 +1,21 @@ +describe('pixi/display/DisplayObject', function () { + 'use strict'; + + var expect = chai.expect; + var DisplayObject = PIXI.DisplayObject; + + it('Module exists', function () { + expect(DisplayObject).to.be.a('function'); + // expect(PIXI).to.have.property('visibleCount', 0); + }); + + it('Confirm new instance', function () { + var obj = new DisplayObject(); + + pixi_display_DisplayObject_confirmNew(obj); + expect(obj).to.have.property('hitArea', null); + expect(obj).to.have.property('interactive', false); + expect(obj).to.have.property('renderable', false); + expect(obj).to.have.property('stage', null); + }); +}); diff --git a/test/unit/pixi-v2/display/DisplayObjectContainer.js b/test/unit/pixi-v2/display/DisplayObjectContainer.js new file mode 100644 index 0000000..15a3376 --- /dev/null +++ b/test/unit/pixi-v2/display/DisplayObjectContainer.js @@ -0,0 +1,67 @@ +describe('pixi/display/DisplayObjectContainer', function () { + 'use strict'; + + var expect = chai.expect; + var DisplayObjectContainer = PIXI.DisplayObjectContainer; + + it('Module exists', function () { + expect(DisplayObjectContainer).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new DisplayObjectContainer(); + + pixi_display_DisplayObjectContainer_confirmNew(obj); + expect(obj).to.have.property('hitArea', null); + expect(obj).to.have.property('interactive', false); + expect(obj).to.have.property('renderable', false); + expect(obj).to.have.property('stage', null); + }); + + it('Gets child index', function() { + var container = new PIXI.DisplayObjectContainer(); + var children = []; + for (var i = 0; i < 10; i++) { + var child = new PIXI.DisplayObject(); + children.push(child); + container.addChild(child); + } + + for (i = 0; i < children.length; i++) { + expect(i).to.eql(container.getChildIndex(children[i])); + } + }); + + it('throws error when trying to get index of not a child', function() { + var container = new PIXI.DisplayObjectContainer(); + var child = new PIXI.DisplayObject(); + + expect(function() { container.getChildIndex(child); }).to.throw(); + }); + + it('Sets child index', function() { + var container = new PIXI.DisplayObjectContainer(); + var children = []; + + for (var i = 0; i < 10; i++) { + var child = new PIXI.DisplayObject(); + children.push(child); + container.addChild(child); + } + children.reverse(); + + for (i = 0; i < children.length; i++) { + container.setChildIndex(children[i], i); + expect(i).to.eql(container.getChildIndex(children[i])); + } + }); + + it('throws error when trying to set incorect index', function() { + var container = new PIXI.DisplayObjectContainer(); + var child = new PIXI.DisplayObject(); + container.addChild(child); + + expect(function() { container.setChildIndex(child, -1); }).to.throw(); + expect(function() { container.setChildIndex(child, 1); }).to.throw(); + }); +}); diff --git a/test/unit/pixi-v2/display/MovieClip.js b/test/unit/pixi-v2/display/MovieClip.js new file mode 100644 index 0000000..f3c6c6a --- /dev/null +++ b/test/unit/pixi-v2/display/MovieClip.js @@ -0,0 +1,33 @@ +describe('pixi/display/MovieClip', function () { + 'use strict'; + + var expect = chai.expect; + var MovieClip = PIXI.MovieClip; + var Texture = PIXI.Texture; + + it('Module exists', function () { + expect(MovieClip).to.be.a('function'); + }); + + it('Confirm new instance', function (done) { + var texture = Texture.fromImage('/base/test/textures/SpriteSheet-Explosion.png'); + var obj = new MovieClip([texture]); + + pixi_display_Sprite_confirmNew(obj, done); + + expect(obj).to.be.an.instanceof(MovieClip); + expect(obj).to.respondTo('stop'); + expect(obj).to.respondTo('play'); + expect(obj).to.respondTo('gotoAndStop'); + expect(obj).to.respondTo('gotoAndPlay'); + expect(obj).to.respondTo('updateTransform'); + + expect(obj).to.have.deep.property('textures.length', 1); + expect(obj).to.have.deep.property('textures[0]', texture); + expect(obj).to.have.property('animationSpeed', 1); + expect(obj).to.have.property('loop', true); + expect(obj).to.have.property('onComplete', null); + expect(obj).to.have.property('currentFrame', 0); + expect(obj).to.have.property('playing', false); + }); +}); diff --git a/test/unit/pixi-v2/display/Sprite.js b/test/unit/pixi-v2/display/Sprite.js new file mode 100644 index 0000000..30c8076 --- /dev/null +++ b/test/unit/pixi-v2/display/Sprite.js @@ -0,0 +1,28 @@ +describe('pixi/display/Sprite', function () { + 'use strict'; + + var expect = chai.expect; + var Sprite = PIXI.Sprite; + var Texture = PIXI.Texture; + + it('Module exists', function () { + expect(Sprite).to.be.a('function'); + expect(PIXI).to.have.deep.property('blendModes.NORMAL', 0); + expect(PIXI).to.have.deep.property('blendModes.ADD', 1); + expect(PIXI).to.have.deep.property('blendModes.MULTIPLY', 2); + expect(PIXI).to.have.deep.property('blendModes.SCREEN', 3); + }); + + + it('Members exist', function () { + expect(Sprite).itself.to.respondTo('fromImage'); + expect(Sprite).itself.to.respondTo('fromFrame'); + }); + + it('Confirm new instance', function (done) { + var texture = Texture.fromImage('/base/test/textures/SpriteSheet-Aliens.png'); + var obj = new Sprite(texture); + + pixi_display_Sprite_confirmNew(obj, done); + }); +}); diff --git a/test/unit/pixi-v2/display/Stage.js b/test/unit/pixi-v2/display/Stage.js new file mode 100644 index 0000000..6974c2e --- /dev/null +++ b/test/unit/pixi-v2/display/Stage.js @@ -0,0 +1,49 @@ +describe('pixi/display/Stage', function () { + 'use strict'; + + var expect = chai.expect; + var Stage = PIXI.Stage; + var InteractionManager = PIXI.InteractionManager; + var Rectangle = PIXI.Rectangle; + + it('Module exists', function () { + expect(Stage).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Stage(null, true); + + pixi_display_DisplayObjectContainer_confirmNew(obj); + + expect(obj).to.be.an.instanceof(Stage); + expect(obj).to.respondTo('updateTransform'); + expect(obj).to.respondTo('setBackgroundColor'); + expect(obj).to.respondTo('getMousePosition'); + // FIXME: duplicate member in DisplayObject + pixi_core_Matrix_confirmNewMatrix(obj.worldTransform); + // FIXME: convert arg to bool in constructor + expect(obj).to.have.property('interactive', true); + + expect(obj).to.have.property('interactionManager') + .and.to.be.an.instanceof(InteractionManager) + .and.to.have.property('stage', obj); + + expect(obj).to.have.property('dirty', true); + + expect(obj).to.have.property('stage', obj); + + expect(obj).to.have.property('hitArea') + .and.to.be.an.instanceof(Rectangle); + pixi_core_Rectangle_confirm(obj.hitArea, 0, 0, 100000, 100000); + + expect(obj).to.have.property('backgroundColor', 0x000000); + expect(obj).to.have.deep.property('backgroundColorSplit.length', 3); + expect(obj).to.have.deep.property('backgroundColorSplit[0]', 0); + expect(obj).to.have.deep.property('backgroundColorSplit[1]', 0); + expect(obj).to.have.deep.property('backgroundColorSplit[2]', 0); + expect(obj).to.have.property('backgroundColorString', '#000000'); + + + expect(obj).to.have.property('worldVisible', true); + }); +}); diff --git a/test/unit/pixi-v2/extras/Rope.js b/test/unit/pixi-v2/extras/Rope.js new file mode 100644 index 0000000..05885ac --- /dev/null +++ b/test/unit/pixi-v2/extras/Rope.js @@ -0,0 +1,31 @@ +describe('pixi/extras/Rope', function () { + 'use strict'; + + var expect = chai.expect; + var Rope = PIXI.Rope; + var Texture = PIXI.Texture; + var Point = PIXI.Point; + + it('Module exists', function () { + expect(Rope).to.be.a('function'); + }); + + it('Confirm new instance', function () { + + var texture = Texture.fromImage('/base/test/textures/bunny.png'); + + // TODO-Alvin + // Same as Strip + + // var obj = new Rope(texture, [new Point(), new Point(5, 10), new Point(10, 20)]); + + // pixi_extras_Strip_confirmNew(obj); + + // expect(obj).to.be.an.instanceof(Rope); + // expect(obj).to.respondTo('refresh'); + // expect(obj).to.respondTo('updateTransform'); + // expect(obj).to.respondTo('setTexture'); + + // TODO: Test properties + }); +}); diff --git a/test/unit/pixi-v2/extras/Spine.js b/test/unit/pixi-v2/extras/Spine.js new file mode 100644 index 0000000..0708bc0 --- /dev/null +++ b/test/unit/pixi-v2/extras/Spine.js @@ -0,0 +1,10 @@ +describe('pixi/extras/Spine', function () { + 'use strict'; + + var expect = chai.expect; + var Spine = PIXI.Spine; + + it('Module exists', function () { + expect(Spine).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/extras/Strip.js b/test/unit/pixi-v2/extras/Strip.js new file mode 100644 index 0000000..230af90 --- /dev/null +++ b/test/unit/pixi-v2/extras/Strip.js @@ -0,0 +1,26 @@ +describe('pixi/extras/Strip', function () { + 'use strict'; + + var expect = chai.expect; + var Strip = PIXI.Strip; + var Texture = PIXI.Texture; + + it('Module exists', function () { + expect(Strip).to.be.a('function'); + }); + + it('Confirm new instance', function () { + + + // TODO-Alvin + // We tweaked it to make it pass the tests, but the whole strip class needs + // to be re-coded + + var texture = Texture.fromImage('/base/test/textures/bunny.png'); + + // var obj = new Strip(texture, 20, 10000); + + + // pixi_extras_Strip_confirmNew(obj); + }); +}); diff --git a/test/unit/pixi-v2/extras/TilingSprite.js b/test/unit/pixi-v2/extras/TilingSprite.js new file mode 100644 index 0000000..56aea14 --- /dev/null +++ b/test/unit/pixi-v2/extras/TilingSprite.js @@ -0,0 +1,24 @@ +describe('pixi/extras/TilingSprite', function () { + 'use strict'; + + var expect = chai.expect; + var TilingSprite = PIXI.TilingSprite; + var Texture = PIXI.Texture; + + it('Module exists', function () { + expect(TilingSprite).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var texture = Texture.fromImage('/base/test/textures/bunny.png'); + var obj = new TilingSprite(texture, 6000, 12000); + + pixi_display_DisplayObjectContainer_confirmNew(obj); + + expect(obj).to.be.an.instanceof(TilingSprite); + expect(obj).to.respondTo('setTexture'); + expect(obj).to.respondTo('onTextureUpdate'); + + // TODO: Test properties + }); +}); diff --git a/test/unit/pixi-v2/filters/FilterBlock.js b/test/unit/pixi-v2/filters/FilterBlock.js new file mode 100644 index 0000000..870cec0 --- /dev/null +++ b/test/unit/pixi-v2/filters/FilterBlock.js @@ -0,0 +1,10 @@ +describe('pixi/filters/FilterBlock', function () { + 'use strict'; + + var expect = chai.expect; + var FilterBlock = PIXI.FilterBlock; + + it('Module exists', function () { + expect(FilterBlock).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/AssetLoader.js b/test/unit/pixi-v2/loaders/AssetLoader.js new file mode 100644 index 0000000..a0aa0b5 --- /dev/null +++ b/test/unit/pixi-v2/loaders/AssetLoader.js @@ -0,0 +1,10 @@ +describe('pixi/loaders/AssetLoader', function () { + 'use strict'; + + var expect = chai.expect; + var AssetLoader = PIXI.AssetLoader; + + it('Module exists', function () { + expect(AssetLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/BitmapFontLoader.js b/test/unit/pixi-v2/loaders/BitmapFontLoader.js new file mode 100644 index 0000000..046f018 --- /dev/null +++ b/test/unit/pixi-v2/loaders/BitmapFontLoader.js @@ -0,0 +1,9 @@ +describe('pixi/loaders/BitmapFontLoader', function () { + 'use strict'; + + var expect = chai.expect; + + it('Module exists', function () { + expect(PIXI.BitmapFontLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/ImageLoader.js b/test/unit/pixi-v2/loaders/ImageLoader.js new file mode 100644 index 0000000..8b1f556 --- /dev/null +++ b/test/unit/pixi-v2/loaders/ImageLoader.js @@ -0,0 +1,10 @@ +describe('pixi/loaders/ImageLoader', function () { + 'use strict'; + + var expect = chai.expect; + var ImageLoader = PIXI.ImageLoader; + + it('Module exists', function () { + expect(ImageLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/JsonLoader.js b/test/unit/pixi-v2/loaders/JsonLoader.js new file mode 100644 index 0000000..c577e83 --- /dev/null +++ b/test/unit/pixi-v2/loaders/JsonLoader.js @@ -0,0 +1,10 @@ +describe('pixi/loaders/JsonLoader', function () { + 'use strict'; + + var expect = chai.expect; + var JsonLoader = PIXI.JsonLoader; + + it('Module exists', function () { + expect(JsonLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/SpineLoader.js b/test/unit/pixi-v2/loaders/SpineLoader.js new file mode 100644 index 0000000..fdcc0b8 --- /dev/null +++ b/test/unit/pixi-v2/loaders/SpineLoader.js @@ -0,0 +1,10 @@ +describe('pixi/loaders/SpineLoader', function () { + 'use strict'; + + var expect = chai.expect; + var SpineLoader = PIXI.SpineLoader; + + it('Module exists', function () { + expect(SpineLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/SpriteSheetLoader.js b/test/unit/pixi-v2/loaders/SpriteSheetLoader.js new file mode 100644 index 0000000..57beb27 --- /dev/null +++ b/test/unit/pixi-v2/loaders/SpriteSheetLoader.js @@ -0,0 +1,10 @@ +describe('pixi/loaders/SpriteSheetLoader', function () { + 'use strict'; + + var expect = chai.expect; + var SpriteSheetLoader = PIXI.SpriteSheetLoader; + + it('Module exists', function () { + expect(SpriteSheetLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/primitives/Graphics.js b/test/unit/pixi-v2/primitives/Graphics.js new file mode 100644 index 0000000..f3849eb --- /dev/null +++ b/test/unit/pixi-v2/primitives/Graphics.js @@ -0,0 +1,44 @@ +describe('pixi/primitives/Graphics', function () { + 'use strict'; + + var expect = chai.expect; + var Graphics = PIXI.Graphics; + + it('Module exists', function () { + expect(Graphics).to.be.a('function'); + + expect(Graphics).itself.to.have.property('POLY', 0); + expect(Graphics).itself.to.have.property('RECT', 1); + expect(Graphics).itself.to.have.property('CIRC', 2); + expect(Graphics).itself.to.have.property('ELIP', 3); + expect(Graphics).itself.to.have.property('RREC', 4); + }); + + it('Confirm new instance', function () { + var obj = new Graphics(); + + pixi_display_DisplayObjectContainer_confirmNew(obj); + + expect(obj).to.be.an.instanceof(Graphics); + expect(obj).to.respondTo('lineStyle'); + expect(obj).to.respondTo('lineStyle'); + expect(obj).to.respondTo('moveTo'); + expect(obj).to.respondTo('lineTo'); + expect(obj).to.respondTo('beginFill'); + expect(obj).to.respondTo('endFill'); + expect(obj).to.respondTo('drawRect'); + // expect(obj).to.respondTo('drawRoundedRect'); + expect(obj).to.respondTo('drawCircle'); + expect(obj).to.respondTo('drawEllipse'); + expect(obj).to.respondTo('clear'); + + expect(obj).to.have.property('renderable', true); + expect(obj).to.have.property('fillAlpha', 1); + expect(obj).to.have.property('lineWidth', 0); + expect(obj).to.have.property('width', 0); + expect(obj).to.have.property('height', 0); + expect(obj).to.have.property('lineColor', 0); + expect(obj).to.have.deep.property('graphicsData.length', 0); + // expect(obj).to.have.deep.property('currentPath.points.length', 0); + }); +}); diff --git a/test/unit/pixi-v2/renderers/canvas/CanvasGraphics.js b/test/unit/pixi-v2/renderers/canvas/CanvasGraphics.js new file mode 100644 index 0000000..8f44472 --- /dev/null +++ b/test/unit/pixi-v2/renderers/canvas/CanvasGraphics.js @@ -0,0 +1,15 @@ +describe('renders/canvas/CanvasGraphics', function () { + 'use strict'; + + var expect = chai.expect; + var CanvasGraphics = PIXI.CanvasGraphics; + + it('Module exists', function () { + expect(CanvasGraphics).to.be.a('function'); + }); + + it('Members exist', function () { + expect(CanvasGraphics).itself.to.respondTo('renderGraphics'); + expect(CanvasGraphics).itself.to.respondTo('renderGraphicsMask'); + }); +}); diff --git a/test/unit/pixi-v2/renderers/canvas/CanvasRenderer.js b/test/unit/pixi-v2/renderers/canvas/CanvasRenderer.js new file mode 100644 index 0000000..1646444 --- /dev/null +++ b/test/unit/pixi-v2/renderers/canvas/CanvasRenderer.js @@ -0,0 +1,36 @@ +describe('renderers/canvas/CanvasRenderer', function () { + 'use strict'; + + var expect = chai.expect; + var CanvasRenderer = PIXI.CanvasRenderer; + + it('Module exists', function () { + expect(CanvasRenderer).to.be.a('function'); + }); + + describe('.autoResize', function () { + it('Should automatically resize view if enabled', function () { + var renderer = new CanvasRenderer(200, 200, { + autoResize: true + }); + + expect(renderer.view.style.width).to.equal('200px'); + }); + + it('Should not automatically resize view if disabled', function () { + var renderer = new CanvasRenderer(200, 200, { + autoResize: false + }); + + expect(renderer.view.style.width).to.equal(''); + }); + + it('Should not automatically resize view if not specified', function () { + var renderer = new CanvasRenderer(200, 200, { + resolution: 2 + }); + + expect(renderer.view.style.width).to.equal(''); + }); + }); +}); diff --git a/test/unit/pixi-v2/renderers/webgl/WebGLGraphics.js b/test/unit/pixi-v2/renderers/webgl/WebGLGraphics.js new file mode 100644 index 0000000..5867b28 --- /dev/null +++ b/test/unit/pixi-v2/renderers/webgl/WebGLGraphics.js @@ -0,0 +1,20 @@ +describe('renderers/wegbl/WebGLGraphics', function () { + 'use strict'; + + var expect = chai.expect; + var WebGLGraphics = PIXI.WebGLGraphics; + + it('Module exists', function () { + expect(WebGLGraphics).to.be.a('function'); + }); + + it('Members exist', function () { + expect(WebGLGraphics).itself.to.respondTo('renderGraphics'); + expect(WebGLGraphics).itself.to.respondTo('updateGraphics'); + expect(WebGLGraphics).itself.to.respondTo('buildRectangle'); + expect(WebGLGraphics).itself.to.respondTo('buildRoundedRectangle'); + expect(WebGLGraphics).itself.to.respondTo('buildCircle'); + expect(WebGLGraphics).itself.to.respondTo('buildLine'); + expect(WebGLGraphics).itself.to.respondTo('buildPoly'); + }); +}); diff --git a/test/unit/pixi-v2/renderers/webgl/WebGLRenderer.js b/test/unit/pixi-v2/renderers/webgl/WebGLRenderer.js new file mode 100644 index 0000000..1680a80 --- /dev/null +++ b/test/unit/pixi-v2/renderers/webgl/WebGLRenderer.js @@ -0,0 +1,49 @@ +describe('renderers/webgl/WebGLRenderer', function () { + 'use strict'; + + var expect = chai.expect; + var WebGLRenderer = PIXI.WebGLRenderer; + + it('Module exists', function () { + expect(WebGLRenderer).to.be.a('function'); + }); + + // Skip tests if WebGL is not available (WebGL not supported in Travis CI) + try { + var renderer = new WebGLRenderer(400, 300, {}); + renderer.destroy(); + } catch (error) { + return; + } + + it('Destroy renderer', function () { + var renderer = new WebGLRenderer(400, 300, {}); + renderer.destroy(); + }); + + describe('.autoResize', function () { + it('Should automatically resize view if enabled', function () { + var renderer = new WebGLRenderer(200, 200, { + autoResize: true + }); + + expect(renderer.view.style.width).to.equal('200px'); + }); + + it('Should not automatically resize view if disabled', function () { + var renderer = new WebGLRenderer(200, 200, { + autoResize: false + }); + + expect(renderer.view.style.width).to.equal(''); + }); + + it('Should not automatically resize view if not specified', function () { + var renderer = new WebGLRenderer(200, 200, { + resolution: 2 + }); + + expect(renderer.view.style.width).to.equal(''); + }); + }); +}); diff --git a/test/unit/pixi-v2/renderers/webgl/WebGLShaders.js b/test/unit/pixi-v2/renderers/webgl/WebGLShaders.js new file mode 100644 index 0000000..6e33e4f --- /dev/null +++ b/test/unit/pixi-v2/renderers/webgl/WebGLShaders.js @@ -0,0 +1,13 @@ +describe('renderers/webgl/WebGLShaders', function () { + 'use strict'; + + var expect = chai.expect; + + it('Module members exist', function () { + + expect(PIXI).to.respondTo('CompileVertexShader'); + expect(PIXI).to.respondTo('CompileFragmentShader'); + expect(PIXI).to.respondTo('_CompileShader'); + expect(PIXI).to.respondTo('compileProgram'); + }); +}); diff --git a/test/unit/pixi-v2/renderers/webgl/WebGLSpriteBatch.js b/test/unit/pixi-v2/renderers/webgl/WebGLSpriteBatch.js new file mode 100644 index 0000000..e662b63 --- /dev/null +++ b/test/unit/pixi-v2/renderers/webgl/WebGLSpriteBatch.js @@ -0,0 +1,10 @@ +describe('renderers/webgl/utils/WebGLSpriteBatch', function () { + 'use strict'; + + var expect = chai.expect; + var WebGLSpriteBatch = PIXI.WebGLSpriteBatch; + + it('Module exists', function () { + expect(WebGLSpriteBatch).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/text/BitmapText.js b/test/unit/pixi-v2/text/BitmapText.js new file mode 100644 index 0000000..9388e3d --- /dev/null +++ b/test/unit/pixi-v2/text/BitmapText.js @@ -0,0 +1,10 @@ +describe('pixi/text/BitmapText', function () { + 'use strict'; + + var expect = chai.expect; + var BitmapText = PIXI.BitmapText; + + it('Module exists', function () { + expect(BitmapText).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/text/Text.js b/test/unit/pixi-v2/text/Text.js new file mode 100644 index 0000000..9bc9ac5 --- /dev/null +++ b/test/unit/pixi-v2/text/Text.js @@ -0,0 +1,10 @@ +describe('pixi/text/Text', function () { + 'use strict'; + + var expect = chai.expect; + var Text = PIXI.Text; + + it('Module exists', function () { + expect(Text).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/textures/BaseTexture.js b/test/unit/pixi-v2/textures/BaseTexture.js new file mode 100644 index 0000000..502b724 --- /dev/null +++ b/test/unit/pixi-v2/textures/BaseTexture.js @@ -0,0 +1,11 @@ +describe('pixi/textures/BaseTexture', function () { + 'use strict'; + + var expect = chai.expect; + var BaseTexture = PIXI.BaseTexture; + + it('Module exists', function () { + expect(BaseTexture).to.be.a('function'); + expect(PIXI).to.have.property('BaseTextureCache').and.to.be.an('object'); + }); +}); diff --git a/test/unit/pixi-v2/textures/RenderTexture.js b/test/unit/pixi-v2/textures/RenderTexture.js new file mode 100644 index 0000000..96acdb4 --- /dev/null +++ b/test/unit/pixi-v2/textures/RenderTexture.js @@ -0,0 +1,15 @@ +describe('pixi/textures/RenderTexture', function () { + 'use strict'; + + var expect = chai.expect; + var RenderTexture = PIXI.RenderTexture; + + it('Module exists', function () { + expect(RenderTexture).to.be.a('function'); + }); + + it('Confirm new instance', function (done) { + var texture = new RenderTexture(100, 100, new PIXI.CanvasRenderer()); + pixi_textures_RenderTexture_confirmNew(texture, done); + }); +}); diff --git a/test/unit/pixi-v2/textures/Texture.js b/test/unit/pixi-v2/textures/Texture.js new file mode 100644 index 0000000..090f64d --- /dev/null +++ b/test/unit/pixi-v2/textures/Texture.js @@ -0,0 +1,26 @@ +describe('pixi/textures/Texture', function () { + 'use strict'; + + var expect = chai.expect; + var Texture = PIXI.Texture; + + it('Module exists', function () { + expect(Texture).to.be.a('function'); + expect(PIXI).to.have.property('TextureCache').and.to.be.an('object'); + }); + + it('Members exist', function () { + expect(Texture).itself.to.respondTo('fromImage'); + expect(Texture).itself.to.respondTo('fromFrame'); + expect(Texture).itself.to.respondTo('fromCanvas'); + expect(Texture).itself.to.respondTo('addTextureToCache'); + expect(Texture).itself.to.respondTo('removeTextureFromCache'); + + // expect(Texture).itself.to.have.deep.property('frameUpdates.length', 0); + }); + + it('Confirm new instance', function (done) { + var texture = Texture.fromImage('/base/test/textures/bunny.png'); + pixi_textures_Texture_confirmNew(texture, done); + }); +}); diff --git a/test/unit/pixi-v2/utils/Detector.js b/test/unit/pixi-v2/utils/Detector.js new file mode 100644 index 0000000..4cf6008 --- /dev/null +++ b/test/unit/pixi-v2/utils/Detector.js @@ -0,0 +1,10 @@ +describe('pixi/utils/Detector', function () { + 'use strict'; + + var expect = chai.expect; + var autoDetectRenderer = PIXI.autoDetectRenderer; + + it('Module exists', function () { + expect(autoDetectRenderer).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/utils/EventTarget.js b/test/unit/pixi-v2/utils/EventTarget.js new file mode 100644 index 0000000..1cfc3a4 --- /dev/null +++ b/test/unit/pixi-v2/utils/EventTarget.js @@ -0,0 +1,361 @@ +describe('pixi/utils/EventTarget', function () { + 'use strict'; + + var expect = chai.expect; + + var Clazz, PClazz, obj, pobj, obj2; + beforeEach(function () { + Clazz = function () {}; + PClazz = function () {}; + + PIXI.EventTarget.mixin(Clazz.prototype); + PIXI.EventTarget.mixin(PClazz.prototype); + + obj = new Clazz(); + obj2 = new Clazz(); + pobj = new PClazz(); + + obj.parent = pobj; + obj2.parent = obj; + }); + + it('Module exists', function () { + expect(PIXI.EventTarget).to.be.an('object'); + }); + + it('Confirm new instance', function () { + pixi_utils_EventTarget_confirm(obj); + }); + + it('simple on/emit case works', function () { + var myData = {}; + + obj.on('myevent', function (event) { + pixi_utils_EventTarget_Event_confirm(event, obj, myData); + }); + + obj.emit('myevent', myData); + }); + + it('simple once case works', function () { + var called = 0; + + obj.once('myevent', function() { called++; }); + + obj.emit('myevent'); + obj.emit('myevent'); + obj.emit('myevent'); + obj.emit('myevent'); + obj.emit('myevent'); + + expect(called).to.equal(1); + }); + + it('simple off case works', function (done) { + function onMyEvent() { + done(new Error('Event listener should not have been called')); + } + + obj.on('myevent', onMyEvent); + obj.off('myevent', onMyEvent); + obj.emit('myevent'); + + done(); + }); + + it('simple propagation case works', function (done) { + var myData = {}; + + pobj.on('myevent', function () { + done(); + }); + + obj.emit('myevent'); + }); + + it('simple stopPropagation case works', function (done) { + var myData = {}; + + pobj.on('myevent', function () { + done(new Error('Event listener should not have been called on the parent element')); + }); + + obj.on('myevent', function (evt) { + evt.stopPropagation(); + }); + + obj.emit('myevent'); + + done(); + }); + + it('simple stopImmediatePropagation case works', function (done) { + var myData = {}; + + pobj.on('myevent', function () { + done(new Error('Event listener should not have been called on the parent')); + }); + + obj.on('myevent', function (evt) { + evt.stopImmediatePropagation(); + }); + + obj.on('myevent', function () { + done(new Error('Event listener should not have been called on the second')); + }); + + obj.emit('myevent'); + + done(); + }); + + it('multiple dispatches work properly', function () { + var called = 0; + + function onMyEvent() { + called++; + } + + obj.on('myevent', onMyEvent); + obj.emit('myevent'); + obj.emit('myevent'); + obj.emit('myevent'); + obj.emit('myevent'); + + expect(called).to.equal(4); + }); + + it('multiple events work properly', function () { + var called = 0; + + function onMyEvent() { + called++; + } + + obj.on('myevent1', onMyEvent); + obj.on('myevent2', onMyEvent); + obj.on('myevent3', onMyEvent); + obj.emit('myevent1'); + obj.emit('myevent2'); + obj.emit('myevent3'); + + expect(called).to.equal(3); + }); + + it('multiple events one removed works properly', function () { + var called = 0; + + function onMyEvent() { + called++; + } + + obj.on('myevent1', onMyEvent); + obj.on('myevent2', onMyEvent); + obj.on('myevent3', onMyEvent); + + obj.emit('myevent1'); + obj.emit('myevent2'); + obj.emit('myevent3'); + + obj.off('myevent2', onMyEvent); + + obj.emit('myevent1'); + obj.emit('myevent2'); + obj.emit('myevent3'); + + expect(called).to.equal(5); + }); + + it('multiple handlers for one event with some removed', function () { + var called = 0; + + var onMyEvent = function () { + called++; + }, + onMyEvent2 = function () { + called++; + }; + + // add 2 handlers and confirm they both get called + obj.on('myevent', onMyEvent); + obj.on('myevent', onMyEvent); + obj.on('myevent', onMyEvent2); + obj.on('myevent', onMyEvent2); + + obj.emit('myevent'); + + expect(called).to.equal(4); + + // remove one of the handlers, emit again, then ensure 1 more call is made + obj.off('myevent', onMyEvent); + + obj.emit('myevent'); + + expect(called).to.equal(6); + }); + + it('calls to off without a handler do nothing', function () { + var called = 0; + + var onMyEvent = function () { + called++; + }; + + obj.on('myevent', onMyEvent); + obj.on('myevent', onMyEvent); + + obj.emit('myevent'); + + expect(called).to.equal(2); + + obj.off('myevent'); + + obj.emit('myevent'); + + expect(called).to.equal(4); + + obj.off('myevent', onMyEvent); + + obj.emit('myevent'); + + expect(called).to.equal(4); + }); + + it('handles multiple instances with the same prototype', function () { + var called = 0; + + function onMyEvent(e) { + called++; + } + + obj.on('myevent1', onMyEvent); + obj.on('myevent2', onMyEvent); + + obj2.istwo = true; + obj2.on('myevent1', onMyEvent); + obj2.on('myevent2', onMyEvent); + + obj.emit('myevent1'); + obj.emit('myevent2'); + obj2.emit('myevent1'); + obj2.emit('myevent2'); + + //we emit 4 times, but since obj2 is a child of obj the event should bubble + //up to obj and show up there as well. So the obj2.emit() calls each increment + //the counter twice. + expect(called).to.equal(6); + }); + + it('is backwards compatible with older .dispatchEvent({})', function () { + var called = 0, + data = { + some: 'thing', + hello: true + }; + + function onMyEvent(event) { + pixi_utils_EventTarget_Event_confirm(event, obj, data); + + called++; + } + + obj.on('myevent1', onMyEvent); + obj.on('myevent2', onMyEvent); + obj.on('myevent3', onMyEvent); + + data.type = 'myevent1'; + obj.emit(data); + + data.type = 'myevent2'; + obj.emit(data); + + data.type = 'myevent3'; + obj.emit(data); + + obj.off('myevent2', onMyEvent); + + data.type = 'myevent1'; + obj.emit(data); + + data.type = 'myevent2'; + obj.emit(data); + + data.type = 'myevent3'; + obj.emit(data); + + expect(called).to.equal(5); + }); + + it('is backwards compatible with older .call(this)', function () { + var Fn = function() { + PIXI.EventTarget.call(this); + }, + o = new Fn(); + + pixi_utils_EventTarget_confirm(o); + }); + + it('is backwards compatible with older .addEventListener("")', function () { + var called = 0, + data = { + some: 'thing', + hello: true + }; + + function onMyEvent(event) { + pixi_utils_EventTarget_Event_confirm(event, obj, data); + + called++; + } + + obj.addEventListener('myevent1', onMyEvent); + obj.addEventListener('myevent2', onMyEvent); + obj.addEventListener('myevent3', onMyEvent); + + data.type = 'myevent1'; + obj.emit(data); + + data.type = 'myevent2'; + obj.emit(data); + + data.type = 'myevent3'; + obj.emit(data); + + obj.off('myevent2', onMyEvent); + + data.type = 'myevent1'; + obj.emit(data); + + data.type = 'myevent2'; + obj.emit(data); + + data.type = 'myevent3'; + obj.emit(data); + + expect(called).to.equal(5); + }); + + it('event remove during emit call properly', function () { + var called = 0; + + function cb1() { + called++; + obj.off('myevent', cb1); + } + function cb2() { + called++; + obj.off('myevent', cb2); + } + function cb3() { + called++; + obj.off('myevent', cb3); + } + + obj.on('myevent', cb1); + obj.on('myevent', cb2); + obj.on('myevent', cb3); + obj.emit('myevent', ''); + + expect(called).to.equal(3); + }); +}); diff --git a/test/unit/pixi-v2/utils/Polyk.js b/test/unit/pixi-v2/utils/Polyk.js new file mode 100644 index 0000000..dfc7128 --- /dev/null +++ b/test/unit/pixi-v2/utils/Polyk.js @@ -0,0 +1,14 @@ +describe('pixi/utils/Polyk', function () { + 'use strict'; + + var expect = chai.expect; + var PolyK = PIXI.PolyK; + + it('Module exists', function () { + expect(PolyK).to.be.an('object'); + }); + + it('Members exist', function () { + expect(PolyK).to.respondTo('Triangulate'); + }); +}); diff --git a/test/unit/pixi-v2/utils/Utils.js b/test/unit/pixi-v2/utils/Utils.js new file mode 100644 index 0000000..c97b3c6 --- /dev/null +++ b/test/unit/pixi-v2/utils/Utils.js @@ -0,0 +1,17 @@ +describe('Utils', function () { + 'use strict'; + + var expect = chai.expect; + + it('requestAnimationFrame exists', function () { + expect(global).to.respondTo('requestAnimationFrame'); + }); + + it('cancelAnimationFrame exists', function () { + expect(global).to.respondTo('cancelAnimationFrame'); + }); + + it('requestAnimFrame exists', function () { + expect(global).to.respondTo('requestAnimFrame'); + }); +}); diff --git a/test/unit/pixi/InteractionManager.js b/test/unit/pixi/InteractionManager.js deleted file mode 100644 index ed3001f..0000000 --- a/test/unit/pixi/InteractionManager.js +++ /dev/null @@ -1,10 +0,0 @@ -describe('pixi/InteractionManager', function () { - 'use strict'; - - var expect = chai.expect; - var InteractionManager = PIXI.InteractionManager; - - it('Module exists', function () { - expect(InteractionManager).to.be.a('function'); - }); -}); diff --git a/test/unit/pixi/Pixi.js b/test/unit/pixi/Pixi.js deleted file mode 100644 index 27debc1..0000000 --- a/test/unit/pixi/Pixi.js +++ /dev/null @@ -1,9 +0,0 @@ -describe('pixi/Pixi', function () { - 'use strict'; - - var expect = chai.expect; - - it('Module exists', function () { - expect(global).to.have.property('PIXI').and.to.be.an('object'); - }); -}); diff --git a/test/unit/pixi/core/Circle.js b/test/unit/pixi/core/Circle.js deleted file mode 100644 index fbcfa17..0000000 --- a/test/unit/pixi/core/Circle.js +++ /dev/null @@ -1,21 +0,0 @@ -describe('pixi/core/Circle', function () { - 'use strict'; - - var expect = chai.expect; - var Circle = PIXI.Circle; - - it('Module exists', function () { - expect(Circle).to.be.a('function'); - }); - - it('Confirm new instance', function () { - var obj = new Circle(); - pixi_core_Circle_confirmNewCircle(obj); - }); - - it("getBounds should return Rectangle that bounds the circle", function() { - var obj = new Circle(100, 250, 50); - var bounds = obj.getBounds(); - pixi_core_Circle_isBoundedByRectangle(obj, bounds); - }); -}); diff --git a/test/unit/pixi/core/Ellipse.js b/test/unit/pixi/core/Ellipse.js deleted file mode 100644 index 026b56f..0000000 --- a/test/unit/pixi/core/Ellipse.js +++ /dev/null @@ -1,24 +0,0 @@ -describe('pixi/core/Ellipse', function () { - 'use strict'; - - var expect = chai.expect; - var Ellipse = PIXI.Ellipse; - - it('Module exists', function () { - expect(Ellipse).to.be.a('function'); - }); - - it('Confirm new instance', function () { - var obj = new Ellipse(); - - expect(obj).to.be.an.instanceof(Ellipse); - expect(obj).to.respondTo('clone'); - expect(obj).to.respondTo('contains'); - expect(obj).to.respondTo('getBounds'); - - expect(obj).to.have.property('x', 0); - expect(obj).to.have.property('y', 0); - expect(obj).to.have.property('width', 0); - expect(obj).to.have.property('height', 0); - }); -}); diff --git a/test/unit/pixi/core/Matrix.js b/test/unit/pixi/core/Matrix.js deleted file mode 100644 index da75e2e..0000000 --- a/test/unit/pixi/core/Matrix.js +++ /dev/null @@ -1,14 +0,0 @@ -describe('pixi/core/Matrix', function () { - 'use strict'; - - var expect = chai.expect; - - it('Matrix exists', function () { - expect(PIXI.Matrix).to.be.an('function'); - }); - - it('Confirm new Matrix', function () { - var matrix = new PIXI.Matrix(); - pixi_core_Matrix_confirmNewMatrix(matrix); - }); -}); diff --git a/test/unit/pixi/core/Point.js b/test/unit/pixi/core/Point.js deleted file mode 100644 index c4d5163..0000000 --- a/test/unit/pixi/core/Point.js +++ /dev/null @@ -1,15 +0,0 @@ -describe('pixi/core/Point', function () { - 'use strict'; - - var expect = chai.expect; - var Point = PIXI.Point; - - it('Module exists', function () { - expect(Point).to.be.a('function'); - }); - - it('Confirm new instance', function () { - var obj = new Point(); - pixi_core_Point_confirm(obj, 0, 0); - }); -}); diff --git a/test/unit/pixi-v2/InteractionManager.js b/test/unit/pixi-v2/InteractionManager.js new file mode 100644 index 0000000..ed3001f --- /dev/null +++ b/test/unit/pixi-v2/InteractionManager.js @@ -0,0 +1,10 @@ +describe('pixi/InteractionManager', function () { + 'use strict'; + + var expect = chai.expect; + var InteractionManager = PIXI.InteractionManager; + + it('Module exists', function () { + expect(InteractionManager).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/Pixi.js b/test/unit/pixi-v2/Pixi.js new file mode 100644 index 0000000..27debc1 --- /dev/null +++ b/test/unit/pixi-v2/Pixi.js @@ -0,0 +1,9 @@ +describe('pixi/Pixi', function () { + 'use strict'; + + var expect = chai.expect; + + it('Module exists', function () { + expect(global).to.have.property('PIXI').and.to.be.an('object'); + }); +}); diff --git a/test/unit/pixi-v2/core/Circle.js b/test/unit/pixi-v2/core/Circle.js new file mode 100644 index 0000000..fbcfa17 --- /dev/null +++ b/test/unit/pixi-v2/core/Circle.js @@ -0,0 +1,21 @@ +describe('pixi/core/Circle', function () { + 'use strict'; + + var expect = chai.expect; + var Circle = PIXI.Circle; + + it('Module exists', function () { + expect(Circle).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Circle(); + pixi_core_Circle_confirmNewCircle(obj); + }); + + it("getBounds should return Rectangle that bounds the circle", function() { + var obj = new Circle(100, 250, 50); + var bounds = obj.getBounds(); + pixi_core_Circle_isBoundedByRectangle(obj, bounds); + }); +}); diff --git a/test/unit/pixi-v2/core/Ellipse.js b/test/unit/pixi-v2/core/Ellipse.js new file mode 100644 index 0000000..026b56f --- /dev/null +++ b/test/unit/pixi-v2/core/Ellipse.js @@ -0,0 +1,24 @@ +describe('pixi/core/Ellipse', function () { + 'use strict'; + + var expect = chai.expect; + var Ellipse = PIXI.Ellipse; + + it('Module exists', function () { + expect(Ellipse).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Ellipse(); + + expect(obj).to.be.an.instanceof(Ellipse); + expect(obj).to.respondTo('clone'); + expect(obj).to.respondTo('contains'); + expect(obj).to.respondTo('getBounds'); + + expect(obj).to.have.property('x', 0); + expect(obj).to.have.property('y', 0); + expect(obj).to.have.property('width', 0); + expect(obj).to.have.property('height', 0); + }); +}); diff --git a/test/unit/pixi-v2/core/Matrix.js b/test/unit/pixi-v2/core/Matrix.js new file mode 100644 index 0000000..da75e2e --- /dev/null +++ b/test/unit/pixi-v2/core/Matrix.js @@ -0,0 +1,14 @@ +describe('pixi/core/Matrix', function () { + 'use strict'; + + var expect = chai.expect; + + it('Matrix exists', function () { + expect(PIXI.Matrix).to.be.an('function'); + }); + + it('Confirm new Matrix', function () { + var matrix = new PIXI.Matrix(); + pixi_core_Matrix_confirmNewMatrix(matrix); + }); +}); diff --git a/test/unit/pixi-v2/core/Point.js b/test/unit/pixi-v2/core/Point.js new file mode 100644 index 0000000..c4d5163 --- /dev/null +++ b/test/unit/pixi-v2/core/Point.js @@ -0,0 +1,15 @@ +describe('pixi/core/Point', function () { + 'use strict'; + + var expect = chai.expect; + var Point = PIXI.Point; + + it('Module exists', function () { + expect(Point).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Point(); + pixi_core_Point_confirm(obj, 0, 0); + }); +}); diff --git a/test/unit/pixi-v2/core/Polygon.js b/test/unit/pixi-v2/core/Polygon.js new file mode 100644 index 0000000..dc8c918 --- /dev/null +++ b/test/unit/pixi-v2/core/Polygon.js @@ -0,0 +1,20 @@ +describe('pixi/core/Polygon', function () { + 'use strict'; + + var expect = chai.expect; + var Polygon = PIXI.Polygon; + + it('Module exists', function () { + expect(Polygon).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Polygon(); + + expect(obj).to.be.an.instanceof(Polygon); + expect(obj).to.respondTo('clone'); + expect(obj).to.respondTo('contains'); + + expect(obj).to.have.deep.property('points.length', 0); + }); +}); diff --git a/test/unit/pixi-v2/core/Rectangle.js b/test/unit/pixi-v2/core/Rectangle.js new file mode 100644 index 0000000..d43316e --- /dev/null +++ b/test/unit/pixi-v2/core/Rectangle.js @@ -0,0 +1,15 @@ +describe('pixi/core/Rectangle', function () { + 'use strict'; + + var expect = chai.expect; + var Rectangle = PIXI.Rectangle; + + it('Module exists', function () { + expect(Rectangle).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var rect = new Rectangle(); + pixi_core_Rectangle_confirm(rect, 0, 0, 0, 0); + }); +}); diff --git a/test/unit/pixi-v2/display/DisplayObject.js b/test/unit/pixi-v2/display/DisplayObject.js new file mode 100644 index 0000000..044acf8 --- /dev/null +++ b/test/unit/pixi-v2/display/DisplayObject.js @@ -0,0 +1,21 @@ +describe('pixi/display/DisplayObject', function () { + 'use strict'; + + var expect = chai.expect; + var DisplayObject = PIXI.DisplayObject; + + it('Module exists', function () { + expect(DisplayObject).to.be.a('function'); + // expect(PIXI).to.have.property('visibleCount', 0); + }); + + it('Confirm new instance', function () { + var obj = new DisplayObject(); + + pixi_display_DisplayObject_confirmNew(obj); + expect(obj).to.have.property('hitArea', null); + expect(obj).to.have.property('interactive', false); + expect(obj).to.have.property('renderable', false); + expect(obj).to.have.property('stage', null); + }); +}); diff --git a/test/unit/pixi-v2/display/DisplayObjectContainer.js b/test/unit/pixi-v2/display/DisplayObjectContainer.js new file mode 100644 index 0000000..15a3376 --- /dev/null +++ b/test/unit/pixi-v2/display/DisplayObjectContainer.js @@ -0,0 +1,67 @@ +describe('pixi/display/DisplayObjectContainer', function () { + 'use strict'; + + var expect = chai.expect; + var DisplayObjectContainer = PIXI.DisplayObjectContainer; + + it('Module exists', function () { + expect(DisplayObjectContainer).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new DisplayObjectContainer(); + + pixi_display_DisplayObjectContainer_confirmNew(obj); + expect(obj).to.have.property('hitArea', null); + expect(obj).to.have.property('interactive', false); + expect(obj).to.have.property('renderable', false); + expect(obj).to.have.property('stage', null); + }); + + it('Gets child index', function() { + var container = new PIXI.DisplayObjectContainer(); + var children = []; + for (var i = 0; i < 10; i++) { + var child = new PIXI.DisplayObject(); + children.push(child); + container.addChild(child); + } + + for (i = 0; i < children.length; i++) { + expect(i).to.eql(container.getChildIndex(children[i])); + } + }); + + it('throws error when trying to get index of not a child', function() { + var container = new PIXI.DisplayObjectContainer(); + var child = new PIXI.DisplayObject(); + + expect(function() { container.getChildIndex(child); }).to.throw(); + }); + + it('Sets child index', function() { + var container = new PIXI.DisplayObjectContainer(); + var children = []; + + for (var i = 0; i < 10; i++) { + var child = new PIXI.DisplayObject(); + children.push(child); + container.addChild(child); + } + children.reverse(); + + for (i = 0; i < children.length; i++) { + container.setChildIndex(children[i], i); + expect(i).to.eql(container.getChildIndex(children[i])); + } + }); + + it('throws error when trying to set incorect index', function() { + var container = new PIXI.DisplayObjectContainer(); + var child = new PIXI.DisplayObject(); + container.addChild(child); + + expect(function() { container.setChildIndex(child, -1); }).to.throw(); + expect(function() { container.setChildIndex(child, 1); }).to.throw(); + }); +}); diff --git a/test/unit/pixi-v2/display/MovieClip.js b/test/unit/pixi-v2/display/MovieClip.js new file mode 100644 index 0000000..f3c6c6a --- /dev/null +++ b/test/unit/pixi-v2/display/MovieClip.js @@ -0,0 +1,33 @@ +describe('pixi/display/MovieClip', function () { + 'use strict'; + + var expect = chai.expect; + var MovieClip = PIXI.MovieClip; + var Texture = PIXI.Texture; + + it('Module exists', function () { + expect(MovieClip).to.be.a('function'); + }); + + it('Confirm new instance', function (done) { + var texture = Texture.fromImage('/base/test/textures/SpriteSheet-Explosion.png'); + var obj = new MovieClip([texture]); + + pixi_display_Sprite_confirmNew(obj, done); + + expect(obj).to.be.an.instanceof(MovieClip); + expect(obj).to.respondTo('stop'); + expect(obj).to.respondTo('play'); + expect(obj).to.respondTo('gotoAndStop'); + expect(obj).to.respondTo('gotoAndPlay'); + expect(obj).to.respondTo('updateTransform'); + + expect(obj).to.have.deep.property('textures.length', 1); + expect(obj).to.have.deep.property('textures[0]', texture); + expect(obj).to.have.property('animationSpeed', 1); + expect(obj).to.have.property('loop', true); + expect(obj).to.have.property('onComplete', null); + expect(obj).to.have.property('currentFrame', 0); + expect(obj).to.have.property('playing', false); + }); +}); diff --git a/test/unit/pixi-v2/display/Sprite.js b/test/unit/pixi-v2/display/Sprite.js new file mode 100644 index 0000000..30c8076 --- /dev/null +++ b/test/unit/pixi-v2/display/Sprite.js @@ -0,0 +1,28 @@ +describe('pixi/display/Sprite', function () { + 'use strict'; + + var expect = chai.expect; + var Sprite = PIXI.Sprite; + var Texture = PIXI.Texture; + + it('Module exists', function () { + expect(Sprite).to.be.a('function'); + expect(PIXI).to.have.deep.property('blendModes.NORMAL', 0); + expect(PIXI).to.have.deep.property('blendModes.ADD', 1); + expect(PIXI).to.have.deep.property('blendModes.MULTIPLY', 2); + expect(PIXI).to.have.deep.property('blendModes.SCREEN', 3); + }); + + + it('Members exist', function () { + expect(Sprite).itself.to.respondTo('fromImage'); + expect(Sprite).itself.to.respondTo('fromFrame'); + }); + + it('Confirm new instance', function (done) { + var texture = Texture.fromImage('/base/test/textures/SpriteSheet-Aliens.png'); + var obj = new Sprite(texture); + + pixi_display_Sprite_confirmNew(obj, done); + }); +}); diff --git a/test/unit/pixi-v2/display/Stage.js b/test/unit/pixi-v2/display/Stage.js new file mode 100644 index 0000000..6974c2e --- /dev/null +++ b/test/unit/pixi-v2/display/Stage.js @@ -0,0 +1,49 @@ +describe('pixi/display/Stage', function () { + 'use strict'; + + var expect = chai.expect; + var Stage = PIXI.Stage; + var InteractionManager = PIXI.InteractionManager; + var Rectangle = PIXI.Rectangle; + + it('Module exists', function () { + expect(Stage).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Stage(null, true); + + pixi_display_DisplayObjectContainer_confirmNew(obj); + + expect(obj).to.be.an.instanceof(Stage); + expect(obj).to.respondTo('updateTransform'); + expect(obj).to.respondTo('setBackgroundColor'); + expect(obj).to.respondTo('getMousePosition'); + // FIXME: duplicate member in DisplayObject + pixi_core_Matrix_confirmNewMatrix(obj.worldTransform); + // FIXME: convert arg to bool in constructor + expect(obj).to.have.property('interactive', true); + + expect(obj).to.have.property('interactionManager') + .and.to.be.an.instanceof(InteractionManager) + .and.to.have.property('stage', obj); + + expect(obj).to.have.property('dirty', true); + + expect(obj).to.have.property('stage', obj); + + expect(obj).to.have.property('hitArea') + .and.to.be.an.instanceof(Rectangle); + pixi_core_Rectangle_confirm(obj.hitArea, 0, 0, 100000, 100000); + + expect(obj).to.have.property('backgroundColor', 0x000000); + expect(obj).to.have.deep.property('backgroundColorSplit.length', 3); + expect(obj).to.have.deep.property('backgroundColorSplit[0]', 0); + expect(obj).to.have.deep.property('backgroundColorSplit[1]', 0); + expect(obj).to.have.deep.property('backgroundColorSplit[2]', 0); + expect(obj).to.have.property('backgroundColorString', '#000000'); + + + expect(obj).to.have.property('worldVisible', true); + }); +}); diff --git a/test/unit/pixi-v2/extras/Rope.js b/test/unit/pixi-v2/extras/Rope.js new file mode 100644 index 0000000..05885ac --- /dev/null +++ b/test/unit/pixi-v2/extras/Rope.js @@ -0,0 +1,31 @@ +describe('pixi/extras/Rope', function () { + 'use strict'; + + var expect = chai.expect; + var Rope = PIXI.Rope; + var Texture = PIXI.Texture; + var Point = PIXI.Point; + + it('Module exists', function () { + expect(Rope).to.be.a('function'); + }); + + it('Confirm new instance', function () { + + var texture = Texture.fromImage('/base/test/textures/bunny.png'); + + // TODO-Alvin + // Same as Strip + + // var obj = new Rope(texture, [new Point(), new Point(5, 10), new Point(10, 20)]); + + // pixi_extras_Strip_confirmNew(obj); + + // expect(obj).to.be.an.instanceof(Rope); + // expect(obj).to.respondTo('refresh'); + // expect(obj).to.respondTo('updateTransform'); + // expect(obj).to.respondTo('setTexture'); + + // TODO: Test properties + }); +}); diff --git a/test/unit/pixi-v2/extras/Spine.js b/test/unit/pixi-v2/extras/Spine.js new file mode 100644 index 0000000..0708bc0 --- /dev/null +++ b/test/unit/pixi-v2/extras/Spine.js @@ -0,0 +1,10 @@ +describe('pixi/extras/Spine', function () { + 'use strict'; + + var expect = chai.expect; + var Spine = PIXI.Spine; + + it('Module exists', function () { + expect(Spine).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/extras/Strip.js b/test/unit/pixi-v2/extras/Strip.js new file mode 100644 index 0000000..230af90 --- /dev/null +++ b/test/unit/pixi-v2/extras/Strip.js @@ -0,0 +1,26 @@ +describe('pixi/extras/Strip', function () { + 'use strict'; + + var expect = chai.expect; + var Strip = PIXI.Strip; + var Texture = PIXI.Texture; + + it('Module exists', function () { + expect(Strip).to.be.a('function'); + }); + + it('Confirm new instance', function () { + + + // TODO-Alvin + // We tweaked it to make it pass the tests, but the whole strip class needs + // to be re-coded + + var texture = Texture.fromImage('/base/test/textures/bunny.png'); + + // var obj = new Strip(texture, 20, 10000); + + + // pixi_extras_Strip_confirmNew(obj); + }); +}); diff --git a/test/unit/pixi-v2/extras/TilingSprite.js b/test/unit/pixi-v2/extras/TilingSprite.js new file mode 100644 index 0000000..56aea14 --- /dev/null +++ b/test/unit/pixi-v2/extras/TilingSprite.js @@ -0,0 +1,24 @@ +describe('pixi/extras/TilingSprite', function () { + 'use strict'; + + var expect = chai.expect; + var TilingSprite = PIXI.TilingSprite; + var Texture = PIXI.Texture; + + it('Module exists', function () { + expect(TilingSprite).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var texture = Texture.fromImage('/base/test/textures/bunny.png'); + var obj = new TilingSprite(texture, 6000, 12000); + + pixi_display_DisplayObjectContainer_confirmNew(obj); + + expect(obj).to.be.an.instanceof(TilingSprite); + expect(obj).to.respondTo('setTexture'); + expect(obj).to.respondTo('onTextureUpdate'); + + // TODO: Test properties + }); +}); diff --git a/test/unit/pixi-v2/filters/FilterBlock.js b/test/unit/pixi-v2/filters/FilterBlock.js new file mode 100644 index 0000000..870cec0 --- /dev/null +++ b/test/unit/pixi-v2/filters/FilterBlock.js @@ -0,0 +1,10 @@ +describe('pixi/filters/FilterBlock', function () { + 'use strict'; + + var expect = chai.expect; + var FilterBlock = PIXI.FilterBlock; + + it('Module exists', function () { + expect(FilterBlock).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/AssetLoader.js b/test/unit/pixi-v2/loaders/AssetLoader.js new file mode 100644 index 0000000..a0aa0b5 --- /dev/null +++ b/test/unit/pixi-v2/loaders/AssetLoader.js @@ -0,0 +1,10 @@ +describe('pixi/loaders/AssetLoader', function () { + 'use strict'; + + var expect = chai.expect; + var AssetLoader = PIXI.AssetLoader; + + it('Module exists', function () { + expect(AssetLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/BitmapFontLoader.js b/test/unit/pixi-v2/loaders/BitmapFontLoader.js new file mode 100644 index 0000000..046f018 --- /dev/null +++ b/test/unit/pixi-v2/loaders/BitmapFontLoader.js @@ -0,0 +1,9 @@ +describe('pixi/loaders/BitmapFontLoader', function () { + 'use strict'; + + var expect = chai.expect; + + it('Module exists', function () { + expect(PIXI.BitmapFontLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/ImageLoader.js b/test/unit/pixi-v2/loaders/ImageLoader.js new file mode 100644 index 0000000..8b1f556 --- /dev/null +++ b/test/unit/pixi-v2/loaders/ImageLoader.js @@ -0,0 +1,10 @@ +describe('pixi/loaders/ImageLoader', function () { + 'use strict'; + + var expect = chai.expect; + var ImageLoader = PIXI.ImageLoader; + + it('Module exists', function () { + expect(ImageLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/JsonLoader.js b/test/unit/pixi-v2/loaders/JsonLoader.js new file mode 100644 index 0000000..c577e83 --- /dev/null +++ b/test/unit/pixi-v2/loaders/JsonLoader.js @@ -0,0 +1,10 @@ +describe('pixi/loaders/JsonLoader', function () { + 'use strict'; + + var expect = chai.expect; + var JsonLoader = PIXI.JsonLoader; + + it('Module exists', function () { + expect(JsonLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/SpineLoader.js b/test/unit/pixi-v2/loaders/SpineLoader.js new file mode 100644 index 0000000..fdcc0b8 --- /dev/null +++ b/test/unit/pixi-v2/loaders/SpineLoader.js @@ -0,0 +1,10 @@ +describe('pixi/loaders/SpineLoader', function () { + 'use strict'; + + var expect = chai.expect; + var SpineLoader = PIXI.SpineLoader; + + it('Module exists', function () { + expect(SpineLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/SpriteSheetLoader.js b/test/unit/pixi-v2/loaders/SpriteSheetLoader.js new file mode 100644 index 0000000..57beb27 --- /dev/null +++ b/test/unit/pixi-v2/loaders/SpriteSheetLoader.js @@ -0,0 +1,10 @@ +describe('pixi/loaders/SpriteSheetLoader', function () { + 'use strict'; + + var expect = chai.expect; + var SpriteSheetLoader = PIXI.SpriteSheetLoader; + + it('Module exists', function () { + expect(SpriteSheetLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/primitives/Graphics.js b/test/unit/pixi-v2/primitives/Graphics.js new file mode 100644 index 0000000..f3849eb --- /dev/null +++ b/test/unit/pixi-v2/primitives/Graphics.js @@ -0,0 +1,44 @@ +describe('pixi/primitives/Graphics', function () { + 'use strict'; + + var expect = chai.expect; + var Graphics = PIXI.Graphics; + + it('Module exists', function () { + expect(Graphics).to.be.a('function'); + + expect(Graphics).itself.to.have.property('POLY', 0); + expect(Graphics).itself.to.have.property('RECT', 1); + expect(Graphics).itself.to.have.property('CIRC', 2); + expect(Graphics).itself.to.have.property('ELIP', 3); + expect(Graphics).itself.to.have.property('RREC', 4); + }); + + it('Confirm new instance', function () { + var obj = new Graphics(); + + pixi_display_DisplayObjectContainer_confirmNew(obj); + + expect(obj).to.be.an.instanceof(Graphics); + expect(obj).to.respondTo('lineStyle'); + expect(obj).to.respondTo('lineStyle'); + expect(obj).to.respondTo('moveTo'); + expect(obj).to.respondTo('lineTo'); + expect(obj).to.respondTo('beginFill'); + expect(obj).to.respondTo('endFill'); + expect(obj).to.respondTo('drawRect'); + // expect(obj).to.respondTo('drawRoundedRect'); + expect(obj).to.respondTo('drawCircle'); + expect(obj).to.respondTo('drawEllipse'); + expect(obj).to.respondTo('clear'); + + expect(obj).to.have.property('renderable', true); + expect(obj).to.have.property('fillAlpha', 1); + expect(obj).to.have.property('lineWidth', 0); + expect(obj).to.have.property('width', 0); + expect(obj).to.have.property('height', 0); + expect(obj).to.have.property('lineColor', 0); + expect(obj).to.have.deep.property('graphicsData.length', 0); + // expect(obj).to.have.deep.property('currentPath.points.length', 0); + }); +}); diff --git a/test/unit/pixi-v2/renderers/canvas/CanvasGraphics.js b/test/unit/pixi-v2/renderers/canvas/CanvasGraphics.js new file mode 100644 index 0000000..8f44472 --- /dev/null +++ b/test/unit/pixi-v2/renderers/canvas/CanvasGraphics.js @@ -0,0 +1,15 @@ +describe('renders/canvas/CanvasGraphics', function () { + 'use strict'; + + var expect = chai.expect; + var CanvasGraphics = PIXI.CanvasGraphics; + + it('Module exists', function () { + expect(CanvasGraphics).to.be.a('function'); + }); + + it('Members exist', function () { + expect(CanvasGraphics).itself.to.respondTo('renderGraphics'); + expect(CanvasGraphics).itself.to.respondTo('renderGraphicsMask'); + }); +}); diff --git a/test/unit/pixi-v2/renderers/canvas/CanvasRenderer.js b/test/unit/pixi-v2/renderers/canvas/CanvasRenderer.js new file mode 100644 index 0000000..1646444 --- /dev/null +++ b/test/unit/pixi-v2/renderers/canvas/CanvasRenderer.js @@ -0,0 +1,36 @@ +describe('renderers/canvas/CanvasRenderer', function () { + 'use strict'; + + var expect = chai.expect; + var CanvasRenderer = PIXI.CanvasRenderer; + + it('Module exists', function () { + expect(CanvasRenderer).to.be.a('function'); + }); + + describe('.autoResize', function () { + it('Should automatically resize view if enabled', function () { + var renderer = new CanvasRenderer(200, 200, { + autoResize: true + }); + + expect(renderer.view.style.width).to.equal('200px'); + }); + + it('Should not automatically resize view if disabled', function () { + var renderer = new CanvasRenderer(200, 200, { + autoResize: false + }); + + expect(renderer.view.style.width).to.equal(''); + }); + + it('Should not automatically resize view if not specified', function () { + var renderer = new CanvasRenderer(200, 200, { + resolution: 2 + }); + + expect(renderer.view.style.width).to.equal(''); + }); + }); +}); diff --git a/test/unit/pixi-v2/renderers/webgl/WebGLGraphics.js b/test/unit/pixi-v2/renderers/webgl/WebGLGraphics.js new file mode 100644 index 0000000..5867b28 --- /dev/null +++ b/test/unit/pixi-v2/renderers/webgl/WebGLGraphics.js @@ -0,0 +1,20 @@ +describe('renderers/wegbl/WebGLGraphics', function () { + 'use strict'; + + var expect = chai.expect; + var WebGLGraphics = PIXI.WebGLGraphics; + + it('Module exists', function () { + expect(WebGLGraphics).to.be.a('function'); + }); + + it('Members exist', function () { + expect(WebGLGraphics).itself.to.respondTo('renderGraphics'); + expect(WebGLGraphics).itself.to.respondTo('updateGraphics'); + expect(WebGLGraphics).itself.to.respondTo('buildRectangle'); + expect(WebGLGraphics).itself.to.respondTo('buildRoundedRectangle'); + expect(WebGLGraphics).itself.to.respondTo('buildCircle'); + expect(WebGLGraphics).itself.to.respondTo('buildLine'); + expect(WebGLGraphics).itself.to.respondTo('buildPoly'); + }); +}); diff --git a/test/unit/pixi-v2/renderers/webgl/WebGLRenderer.js b/test/unit/pixi-v2/renderers/webgl/WebGLRenderer.js new file mode 100644 index 0000000..1680a80 --- /dev/null +++ b/test/unit/pixi-v2/renderers/webgl/WebGLRenderer.js @@ -0,0 +1,49 @@ +describe('renderers/webgl/WebGLRenderer', function () { + 'use strict'; + + var expect = chai.expect; + var WebGLRenderer = PIXI.WebGLRenderer; + + it('Module exists', function () { + expect(WebGLRenderer).to.be.a('function'); + }); + + // Skip tests if WebGL is not available (WebGL not supported in Travis CI) + try { + var renderer = new WebGLRenderer(400, 300, {}); + renderer.destroy(); + } catch (error) { + return; + } + + it('Destroy renderer', function () { + var renderer = new WebGLRenderer(400, 300, {}); + renderer.destroy(); + }); + + describe('.autoResize', function () { + it('Should automatically resize view if enabled', function () { + var renderer = new WebGLRenderer(200, 200, { + autoResize: true + }); + + expect(renderer.view.style.width).to.equal('200px'); + }); + + it('Should not automatically resize view if disabled', function () { + var renderer = new WebGLRenderer(200, 200, { + autoResize: false + }); + + expect(renderer.view.style.width).to.equal(''); + }); + + it('Should not automatically resize view if not specified', function () { + var renderer = new WebGLRenderer(200, 200, { + resolution: 2 + }); + + expect(renderer.view.style.width).to.equal(''); + }); + }); +}); diff --git a/test/unit/pixi-v2/renderers/webgl/WebGLShaders.js b/test/unit/pixi-v2/renderers/webgl/WebGLShaders.js new file mode 100644 index 0000000..6e33e4f --- /dev/null +++ b/test/unit/pixi-v2/renderers/webgl/WebGLShaders.js @@ -0,0 +1,13 @@ +describe('renderers/webgl/WebGLShaders', function () { + 'use strict'; + + var expect = chai.expect; + + it('Module members exist', function () { + + expect(PIXI).to.respondTo('CompileVertexShader'); + expect(PIXI).to.respondTo('CompileFragmentShader'); + expect(PIXI).to.respondTo('_CompileShader'); + expect(PIXI).to.respondTo('compileProgram'); + }); +}); diff --git a/test/unit/pixi-v2/renderers/webgl/WebGLSpriteBatch.js b/test/unit/pixi-v2/renderers/webgl/WebGLSpriteBatch.js new file mode 100644 index 0000000..e662b63 --- /dev/null +++ b/test/unit/pixi-v2/renderers/webgl/WebGLSpriteBatch.js @@ -0,0 +1,10 @@ +describe('renderers/webgl/utils/WebGLSpriteBatch', function () { + 'use strict'; + + var expect = chai.expect; + var WebGLSpriteBatch = PIXI.WebGLSpriteBatch; + + it('Module exists', function () { + expect(WebGLSpriteBatch).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/text/BitmapText.js b/test/unit/pixi-v2/text/BitmapText.js new file mode 100644 index 0000000..9388e3d --- /dev/null +++ b/test/unit/pixi-v2/text/BitmapText.js @@ -0,0 +1,10 @@ +describe('pixi/text/BitmapText', function () { + 'use strict'; + + var expect = chai.expect; + var BitmapText = PIXI.BitmapText; + + it('Module exists', function () { + expect(BitmapText).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/text/Text.js b/test/unit/pixi-v2/text/Text.js new file mode 100644 index 0000000..9bc9ac5 --- /dev/null +++ b/test/unit/pixi-v2/text/Text.js @@ -0,0 +1,10 @@ +describe('pixi/text/Text', function () { + 'use strict'; + + var expect = chai.expect; + var Text = PIXI.Text; + + it('Module exists', function () { + expect(Text).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/textures/BaseTexture.js b/test/unit/pixi-v2/textures/BaseTexture.js new file mode 100644 index 0000000..502b724 --- /dev/null +++ b/test/unit/pixi-v2/textures/BaseTexture.js @@ -0,0 +1,11 @@ +describe('pixi/textures/BaseTexture', function () { + 'use strict'; + + var expect = chai.expect; + var BaseTexture = PIXI.BaseTexture; + + it('Module exists', function () { + expect(BaseTexture).to.be.a('function'); + expect(PIXI).to.have.property('BaseTextureCache').and.to.be.an('object'); + }); +}); diff --git a/test/unit/pixi-v2/textures/RenderTexture.js b/test/unit/pixi-v2/textures/RenderTexture.js new file mode 100644 index 0000000..96acdb4 --- /dev/null +++ b/test/unit/pixi-v2/textures/RenderTexture.js @@ -0,0 +1,15 @@ +describe('pixi/textures/RenderTexture', function () { + 'use strict'; + + var expect = chai.expect; + var RenderTexture = PIXI.RenderTexture; + + it('Module exists', function () { + expect(RenderTexture).to.be.a('function'); + }); + + it('Confirm new instance', function (done) { + var texture = new RenderTexture(100, 100, new PIXI.CanvasRenderer()); + pixi_textures_RenderTexture_confirmNew(texture, done); + }); +}); diff --git a/test/unit/pixi-v2/textures/Texture.js b/test/unit/pixi-v2/textures/Texture.js new file mode 100644 index 0000000..090f64d --- /dev/null +++ b/test/unit/pixi-v2/textures/Texture.js @@ -0,0 +1,26 @@ +describe('pixi/textures/Texture', function () { + 'use strict'; + + var expect = chai.expect; + var Texture = PIXI.Texture; + + it('Module exists', function () { + expect(Texture).to.be.a('function'); + expect(PIXI).to.have.property('TextureCache').and.to.be.an('object'); + }); + + it('Members exist', function () { + expect(Texture).itself.to.respondTo('fromImage'); + expect(Texture).itself.to.respondTo('fromFrame'); + expect(Texture).itself.to.respondTo('fromCanvas'); + expect(Texture).itself.to.respondTo('addTextureToCache'); + expect(Texture).itself.to.respondTo('removeTextureFromCache'); + + // expect(Texture).itself.to.have.deep.property('frameUpdates.length', 0); + }); + + it('Confirm new instance', function (done) { + var texture = Texture.fromImage('/base/test/textures/bunny.png'); + pixi_textures_Texture_confirmNew(texture, done); + }); +}); diff --git a/test/unit/pixi-v2/utils/Detector.js b/test/unit/pixi-v2/utils/Detector.js new file mode 100644 index 0000000..4cf6008 --- /dev/null +++ b/test/unit/pixi-v2/utils/Detector.js @@ -0,0 +1,10 @@ +describe('pixi/utils/Detector', function () { + 'use strict'; + + var expect = chai.expect; + var autoDetectRenderer = PIXI.autoDetectRenderer; + + it('Module exists', function () { + expect(autoDetectRenderer).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/utils/EventTarget.js b/test/unit/pixi-v2/utils/EventTarget.js new file mode 100644 index 0000000..1cfc3a4 --- /dev/null +++ b/test/unit/pixi-v2/utils/EventTarget.js @@ -0,0 +1,361 @@ +describe('pixi/utils/EventTarget', function () { + 'use strict'; + + var expect = chai.expect; + + var Clazz, PClazz, obj, pobj, obj2; + beforeEach(function () { + Clazz = function () {}; + PClazz = function () {}; + + PIXI.EventTarget.mixin(Clazz.prototype); + PIXI.EventTarget.mixin(PClazz.prototype); + + obj = new Clazz(); + obj2 = new Clazz(); + pobj = new PClazz(); + + obj.parent = pobj; + obj2.parent = obj; + }); + + it('Module exists', function () { + expect(PIXI.EventTarget).to.be.an('object'); + }); + + it('Confirm new instance', function () { + pixi_utils_EventTarget_confirm(obj); + }); + + it('simple on/emit case works', function () { + var myData = {}; + + obj.on('myevent', function (event) { + pixi_utils_EventTarget_Event_confirm(event, obj, myData); + }); + + obj.emit('myevent', myData); + }); + + it('simple once case works', function () { + var called = 0; + + obj.once('myevent', function() { called++; }); + + obj.emit('myevent'); + obj.emit('myevent'); + obj.emit('myevent'); + obj.emit('myevent'); + obj.emit('myevent'); + + expect(called).to.equal(1); + }); + + it('simple off case works', function (done) { + function onMyEvent() { + done(new Error('Event listener should not have been called')); + } + + obj.on('myevent', onMyEvent); + obj.off('myevent', onMyEvent); + obj.emit('myevent'); + + done(); + }); + + it('simple propagation case works', function (done) { + var myData = {}; + + pobj.on('myevent', function () { + done(); + }); + + obj.emit('myevent'); + }); + + it('simple stopPropagation case works', function (done) { + var myData = {}; + + pobj.on('myevent', function () { + done(new Error('Event listener should not have been called on the parent element')); + }); + + obj.on('myevent', function (evt) { + evt.stopPropagation(); + }); + + obj.emit('myevent'); + + done(); + }); + + it('simple stopImmediatePropagation case works', function (done) { + var myData = {}; + + pobj.on('myevent', function () { + done(new Error('Event listener should not have been called on the parent')); + }); + + obj.on('myevent', function (evt) { + evt.stopImmediatePropagation(); + }); + + obj.on('myevent', function () { + done(new Error('Event listener should not have been called on the second')); + }); + + obj.emit('myevent'); + + done(); + }); + + it('multiple dispatches work properly', function () { + var called = 0; + + function onMyEvent() { + called++; + } + + obj.on('myevent', onMyEvent); + obj.emit('myevent'); + obj.emit('myevent'); + obj.emit('myevent'); + obj.emit('myevent'); + + expect(called).to.equal(4); + }); + + it('multiple events work properly', function () { + var called = 0; + + function onMyEvent() { + called++; + } + + obj.on('myevent1', onMyEvent); + obj.on('myevent2', onMyEvent); + obj.on('myevent3', onMyEvent); + obj.emit('myevent1'); + obj.emit('myevent2'); + obj.emit('myevent3'); + + expect(called).to.equal(3); + }); + + it('multiple events one removed works properly', function () { + var called = 0; + + function onMyEvent() { + called++; + } + + obj.on('myevent1', onMyEvent); + obj.on('myevent2', onMyEvent); + obj.on('myevent3', onMyEvent); + + obj.emit('myevent1'); + obj.emit('myevent2'); + obj.emit('myevent3'); + + obj.off('myevent2', onMyEvent); + + obj.emit('myevent1'); + obj.emit('myevent2'); + obj.emit('myevent3'); + + expect(called).to.equal(5); + }); + + it('multiple handlers for one event with some removed', function () { + var called = 0; + + var onMyEvent = function () { + called++; + }, + onMyEvent2 = function () { + called++; + }; + + // add 2 handlers and confirm they both get called + obj.on('myevent', onMyEvent); + obj.on('myevent', onMyEvent); + obj.on('myevent', onMyEvent2); + obj.on('myevent', onMyEvent2); + + obj.emit('myevent'); + + expect(called).to.equal(4); + + // remove one of the handlers, emit again, then ensure 1 more call is made + obj.off('myevent', onMyEvent); + + obj.emit('myevent'); + + expect(called).to.equal(6); + }); + + it('calls to off without a handler do nothing', function () { + var called = 0; + + var onMyEvent = function () { + called++; + }; + + obj.on('myevent', onMyEvent); + obj.on('myevent', onMyEvent); + + obj.emit('myevent'); + + expect(called).to.equal(2); + + obj.off('myevent'); + + obj.emit('myevent'); + + expect(called).to.equal(4); + + obj.off('myevent', onMyEvent); + + obj.emit('myevent'); + + expect(called).to.equal(4); + }); + + it('handles multiple instances with the same prototype', function () { + var called = 0; + + function onMyEvent(e) { + called++; + } + + obj.on('myevent1', onMyEvent); + obj.on('myevent2', onMyEvent); + + obj2.istwo = true; + obj2.on('myevent1', onMyEvent); + obj2.on('myevent2', onMyEvent); + + obj.emit('myevent1'); + obj.emit('myevent2'); + obj2.emit('myevent1'); + obj2.emit('myevent2'); + + //we emit 4 times, but since obj2 is a child of obj the event should bubble + //up to obj and show up there as well. So the obj2.emit() calls each increment + //the counter twice. + expect(called).to.equal(6); + }); + + it('is backwards compatible with older .dispatchEvent({})', function () { + var called = 0, + data = { + some: 'thing', + hello: true + }; + + function onMyEvent(event) { + pixi_utils_EventTarget_Event_confirm(event, obj, data); + + called++; + } + + obj.on('myevent1', onMyEvent); + obj.on('myevent2', onMyEvent); + obj.on('myevent3', onMyEvent); + + data.type = 'myevent1'; + obj.emit(data); + + data.type = 'myevent2'; + obj.emit(data); + + data.type = 'myevent3'; + obj.emit(data); + + obj.off('myevent2', onMyEvent); + + data.type = 'myevent1'; + obj.emit(data); + + data.type = 'myevent2'; + obj.emit(data); + + data.type = 'myevent3'; + obj.emit(data); + + expect(called).to.equal(5); + }); + + it('is backwards compatible with older .call(this)', function () { + var Fn = function() { + PIXI.EventTarget.call(this); + }, + o = new Fn(); + + pixi_utils_EventTarget_confirm(o); + }); + + it('is backwards compatible with older .addEventListener("")', function () { + var called = 0, + data = { + some: 'thing', + hello: true + }; + + function onMyEvent(event) { + pixi_utils_EventTarget_Event_confirm(event, obj, data); + + called++; + } + + obj.addEventListener('myevent1', onMyEvent); + obj.addEventListener('myevent2', onMyEvent); + obj.addEventListener('myevent3', onMyEvent); + + data.type = 'myevent1'; + obj.emit(data); + + data.type = 'myevent2'; + obj.emit(data); + + data.type = 'myevent3'; + obj.emit(data); + + obj.off('myevent2', onMyEvent); + + data.type = 'myevent1'; + obj.emit(data); + + data.type = 'myevent2'; + obj.emit(data); + + data.type = 'myevent3'; + obj.emit(data); + + expect(called).to.equal(5); + }); + + it('event remove during emit call properly', function () { + var called = 0; + + function cb1() { + called++; + obj.off('myevent', cb1); + } + function cb2() { + called++; + obj.off('myevent', cb2); + } + function cb3() { + called++; + obj.off('myevent', cb3); + } + + obj.on('myevent', cb1); + obj.on('myevent', cb2); + obj.on('myevent', cb3); + obj.emit('myevent', ''); + + expect(called).to.equal(3); + }); +}); diff --git a/test/unit/pixi-v2/utils/Polyk.js b/test/unit/pixi-v2/utils/Polyk.js new file mode 100644 index 0000000..dfc7128 --- /dev/null +++ b/test/unit/pixi-v2/utils/Polyk.js @@ -0,0 +1,14 @@ +describe('pixi/utils/Polyk', function () { + 'use strict'; + + var expect = chai.expect; + var PolyK = PIXI.PolyK; + + it('Module exists', function () { + expect(PolyK).to.be.an('object'); + }); + + it('Members exist', function () { + expect(PolyK).to.respondTo('Triangulate'); + }); +}); diff --git a/test/unit/pixi-v2/utils/Utils.js b/test/unit/pixi-v2/utils/Utils.js new file mode 100644 index 0000000..c97b3c6 --- /dev/null +++ b/test/unit/pixi-v2/utils/Utils.js @@ -0,0 +1,17 @@ +describe('Utils', function () { + 'use strict'; + + var expect = chai.expect; + + it('requestAnimationFrame exists', function () { + expect(global).to.respondTo('requestAnimationFrame'); + }); + + it('cancelAnimationFrame exists', function () { + expect(global).to.respondTo('cancelAnimationFrame'); + }); + + it('requestAnimFrame exists', function () { + expect(global).to.respondTo('requestAnimFrame'); + }); +}); diff --git a/test/unit/pixi/InteractionManager.js b/test/unit/pixi/InteractionManager.js deleted file mode 100644 index ed3001f..0000000 --- a/test/unit/pixi/InteractionManager.js +++ /dev/null @@ -1,10 +0,0 @@ -describe('pixi/InteractionManager', function () { - 'use strict'; - - var expect = chai.expect; - var InteractionManager = PIXI.InteractionManager; - - it('Module exists', function () { - expect(InteractionManager).to.be.a('function'); - }); -}); diff --git a/test/unit/pixi/Pixi.js b/test/unit/pixi/Pixi.js deleted file mode 100644 index 27debc1..0000000 --- a/test/unit/pixi/Pixi.js +++ /dev/null @@ -1,9 +0,0 @@ -describe('pixi/Pixi', function () { - 'use strict'; - - var expect = chai.expect; - - it('Module exists', function () { - expect(global).to.have.property('PIXI').and.to.be.an('object'); - }); -}); diff --git a/test/unit/pixi/core/Circle.js b/test/unit/pixi/core/Circle.js deleted file mode 100644 index fbcfa17..0000000 --- a/test/unit/pixi/core/Circle.js +++ /dev/null @@ -1,21 +0,0 @@ -describe('pixi/core/Circle', function () { - 'use strict'; - - var expect = chai.expect; - var Circle = PIXI.Circle; - - it('Module exists', function () { - expect(Circle).to.be.a('function'); - }); - - it('Confirm new instance', function () { - var obj = new Circle(); - pixi_core_Circle_confirmNewCircle(obj); - }); - - it("getBounds should return Rectangle that bounds the circle", function() { - var obj = new Circle(100, 250, 50); - var bounds = obj.getBounds(); - pixi_core_Circle_isBoundedByRectangle(obj, bounds); - }); -}); diff --git a/test/unit/pixi/core/Ellipse.js b/test/unit/pixi/core/Ellipse.js deleted file mode 100644 index 026b56f..0000000 --- a/test/unit/pixi/core/Ellipse.js +++ /dev/null @@ -1,24 +0,0 @@ -describe('pixi/core/Ellipse', function () { - 'use strict'; - - var expect = chai.expect; - var Ellipse = PIXI.Ellipse; - - it('Module exists', function () { - expect(Ellipse).to.be.a('function'); - }); - - it('Confirm new instance', function () { - var obj = new Ellipse(); - - expect(obj).to.be.an.instanceof(Ellipse); - expect(obj).to.respondTo('clone'); - expect(obj).to.respondTo('contains'); - expect(obj).to.respondTo('getBounds'); - - expect(obj).to.have.property('x', 0); - expect(obj).to.have.property('y', 0); - expect(obj).to.have.property('width', 0); - expect(obj).to.have.property('height', 0); - }); -}); diff --git a/test/unit/pixi/core/Matrix.js b/test/unit/pixi/core/Matrix.js deleted file mode 100644 index da75e2e..0000000 --- a/test/unit/pixi/core/Matrix.js +++ /dev/null @@ -1,14 +0,0 @@ -describe('pixi/core/Matrix', function () { - 'use strict'; - - var expect = chai.expect; - - it('Matrix exists', function () { - expect(PIXI.Matrix).to.be.an('function'); - }); - - it('Confirm new Matrix', function () { - var matrix = new PIXI.Matrix(); - pixi_core_Matrix_confirmNewMatrix(matrix); - }); -}); diff --git a/test/unit/pixi/core/Point.js b/test/unit/pixi/core/Point.js deleted file mode 100644 index c4d5163..0000000 --- a/test/unit/pixi/core/Point.js +++ /dev/null @@ -1,15 +0,0 @@ -describe('pixi/core/Point', function () { - 'use strict'; - - var expect = chai.expect; - var Point = PIXI.Point; - - it('Module exists', function () { - expect(Point).to.be.a('function'); - }); - - it('Confirm new instance', function () { - var obj = new Point(); - pixi_core_Point_confirm(obj, 0, 0); - }); -}); diff --git a/test/unit/pixi/core/Polygon.js b/test/unit/pixi/core/Polygon.js deleted file mode 100644 index dc8c918..0000000 --- a/test/unit/pixi/core/Polygon.js +++ /dev/null @@ -1,20 +0,0 @@ -describe('pixi/core/Polygon', function () { - 'use strict'; - - var expect = chai.expect; - var Polygon = PIXI.Polygon; - - it('Module exists', function () { - expect(Polygon).to.be.a('function'); - }); - - it('Confirm new instance', function () { - var obj = new Polygon(); - - expect(obj).to.be.an.instanceof(Polygon); - expect(obj).to.respondTo('clone'); - expect(obj).to.respondTo('contains'); - - expect(obj).to.have.deep.property('points.length', 0); - }); -}); diff --git a/test/unit/pixi-v2/InteractionManager.js b/test/unit/pixi-v2/InteractionManager.js new file mode 100644 index 0000000..ed3001f --- /dev/null +++ b/test/unit/pixi-v2/InteractionManager.js @@ -0,0 +1,10 @@ +describe('pixi/InteractionManager', function () { + 'use strict'; + + var expect = chai.expect; + var InteractionManager = PIXI.InteractionManager; + + it('Module exists', function () { + expect(InteractionManager).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/Pixi.js b/test/unit/pixi-v2/Pixi.js new file mode 100644 index 0000000..27debc1 --- /dev/null +++ b/test/unit/pixi-v2/Pixi.js @@ -0,0 +1,9 @@ +describe('pixi/Pixi', function () { + 'use strict'; + + var expect = chai.expect; + + it('Module exists', function () { + expect(global).to.have.property('PIXI').and.to.be.an('object'); + }); +}); diff --git a/test/unit/pixi-v2/core/Circle.js b/test/unit/pixi-v2/core/Circle.js new file mode 100644 index 0000000..fbcfa17 --- /dev/null +++ b/test/unit/pixi-v2/core/Circle.js @@ -0,0 +1,21 @@ +describe('pixi/core/Circle', function () { + 'use strict'; + + var expect = chai.expect; + var Circle = PIXI.Circle; + + it('Module exists', function () { + expect(Circle).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Circle(); + pixi_core_Circle_confirmNewCircle(obj); + }); + + it("getBounds should return Rectangle that bounds the circle", function() { + var obj = new Circle(100, 250, 50); + var bounds = obj.getBounds(); + pixi_core_Circle_isBoundedByRectangle(obj, bounds); + }); +}); diff --git a/test/unit/pixi-v2/core/Ellipse.js b/test/unit/pixi-v2/core/Ellipse.js new file mode 100644 index 0000000..026b56f --- /dev/null +++ b/test/unit/pixi-v2/core/Ellipse.js @@ -0,0 +1,24 @@ +describe('pixi/core/Ellipse', function () { + 'use strict'; + + var expect = chai.expect; + var Ellipse = PIXI.Ellipse; + + it('Module exists', function () { + expect(Ellipse).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Ellipse(); + + expect(obj).to.be.an.instanceof(Ellipse); + expect(obj).to.respondTo('clone'); + expect(obj).to.respondTo('contains'); + expect(obj).to.respondTo('getBounds'); + + expect(obj).to.have.property('x', 0); + expect(obj).to.have.property('y', 0); + expect(obj).to.have.property('width', 0); + expect(obj).to.have.property('height', 0); + }); +}); diff --git a/test/unit/pixi-v2/core/Matrix.js b/test/unit/pixi-v2/core/Matrix.js new file mode 100644 index 0000000..da75e2e --- /dev/null +++ b/test/unit/pixi-v2/core/Matrix.js @@ -0,0 +1,14 @@ +describe('pixi/core/Matrix', function () { + 'use strict'; + + var expect = chai.expect; + + it('Matrix exists', function () { + expect(PIXI.Matrix).to.be.an('function'); + }); + + it('Confirm new Matrix', function () { + var matrix = new PIXI.Matrix(); + pixi_core_Matrix_confirmNewMatrix(matrix); + }); +}); diff --git a/test/unit/pixi-v2/core/Point.js b/test/unit/pixi-v2/core/Point.js new file mode 100644 index 0000000..c4d5163 --- /dev/null +++ b/test/unit/pixi-v2/core/Point.js @@ -0,0 +1,15 @@ +describe('pixi/core/Point', function () { + 'use strict'; + + var expect = chai.expect; + var Point = PIXI.Point; + + it('Module exists', function () { + expect(Point).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Point(); + pixi_core_Point_confirm(obj, 0, 0); + }); +}); diff --git a/test/unit/pixi-v2/core/Polygon.js b/test/unit/pixi-v2/core/Polygon.js new file mode 100644 index 0000000..dc8c918 --- /dev/null +++ b/test/unit/pixi-v2/core/Polygon.js @@ -0,0 +1,20 @@ +describe('pixi/core/Polygon', function () { + 'use strict'; + + var expect = chai.expect; + var Polygon = PIXI.Polygon; + + it('Module exists', function () { + expect(Polygon).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Polygon(); + + expect(obj).to.be.an.instanceof(Polygon); + expect(obj).to.respondTo('clone'); + expect(obj).to.respondTo('contains'); + + expect(obj).to.have.deep.property('points.length', 0); + }); +}); diff --git a/test/unit/pixi-v2/core/Rectangle.js b/test/unit/pixi-v2/core/Rectangle.js new file mode 100644 index 0000000..d43316e --- /dev/null +++ b/test/unit/pixi-v2/core/Rectangle.js @@ -0,0 +1,15 @@ +describe('pixi/core/Rectangle', function () { + 'use strict'; + + var expect = chai.expect; + var Rectangle = PIXI.Rectangle; + + it('Module exists', function () { + expect(Rectangle).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var rect = new Rectangle(); + pixi_core_Rectangle_confirm(rect, 0, 0, 0, 0); + }); +}); diff --git a/test/unit/pixi-v2/display/DisplayObject.js b/test/unit/pixi-v2/display/DisplayObject.js new file mode 100644 index 0000000..044acf8 --- /dev/null +++ b/test/unit/pixi-v2/display/DisplayObject.js @@ -0,0 +1,21 @@ +describe('pixi/display/DisplayObject', function () { + 'use strict'; + + var expect = chai.expect; + var DisplayObject = PIXI.DisplayObject; + + it('Module exists', function () { + expect(DisplayObject).to.be.a('function'); + // expect(PIXI).to.have.property('visibleCount', 0); + }); + + it('Confirm new instance', function () { + var obj = new DisplayObject(); + + pixi_display_DisplayObject_confirmNew(obj); + expect(obj).to.have.property('hitArea', null); + expect(obj).to.have.property('interactive', false); + expect(obj).to.have.property('renderable', false); + expect(obj).to.have.property('stage', null); + }); +}); diff --git a/test/unit/pixi-v2/display/DisplayObjectContainer.js b/test/unit/pixi-v2/display/DisplayObjectContainer.js new file mode 100644 index 0000000..15a3376 --- /dev/null +++ b/test/unit/pixi-v2/display/DisplayObjectContainer.js @@ -0,0 +1,67 @@ +describe('pixi/display/DisplayObjectContainer', function () { + 'use strict'; + + var expect = chai.expect; + var DisplayObjectContainer = PIXI.DisplayObjectContainer; + + it('Module exists', function () { + expect(DisplayObjectContainer).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new DisplayObjectContainer(); + + pixi_display_DisplayObjectContainer_confirmNew(obj); + expect(obj).to.have.property('hitArea', null); + expect(obj).to.have.property('interactive', false); + expect(obj).to.have.property('renderable', false); + expect(obj).to.have.property('stage', null); + }); + + it('Gets child index', function() { + var container = new PIXI.DisplayObjectContainer(); + var children = []; + for (var i = 0; i < 10; i++) { + var child = new PIXI.DisplayObject(); + children.push(child); + container.addChild(child); + } + + for (i = 0; i < children.length; i++) { + expect(i).to.eql(container.getChildIndex(children[i])); + } + }); + + it('throws error when trying to get index of not a child', function() { + var container = new PIXI.DisplayObjectContainer(); + var child = new PIXI.DisplayObject(); + + expect(function() { container.getChildIndex(child); }).to.throw(); + }); + + it('Sets child index', function() { + var container = new PIXI.DisplayObjectContainer(); + var children = []; + + for (var i = 0; i < 10; i++) { + var child = new PIXI.DisplayObject(); + children.push(child); + container.addChild(child); + } + children.reverse(); + + for (i = 0; i < children.length; i++) { + container.setChildIndex(children[i], i); + expect(i).to.eql(container.getChildIndex(children[i])); + } + }); + + it('throws error when trying to set incorect index', function() { + var container = new PIXI.DisplayObjectContainer(); + var child = new PIXI.DisplayObject(); + container.addChild(child); + + expect(function() { container.setChildIndex(child, -1); }).to.throw(); + expect(function() { container.setChildIndex(child, 1); }).to.throw(); + }); +}); diff --git a/test/unit/pixi-v2/display/MovieClip.js b/test/unit/pixi-v2/display/MovieClip.js new file mode 100644 index 0000000..f3c6c6a --- /dev/null +++ b/test/unit/pixi-v2/display/MovieClip.js @@ -0,0 +1,33 @@ +describe('pixi/display/MovieClip', function () { + 'use strict'; + + var expect = chai.expect; + var MovieClip = PIXI.MovieClip; + var Texture = PIXI.Texture; + + it('Module exists', function () { + expect(MovieClip).to.be.a('function'); + }); + + it('Confirm new instance', function (done) { + var texture = Texture.fromImage('/base/test/textures/SpriteSheet-Explosion.png'); + var obj = new MovieClip([texture]); + + pixi_display_Sprite_confirmNew(obj, done); + + expect(obj).to.be.an.instanceof(MovieClip); + expect(obj).to.respondTo('stop'); + expect(obj).to.respondTo('play'); + expect(obj).to.respondTo('gotoAndStop'); + expect(obj).to.respondTo('gotoAndPlay'); + expect(obj).to.respondTo('updateTransform'); + + expect(obj).to.have.deep.property('textures.length', 1); + expect(obj).to.have.deep.property('textures[0]', texture); + expect(obj).to.have.property('animationSpeed', 1); + expect(obj).to.have.property('loop', true); + expect(obj).to.have.property('onComplete', null); + expect(obj).to.have.property('currentFrame', 0); + expect(obj).to.have.property('playing', false); + }); +}); diff --git a/test/unit/pixi-v2/display/Sprite.js b/test/unit/pixi-v2/display/Sprite.js new file mode 100644 index 0000000..30c8076 --- /dev/null +++ b/test/unit/pixi-v2/display/Sprite.js @@ -0,0 +1,28 @@ +describe('pixi/display/Sprite', function () { + 'use strict'; + + var expect = chai.expect; + var Sprite = PIXI.Sprite; + var Texture = PIXI.Texture; + + it('Module exists', function () { + expect(Sprite).to.be.a('function'); + expect(PIXI).to.have.deep.property('blendModes.NORMAL', 0); + expect(PIXI).to.have.deep.property('blendModes.ADD', 1); + expect(PIXI).to.have.deep.property('blendModes.MULTIPLY', 2); + expect(PIXI).to.have.deep.property('blendModes.SCREEN', 3); + }); + + + it('Members exist', function () { + expect(Sprite).itself.to.respondTo('fromImage'); + expect(Sprite).itself.to.respondTo('fromFrame'); + }); + + it('Confirm new instance', function (done) { + var texture = Texture.fromImage('/base/test/textures/SpriteSheet-Aliens.png'); + var obj = new Sprite(texture); + + pixi_display_Sprite_confirmNew(obj, done); + }); +}); diff --git a/test/unit/pixi-v2/display/Stage.js b/test/unit/pixi-v2/display/Stage.js new file mode 100644 index 0000000..6974c2e --- /dev/null +++ b/test/unit/pixi-v2/display/Stage.js @@ -0,0 +1,49 @@ +describe('pixi/display/Stage', function () { + 'use strict'; + + var expect = chai.expect; + var Stage = PIXI.Stage; + var InteractionManager = PIXI.InteractionManager; + var Rectangle = PIXI.Rectangle; + + it('Module exists', function () { + expect(Stage).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Stage(null, true); + + pixi_display_DisplayObjectContainer_confirmNew(obj); + + expect(obj).to.be.an.instanceof(Stage); + expect(obj).to.respondTo('updateTransform'); + expect(obj).to.respondTo('setBackgroundColor'); + expect(obj).to.respondTo('getMousePosition'); + // FIXME: duplicate member in DisplayObject + pixi_core_Matrix_confirmNewMatrix(obj.worldTransform); + // FIXME: convert arg to bool in constructor + expect(obj).to.have.property('interactive', true); + + expect(obj).to.have.property('interactionManager') + .and.to.be.an.instanceof(InteractionManager) + .and.to.have.property('stage', obj); + + expect(obj).to.have.property('dirty', true); + + expect(obj).to.have.property('stage', obj); + + expect(obj).to.have.property('hitArea') + .and.to.be.an.instanceof(Rectangle); + pixi_core_Rectangle_confirm(obj.hitArea, 0, 0, 100000, 100000); + + expect(obj).to.have.property('backgroundColor', 0x000000); + expect(obj).to.have.deep.property('backgroundColorSplit.length', 3); + expect(obj).to.have.deep.property('backgroundColorSplit[0]', 0); + expect(obj).to.have.deep.property('backgroundColorSplit[1]', 0); + expect(obj).to.have.deep.property('backgroundColorSplit[2]', 0); + expect(obj).to.have.property('backgroundColorString', '#000000'); + + + expect(obj).to.have.property('worldVisible', true); + }); +}); diff --git a/test/unit/pixi-v2/extras/Rope.js b/test/unit/pixi-v2/extras/Rope.js new file mode 100644 index 0000000..05885ac --- /dev/null +++ b/test/unit/pixi-v2/extras/Rope.js @@ -0,0 +1,31 @@ +describe('pixi/extras/Rope', function () { + 'use strict'; + + var expect = chai.expect; + var Rope = PIXI.Rope; + var Texture = PIXI.Texture; + var Point = PIXI.Point; + + it('Module exists', function () { + expect(Rope).to.be.a('function'); + }); + + it('Confirm new instance', function () { + + var texture = Texture.fromImage('/base/test/textures/bunny.png'); + + // TODO-Alvin + // Same as Strip + + // var obj = new Rope(texture, [new Point(), new Point(5, 10), new Point(10, 20)]); + + // pixi_extras_Strip_confirmNew(obj); + + // expect(obj).to.be.an.instanceof(Rope); + // expect(obj).to.respondTo('refresh'); + // expect(obj).to.respondTo('updateTransform'); + // expect(obj).to.respondTo('setTexture'); + + // TODO: Test properties + }); +}); diff --git a/test/unit/pixi-v2/extras/Spine.js b/test/unit/pixi-v2/extras/Spine.js new file mode 100644 index 0000000..0708bc0 --- /dev/null +++ b/test/unit/pixi-v2/extras/Spine.js @@ -0,0 +1,10 @@ +describe('pixi/extras/Spine', function () { + 'use strict'; + + var expect = chai.expect; + var Spine = PIXI.Spine; + + it('Module exists', function () { + expect(Spine).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/extras/Strip.js b/test/unit/pixi-v2/extras/Strip.js new file mode 100644 index 0000000..230af90 --- /dev/null +++ b/test/unit/pixi-v2/extras/Strip.js @@ -0,0 +1,26 @@ +describe('pixi/extras/Strip', function () { + 'use strict'; + + var expect = chai.expect; + var Strip = PIXI.Strip; + var Texture = PIXI.Texture; + + it('Module exists', function () { + expect(Strip).to.be.a('function'); + }); + + it('Confirm new instance', function () { + + + // TODO-Alvin + // We tweaked it to make it pass the tests, but the whole strip class needs + // to be re-coded + + var texture = Texture.fromImage('/base/test/textures/bunny.png'); + + // var obj = new Strip(texture, 20, 10000); + + + // pixi_extras_Strip_confirmNew(obj); + }); +}); diff --git a/test/unit/pixi-v2/extras/TilingSprite.js b/test/unit/pixi-v2/extras/TilingSprite.js new file mode 100644 index 0000000..56aea14 --- /dev/null +++ b/test/unit/pixi-v2/extras/TilingSprite.js @@ -0,0 +1,24 @@ +describe('pixi/extras/TilingSprite', function () { + 'use strict'; + + var expect = chai.expect; + var TilingSprite = PIXI.TilingSprite; + var Texture = PIXI.Texture; + + it('Module exists', function () { + expect(TilingSprite).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var texture = Texture.fromImage('/base/test/textures/bunny.png'); + var obj = new TilingSprite(texture, 6000, 12000); + + pixi_display_DisplayObjectContainer_confirmNew(obj); + + expect(obj).to.be.an.instanceof(TilingSprite); + expect(obj).to.respondTo('setTexture'); + expect(obj).to.respondTo('onTextureUpdate'); + + // TODO: Test properties + }); +}); diff --git a/test/unit/pixi-v2/filters/FilterBlock.js b/test/unit/pixi-v2/filters/FilterBlock.js new file mode 100644 index 0000000..870cec0 --- /dev/null +++ b/test/unit/pixi-v2/filters/FilterBlock.js @@ -0,0 +1,10 @@ +describe('pixi/filters/FilterBlock', function () { + 'use strict'; + + var expect = chai.expect; + var FilterBlock = PIXI.FilterBlock; + + it('Module exists', function () { + expect(FilterBlock).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/AssetLoader.js b/test/unit/pixi-v2/loaders/AssetLoader.js new file mode 100644 index 0000000..a0aa0b5 --- /dev/null +++ b/test/unit/pixi-v2/loaders/AssetLoader.js @@ -0,0 +1,10 @@ +describe('pixi/loaders/AssetLoader', function () { + 'use strict'; + + var expect = chai.expect; + var AssetLoader = PIXI.AssetLoader; + + it('Module exists', function () { + expect(AssetLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/BitmapFontLoader.js b/test/unit/pixi-v2/loaders/BitmapFontLoader.js new file mode 100644 index 0000000..046f018 --- /dev/null +++ b/test/unit/pixi-v2/loaders/BitmapFontLoader.js @@ -0,0 +1,9 @@ +describe('pixi/loaders/BitmapFontLoader', function () { + 'use strict'; + + var expect = chai.expect; + + it('Module exists', function () { + expect(PIXI.BitmapFontLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/ImageLoader.js b/test/unit/pixi-v2/loaders/ImageLoader.js new file mode 100644 index 0000000..8b1f556 --- /dev/null +++ b/test/unit/pixi-v2/loaders/ImageLoader.js @@ -0,0 +1,10 @@ +describe('pixi/loaders/ImageLoader', function () { + 'use strict'; + + var expect = chai.expect; + var ImageLoader = PIXI.ImageLoader; + + it('Module exists', function () { + expect(ImageLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/JsonLoader.js b/test/unit/pixi-v2/loaders/JsonLoader.js new file mode 100644 index 0000000..c577e83 --- /dev/null +++ b/test/unit/pixi-v2/loaders/JsonLoader.js @@ -0,0 +1,10 @@ +describe('pixi/loaders/JsonLoader', function () { + 'use strict'; + + var expect = chai.expect; + var JsonLoader = PIXI.JsonLoader; + + it('Module exists', function () { + expect(JsonLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/SpineLoader.js b/test/unit/pixi-v2/loaders/SpineLoader.js new file mode 100644 index 0000000..fdcc0b8 --- /dev/null +++ b/test/unit/pixi-v2/loaders/SpineLoader.js @@ -0,0 +1,10 @@ +describe('pixi/loaders/SpineLoader', function () { + 'use strict'; + + var expect = chai.expect; + var SpineLoader = PIXI.SpineLoader; + + it('Module exists', function () { + expect(SpineLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/SpriteSheetLoader.js b/test/unit/pixi-v2/loaders/SpriteSheetLoader.js new file mode 100644 index 0000000..57beb27 --- /dev/null +++ b/test/unit/pixi-v2/loaders/SpriteSheetLoader.js @@ -0,0 +1,10 @@ +describe('pixi/loaders/SpriteSheetLoader', function () { + 'use strict'; + + var expect = chai.expect; + var SpriteSheetLoader = PIXI.SpriteSheetLoader; + + it('Module exists', function () { + expect(SpriteSheetLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/primitives/Graphics.js b/test/unit/pixi-v2/primitives/Graphics.js new file mode 100644 index 0000000..f3849eb --- /dev/null +++ b/test/unit/pixi-v2/primitives/Graphics.js @@ -0,0 +1,44 @@ +describe('pixi/primitives/Graphics', function () { + 'use strict'; + + var expect = chai.expect; + var Graphics = PIXI.Graphics; + + it('Module exists', function () { + expect(Graphics).to.be.a('function'); + + expect(Graphics).itself.to.have.property('POLY', 0); + expect(Graphics).itself.to.have.property('RECT', 1); + expect(Graphics).itself.to.have.property('CIRC', 2); + expect(Graphics).itself.to.have.property('ELIP', 3); + expect(Graphics).itself.to.have.property('RREC', 4); + }); + + it('Confirm new instance', function () { + var obj = new Graphics(); + + pixi_display_DisplayObjectContainer_confirmNew(obj); + + expect(obj).to.be.an.instanceof(Graphics); + expect(obj).to.respondTo('lineStyle'); + expect(obj).to.respondTo('lineStyle'); + expect(obj).to.respondTo('moveTo'); + expect(obj).to.respondTo('lineTo'); + expect(obj).to.respondTo('beginFill'); + expect(obj).to.respondTo('endFill'); + expect(obj).to.respondTo('drawRect'); + // expect(obj).to.respondTo('drawRoundedRect'); + expect(obj).to.respondTo('drawCircle'); + expect(obj).to.respondTo('drawEllipse'); + expect(obj).to.respondTo('clear'); + + expect(obj).to.have.property('renderable', true); + expect(obj).to.have.property('fillAlpha', 1); + expect(obj).to.have.property('lineWidth', 0); + expect(obj).to.have.property('width', 0); + expect(obj).to.have.property('height', 0); + expect(obj).to.have.property('lineColor', 0); + expect(obj).to.have.deep.property('graphicsData.length', 0); + // expect(obj).to.have.deep.property('currentPath.points.length', 0); + }); +}); diff --git a/test/unit/pixi-v2/renderers/canvas/CanvasGraphics.js b/test/unit/pixi-v2/renderers/canvas/CanvasGraphics.js new file mode 100644 index 0000000..8f44472 --- /dev/null +++ b/test/unit/pixi-v2/renderers/canvas/CanvasGraphics.js @@ -0,0 +1,15 @@ +describe('renders/canvas/CanvasGraphics', function () { + 'use strict'; + + var expect = chai.expect; + var CanvasGraphics = PIXI.CanvasGraphics; + + it('Module exists', function () { + expect(CanvasGraphics).to.be.a('function'); + }); + + it('Members exist', function () { + expect(CanvasGraphics).itself.to.respondTo('renderGraphics'); + expect(CanvasGraphics).itself.to.respondTo('renderGraphicsMask'); + }); +}); diff --git a/test/unit/pixi-v2/renderers/canvas/CanvasRenderer.js b/test/unit/pixi-v2/renderers/canvas/CanvasRenderer.js new file mode 100644 index 0000000..1646444 --- /dev/null +++ b/test/unit/pixi-v2/renderers/canvas/CanvasRenderer.js @@ -0,0 +1,36 @@ +describe('renderers/canvas/CanvasRenderer', function () { + 'use strict'; + + var expect = chai.expect; + var CanvasRenderer = PIXI.CanvasRenderer; + + it('Module exists', function () { + expect(CanvasRenderer).to.be.a('function'); + }); + + describe('.autoResize', function () { + it('Should automatically resize view if enabled', function () { + var renderer = new CanvasRenderer(200, 200, { + autoResize: true + }); + + expect(renderer.view.style.width).to.equal('200px'); + }); + + it('Should not automatically resize view if disabled', function () { + var renderer = new CanvasRenderer(200, 200, { + autoResize: false + }); + + expect(renderer.view.style.width).to.equal(''); + }); + + it('Should not automatically resize view if not specified', function () { + var renderer = new CanvasRenderer(200, 200, { + resolution: 2 + }); + + expect(renderer.view.style.width).to.equal(''); + }); + }); +}); diff --git a/test/unit/pixi-v2/renderers/webgl/WebGLGraphics.js b/test/unit/pixi-v2/renderers/webgl/WebGLGraphics.js new file mode 100644 index 0000000..5867b28 --- /dev/null +++ b/test/unit/pixi-v2/renderers/webgl/WebGLGraphics.js @@ -0,0 +1,20 @@ +describe('renderers/wegbl/WebGLGraphics', function () { + 'use strict'; + + var expect = chai.expect; + var WebGLGraphics = PIXI.WebGLGraphics; + + it('Module exists', function () { + expect(WebGLGraphics).to.be.a('function'); + }); + + it('Members exist', function () { + expect(WebGLGraphics).itself.to.respondTo('renderGraphics'); + expect(WebGLGraphics).itself.to.respondTo('updateGraphics'); + expect(WebGLGraphics).itself.to.respondTo('buildRectangle'); + expect(WebGLGraphics).itself.to.respondTo('buildRoundedRectangle'); + expect(WebGLGraphics).itself.to.respondTo('buildCircle'); + expect(WebGLGraphics).itself.to.respondTo('buildLine'); + expect(WebGLGraphics).itself.to.respondTo('buildPoly'); + }); +}); diff --git a/test/unit/pixi-v2/renderers/webgl/WebGLRenderer.js b/test/unit/pixi-v2/renderers/webgl/WebGLRenderer.js new file mode 100644 index 0000000..1680a80 --- /dev/null +++ b/test/unit/pixi-v2/renderers/webgl/WebGLRenderer.js @@ -0,0 +1,49 @@ +describe('renderers/webgl/WebGLRenderer', function () { + 'use strict'; + + var expect = chai.expect; + var WebGLRenderer = PIXI.WebGLRenderer; + + it('Module exists', function () { + expect(WebGLRenderer).to.be.a('function'); + }); + + // Skip tests if WebGL is not available (WebGL not supported in Travis CI) + try { + var renderer = new WebGLRenderer(400, 300, {}); + renderer.destroy(); + } catch (error) { + return; + } + + it('Destroy renderer', function () { + var renderer = new WebGLRenderer(400, 300, {}); + renderer.destroy(); + }); + + describe('.autoResize', function () { + it('Should automatically resize view if enabled', function () { + var renderer = new WebGLRenderer(200, 200, { + autoResize: true + }); + + expect(renderer.view.style.width).to.equal('200px'); + }); + + it('Should not automatically resize view if disabled', function () { + var renderer = new WebGLRenderer(200, 200, { + autoResize: false + }); + + expect(renderer.view.style.width).to.equal(''); + }); + + it('Should not automatically resize view if not specified', function () { + var renderer = new WebGLRenderer(200, 200, { + resolution: 2 + }); + + expect(renderer.view.style.width).to.equal(''); + }); + }); +}); diff --git a/test/unit/pixi-v2/renderers/webgl/WebGLShaders.js b/test/unit/pixi-v2/renderers/webgl/WebGLShaders.js new file mode 100644 index 0000000..6e33e4f --- /dev/null +++ b/test/unit/pixi-v2/renderers/webgl/WebGLShaders.js @@ -0,0 +1,13 @@ +describe('renderers/webgl/WebGLShaders', function () { + 'use strict'; + + var expect = chai.expect; + + it('Module members exist', function () { + + expect(PIXI).to.respondTo('CompileVertexShader'); + expect(PIXI).to.respondTo('CompileFragmentShader'); + expect(PIXI).to.respondTo('_CompileShader'); + expect(PIXI).to.respondTo('compileProgram'); + }); +}); diff --git a/test/unit/pixi-v2/renderers/webgl/WebGLSpriteBatch.js b/test/unit/pixi-v2/renderers/webgl/WebGLSpriteBatch.js new file mode 100644 index 0000000..e662b63 --- /dev/null +++ b/test/unit/pixi-v2/renderers/webgl/WebGLSpriteBatch.js @@ -0,0 +1,10 @@ +describe('renderers/webgl/utils/WebGLSpriteBatch', function () { + 'use strict'; + + var expect = chai.expect; + var WebGLSpriteBatch = PIXI.WebGLSpriteBatch; + + it('Module exists', function () { + expect(WebGLSpriteBatch).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/text/BitmapText.js b/test/unit/pixi-v2/text/BitmapText.js new file mode 100644 index 0000000..9388e3d --- /dev/null +++ b/test/unit/pixi-v2/text/BitmapText.js @@ -0,0 +1,10 @@ +describe('pixi/text/BitmapText', function () { + 'use strict'; + + var expect = chai.expect; + var BitmapText = PIXI.BitmapText; + + it('Module exists', function () { + expect(BitmapText).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/text/Text.js b/test/unit/pixi-v2/text/Text.js new file mode 100644 index 0000000..9bc9ac5 --- /dev/null +++ b/test/unit/pixi-v2/text/Text.js @@ -0,0 +1,10 @@ +describe('pixi/text/Text', function () { + 'use strict'; + + var expect = chai.expect; + var Text = PIXI.Text; + + it('Module exists', function () { + expect(Text).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/textures/BaseTexture.js b/test/unit/pixi-v2/textures/BaseTexture.js new file mode 100644 index 0000000..502b724 --- /dev/null +++ b/test/unit/pixi-v2/textures/BaseTexture.js @@ -0,0 +1,11 @@ +describe('pixi/textures/BaseTexture', function () { + 'use strict'; + + var expect = chai.expect; + var BaseTexture = PIXI.BaseTexture; + + it('Module exists', function () { + expect(BaseTexture).to.be.a('function'); + expect(PIXI).to.have.property('BaseTextureCache').and.to.be.an('object'); + }); +}); diff --git a/test/unit/pixi-v2/textures/RenderTexture.js b/test/unit/pixi-v2/textures/RenderTexture.js new file mode 100644 index 0000000..96acdb4 --- /dev/null +++ b/test/unit/pixi-v2/textures/RenderTexture.js @@ -0,0 +1,15 @@ +describe('pixi/textures/RenderTexture', function () { + 'use strict'; + + var expect = chai.expect; + var RenderTexture = PIXI.RenderTexture; + + it('Module exists', function () { + expect(RenderTexture).to.be.a('function'); + }); + + it('Confirm new instance', function (done) { + var texture = new RenderTexture(100, 100, new PIXI.CanvasRenderer()); + pixi_textures_RenderTexture_confirmNew(texture, done); + }); +}); diff --git a/test/unit/pixi-v2/textures/Texture.js b/test/unit/pixi-v2/textures/Texture.js new file mode 100644 index 0000000..090f64d --- /dev/null +++ b/test/unit/pixi-v2/textures/Texture.js @@ -0,0 +1,26 @@ +describe('pixi/textures/Texture', function () { + 'use strict'; + + var expect = chai.expect; + var Texture = PIXI.Texture; + + it('Module exists', function () { + expect(Texture).to.be.a('function'); + expect(PIXI).to.have.property('TextureCache').and.to.be.an('object'); + }); + + it('Members exist', function () { + expect(Texture).itself.to.respondTo('fromImage'); + expect(Texture).itself.to.respondTo('fromFrame'); + expect(Texture).itself.to.respondTo('fromCanvas'); + expect(Texture).itself.to.respondTo('addTextureToCache'); + expect(Texture).itself.to.respondTo('removeTextureFromCache'); + + // expect(Texture).itself.to.have.deep.property('frameUpdates.length', 0); + }); + + it('Confirm new instance', function (done) { + var texture = Texture.fromImage('/base/test/textures/bunny.png'); + pixi_textures_Texture_confirmNew(texture, done); + }); +}); diff --git a/test/unit/pixi-v2/utils/Detector.js b/test/unit/pixi-v2/utils/Detector.js new file mode 100644 index 0000000..4cf6008 --- /dev/null +++ b/test/unit/pixi-v2/utils/Detector.js @@ -0,0 +1,10 @@ +describe('pixi/utils/Detector', function () { + 'use strict'; + + var expect = chai.expect; + var autoDetectRenderer = PIXI.autoDetectRenderer; + + it('Module exists', function () { + expect(autoDetectRenderer).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/utils/EventTarget.js b/test/unit/pixi-v2/utils/EventTarget.js new file mode 100644 index 0000000..1cfc3a4 --- /dev/null +++ b/test/unit/pixi-v2/utils/EventTarget.js @@ -0,0 +1,361 @@ +describe('pixi/utils/EventTarget', function () { + 'use strict'; + + var expect = chai.expect; + + var Clazz, PClazz, obj, pobj, obj2; + beforeEach(function () { + Clazz = function () {}; + PClazz = function () {}; + + PIXI.EventTarget.mixin(Clazz.prototype); + PIXI.EventTarget.mixin(PClazz.prototype); + + obj = new Clazz(); + obj2 = new Clazz(); + pobj = new PClazz(); + + obj.parent = pobj; + obj2.parent = obj; + }); + + it('Module exists', function () { + expect(PIXI.EventTarget).to.be.an('object'); + }); + + it('Confirm new instance', function () { + pixi_utils_EventTarget_confirm(obj); + }); + + it('simple on/emit case works', function () { + var myData = {}; + + obj.on('myevent', function (event) { + pixi_utils_EventTarget_Event_confirm(event, obj, myData); + }); + + obj.emit('myevent', myData); + }); + + it('simple once case works', function () { + var called = 0; + + obj.once('myevent', function() { called++; }); + + obj.emit('myevent'); + obj.emit('myevent'); + obj.emit('myevent'); + obj.emit('myevent'); + obj.emit('myevent'); + + expect(called).to.equal(1); + }); + + it('simple off case works', function (done) { + function onMyEvent() { + done(new Error('Event listener should not have been called')); + } + + obj.on('myevent', onMyEvent); + obj.off('myevent', onMyEvent); + obj.emit('myevent'); + + done(); + }); + + it('simple propagation case works', function (done) { + var myData = {}; + + pobj.on('myevent', function () { + done(); + }); + + obj.emit('myevent'); + }); + + it('simple stopPropagation case works', function (done) { + var myData = {}; + + pobj.on('myevent', function () { + done(new Error('Event listener should not have been called on the parent element')); + }); + + obj.on('myevent', function (evt) { + evt.stopPropagation(); + }); + + obj.emit('myevent'); + + done(); + }); + + it('simple stopImmediatePropagation case works', function (done) { + var myData = {}; + + pobj.on('myevent', function () { + done(new Error('Event listener should not have been called on the parent')); + }); + + obj.on('myevent', function (evt) { + evt.stopImmediatePropagation(); + }); + + obj.on('myevent', function () { + done(new Error('Event listener should not have been called on the second')); + }); + + obj.emit('myevent'); + + done(); + }); + + it('multiple dispatches work properly', function () { + var called = 0; + + function onMyEvent() { + called++; + } + + obj.on('myevent', onMyEvent); + obj.emit('myevent'); + obj.emit('myevent'); + obj.emit('myevent'); + obj.emit('myevent'); + + expect(called).to.equal(4); + }); + + it('multiple events work properly', function () { + var called = 0; + + function onMyEvent() { + called++; + } + + obj.on('myevent1', onMyEvent); + obj.on('myevent2', onMyEvent); + obj.on('myevent3', onMyEvent); + obj.emit('myevent1'); + obj.emit('myevent2'); + obj.emit('myevent3'); + + expect(called).to.equal(3); + }); + + it('multiple events one removed works properly', function () { + var called = 0; + + function onMyEvent() { + called++; + } + + obj.on('myevent1', onMyEvent); + obj.on('myevent2', onMyEvent); + obj.on('myevent3', onMyEvent); + + obj.emit('myevent1'); + obj.emit('myevent2'); + obj.emit('myevent3'); + + obj.off('myevent2', onMyEvent); + + obj.emit('myevent1'); + obj.emit('myevent2'); + obj.emit('myevent3'); + + expect(called).to.equal(5); + }); + + it('multiple handlers for one event with some removed', function () { + var called = 0; + + var onMyEvent = function () { + called++; + }, + onMyEvent2 = function () { + called++; + }; + + // add 2 handlers and confirm they both get called + obj.on('myevent', onMyEvent); + obj.on('myevent', onMyEvent); + obj.on('myevent', onMyEvent2); + obj.on('myevent', onMyEvent2); + + obj.emit('myevent'); + + expect(called).to.equal(4); + + // remove one of the handlers, emit again, then ensure 1 more call is made + obj.off('myevent', onMyEvent); + + obj.emit('myevent'); + + expect(called).to.equal(6); + }); + + it('calls to off without a handler do nothing', function () { + var called = 0; + + var onMyEvent = function () { + called++; + }; + + obj.on('myevent', onMyEvent); + obj.on('myevent', onMyEvent); + + obj.emit('myevent'); + + expect(called).to.equal(2); + + obj.off('myevent'); + + obj.emit('myevent'); + + expect(called).to.equal(4); + + obj.off('myevent', onMyEvent); + + obj.emit('myevent'); + + expect(called).to.equal(4); + }); + + it('handles multiple instances with the same prototype', function () { + var called = 0; + + function onMyEvent(e) { + called++; + } + + obj.on('myevent1', onMyEvent); + obj.on('myevent2', onMyEvent); + + obj2.istwo = true; + obj2.on('myevent1', onMyEvent); + obj2.on('myevent2', onMyEvent); + + obj.emit('myevent1'); + obj.emit('myevent2'); + obj2.emit('myevent1'); + obj2.emit('myevent2'); + + //we emit 4 times, but since obj2 is a child of obj the event should bubble + //up to obj and show up there as well. So the obj2.emit() calls each increment + //the counter twice. + expect(called).to.equal(6); + }); + + it('is backwards compatible with older .dispatchEvent({})', function () { + var called = 0, + data = { + some: 'thing', + hello: true + }; + + function onMyEvent(event) { + pixi_utils_EventTarget_Event_confirm(event, obj, data); + + called++; + } + + obj.on('myevent1', onMyEvent); + obj.on('myevent2', onMyEvent); + obj.on('myevent3', onMyEvent); + + data.type = 'myevent1'; + obj.emit(data); + + data.type = 'myevent2'; + obj.emit(data); + + data.type = 'myevent3'; + obj.emit(data); + + obj.off('myevent2', onMyEvent); + + data.type = 'myevent1'; + obj.emit(data); + + data.type = 'myevent2'; + obj.emit(data); + + data.type = 'myevent3'; + obj.emit(data); + + expect(called).to.equal(5); + }); + + it('is backwards compatible with older .call(this)', function () { + var Fn = function() { + PIXI.EventTarget.call(this); + }, + o = new Fn(); + + pixi_utils_EventTarget_confirm(o); + }); + + it('is backwards compatible with older .addEventListener("")', function () { + var called = 0, + data = { + some: 'thing', + hello: true + }; + + function onMyEvent(event) { + pixi_utils_EventTarget_Event_confirm(event, obj, data); + + called++; + } + + obj.addEventListener('myevent1', onMyEvent); + obj.addEventListener('myevent2', onMyEvent); + obj.addEventListener('myevent3', onMyEvent); + + data.type = 'myevent1'; + obj.emit(data); + + data.type = 'myevent2'; + obj.emit(data); + + data.type = 'myevent3'; + obj.emit(data); + + obj.off('myevent2', onMyEvent); + + data.type = 'myevent1'; + obj.emit(data); + + data.type = 'myevent2'; + obj.emit(data); + + data.type = 'myevent3'; + obj.emit(data); + + expect(called).to.equal(5); + }); + + it('event remove during emit call properly', function () { + var called = 0; + + function cb1() { + called++; + obj.off('myevent', cb1); + } + function cb2() { + called++; + obj.off('myevent', cb2); + } + function cb3() { + called++; + obj.off('myevent', cb3); + } + + obj.on('myevent', cb1); + obj.on('myevent', cb2); + obj.on('myevent', cb3); + obj.emit('myevent', ''); + + expect(called).to.equal(3); + }); +}); diff --git a/test/unit/pixi-v2/utils/Polyk.js b/test/unit/pixi-v2/utils/Polyk.js new file mode 100644 index 0000000..dfc7128 --- /dev/null +++ b/test/unit/pixi-v2/utils/Polyk.js @@ -0,0 +1,14 @@ +describe('pixi/utils/Polyk', function () { + 'use strict'; + + var expect = chai.expect; + var PolyK = PIXI.PolyK; + + it('Module exists', function () { + expect(PolyK).to.be.an('object'); + }); + + it('Members exist', function () { + expect(PolyK).to.respondTo('Triangulate'); + }); +}); diff --git a/test/unit/pixi-v2/utils/Utils.js b/test/unit/pixi-v2/utils/Utils.js new file mode 100644 index 0000000..c97b3c6 --- /dev/null +++ b/test/unit/pixi-v2/utils/Utils.js @@ -0,0 +1,17 @@ +describe('Utils', function () { + 'use strict'; + + var expect = chai.expect; + + it('requestAnimationFrame exists', function () { + expect(global).to.respondTo('requestAnimationFrame'); + }); + + it('cancelAnimationFrame exists', function () { + expect(global).to.respondTo('cancelAnimationFrame'); + }); + + it('requestAnimFrame exists', function () { + expect(global).to.respondTo('requestAnimFrame'); + }); +}); diff --git a/test/unit/pixi/InteractionManager.js b/test/unit/pixi/InteractionManager.js deleted file mode 100644 index ed3001f..0000000 --- a/test/unit/pixi/InteractionManager.js +++ /dev/null @@ -1,10 +0,0 @@ -describe('pixi/InteractionManager', function () { - 'use strict'; - - var expect = chai.expect; - var InteractionManager = PIXI.InteractionManager; - - it('Module exists', function () { - expect(InteractionManager).to.be.a('function'); - }); -}); diff --git a/test/unit/pixi/Pixi.js b/test/unit/pixi/Pixi.js deleted file mode 100644 index 27debc1..0000000 --- a/test/unit/pixi/Pixi.js +++ /dev/null @@ -1,9 +0,0 @@ -describe('pixi/Pixi', function () { - 'use strict'; - - var expect = chai.expect; - - it('Module exists', function () { - expect(global).to.have.property('PIXI').and.to.be.an('object'); - }); -}); diff --git a/test/unit/pixi/core/Circle.js b/test/unit/pixi/core/Circle.js deleted file mode 100644 index fbcfa17..0000000 --- a/test/unit/pixi/core/Circle.js +++ /dev/null @@ -1,21 +0,0 @@ -describe('pixi/core/Circle', function () { - 'use strict'; - - var expect = chai.expect; - var Circle = PIXI.Circle; - - it('Module exists', function () { - expect(Circle).to.be.a('function'); - }); - - it('Confirm new instance', function () { - var obj = new Circle(); - pixi_core_Circle_confirmNewCircle(obj); - }); - - it("getBounds should return Rectangle that bounds the circle", function() { - var obj = new Circle(100, 250, 50); - var bounds = obj.getBounds(); - pixi_core_Circle_isBoundedByRectangle(obj, bounds); - }); -}); diff --git a/test/unit/pixi/core/Ellipse.js b/test/unit/pixi/core/Ellipse.js deleted file mode 100644 index 026b56f..0000000 --- a/test/unit/pixi/core/Ellipse.js +++ /dev/null @@ -1,24 +0,0 @@ -describe('pixi/core/Ellipse', function () { - 'use strict'; - - var expect = chai.expect; - var Ellipse = PIXI.Ellipse; - - it('Module exists', function () { - expect(Ellipse).to.be.a('function'); - }); - - it('Confirm new instance', function () { - var obj = new Ellipse(); - - expect(obj).to.be.an.instanceof(Ellipse); - expect(obj).to.respondTo('clone'); - expect(obj).to.respondTo('contains'); - expect(obj).to.respondTo('getBounds'); - - expect(obj).to.have.property('x', 0); - expect(obj).to.have.property('y', 0); - expect(obj).to.have.property('width', 0); - expect(obj).to.have.property('height', 0); - }); -}); diff --git a/test/unit/pixi/core/Matrix.js b/test/unit/pixi/core/Matrix.js deleted file mode 100644 index da75e2e..0000000 --- a/test/unit/pixi/core/Matrix.js +++ /dev/null @@ -1,14 +0,0 @@ -describe('pixi/core/Matrix', function () { - 'use strict'; - - var expect = chai.expect; - - it('Matrix exists', function () { - expect(PIXI.Matrix).to.be.an('function'); - }); - - it('Confirm new Matrix', function () { - var matrix = new PIXI.Matrix(); - pixi_core_Matrix_confirmNewMatrix(matrix); - }); -}); diff --git a/test/unit/pixi/core/Point.js b/test/unit/pixi/core/Point.js deleted file mode 100644 index c4d5163..0000000 --- a/test/unit/pixi/core/Point.js +++ /dev/null @@ -1,15 +0,0 @@ -describe('pixi/core/Point', function () { - 'use strict'; - - var expect = chai.expect; - var Point = PIXI.Point; - - it('Module exists', function () { - expect(Point).to.be.a('function'); - }); - - it('Confirm new instance', function () { - var obj = new Point(); - pixi_core_Point_confirm(obj, 0, 0); - }); -}); diff --git a/test/unit/pixi/core/Polygon.js b/test/unit/pixi/core/Polygon.js deleted file mode 100644 index dc8c918..0000000 --- a/test/unit/pixi/core/Polygon.js +++ /dev/null @@ -1,20 +0,0 @@ -describe('pixi/core/Polygon', function () { - 'use strict'; - - var expect = chai.expect; - var Polygon = PIXI.Polygon; - - it('Module exists', function () { - expect(Polygon).to.be.a('function'); - }); - - it('Confirm new instance', function () { - var obj = new Polygon(); - - expect(obj).to.be.an.instanceof(Polygon); - expect(obj).to.respondTo('clone'); - expect(obj).to.respondTo('contains'); - - expect(obj).to.have.deep.property('points.length', 0); - }); -}); diff --git a/test/unit/pixi/core/Rectangle.js b/test/unit/pixi/core/Rectangle.js deleted file mode 100644 index d43316e..0000000 --- a/test/unit/pixi/core/Rectangle.js +++ /dev/null @@ -1,15 +0,0 @@ -describe('pixi/core/Rectangle', function () { - 'use strict'; - - var expect = chai.expect; - var Rectangle = PIXI.Rectangle; - - it('Module exists', function () { - expect(Rectangle).to.be.a('function'); - }); - - it('Confirm new instance', function () { - var rect = new Rectangle(); - pixi_core_Rectangle_confirm(rect, 0, 0, 0, 0); - }); -}); diff --git a/test/unit/pixi-v2/InteractionManager.js b/test/unit/pixi-v2/InteractionManager.js new file mode 100644 index 0000000..ed3001f --- /dev/null +++ b/test/unit/pixi-v2/InteractionManager.js @@ -0,0 +1,10 @@ +describe('pixi/InteractionManager', function () { + 'use strict'; + + var expect = chai.expect; + var InteractionManager = PIXI.InteractionManager; + + it('Module exists', function () { + expect(InteractionManager).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/Pixi.js b/test/unit/pixi-v2/Pixi.js new file mode 100644 index 0000000..27debc1 --- /dev/null +++ b/test/unit/pixi-v2/Pixi.js @@ -0,0 +1,9 @@ +describe('pixi/Pixi', function () { + 'use strict'; + + var expect = chai.expect; + + it('Module exists', function () { + expect(global).to.have.property('PIXI').and.to.be.an('object'); + }); +}); diff --git a/test/unit/pixi-v2/core/Circle.js b/test/unit/pixi-v2/core/Circle.js new file mode 100644 index 0000000..fbcfa17 --- /dev/null +++ b/test/unit/pixi-v2/core/Circle.js @@ -0,0 +1,21 @@ +describe('pixi/core/Circle', function () { + 'use strict'; + + var expect = chai.expect; + var Circle = PIXI.Circle; + + it('Module exists', function () { + expect(Circle).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Circle(); + pixi_core_Circle_confirmNewCircle(obj); + }); + + it("getBounds should return Rectangle that bounds the circle", function() { + var obj = new Circle(100, 250, 50); + var bounds = obj.getBounds(); + pixi_core_Circle_isBoundedByRectangle(obj, bounds); + }); +}); diff --git a/test/unit/pixi-v2/core/Ellipse.js b/test/unit/pixi-v2/core/Ellipse.js new file mode 100644 index 0000000..026b56f --- /dev/null +++ b/test/unit/pixi-v2/core/Ellipse.js @@ -0,0 +1,24 @@ +describe('pixi/core/Ellipse', function () { + 'use strict'; + + var expect = chai.expect; + var Ellipse = PIXI.Ellipse; + + it('Module exists', function () { + expect(Ellipse).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Ellipse(); + + expect(obj).to.be.an.instanceof(Ellipse); + expect(obj).to.respondTo('clone'); + expect(obj).to.respondTo('contains'); + expect(obj).to.respondTo('getBounds'); + + expect(obj).to.have.property('x', 0); + expect(obj).to.have.property('y', 0); + expect(obj).to.have.property('width', 0); + expect(obj).to.have.property('height', 0); + }); +}); diff --git a/test/unit/pixi-v2/core/Matrix.js b/test/unit/pixi-v2/core/Matrix.js new file mode 100644 index 0000000..da75e2e --- /dev/null +++ b/test/unit/pixi-v2/core/Matrix.js @@ -0,0 +1,14 @@ +describe('pixi/core/Matrix', function () { + 'use strict'; + + var expect = chai.expect; + + it('Matrix exists', function () { + expect(PIXI.Matrix).to.be.an('function'); + }); + + it('Confirm new Matrix', function () { + var matrix = new PIXI.Matrix(); + pixi_core_Matrix_confirmNewMatrix(matrix); + }); +}); diff --git a/test/unit/pixi-v2/core/Point.js b/test/unit/pixi-v2/core/Point.js new file mode 100644 index 0000000..c4d5163 --- /dev/null +++ b/test/unit/pixi-v2/core/Point.js @@ -0,0 +1,15 @@ +describe('pixi/core/Point', function () { + 'use strict'; + + var expect = chai.expect; + var Point = PIXI.Point; + + it('Module exists', function () { + expect(Point).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Point(); + pixi_core_Point_confirm(obj, 0, 0); + }); +}); diff --git a/test/unit/pixi-v2/core/Polygon.js b/test/unit/pixi-v2/core/Polygon.js new file mode 100644 index 0000000..dc8c918 --- /dev/null +++ b/test/unit/pixi-v2/core/Polygon.js @@ -0,0 +1,20 @@ +describe('pixi/core/Polygon', function () { + 'use strict'; + + var expect = chai.expect; + var Polygon = PIXI.Polygon; + + it('Module exists', function () { + expect(Polygon).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Polygon(); + + expect(obj).to.be.an.instanceof(Polygon); + expect(obj).to.respondTo('clone'); + expect(obj).to.respondTo('contains'); + + expect(obj).to.have.deep.property('points.length', 0); + }); +}); diff --git a/test/unit/pixi-v2/core/Rectangle.js b/test/unit/pixi-v2/core/Rectangle.js new file mode 100644 index 0000000..d43316e --- /dev/null +++ b/test/unit/pixi-v2/core/Rectangle.js @@ -0,0 +1,15 @@ +describe('pixi/core/Rectangle', function () { + 'use strict'; + + var expect = chai.expect; + var Rectangle = PIXI.Rectangle; + + it('Module exists', function () { + expect(Rectangle).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var rect = new Rectangle(); + pixi_core_Rectangle_confirm(rect, 0, 0, 0, 0); + }); +}); diff --git a/test/unit/pixi-v2/display/DisplayObject.js b/test/unit/pixi-v2/display/DisplayObject.js new file mode 100644 index 0000000..044acf8 --- /dev/null +++ b/test/unit/pixi-v2/display/DisplayObject.js @@ -0,0 +1,21 @@ +describe('pixi/display/DisplayObject', function () { + 'use strict'; + + var expect = chai.expect; + var DisplayObject = PIXI.DisplayObject; + + it('Module exists', function () { + expect(DisplayObject).to.be.a('function'); + // expect(PIXI).to.have.property('visibleCount', 0); + }); + + it('Confirm new instance', function () { + var obj = new DisplayObject(); + + pixi_display_DisplayObject_confirmNew(obj); + expect(obj).to.have.property('hitArea', null); + expect(obj).to.have.property('interactive', false); + expect(obj).to.have.property('renderable', false); + expect(obj).to.have.property('stage', null); + }); +}); diff --git a/test/unit/pixi-v2/display/DisplayObjectContainer.js b/test/unit/pixi-v2/display/DisplayObjectContainer.js new file mode 100644 index 0000000..15a3376 --- /dev/null +++ b/test/unit/pixi-v2/display/DisplayObjectContainer.js @@ -0,0 +1,67 @@ +describe('pixi/display/DisplayObjectContainer', function () { + 'use strict'; + + var expect = chai.expect; + var DisplayObjectContainer = PIXI.DisplayObjectContainer; + + it('Module exists', function () { + expect(DisplayObjectContainer).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new DisplayObjectContainer(); + + pixi_display_DisplayObjectContainer_confirmNew(obj); + expect(obj).to.have.property('hitArea', null); + expect(obj).to.have.property('interactive', false); + expect(obj).to.have.property('renderable', false); + expect(obj).to.have.property('stage', null); + }); + + it('Gets child index', function() { + var container = new PIXI.DisplayObjectContainer(); + var children = []; + for (var i = 0; i < 10; i++) { + var child = new PIXI.DisplayObject(); + children.push(child); + container.addChild(child); + } + + for (i = 0; i < children.length; i++) { + expect(i).to.eql(container.getChildIndex(children[i])); + } + }); + + it('throws error when trying to get index of not a child', function() { + var container = new PIXI.DisplayObjectContainer(); + var child = new PIXI.DisplayObject(); + + expect(function() { container.getChildIndex(child); }).to.throw(); + }); + + it('Sets child index', function() { + var container = new PIXI.DisplayObjectContainer(); + var children = []; + + for (var i = 0; i < 10; i++) { + var child = new PIXI.DisplayObject(); + children.push(child); + container.addChild(child); + } + children.reverse(); + + for (i = 0; i < children.length; i++) { + container.setChildIndex(children[i], i); + expect(i).to.eql(container.getChildIndex(children[i])); + } + }); + + it('throws error when trying to set incorect index', function() { + var container = new PIXI.DisplayObjectContainer(); + var child = new PIXI.DisplayObject(); + container.addChild(child); + + expect(function() { container.setChildIndex(child, -1); }).to.throw(); + expect(function() { container.setChildIndex(child, 1); }).to.throw(); + }); +}); diff --git a/test/unit/pixi-v2/display/MovieClip.js b/test/unit/pixi-v2/display/MovieClip.js new file mode 100644 index 0000000..f3c6c6a --- /dev/null +++ b/test/unit/pixi-v2/display/MovieClip.js @@ -0,0 +1,33 @@ +describe('pixi/display/MovieClip', function () { + 'use strict'; + + var expect = chai.expect; + var MovieClip = PIXI.MovieClip; + var Texture = PIXI.Texture; + + it('Module exists', function () { + expect(MovieClip).to.be.a('function'); + }); + + it('Confirm new instance', function (done) { + var texture = Texture.fromImage('/base/test/textures/SpriteSheet-Explosion.png'); + var obj = new MovieClip([texture]); + + pixi_display_Sprite_confirmNew(obj, done); + + expect(obj).to.be.an.instanceof(MovieClip); + expect(obj).to.respondTo('stop'); + expect(obj).to.respondTo('play'); + expect(obj).to.respondTo('gotoAndStop'); + expect(obj).to.respondTo('gotoAndPlay'); + expect(obj).to.respondTo('updateTransform'); + + expect(obj).to.have.deep.property('textures.length', 1); + expect(obj).to.have.deep.property('textures[0]', texture); + expect(obj).to.have.property('animationSpeed', 1); + expect(obj).to.have.property('loop', true); + expect(obj).to.have.property('onComplete', null); + expect(obj).to.have.property('currentFrame', 0); + expect(obj).to.have.property('playing', false); + }); +}); diff --git a/test/unit/pixi-v2/display/Sprite.js b/test/unit/pixi-v2/display/Sprite.js new file mode 100644 index 0000000..30c8076 --- /dev/null +++ b/test/unit/pixi-v2/display/Sprite.js @@ -0,0 +1,28 @@ +describe('pixi/display/Sprite', function () { + 'use strict'; + + var expect = chai.expect; + var Sprite = PIXI.Sprite; + var Texture = PIXI.Texture; + + it('Module exists', function () { + expect(Sprite).to.be.a('function'); + expect(PIXI).to.have.deep.property('blendModes.NORMAL', 0); + expect(PIXI).to.have.deep.property('blendModes.ADD', 1); + expect(PIXI).to.have.deep.property('blendModes.MULTIPLY', 2); + expect(PIXI).to.have.deep.property('blendModes.SCREEN', 3); + }); + + + it('Members exist', function () { + expect(Sprite).itself.to.respondTo('fromImage'); + expect(Sprite).itself.to.respondTo('fromFrame'); + }); + + it('Confirm new instance', function (done) { + var texture = Texture.fromImage('/base/test/textures/SpriteSheet-Aliens.png'); + var obj = new Sprite(texture); + + pixi_display_Sprite_confirmNew(obj, done); + }); +}); diff --git a/test/unit/pixi-v2/display/Stage.js b/test/unit/pixi-v2/display/Stage.js new file mode 100644 index 0000000..6974c2e --- /dev/null +++ b/test/unit/pixi-v2/display/Stage.js @@ -0,0 +1,49 @@ +describe('pixi/display/Stage', function () { + 'use strict'; + + var expect = chai.expect; + var Stage = PIXI.Stage; + var InteractionManager = PIXI.InteractionManager; + var Rectangle = PIXI.Rectangle; + + it('Module exists', function () { + expect(Stage).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Stage(null, true); + + pixi_display_DisplayObjectContainer_confirmNew(obj); + + expect(obj).to.be.an.instanceof(Stage); + expect(obj).to.respondTo('updateTransform'); + expect(obj).to.respondTo('setBackgroundColor'); + expect(obj).to.respondTo('getMousePosition'); + // FIXME: duplicate member in DisplayObject + pixi_core_Matrix_confirmNewMatrix(obj.worldTransform); + // FIXME: convert arg to bool in constructor + expect(obj).to.have.property('interactive', true); + + expect(obj).to.have.property('interactionManager') + .and.to.be.an.instanceof(InteractionManager) + .and.to.have.property('stage', obj); + + expect(obj).to.have.property('dirty', true); + + expect(obj).to.have.property('stage', obj); + + expect(obj).to.have.property('hitArea') + .and.to.be.an.instanceof(Rectangle); + pixi_core_Rectangle_confirm(obj.hitArea, 0, 0, 100000, 100000); + + expect(obj).to.have.property('backgroundColor', 0x000000); + expect(obj).to.have.deep.property('backgroundColorSplit.length', 3); + expect(obj).to.have.deep.property('backgroundColorSplit[0]', 0); + expect(obj).to.have.deep.property('backgroundColorSplit[1]', 0); + expect(obj).to.have.deep.property('backgroundColorSplit[2]', 0); + expect(obj).to.have.property('backgroundColorString', '#000000'); + + + expect(obj).to.have.property('worldVisible', true); + }); +}); diff --git a/test/unit/pixi-v2/extras/Rope.js b/test/unit/pixi-v2/extras/Rope.js new file mode 100644 index 0000000..05885ac --- /dev/null +++ b/test/unit/pixi-v2/extras/Rope.js @@ -0,0 +1,31 @@ +describe('pixi/extras/Rope', function () { + 'use strict'; + + var expect = chai.expect; + var Rope = PIXI.Rope; + var Texture = PIXI.Texture; + var Point = PIXI.Point; + + it('Module exists', function () { + expect(Rope).to.be.a('function'); + }); + + it('Confirm new instance', function () { + + var texture = Texture.fromImage('/base/test/textures/bunny.png'); + + // TODO-Alvin + // Same as Strip + + // var obj = new Rope(texture, [new Point(), new Point(5, 10), new Point(10, 20)]); + + // pixi_extras_Strip_confirmNew(obj); + + // expect(obj).to.be.an.instanceof(Rope); + // expect(obj).to.respondTo('refresh'); + // expect(obj).to.respondTo('updateTransform'); + // expect(obj).to.respondTo('setTexture'); + + // TODO: Test properties + }); +}); diff --git a/test/unit/pixi-v2/extras/Spine.js b/test/unit/pixi-v2/extras/Spine.js new file mode 100644 index 0000000..0708bc0 --- /dev/null +++ b/test/unit/pixi-v2/extras/Spine.js @@ -0,0 +1,10 @@ +describe('pixi/extras/Spine', function () { + 'use strict'; + + var expect = chai.expect; + var Spine = PIXI.Spine; + + it('Module exists', function () { + expect(Spine).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/extras/Strip.js b/test/unit/pixi-v2/extras/Strip.js new file mode 100644 index 0000000..230af90 --- /dev/null +++ b/test/unit/pixi-v2/extras/Strip.js @@ -0,0 +1,26 @@ +describe('pixi/extras/Strip', function () { + 'use strict'; + + var expect = chai.expect; + var Strip = PIXI.Strip; + var Texture = PIXI.Texture; + + it('Module exists', function () { + expect(Strip).to.be.a('function'); + }); + + it('Confirm new instance', function () { + + + // TODO-Alvin + // We tweaked it to make it pass the tests, but the whole strip class needs + // to be re-coded + + var texture = Texture.fromImage('/base/test/textures/bunny.png'); + + // var obj = new Strip(texture, 20, 10000); + + + // pixi_extras_Strip_confirmNew(obj); + }); +}); diff --git a/test/unit/pixi-v2/extras/TilingSprite.js b/test/unit/pixi-v2/extras/TilingSprite.js new file mode 100644 index 0000000..56aea14 --- /dev/null +++ b/test/unit/pixi-v2/extras/TilingSprite.js @@ -0,0 +1,24 @@ +describe('pixi/extras/TilingSprite', function () { + 'use strict'; + + var expect = chai.expect; + var TilingSprite = PIXI.TilingSprite; + var Texture = PIXI.Texture; + + it('Module exists', function () { + expect(TilingSprite).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var texture = Texture.fromImage('/base/test/textures/bunny.png'); + var obj = new TilingSprite(texture, 6000, 12000); + + pixi_display_DisplayObjectContainer_confirmNew(obj); + + expect(obj).to.be.an.instanceof(TilingSprite); + expect(obj).to.respondTo('setTexture'); + expect(obj).to.respondTo('onTextureUpdate'); + + // TODO: Test properties + }); +}); diff --git a/test/unit/pixi-v2/filters/FilterBlock.js b/test/unit/pixi-v2/filters/FilterBlock.js new file mode 100644 index 0000000..870cec0 --- /dev/null +++ b/test/unit/pixi-v2/filters/FilterBlock.js @@ -0,0 +1,10 @@ +describe('pixi/filters/FilterBlock', function () { + 'use strict'; + + var expect = chai.expect; + var FilterBlock = PIXI.FilterBlock; + + it('Module exists', function () { + expect(FilterBlock).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/AssetLoader.js b/test/unit/pixi-v2/loaders/AssetLoader.js new file mode 100644 index 0000000..a0aa0b5 --- /dev/null +++ b/test/unit/pixi-v2/loaders/AssetLoader.js @@ -0,0 +1,10 @@ +describe('pixi/loaders/AssetLoader', function () { + 'use strict'; + + var expect = chai.expect; + var AssetLoader = PIXI.AssetLoader; + + it('Module exists', function () { + expect(AssetLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/BitmapFontLoader.js b/test/unit/pixi-v2/loaders/BitmapFontLoader.js new file mode 100644 index 0000000..046f018 --- /dev/null +++ b/test/unit/pixi-v2/loaders/BitmapFontLoader.js @@ -0,0 +1,9 @@ +describe('pixi/loaders/BitmapFontLoader', function () { + 'use strict'; + + var expect = chai.expect; + + it('Module exists', function () { + expect(PIXI.BitmapFontLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/ImageLoader.js b/test/unit/pixi-v2/loaders/ImageLoader.js new file mode 100644 index 0000000..8b1f556 --- /dev/null +++ b/test/unit/pixi-v2/loaders/ImageLoader.js @@ -0,0 +1,10 @@ +describe('pixi/loaders/ImageLoader', function () { + 'use strict'; + + var expect = chai.expect; + var ImageLoader = PIXI.ImageLoader; + + it('Module exists', function () { + expect(ImageLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/JsonLoader.js b/test/unit/pixi-v2/loaders/JsonLoader.js new file mode 100644 index 0000000..c577e83 --- /dev/null +++ b/test/unit/pixi-v2/loaders/JsonLoader.js @@ -0,0 +1,10 @@ +describe('pixi/loaders/JsonLoader', function () { + 'use strict'; + + var expect = chai.expect; + var JsonLoader = PIXI.JsonLoader; + + it('Module exists', function () { + expect(JsonLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/SpineLoader.js b/test/unit/pixi-v2/loaders/SpineLoader.js new file mode 100644 index 0000000..fdcc0b8 --- /dev/null +++ b/test/unit/pixi-v2/loaders/SpineLoader.js @@ -0,0 +1,10 @@ +describe('pixi/loaders/SpineLoader', function () { + 'use strict'; + + var expect = chai.expect; + var SpineLoader = PIXI.SpineLoader; + + it('Module exists', function () { + expect(SpineLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/SpriteSheetLoader.js b/test/unit/pixi-v2/loaders/SpriteSheetLoader.js new file mode 100644 index 0000000..57beb27 --- /dev/null +++ b/test/unit/pixi-v2/loaders/SpriteSheetLoader.js @@ -0,0 +1,10 @@ +describe('pixi/loaders/SpriteSheetLoader', function () { + 'use strict'; + + var expect = chai.expect; + var SpriteSheetLoader = PIXI.SpriteSheetLoader; + + it('Module exists', function () { + expect(SpriteSheetLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/primitives/Graphics.js b/test/unit/pixi-v2/primitives/Graphics.js new file mode 100644 index 0000000..f3849eb --- /dev/null +++ b/test/unit/pixi-v2/primitives/Graphics.js @@ -0,0 +1,44 @@ +describe('pixi/primitives/Graphics', function () { + 'use strict'; + + var expect = chai.expect; + var Graphics = PIXI.Graphics; + + it('Module exists', function () { + expect(Graphics).to.be.a('function'); + + expect(Graphics).itself.to.have.property('POLY', 0); + expect(Graphics).itself.to.have.property('RECT', 1); + expect(Graphics).itself.to.have.property('CIRC', 2); + expect(Graphics).itself.to.have.property('ELIP', 3); + expect(Graphics).itself.to.have.property('RREC', 4); + }); + + it('Confirm new instance', function () { + var obj = new Graphics(); + + pixi_display_DisplayObjectContainer_confirmNew(obj); + + expect(obj).to.be.an.instanceof(Graphics); + expect(obj).to.respondTo('lineStyle'); + expect(obj).to.respondTo('lineStyle'); + expect(obj).to.respondTo('moveTo'); + expect(obj).to.respondTo('lineTo'); + expect(obj).to.respondTo('beginFill'); + expect(obj).to.respondTo('endFill'); + expect(obj).to.respondTo('drawRect'); + // expect(obj).to.respondTo('drawRoundedRect'); + expect(obj).to.respondTo('drawCircle'); + expect(obj).to.respondTo('drawEllipse'); + expect(obj).to.respondTo('clear'); + + expect(obj).to.have.property('renderable', true); + expect(obj).to.have.property('fillAlpha', 1); + expect(obj).to.have.property('lineWidth', 0); + expect(obj).to.have.property('width', 0); + expect(obj).to.have.property('height', 0); + expect(obj).to.have.property('lineColor', 0); + expect(obj).to.have.deep.property('graphicsData.length', 0); + // expect(obj).to.have.deep.property('currentPath.points.length', 0); + }); +}); diff --git a/test/unit/pixi-v2/renderers/canvas/CanvasGraphics.js b/test/unit/pixi-v2/renderers/canvas/CanvasGraphics.js new file mode 100644 index 0000000..8f44472 --- /dev/null +++ b/test/unit/pixi-v2/renderers/canvas/CanvasGraphics.js @@ -0,0 +1,15 @@ +describe('renders/canvas/CanvasGraphics', function () { + 'use strict'; + + var expect = chai.expect; + var CanvasGraphics = PIXI.CanvasGraphics; + + it('Module exists', function () { + expect(CanvasGraphics).to.be.a('function'); + }); + + it('Members exist', function () { + expect(CanvasGraphics).itself.to.respondTo('renderGraphics'); + expect(CanvasGraphics).itself.to.respondTo('renderGraphicsMask'); + }); +}); diff --git a/test/unit/pixi-v2/renderers/canvas/CanvasRenderer.js b/test/unit/pixi-v2/renderers/canvas/CanvasRenderer.js new file mode 100644 index 0000000..1646444 --- /dev/null +++ b/test/unit/pixi-v2/renderers/canvas/CanvasRenderer.js @@ -0,0 +1,36 @@ +describe('renderers/canvas/CanvasRenderer', function () { + 'use strict'; + + var expect = chai.expect; + var CanvasRenderer = PIXI.CanvasRenderer; + + it('Module exists', function () { + expect(CanvasRenderer).to.be.a('function'); + }); + + describe('.autoResize', function () { + it('Should automatically resize view if enabled', function () { + var renderer = new CanvasRenderer(200, 200, { + autoResize: true + }); + + expect(renderer.view.style.width).to.equal('200px'); + }); + + it('Should not automatically resize view if disabled', function () { + var renderer = new CanvasRenderer(200, 200, { + autoResize: false + }); + + expect(renderer.view.style.width).to.equal(''); + }); + + it('Should not automatically resize view if not specified', function () { + var renderer = new CanvasRenderer(200, 200, { + resolution: 2 + }); + + expect(renderer.view.style.width).to.equal(''); + }); + }); +}); diff --git a/test/unit/pixi-v2/renderers/webgl/WebGLGraphics.js b/test/unit/pixi-v2/renderers/webgl/WebGLGraphics.js new file mode 100644 index 0000000..5867b28 --- /dev/null +++ b/test/unit/pixi-v2/renderers/webgl/WebGLGraphics.js @@ -0,0 +1,20 @@ +describe('renderers/wegbl/WebGLGraphics', function () { + 'use strict'; + + var expect = chai.expect; + var WebGLGraphics = PIXI.WebGLGraphics; + + it('Module exists', function () { + expect(WebGLGraphics).to.be.a('function'); + }); + + it('Members exist', function () { + expect(WebGLGraphics).itself.to.respondTo('renderGraphics'); + expect(WebGLGraphics).itself.to.respondTo('updateGraphics'); + expect(WebGLGraphics).itself.to.respondTo('buildRectangle'); + expect(WebGLGraphics).itself.to.respondTo('buildRoundedRectangle'); + expect(WebGLGraphics).itself.to.respondTo('buildCircle'); + expect(WebGLGraphics).itself.to.respondTo('buildLine'); + expect(WebGLGraphics).itself.to.respondTo('buildPoly'); + }); +}); diff --git a/test/unit/pixi-v2/renderers/webgl/WebGLRenderer.js b/test/unit/pixi-v2/renderers/webgl/WebGLRenderer.js new file mode 100644 index 0000000..1680a80 --- /dev/null +++ b/test/unit/pixi-v2/renderers/webgl/WebGLRenderer.js @@ -0,0 +1,49 @@ +describe('renderers/webgl/WebGLRenderer', function () { + 'use strict'; + + var expect = chai.expect; + var WebGLRenderer = PIXI.WebGLRenderer; + + it('Module exists', function () { + expect(WebGLRenderer).to.be.a('function'); + }); + + // Skip tests if WebGL is not available (WebGL not supported in Travis CI) + try { + var renderer = new WebGLRenderer(400, 300, {}); + renderer.destroy(); + } catch (error) { + return; + } + + it('Destroy renderer', function () { + var renderer = new WebGLRenderer(400, 300, {}); + renderer.destroy(); + }); + + describe('.autoResize', function () { + it('Should automatically resize view if enabled', function () { + var renderer = new WebGLRenderer(200, 200, { + autoResize: true + }); + + expect(renderer.view.style.width).to.equal('200px'); + }); + + it('Should not automatically resize view if disabled', function () { + var renderer = new WebGLRenderer(200, 200, { + autoResize: false + }); + + expect(renderer.view.style.width).to.equal(''); + }); + + it('Should not automatically resize view if not specified', function () { + var renderer = new WebGLRenderer(200, 200, { + resolution: 2 + }); + + expect(renderer.view.style.width).to.equal(''); + }); + }); +}); diff --git a/test/unit/pixi-v2/renderers/webgl/WebGLShaders.js b/test/unit/pixi-v2/renderers/webgl/WebGLShaders.js new file mode 100644 index 0000000..6e33e4f --- /dev/null +++ b/test/unit/pixi-v2/renderers/webgl/WebGLShaders.js @@ -0,0 +1,13 @@ +describe('renderers/webgl/WebGLShaders', function () { + 'use strict'; + + var expect = chai.expect; + + it('Module members exist', function () { + + expect(PIXI).to.respondTo('CompileVertexShader'); + expect(PIXI).to.respondTo('CompileFragmentShader'); + expect(PIXI).to.respondTo('_CompileShader'); + expect(PIXI).to.respondTo('compileProgram'); + }); +}); diff --git a/test/unit/pixi-v2/renderers/webgl/WebGLSpriteBatch.js b/test/unit/pixi-v2/renderers/webgl/WebGLSpriteBatch.js new file mode 100644 index 0000000..e662b63 --- /dev/null +++ b/test/unit/pixi-v2/renderers/webgl/WebGLSpriteBatch.js @@ -0,0 +1,10 @@ +describe('renderers/webgl/utils/WebGLSpriteBatch', function () { + 'use strict'; + + var expect = chai.expect; + var WebGLSpriteBatch = PIXI.WebGLSpriteBatch; + + it('Module exists', function () { + expect(WebGLSpriteBatch).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/text/BitmapText.js b/test/unit/pixi-v2/text/BitmapText.js new file mode 100644 index 0000000..9388e3d --- /dev/null +++ b/test/unit/pixi-v2/text/BitmapText.js @@ -0,0 +1,10 @@ +describe('pixi/text/BitmapText', function () { + 'use strict'; + + var expect = chai.expect; + var BitmapText = PIXI.BitmapText; + + it('Module exists', function () { + expect(BitmapText).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/text/Text.js b/test/unit/pixi-v2/text/Text.js new file mode 100644 index 0000000..9bc9ac5 --- /dev/null +++ b/test/unit/pixi-v2/text/Text.js @@ -0,0 +1,10 @@ +describe('pixi/text/Text', function () { + 'use strict'; + + var expect = chai.expect; + var Text = PIXI.Text; + + it('Module exists', function () { + expect(Text).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/textures/BaseTexture.js b/test/unit/pixi-v2/textures/BaseTexture.js new file mode 100644 index 0000000..502b724 --- /dev/null +++ b/test/unit/pixi-v2/textures/BaseTexture.js @@ -0,0 +1,11 @@ +describe('pixi/textures/BaseTexture', function () { + 'use strict'; + + var expect = chai.expect; + var BaseTexture = PIXI.BaseTexture; + + it('Module exists', function () { + expect(BaseTexture).to.be.a('function'); + expect(PIXI).to.have.property('BaseTextureCache').and.to.be.an('object'); + }); +}); diff --git a/test/unit/pixi-v2/textures/RenderTexture.js b/test/unit/pixi-v2/textures/RenderTexture.js new file mode 100644 index 0000000..96acdb4 --- /dev/null +++ b/test/unit/pixi-v2/textures/RenderTexture.js @@ -0,0 +1,15 @@ +describe('pixi/textures/RenderTexture', function () { + 'use strict'; + + var expect = chai.expect; + var RenderTexture = PIXI.RenderTexture; + + it('Module exists', function () { + expect(RenderTexture).to.be.a('function'); + }); + + it('Confirm new instance', function (done) { + var texture = new RenderTexture(100, 100, new PIXI.CanvasRenderer()); + pixi_textures_RenderTexture_confirmNew(texture, done); + }); +}); diff --git a/test/unit/pixi-v2/textures/Texture.js b/test/unit/pixi-v2/textures/Texture.js new file mode 100644 index 0000000..090f64d --- /dev/null +++ b/test/unit/pixi-v2/textures/Texture.js @@ -0,0 +1,26 @@ +describe('pixi/textures/Texture', function () { + 'use strict'; + + var expect = chai.expect; + var Texture = PIXI.Texture; + + it('Module exists', function () { + expect(Texture).to.be.a('function'); + expect(PIXI).to.have.property('TextureCache').and.to.be.an('object'); + }); + + it('Members exist', function () { + expect(Texture).itself.to.respondTo('fromImage'); + expect(Texture).itself.to.respondTo('fromFrame'); + expect(Texture).itself.to.respondTo('fromCanvas'); + expect(Texture).itself.to.respondTo('addTextureToCache'); + expect(Texture).itself.to.respondTo('removeTextureFromCache'); + + // expect(Texture).itself.to.have.deep.property('frameUpdates.length', 0); + }); + + it('Confirm new instance', function (done) { + var texture = Texture.fromImage('/base/test/textures/bunny.png'); + pixi_textures_Texture_confirmNew(texture, done); + }); +}); diff --git a/test/unit/pixi-v2/utils/Detector.js b/test/unit/pixi-v2/utils/Detector.js new file mode 100644 index 0000000..4cf6008 --- /dev/null +++ b/test/unit/pixi-v2/utils/Detector.js @@ -0,0 +1,10 @@ +describe('pixi/utils/Detector', function () { + 'use strict'; + + var expect = chai.expect; + var autoDetectRenderer = PIXI.autoDetectRenderer; + + it('Module exists', function () { + expect(autoDetectRenderer).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/utils/EventTarget.js b/test/unit/pixi-v2/utils/EventTarget.js new file mode 100644 index 0000000..1cfc3a4 --- /dev/null +++ b/test/unit/pixi-v2/utils/EventTarget.js @@ -0,0 +1,361 @@ +describe('pixi/utils/EventTarget', function () { + 'use strict'; + + var expect = chai.expect; + + var Clazz, PClazz, obj, pobj, obj2; + beforeEach(function () { + Clazz = function () {}; + PClazz = function () {}; + + PIXI.EventTarget.mixin(Clazz.prototype); + PIXI.EventTarget.mixin(PClazz.prototype); + + obj = new Clazz(); + obj2 = new Clazz(); + pobj = new PClazz(); + + obj.parent = pobj; + obj2.parent = obj; + }); + + it('Module exists', function () { + expect(PIXI.EventTarget).to.be.an('object'); + }); + + it('Confirm new instance', function () { + pixi_utils_EventTarget_confirm(obj); + }); + + it('simple on/emit case works', function () { + var myData = {}; + + obj.on('myevent', function (event) { + pixi_utils_EventTarget_Event_confirm(event, obj, myData); + }); + + obj.emit('myevent', myData); + }); + + it('simple once case works', function () { + var called = 0; + + obj.once('myevent', function() { called++; }); + + obj.emit('myevent'); + obj.emit('myevent'); + obj.emit('myevent'); + obj.emit('myevent'); + obj.emit('myevent'); + + expect(called).to.equal(1); + }); + + it('simple off case works', function (done) { + function onMyEvent() { + done(new Error('Event listener should not have been called')); + } + + obj.on('myevent', onMyEvent); + obj.off('myevent', onMyEvent); + obj.emit('myevent'); + + done(); + }); + + it('simple propagation case works', function (done) { + var myData = {}; + + pobj.on('myevent', function () { + done(); + }); + + obj.emit('myevent'); + }); + + it('simple stopPropagation case works', function (done) { + var myData = {}; + + pobj.on('myevent', function () { + done(new Error('Event listener should not have been called on the parent element')); + }); + + obj.on('myevent', function (evt) { + evt.stopPropagation(); + }); + + obj.emit('myevent'); + + done(); + }); + + it('simple stopImmediatePropagation case works', function (done) { + var myData = {}; + + pobj.on('myevent', function () { + done(new Error('Event listener should not have been called on the parent')); + }); + + obj.on('myevent', function (evt) { + evt.stopImmediatePropagation(); + }); + + obj.on('myevent', function () { + done(new Error('Event listener should not have been called on the second')); + }); + + obj.emit('myevent'); + + done(); + }); + + it('multiple dispatches work properly', function () { + var called = 0; + + function onMyEvent() { + called++; + } + + obj.on('myevent', onMyEvent); + obj.emit('myevent'); + obj.emit('myevent'); + obj.emit('myevent'); + obj.emit('myevent'); + + expect(called).to.equal(4); + }); + + it('multiple events work properly', function () { + var called = 0; + + function onMyEvent() { + called++; + } + + obj.on('myevent1', onMyEvent); + obj.on('myevent2', onMyEvent); + obj.on('myevent3', onMyEvent); + obj.emit('myevent1'); + obj.emit('myevent2'); + obj.emit('myevent3'); + + expect(called).to.equal(3); + }); + + it('multiple events one removed works properly', function () { + var called = 0; + + function onMyEvent() { + called++; + } + + obj.on('myevent1', onMyEvent); + obj.on('myevent2', onMyEvent); + obj.on('myevent3', onMyEvent); + + obj.emit('myevent1'); + obj.emit('myevent2'); + obj.emit('myevent3'); + + obj.off('myevent2', onMyEvent); + + obj.emit('myevent1'); + obj.emit('myevent2'); + obj.emit('myevent3'); + + expect(called).to.equal(5); + }); + + it('multiple handlers for one event with some removed', function () { + var called = 0; + + var onMyEvent = function () { + called++; + }, + onMyEvent2 = function () { + called++; + }; + + // add 2 handlers and confirm they both get called + obj.on('myevent', onMyEvent); + obj.on('myevent', onMyEvent); + obj.on('myevent', onMyEvent2); + obj.on('myevent', onMyEvent2); + + obj.emit('myevent'); + + expect(called).to.equal(4); + + // remove one of the handlers, emit again, then ensure 1 more call is made + obj.off('myevent', onMyEvent); + + obj.emit('myevent'); + + expect(called).to.equal(6); + }); + + it('calls to off without a handler do nothing', function () { + var called = 0; + + var onMyEvent = function () { + called++; + }; + + obj.on('myevent', onMyEvent); + obj.on('myevent', onMyEvent); + + obj.emit('myevent'); + + expect(called).to.equal(2); + + obj.off('myevent'); + + obj.emit('myevent'); + + expect(called).to.equal(4); + + obj.off('myevent', onMyEvent); + + obj.emit('myevent'); + + expect(called).to.equal(4); + }); + + it('handles multiple instances with the same prototype', function () { + var called = 0; + + function onMyEvent(e) { + called++; + } + + obj.on('myevent1', onMyEvent); + obj.on('myevent2', onMyEvent); + + obj2.istwo = true; + obj2.on('myevent1', onMyEvent); + obj2.on('myevent2', onMyEvent); + + obj.emit('myevent1'); + obj.emit('myevent2'); + obj2.emit('myevent1'); + obj2.emit('myevent2'); + + //we emit 4 times, but since obj2 is a child of obj the event should bubble + //up to obj and show up there as well. So the obj2.emit() calls each increment + //the counter twice. + expect(called).to.equal(6); + }); + + it('is backwards compatible with older .dispatchEvent({})', function () { + var called = 0, + data = { + some: 'thing', + hello: true + }; + + function onMyEvent(event) { + pixi_utils_EventTarget_Event_confirm(event, obj, data); + + called++; + } + + obj.on('myevent1', onMyEvent); + obj.on('myevent2', onMyEvent); + obj.on('myevent3', onMyEvent); + + data.type = 'myevent1'; + obj.emit(data); + + data.type = 'myevent2'; + obj.emit(data); + + data.type = 'myevent3'; + obj.emit(data); + + obj.off('myevent2', onMyEvent); + + data.type = 'myevent1'; + obj.emit(data); + + data.type = 'myevent2'; + obj.emit(data); + + data.type = 'myevent3'; + obj.emit(data); + + expect(called).to.equal(5); + }); + + it('is backwards compatible with older .call(this)', function () { + var Fn = function() { + PIXI.EventTarget.call(this); + }, + o = new Fn(); + + pixi_utils_EventTarget_confirm(o); + }); + + it('is backwards compatible with older .addEventListener("")', function () { + var called = 0, + data = { + some: 'thing', + hello: true + }; + + function onMyEvent(event) { + pixi_utils_EventTarget_Event_confirm(event, obj, data); + + called++; + } + + obj.addEventListener('myevent1', onMyEvent); + obj.addEventListener('myevent2', onMyEvent); + obj.addEventListener('myevent3', onMyEvent); + + data.type = 'myevent1'; + obj.emit(data); + + data.type = 'myevent2'; + obj.emit(data); + + data.type = 'myevent3'; + obj.emit(data); + + obj.off('myevent2', onMyEvent); + + data.type = 'myevent1'; + obj.emit(data); + + data.type = 'myevent2'; + obj.emit(data); + + data.type = 'myevent3'; + obj.emit(data); + + expect(called).to.equal(5); + }); + + it('event remove during emit call properly', function () { + var called = 0; + + function cb1() { + called++; + obj.off('myevent', cb1); + } + function cb2() { + called++; + obj.off('myevent', cb2); + } + function cb3() { + called++; + obj.off('myevent', cb3); + } + + obj.on('myevent', cb1); + obj.on('myevent', cb2); + obj.on('myevent', cb3); + obj.emit('myevent', ''); + + expect(called).to.equal(3); + }); +}); diff --git a/test/unit/pixi-v2/utils/Polyk.js b/test/unit/pixi-v2/utils/Polyk.js new file mode 100644 index 0000000..dfc7128 --- /dev/null +++ b/test/unit/pixi-v2/utils/Polyk.js @@ -0,0 +1,14 @@ +describe('pixi/utils/Polyk', function () { + 'use strict'; + + var expect = chai.expect; + var PolyK = PIXI.PolyK; + + it('Module exists', function () { + expect(PolyK).to.be.an('object'); + }); + + it('Members exist', function () { + expect(PolyK).to.respondTo('Triangulate'); + }); +}); diff --git a/test/unit/pixi-v2/utils/Utils.js b/test/unit/pixi-v2/utils/Utils.js new file mode 100644 index 0000000..c97b3c6 --- /dev/null +++ b/test/unit/pixi-v2/utils/Utils.js @@ -0,0 +1,17 @@ +describe('Utils', function () { + 'use strict'; + + var expect = chai.expect; + + it('requestAnimationFrame exists', function () { + expect(global).to.respondTo('requestAnimationFrame'); + }); + + it('cancelAnimationFrame exists', function () { + expect(global).to.respondTo('cancelAnimationFrame'); + }); + + it('requestAnimFrame exists', function () { + expect(global).to.respondTo('requestAnimFrame'); + }); +}); diff --git a/test/unit/pixi/InteractionManager.js b/test/unit/pixi/InteractionManager.js deleted file mode 100644 index ed3001f..0000000 --- a/test/unit/pixi/InteractionManager.js +++ /dev/null @@ -1,10 +0,0 @@ -describe('pixi/InteractionManager', function () { - 'use strict'; - - var expect = chai.expect; - var InteractionManager = PIXI.InteractionManager; - - it('Module exists', function () { - expect(InteractionManager).to.be.a('function'); - }); -}); diff --git a/test/unit/pixi/Pixi.js b/test/unit/pixi/Pixi.js deleted file mode 100644 index 27debc1..0000000 --- a/test/unit/pixi/Pixi.js +++ /dev/null @@ -1,9 +0,0 @@ -describe('pixi/Pixi', function () { - 'use strict'; - - var expect = chai.expect; - - it('Module exists', function () { - expect(global).to.have.property('PIXI').and.to.be.an('object'); - }); -}); diff --git a/test/unit/pixi/core/Circle.js b/test/unit/pixi/core/Circle.js deleted file mode 100644 index fbcfa17..0000000 --- a/test/unit/pixi/core/Circle.js +++ /dev/null @@ -1,21 +0,0 @@ -describe('pixi/core/Circle', function () { - 'use strict'; - - var expect = chai.expect; - var Circle = PIXI.Circle; - - it('Module exists', function () { - expect(Circle).to.be.a('function'); - }); - - it('Confirm new instance', function () { - var obj = new Circle(); - pixi_core_Circle_confirmNewCircle(obj); - }); - - it("getBounds should return Rectangle that bounds the circle", function() { - var obj = new Circle(100, 250, 50); - var bounds = obj.getBounds(); - pixi_core_Circle_isBoundedByRectangle(obj, bounds); - }); -}); diff --git a/test/unit/pixi/core/Ellipse.js b/test/unit/pixi/core/Ellipse.js deleted file mode 100644 index 026b56f..0000000 --- a/test/unit/pixi/core/Ellipse.js +++ /dev/null @@ -1,24 +0,0 @@ -describe('pixi/core/Ellipse', function () { - 'use strict'; - - var expect = chai.expect; - var Ellipse = PIXI.Ellipse; - - it('Module exists', function () { - expect(Ellipse).to.be.a('function'); - }); - - it('Confirm new instance', function () { - var obj = new Ellipse(); - - expect(obj).to.be.an.instanceof(Ellipse); - expect(obj).to.respondTo('clone'); - expect(obj).to.respondTo('contains'); - expect(obj).to.respondTo('getBounds'); - - expect(obj).to.have.property('x', 0); - expect(obj).to.have.property('y', 0); - expect(obj).to.have.property('width', 0); - expect(obj).to.have.property('height', 0); - }); -}); diff --git a/test/unit/pixi/core/Matrix.js b/test/unit/pixi/core/Matrix.js deleted file mode 100644 index da75e2e..0000000 --- a/test/unit/pixi/core/Matrix.js +++ /dev/null @@ -1,14 +0,0 @@ -describe('pixi/core/Matrix', function () { - 'use strict'; - - var expect = chai.expect; - - it('Matrix exists', function () { - expect(PIXI.Matrix).to.be.an('function'); - }); - - it('Confirm new Matrix', function () { - var matrix = new PIXI.Matrix(); - pixi_core_Matrix_confirmNewMatrix(matrix); - }); -}); diff --git a/test/unit/pixi/core/Point.js b/test/unit/pixi/core/Point.js deleted file mode 100644 index c4d5163..0000000 --- a/test/unit/pixi/core/Point.js +++ /dev/null @@ -1,15 +0,0 @@ -describe('pixi/core/Point', function () { - 'use strict'; - - var expect = chai.expect; - var Point = PIXI.Point; - - it('Module exists', function () { - expect(Point).to.be.a('function'); - }); - - it('Confirm new instance', function () { - var obj = new Point(); - pixi_core_Point_confirm(obj, 0, 0); - }); -}); diff --git a/test/unit/pixi/core/Polygon.js b/test/unit/pixi/core/Polygon.js deleted file mode 100644 index dc8c918..0000000 --- a/test/unit/pixi/core/Polygon.js +++ /dev/null @@ -1,20 +0,0 @@ -describe('pixi/core/Polygon', function () { - 'use strict'; - - var expect = chai.expect; - var Polygon = PIXI.Polygon; - - it('Module exists', function () { - expect(Polygon).to.be.a('function'); - }); - - it('Confirm new instance', function () { - var obj = new Polygon(); - - expect(obj).to.be.an.instanceof(Polygon); - expect(obj).to.respondTo('clone'); - expect(obj).to.respondTo('contains'); - - expect(obj).to.have.deep.property('points.length', 0); - }); -}); diff --git a/test/unit/pixi/core/Rectangle.js b/test/unit/pixi/core/Rectangle.js deleted file mode 100644 index d43316e..0000000 --- a/test/unit/pixi/core/Rectangle.js +++ /dev/null @@ -1,15 +0,0 @@ -describe('pixi/core/Rectangle', function () { - 'use strict'; - - var expect = chai.expect; - var Rectangle = PIXI.Rectangle; - - it('Module exists', function () { - expect(Rectangle).to.be.a('function'); - }); - - it('Confirm new instance', function () { - var rect = new Rectangle(); - pixi_core_Rectangle_confirm(rect, 0, 0, 0, 0); - }); -}); diff --git a/test/unit/pixi/display/DisplayObject.js b/test/unit/pixi/display/DisplayObject.js deleted file mode 100644 index 044acf8..0000000 --- a/test/unit/pixi/display/DisplayObject.js +++ /dev/null @@ -1,21 +0,0 @@ -describe('pixi/display/DisplayObject', function () { - 'use strict'; - - var expect = chai.expect; - var DisplayObject = PIXI.DisplayObject; - - it('Module exists', function () { - expect(DisplayObject).to.be.a('function'); - // expect(PIXI).to.have.property('visibleCount', 0); - }); - - it('Confirm new instance', function () { - var obj = new DisplayObject(); - - pixi_display_DisplayObject_confirmNew(obj); - expect(obj).to.have.property('hitArea', null); - expect(obj).to.have.property('interactive', false); - expect(obj).to.have.property('renderable', false); - expect(obj).to.have.property('stage', null); - }); -}); diff --git a/test/unit/pixi-v2/InteractionManager.js b/test/unit/pixi-v2/InteractionManager.js new file mode 100644 index 0000000..ed3001f --- /dev/null +++ b/test/unit/pixi-v2/InteractionManager.js @@ -0,0 +1,10 @@ +describe('pixi/InteractionManager', function () { + 'use strict'; + + var expect = chai.expect; + var InteractionManager = PIXI.InteractionManager; + + it('Module exists', function () { + expect(InteractionManager).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/Pixi.js b/test/unit/pixi-v2/Pixi.js new file mode 100644 index 0000000..27debc1 --- /dev/null +++ b/test/unit/pixi-v2/Pixi.js @@ -0,0 +1,9 @@ +describe('pixi/Pixi', function () { + 'use strict'; + + var expect = chai.expect; + + it('Module exists', function () { + expect(global).to.have.property('PIXI').and.to.be.an('object'); + }); +}); diff --git a/test/unit/pixi-v2/core/Circle.js b/test/unit/pixi-v2/core/Circle.js new file mode 100644 index 0000000..fbcfa17 --- /dev/null +++ b/test/unit/pixi-v2/core/Circle.js @@ -0,0 +1,21 @@ +describe('pixi/core/Circle', function () { + 'use strict'; + + var expect = chai.expect; + var Circle = PIXI.Circle; + + it('Module exists', function () { + expect(Circle).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Circle(); + pixi_core_Circle_confirmNewCircle(obj); + }); + + it("getBounds should return Rectangle that bounds the circle", function() { + var obj = new Circle(100, 250, 50); + var bounds = obj.getBounds(); + pixi_core_Circle_isBoundedByRectangle(obj, bounds); + }); +}); diff --git a/test/unit/pixi-v2/core/Ellipse.js b/test/unit/pixi-v2/core/Ellipse.js new file mode 100644 index 0000000..026b56f --- /dev/null +++ b/test/unit/pixi-v2/core/Ellipse.js @@ -0,0 +1,24 @@ +describe('pixi/core/Ellipse', function () { + 'use strict'; + + var expect = chai.expect; + var Ellipse = PIXI.Ellipse; + + it('Module exists', function () { + expect(Ellipse).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Ellipse(); + + expect(obj).to.be.an.instanceof(Ellipse); + expect(obj).to.respondTo('clone'); + expect(obj).to.respondTo('contains'); + expect(obj).to.respondTo('getBounds'); + + expect(obj).to.have.property('x', 0); + expect(obj).to.have.property('y', 0); + expect(obj).to.have.property('width', 0); + expect(obj).to.have.property('height', 0); + }); +}); diff --git a/test/unit/pixi-v2/core/Matrix.js b/test/unit/pixi-v2/core/Matrix.js new file mode 100644 index 0000000..da75e2e --- /dev/null +++ b/test/unit/pixi-v2/core/Matrix.js @@ -0,0 +1,14 @@ +describe('pixi/core/Matrix', function () { + 'use strict'; + + var expect = chai.expect; + + it('Matrix exists', function () { + expect(PIXI.Matrix).to.be.an('function'); + }); + + it('Confirm new Matrix', function () { + var matrix = new PIXI.Matrix(); + pixi_core_Matrix_confirmNewMatrix(matrix); + }); +}); diff --git a/test/unit/pixi-v2/core/Point.js b/test/unit/pixi-v2/core/Point.js new file mode 100644 index 0000000..c4d5163 --- /dev/null +++ b/test/unit/pixi-v2/core/Point.js @@ -0,0 +1,15 @@ +describe('pixi/core/Point', function () { + 'use strict'; + + var expect = chai.expect; + var Point = PIXI.Point; + + it('Module exists', function () { + expect(Point).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Point(); + pixi_core_Point_confirm(obj, 0, 0); + }); +}); diff --git a/test/unit/pixi-v2/core/Polygon.js b/test/unit/pixi-v2/core/Polygon.js new file mode 100644 index 0000000..dc8c918 --- /dev/null +++ b/test/unit/pixi-v2/core/Polygon.js @@ -0,0 +1,20 @@ +describe('pixi/core/Polygon', function () { + 'use strict'; + + var expect = chai.expect; + var Polygon = PIXI.Polygon; + + it('Module exists', function () { + expect(Polygon).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Polygon(); + + expect(obj).to.be.an.instanceof(Polygon); + expect(obj).to.respondTo('clone'); + expect(obj).to.respondTo('contains'); + + expect(obj).to.have.deep.property('points.length', 0); + }); +}); diff --git a/test/unit/pixi-v2/core/Rectangle.js b/test/unit/pixi-v2/core/Rectangle.js new file mode 100644 index 0000000..d43316e --- /dev/null +++ b/test/unit/pixi-v2/core/Rectangle.js @@ -0,0 +1,15 @@ +describe('pixi/core/Rectangle', function () { + 'use strict'; + + var expect = chai.expect; + var Rectangle = PIXI.Rectangle; + + it('Module exists', function () { + expect(Rectangle).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var rect = new Rectangle(); + pixi_core_Rectangle_confirm(rect, 0, 0, 0, 0); + }); +}); diff --git a/test/unit/pixi-v2/display/DisplayObject.js b/test/unit/pixi-v2/display/DisplayObject.js new file mode 100644 index 0000000..044acf8 --- /dev/null +++ b/test/unit/pixi-v2/display/DisplayObject.js @@ -0,0 +1,21 @@ +describe('pixi/display/DisplayObject', function () { + 'use strict'; + + var expect = chai.expect; + var DisplayObject = PIXI.DisplayObject; + + it('Module exists', function () { + expect(DisplayObject).to.be.a('function'); + // expect(PIXI).to.have.property('visibleCount', 0); + }); + + it('Confirm new instance', function () { + var obj = new DisplayObject(); + + pixi_display_DisplayObject_confirmNew(obj); + expect(obj).to.have.property('hitArea', null); + expect(obj).to.have.property('interactive', false); + expect(obj).to.have.property('renderable', false); + expect(obj).to.have.property('stage', null); + }); +}); diff --git a/test/unit/pixi-v2/display/DisplayObjectContainer.js b/test/unit/pixi-v2/display/DisplayObjectContainer.js new file mode 100644 index 0000000..15a3376 --- /dev/null +++ b/test/unit/pixi-v2/display/DisplayObjectContainer.js @@ -0,0 +1,67 @@ +describe('pixi/display/DisplayObjectContainer', function () { + 'use strict'; + + var expect = chai.expect; + var DisplayObjectContainer = PIXI.DisplayObjectContainer; + + it('Module exists', function () { + expect(DisplayObjectContainer).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new DisplayObjectContainer(); + + pixi_display_DisplayObjectContainer_confirmNew(obj); + expect(obj).to.have.property('hitArea', null); + expect(obj).to.have.property('interactive', false); + expect(obj).to.have.property('renderable', false); + expect(obj).to.have.property('stage', null); + }); + + it('Gets child index', function() { + var container = new PIXI.DisplayObjectContainer(); + var children = []; + for (var i = 0; i < 10; i++) { + var child = new PIXI.DisplayObject(); + children.push(child); + container.addChild(child); + } + + for (i = 0; i < children.length; i++) { + expect(i).to.eql(container.getChildIndex(children[i])); + } + }); + + it('throws error when trying to get index of not a child', function() { + var container = new PIXI.DisplayObjectContainer(); + var child = new PIXI.DisplayObject(); + + expect(function() { container.getChildIndex(child); }).to.throw(); + }); + + it('Sets child index', function() { + var container = new PIXI.DisplayObjectContainer(); + var children = []; + + for (var i = 0; i < 10; i++) { + var child = new PIXI.DisplayObject(); + children.push(child); + container.addChild(child); + } + children.reverse(); + + for (i = 0; i < children.length; i++) { + container.setChildIndex(children[i], i); + expect(i).to.eql(container.getChildIndex(children[i])); + } + }); + + it('throws error when trying to set incorect index', function() { + var container = new PIXI.DisplayObjectContainer(); + var child = new PIXI.DisplayObject(); + container.addChild(child); + + expect(function() { container.setChildIndex(child, -1); }).to.throw(); + expect(function() { container.setChildIndex(child, 1); }).to.throw(); + }); +}); diff --git a/test/unit/pixi-v2/display/MovieClip.js b/test/unit/pixi-v2/display/MovieClip.js new file mode 100644 index 0000000..f3c6c6a --- /dev/null +++ b/test/unit/pixi-v2/display/MovieClip.js @@ -0,0 +1,33 @@ +describe('pixi/display/MovieClip', function () { + 'use strict'; + + var expect = chai.expect; + var MovieClip = PIXI.MovieClip; + var Texture = PIXI.Texture; + + it('Module exists', function () { + expect(MovieClip).to.be.a('function'); + }); + + it('Confirm new instance', function (done) { + var texture = Texture.fromImage('/base/test/textures/SpriteSheet-Explosion.png'); + var obj = new MovieClip([texture]); + + pixi_display_Sprite_confirmNew(obj, done); + + expect(obj).to.be.an.instanceof(MovieClip); + expect(obj).to.respondTo('stop'); + expect(obj).to.respondTo('play'); + expect(obj).to.respondTo('gotoAndStop'); + expect(obj).to.respondTo('gotoAndPlay'); + expect(obj).to.respondTo('updateTransform'); + + expect(obj).to.have.deep.property('textures.length', 1); + expect(obj).to.have.deep.property('textures[0]', texture); + expect(obj).to.have.property('animationSpeed', 1); + expect(obj).to.have.property('loop', true); + expect(obj).to.have.property('onComplete', null); + expect(obj).to.have.property('currentFrame', 0); + expect(obj).to.have.property('playing', false); + }); +}); diff --git a/test/unit/pixi-v2/display/Sprite.js b/test/unit/pixi-v2/display/Sprite.js new file mode 100644 index 0000000..30c8076 --- /dev/null +++ b/test/unit/pixi-v2/display/Sprite.js @@ -0,0 +1,28 @@ +describe('pixi/display/Sprite', function () { + 'use strict'; + + var expect = chai.expect; + var Sprite = PIXI.Sprite; + var Texture = PIXI.Texture; + + it('Module exists', function () { + expect(Sprite).to.be.a('function'); + expect(PIXI).to.have.deep.property('blendModes.NORMAL', 0); + expect(PIXI).to.have.deep.property('blendModes.ADD', 1); + expect(PIXI).to.have.deep.property('blendModes.MULTIPLY', 2); + expect(PIXI).to.have.deep.property('blendModes.SCREEN', 3); + }); + + + it('Members exist', function () { + expect(Sprite).itself.to.respondTo('fromImage'); + expect(Sprite).itself.to.respondTo('fromFrame'); + }); + + it('Confirm new instance', function (done) { + var texture = Texture.fromImage('/base/test/textures/SpriteSheet-Aliens.png'); + var obj = new Sprite(texture); + + pixi_display_Sprite_confirmNew(obj, done); + }); +}); diff --git a/test/unit/pixi-v2/display/Stage.js b/test/unit/pixi-v2/display/Stage.js new file mode 100644 index 0000000..6974c2e --- /dev/null +++ b/test/unit/pixi-v2/display/Stage.js @@ -0,0 +1,49 @@ +describe('pixi/display/Stage', function () { + 'use strict'; + + var expect = chai.expect; + var Stage = PIXI.Stage; + var InteractionManager = PIXI.InteractionManager; + var Rectangle = PIXI.Rectangle; + + it('Module exists', function () { + expect(Stage).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Stage(null, true); + + pixi_display_DisplayObjectContainer_confirmNew(obj); + + expect(obj).to.be.an.instanceof(Stage); + expect(obj).to.respondTo('updateTransform'); + expect(obj).to.respondTo('setBackgroundColor'); + expect(obj).to.respondTo('getMousePosition'); + // FIXME: duplicate member in DisplayObject + pixi_core_Matrix_confirmNewMatrix(obj.worldTransform); + // FIXME: convert arg to bool in constructor + expect(obj).to.have.property('interactive', true); + + expect(obj).to.have.property('interactionManager') + .and.to.be.an.instanceof(InteractionManager) + .and.to.have.property('stage', obj); + + expect(obj).to.have.property('dirty', true); + + expect(obj).to.have.property('stage', obj); + + expect(obj).to.have.property('hitArea') + .and.to.be.an.instanceof(Rectangle); + pixi_core_Rectangle_confirm(obj.hitArea, 0, 0, 100000, 100000); + + expect(obj).to.have.property('backgroundColor', 0x000000); + expect(obj).to.have.deep.property('backgroundColorSplit.length', 3); + expect(obj).to.have.deep.property('backgroundColorSplit[0]', 0); + expect(obj).to.have.deep.property('backgroundColorSplit[1]', 0); + expect(obj).to.have.deep.property('backgroundColorSplit[2]', 0); + expect(obj).to.have.property('backgroundColorString', '#000000'); + + + expect(obj).to.have.property('worldVisible', true); + }); +}); diff --git a/test/unit/pixi-v2/extras/Rope.js b/test/unit/pixi-v2/extras/Rope.js new file mode 100644 index 0000000..05885ac --- /dev/null +++ b/test/unit/pixi-v2/extras/Rope.js @@ -0,0 +1,31 @@ +describe('pixi/extras/Rope', function () { + 'use strict'; + + var expect = chai.expect; + var Rope = PIXI.Rope; + var Texture = PIXI.Texture; + var Point = PIXI.Point; + + it('Module exists', function () { + expect(Rope).to.be.a('function'); + }); + + it('Confirm new instance', function () { + + var texture = Texture.fromImage('/base/test/textures/bunny.png'); + + // TODO-Alvin + // Same as Strip + + // var obj = new Rope(texture, [new Point(), new Point(5, 10), new Point(10, 20)]); + + // pixi_extras_Strip_confirmNew(obj); + + // expect(obj).to.be.an.instanceof(Rope); + // expect(obj).to.respondTo('refresh'); + // expect(obj).to.respondTo('updateTransform'); + // expect(obj).to.respondTo('setTexture'); + + // TODO: Test properties + }); +}); diff --git a/test/unit/pixi-v2/extras/Spine.js b/test/unit/pixi-v2/extras/Spine.js new file mode 100644 index 0000000..0708bc0 --- /dev/null +++ b/test/unit/pixi-v2/extras/Spine.js @@ -0,0 +1,10 @@ +describe('pixi/extras/Spine', function () { + 'use strict'; + + var expect = chai.expect; + var Spine = PIXI.Spine; + + it('Module exists', function () { + expect(Spine).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/extras/Strip.js b/test/unit/pixi-v2/extras/Strip.js new file mode 100644 index 0000000..230af90 --- /dev/null +++ b/test/unit/pixi-v2/extras/Strip.js @@ -0,0 +1,26 @@ +describe('pixi/extras/Strip', function () { + 'use strict'; + + var expect = chai.expect; + var Strip = PIXI.Strip; + var Texture = PIXI.Texture; + + it('Module exists', function () { + expect(Strip).to.be.a('function'); + }); + + it('Confirm new instance', function () { + + + // TODO-Alvin + // We tweaked it to make it pass the tests, but the whole strip class needs + // to be re-coded + + var texture = Texture.fromImage('/base/test/textures/bunny.png'); + + // var obj = new Strip(texture, 20, 10000); + + + // pixi_extras_Strip_confirmNew(obj); + }); +}); diff --git a/test/unit/pixi-v2/extras/TilingSprite.js b/test/unit/pixi-v2/extras/TilingSprite.js new file mode 100644 index 0000000..56aea14 --- /dev/null +++ b/test/unit/pixi-v2/extras/TilingSprite.js @@ -0,0 +1,24 @@ +describe('pixi/extras/TilingSprite', function () { + 'use strict'; + + var expect = chai.expect; + var TilingSprite = PIXI.TilingSprite; + var Texture = PIXI.Texture; + + it('Module exists', function () { + expect(TilingSprite).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var texture = Texture.fromImage('/base/test/textures/bunny.png'); + var obj = new TilingSprite(texture, 6000, 12000); + + pixi_display_DisplayObjectContainer_confirmNew(obj); + + expect(obj).to.be.an.instanceof(TilingSprite); + expect(obj).to.respondTo('setTexture'); + expect(obj).to.respondTo('onTextureUpdate'); + + // TODO: Test properties + }); +}); diff --git a/test/unit/pixi-v2/filters/FilterBlock.js b/test/unit/pixi-v2/filters/FilterBlock.js new file mode 100644 index 0000000..870cec0 --- /dev/null +++ b/test/unit/pixi-v2/filters/FilterBlock.js @@ -0,0 +1,10 @@ +describe('pixi/filters/FilterBlock', function () { + 'use strict'; + + var expect = chai.expect; + var FilterBlock = PIXI.FilterBlock; + + it('Module exists', function () { + expect(FilterBlock).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/AssetLoader.js b/test/unit/pixi-v2/loaders/AssetLoader.js new file mode 100644 index 0000000..a0aa0b5 --- /dev/null +++ b/test/unit/pixi-v2/loaders/AssetLoader.js @@ -0,0 +1,10 @@ +describe('pixi/loaders/AssetLoader', function () { + 'use strict'; + + var expect = chai.expect; + var AssetLoader = PIXI.AssetLoader; + + it('Module exists', function () { + expect(AssetLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/BitmapFontLoader.js b/test/unit/pixi-v2/loaders/BitmapFontLoader.js new file mode 100644 index 0000000..046f018 --- /dev/null +++ b/test/unit/pixi-v2/loaders/BitmapFontLoader.js @@ -0,0 +1,9 @@ +describe('pixi/loaders/BitmapFontLoader', function () { + 'use strict'; + + var expect = chai.expect; + + it('Module exists', function () { + expect(PIXI.BitmapFontLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/ImageLoader.js b/test/unit/pixi-v2/loaders/ImageLoader.js new file mode 100644 index 0000000..8b1f556 --- /dev/null +++ b/test/unit/pixi-v2/loaders/ImageLoader.js @@ -0,0 +1,10 @@ +describe('pixi/loaders/ImageLoader', function () { + 'use strict'; + + var expect = chai.expect; + var ImageLoader = PIXI.ImageLoader; + + it('Module exists', function () { + expect(ImageLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/JsonLoader.js b/test/unit/pixi-v2/loaders/JsonLoader.js new file mode 100644 index 0000000..c577e83 --- /dev/null +++ b/test/unit/pixi-v2/loaders/JsonLoader.js @@ -0,0 +1,10 @@ +describe('pixi/loaders/JsonLoader', function () { + 'use strict'; + + var expect = chai.expect; + var JsonLoader = PIXI.JsonLoader; + + it('Module exists', function () { + expect(JsonLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/SpineLoader.js b/test/unit/pixi-v2/loaders/SpineLoader.js new file mode 100644 index 0000000..fdcc0b8 --- /dev/null +++ b/test/unit/pixi-v2/loaders/SpineLoader.js @@ -0,0 +1,10 @@ +describe('pixi/loaders/SpineLoader', function () { + 'use strict'; + + var expect = chai.expect; + var SpineLoader = PIXI.SpineLoader; + + it('Module exists', function () { + expect(SpineLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/SpriteSheetLoader.js b/test/unit/pixi-v2/loaders/SpriteSheetLoader.js new file mode 100644 index 0000000..57beb27 --- /dev/null +++ b/test/unit/pixi-v2/loaders/SpriteSheetLoader.js @@ -0,0 +1,10 @@ +describe('pixi/loaders/SpriteSheetLoader', function () { + 'use strict'; + + var expect = chai.expect; + var SpriteSheetLoader = PIXI.SpriteSheetLoader; + + it('Module exists', function () { + expect(SpriteSheetLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/primitives/Graphics.js b/test/unit/pixi-v2/primitives/Graphics.js new file mode 100644 index 0000000..f3849eb --- /dev/null +++ b/test/unit/pixi-v2/primitives/Graphics.js @@ -0,0 +1,44 @@ +describe('pixi/primitives/Graphics', function () { + 'use strict'; + + var expect = chai.expect; + var Graphics = PIXI.Graphics; + + it('Module exists', function () { + expect(Graphics).to.be.a('function'); + + expect(Graphics).itself.to.have.property('POLY', 0); + expect(Graphics).itself.to.have.property('RECT', 1); + expect(Graphics).itself.to.have.property('CIRC', 2); + expect(Graphics).itself.to.have.property('ELIP', 3); + expect(Graphics).itself.to.have.property('RREC', 4); + }); + + it('Confirm new instance', function () { + var obj = new Graphics(); + + pixi_display_DisplayObjectContainer_confirmNew(obj); + + expect(obj).to.be.an.instanceof(Graphics); + expect(obj).to.respondTo('lineStyle'); + expect(obj).to.respondTo('lineStyle'); + expect(obj).to.respondTo('moveTo'); + expect(obj).to.respondTo('lineTo'); + expect(obj).to.respondTo('beginFill'); + expect(obj).to.respondTo('endFill'); + expect(obj).to.respondTo('drawRect'); + // expect(obj).to.respondTo('drawRoundedRect'); + expect(obj).to.respondTo('drawCircle'); + expect(obj).to.respondTo('drawEllipse'); + expect(obj).to.respondTo('clear'); + + expect(obj).to.have.property('renderable', true); + expect(obj).to.have.property('fillAlpha', 1); + expect(obj).to.have.property('lineWidth', 0); + expect(obj).to.have.property('width', 0); + expect(obj).to.have.property('height', 0); + expect(obj).to.have.property('lineColor', 0); + expect(obj).to.have.deep.property('graphicsData.length', 0); + // expect(obj).to.have.deep.property('currentPath.points.length', 0); + }); +}); diff --git a/test/unit/pixi-v2/renderers/canvas/CanvasGraphics.js b/test/unit/pixi-v2/renderers/canvas/CanvasGraphics.js new file mode 100644 index 0000000..8f44472 --- /dev/null +++ b/test/unit/pixi-v2/renderers/canvas/CanvasGraphics.js @@ -0,0 +1,15 @@ +describe('renders/canvas/CanvasGraphics', function () { + 'use strict'; + + var expect = chai.expect; + var CanvasGraphics = PIXI.CanvasGraphics; + + it('Module exists', function () { + expect(CanvasGraphics).to.be.a('function'); + }); + + it('Members exist', function () { + expect(CanvasGraphics).itself.to.respondTo('renderGraphics'); + expect(CanvasGraphics).itself.to.respondTo('renderGraphicsMask'); + }); +}); diff --git a/test/unit/pixi-v2/renderers/canvas/CanvasRenderer.js b/test/unit/pixi-v2/renderers/canvas/CanvasRenderer.js new file mode 100644 index 0000000..1646444 --- /dev/null +++ b/test/unit/pixi-v2/renderers/canvas/CanvasRenderer.js @@ -0,0 +1,36 @@ +describe('renderers/canvas/CanvasRenderer', function () { + 'use strict'; + + var expect = chai.expect; + var CanvasRenderer = PIXI.CanvasRenderer; + + it('Module exists', function () { + expect(CanvasRenderer).to.be.a('function'); + }); + + describe('.autoResize', function () { + it('Should automatically resize view if enabled', function () { + var renderer = new CanvasRenderer(200, 200, { + autoResize: true + }); + + expect(renderer.view.style.width).to.equal('200px'); + }); + + it('Should not automatically resize view if disabled', function () { + var renderer = new CanvasRenderer(200, 200, { + autoResize: false + }); + + expect(renderer.view.style.width).to.equal(''); + }); + + it('Should not automatically resize view if not specified', function () { + var renderer = new CanvasRenderer(200, 200, { + resolution: 2 + }); + + expect(renderer.view.style.width).to.equal(''); + }); + }); +}); diff --git a/test/unit/pixi-v2/renderers/webgl/WebGLGraphics.js b/test/unit/pixi-v2/renderers/webgl/WebGLGraphics.js new file mode 100644 index 0000000..5867b28 --- /dev/null +++ b/test/unit/pixi-v2/renderers/webgl/WebGLGraphics.js @@ -0,0 +1,20 @@ +describe('renderers/wegbl/WebGLGraphics', function () { + 'use strict'; + + var expect = chai.expect; + var WebGLGraphics = PIXI.WebGLGraphics; + + it('Module exists', function () { + expect(WebGLGraphics).to.be.a('function'); + }); + + it('Members exist', function () { + expect(WebGLGraphics).itself.to.respondTo('renderGraphics'); + expect(WebGLGraphics).itself.to.respondTo('updateGraphics'); + expect(WebGLGraphics).itself.to.respondTo('buildRectangle'); + expect(WebGLGraphics).itself.to.respondTo('buildRoundedRectangle'); + expect(WebGLGraphics).itself.to.respondTo('buildCircle'); + expect(WebGLGraphics).itself.to.respondTo('buildLine'); + expect(WebGLGraphics).itself.to.respondTo('buildPoly'); + }); +}); diff --git a/test/unit/pixi-v2/renderers/webgl/WebGLRenderer.js b/test/unit/pixi-v2/renderers/webgl/WebGLRenderer.js new file mode 100644 index 0000000..1680a80 --- /dev/null +++ b/test/unit/pixi-v2/renderers/webgl/WebGLRenderer.js @@ -0,0 +1,49 @@ +describe('renderers/webgl/WebGLRenderer', function () { + 'use strict'; + + var expect = chai.expect; + var WebGLRenderer = PIXI.WebGLRenderer; + + it('Module exists', function () { + expect(WebGLRenderer).to.be.a('function'); + }); + + // Skip tests if WebGL is not available (WebGL not supported in Travis CI) + try { + var renderer = new WebGLRenderer(400, 300, {}); + renderer.destroy(); + } catch (error) { + return; + } + + it('Destroy renderer', function () { + var renderer = new WebGLRenderer(400, 300, {}); + renderer.destroy(); + }); + + describe('.autoResize', function () { + it('Should automatically resize view if enabled', function () { + var renderer = new WebGLRenderer(200, 200, { + autoResize: true + }); + + expect(renderer.view.style.width).to.equal('200px'); + }); + + it('Should not automatically resize view if disabled', function () { + var renderer = new WebGLRenderer(200, 200, { + autoResize: false + }); + + expect(renderer.view.style.width).to.equal(''); + }); + + it('Should not automatically resize view if not specified', function () { + var renderer = new WebGLRenderer(200, 200, { + resolution: 2 + }); + + expect(renderer.view.style.width).to.equal(''); + }); + }); +}); diff --git a/test/unit/pixi-v2/renderers/webgl/WebGLShaders.js b/test/unit/pixi-v2/renderers/webgl/WebGLShaders.js new file mode 100644 index 0000000..6e33e4f --- /dev/null +++ b/test/unit/pixi-v2/renderers/webgl/WebGLShaders.js @@ -0,0 +1,13 @@ +describe('renderers/webgl/WebGLShaders', function () { + 'use strict'; + + var expect = chai.expect; + + it('Module members exist', function () { + + expect(PIXI).to.respondTo('CompileVertexShader'); + expect(PIXI).to.respondTo('CompileFragmentShader'); + expect(PIXI).to.respondTo('_CompileShader'); + expect(PIXI).to.respondTo('compileProgram'); + }); +}); diff --git a/test/unit/pixi-v2/renderers/webgl/WebGLSpriteBatch.js b/test/unit/pixi-v2/renderers/webgl/WebGLSpriteBatch.js new file mode 100644 index 0000000..e662b63 --- /dev/null +++ b/test/unit/pixi-v2/renderers/webgl/WebGLSpriteBatch.js @@ -0,0 +1,10 @@ +describe('renderers/webgl/utils/WebGLSpriteBatch', function () { + 'use strict'; + + var expect = chai.expect; + var WebGLSpriteBatch = PIXI.WebGLSpriteBatch; + + it('Module exists', function () { + expect(WebGLSpriteBatch).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/text/BitmapText.js b/test/unit/pixi-v2/text/BitmapText.js new file mode 100644 index 0000000..9388e3d --- /dev/null +++ b/test/unit/pixi-v2/text/BitmapText.js @@ -0,0 +1,10 @@ +describe('pixi/text/BitmapText', function () { + 'use strict'; + + var expect = chai.expect; + var BitmapText = PIXI.BitmapText; + + it('Module exists', function () { + expect(BitmapText).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/text/Text.js b/test/unit/pixi-v2/text/Text.js new file mode 100644 index 0000000..9bc9ac5 --- /dev/null +++ b/test/unit/pixi-v2/text/Text.js @@ -0,0 +1,10 @@ +describe('pixi/text/Text', function () { + 'use strict'; + + var expect = chai.expect; + var Text = PIXI.Text; + + it('Module exists', function () { + expect(Text).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/textures/BaseTexture.js b/test/unit/pixi-v2/textures/BaseTexture.js new file mode 100644 index 0000000..502b724 --- /dev/null +++ b/test/unit/pixi-v2/textures/BaseTexture.js @@ -0,0 +1,11 @@ +describe('pixi/textures/BaseTexture', function () { + 'use strict'; + + var expect = chai.expect; + var BaseTexture = PIXI.BaseTexture; + + it('Module exists', function () { + expect(BaseTexture).to.be.a('function'); + expect(PIXI).to.have.property('BaseTextureCache').and.to.be.an('object'); + }); +}); diff --git a/test/unit/pixi-v2/textures/RenderTexture.js b/test/unit/pixi-v2/textures/RenderTexture.js new file mode 100644 index 0000000..96acdb4 --- /dev/null +++ b/test/unit/pixi-v2/textures/RenderTexture.js @@ -0,0 +1,15 @@ +describe('pixi/textures/RenderTexture', function () { + 'use strict'; + + var expect = chai.expect; + var RenderTexture = PIXI.RenderTexture; + + it('Module exists', function () { + expect(RenderTexture).to.be.a('function'); + }); + + it('Confirm new instance', function (done) { + var texture = new RenderTexture(100, 100, new PIXI.CanvasRenderer()); + pixi_textures_RenderTexture_confirmNew(texture, done); + }); +}); diff --git a/test/unit/pixi-v2/textures/Texture.js b/test/unit/pixi-v2/textures/Texture.js new file mode 100644 index 0000000..090f64d --- /dev/null +++ b/test/unit/pixi-v2/textures/Texture.js @@ -0,0 +1,26 @@ +describe('pixi/textures/Texture', function () { + 'use strict'; + + var expect = chai.expect; + var Texture = PIXI.Texture; + + it('Module exists', function () { + expect(Texture).to.be.a('function'); + expect(PIXI).to.have.property('TextureCache').and.to.be.an('object'); + }); + + it('Members exist', function () { + expect(Texture).itself.to.respondTo('fromImage'); + expect(Texture).itself.to.respondTo('fromFrame'); + expect(Texture).itself.to.respondTo('fromCanvas'); + expect(Texture).itself.to.respondTo('addTextureToCache'); + expect(Texture).itself.to.respondTo('removeTextureFromCache'); + + // expect(Texture).itself.to.have.deep.property('frameUpdates.length', 0); + }); + + it('Confirm new instance', function (done) { + var texture = Texture.fromImage('/base/test/textures/bunny.png'); + pixi_textures_Texture_confirmNew(texture, done); + }); +}); diff --git a/test/unit/pixi-v2/utils/Detector.js b/test/unit/pixi-v2/utils/Detector.js new file mode 100644 index 0000000..4cf6008 --- /dev/null +++ b/test/unit/pixi-v2/utils/Detector.js @@ -0,0 +1,10 @@ +describe('pixi/utils/Detector', function () { + 'use strict'; + + var expect = chai.expect; + var autoDetectRenderer = PIXI.autoDetectRenderer; + + it('Module exists', function () { + expect(autoDetectRenderer).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/utils/EventTarget.js b/test/unit/pixi-v2/utils/EventTarget.js new file mode 100644 index 0000000..1cfc3a4 --- /dev/null +++ b/test/unit/pixi-v2/utils/EventTarget.js @@ -0,0 +1,361 @@ +describe('pixi/utils/EventTarget', function () { + 'use strict'; + + var expect = chai.expect; + + var Clazz, PClazz, obj, pobj, obj2; + beforeEach(function () { + Clazz = function () {}; + PClazz = function () {}; + + PIXI.EventTarget.mixin(Clazz.prototype); + PIXI.EventTarget.mixin(PClazz.prototype); + + obj = new Clazz(); + obj2 = new Clazz(); + pobj = new PClazz(); + + obj.parent = pobj; + obj2.parent = obj; + }); + + it('Module exists', function () { + expect(PIXI.EventTarget).to.be.an('object'); + }); + + it('Confirm new instance', function () { + pixi_utils_EventTarget_confirm(obj); + }); + + it('simple on/emit case works', function () { + var myData = {}; + + obj.on('myevent', function (event) { + pixi_utils_EventTarget_Event_confirm(event, obj, myData); + }); + + obj.emit('myevent', myData); + }); + + it('simple once case works', function () { + var called = 0; + + obj.once('myevent', function() { called++; }); + + obj.emit('myevent'); + obj.emit('myevent'); + obj.emit('myevent'); + obj.emit('myevent'); + obj.emit('myevent'); + + expect(called).to.equal(1); + }); + + it('simple off case works', function (done) { + function onMyEvent() { + done(new Error('Event listener should not have been called')); + } + + obj.on('myevent', onMyEvent); + obj.off('myevent', onMyEvent); + obj.emit('myevent'); + + done(); + }); + + it('simple propagation case works', function (done) { + var myData = {}; + + pobj.on('myevent', function () { + done(); + }); + + obj.emit('myevent'); + }); + + it('simple stopPropagation case works', function (done) { + var myData = {}; + + pobj.on('myevent', function () { + done(new Error('Event listener should not have been called on the parent element')); + }); + + obj.on('myevent', function (evt) { + evt.stopPropagation(); + }); + + obj.emit('myevent'); + + done(); + }); + + it('simple stopImmediatePropagation case works', function (done) { + var myData = {}; + + pobj.on('myevent', function () { + done(new Error('Event listener should not have been called on the parent')); + }); + + obj.on('myevent', function (evt) { + evt.stopImmediatePropagation(); + }); + + obj.on('myevent', function () { + done(new Error('Event listener should not have been called on the second')); + }); + + obj.emit('myevent'); + + done(); + }); + + it('multiple dispatches work properly', function () { + var called = 0; + + function onMyEvent() { + called++; + } + + obj.on('myevent', onMyEvent); + obj.emit('myevent'); + obj.emit('myevent'); + obj.emit('myevent'); + obj.emit('myevent'); + + expect(called).to.equal(4); + }); + + it('multiple events work properly', function () { + var called = 0; + + function onMyEvent() { + called++; + } + + obj.on('myevent1', onMyEvent); + obj.on('myevent2', onMyEvent); + obj.on('myevent3', onMyEvent); + obj.emit('myevent1'); + obj.emit('myevent2'); + obj.emit('myevent3'); + + expect(called).to.equal(3); + }); + + it('multiple events one removed works properly', function () { + var called = 0; + + function onMyEvent() { + called++; + } + + obj.on('myevent1', onMyEvent); + obj.on('myevent2', onMyEvent); + obj.on('myevent3', onMyEvent); + + obj.emit('myevent1'); + obj.emit('myevent2'); + obj.emit('myevent3'); + + obj.off('myevent2', onMyEvent); + + obj.emit('myevent1'); + obj.emit('myevent2'); + obj.emit('myevent3'); + + expect(called).to.equal(5); + }); + + it('multiple handlers for one event with some removed', function () { + var called = 0; + + var onMyEvent = function () { + called++; + }, + onMyEvent2 = function () { + called++; + }; + + // add 2 handlers and confirm they both get called + obj.on('myevent', onMyEvent); + obj.on('myevent', onMyEvent); + obj.on('myevent', onMyEvent2); + obj.on('myevent', onMyEvent2); + + obj.emit('myevent'); + + expect(called).to.equal(4); + + // remove one of the handlers, emit again, then ensure 1 more call is made + obj.off('myevent', onMyEvent); + + obj.emit('myevent'); + + expect(called).to.equal(6); + }); + + it('calls to off without a handler do nothing', function () { + var called = 0; + + var onMyEvent = function () { + called++; + }; + + obj.on('myevent', onMyEvent); + obj.on('myevent', onMyEvent); + + obj.emit('myevent'); + + expect(called).to.equal(2); + + obj.off('myevent'); + + obj.emit('myevent'); + + expect(called).to.equal(4); + + obj.off('myevent', onMyEvent); + + obj.emit('myevent'); + + expect(called).to.equal(4); + }); + + it('handles multiple instances with the same prototype', function () { + var called = 0; + + function onMyEvent(e) { + called++; + } + + obj.on('myevent1', onMyEvent); + obj.on('myevent2', onMyEvent); + + obj2.istwo = true; + obj2.on('myevent1', onMyEvent); + obj2.on('myevent2', onMyEvent); + + obj.emit('myevent1'); + obj.emit('myevent2'); + obj2.emit('myevent1'); + obj2.emit('myevent2'); + + //we emit 4 times, but since obj2 is a child of obj the event should bubble + //up to obj and show up there as well. So the obj2.emit() calls each increment + //the counter twice. + expect(called).to.equal(6); + }); + + it('is backwards compatible with older .dispatchEvent({})', function () { + var called = 0, + data = { + some: 'thing', + hello: true + }; + + function onMyEvent(event) { + pixi_utils_EventTarget_Event_confirm(event, obj, data); + + called++; + } + + obj.on('myevent1', onMyEvent); + obj.on('myevent2', onMyEvent); + obj.on('myevent3', onMyEvent); + + data.type = 'myevent1'; + obj.emit(data); + + data.type = 'myevent2'; + obj.emit(data); + + data.type = 'myevent3'; + obj.emit(data); + + obj.off('myevent2', onMyEvent); + + data.type = 'myevent1'; + obj.emit(data); + + data.type = 'myevent2'; + obj.emit(data); + + data.type = 'myevent3'; + obj.emit(data); + + expect(called).to.equal(5); + }); + + it('is backwards compatible with older .call(this)', function () { + var Fn = function() { + PIXI.EventTarget.call(this); + }, + o = new Fn(); + + pixi_utils_EventTarget_confirm(o); + }); + + it('is backwards compatible with older .addEventListener("")', function () { + var called = 0, + data = { + some: 'thing', + hello: true + }; + + function onMyEvent(event) { + pixi_utils_EventTarget_Event_confirm(event, obj, data); + + called++; + } + + obj.addEventListener('myevent1', onMyEvent); + obj.addEventListener('myevent2', onMyEvent); + obj.addEventListener('myevent3', onMyEvent); + + data.type = 'myevent1'; + obj.emit(data); + + data.type = 'myevent2'; + obj.emit(data); + + data.type = 'myevent3'; + obj.emit(data); + + obj.off('myevent2', onMyEvent); + + data.type = 'myevent1'; + obj.emit(data); + + data.type = 'myevent2'; + obj.emit(data); + + data.type = 'myevent3'; + obj.emit(data); + + expect(called).to.equal(5); + }); + + it('event remove during emit call properly', function () { + var called = 0; + + function cb1() { + called++; + obj.off('myevent', cb1); + } + function cb2() { + called++; + obj.off('myevent', cb2); + } + function cb3() { + called++; + obj.off('myevent', cb3); + } + + obj.on('myevent', cb1); + obj.on('myevent', cb2); + obj.on('myevent', cb3); + obj.emit('myevent', ''); + + expect(called).to.equal(3); + }); +}); diff --git a/test/unit/pixi-v2/utils/Polyk.js b/test/unit/pixi-v2/utils/Polyk.js new file mode 100644 index 0000000..dfc7128 --- /dev/null +++ b/test/unit/pixi-v2/utils/Polyk.js @@ -0,0 +1,14 @@ +describe('pixi/utils/Polyk', function () { + 'use strict'; + + var expect = chai.expect; + var PolyK = PIXI.PolyK; + + it('Module exists', function () { + expect(PolyK).to.be.an('object'); + }); + + it('Members exist', function () { + expect(PolyK).to.respondTo('Triangulate'); + }); +}); diff --git a/test/unit/pixi-v2/utils/Utils.js b/test/unit/pixi-v2/utils/Utils.js new file mode 100644 index 0000000..c97b3c6 --- /dev/null +++ b/test/unit/pixi-v2/utils/Utils.js @@ -0,0 +1,17 @@ +describe('Utils', function () { + 'use strict'; + + var expect = chai.expect; + + it('requestAnimationFrame exists', function () { + expect(global).to.respondTo('requestAnimationFrame'); + }); + + it('cancelAnimationFrame exists', function () { + expect(global).to.respondTo('cancelAnimationFrame'); + }); + + it('requestAnimFrame exists', function () { + expect(global).to.respondTo('requestAnimFrame'); + }); +}); diff --git a/test/unit/pixi/InteractionManager.js b/test/unit/pixi/InteractionManager.js deleted file mode 100644 index ed3001f..0000000 --- a/test/unit/pixi/InteractionManager.js +++ /dev/null @@ -1,10 +0,0 @@ -describe('pixi/InteractionManager', function () { - 'use strict'; - - var expect = chai.expect; - var InteractionManager = PIXI.InteractionManager; - - it('Module exists', function () { - expect(InteractionManager).to.be.a('function'); - }); -}); diff --git a/test/unit/pixi/Pixi.js b/test/unit/pixi/Pixi.js deleted file mode 100644 index 27debc1..0000000 --- a/test/unit/pixi/Pixi.js +++ /dev/null @@ -1,9 +0,0 @@ -describe('pixi/Pixi', function () { - 'use strict'; - - var expect = chai.expect; - - it('Module exists', function () { - expect(global).to.have.property('PIXI').and.to.be.an('object'); - }); -}); diff --git a/test/unit/pixi/core/Circle.js b/test/unit/pixi/core/Circle.js deleted file mode 100644 index fbcfa17..0000000 --- a/test/unit/pixi/core/Circle.js +++ /dev/null @@ -1,21 +0,0 @@ -describe('pixi/core/Circle', function () { - 'use strict'; - - var expect = chai.expect; - var Circle = PIXI.Circle; - - it('Module exists', function () { - expect(Circle).to.be.a('function'); - }); - - it('Confirm new instance', function () { - var obj = new Circle(); - pixi_core_Circle_confirmNewCircle(obj); - }); - - it("getBounds should return Rectangle that bounds the circle", function() { - var obj = new Circle(100, 250, 50); - var bounds = obj.getBounds(); - pixi_core_Circle_isBoundedByRectangle(obj, bounds); - }); -}); diff --git a/test/unit/pixi/core/Ellipse.js b/test/unit/pixi/core/Ellipse.js deleted file mode 100644 index 026b56f..0000000 --- a/test/unit/pixi/core/Ellipse.js +++ /dev/null @@ -1,24 +0,0 @@ -describe('pixi/core/Ellipse', function () { - 'use strict'; - - var expect = chai.expect; - var Ellipse = PIXI.Ellipse; - - it('Module exists', function () { - expect(Ellipse).to.be.a('function'); - }); - - it('Confirm new instance', function () { - var obj = new Ellipse(); - - expect(obj).to.be.an.instanceof(Ellipse); - expect(obj).to.respondTo('clone'); - expect(obj).to.respondTo('contains'); - expect(obj).to.respondTo('getBounds'); - - expect(obj).to.have.property('x', 0); - expect(obj).to.have.property('y', 0); - expect(obj).to.have.property('width', 0); - expect(obj).to.have.property('height', 0); - }); -}); diff --git a/test/unit/pixi/core/Matrix.js b/test/unit/pixi/core/Matrix.js deleted file mode 100644 index da75e2e..0000000 --- a/test/unit/pixi/core/Matrix.js +++ /dev/null @@ -1,14 +0,0 @@ -describe('pixi/core/Matrix', function () { - 'use strict'; - - var expect = chai.expect; - - it('Matrix exists', function () { - expect(PIXI.Matrix).to.be.an('function'); - }); - - it('Confirm new Matrix', function () { - var matrix = new PIXI.Matrix(); - pixi_core_Matrix_confirmNewMatrix(matrix); - }); -}); diff --git a/test/unit/pixi/core/Point.js b/test/unit/pixi/core/Point.js deleted file mode 100644 index c4d5163..0000000 --- a/test/unit/pixi/core/Point.js +++ /dev/null @@ -1,15 +0,0 @@ -describe('pixi/core/Point', function () { - 'use strict'; - - var expect = chai.expect; - var Point = PIXI.Point; - - it('Module exists', function () { - expect(Point).to.be.a('function'); - }); - - it('Confirm new instance', function () { - var obj = new Point(); - pixi_core_Point_confirm(obj, 0, 0); - }); -}); diff --git a/test/unit/pixi/core/Polygon.js b/test/unit/pixi/core/Polygon.js deleted file mode 100644 index dc8c918..0000000 --- a/test/unit/pixi/core/Polygon.js +++ /dev/null @@ -1,20 +0,0 @@ -describe('pixi/core/Polygon', function () { - 'use strict'; - - var expect = chai.expect; - var Polygon = PIXI.Polygon; - - it('Module exists', function () { - expect(Polygon).to.be.a('function'); - }); - - it('Confirm new instance', function () { - var obj = new Polygon(); - - expect(obj).to.be.an.instanceof(Polygon); - expect(obj).to.respondTo('clone'); - expect(obj).to.respondTo('contains'); - - expect(obj).to.have.deep.property('points.length', 0); - }); -}); diff --git a/test/unit/pixi/core/Rectangle.js b/test/unit/pixi/core/Rectangle.js deleted file mode 100644 index d43316e..0000000 --- a/test/unit/pixi/core/Rectangle.js +++ /dev/null @@ -1,15 +0,0 @@ -describe('pixi/core/Rectangle', function () { - 'use strict'; - - var expect = chai.expect; - var Rectangle = PIXI.Rectangle; - - it('Module exists', function () { - expect(Rectangle).to.be.a('function'); - }); - - it('Confirm new instance', function () { - var rect = new Rectangle(); - pixi_core_Rectangle_confirm(rect, 0, 0, 0, 0); - }); -}); diff --git a/test/unit/pixi/display/DisplayObject.js b/test/unit/pixi/display/DisplayObject.js deleted file mode 100644 index 044acf8..0000000 --- a/test/unit/pixi/display/DisplayObject.js +++ /dev/null @@ -1,21 +0,0 @@ -describe('pixi/display/DisplayObject', function () { - 'use strict'; - - var expect = chai.expect; - var DisplayObject = PIXI.DisplayObject; - - it('Module exists', function () { - expect(DisplayObject).to.be.a('function'); - // expect(PIXI).to.have.property('visibleCount', 0); - }); - - it('Confirm new instance', function () { - var obj = new DisplayObject(); - - pixi_display_DisplayObject_confirmNew(obj); - expect(obj).to.have.property('hitArea', null); - expect(obj).to.have.property('interactive', false); - expect(obj).to.have.property('renderable', false); - expect(obj).to.have.property('stage', null); - }); -}); diff --git a/test/unit/pixi/display/DisplayObjectContainer.js b/test/unit/pixi/display/DisplayObjectContainer.js deleted file mode 100644 index 15a3376..0000000 --- a/test/unit/pixi/display/DisplayObjectContainer.js +++ /dev/null @@ -1,67 +0,0 @@ -describe('pixi/display/DisplayObjectContainer', function () { - 'use strict'; - - var expect = chai.expect; - var DisplayObjectContainer = PIXI.DisplayObjectContainer; - - it('Module exists', function () { - expect(DisplayObjectContainer).to.be.a('function'); - }); - - it('Confirm new instance', function () { - var obj = new DisplayObjectContainer(); - - pixi_display_DisplayObjectContainer_confirmNew(obj); - expect(obj).to.have.property('hitArea', null); - expect(obj).to.have.property('interactive', false); - expect(obj).to.have.property('renderable', false); - expect(obj).to.have.property('stage', null); - }); - - it('Gets child index', function() { - var container = new PIXI.DisplayObjectContainer(); - var children = []; - for (var i = 0; i < 10; i++) { - var child = new PIXI.DisplayObject(); - children.push(child); - container.addChild(child); - } - - for (i = 0; i < children.length; i++) { - expect(i).to.eql(container.getChildIndex(children[i])); - } - }); - - it('throws error when trying to get index of not a child', function() { - var container = new PIXI.DisplayObjectContainer(); - var child = new PIXI.DisplayObject(); - - expect(function() { container.getChildIndex(child); }).to.throw(); - }); - - it('Sets child index', function() { - var container = new PIXI.DisplayObjectContainer(); - var children = []; - - for (var i = 0; i < 10; i++) { - var child = new PIXI.DisplayObject(); - children.push(child); - container.addChild(child); - } - children.reverse(); - - for (i = 0; i < children.length; i++) { - container.setChildIndex(children[i], i); - expect(i).to.eql(container.getChildIndex(children[i])); - } - }); - - it('throws error when trying to set incorect index', function() { - var container = new PIXI.DisplayObjectContainer(); - var child = new PIXI.DisplayObject(); - container.addChild(child); - - expect(function() { container.setChildIndex(child, -1); }).to.throw(); - expect(function() { container.setChildIndex(child, 1); }).to.throw(); - }); -}); diff --git a/test/unit/pixi-v2/InteractionManager.js b/test/unit/pixi-v2/InteractionManager.js new file mode 100644 index 0000000..ed3001f --- /dev/null +++ b/test/unit/pixi-v2/InteractionManager.js @@ -0,0 +1,10 @@ +describe('pixi/InteractionManager', function () { + 'use strict'; + + var expect = chai.expect; + var InteractionManager = PIXI.InteractionManager; + + it('Module exists', function () { + expect(InteractionManager).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/Pixi.js b/test/unit/pixi-v2/Pixi.js new file mode 100644 index 0000000..27debc1 --- /dev/null +++ b/test/unit/pixi-v2/Pixi.js @@ -0,0 +1,9 @@ +describe('pixi/Pixi', function () { + 'use strict'; + + var expect = chai.expect; + + it('Module exists', function () { + expect(global).to.have.property('PIXI').and.to.be.an('object'); + }); +}); diff --git a/test/unit/pixi-v2/core/Circle.js b/test/unit/pixi-v2/core/Circle.js new file mode 100644 index 0000000..fbcfa17 --- /dev/null +++ b/test/unit/pixi-v2/core/Circle.js @@ -0,0 +1,21 @@ +describe('pixi/core/Circle', function () { + 'use strict'; + + var expect = chai.expect; + var Circle = PIXI.Circle; + + it('Module exists', function () { + expect(Circle).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Circle(); + pixi_core_Circle_confirmNewCircle(obj); + }); + + it("getBounds should return Rectangle that bounds the circle", function() { + var obj = new Circle(100, 250, 50); + var bounds = obj.getBounds(); + pixi_core_Circle_isBoundedByRectangle(obj, bounds); + }); +}); diff --git a/test/unit/pixi-v2/core/Ellipse.js b/test/unit/pixi-v2/core/Ellipse.js new file mode 100644 index 0000000..026b56f --- /dev/null +++ b/test/unit/pixi-v2/core/Ellipse.js @@ -0,0 +1,24 @@ +describe('pixi/core/Ellipse', function () { + 'use strict'; + + var expect = chai.expect; + var Ellipse = PIXI.Ellipse; + + it('Module exists', function () { + expect(Ellipse).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Ellipse(); + + expect(obj).to.be.an.instanceof(Ellipse); + expect(obj).to.respondTo('clone'); + expect(obj).to.respondTo('contains'); + expect(obj).to.respondTo('getBounds'); + + expect(obj).to.have.property('x', 0); + expect(obj).to.have.property('y', 0); + expect(obj).to.have.property('width', 0); + expect(obj).to.have.property('height', 0); + }); +}); diff --git a/test/unit/pixi-v2/core/Matrix.js b/test/unit/pixi-v2/core/Matrix.js new file mode 100644 index 0000000..da75e2e --- /dev/null +++ b/test/unit/pixi-v2/core/Matrix.js @@ -0,0 +1,14 @@ +describe('pixi/core/Matrix', function () { + 'use strict'; + + var expect = chai.expect; + + it('Matrix exists', function () { + expect(PIXI.Matrix).to.be.an('function'); + }); + + it('Confirm new Matrix', function () { + var matrix = new PIXI.Matrix(); + pixi_core_Matrix_confirmNewMatrix(matrix); + }); +}); diff --git a/test/unit/pixi-v2/core/Point.js b/test/unit/pixi-v2/core/Point.js new file mode 100644 index 0000000..c4d5163 --- /dev/null +++ b/test/unit/pixi-v2/core/Point.js @@ -0,0 +1,15 @@ +describe('pixi/core/Point', function () { + 'use strict'; + + var expect = chai.expect; + var Point = PIXI.Point; + + it('Module exists', function () { + expect(Point).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Point(); + pixi_core_Point_confirm(obj, 0, 0); + }); +}); diff --git a/test/unit/pixi-v2/core/Polygon.js b/test/unit/pixi-v2/core/Polygon.js new file mode 100644 index 0000000..dc8c918 --- /dev/null +++ b/test/unit/pixi-v2/core/Polygon.js @@ -0,0 +1,20 @@ +describe('pixi/core/Polygon', function () { + 'use strict'; + + var expect = chai.expect; + var Polygon = PIXI.Polygon; + + it('Module exists', function () { + expect(Polygon).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Polygon(); + + expect(obj).to.be.an.instanceof(Polygon); + expect(obj).to.respondTo('clone'); + expect(obj).to.respondTo('contains'); + + expect(obj).to.have.deep.property('points.length', 0); + }); +}); diff --git a/test/unit/pixi-v2/core/Rectangle.js b/test/unit/pixi-v2/core/Rectangle.js new file mode 100644 index 0000000..d43316e --- /dev/null +++ b/test/unit/pixi-v2/core/Rectangle.js @@ -0,0 +1,15 @@ +describe('pixi/core/Rectangle', function () { + 'use strict'; + + var expect = chai.expect; + var Rectangle = PIXI.Rectangle; + + it('Module exists', function () { + expect(Rectangle).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var rect = new Rectangle(); + pixi_core_Rectangle_confirm(rect, 0, 0, 0, 0); + }); +}); diff --git a/test/unit/pixi-v2/display/DisplayObject.js b/test/unit/pixi-v2/display/DisplayObject.js new file mode 100644 index 0000000..044acf8 --- /dev/null +++ b/test/unit/pixi-v2/display/DisplayObject.js @@ -0,0 +1,21 @@ +describe('pixi/display/DisplayObject', function () { + 'use strict'; + + var expect = chai.expect; + var DisplayObject = PIXI.DisplayObject; + + it('Module exists', function () { + expect(DisplayObject).to.be.a('function'); + // expect(PIXI).to.have.property('visibleCount', 0); + }); + + it('Confirm new instance', function () { + var obj = new DisplayObject(); + + pixi_display_DisplayObject_confirmNew(obj); + expect(obj).to.have.property('hitArea', null); + expect(obj).to.have.property('interactive', false); + expect(obj).to.have.property('renderable', false); + expect(obj).to.have.property('stage', null); + }); +}); diff --git a/test/unit/pixi-v2/display/DisplayObjectContainer.js b/test/unit/pixi-v2/display/DisplayObjectContainer.js new file mode 100644 index 0000000..15a3376 --- /dev/null +++ b/test/unit/pixi-v2/display/DisplayObjectContainer.js @@ -0,0 +1,67 @@ +describe('pixi/display/DisplayObjectContainer', function () { + 'use strict'; + + var expect = chai.expect; + var DisplayObjectContainer = PIXI.DisplayObjectContainer; + + it('Module exists', function () { + expect(DisplayObjectContainer).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new DisplayObjectContainer(); + + pixi_display_DisplayObjectContainer_confirmNew(obj); + expect(obj).to.have.property('hitArea', null); + expect(obj).to.have.property('interactive', false); + expect(obj).to.have.property('renderable', false); + expect(obj).to.have.property('stage', null); + }); + + it('Gets child index', function() { + var container = new PIXI.DisplayObjectContainer(); + var children = []; + for (var i = 0; i < 10; i++) { + var child = new PIXI.DisplayObject(); + children.push(child); + container.addChild(child); + } + + for (i = 0; i < children.length; i++) { + expect(i).to.eql(container.getChildIndex(children[i])); + } + }); + + it('throws error when trying to get index of not a child', function() { + var container = new PIXI.DisplayObjectContainer(); + var child = new PIXI.DisplayObject(); + + expect(function() { container.getChildIndex(child); }).to.throw(); + }); + + it('Sets child index', function() { + var container = new PIXI.DisplayObjectContainer(); + var children = []; + + for (var i = 0; i < 10; i++) { + var child = new PIXI.DisplayObject(); + children.push(child); + container.addChild(child); + } + children.reverse(); + + for (i = 0; i < children.length; i++) { + container.setChildIndex(children[i], i); + expect(i).to.eql(container.getChildIndex(children[i])); + } + }); + + it('throws error when trying to set incorect index', function() { + var container = new PIXI.DisplayObjectContainer(); + var child = new PIXI.DisplayObject(); + container.addChild(child); + + expect(function() { container.setChildIndex(child, -1); }).to.throw(); + expect(function() { container.setChildIndex(child, 1); }).to.throw(); + }); +}); diff --git a/test/unit/pixi-v2/display/MovieClip.js b/test/unit/pixi-v2/display/MovieClip.js new file mode 100644 index 0000000..f3c6c6a --- /dev/null +++ b/test/unit/pixi-v2/display/MovieClip.js @@ -0,0 +1,33 @@ +describe('pixi/display/MovieClip', function () { + 'use strict'; + + var expect = chai.expect; + var MovieClip = PIXI.MovieClip; + var Texture = PIXI.Texture; + + it('Module exists', function () { + expect(MovieClip).to.be.a('function'); + }); + + it('Confirm new instance', function (done) { + var texture = Texture.fromImage('/base/test/textures/SpriteSheet-Explosion.png'); + var obj = new MovieClip([texture]); + + pixi_display_Sprite_confirmNew(obj, done); + + expect(obj).to.be.an.instanceof(MovieClip); + expect(obj).to.respondTo('stop'); + expect(obj).to.respondTo('play'); + expect(obj).to.respondTo('gotoAndStop'); + expect(obj).to.respondTo('gotoAndPlay'); + expect(obj).to.respondTo('updateTransform'); + + expect(obj).to.have.deep.property('textures.length', 1); + expect(obj).to.have.deep.property('textures[0]', texture); + expect(obj).to.have.property('animationSpeed', 1); + expect(obj).to.have.property('loop', true); + expect(obj).to.have.property('onComplete', null); + expect(obj).to.have.property('currentFrame', 0); + expect(obj).to.have.property('playing', false); + }); +}); diff --git a/test/unit/pixi-v2/display/Sprite.js b/test/unit/pixi-v2/display/Sprite.js new file mode 100644 index 0000000..30c8076 --- /dev/null +++ b/test/unit/pixi-v2/display/Sprite.js @@ -0,0 +1,28 @@ +describe('pixi/display/Sprite', function () { + 'use strict'; + + var expect = chai.expect; + var Sprite = PIXI.Sprite; + var Texture = PIXI.Texture; + + it('Module exists', function () { + expect(Sprite).to.be.a('function'); + expect(PIXI).to.have.deep.property('blendModes.NORMAL', 0); + expect(PIXI).to.have.deep.property('blendModes.ADD', 1); + expect(PIXI).to.have.deep.property('blendModes.MULTIPLY', 2); + expect(PIXI).to.have.deep.property('blendModes.SCREEN', 3); + }); + + + it('Members exist', function () { + expect(Sprite).itself.to.respondTo('fromImage'); + expect(Sprite).itself.to.respondTo('fromFrame'); + }); + + it('Confirm new instance', function (done) { + var texture = Texture.fromImage('/base/test/textures/SpriteSheet-Aliens.png'); + var obj = new Sprite(texture); + + pixi_display_Sprite_confirmNew(obj, done); + }); +}); diff --git a/test/unit/pixi-v2/display/Stage.js b/test/unit/pixi-v2/display/Stage.js new file mode 100644 index 0000000..6974c2e --- /dev/null +++ b/test/unit/pixi-v2/display/Stage.js @@ -0,0 +1,49 @@ +describe('pixi/display/Stage', function () { + 'use strict'; + + var expect = chai.expect; + var Stage = PIXI.Stage; + var InteractionManager = PIXI.InteractionManager; + var Rectangle = PIXI.Rectangle; + + it('Module exists', function () { + expect(Stage).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Stage(null, true); + + pixi_display_DisplayObjectContainer_confirmNew(obj); + + expect(obj).to.be.an.instanceof(Stage); + expect(obj).to.respondTo('updateTransform'); + expect(obj).to.respondTo('setBackgroundColor'); + expect(obj).to.respondTo('getMousePosition'); + // FIXME: duplicate member in DisplayObject + pixi_core_Matrix_confirmNewMatrix(obj.worldTransform); + // FIXME: convert arg to bool in constructor + expect(obj).to.have.property('interactive', true); + + expect(obj).to.have.property('interactionManager') + .and.to.be.an.instanceof(InteractionManager) + .and.to.have.property('stage', obj); + + expect(obj).to.have.property('dirty', true); + + expect(obj).to.have.property('stage', obj); + + expect(obj).to.have.property('hitArea') + .and.to.be.an.instanceof(Rectangle); + pixi_core_Rectangle_confirm(obj.hitArea, 0, 0, 100000, 100000); + + expect(obj).to.have.property('backgroundColor', 0x000000); + expect(obj).to.have.deep.property('backgroundColorSplit.length', 3); + expect(obj).to.have.deep.property('backgroundColorSplit[0]', 0); + expect(obj).to.have.deep.property('backgroundColorSplit[1]', 0); + expect(obj).to.have.deep.property('backgroundColorSplit[2]', 0); + expect(obj).to.have.property('backgroundColorString', '#000000'); + + + expect(obj).to.have.property('worldVisible', true); + }); +}); diff --git a/test/unit/pixi-v2/extras/Rope.js b/test/unit/pixi-v2/extras/Rope.js new file mode 100644 index 0000000..05885ac --- /dev/null +++ b/test/unit/pixi-v2/extras/Rope.js @@ -0,0 +1,31 @@ +describe('pixi/extras/Rope', function () { + 'use strict'; + + var expect = chai.expect; + var Rope = PIXI.Rope; + var Texture = PIXI.Texture; + var Point = PIXI.Point; + + it('Module exists', function () { + expect(Rope).to.be.a('function'); + }); + + it('Confirm new instance', function () { + + var texture = Texture.fromImage('/base/test/textures/bunny.png'); + + // TODO-Alvin + // Same as Strip + + // var obj = new Rope(texture, [new Point(), new Point(5, 10), new Point(10, 20)]); + + // pixi_extras_Strip_confirmNew(obj); + + // expect(obj).to.be.an.instanceof(Rope); + // expect(obj).to.respondTo('refresh'); + // expect(obj).to.respondTo('updateTransform'); + // expect(obj).to.respondTo('setTexture'); + + // TODO: Test properties + }); +}); diff --git a/test/unit/pixi-v2/extras/Spine.js b/test/unit/pixi-v2/extras/Spine.js new file mode 100644 index 0000000..0708bc0 --- /dev/null +++ b/test/unit/pixi-v2/extras/Spine.js @@ -0,0 +1,10 @@ +describe('pixi/extras/Spine', function () { + 'use strict'; + + var expect = chai.expect; + var Spine = PIXI.Spine; + + it('Module exists', function () { + expect(Spine).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/extras/Strip.js b/test/unit/pixi-v2/extras/Strip.js new file mode 100644 index 0000000..230af90 --- /dev/null +++ b/test/unit/pixi-v2/extras/Strip.js @@ -0,0 +1,26 @@ +describe('pixi/extras/Strip', function () { + 'use strict'; + + var expect = chai.expect; + var Strip = PIXI.Strip; + var Texture = PIXI.Texture; + + it('Module exists', function () { + expect(Strip).to.be.a('function'); + }); + + it('Confirm new instance', function () { + + + // TODO-Alvin + // We tweaked it to make it pass the tests, but the whole strip class needs + // to be re-coded + + var texture = Texture.fromImage('/base/test/textures/bunny.png'); + + // var obj = new Strip(texture, 20, 10000); + + + // pixi_extras_Strip_confirmNew(obj); + }); +}); diff --git a/test/unit/pixi-v2/extras/TilingSprite.js b/test/unit/pixi-v2/extras/TilingSprite.js new file mode 100644 index 0000000..56aea14 --- /dev/null +++ b/test/unit/pixi-v2/extras/TilingSprite.js @@ -0,0 +1,24 @@ +describe('pixi/extras/TilingSprite', function () { + 'use strict'; + + var expect = chai.expect; + var TilingSprite = PIXI.TilingSprite; + var Texture = PIXI.Texture; + + it('Module exists', function () { + expect(TilingSprite).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var texture = Texture.fromImage('/base/test/textures/bunny.png'); + var obj = new TilingSprite(texture, 6000, 12000); + + pixi_display_DisplayObjectContainer_confirmNew(obj); + + expect(obj).to.be.an.instanceof(TilingSprite); + expect(obj).to.respondTo('setTexture'); + expect(obj).to.respondTo('onTextureUpdate'); + + // TODO: Test properties + }); +}); diff --git a/test/unit/pixi-v2/filters/FilterBlock.js b/test/unit/pixi-v2/filters/FilterBlock.js new file mode 100644 index 0000000..870cec0 --- /dev/null +++ b/test/unit/pixi-v2/filters/FilterBlock.js @@ -0,0 +1,10 @@ +describe('pixi/filters/FilterBlock', function () { + 'use strict'; + + var expect = chai.expect; + var FilterBlock = PIXI.FilterBlock; + + it('Module exists', function () { + expect(FilterBlock).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/AssetLoader.js b/test/unit/pixi-v2/loaders/AssetLoader.js new file mode 100644 index 0000000..a0aa0b5 --- /dev/null +++ b/test/unit/pixi-v2/loaders/AssetLoader.js @@ -0,0 +1,10 @@ +describe('pixi/loaders/AssetLoader', function () { + 'use strict'; + + var expect = chai.expect; + var AssetLoader = PIXI.AssetLoader; + + it('Module exists', function () { + expect(AssetLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/BitmapFontLoader.js b/test/unit/pixi-v2/loaders/BitmapFontLoader.js new file mode 100644 index 0000000..046f018 --- /dev/null +++ b/test/unit/pixi-v2/loaders/BitmapFontLoader.js @@ -0,0 +1,9 @@ +describe('pixi/loaders/BitmapFontLoader', function () { + 'use strict'; + + var expect = chai.expect; + + it('Module exists', function () { + expect(PIXI.BitmapFontLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/ImageLoader.js b/test/unit/pixi-v2/loaders/ImageLoader.js new file mode 100644 index 0000000..8b1f556 --- /dev/null +++ b/test/unit/pixi-v2/loaders/ImageLoader.js @@ -0,0 +1,10 @@ +describe('pixi/loaders/ImageLoader', function () { + 'use strict'; + + var expect = chai.expect; + var ImageLoader = PIXI.ImageLoader; + + it('Module exists', function () { + expect(ImageLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/JsonLoader.js b/test/unit/pixi-v2/loaders/JsonLoader.js new file mode 100644 index 0000000..c577e83 --- /dev/null +++ b/test/unit/pixi-v2/loaders/JsonLoader.js @@ -0,0 +1,10 @@ +describe('pixi/loaders/JsonLoader', function () { + 'use strict'; + + var expect = chai.expect; + var JsonLoader = PIXI.JsonLoader; + + it('Module exists', function () { + expect(JsonLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/SpineLoader.js b/test/unit/pixi-v2/loaders/SpineLoader.js new file mode 100644 index 0000000..fdcc0b8 --- /dev/null +++ b/test/unit/pixi-v2/loaders/SpineLoader.js @@ -0,0 +1,10 @@ +describe('pixi/loaders/SpineLoader', function () { + 'use strict'; + + var expect = chai.expect; + var SpineLoader = PIXI.SpineLoader; + + it('Module exists', function () { + expect(SpineLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/SpriteSheetLoader.js b/test/unit/pixi-v2/loaders/SpriteSheetLoader.js new file mode 100644 index 0000000..57beb27 --- /dev/null +++ b/test/unit/pixi-v2/loaders/SpriteSheetLoader.js @@ -0,0 +1,10 @@ +describe('pixi/loaders/SpriteSheetLoader', function () { + 'use strict'; + + var expect = chai.expect; + var SpriteSheetLoader = PIXI.SpriteSheetLoader; + + it('Module exists', function () { + expect(SpriteSheetLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/primitives/Graphics.js b/test/unit/pixi-v2/primitives/Graphics.js new file mode 100644 index 0000000..f3849eb --- /dev/null +++ b/test/unit/pixi-v2/primitives/Graphics.js @@ -0,0 +1,44 @@ +describe('pixi/primitives/Graphics', function () { + 'use strict'; + + var expect = chai.expect; + var Graphics = PIXI.Graphics; + + it('Module exists', function () { + expect(Graphics).to.be.a('function'); + + expect(Graphics).itself.to.have.property('POLY', 0); + expect(Graphics).itself.to.have.property('RECT', 1); + expect(Graphics).itself.to.have.property('CIRC', 2); + expect(Graphics).itself.to.have.property('ELIP', 3); + expect(Graphics).itself.to.have.property('RREC', 4); + }); + + it('Confirm new instance', function () { + var obj = new Graphics(); + + pixi_display_DisplayObjectContainer_confirmNew(obj); + + expect(obj).to.be.an.instanceof(Graphics); + expect(obj).to.respondTo('lineStyle'); + expect(obj).to.respondTo('lineStyle'); + expect(obj).to.respondTo('moveTo'); + expect(obj).to.respondTo('lineTo'); + expect(obj).to.respondTo('beginFill'); + expect(obj).to.respondTo('endFill'); + expect(obj).to.respondTo('drawRect'); + // expect(obj).to.respondTo('drawRoundedRect'); + expect(obj).to.respondTo('drawCircle'); + expect(obj).to.respondTo('drawEllipse'); + expect(obj).to.respondTo('clear'); + + expect(obj).to.have.property('renderable', true); + expect(obj).to.have.property('fillAlpha', 1); + expect(obj).to.have.property('lineWidth', 0); + expect(obj).to.have.property('width', 0); + expect(obj).to.have.property('height', 0); + expect(obj).to.have.property('lineColor', 0); + expect(obj).to.have.deep.property('graphicsData.length', 0); + // expect(obj).to.have.deep.property('currentPath.points.length', 0); + }); +}); diff --git a/test/unit/pixi-v2/renderers/canvas/CanvasGraphics.js b/test/unit/pixi-v2/renderers/canvas/CanvasGraphics.js new file mode 100644 index 0000000..8f44472 --- /dev/null +++ b/test/unit/pixi-v2/renderers/canvas/CanvasGraphics.js @@ -0,0 +1,15 @@ +describe('renders/canvas/CanvasGraphics', function () { + 'use strict'; + + var expect = chai.expect; + var CanvasGraphics = PIXI.CanvasGraphics; + + it('Module exists', function () { + expect(CanvasGraphics).to.be.a('function'); + }); + + it('Members exist', function () { + expect(CanvasGraphics).itself.to.respondTo('renderGraphics'); + expect(CanvasGraphics).itself.to.respondTo('renderGraphicsMask'); + }); +}); diff --git a/test/unit/pixi-v2/renderers/canvas/CanvasRenderer.js b/test/unit/pixi-v2/renderers/canvas/CanvasRenderer.js new file mode 100644 index 0000000..1646444 --- /dev/null +++ b/test/unit/pixi-v2/renderers/canvas/CanvasRenderer.js @@ -0,0 +1,36 @@ +describe('renderers/canvas/CanvasRenderer', function () { + 'use strict'; + + var expect = chai.expect; + var CanvasRenderer = PIXI.CanvasRenderer; + + it('Module exists', function () { + expect(CanvasRenderer).to.be.a('function'); + }); + + describe('.autoResize', function () { + it('Should automatically resize view if enabled', function () { + var renderer = new CanvasRenderer(200, 200, { + autoResize: true + }); + + expect(renderer.view.style.width).to.equal('200px'); + }); + + it('Should not automatically resize view if disabled', function () { + var renderer = new CanvasRenderer(200, 200, { + autoResize: false + }); + + expect(renderer.view.style.width).to.equal(''); + }); + + it('Should not automatically resize view if not specified', function () { + var renderer = new CanvasRenderer(200, 200, { + resolution: 2 + }); + + expect(renderer.view.style.width).to.equal(''); + }); + }); +}); diff --git a/test/unit/pixi-v2/renderers/webgl/WebGLGraphics.js b/test/unit/pixi-v2/renderers/webgl/WebGLGraphics.js new file mode 100644 index 0000000..5867b28 --- /dev/null +++ b/test/unit/pixi-v2/renderers/webgl/WebGLGraphics.js @@ -0,0 +1,20 @@ +describe('renderers/wegbl/WebGLGraphics', function () { + 'use strict'; + + var expect = chai.expect; + var WebGLGraphics = PIXI.WebGLGraphics; + + it('Module exists', function () { + expect(WebGLGraphics).to.be.a('function'); + }); + + it('Members exist', function () { + expect(WebGLGraphics).itself.to.respondTo('renderGraphics'); + expect(WebGLGraphics).itself.to.respondTo('updateGraphics'); + expect(WebGLGraphics).itself.to.respondTo('buildRectangle'); + expect(WebGLGraphics).itself.to.respondTo('buildRoundedRectangle'); + expect(WebGLGraphics).itself.to.respondTo('buildCircle'); + expect(WebGLGraphics).itself.to.respondTo('buildLine'); + expect(WebGLGraphics).itself.to.respondTo('buildPoly'); + }); +}); diff --git a/test/unit/pixi-v2/renderers/webgl/WebGLRenderer.js b/test/unit/pixi-v2/renderers/webgl/WebGLRenderer.js new file mode 100644 index 0000000..1680a80 --- /dev/null +++ b/test/unit/pixi-v2/renderers/webgl/WebGLRenderer.js @@ -0,0 +1,49 @@ +describe('renderers/webgl/WebGLRenderer', function () { + 'use strict'; + + var expect = chai.expect; + var WebGLRenderer = PIXI.WebGLRenderer; + + it('Module exists', function () { + expect(WebGLRenderer).to.be.a('function'); + }); + + // Skip tests if WebGL is not available (WebGL not supported in Travis CI) + try { + var renderer = new WebGLRenderer(400, 300, {}); + renderer.destroy(); + } catch (error) { + return; + } + + it('Destroy renderer', function () { + var renderer = new WebGLRenderer(400, 300, {}); + renderer.destroy(); + }); + + describe('.autoResize', function () { + it('Should automatically resize view if enabled', function () { + var renderer = new WebGLRenderer(200, 200, { + autoResize: true + }); + + expect(renderer.view.style.width).to.equal('200px'); + }); + + it('Should not automatically resize view if disabled', function () { + var renderer = new WebGLRenderer(200, 200, { + autoResize: false + }); + + expect(renderer.view.style.width).to.equal(''); + }); + + it('Should not automatically resize view if not specified', function () { + var renderer = new WebGLRenderer(200, 200, { + resolution: 2 + }); + + expect(renderer.view.style.width).to.equal(''); + }); + }); +}); diff --git a/test/unit/pixi-v2/renderers/webgl/WebGLShaders.js b/test/unit/pixi-v2/renderers/webgl/WebGLShaders.js new file mode 100644 index 0000000..6e33e4f --- /dev/null +++ b/test/unit/pixi-v2/renderers/webgl/WebGLShaders.js @@ -0,0 +1,13 @@ +describe('renderers/webgl/WebGLShaders', function () { + 'use strict'; + + var expect = chai.expect; + + it('Module members exist', function () { + + expect(PIXI).to.respondTo('CompileVertexShader'); + expect(PIXI).to.respondTo('CompileFragmentShader'); + expect(PIXI).to.respondTo('_CompileShader'); + expect(PIXI).to.respondTo('compileProgram'); + }); +}); diff --git a/test/unit/pixi-v2/renderers/webgl/WebGLSpriteBatch.js b/test/unit/pixi-v2/renderers/webgl/WebGLSpriteBatch.js new file mode 100644 index 0000000..e662b63 --- /dev/null +++ b/test/unit/pixi-v2/renderers/webgl/WebGLSpriteBatch.js @@ -0,0 +1,10 @@ +describe('renderers/webgl/utils/WebGLSpriteBatch', function () { + 'use strict'; + + var expect = chai.expect; + var WebGLSpriteBatch = PIXI.WebGLSpriteBatch; + + it('Module exists', function () { + expect(WebGLSpriteBatch).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/text/BitmapText.js b/test/unit/pixi-v2/text/BitmapText.js new file mode 100644 index 0000000..9388e3d --- /dev/null +++ b/test/unit/pixi-v2/text/BitmapText.js @@ -0,0 +1,10 @@ +describe('pixi/text/BitmapText', function () { + 'use strict'; + + var expect = chai.expect; + var BitmapText = PIXI.BitmapText; + + it('Module exists', function () { + expect(BitmapText).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/text/Text.js b/test/unit/pixi-v2/text/Text.js new file mode 100644 index 0000000..9bc9ac5 --- /dev/null +++ b/test/unit/pixi-v2/text/Text.js @@ -0,0 +1,10 @@ +describe('pixi/text/Text', function () { + 'use strict'; + + var expect = chai.expect; + var Text = PIXI.Text; + + it('Module exists', function () { + expect(Text).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/textures/BaseTexture.js b/test/unit/pixi-v2/textures/BaseTexture.js new file mode 100644 index 0000000..502b724 --- /dev/null +++ b/test/unit/pixi-v2/textures/BaseTexture.js @@ -0,0 +1,11 @@ +describe('pixi/textures/BaseTexture', function () { + 'use strict'; + + var expect = chai.expect; + var BaseTexture = PIXI.BaseTexture; + + it('Module exists', function () { + expect(BaseTexture).to.be.a('function'); + expect(PIXI).to.have.property('BaseTextureCache').and.to.be.an('object'); + }); +}); diff --git a/test/unit/pixi-v2/textures/RenderTexture.js b/test/unit/pixi-v2/textures/RenderTexture.js new file mode 100644 index 0000000..96acdb4 --- /dev/null +++ b/test/unit/pixi-v2/textures/RenderTexture.js @@ -0,0 +1,15 @@ +describe('pixi/textures/RenderTexture', function () { + 'use strict'; + + var expect = chai.expect; + var RenderTexture = PIXI.RenderTexture; + + it('Module exists', function () { + expect(RenderTexture).to.be.a('function'); + }); + + it('Confirm new instance', function (done) { + var texture = new RenderTexture(100, 100, new PIXI.CanvasRenderer()); + pixi_textures_RenderTexture_confirmNew(texture, done); + }); +}); diff --git a/test/unit/pixi-v2/textures/Texture.js b/test/unit/pixi-v2/textures/Texture.js new file mode 100644 index 0000000..090f64d --- /dev/null +++ b/test/unit/pixi-v2/textures/Texture.js @@ -0,0 +1,26 @@ +describe('pixi/textures/Texture', function () { + 'use strict'; + + var expect = chai.expect; + var Texture = PIXI.Texture; + + it('Module exists', function () { + expect(Texture).to.be.a('function'); + expect(PIXI).to.have.property('TextureCache').and.to.be.an('object'); + }); + + it('Members exist', function () { + expect(Texture).itself.to.respondTo('fromImage'); + expect(Texture).itself.to.respondTo('fromFrame'); + expect(Texture).itself.to.respondTo('fromCanvas'); + expect(Texture).itself.to.respondTo('addTextureToCache'); + expect(Texture).itself.to.respondTo('removeTextureFromCache'); + + // expect(Texture).itself.to.have.deep.property('frameUpdates.length', 0); + }); + + it('Confirm new instance', function (done) { + var texture = Texture.fromImage('/base/test/textures/bunny.png'); + pixi_textures_Texture_confirmNew(texture, done); + }); +}); diff --git a/test/unit/pixi-v2/utils/Detector.js b/test/unit/pixi-v2/utils/Detector.js new file mode 100644 index 0000000..4cf6008 --- /dev/null +++ b/test/unit/pixi-v2/utils/Detector.js @@ -0,0 +1,10 @@ +describe('pixi/utils/Detector', function () { + 'use strict'; + + var expect = chai.expect; + var autoDetectRenderer = PIXI.autoDetectRenderer; + + it('Module exists', function () { + expect(autoDetectRenderer).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/utils/EventTarget.js b/test/unit/pixi-v2/utils/EventTarget.js new file mode 100644 index 0000000..1cfc3a4 --- /dev/null +++ b/test/unit/pixi-v2/utils/EventTarget.js @@ -0,0 +1,361 @@ +describe('pixi/utils/EventTarget', function () { + 'use strict'; + + var expect = chai.expect; + + var Clazz, PClazz, obj, pobj, obj2; + beforeEach(function () { + Clazz = function () {}; + PClazz = function () {}; + + PIXI.EventTarget.mixin(Clazz.prototype); + PIXI.EventTarget.mixin(PClazz.prototype); + + obj = new Clazz(); + obj2 = new Clazz(); + pobj = new PClazz(); + + obj.parent = pobj; + obj2.parent = obj; + }); + + it('Module exists', function () { + expect(PIXI.EventTarget).to.be.an('object'); + }); + + it('Confirm new instance', function () { + pixi_utils_EventTarget_confirm(obj); + }); + + it('simple on/emit case works', function () { + var myData = {}; + + obj.on('myevent', function (event) { + pixi_utils_EventTarget_Event_confirm(event, obj, myData); + }); + + obj.emit('myevent', myData); + }); + + it('simple once case works', function () { + var called = 0; + + obj.once('myevent', function() { called++; }); + + obj.emit('myevent'); + obj.emit('myevent'); + obj.emit('myevent'); + obj.emit('myevent'); + obj.emit('myevent'); + + expect(called).to.equal(1); + }); + + it('simple off case works', function (done) { + function onMyEvent() { + done(new Error('Event listener should not have been called')); + } + + obj.on('myevent', onMyEvent); + obj.off('myevent', onMyEvent); + obj.emit('myevent'); + + done(); + }); + + it('simple propagation case works', function (done) { + var myData = {}; + + pobj.on('myevent', function () { + done(); + }); + + obj.emit('myevent'); + }); + + it('simple stopPropagation case works', function (done) { + var myData = {}; + + pobj.on('myevent', function () { + done(new Error('Event listener should not have been called on the parent element')); + }); + + obj.on('myevent', function (evt) { + evt.stopPropagation(); + }); + + obj.emit('myevent'); + + done(); + }); + + it('simple stopImmediatePropagation case works', function (done) { + var myData = {}; + + pobj.on('myevent', function () { + done(new Error('Event listener should not have been called on the parent')); + }); + + obj.on('myevent', function (evt) { + evt.stopImmediatePropagation(); + }); + + obj.on('myevent', function () { + done(new Error('Event listener should not have been called on the second')); + }); + + obj.emit('myevent'); + + done(); + }); + + it('multiple dispatches work properly', function () { + var called = 0; + + function onMyEvent() { + called++; + } + + obj.on('myevent', onMyEvent); + obj.emit('myevent'); + obj.emit('myevent'); + obj.emit('myevent'); + obj.emit('myevent'); + + expect(called).to.equal(4); + }); + + it('multiple events work properly', function () { + var called = 0; + + function onMyEvent() { + called++; + } + + obj.on('myevent1', onMyEvent); + obj.on('myevent2', onMyEvent); + obj.on('myevent3', onMyEvent); + obj.emit('myevent1'); + obj.emit('myevent2'); + obj.emit('myevent3'); + + expect(called).to.equal(3); + }); + + it('multiple events one removed works properly', function () { + var called = 0; + + function onMyEvent() { + called++; + } + + obj.on('myevent1', onMyEvent); + obj.on('myevent2', onMyEvent); + obj.on('myevent3', onMyEvent); + + obj.emit('myevent1'); + obj.emit('myevent2'); + obj.emit('myevent3'); + + obj.off('myevent2', onMyEvent); + + obj.emit('myevent1'); + obj.emit('myevent2'); + obj.emit('myevent3'); + + expect(called).to.equal(5); + }); + + it('multiple handlers for one event with some removed', function () { + var called = 0; + + var onMyEvent = function () { + called++; + }, + onMyEvent2 = function () { + called++; + }; + + // add 2 handlers and confirm they both get called + obj.on('myevent', onMyEvent); + obj.on('myevent', onMyEvent); + obj.on('myevent', onMyEvent2); + obj.on('myevent', onMyEvent2); + + obj.emit('myevent'); + + expect(called).to.equal(4); + + // remove one of the handlers, emit again, then ensure 1 more call is made + obj.off('myevent', onMyEvent); + + obj.emit('myevent'); + + expect(called).to.equal(6); + }); + + it('calls to off without a handler do nothing', function () { + var called = 0; + + var onMyEvent = function () { + called++; + }; + + obj.on('myevent', onMyEvent); + obj.on('myevent', onMyEvent); + + obj.emit('myevent'); + + expect(called).to.equal(2); + + obj.off('myevent'); + + obj.emit('myevent'); + + expect(called).to.equal(4); + + obj.off('myevent', onMyEvent); + + obj.emit('myevent'); + + expect(called).to.equal(4); + }); + + it('handles multiple instances with the same prototype', function () { + var called = 0; + + function onMyEvent(e) { + called++; + } + + obj.on('myevent1', onMyEvent); + obj.on('myevent2', onMyEvent); + + obj2.istwo = true; + obj2.on('myevent1', onMyEvent); + obj2.on('myevent2', onMyEvent); + + obj.emit('myevent1'); + obj.emit('myevent2'); + obj2.emit('myevent1'); + obj2.emit('myevent2'); + + //we emit 4 times, but since obj2 is a child of obj the event should bubble + //up to obj and show up there as well. So the obj2.emit() calls each increment + //the counter twice. + expect(called).to.equal(6); + }); + + it('is backwards compatible with older .dispatchEvent({})', function () { + var called = 0, + data = { + some: 'thing', + hello: true + }; + + function onMyEvent(event) { + pixi_utils_EventTarget_Event_confirm(event, obj, data); + + called++; + } + + obj.on('myevent1', onMyEvent); + obj.on('myevent2', onMyEvent); + obj.on('myevent3', onMyEvent); + + data.type = 'myevent1'; + obj.emit(data); + + data.type = 'myevent2'; + obj.emit(data); + + data.type = 'myevent3'; + obj.emit(data); + + obj.off('myevent2', onMyEvent); + + data.type = 'myevent1'; + obj.emit(data); + + data.type = 'myevent2'; + obj.emit(data); + + data.type = 'myevent3'; + obj.emit(data); + + expect(called).to.equal(5); + }); + + it('is backwards compatible with older .call(this)', function () { + var Fn = function() { + PIXI.EventTarget.call(this); + }, + o = new Fn(); + + pixi_utils_EventTarget_confirm(o); + }); + + it('is backwards compatible with older .addEventListener("")', function () { + var called = 0, + data = { + some: 'thing', + hello: true + }; + + function onMyEvent(event) { + pixi_utils_EventTarget_Event_confirm(event, obj, data); + + called++; + } + + obj.addEventListener('myevent1', onMyEvent); + obj.addEventListener('myevent2', onMyEvent); + obj.addEventListener('myevent3', onMyEvent); + + data.type = 'myevent1'; + obj.emit(data); + + data.type = 'myevent2'; + obj.emit(data); + + data.type = 'myevent3'; + obj.emit(data); + + obj.off('myevent2', onMyEvent); + + data.type = 'myevent1'; + obj.emit(data); + + data.type = 'myevent2'; + obj.emit(data); + + data.type = 'myevent3'; + obj.emit(data); + + expect(called).to.equal(5); + }); + + it('event remove during emit call properly', function () { + var called = 0; + + function cb1() { + called++; + obj.off('myevent', cb1); + } + function cb2() { + called++; + obj.off('myevent', cb2); + } + function cb3() { + called++; + obj.off('myevent', cb3); + } + + obj.on('myevent', cb1); + obj.on('myevent', cb2); + obj.on('myevent', cb3); + obj.emit('myevent', ''); + + expect(called).to.equal(3); + }); +}); diff --git a/test/unit/pixi-v2/utils/Polyk.js b/test/unit/pixi-v2/utils/Polyk.js new file mode 100644 index 0000000..dfc7128 --- /dev/null +++ b/test/unit/pixi-v2/utils/Polyk.js @@ -0,0 +1,14 @@ +describe('pixi/utils/Polyk', function () { + 'use strict'; + + var expect = chai.expect; + var PolyK = PIXI.PolyK; + + it('Module exists', function () { + expect(PolyK).to.be.an('object'); + }); + + it('Members exist', function () { + expect(PolyK).to.respondTo('Triangulate'); + }); +}); diff --git a/test/unit/pixi-v2/utils/Utils.js b/test/unit/pixi-v2/utils/Utils.js new file mode 100644 index 0000000..c97b3c6 --- /dev/null +++ b/test/unit/pixi-v2/utils/Utils.js @@ -0,0 +1,17 @@ +describe('Utils', function () { + 'use strict'; + + var expect = chai.expect; + + it('requestAnimationFrame exists', function () { + expect(global).to.respondTo('requestAnimationFrame'); + }); + + it('cancelAnimationFrame exists', function () { + expect(global).to.respondTo('cancelAnimationFrame'); + }); + + it('requestAnimFrame exists', function () { + expect(global).to.respondTo('requestAnimFrame'); + }); +}); diff --git a/test/unit/pixi/InteractionManager.js b/test/unit/pixi/InteractionManager.js deleted file mode 100644 index ed3001f..0000000 --- a/test/unit/pixi/InteractionManager.js +++ /dev/null @@ -1,10 +0,0 @@ -describe('pixi/InteractionManager', function () { - 'use strict'; - - var expect = chai.expect; - var InteractionManager = PIXI.InteractionManager; - - it('Module exists', function () { - expect(InteractionManager).to.be.a('function'); - }); -}); diff --git a/test/unit/pixi/Pixi.js b/test/unit/pixi/Pixi.js deleted file mode 100644 index 27debc1..0000000 --- a/test/unit/pixi/Pixi.js +++ /dev/null @@ -1,9 +0,0 @@ -describe('pixi/Pixi', function () { - 'use strict'; - - var expect = chai.expect; - - it('Module exists', function () { - expect(global).to.have.property('PIXI').and.to.be.an('object'); - }); -}); diff --git a/test/unit/pixi/core/Circle.js b/test/unit/pixi/core/Circle.js deleted file mode 100644 index fbcfa17..0000000 --- a/test/unit/pixi/core/Circle.js +++ /dev/null @@ -1,21 +0,0 @@ -describe('pixi/core/Circle', function () { - 'use strict'; - - var expect = chai.expect; - var Circle = PIXI.Circle; - - it('Module exists', function () { - expect(Circle).to.be.a('function'); - }); - - it('Confirm new instance', function () { - var obj = new Circle(); - pixi_core_Circle_confirmNewCircle(obj); - }); - - it("getBounds should return Rectangle that bounds the circle", function() { - var obj = new Circle(100, 250, 50); - var bounds = obj.getBounds(); - pixi_core_Circle_isBoundedByRectangle(obj, bounds); - }); -}); diff --git a/test/unit/pixi/core/Ellipse.js b/test/unit/pixi/core/Ellipse.js deleted file mode 100644 index 026b56f..0000000 --- a/test/unit/pixi/core/Ellipse.js +++ /dev/null @@ -1,24 +0,0 @@ -describe('pixi/core/Ellipse', function () { - 'use strict'; - - var expect = chai.expect; - var Ellipse = PIXI.Ellipse; - - it('Module exists', function () { - expect(Ellipse).to.be.a('function'); - }); - - it('Confirm new instance', function () { - var obj = new Ellipse(); - - expect(obj).to.be.an.instanceof(Ellipse); - expect(obj).to.respondTo('clone'); - expect(obj).to.respondTo('contains'); - expect(obj).to.respondTo('getBounds'); - - expect(obj).to.have.property('x', 0); - expect(obj).to.have.property('y', 0); - expect(obj).to.have.property('width', 0); - expect(obj).to.have.property('height', 0); - }); -}); diff --git a/test/unit/pixi/core/Matrix.js b/test/unit/pixi/core/Matrix.js deleted file mode 100644 index da75e2e..0000000 --- a/test/unit/pixi/core/Matrix.js +++ /dev/null @@ -1,14 +0,0 @@ -describe('pixi/core/Matrix', function () { - 'use strict'; - - var expect = chai.expect; - - it('Matrix exists', function () { - expect(PIXI.Matrix).to.be.an('function'); - }); - - it('Confirm new Matrix', function () { - var matrix = new PIXI.Matrix(); - pixi_core_Matrix_confirmNewMatrix(matrix); - }); -}); diff --git a/test/unit/pixi/core/Point.js b/test/unit/pixi/core/Point.js deleted file mode 100644 index c4d5163..0000000 --- a/test/unit/pixi/core/Point.js +++ /dev/null @@ -1,15 +0,0 @@ -describe('pixi/core/Point', function () { - 'use strict'; - - var expect = chai.expect; - var Point = PIXI.Point; - - it('Module exists', function () { - expect(Point).to.be.a('function'); - }); - - it('Confirm new instance', function () { - var obj = new Point(); - pixi_core_Point_confirm(obj, 0, 0); - }); -}); diff --git a/test/unit/pixi/core/Polygon.js b/test/unit/pixi/core/Polygon.js deleted file mode 100644 index dc8c918..0000000 --- a/test/unit/pixi/core/Polygon.js +++ /dev/null @@ -1,20 +0,0 @@ -describe('pixi/core/Polygon', function () { - 'use strict'; - - var expect = chai.expect; - var Polygon = PIXI.Polygon; - - it('Module exists', function () { - expect(Polygon).to.be.a('function'); - }); - - it('Confirm new instance', function () { - var obj = new Polygon(); - - expect(obj).to.be.an.instanceof(Polygon); - expect(obj).to.respondTo('clone'); - expect(obj).to.respondTo('contains'); - - expect(obj).to.have.deep.property('points.length', 0); - }); -}); diff --git a/test/unit/pixi/core/Rectangle.js b/test/unit/pixi/core/Rectangle.js deleted file mode 100644 index d43316e..0000000 --- a/test/unit/pixi/core/Rectangle.js +++ /dev/null @@ -1,15 +0,0 @@ -describe('pixi/core/Rectangle', function () { - 'use strict'; - - var expect = chai.expect; - var Rectangle = PIXI.Rectangle; - - it('Module exists', function () { - expect(Rectangle).to.be.a('function'); - }); - - it('Confirm new instance', function () { - var rect = new Rectangle(); - pixi_core_Rectangle_confirm(rect, 0, 0, 0, 0); - }); -}); diff --git a/test/unit/pixi/display/DisplayObject.js b/test/unit/pixi/display/DisplayObject.js deleted file mode 100644 index 044acf8..0000000 --- a/test/unit/pixi/display/DisplayObject.js +++ /dev/null @@ -1,21 +0,0 @@ -describe('pixi/display/DisplayObject', function () { - 'use strict'; - - var expect = chai.expect; - var DisplayObject = PIXI.DisplayObject; - - it('Module exists', function () { - expect(DisplayObject).to.be.a('function'); - // expect(PIXI).to.have.property('visibleCount', 0); - }); - - it('Confirm new instance', function () { - var obj = new DisplayObject(); - - pixi_display_DisplayObject_confirmNew(obj); - expect(obj).to.have.property('hitArea', null); - expect(obj).to.have.property('interactive', false); - expect(obj).to.have.property('renderable', false); - expect(obj).to.have.property('stage', null); - }); -}); diff --git a/test/unit/pixi/display/DisplayObjectContainer.js b/test/unit/pixi/display/DisplayObjectContainer.js deleted file mode 100644 index 15a3376..0000000 --- a/test/unit/pixi/display/DisplayObjectContainer.js +++ /dev/null @@ -1,67 +0,0 @@ -describe('pixi/display/DisplayObjectContainer', function () { - 'use strict'; - - var expect = chai.expect; - var DisplayObjectContainer = PIXI.DisplayObjectContainer; - - it('Module exists', function () { - expect(DisplayObjectContainer).to.be.a('function'); - }); - - it('Confirm new instance', function () { - var obj = new DisplayObjectContainer(); - - pixi_display_DisplayObjectContainer_confirmNew(obj); - expect(obj).to.have.property('hitArea', null); - expect(obj).to.have.property('interactive', false); - expect(obj).to.have.property('renderable', false); - expect(obj).to.have.property('stage', null); - }); - - it('Gets child index', function() { - var container = new PIXI.DisplayObjectContainer(); - var children = []; - for (var i = 0; i < 10; i++) { - var child = new PIXI.DisplayObject(); - children.push(child); - container.addChild(child); - } - - for (i = 0; i < children.length; i++) { - expect(i).to.eql(container.getChildIndex(children[i])); - } - }); - - it('throws error when trying to get index of not a child', function() { - var container = new PIXI.DisplayObjectContainer(); - var child = new PIXI.DisplayObject(); - - expect(function() { container.getChildIndex(child); }).to.throw(); - }); - - it('Sets child index', function() { - var container = new PIXI.DisplayObjectContainer(); - var children = []; - - for (var i = 0; i < 10; i++) { - var child = new PIXI.DisplayObject(); - children.push(child); - container.addChild(child); - } - children.reverse(); - - for (i = 0; i < children.length; i++) { - container.setChildIndex(children[i], i); - expect(i).to.eql(container.getChildIndex(children[i])); - } - }); - - it('throws error when trying to set incorect index', function() { - var container = new PIXI.DisplayObjectContainer(); - var child = new PIXI.DisplayObject(); - container.addChild(child); - - expect(function() { container.setChildIndex(child, -1); }).to.throw(); - expect(function() { container.setChildIndex(child, 1); }).to.throw(); - }); -}); diff --git a/test/unit/pixi/display/MovieClip.js b/test/unit/pixi/display/MovieClip.js deleted file mode 100644 index f3c6c6a..0000000 --- a/test/unit/pixi/display/MovieClip.js +++ /dev/null @@ -1,33 +0,0 @@ -describe('pixi/display/MovieClip', function () { - 'use strict'; - - var expect = chai.expect; - var MovieClip = PIXI.MovieClip; - var Texture = PIXI.Texture; - - it('Module exists', function () { - expect(MovieClip).to.be.a('function'); - }); - - it('Confirm new instance', function (done) { - var texture = Texture.fromImage('/base/test/textures/SpriteSheet-Explosion.png'); - var obj = new MovieClip([texture]); - - pixi_display_Sprite_confirmNew(obj, done); - - expect(obj).to.be.an.instanceof(MovieClip); - expect(obj).to.respondTo('stop'); - expect(obj).to.respondTo('play'); - expect(obj).to.respondTo('gotoAndStop'); - expect(obj).to.respondTo('gotoAndPlay'); - expect(obj).to.respondTo('updateTransform'); - - expect(obj).to.have.deep.property('textures.length', 1); - expect(obj).to.have.deep.property('textures[0]', texture); - expect(obj).to.have.property('animationSpeed', 1); - expect(obj).to.have.property('loop', true); - expect(obj).to.have.property('onComplete', null); - expect(obj).to.have.property('currentFrame', 0); - expect(obj).to.have.property('playing', false); - }); -}); diff --git a/test/unit/pixi-v2/InteractionManager.js b/test/unit/pixi-v2/InteractionManager.js new file mode 100644 index 0000000..ed3001f --- /dev/null +++ b/test/unit/pixi-v2/InteractionManager.js @@ -0,0 +1,10 @@ +describe('pixi/InteractionManager', function () { + 'use strict'; + + var expect = chai.expect; + var InteractionManager = PIXI.InteractionManager; + + it('Module exists', function () { + expect(InteractionManager).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/Pixi.js b/test/unit/pixi-v2/Pixi.js new file mode 100644 index 0000000..27debc1 --- /dev/null +++ b/test/unit/pixi-v2/Pixi.js @@ -0,0 +1,9 @@ +describe('pixi/Pixi', function () { + 'use strict'; + + var expect = chai.expect; + + it('Module exists', function () { + expect(global).to.have.property('PIXI').and.to.be.an('object'); + }); +}); diff --git a/test/unit/pixi-v2/core/Circle.js b/test/unit/pixi-v2/core/Circle.js new file mode 100644 index 0000000..fbcfa17 --- /dev/null +++ b/test/unit/pixi-v2/core/Circle.js @@ -0,0 +1,21 @@ +describe('pixi/core/Circle', function () { + 'use strict'; + + var expect = chai.expect; + var Circle = PIXI.Circle; + + it('Module exists', function () { + expect(Circle).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Circle(); + pixi_core_Circle_confirmNewCircle(obj); + }); + + it("getBounds should return Rectangle that bounds the circle", function() { + var obj = new Circle(100, 250, 50); + var bounds = obj.getBounds(); + pixi_core_Circle_isBoundedByRectangle(obj, bounds); + }); +}); diff --git a/test/unit/pixi-v2/core/Ellipse.js b/test/unit/pixi-v2/core/Ellipse.js new file mode 100644 index 0000000..026b56f --- /dev/null +++ b/test/unit/pixi-v2/core/Ellipse.js @@ -0,0 +1,24 @@ +describe('pixi/core/Ellipse', function () { + 'use strict'; + + var expect = chai.expect; + var Ellipse = PIXI.Ellipse; + + it('Module exists', function () { + expect(Ellipse).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Ellipse(); + + expect(obj).to.be.an.instanceof(Ellipse); + expect(obj).to.respondTo('clone'); + expect(obj).to.respondTo('contains'); + expect(obj).to.respondTo('getBounds'); + + expect(obj).to.have.property('x', 0); + expect(obj).to.have.property('y', 0); + expect(obj).to.have.property('width', 0); + expect(obj).to.have.property('height', 0); + }); +}); diff --git a/test/unit/pixi-v2/core/Matrix.js b/test/unit/pixi-v2/core/Matrix.js new file mode 100644 index 0000000..da75e2e --- /dev/null +++ b/test/unit/pixi-v2/core/Matrix.js @@ -0,0 +1,14 @@ +describe('pixi/core/Matrix', function () { + 'use strict'; + + var expect = chai.expect; + + it('Matrix exists', function () { + expect(PIXI.Matrix).to.be.an('function'); + }); + + it('Confirm new Matrix', function () { + var matrix = new PIXI.Matrix(); + pixi_core_Matrix_confirmNewMatrix(matrix); + }); +}); diff --git a/test/unit/pixi-v2/core/Point.js b/test/unit/pixi-v2/core/Point.js new file mode 100644 index 0000000..c4d5163 --- /dev/null +++ b/test/unit/pixi-v2/core/Point.js @@ -0,0 +1,15 @@ +describe('pixi/core/Point', function () { + 'use strict'; + + var expect = chai.expect; + var Point = PIXI.Point; + + it('Module exists', function () { + expect(Point).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Point(); + pixi_core_Point_confirm(obj, 0, 0); + }); +}); diff --git a/test/unit/pixi-v2/core/Polygon.js b/test/unit/pixi-v2/core/Polygon.js new file mode 100644 index 0000000..dc8c918 --- /dev/null +++ b/test/unit/pixi-v2/core/Polygon.js @@ -0,0 +1,20 @@ +describe('pixi/core/Polygon', function () { + 'use strict'; + + var expect = chai.expect; + var Polygon = PIXI.Polygon; + + it('Module exists', function () { + expect(Polygon).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Polygon(); + + expect(obj).to.be.an.instanceof(Polygon); + expect(obj).to.respondTo('clone'); + expect(obj).to.respondTo('contains'); + + expect(obj).to.have.deep.property('points.length', 0); + }); +}); diff --git a/test/unit/pixi-v2/core/Rectangle.js b/test/unit/pixi-v2/core/Rectangle.js new file mode 100644 index 0000000..d43316e --- /dev/null +++ b/test/unit/pixi-v2/core/Rectangle.js @@ -0,0 +1,15 @@ +describe('pixi/core/Rectangle', function () { + 'use strict'; + + var expect = chai.expect; + var Rectangle = PIXI.Rectangle; + + it('Module exists', function () { + expect(Rectangle).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var rect = new Rectangle(); + pixi_core_Rectangle_confirm(rect, 0, 0, 0, 0); + }); +}); diff --git a/test/unit/pixi-v2/display/DisplayObject.js b/test/unit/pixi-v2/display/DisplayObject.js new file mode 100644 index 0000000..044acf8 --- /dev/null +++ b/test/unit/pixi-v2/display/DisplayObject.js @@ -0,0 +1,21 @@ +describe('pixi/display/DisplayObject', function () { + 'use strict'; + + var expect = chai.expect; + var DisplayObject = PIXI.DisplayObject; + + it('Module exists', function () { + expect(DisplayObject).to.be.a('function'); + // expect(PIXI).to.have.property('visibleCount', 0); + }); + + it('Confirm new instance', function () { + var obj = new DisplayObject(); + + pixi_display_DisplayObject_confirmNew(obj); + expect(obj).to.have.property('hitArea', null); + expect(obj).to.have.property('interactive', false); + expect(obj).to.have.property('renderable', false); + expect(obj).to.have.property('stage', null); + }); +}); diff --git a/test/unit/pixi-v2/display/DisplayObjectContainer.js b/test/unit/pixi-v2/display/DisplayObjectContainer.js new file mode 100644 index 0000000..15a3376 --- /dev/null +++ b/test/unit/pixi-v2/display/DisplayObjectContainer.js @@ -0,0 +1,67 @@ +describe('pixi/display/DisplayObjectContainer', function () { + 'use strict'; + + var expect = chai.expect; + var DisplayObjectContainer = PIXI.DisplayObjectContainer; + + it('Module exists', function () { + expect(DisplayObjectContainer).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new DisplayObjectContainer(); + + pixi_display_DisplayObjectContainer_confirmNew(obj); + expect(obj).to.have.property('hitArea', null); + expect(obj).to.have.property('interactive', false); + expect(obj).to.have.property('renderable', false); + expect(obj).to.have.property('stage', null); + }); + + it('Gets child index', function() { + var container = new PIXI.DisplayObjectContainer(); + var children = []; + for (var i = 0; i < 10; i++) { + var child = new PIXI.DisplayObject(); + children.push(child); + container.addChild(child); + } + + for (i = 0; i < children.length; i++) { + expect(i).to.eql(container.getChildIndex(children[i])); + } + }); + + it('throws error when trying to get index of not a child', function() { + var container = new PIXI.DisplayObjectContainer(); + var child = new PIXI.DisplayObject(); + + expect(function() { container.getChildIndex(child); }).to.throw(); + }); + + it('Sets child index', function() { + var container = new PIXI.DisplayObjectContainer(); + var children = []; + + for (var i = 0; i < 10; i++) { + var child = new PIXI.DisplayObject(); + children.push(child); + container.addChild(child); + } + children.reverse(); + + for (i = 0; i < children.length; i++) { + container.setChildIndex(children[i], i); + expect(i).to.eql(container.getChildIndex(children[i])); + } + }); + + it('throws error when trying to set incorect index', function() { + var container = new PIXI.DisplayObjectContainer(); + var child = new PIXI.DisplayObject(); + container.addChild(child); + + expect(function() { container.setChildIndex(child, -1); }).to.throw(); + expect(function() { container.setChildIndex(child, 1); }).to.throw(); + }); +}); diff --git a/test/unit/pixi-v2/display/MovieClip.js b/test/unit/pixi-v2/display/MovieClip.js new file mode 100644 index 0000000..f3c6c6a --- /dev/null +++ b/test/unit/pixi-v2/display/MovieClip.js @@ -0,0 +1,33 @@ +describe('pixi/display/MovieClip', function () { + 'use strict'; + + var expect = chai.expect; + var MovieClip = PIXI.MovieClip; + var Texture = PIXI.Texture; + + it('Module exists', function () { + expect(MovieClip).to.be.a('function'); + }); + + it('Confirm new instance', function (done) { + var texture = Texture.fromImage('/base/test/textures/SpriteSheet-Explosion.png'); + var obj = new MovieClip([texture]); + + pixi_display_Sprite_confirmNew(obj, done); + + expect(obj).to.be.an.instanceof(MovieClip); + expect(obj).to.respondTo('stop'); + expect(obj).to.respondTo('play'); + expect(obj).to.respondTo('gotoAndStop'); + expect(obj).to.respondTo('gotoAndPlay'); + expect(obj).to.respondTo('updateTransform'); + + expect(obj).to.have.deep.property('textures.length', 1); + expect(obj).to.have.deep.property('textures[0]', texture); + expect(obj).to.have.property('animationSpeed', 1); + expect(obj).to.have.property('loop', true); + expect(obj).to.have.property('onComplete', null); + expect(obj).to.have.property('currentFrame', 0); + expect(obj).to.have.property('playing', false); + }); +}); diff --git a/test/unit/pixi-v2/display/Sprite.js b/test/unit/pixi-v2/display/Sprite.js new file mode 100644 index 0000000..30c8076 --- /dev/null +++ b/test/unit/pixi-v2/display/Sprite.js @@ -0,0 +1,28 @@ +describe('pixi/display/Sprite', function () { + 'use strict'; + + var expect = chai.expect; + var Sprite = PIXI.Sprite; + var Texture = PIXI.Texture; + + it('Module exists', function () { + expect(Sprite).to.be.a('function'); + expect(PIXI).to.have.deep.property('blendModes.NORMAL', 0); + expect(PIXI).to.have.deep.property('blendModes.ADD', 1); + expect(PIXI).to.have.deep.property('blendModes.MULTIPLY', 2); + expect(PIXI).to.have.deep.property('blendModes.SCREEN', 3); + }); + + + it('Members exist', function () { + expect(Sprite).itself.to.respondTo('fromImage'); + expect(Sprite).itself.to.respondTo('fromFrame'); + }); + + it('Confirm new instance', function (done) { + var texture = Texture.fromImage('/base/test/textures/SpriteSheet-Aliens.png'); + var obj = new Sprite(texture); + + pixi_display_Sprite_confirmNew(obj, done); + }); +}); diff --git a/test/unit/pixi-v2/display/Stage.js b/test/unit/pixi-v2/display/Stage.js new file mode 100644 index 0000000..6974c2e --- /dev/null +++ b/test/unit/pixi-v2/display/Stage.js @@ -0,0 +1,49 @@ +describe('pixi/display/Stage', function () { + 'use strict'; + + var expect = chai.expect; + var Stage = PIXI.Stage; + var InteractionManager = PIXI.InteractionManager; + var Rectangle = PIXI.Rectangle; + + it('Module exists', function () { + expect(Stage).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Stage(null, true); + + pixi_display_DisplayObjectContainer_confirmNew(obj); + + expect(obj).to.be.an.instanceof(Stage); + expect(obj).to.respondTo('updateTransform'); + expect(obj).to.respondTo('setBackgroundColor'); + expect(obj).to.respondTo('getMousePosition'); + // FIXME: duplicate member in DisplayObject + pixi_core_Matrix_confirmNewMatrix(obj.worldTransform); + // FIXME: convert arg to bool in constructor + expect(obj).to.have.property('interactive', true); + + expect(obj).to.have.property('interactionManager') + .and.to.be.an.instanceof(InteractionManager) + .and.to.have.property('stage', obj); + + expect(obj).to.have.property('dirty', true); + + expect(obj).to.have.property('stage', obj); + + expect(obj).to.have.property('hitArea') + .and.to.be.an.instanceof(Rectangle); + pixi_core_Rectangle_confirm(obj.hitArea, 0, 0, 100000, 100000); + + expect(obj).to.have.property('backgroundColor', 0x000000); + expect(obj).to.have.deep.property('backgroundColorSplit.length', 3); + expect(obj).to.have.deep.property('backgroundColorSplit[0]', 0); + expect(obj).to.have.deep.property('backgroundColorSplit[1]', 0); + expect(obj).to.have.deep.property('backgroundColorSplit[2]', 0); + expect(obj).to.have.property('backgroundColorString', '#000000'); + + + expect(obj).to.have.property('worldVisible', true); + }); +}); diff --git a/test/unit/pixi-v2/extras/Rope.js b/test/unit/pixi-v2/extras/Rope.js new file mode 100644 index 0000000..05885ac --- /dev/null +++ b/test/unit/pixi-v2/extras/Rope.js @@ -0,0 +1,31 @@ +describe('pixi/extras/Rope', function () { + 'use strict'; + + var expect = chai.expect; + var Rope = PIXI.Rope; + var Texture = PIXI.Texture; + var Point = PIXI.Point; + + it('Module exists', function () { + expect(Rope).to.be.a('function'); + }); + + it('Confirm new instance', function () { + + var texture = Texture.fromImage('/base/test/textures/bunny.png'); + + // TODO-Alvin + // Same as Strip + + // var obj = new Rope(texture, [new Point(), new Point(5, 10), new Point(10, 20)]); + + // pixi_extras_Strip_confirmNew(obj); + + // expect(obj).to.be.an.instanceof(Rope); + // expect(obj).to.respondTo('refresh'); + // expect(obj).to.respondTo('updateTransform'); + // expect(obj).to.respondTo('setTexture'); + + // TODO: Test properties + }); +}); diff --git a/test/unit/pixi-v2/extras/Spine.js b/test/unit/pixi-v2/extras/Spine.js new file mode 100644 index 0000000..0708bc0 --- /dev/null +++ b/test/unit/pixi-v2/extras/Spine.js @@ -0,0 +1,10 @@ +describe('pixi/extras/Spine', function () { + 'use strict'; + + var expect = chai.expect; + var Spine = PIXI.Spine; + + it('Module exists', function () { + expect(Spine).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/extras/Strip.js b/test/unit/pixi-v2/extras/Strip.js new file mode 100644 index 0000000..230af90 --- /dev/null +++ b/test/unit/pixi-v2/extras/Strip.js @@ -0,0 +1,26 @@ +describe('pixi/extras/Strip', function () { + 'use strict'; + + var expect = chai.expect; + var Strip = PIXI.Strip; + var Texture = PIXI.Texture; + + it('Module exists', function () { + expect(Strip).to.be.a('function'); + }); + + it('Confirm new instance', function () { + + + // TODO-Alvin + // We tweaked it to make it pass the tests, but the whole strip class needs + // to be re-coded + + var texture = Texture.fromImage('/base/test/textures/bunny.png'); + + // var obj = new Strip(texture, 20, 10000); + + + // pixi_extras_Strip_confirmNew(obj); + }); +}); diff --git a/test/unit/pixi-v2/extras/TilingSprite.js b/test/unit/pixi-v2/extras/TilingSprite.js new file mode 100644 index 0000000..56aea14 --- /dev/null +++ b/test/unit/pixi-v2/extras/TilingSprite.js @@ -0,0 +1,24 @@ +describe('pixi/extras/TilingSprite', function () { + 'use strict'; + + var expect = chai.expect; + var TilingSprite = PIXI.TilingSprite; + var Texture = PIXI.Texture; + + it('Module exists', function () { + expect(TilingSprite).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var texture = Texture.fromImage('/base/test/textures/bunny.png'); + var obj = new TilingSprite(texture, 6000, 12000); + + pixi_display_DisplayObjectContainer_confirmNew(obj); + + expect(obj).to.be.an.instanceof(TilingSprite); + expect(obj).to.respondTo('setTexture'); + expect(obj).to.respondTo('onTextureUpdate'); + + // TODO: Test properties + }); +}); diff --git a/test/unit/pixi-v2/filters/FilterBlock.js b/test/unit/pixi-v2/filters/FilterBlock.js new file mode 100644 index 0000000..870cec0 --- /dev/null +++ b/test/unit/pixi-v2/filters/FilterBlock.js @@ -0,0 +1,10 @@ +describe('pixi/filters/FilterBlock', function () { + 'use strict'; + + var expect = chai.expect; + var FilterBlock = PIXI.FilterBlock; + + it('Module exists', function () { + expect(FilterBlock).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/AssetLoader.js b/test/unit/pixi-v2/loaders/AssetLoader.js new file mode 100644 index 0000000..a0aa0b5 --- /dev/null +++ b/test/unit/pixi-v2/loaders/AssetLoader.js @@ -0,0 +1,10 @@ +describe('pixi/loaders/AssetLoader', function () { + 'use strict'; + + var expect = chai.expect; + var AssetLoader = PIXI.AssetLoader; + + it('Module exists', function () { + expect(AssetLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/BitmapFontLoader.js b/test/unit/pixi-v2/loaders/BitmapFontLoader.js new file mode 100644 index 0000000..046f018 --- /dev/null +++ b/test/unit/pixi-v2/loaders/BitmapFontLoader.js @@ -0,0 +1,9 @@ +describe('pixi/loaders/BitmapFontLoader', function () { + 'use strict'; + + var expect = chai.expect; + + it('Module exists', function () { + expect(PIXI.BitmapFontLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/ImageLoader.js b/test/unit/pixi-v2/loaders/ImageLoader.js new file mode 100644 index 0000000..8b1f556 --- /dev/null +++ b/test/unit/pixi-v2/loaders/ImageLoader.js @@ -0,0 +1,10 @@ +describe('pixi/loaders/ImageLoader', function () { + 'use strict'; + + var expect = chai.expect; + var ImageLoader = PIXI.ImageLoader; + + it('Module exists', function () { + expect(ImageLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/JsonLoader.js b/test/unit/pixi-v2/loaders/JsonLoader.js new file mode 100644 index 0000000..c577e83 --- /dev/null +++ b/test/unit/pixi-v2/loaders/JsonLoader.js @@ -0,0 +1,10 @@ +describe('pixi/loaders/JsonLoader', function () { + 'use strict'; + + var expect = chai.expect; + var JsonLoader = PIXI.JsonLoader; + + it('Module exists', function () { + expect(JsonLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/SpineLoader.js b/test/unit/pixi-v2/loaders/SpineLoader.js new file mode 100644 index 0000000..fdcc0b8 --- /dev/null +++ b/test/unit/pixi-v2/loaders/SpineLoader.js @@ -0,0 +1,10 @@ +describe('pixi/loaders/SpineLoader', function () { + 'use strict'; + + var expect = chai.expect; + var SpineLoader = PIXI.SpineLoader; + + it('Module exists', function () { + expect(SpineLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/SpriteSheetLoader.js b/test/unit/pixi-v2/loaders/SpriteSheetLoader.js new file mode 100644 index 0000000..57beb27 --- /dev/null +++ b/test/unit/pixi-v2/loaders/SpriteSheetLoader.js @@ -0,0 +1,10 @@ +describe('pixi/loaders/SpriteSheetLoader', function () { + 'use strict'; + + var expect = chai.expect; + var SpriteSheetLoader = PIXI.SpriteSheetLoader; + + it('Module exists', function () { + expect(SpriteSheetLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/primitives/Graphics.js b/test/unit/pixi-v2/primitives/Graphics.js new file mode 100644 index 0000000..f3849eb --- /dev/null +++ b/test/unit/pixi-v2/primitives/Graphics.js @@ -0,0 +1,44 @@ +describe('pixi/primitives/Graphics', function () { + 'use strict'; + + var expect = chai.expect; + var Graphics = PIXI.Graphics; + + it('Module exists', function () { + expect(Graphics).to.be.a('function'); + + expect(Graphics).itself.to.have.property('POLY', 0); + expect(Graphics).itself.to.have.property('RECT', 1); + expect(Graphics).itself.to.have.property('CIRC', 2); + expect(Graphics).itself.to.have.property('ELIP', 3); + expect(Graphics).itself.to.have.property('RREC', 4); + }); + + it('Confirm new instance', function () { + var obj = new Graphics(); + + pixi_display_DisplayObjectContainer_confirmNew(obj); + + expect(obj).to.be.an.instanceof(Graphics); + expect(obj).to.respondTo('lineStyle'); + expect(obj).to.respondTo('lineStyle'); + expect(obj).to.respondTo('moveTo'); + expect(obj).to.respondTo('lineTo'); + expect(obj).to.respondTo('beginFill'); + expect(obj).to.respondTo('endFill'); + expect(obj).to.respondTo('drawRect'); + // expect(obj).to.respondTo('drawRoundedRect'); + expect(obj).to.respondTo('drawCircle'); + expect(obj).to.respondTo('drawEllipse'); + expect(obj).to.respondTo('clear'); + + expect(obj).to.have.property('renderable', true); + expect(obj).to.have.property('fillAlpha', 1); + expect(obj).to.have.property('lineWidth', 0); + expect(obj).to.have.property('width', 0); + expect(obj).to.have.property('height', 0); + expect(obj).to.have.property('lineColor', 0); + expect(obj).to.have.deep.property('graphicsData.length', 0); + // expect(obj).to.have.deep.property('currentPath.points.length', 0); + }); +}); diff --git a/test/unit/pixi-v2/renderers/canvas/CanvasGraphics.js b/test/unit/pixi-v2/renderers/canvas/CanvasGraphics.js new file mode 100644 index 0000000..8f44472 --- /dev/null +++ b/test/unit/pixi-v2/renderers/canvas/CanvasGraphics.js @@ -0,0 +1,15 @@ +describe('renders/canvas/CanvasGraphics', function () { + 'use strict'; + + var expect = chai.expect; + var CanvasGraphics = PIXI.CanvasGraphics; + + it('Module exists', function () { + expect(CanvasGraphics).to.be.a('function'); + }); + + it('Members exist', function () { + expect(CanvasGraphics).itself.to.respondTo('renderGraphics'); + expect(CanvasGraphics).itself.to.respondTo('renderGraphicsMask'); + }); +}); diff --git a/test/unit/pixi-v2/renderers/canvas/CanvasRenderer.js b/test/unit/pixi-v2/renderers/canvas/CanvasRenderer.js new file mode 100644 index 0000000..1646444 --- /dev/null +++ b/test/unit/pixi-v2/renderers/canvas/CanvasRenderer.js @@ -0,0 +1,36 @@ +describe('renderers/canvas/CanvasRenderer', function () { + 'use strict'; + + var expect = chai.expect; + var CanvasRenderer = PIXI.CanvasRenderer; + + it('Module exists', function () { + expect(CanvasRenderer).to.be.a('function'); + }); + + describe('.autoResize', function () { + it('Should automatically resize view if enabled', function () { + var renderer = new CanvasRenderer(200, 200, { + autoResize: true + }); + + expect(renderer.view.style.width).to.equal('200px'); + }); + + it('Should not automatically resize view if disabled', function () { + var renderer = new CanvasRenderer(200, 200, { + autoResize: false + }); + + expect(renderer.view.style.width).to.equal(''); + }); + + it('Should not automatically resize view if not specified', function () { + var renderer = new CanvasRenderer(200, 200, { + resolution: 2 + }); + + expect(renderer.view.style.width).to.equal(''); + }); + }); +}); diff --git a/test/unit/pixi-v2/renderers/webgl/WebGLGraphics.js b/test/unit/pixi-v2/renderers/webgl/WebGLGraphics.js new file mode 100644 index 0000000..5867b28 --- /dev/null +++ b/test/unit/pixi-v2/renderers/webgl/WebGLGraphics.js @@ -0,0 +1,20 @@ +describe('renderers/wegbl/WebGLGraphics', function () { + 'use strict'; + + var expect = chai.expect; + var WebGLGraphics = PIXI.WebGLGraphics; + + it('Module exists', function () { + expect(WebGLGraphics).to.be.a('function'); + }); + + it('Members exist', function () { + expect(WebGLGraphics).itself.to.respondTo('renderGraphics'); + expect(WebGLGraphics).itself.to.respondTo('updateGraphics'); + expect(WebGLGraphics).itself.to.respondTo('buildRectangle'); + expect(WebGLGraphics).itself.to.respondTo('buildRoundedRectangle'); + expect(WebGLGraphics).itself.to.respondTo('buildCircle'); + expect(WebGLGraphics).itself.to.respondTo('buildLine'); + expect(WebGLGraphics).itself.to.respondTo('buildPoly'); + }); +}); diff --git a/test/unit/pixi-v2/renderers/webgl/WebGLRenderer.js b/test/unit/pixi-v2/renderers/webgl/WebGLRenderer.js new file mode 100644 index 0000000..1680a80 --- /dev/null +++ b/test/unit/pixi-v2/renderers/webgl/WebGLRenderer.js @@ -0,0 +1,49 @@ +describe('renderers/webgl/WebGLRenderer', function () { + 'use strict'; + + var expect = chai.expect; + var WebGLRenderer = PIXI.WebGLRenderer; + + it('Module exists', function () { + expect(WebGLRenderer).to.be.a('function'); + }); + + // Skip tests if WebGL is not available (WebGL not supported in Travis CI) + try { + var renderer = new WebGLRenderer(400, 300, {}); + renderer.destroy(); + } catch (error) { + return; + } + + it('Destroy renderer', function () { + var renderer = new WebGLRenderer(400, 300, {}); + renderer.destroy(); + }); + + describe('.autoResize', function () { + it('Should automatically resize view if enabled', function () { + var renderer = new WebGLRenderer(200, 200, { + autoResize: true + }); + + expect(renderer.view.style.width).to.equal('200px'); + }); + + it('Should not automatically resize view if disabled', function () { + var renderer = new WebGLRenderer(200, 200, { + autoResize: false + }); + + expect(renderer.view.style.width).to.equal(''); + }); + + it('Should not automatically resize view if not specified', function () { + var renderer = new WebGLRenderer(200, 200, { + resolution: 2 + }); + + expect(renderer.view.style.width).to.equal(''); + }); + }); +}); diff --git a/test/unit/pixi-v2/renderers/webgl/WebGLShaders.js b/test/unit/pixi-v2/renderers/webgl/WebGLShaders.js new file mode 100644 index 0000000..6e33e4f --- /dev/null +++ b/test/unit/pixi-v2/renderers/webgl/WebGLShaders.js @@ -0,0 +1,13 @@ +describe('renderers/webgl/WebGLShaders', function () { + 'use strict'; + + var expect = chai.expect; + + it('Module members exist', function () { + + expect(PIXI).to.respondTo('CompileVertexShader'); + expect(PIXI).to.respondTo('CompileFragmentShader'); + expect(PIXI).to.respondTo('_CompileShader'); + expect(PIXI).to.respondTo('compileProgram'); + }); +}); diff --git a/test/unit/pixi-v2/renderers/webgl/WebGLSpriteBatch.js b/test/unit/pixi-v2/renderers/webgl/WebGLSpriteBatch.js new file mode 100644 index 0000000..e662b63 --- /dev/null +++ b/test/unit/pixi-v2/renderers/webgl/WebGLSpriteBatch.js @@ -0,0 +1,10 @@ +describe('renderers/webgl/utils/WebGLSpriteBatch', function () { + 'use strict'; + + var expect = chai.expect; + var WebGLSpriteBatch = PIXI.WebGLSpriteBatch; + + it('Module exists', function () { + expect(WebGLSpriteBatch).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/text/BitmapText.js b/test/unit/pixi-v2/text/BitmapText.js new file mode 100644 index 0000000..9388e3d --- /dev/null +++ b/test/unit/pixi-v2/text/BitmapText.js @@ -0,0 +1,10 @@ +describe('pixi/text/BitmapText', function () { + 'use strict'; + + var expect = chai.expect; + var BitmapText = PIXI.BitmapText; + + it('Module exists', function () { + expect(BitmapText).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/text/Text.js b/test/unit/pixi-v2/text/Text.js new file mode 100644 index 0000000..9bc9ac5 --- /dev/null +++ b/test/unit/pixi-v2/text/Text.js @@ -0,0 +1,10 @@ +describe('pixi/text/Text', function () { + 'use strict'; + + var expect = chai.expect; + var Text = PIXI.Text; + + it('Module exists', function () { + expect(Text).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/textures/BaseTexture.js b/test/unit/pixi-v2/textures/BaseTexture.js new file mode 100644 index 0000000..502b724 --- /dev/null +++ b/test/unit/pixi-v2/textures/BaseTexture.js @@ -0,0 +1,11 @@ +describe('pixi/textures/BaseTexture', function () { + 'use strict'; + + var expect = chai.expect; + var BaseTexture = PIXI.BaseTexture; + + it('Module exists', function () { + expect(BaseTexture).to.be.a('function'); + expect(PIXI).to.have.property('BaseTextureCache').and.to.be.an('object'); + }); +}); diff --git a/test/unit/pixi-v2/textures/RenderTexture.js b/test/unit/pixi-v2/textures/RenderTexture.js new file mode 100644 index 0000000..96acdb4 --- /dev/null +++ b/test/unit/pixi-v2/textures/RenderTexture.js @@ -0,0 +1,15 @@ +describe('pixi/textures/RenderTexture', function () { + 'use strict'; + + var expect = chai.expect; + var RenderTexture = PIXI.RenderTexture; + + it('Module exists', function () { + expect(RenderTexture).to.be.a('function'); + }); + + it('Confirm new instance', function (done) { + var texture = new RenderTexture(100, 100, new PIXI.CanvasRenderer()); + pixi_textures_RenderTexture_confirmNew(texture, done); + }); +}); diff --git a/test/unit/pixi-v2/textures/Texture.js b/test/unit/pixi-v2/textures/Texture.js new file mode 100644 index 0000000..090f64d --- /dev/null +++ b/test/unit/pixi-v2/textures/Texture.js @@ -0,0 +1,26 @@ +describe('pixi/textures/Texture', function () { + 'use strict'; + + var expect = chai.expect; + var Texture = PIXI.Texture; + + it('Module exists', function () { + expect(Texture).to.be.a('function'); + expect(PIXI).to.have.property('TextureCache').and.to.be.an('object'); + }); + + it('Members exist', function () { + expect(Texture).itself.to.respondTo('fromImage'); + expect(Texture).itself.to.respondTo('fromFrame'); + expect(Texture).itself.to.respondTo('fromCanvas'); + expect(Texture).itself.to.respondTo('addTextureToCache'); + expect(Texture).itself.to.respondTo('removeTextureFromCache'); + + // expect(Texture).itself.to.have.deep.property('frameUpdates.length', 0); + }); + + it('Confirm new instance', function (done) { + var texture = Texture.fromImage('/base/test/textures/bunny.png'); + pixi_textures_Texture_confirmNew(texture, done); + }); +}); diff --git a/test/unit/pixi-v2/utils/Detector.js b/test/unit/pixi-v2/utils/Detector.js new file mode 100644 index 0000000..4cf6008 --- /dev/null +++ b/test/unit/pixi-v2/utils/Detector.js @@ -0,0 +1,10 @@ +describe('pixi/utils/Detector', function () { + 'use strict'; + + var expect = chai.expect; + var autoDetectRenderer = PIXI.autoDetectRenderer; + + it('Module exists', function () { + expect(autoDetectRenderer).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/utils/EventTarget.js b/test/unit/pixi-v2/utils/EventTarget.js new file mode 100644 index 0000000..1cfc3a4 --- /dev/null +++ b/test/unit/pixi-v2/utils/EventTarget.js @@ -0,0 +1,361 @@ +describe('pixi/utils/EventTarget', function () { + 'use strict'; + + var expect = chai.expect; + + var Clazz, PClazz, obj, pobj, obj2; + beforeEach(function () { + Clazz = function () {}; + PClazz = function () {}; + + PIXI.EventTarget.mixin(Clazz.prototype); + PIXI.EventTarget.mixin(PClazz.prototype); + + obj = new Clazz(); + obj2 = new Clazz(); + pobj = new PClazz(); + + obj.parent = pobj; + obj2.parent = obj; + }); + + it('Module exists', function () { + expect(PIXI.EventTarget).to.be.an('object'); + }); + + it('Confirm new instance', function () { + pixi_utils_EventTarget_confirm(obj); + }); + + it('simple on/emit case works', function () { + var myData = {}; + + obj.on('myevent', function (event) { + pixi_utils_EventTarget_Event_confirm(event, obj, myData); + }); + + obj.emit('myevent', myData); + }); + + it('simple once case works', function () { + var called = 0; + + obj.once('myevent', function() { called++; }); + + obj.emit('myevent'); + obj.emit('myevent'); + obj.emit('myevent'); + obj.emit('myevent'); + obj.emit('myevent'); + + expect(called).to.equal(1); + }); + + it('simple off case works', function (done) { + function onMyEvent() { + done(new Error('Event listener should not have been called')); + } + + obj.on('myevent', onMyEvent); + obj.off('myevent', onMyEvent); + obj.emit('myevent'); + + done(); + }); + + it('simple propagation case works', function (done) { + var myData = {}; + + pobj.on('myevent', function () { + done(); + }); + + obj.emit('myevent'); + }); + + it('simple stopPropagation case works', function (done) { + var myData = {}; + + pobj.on('myevent', function () { + done(new Error('Event listener should not have been called on the parent element')); + }); + + obj.on('myevent', function (evt) { + evt.stopPropagation(); + }); + + obj.emit('myevent'); + + done(); + }); + + it('simple stopImmediatePropagation case works', function (done) { + var myData = {}; + + pobj.on('myevent', function () { + done(new Error('Event listener should not have been called on the parent')); + }); + + obj.on('myevent', function (evt) { + evt.stopImmediatePropagation(); + }); + + obj.on('myevent', function () { + done(new Error('Event listener should not have been called on the second')); + }); + + obj.emit('myevent'); + + done(); + }); + + it('multiple dispatches work properly', function () { + var called = 0; + + function onMyEvent() { + called++; + } + + obj.on('myevent', onMyEvent); + obj.emit('myevent'); + obj.emit('myevent'); + obj.emit('myevent'); + obj.emit('myevent'); + + expect(called).to.equal(4); + }); + + it('multiple events work properly', function () { + var called = 0; + + function onMyEvent() { + called++; + } + + obj.on('myevent1', onMyEvent); + obj.on('myevent2', onMyEvent); + obj.on('myevent3', onMyEvent); + obj.emit('myevent1'); + obj.emit('myevent2'); + obj.emit('myevent3'); + + expect(called).to.equal(3); + }); + + it('multiple events one removed works properly', function () { + var called = 0; + + function onMyEvent() { + called++; + } + + obj.on('myevent1', onMyEvent); + obj.on('myevent2', onMyEvent); + obj.on('myevent3', onMyEvent); + + obj.emit('myevent1'); + obj.emit('myevent2'); + obj.emit('myevent3'); + + obj.off('myevent2', onMyEvent); + + obj.emit('myevent1'); + obj.emit('myevent2'); + obj.emit('myevent3'); + + expect(called).to.equal(5); + }); + + it('multiple handlers for one event with some removed', function () { + var called = 0; + + var onMyEvent = function () { + called++; + }, + onMyEvent2 = function () { + called++; + }; + + // add 2 handlers and confirm they both get called + obj.on('myevent', onMyEvent); + obj.on('myevent', onMyEvent); + obj.on('myevent', onMyEvent2); + obj.on('myevent', onMyEvent2); + + obj.emit('myevent'); + + expect(called).to.equal(4); + + // remove one of the handlers, emit again, then ensure 1 more call is made + obj.off('myevent', onMyEvent); + + obj.emit('myevent'); + + expect(called).to.equal(6); + }); + + it('calls to off without a handler do nothing', function () { + var called = 0; + + var onMyEvent = function () { + called++; + }; + + obj.on('myevent', onMyEvent); + obj.on('myevent', onMyEvent); + + obj.emit('myevent'); + + expect(called).to.equal(2); + + obj.off('myevent'); + + obj.emit('myevent'); + + expect(called).to.equal(4); + + obj.off('myevent', onMyEvent); + + obj.emit('myevent'); + + expect(called).to.equal(4); + }); + + it('handles multiple instances with the same prototype', function () { + var called = 0; + + function onMyEvent(e) { + called++; + } + + obj.on('myevent1', onMyEvent); + obj.on('myevent2', onMyEvent); + + obj2.istwo = true; + obj2.on('myevent1', onMyEvent); + obj2.on('myevent2', onMyEvent); + + obj.emit('myevent1'); + obj.emit('myevent2'); + obj2.emit('myevent1'); + obj2.emit('myevent2'); + + //we emit 4 times, but since obj2 is a child of obj the event should bubble + //up to obj and show up there as well. So the obj2.emit() calls each increment + //the counter twice. + expect(called).to.equal(6); + }); + + it('is backwards compatible with older .dispatchEvent({})', function () { + var called = 0, + data = { + some: 'thing', + hello: true + }; + + function onMyEvent(event) { + pixi_utils_EventTarget_Event_confirm(event, obj, data); + + called++; + } + + obj.on('myevent1', onMyEvent); + obj.on('myevent2', onMyEvent); + obj.on('myevent3', onMyEvent); + + data.type = 'myevent1'; + obj.emit(data); + + data.type = 'myevent2'; + obj.emit(data); + + data.type = 'myevent3'; + obj.emit(data); + + obj.off('myevent2', onMyEvent); + + data.type = 'myevent1'; + obj.emit(data); + + data.type = 'myevent2'; + obj.emit(data); + + data.type = 'myevent3'; + obj.emit(data); + + expect(called).to.equal(5); + }); + + it('is backwards compatible with older .call(this)', function () { + var Fn = function() { + PIXI.EventTarget.call(this); + }, + o = new Fn(); + + pixi_utils_EventTarget_confirm(o); + }); + + it('is backwards compatible with older .addEventListener("")', function () { + var called = 0, + data = { + some: 'thing', + hello: true + }; + + function onMyEvent(event) { + pixi_utils_EventTarget_Event_confirm(event, obj, data); + + called++; + } + + obj.addEventListener('myevent1', onMyEvent); + obj.addEventListener('myevent2', onMyEvent); + obj.addEventListener('myevent3', onMyEvent); + + data.type = 'myevent1'; + obj.emit(data); + + data.type = 'myevent2'; + obj.emit(data); + + data.type = 'myevent3'; + obj.emit(data); + + obj.off('myevent2', onMyEvent); + + data.type = 'myevent1'; + obj.emit(data); + + data.type = 'myevent2'; + obj.emit(data); + + data.type = 'myevent3'; + obj.emit(data); + + expect(called).to.equal(5); + }); + + it('event remove during emit call properly', function () { + var called = 0; + + function cb1() { + called++; + obj.off('myevent', cb1); + } + function cb2() { + called++; + obj.off('myevent', cb2); + } + function cb3() { + called++; + obj.off('myevent', cb3); + } + + obj.on('myevent', cb1); + obj.on('myevent', cb2); + obj.on('myevent', cb3); + obj.emit('myevent', ''); + + expect(called).to.equal(3); + }); +}); diff --git a/test/unit/pixi-v2/utils/Polyk.js b/test/unit/pixi-v2/utils/Polyk.js new file mode 100644 index 0000000..dfc7128 --- /dev/null +++ b/test/unit/pixi-v2/utils/Polyk.js @@ -0,0 +1,14 @@ +describe('pixi/utils/Polyk', function () { + 'use strict'; + + var expect = chai.expect; + var PolyK = PIXI.PolyK; + + it('Module exists', function () { + expect(PolyK).to.be.an('object'); + }); + + it('Members exist', function () { + expect(PolyK).to.respondTo('Triangulate'); + }); +}); diff --git a/test/unit/pixi-v2/utils/Utils.js b/test/unit/pixi-v2/utils/Utils.js new file mode 100644 index 0000000..c97b3c6 --- /dev/null +++ b/test/unit/pixi-v2/utils/Utils.js @@ -0,0 +1,17 @@ +describe('Utils', function () { + 'use strict'; + + var expect = chai.expect; + + it('requestAnimationFrame exists', function () { + expect(global).to.respondTo('requestAnimationFrame'); + }); + + it('cancelAnimationFrame exists', function () { + expect(global).to.respondTo('cancelAnimationFrame'); + }); + + it('requestAnimFrame exists', function () { + expect(global).to.respondTo('requestAnimFrame'); + }); +}); diff --git a/test/unit/pixi/InteractionManager.js b/test/unit/pixi/InteractionManager.js deleted file mode 100644 index ed3001f..0000000 --- a/test/unit/pixi/InteractionManager.js +++ /dev/null @@ -1,10 +0,0 @@ -describe('pixi/InteractionManager', function () { - 'use strict'; - - var expect = chai.expect; - var InteractionManager = PIXI.InteractionManager; - - it('Module exists', function () { - expect(InteractionManager).to.be.a('function'); - }); -}); diff --git a/test/unit/pixi/Pixi.js b/test/unit/pixi/Pixi.js deleted file mode 100644 index 27debc1..0000000 --- a/test/unit/pixi/Pixi.js +++ /dev/null @@ -1,9 +0,0 @@ -describe('pixi/Pixi', function () { - 'use strict'; - - var expect = chai.expect; - - it('Module exists', function () { - expect(global).to.have.property('PIXI').and.to.be.an('object'); - }); -}); diff --git a/test/unit/pixi/core/Circle.js b/test/unit/pixi/core/Circle.js deleted file mode 100644 index fbcfa17..0000000 --- a/test/unit/pixi/core/Circle.js +++ /dev/null @@ -1,21 +0,0 @@ -describe('pixi/core/Circle', function () { - 'use strict'; - - var expect = chai.expect; - var Circle = PIXI.Circle; - - it('Module exists', function () { - expect(Circle).to.be.a('function'); - }); - - it('Confirm new instance', function () { - var obj = new Circle(); - pixi_core_Circle_confirmNewCircle(obj); - }); - - it("getBounds should return Rectangle that bounds the circle", function() { - var obj = new Circle(100, 250, 50); - var bounds = obj.getBounds(); - pixi_core_Circle_isBoundedByRectangle(obj, bounds); - }); -}); diff --git a/test/unit/pixi/core/Ellipse.js b/test/unit/pixi/core/Ellipse.js deleted file mode 100644 index 026b56f..0000000 --- a/test/unit/pixi/core/Ellipse.js +++ /dev/null @@ -1,24 +0,0 @@ -describe('pixi/core/Ellipse', function () { - 'use strict'; - - var expect = chai.expect; - var Ellipse = PIXI.Ellipse; - - it('Module exists', function () { - expect(Ellipse).to.be.a('function'); - }); - - it('Confirm new instance', function () { - var obj = new Ellipse(); - - expect(obj).to.be.an.instanceof(Ellipse); - expect(obj).to.respondTo('clone'); - expect(obj).to.respondTo('contains'); - expect(obj).to.respondTo('getBounds'); - - expect(obj).to.have.property('x', 0); - expect(obj).to.have.property('y', 0); - expect(obj).to.have.property('width', 0); - expect(obj).to.have.property('height', 0); - }); -}); diff --git a/test/unit/pixi/core/Matrix.js b/test/unit/pixi/core/Matrix.js deleted file mode 100644 index da75e2e..0000000 --- a/test/unit/pixi/core/Matrix.js +++ /dev/null @@ -1,14 +0,0 @@ -describe('pixi/core/Matrix', function () { - 'use strict'; - - var expect = chai.expect; - - it('Matrix exists', function () { - expect(PIXI.Matrix).to.be.an('function'); - }); - - it('Confirm new Matrix', function () { - var matrix = new PIXI.Matrix(); - pixi_core_Matrix_confirmNewMatrix(matrix); - }); -}); diff --git a/test/unit/pixi/core/Point.js b/test/unit/pixi/core/Point.js deleted file mode 100644 index c4d5163..0000000 --- a/test/unit/pixi/core/Point.js +++ /dev/null @@ -1,15 +0,0 @@ -describe('pixi/core/Point', function () { - 'use strict'; - - var expect = chai.expect; - var Point = PIXI.Point; - - it('Module exists', function () { - expect(Point).to.be.a('function'); - }); - - it('Confirm new instance', function () { - var obj = new Point(); - pixi_core_Point_confirm(obj, 0, 0); - }); -}); diff --git a/test/unit/pixi/core/Polygon.js b/test/unit/pixi/core/Polygon.js deleted file mode 100644 index dc8c918..0000000 --- a/test/unit/pixi/core/Polygon.js +++ /dev/null @@ -1,20 +0,0 @@ -describe('pixi/core/Polygon', function () { - 'use strict'; - - var expect = chai.expect; - var Polygon = PIXI.Polygon; - - it('Module exists', function () { - expect(Polygon).to.be.a('function'); - }); - - it('Confirm new instance', function () { - var obj = new Polygon(); - - expect(obj).to.be.an.instanceof(Polygon); - expect(obj).to.respondTo('clone'); - expect(obj).to.respondTo('contains'); - - expect(obj).to.have.deep.property('points.length', 0); - }); -}); diff --git a/test/unit/pixi/core/Rectangle.js b/test/unit/pixi/core/Rectangle.js deleted file mode 100644 index d43316e..0000000 --- a/test/unit/pixi/core/Rectangle.js +++ /dev/null @@ -1,15 +0,0 @@ -describe('pixi/core/Rectangle', function () { - 'use strict'; - - var expect = chai.expect; - var Rectangle = PIXI.Rectangle; - - it('Module exists', function () { - expect(Rectangle).to.be.a('function'); - }); - - it('Confirm new instance', function () { - var rect = new Rectangle(); - pixi_core_Rectangle_confirm(rect, 0, 0, 0, 0); - }); -}); diff --git a/test/unit/pixi/display/DisplayObject.js b/test/unit/pixi/display/DisplayObject.js deleted file mode 100644 index 044acf8..0000000 --- a/test/unit/pixi/display/DisplayObject.js +++ /dev/null @@ -1,21 +0,0 @@ -describe('pixi/display/DisplayObject', function () { - 'use strict'; - - var expect = chai.expect; - var DisplayObject = PIXI.DisplayObject; - - it('Module exists', function () { - expect(DisplayObject).to.be.a('function'); - // expect(PIXI).to.have.property('visibleCount', 0); - }); - - it('Confirm new instance', function () { - var obj = new DisplayObject(); - - pixi_display_DisplayObject_confirmNew(obj); - expect(obj).to.have.property('hitArea', null); - expect(obj).to.have.property('interactive', false); - expect(obj).to.have.property('renderable', false); - expect(obj).to.have.property('stage', null); - }); -}); diff --git a/test/unit/pixi/display/DisplayObjectContainer.js b/test/unit/pixi/display/DisplayObjectContainer.js deleted file mode 100644 index 15a3376..0000000 --- a/test/unit/pixi/display/DisplayObjectContainer.js +++ /dev/null @@ -1,67 +0,0 @@ -describe('pixi/display/DisplayObjectContainer', function () { - 'use strict'; - - var expect = chai.expect; - var DisplayObjectContainer = PIXI.DisplayObjectContainer; - - it('Module exists', function () { - expect(DisplayObjectContainer).to.be.a('function'); - }); - - it('Confirm new instance', function () { - var obj = new DisplayObjectContainer(); - - pixi_display_DisplayObjectContainer_confirmNew(obj); - expect(obj).to.have.property('hitArea', null); - expect(obj).to.have.property('interactive', false); - expect(obj).to.have.property('renderable', false); - expect(obj).to.have.property('stage', null); - }); - - it('Gets child index', function() { - var container = new PIXI.DisplayObjectContainer(); - var children = []; - for (var i = 0; i < 10; i++) { - var child = new PIXI.DisplayObject(); - children.push(child); - container.addChild(child); - } - - for (i = 0; i < children.length; i++) { - expect(i).to.eql(container.getChildIndex(children[i])); - } - }); - - it('throws error when trying to get index of not a child', function() { - var container = new PIXI.DisplayObjectContainer(); - var child = new PIXI.DisplayObject(); - - expect(function() { container.getChildIndex(child); }).to.throw(); - }); - - it('Sets child index', function() { - var container = new PIXI.DisplayObjectContainer(); - var children = []; - - for (var i = 0; i < 10; i++) { - var child = new PIXI.DisplayObject(); - children.push(child); - container.addChild(child); - } - children.reverse(); - - for (i = 0; i < children.length; i++) { - container.setChildIndex(children[i], i); - expect(i).to.eql(container.getChildIndex(children[i])); - } - }); - - it('throws error when trying to set incorect index', function() { - var container = new PIXI.DisplayObjectContainer(); - var child = new PIXI.DisplayObject(); - container.addChild(child); - - expect(function() { container.setChildIndex(child, -1); }).to.throw(); - expect(function() { container.setChildIndex(child, 1); }).to.throw(); - }); -}); diff --git a/test/unit/pixi/display/MovieClip.js b/test/unit/pixi/display/MovieClip.js deleted file mode 100644 index f3c6c6a..0000000 --- a/test/unit/pixi/display/MovieClip.js +++ /dev/null @@ -1,33 +0,0 @@ -describe('pixi/display/MovieClip', function () { - 'use strict'; - - var expect = chai.expect; - var MovieClip = PIXI.MovieClip; - var Texture = PIXI.Texture; - - it('Module exists', function () { - expect(MovieClip).to.be.a('function'); - }); - - it('Confirm new instance', function (done) { - var texture = Texture.fromImage('/base/test/textures/SpriteSheet-Explosion.png'); - var obj = new MovieClip([texture]); - - pixi_display_Sprite_confirmNew(obj, done); - - expect(obj).to.be.an.instanceof(MovieClip); - expect(obj).to.respondTo('stop'); - expect(obj).to.respondTo('play'); - expect(obj).to.respondTo('gotoAndStop'); - expect(obj).to.respondTo('gotoAndPlay'); - expect(obj).to.respondTo('updateTransform'); - - expect(obj).to.have.deep.property('textures.length', 1); - expect(obj).to.have.deep.property('textures[0]', texture); - expect(obj).to.have.property('animationSpeed', 1); - expect(obj).to.have.property('loop', true); - expect(obj).to.have.property('onComplete', null); - expect(obj).to.have.property('currentFrame', 0); - expect(obj).to.have.property('playing', false); - }); -}); diff --git a/test/unit/pixi/display/Sprite.js b/test/unit/pixi/display/Sprite.js deleted file mode 100644 index 30c8076..0000000 --- a/test/unit/pixi/display/Sprite.js +++ /dev/null @@ -1,28 +0,0 @@ -describe('pixi/display/Sprite', function () { - 'use strict'; - - var expect = chai.expect; - var Sprite = PIXI.Sprite; - var Texture = PIXI.Texture; - - it('Module exists', function () { - expect(Sprite).to.be.a('function'); - expect(PIXI).to.have.deep.property('blendModes.NORMAL', 0); - expect(PIXI).to.have.deep.property('blendModes.ADD', 1); - expect(PIXI).to.have.deep.property('blendModes.MULTIPLY', 2); - expect(PIXI).to.have.deep.property('blendModes.SCREEN', 3); - }); - - - it('Members exist', function () { - expect(Sprite).itself.to.respondTo('fromImage'); - expect(Sprite).itself.to.respondTo('fromFrame'); - }); - - it('Confirm new instance', function (done) { - var texture = Texture.fromImage('/base/test/textures/SpriteSheet-Aliens.png'); - var obj = new Sprite(texture); - - pixi_display_Sprite_confirmNew(obj, done); - }); -}); diff --git a/test/unit/pixi-v2/InteractionManager.js b/test/unit/pixi-v2/InteractionManager.js new file mode 100644 index 0000000..ed3001f --- /dev/null +++ b/test/unit/pixi-v2/InteractionManager.js @@ -0,0 +1,10 @@ +describe('pixi/InteractionManager', function () { + 'use strict'; + + var expect = chai.expect; + var InteractionManager = PIXI.InteractionManager; + + it('Module exists', function () { + expect(InteractionManager).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/Pixi.js b/test/unit/pixi-v2/Pixi.js new file mode 100644 index 0000000..27debc1 --- /dev/null +++ b/test/unit/pixi-v2/Pixi.js @@ -0,0 +1,9 @@ +describe('pixi/Pixi', function () { + 'use strict'; + + var expect = chai.expect; + + it('Module exists', function () { + expect(global).to.have.property('PIXI').and.to.be.an('object'); + }); +}); diff --git a/test/unit/pixi-v2/core/Circle.js b/test/unit/pixi-v2/core/Circle.js new file mode 100644 index 0000000..fbcfa17 --- /dev/null +++ b/test/unit/pixi-v2/core/Circle.js @@ -0,0 +1,21 @@ +describe('pixi/core/Circle', function () { + 'use strict'; + + var expect = chai.expect; + var Circle = PIXI.Circle; + + it('Module exists', function () { + expect(Circle).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Circle(); + pixi_core_Circle_confirmNewCircle(obj); + }); + + it("getBounds should return Rectangle that bounds the circle", function() { + var obj = new Circle(100, 250, 50); + var bounds = obj.getBounds(); + pixi_core_Circle_isBoundedByRectangle(obj, bounds); + }); +}); diff --git a/test/unit/pixi-v2/core/Ellipse.js b/test/unit/pixi-v2/core/Ellipse.js new file mode 100644 index 0000000..026b56f --- /dev/null +++ b/test/unit/pixi-v2/core/Ellipse.js @@ -0,0 +1,24 @@ +describe('pixi/core/Ellipse', function () { + 'use strict'; + + var expect = chai.expect; + var Ellipse = PIXI.Ellipse; + + it('Module exists', function () { + expect(Ellipse).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Ellipse(); + + expect(obj).to.be.an.instanceof(Ellipse); + expect(obj).to.respondTo('clone'); + expect(obj).to.respondTo('contains'); + expect(obj).to.respondTo('getBounds'); + + expect(obj).to.have.property('x', 0); + expect(obj).to.have.property('y', 0); + expect(obj).to.have.property('width', 0); + expect(obj).to.have.property('height', 0); + }); +}); diff --git a/test/unit/pixi-v2/core/Matrix.js b/test/unit/pixi-v2/core/Matrix.js new file mode 100644 index 0000000..da75e2e --- /dev/null +++ b/test/unit/pixi-v2/core/Matrix.js @@ -0,0 +1,14 @@ +describe('pixi/core/Matrix', function () { + 'use strict'; + + var expect = chai.expect; + + it('Matrix exists', function () { + expect(PIXI.Matrix).to.be.an('function'); + }); + + it('Confirm new Matrix', function () { + var matrix = new PIXI.Matrix(); + pixi_core_Matrix_confirmNewMatrix(matrix); + }); +}); diff --git a/test/unit/pixi-v2/core/Point.js b/test/unit/pixi-v2/core/Point.js new file mode 100644 index 0000000..c4d5163 --- /dev/null +++ b/test/unit/pixi-v2/core/Point.js @@ -0,0 +1,15 @@ +describe('pixi/core/Point', function () { + 'use strict'; + + var expect = chai.expect; + var Point = PIXI.Point; + + it('Module exists', function () { + expect(Point).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Point(); + pixi_core_Point_confirm(obj, 0, 0); + }); +}); diff --git a/test/unit/pixi-v2/core/Polygon.js b/test/unit/pixi-v2/core/Polygon.js new file mode 100644 index 0000000..dc8c918 --- /dev/null +++ b/test/unit/pixi-v2/core/Polygon.js @@ -0,0 +1,20 @@ +describe('pixi/core/Polygon', function () { + 'use strict'; + + var expect = chai.expect; + var Polygon = PIXI.Polygon; + + it('Module exists', function () { + expect(Polygon).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Polygon(); + + expect(obj).to.be.an.instanceof(Polygon); + expect(obj).to.respondTo('clone'); + expect(obj).to.respondTo('contains'); + + expect(obj).to.have.deep.property('points.length', 0); + }); +}); diff --git a/test/unit/pixi-v2/core/Rectangle.js b/test/unit/pixi-v2/core/Rectangle.js new file mode 100644 index 0000000..d43316e --- /dev/null +++ b/test/unit/pixi-v2/core/Rectangle.js @@ -0,0 +1,15 @@ +describe('pixi/core/Rectangle', function () { + 'use strict'; + + var expect = chai.expect; + var Rectangle = PIXI.Rectangle; + + it('Module exists', function () { + expect(Rectangle).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var rect = new Rectangle(); + pixi_core_Rectangle_confirm(rect, 0, 0, 0, 0); + }); +}); diff --git a/test/unit/pixi-v2/display/DisplayObject.js b/test/unit/pixi-v2/display/DisplayObject.js new file mode 100644 index 0000000..044acf8 --- /dev/null +++ b/test/unit/pixi-v2/display/DisplayObject.js @@ -0,0 +1,21 @@ +describe('pixi/display/DisplayObject', function () { + 'use strict'; + + var expect = chai.expect; + var DisplayObject = PIXI.DisplayObject; + + it('Module exists', function () { + expect(DisplayObject).to.be.a('function'); + // expect(PIXI).to.have.property('visibleCount', 0); + }); + + it('Confirm new instance', function () { + var obj = new DisplayObject(); + + pixi_display_DisplayObject_confirmNew(obj); + expect(obj).to.have.property('hitArea', null); + expect(obj).to.have.property('interactive', false); + expect(obj).to.have.property('renderable', false); + expect(obj).to.have.property('stage', null); + }); +}); diff --git a/test/unit/pixi-v2/display/DisplayObjectContainer.js b/test/unit/pixi-v2/display/DisplayObjectContainer.js new file mode 100644 index 0000000..15a3376 --- /dev/null +++ b/test/unit/pixi-v2/display/DisplayObjectContainer.js @@ -0,0 +1,67 @@ +describe('pixi/display/DisplayObjectContainer', function () { + 'use strict'; + + var expect = chai.expect; + var DisplayObjectContainer = PIXI.DisplayObjectContainer; + + it('Module exists', function () { + expect(DisplayObjectContainer).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new DisplayObjectContainer(); + + pixi_display_DisplayObjectContainer_confirmNew(obj); + expect(obj).to.have.property('hitArea', null); + expect(obj).to.have.property('interactive', false); + expect(obj).to.have.property('renderable', false); + expect(obj).to.have.property('stage', null); + }); + + it('Gets child index', function() { + var container = new PIXI.DisplayObjectContainer(); + var children = []; + for (var i = 0; i < 10; i++) { + var child = new PIXI.DisplayObject(); + children.push(child); + container.addChild(child); + } + + for (i = 0; i < children.length; i++) { + expect(i).to.eql(container.getChildIndex(children[i])); + } + }); + + it('throws error when trying to get index of not a child', function() { + var container = new PIXI.DisplayObjectContainer(); + var child = new PIXI.DisplayObject(); + + expect(function() { container.getChildIndex(child); }).to.throw(); + }); + + it('Sets child index', function() { + var container = new PIXI.DisplayObjectContainer(); + var children = []; + + for (var i = 0; i < 10; i++) { + var child = new PIXI.DisplayObject(); + children.push(child); + container.addChild(child); + } + children.reverse(); + + for (i = 0; i < children.length; i++) { + container.setChildIndex(children[i], i); + expect(i).to.eql(container.getChildIndex(children[i])); + } + }); + + it('throws error when trying to set incorect index', function() { + var container = new PIXI.DisplayObjectContainer(); + var child = new PIXI.DisplayObject(); + container.addChild(child); + + expect(function() { container.setChildIndex(child, -1); }).to.throw(); + expect(function() { container.setChildIndex(child, 1); }).to.throw(); + }); +}); diff --git a/test/unit/pixi-v2/display/MovieClip.js b/test/unit/pixi-v2/display/MovieClip.js new file mode 100644 index 0000000..f3c6c6a --- /dev/null +++ b/test/unit/pixi-v2/display/MovieClip.js @@ -0,0 +1,33 @@ +describe('pixi/display/MovieClip', function () { + 'use strict'; + + var expect = chai.expect; + var MovieClip = PIXI.MovieClip; + var Texture = PIXI.Texture; + + it('Module exists', function () { + expect(MovieClip).to.be.a('function'); + }); + + it('Confirm new instance', function (done) { + var texture = Texture.fromImage('/base/test/textures/SpriteSheet-Explosion.png'); + var obj = new MovieClip([texture]); + + pixi_display_Sprite_confirmNew(obj, done); + + expect(obj).to.be.an.instanceof(MovieClip); + expect(obj).to.respondTo('stop'); + expect(obj).to.respondTo('play'); + expect(obj).to.respondTo('gotoAndStop'); + expect(obj).to.respondTo('gotoAndPlay'); + expect(obj).to.respondTo('updateTransform'); + + expect(obj).to.have.deep.property('textures.length', 1); + expect(obj).to.have.deep.property('textures[0]', texture); + expect(obj).to.have.property('animationSpeed', 1); + expect(obj).to.have.property('loop', true); + expect(obj).to.have.property('onComplete', null); + expect(obj).to.have.property('currentFrame', 0); + expect(obj).to.have.property('playing', false); + }); +}); diff --git a/test/unit/pixi-v2/display/Sprite.js b/test/unit/pixi-v2/display/Sprite.js new file mode 100644 index 0000000..30c8076 --- /dev/null +++ b/test/unit/pixi-v2/display/Sprite.js @@ -0,0 +1,28 @@ +describe('pixi/display/Sprite', function () { + 'use strict'; + + var expect = chai.expect; + var Sprite = PIXI.Sprite; + var Texture = PIXI.Texture; + + it('Module exists', function () { + expect(Sprite).to.be.a('function'); + expect(PIXI).to.have.deep.property('blendModes.NORMAL', 0); + expect(PIXI).to.have.deep.property('blendModes.ADD', 1); + expect(PIXI).to.have.deep.property('blendModes.MULTIPLY', 2); + expect(PIXI).to.have.deep.property('blendModes.SCREEN', 3); + }); + + + it('Members exist', function () { + expect(Sprite).itself.to.respondTo('fromImage'); + expect(Sprite).itself.to.respondTo('fromFrame'); + }); + + it('Confirm new instance', function (done) { + var texture = Texture.fromImage('/base/test/textures/SpriteSheet-Aliens.png'); + var obj = new Sprite(texture); + + pixi_display_Sprite_confirmNew(obj, done); + }); +}); diff --git a/test/unit/pixi-v2/display/Stage.js b/test/unit/pixi-v2/display/Stage.js new file mode 100644 index 0000000..6974c2e --- /dev/null +++ b/test/unit/pixi-v2/display/Stage.js @@ -0,0 +1,49 @@ +describe('pixi/display/Stage', function () { + 'use strict'; + + var expect = chai.expect; + var Stage = PIXI.Stage; + var InteractionManager = PIXI.InteractionManager; + var Rectangle = PIXI.Rectangle; + + it('Module exists', function () { + expect(Stage).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Stage(null, true); + + pixi_display_DisplayObjectContainer_confirmNew(obj); + + expect(obj).to.be.an.instanceof(Stage); + expect(obj).to.respondTo('updateTransform'); + expect(obj).to.respondTo('setBackgroundColor'); + expect(obj).to.respondTo('getMousePosition'); + // FIXME: duplicate member in DisplayObject + pixi_core_Matrix_confirmNewMatrix(obj.worldTransform); + // FIXME: convert arg to bool in constructor + expect(obj).to.have.property('interactive', true); + + expect(obj).to.have.property('interactionManager') + .and.to.be.an.instanceof(InteractionManager) + .and.to.have.property('stage', obj); + + expect(obj).to.have.property('dirty', true); + + expect(obj).to.have.property('stage', obj); + + expect(obj).to.have.property('hitArea') + .and.to.be.an.instanceof(Rectangle); + pixi_core_Rectangle_confirm(obj.hitArea, 0, 0, 100000, 100000); + + expect(obj).to.have.property('backgroundColor', 0x000000); + expect(obj).to.have.deep.property('backgroundColorSplit.length', 3); + expect(obj).to.have.deep.property('backgroundColorSplit[0]', 0); + expect(obj).to.have.deep.property('backgroundColorSplit[1]', 0); + expect(obj).to.have.deep.property('backgroundColorSplit[2]', 0); + expect(obj).to.have.property('backgroundColorString', '#000000'); + + + expect(obj).to.have.property('worldVisible', true); + }); +}); diff --git a/test/unit/pixi-v2/extras/Rope.js b/test/unit/pixi-v2/extras/Rope.js new file mode 100644 index 0000000..05885ac --- /dev/null +++ b/test/unit/pixi-v2/extras/Rope.js @@ -0,0 +1,31 @@ +describe('pixi/extras/Rope', function () { + 'use strict'; + + var expect = chai.expect; + var Rope = PIXI.Rope; + var Texture = PIXI.Texture; + var Point = PIXI.Point; + + it('Module exists', function () { + expect(Rope).to.be.a('function'); + }); + + it('Confirm new instance', function () { + + var texture = Texture.fromImage('/base/test/textures/bunny.png'); + + // TODO-Alvin + // Same as Strip + + // var obj = new Rope(texture, [new Point(), new Point(5, 10), new Point(10, 20)]); + + // pixi_extras_Strip_confirmNew(obj); + + // expect(obj).to.be.an.instanceof(Rope); + // expect(obj).to.respondTo('refresh'); + // expect(obj).to.respondTo('updateTransform'); + // expect(obj).to.respondTo('setTexture'); + + // TODO: Test properties + }); +}); diff --git a/test/unit/pixi-v2/extras/Spine.js b/test/unit/pixi-v2/extras/Spine.js new file mode 100644 index 0000000..0708bc0 --- /dev/null +++ b/test/unit/pixi-v2/extras/Spine.js @@ -0,0 +1,10 @@ +describe('pixi/extras/Spine', function () { + 'use strict'; + + var expect = chai.expect; + var Spine = PIXI.Spine; + + it('Module exists', function () { + expect(Spine).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/extras/Strip.js b/test/unit/pixi-v2/extras/Strip.js new file mode 100644 index 0000000..230af90 --- /dev/null +++ b/test/unit/pixi-v2/extras/Strip.js @@ -0,0 +1,26 @@ +describe('pixi/extras/Strip', function () { + 'use strict'; + + var expect = chai.expect; + var Strip = PIXI.Strip; + var Texture = PIXI.Texture; + + it('Module exists', function () { + expect(Strip).to.be.a('function'); + }); + + it('Confirm new instance', function () { + + + // TODO-Alvin + // We tweaked it to make it pass the tests, but the whole strip class needs + // to be re-coded + + var texture = Texture.fromImage('/base/test/textures/bunny.png'); + + // var obj = new Strip(texture, 20, 10000); + + + // pixi_extras_Strip_confirmNew(obj); + }); +}); diff --git a/test/unit/pixi-v2/extras/TilingSprite.js b/test/unit/pixi-v2/extras/TilingSprite.js new file mode 100644 index 0000000..56aea14 --- /dev/null +++ b/test/unit/pixi-v2/extras/TilingSprite.js @@ -0,0 +1,24 @@ +describe('pixi/extras/TilingSprite', function () { + 'use strict'; + + var expect = chai.expect; + var TilingSprite = PIXI.TilingSprite; + var Texture = PIXI.Texture; + + it('Module exists', function () { + expect(TilingSprite).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var texture = Texture.fromImage('/base/test/textures/bunny.png'); + var obj = new TilingSprite(texture, 6000, 12000); + + pixi_display_DisplayObjectContainer_confirmNew(obj); + + expect(obj).to.be.an.instanceof(TilingSprite); + expect(obj).to.respondTo('setTexture'); + expect(obj).to.respondTo('onTextureUpdate'); + + // TODO: Test properties + }); +}); diff --git a/test/unit/pixi-v2/filters/FilterBlock.js b/test/unit/pixi-v2/filters/FilterBlock.js new file mode 100644 index 0000000..870cec0 --- /dev/null +++ b/test/unit/pixi-v2/filters/FilterBlock.js @@ -0,0 +1,10 @@ +describe('pixi/filters/FilterBlock', function () { + 'use strict'; + + var expect = chai.expect; + var FilterBlock = PIXI.FilterBlock; + + it('Module exists', function () { + expect(FilterBlock).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/AssetLoader.js b/test/unit/pixi-v2/loaders/AssetLoader.js new file mode 100644 index 0000000..a0aa0b5 --- /dev/null +++ b/test/unit/pixi-v2/loaders/AssetLoader.js @@ -0,0 +1,10 @@ +describe('pixi/loaders/AssetLoader', function () { + 'use strict'; + + var expect = chai.expect; + var AssetLoader = PIXI.AssetLoader; + + it('Module exists', function () { + expect(AssetLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/BitmapFontLoader.js b/test/unit/pixi-v2/loaders/BitmapFontLoader.js new file mode 100644 index 0000000..046f018 --- /dev/null +++ b/test/unit/pixi-v2/loaders/BitmapFontLoader.js @@ -0,0 +1,9 @@ +describe('pixi/loaders/BitmapFontLoader', function () { + 'use strict'; + + var expect = chai.expect; + + it('Module exists', function () { + expect(PIXI.BitmapFontLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/ImageLoader.js b/test/unit/pixi-v2/loaders/ImageLoader.js new file mode 100644 index 0000000..8b1f556 --- /dev/null +++ b/test/unit/pixi-v2/loaders/ImageLoader.js @@ -0,0 +1,10 @@ +describe('pixi/loaders/ImageLoader', function () { + 'use strict'; + + var expect = chai.expect; + var ImageLoader = PIXI.ImageLoader; + + it('Module exists', function () { + expect(ImageLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/JsonLoader.js b/test/unit/pixi-v2/loaders/JsonLoader.js new file mode 100644 index 0000000..c577e83 --- /dev/null +++ b/test/unit/pixi-v2/loaders/JsonLoader.js @@ -0,0 +1,10 @@ +describe('pixi/loaders/JsonLoader', function () { + 'use strict'; + + var expect = chai.expect; + var JsonLoader = PIXI.JsonLoader; + + it('Module exists', function () { + expect(JsonLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/SpineLoader.js b/test/unit/pixi-v2/loaders/SpineLoader.js new file mode 100644 index 0000000..fdcc0b8 --- /dev/null +++ b/test/unit/pixi-v2/loaders/SpineLoader.js @@ -0,0 +1,10 @@ +describe('pixi/loaders/SpineLoader', function () { + 'use strict'; + + var expect = chai.expect; + var SpineLoader = PIXI.SpineLoader; + + it('Module exists', function () { + expect(SpineLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/SpriteSheetLoader.js b/test/unit/pixi-v2/loaders/SpriteSheetLoader.js new file mode 100644 index 0000000..57beb27 --- /dev/null +++ b/test/unit/pixi-v2/loaders/SpriteSheetLoader.js @@ -0,0 +1,10 @@ +describe('pixi/loaders/SpriteSheetLoader', function () { + 'use strict'; + + var expect = chai.expect; + var SpriteSheetLoader = PIXI.SpriteSheetLoader; + + it('Module exists', function () { + expect(SpriteSheetLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/primitives/Graphics.js b/test/unit/pixi-v2/primitives/Graphics.js new file mode 100644 index 0000000..f3849eb --- /dev/null +++ b/test/unit/pixi-v2/primitives/Graphics.js @@ -0,0 +1,44 @@ +describe('pixi/primitives/Graphics', function () { + 'use strict'; + + var expect = chai.expect; + var Graphics = PIXI.Graphics; + + it('Module exists', function () { + expect(Graphics).to.be.a('function'); + + expect(Graphics).itself.to.have.property('POLY', 0); + expect(Graphics).itself.to.have.property('RECT', 1); + expect(Graphics).itself.to.have.property('CIRC', 2); + expect(Graphics).itself.to.have.property('ELIP', 3); + expect(Graphics).itself.to.have.property('RREC', 4); + }); + + it('Confirm new instance', function () { + var obj = new Graphics(); + + pixi_display_DisplayObjectContainer_confirmNew(obj); + + expect(obj).to.be.an.instanceof(Graphics); + expect(obj).to.respondTo('lineStyle'); + expect(obj).to.respondTo('lineStyle'); + expect(obj).to.respondTo('moveTo'); + expect(obj).to.respondTo('lineTo'); + expect(obj).to.respondTo('beginFill'); + expect(obj).to.respondTo('endFill'); + expect(obj).to.respondTo('drawRect'); + // expect(obj).to.respondTo('drawRoundedRect'); + expect(obj).to.respondTo('drawCircle'); + expect(obj).to.respondTo('drawEllipse'); + expect(obj).to.respondTo('clear'); + + expect(obj).to.have.property('renderable', true); + expect(obj).to.have.property('fillAlpha', 1); + expect(obj).to.have.property('lineWidth', 0); + expect(obj).to.have.property('width', 0); + expect(obj).to.have.property('height', 0); + expect(obj).to.have.property('lineColor', 0); + expect(obj).to.have.deep.property('graphicsData.length', 0); + // expect(obj).to.have.deep.property('currentPath.points.length', 0); + }); +}); diff --git a/test/unit/pixi-v2/renderers/canvas/CanvasGraphics.js b/test/unit/pixi-v2/renderers/canvas/CanvasGraphics.js new file mode 100644 index 0000000..8f44472 --- /dev/null +++ b/test/unit/pixi-v2/renderers/canvas/CanvasGraphics.js @@ -0,0 +1,15 @@ +describe('renders/canvas/CanvasGraphics', function () { + 'use strict'; + + var expect = chai.expect; + var CanvasGraphics = PIXI.CanvasGraphics; + + it('Module exists', function () { + expect(CanvasGraphics).to.be.a('function'); + }); + + it('Members exist', function () { + expect(CanvasGraphics).itself.to.respondTo('renderGraphics'); + expect(CanvasGraphics).itself.to.respondTo('renderGraphicsMask'); + }); +}); diff --git a/test/unit/pixi-v2/renderers/canvas/CanvasRenderer.js b/test/unit/pixi-v2/renderers/canvas/CanvasRenderer.js new file mode 100644 index 0000000..1646444 --- /dev/null +++ b/test/unit/pixi-v2/renderers/canvas/CanvasRenderer.js @@ -0,0 +1,36 @@ +describe('renderers/canvas/CanvasRenderer', function () { + 'use strict'; + + var expect = chai.expect; + var CanvasRenderer = PIXI.CanvasRenderer; + + it('Module exists', function () { + expect(CanvasRenderer).to.be.a('function'); + }); + + describe('.autoResize', function () { + it('Should automatically resize view if enabled', function () { + var renderer = new CanvasRenderer(200, 200, { + autoResize: true + }); + + expect(renderer.view.style.width).to.equal('200px'); + }); + + it('Should not automatically resize view if disabled', function () { + var renderer = new CanvasRenderer(200, 200, { + autoResize: false + }); + + expect(renderer.view.style.width).to.equal(''); + }); + + it('Should not automatically resize view if not specified', function () { + var renderer = new CanvasRenderer(200, 200, { + resolution: 2 + }); + + expect(renderer.view.style.width).to.equal(''); + }); + }); +}); diff --git a/test/unit/pixi-v2/renderers/webgl/WebGLGraphics.js b/test/unit/pixi-v2/renderers/webgl/WebGLGraphics.js new file mode 100644 index 0000000..5867b28 --- /dev/null +++ b/test/unit/pixi-v2/renderers/webgl/WebGLGraphics.js @@ -0,0 +1,20 @@ +describe('renderers/wegbl/WebGLGraphics', function () { + 'use strict'; + + var expect = chai.expect; + var WebGLGraphics = PIXI.WebGLGraphics; + + it('Module exists', function () { + expect(WebGLGraphics).to.be.a('function'); + }); + + it('Members exist', function () { + expect(WebGLGraphics).itself.to.respondTo('renderGraphics'); + expect(WebGLGraphics).itself.to.respondTo('updateGraphics'); + expect(WebGLGraphics).itself.to.respondTo('buildRectangle'); + expect(WebGLGraphics).itself.to.respondTo('buildRoundedRectangle'); + expect(WebGLGraphics).itself.to.respondTo('buildCircle'); + expect(WebGLGraphics).itself.to.respondTo('buildLine'); + expect(WebGLGraphics).itself.to.respondTo('buildPoly'); + }); +}); diff --git a/test/unit/pixi-v2/renderers/webgl/WebGLRenderer.js b/test/unit/pixi-v2/renderers/webgl/WebGLRenderer.js new file mode 100644 index 0000000..1680a80 --- /dev/null +++ b/test/unit/pixi-v2/renderers/webgl/WebGLRenderer.js @@ -0,0 +1,49 @@ +describe('renderers/webgl/WebGLRenderer', function () { + 'use strict'; + + var expect = chai.expect; + var WebGLRenderer = PIXI.WebGLRenderer; + + it('Module exists', function () { + expect(WebGLRenderer).to.be.a('function'); + }); + + // Skip tests if WebGL is not available (WebGL not supported in Travis CI) + try { + var renderer = new WebGLRenderer(400, 300, {}); + renderer.destroy(); + } catch (error) { + return; + } + + it('Destroy renderer', function () { + var renderer = new WebGLRenderer(400, 300, {}); + renderer.destroy(); + }); + + describe('.autoResize', function () { + it('Should automatically resize view if enabled', function () { + var renderer = new WebGLRenderer(200, 200, { + autoResize: true + }); + + expect(renderer.view.style.width).to.equal('200px'); + }); + + it('Should not automatically resize view if disabled', function () { + var renderer = new WebGLRenderer(200, 200, { + autoResize: false + }); + + expect(renderer.view.style.width).to.equal(''); + }); + + it('Should not automatically resize view if not specified', function () { + var renderer = new WebGLRenderer(200, 200, { + resolution: 2 + }); + + expect(renderer.view.style.width).to.equal(''); + }); + }); +}); diff --git a/test/unit/pixi-v2/renderers/webgl/WebGLShaders.js b/test/unit/pixi-v2/renderers/webgl/WebGLShaders.js new file mode 100644 index 0000000..6e33e4f --- /dev/null +++ b/test/unit/pixi-v2/renderers/webgl/WebGLShaders.js @@ -0,0 +1,13 @@ +describe('renderers/webgl/WebGLShaders', function () { + 'use strict'; + + var expect = chai.expect; + + it('Module members exist', function () { + + expect(PIXI).to.respondTo('CompileVertexShader'); + expect(PIXI).to.respondTo('CompileFragmentShader'); + expect(PIXI).to.respondTo('_CompileShader'); + expect(PIXI).to.respondTo('compileProgram'); + }); +}); diff --git a/test/unit/pixi-v2/renderers/webgl/WebGLSpriteBatch.js b/test/unit/pixi-v2/renderers/webgl/WebGLSpriteBatch.js new file mode 100644 index 0000000..e662b63 --- /dev/null +++ b/test/unit/pixi-v2/renderers/webgl/WebGLSpriteBatch.js @@ -0,0 +1,10 @@ +describe('renderers/webgl/utils/WebGLSpriteBatch', function () { + 'use strict'; + + var expect = chai.expect; + var WebGLSpriteBatch = PIXI.WebGLSpriteBatch; + + it('Module exists', function () { + expect(WebGLSpriteBatch).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/text/BitmapText.js b/test/unit/pixi-v2/text/BitmapText.js new file mode 100644 index 0000000..9388e3d --- /dev/null +++ b/test/unit/pixi-v2/text/BitmapText.js @@ -0,0 +1,10 @@ +describe('pixi/text/BitmapText', function () { + 'use strict'; + + var expect = chai.expect; + var BitmapText = PIXI.BitmapText; + + it('Module exists', function () { + expect(BitmapText).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/text/Text.js b/test/unit/pixi-v2/text/Text.js new file mode 100644 index 0000000..9bc9ac5 --- /dev/null +++ b/test/unit/pixi-v2/text/Text.js @@ -0,0 +1,10 @@ +describe('pixi/text/Text', function () { + 'use strict'; + + var expect = chai.expect; + var Text = PIXI.Text; + + it('Module exists', function () { + expect(Text).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/textures/BaseTexture.js b/test/unit/pixi-v2/textures/BaseTexture.js new file mode 100644 index 0000000..502b724 --- /dev/null +++ b/test/unit/pixi-v2/textures/BaseTexture.js @@ -0,0 +1,11 @@ +describe('pixi/textures/BaseTexture', function () { + 'use strict'; + + var expect = chai.expect; + var BaseTexture = PIXI.BaseTexture; + + it('Module exists', function () { + expect(BaseTexture).to.be.a('function'); + expect(PIXI).to.have.property('BaseTextureCache').and.to.be.an('object'); + }); +}); diff --git a/test/unit/pixi-v2/textures/RenderTexture.js b/test/unit/pixi-v2/textures/RenderTexture.js new file mode 100644 index 0000000..96acdb4 --- /dev/null +++ b/test/unit/pixi-v2/textures/RenderTexture.js @@ -0,0 +1,15 @@ +describe('pixi/textures/RenderTexture', function () { + 'use strict'; + + var expect = chai.expect; + var RenderTexture = PIXI.RenderTexture; + + it('Module exists', function () { + expect(RenderTexture).to.be.a('function'); + }); + + it('Confirm new instance', function (done) { + var texture = new RenderTexture(100, 100, new PIXI.CanvasRenderer()); + pixi_textures_RenderTexture_confirmNew(texture, done); + }); +}); diff --git a/test/unit/pixi-v2/textures/Texture.js b/test/unit/pixi-v2/textures/Texture.js new file mode 100644 index 0000000..090f64d --- /dev/null +++ b/test/unit/pixi-v2/textures/Texture.js @@ -0,0 +1,26 @@ +describe('pixi/textures/Texture', function () { + 'use strict'; + + var expect = chai.expect; + var Texture = PIXI.Texture; + + it('Module exists', function () { + expect(Texture).to.be.a('function'); + expect(PIXI).to.have.property('TextureCache').and.to.be.an('object'); + }); + + it('Members exist', function () { + expect(Texture).itself.to.respondTo('fromImage'); + expect(Texture).itself.to.respondTo('fromFrame'); + expect(Texture).itself.to.respondTo('fromCanvas'); + expect(Texture).itself.to.respondTo('addTextureToCache'); + expect(Texture).itself.to.respondTo('removeTextureFromCache'); + + // expect(Texture).itself.to.have.deep.property('frameUpdates.length', 0); + }); + + it('Confirm new instance', function (done) { + var texture = Texture.fromImage('/base/test/textures/bunny.png'); + pixi_textures_Texture_confirmNew(texture, done); + }); +}); diff --git a/test/unit/pixi-v2/utils/Detector.js b/test/unit/pixi-v2/utils/Detector.js new file mode 100644 index 0000000..4cf6008 --- /dev/null +++ b/test/unit/pixi-v2/utils/Detector.js @@ -0,0 +1,10 @@ +describe('pixi/utils/Detector', function () { + 'use strict'; + + var expect = chai.expect; + var autoDetectRenderer = PIXI.autoDetectRenderer; + + it('Module exists', function () { + expect(autoDetectRenderer).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/utils/EventTarget.js b/test/unit/pixi-v2/utils/EventTarget.js new file mode 100644 index 0000000..1cfc3a4 --- /dev/null +++ b/test/unit/pixi-v2/utils/EventTarget.js @@ -0,0 +1,361 @@ +describe('pixi/utils/EventTarget', function () { + 'use strict'; + + var expect = chai.expect; + + var Clazz, PClazz, obj, pobj, obj2; + beforeEach(function () { + Clazz = function () {}; + PClazz = function () {}; + + PIXI.EventTarget.mixin(Clazz.prototype); + PIXI.EventTarget.mixin(PClazz.prototype); + + obj = new Clazz(); + obj2 = new Clazz(); + pobj = new PClazz(); + + obj.parent = pobj; + obj2.parent = obj; + }); + + it('Module exists', function () { + expect(PIXI.EventTarget).to.be.an('object'); + }); + + it('Confirm new instance', function () { + pixi_utils_EventTarget_confirm(obj); + }); + + it('simple on/emit case works', function () { + var myData = {}; + + obj.on('myevent', function (event) { + pixi_utils_EventTarget_Event_confirm(event, obj, myData); + }); + + obj.emit('myevent', myData); + }); + + it('simple once case works', function () { + var called = 0; + + obj.once('myevent', function() { called++; }); + + obj.emit('myevent'); + obj.emit('myevent'); + obj.emit('myevent'); + obj.emit('myevent'); + obj.emit('myevent'); + + expect(called).to.equal(1); + }); + + it('simple off case works', function (done) { + function onMyEvent() { + done(new Error('Event listener should not have been called')); + } + + obj.on('myevent', onMyEvent); + obj.off('myevent', onMyEvent); + obj.emit('myevent'); + + done(); + }); + + it('simple propagation case works', function (done) { + var myData = {}; + + pobj.on('myevent', function () { + done(); + }); + + obj.emit('myevent'); + }); + + it('simple stopPropagation case works', function (done) { + var myData = {}; + + pobj.on('myevent', function () { + done(new Error('Event listener should not have been called on the parent element')); + }); + + obj.on('myevent', function (evt) { + evt.stopPropagation(); + }); + + obj.emit('myevent'); + + done(); + }); + + it('simple stopImmediatePropagation case works', function (done) { + var myData = {}; + + pobj.on('myevent', function () { + done(new Error('Event listener should not have been called on the parent')); + }); + + obj.on('myevent', function (evt) { + evt.stopImmediatePropagation(); + }); + + obj.on('myevent', function () { + done(new Error('Event listener should not have been called on the second')); + }); + + obj.emit('myevent'); + + done(); + }); + + it('multiple dispatches work properly', function () { + var called = 0; + + function onMyEvent() { + called++; + } + + obj.on('myevent', onMyEvent); + obj.emit('myevent'); + obj.emit('myevent'); + obj.emit('myevent'); + obj.emit('myevent'); + + expect(called).to.equal(4); + }); + + it('multiple events work properly', function () { + var called = 0; + + function onMyEvent() { + called++; + } + + obj.on('myevent1', onMyEvent); + obj.on('myevent2', onMyEvent); + obj.on('myevent3', onMyEvent); + obj.emit('myevent1'); + obj.emit('myevent2'); + obj.emit('myevent3'); + + expect(called).to.equal(3); + }); + + it('multiple events one removed works properly', function () { + var called = 0; + + function onMyEvent() { + called++; + } + + obj.on('myevent1', onMyEvent); + obj.on('myevent2', onMyEvent); + obj.on('myevent3', onMyEvent); + + obj.emit('myevent1'); + obj.emit('myevent2'); + obj.emit('myevent3'); + + obj.off('myevent2', onMyEvent); + + obj.emit('myevent1'); + obj.emit('myevent2'); + obj.emit('myevent3'); + + expect(called).to.equal(5); + }); + + it('multiple handlers for one event with some removed', function () { + var called = 0; + + var onMyEvent = function () { + called++; + }, + onMyEvent2 = function () { + called++; + }; + + // add 2 handlers and confirm they both get called + obj.on('myevent', onMyEvent); + obj.on('myevent', onMyEvent); + obj.on('myevent', onMyEvent2); + obj.on('myevent', onMyEvent2); + + obj.emit('myevent'); + + expect(called).to.equal(4); + + // remove one of the handlers, emit again, then ensure 1 more call is made + obj.off('myevent', onMyEvent); + + obj.emit('myevent'); + + expect(called).to.equal(6); + }); + + it('calls to off without a handler do nothing', function () { + var called = 0; + + var onMyEvent = function () { + called++; + }; + + obj.on('myevent', onMyEvent); + obj.on('myevent', onMyEvent); + + obj.emit('myevent'); + + expect(called).to.equal(2); + + obj.off('myevent'); + + obj.emit('myevent'); + + expect(called).to.equal(4); + + obj.off('myevent', onMyEvent); + + obj.emit('myevent'); + + expect(called).to.equal(4); + }); + + it('handles multiple instances with the same prototype', function () { + var called = 0; + + function onMyEvent(e) { + called++; + } + + obj.on('myevent1', onMyEvent); + obj.on('myevent2', onMyEvent); + + obj2.istwo = true; + obj2.on('myevent1', onMyEvent); + obj2.on('myevent2', onMyEvent); + + obj.emit('myevent1'); + obj.emit('myevent2'); + obj2.emit('myevent1'); + obj2.emit('myevent2'); + + //we emit 4 times, but since obj2 is a child of obj the event should bubble + //up to obj and show up there as well. So the obj2.emit() calls each increment + //the counter twice. + expect(called).to.equal(6); + }); + + it('is backwards compatible with older .dispatchEvent({})', function () { + var called = 0, + data = { + some: 'thing', + hello: true + }; + + function onMyEvent(event) { + pixi_utils_EventTarget_Event_confirm(event, obj, data); + + called++; + } + + obj.on('myevent1', onMyEvent); + obj.on('myevent2', onMyEvent); + obj.on('myevent3', onMyEvent); + + data.type = 'myevent1'; + obj.emit(data); + + data.type = 'myevent2'; + obj.emit(data); + + data.type = 'myevent3'; + obj.emit(data); + + obj.off('myevent2', onMyEvent); + + data.type = 'myevent1'; + obj.emit(data); + + data.type = 'myevent2'; + obj.emit(data); + + data.type = 'myevent3'; + obj.emit(data); + + expect(called).to.equal(5); + }); + + it('is backwards compatible with older .call(this)', function () { + var Fn = function() { + PIXI.EventTarget.call(this); + }, + o = new Fn(); + + pixi_utils_EventTarget_confirm(o); + }); + + it('is backwards compatible with older .addEventListener("")', function () { + var called = 0, + data = { + some: 'thing', + hello: true + }; + + function onMyEvent(event) { + pixi_utils_EventTarget_Event_confirm(event, obj, data); + + called++; + } + + obj.addEventListener('myevent1', onMyEvent); + obj.addEventListener('myevent2', onMyEvent); + obj.addEventListener('myevent3', onMyEvent); + + data.type = 'myevent1'; + obj.emit(data); + + data.type = 'myevent2'; + obj.emit(data); + + data.type = 'myevent3'; + obj.emit(data); + + obj.off('myevent2', onMyEvent); + + data.type = 'myevent1'; + obj.emit(data); + + data.type = 'myevent2'; + obj.emit(data); + + data.type = 'myevent3'; + obj.emit(data); + + expect(called).to.equal(5); + }); + + it('event remove during emit call properly', function () { + var called = 0; + + function cb1() { + called++; + obj.off('myevent', cb1); + } + function cb2() { + called++; + obj.off('myevent', cb2); + } + function cb3() { + called++; + obj.off('myevent', cb3); + } + + obj.on('myevent', cb1); + obj.on('myevent', cb2); + obj.on('myevent', cb3); + obj.emit('myevent', ''); + + expect(called).to.equal(3); + }); +}); diff --git a/test/unit/pixi-v2/utils/Polyk.js b/test/unit/pixi-v2/utils/Polyk.js new file mode 100644 index 0000000..dfc7128 --- /dev/null +++ b/test/unit/pixi-v2/utils/Polyk.js @@ -0,0 +1,14 @@ +describe('pixi/utils/Polyk', function () { + 'use strict'; + + var expect = chai.expect; + var PolyK = PIXI.PolyK; + + it('Module exists', function () { + expect(PolyK).to.be.an('object'); + }); + + it('Members exist', function () { + expect(PolyK).to.respondTo('Triangulate'); + }); +}); diff --git a/test/unit/pixi-v2/utils/Utils.js b/test/unit/pixi-v2/utils/Utils.js new file mode 100644 index 0000000..c97b3c6 --- /dev/null +++ b/test/unit/pixi-v2/utils/Utils.js @@ -0,0 +1,17 @@ +describe('Utils', function () { + 'use strict'; + + var expect = chai.expect; + + it('requestAnimationFrame exists', function () { + expect(global).to.respondTo('requestAnimationFrame'); + }); + + it('cancelAnimationFrame exists', function () { + expect(global).to.respondTo('cancelAnimationFrame'); + }); + + it('requestAnimFrame exists', function () { + expect(global).to.respondTo('requestAnimFrame'); + }); +}); diff --git a/test/unit/pixi/InteractionManager.js b/test/unit/pixi/InteractionManager.js deleted file mode 100644 index ed3001f..0000000 --- a/test/unit/pixi/InteractionManager.js +++ /dev/null @@ -1,10 +0,0 @@ -describe('pixi/InteractionManager', function () { - 'use strict'; - - var expect = chai.expect; - var InteractionManager = PIXI.InteractionManager; - - it('Module exists', function () { - expect(InteractionManager).to.be.a('function'); - }); -}); diff --git a/test/unit/pixi/Pixi.js b/test/unit/pixi/Pixi.js deleted file mode 100644 index 27debc1..0000000 --- a/test/unit/pixi/Pixi.js +++ /dev/null @@ -1,9 +0,0 @@ -describe('pixi/Pixi', function () { - 'use strict'; - - var expect = chai.expect; - - it('Module exists', function () { - expect(global).to.have.property('PIXI').and.to.be.an('object'); - }); -}); diff --git a/test/unit/pixi/core/Circle.js b/test/unit/pixi/core/Circle.js deleted file mode 100644 index fbcfa17..0000000 --- a/test/unit/pixi/core/Circle.js +++ /dev/null @@ -1,21 +0,0 @@ -describe('pixi/core/Circle', function () { - 'use strict'; - - var expect = chai.expect; - var Circle = PIXI.Circle; - - it('Module exists', function () { - expect(Circle).to.be.a('function'); - }); - - it('Confirm new instance', function () { - var obj = new Circle(); - pixi_core_Circle_confirmNewCircle(obj); - }); - - it("getBounds should return Rectangle that bounds the circle", function() { - var obj = new Circle(100, 250, 50); - var bounds = obj.getBounds(); - pixi_core_Circle_isBoundedByRectangle(obj, bounds); - }); -}); diff --git a/test/unit/pixi/core/Ellipse.js b/test/unit/pixi/core/Ellipse.js deleted file mode 100644 index 026b56f..0000000 --- a/test/unit/pixi/core/Ellipse.js +++ /dev/null @@ -1,24 +0,0 @@ -describe('pixi/core/Ellipse', function () { - 'use strict'; - - var expect = chai.expect; - var Ellipse = PIXI.Ellipse; - - it('Module exists', function () { - expect(Ellipse).to.be.a('function'); - }); - - it('Confirm new instance', function () { - var obj = new Ellipse(); - - expect(obj).to.be.an.instanceof(Ellipse); - expect(obj).to.respondTo('clone'); - expect(obj).to.respondTo('contains'); - expect(obj).to.respondTo('getBounds'); - - expect(obj).to.have.property('x', 0); - expect(obj).to.have.property('y', 0); - expect(obj).to.have.property('width', 0); - expect(obj).to.have.property('height', 0); - }); -}); diff --git a/test/unit/pixi/core/Matrix.js b/test/unit/pixi/core/Matrix.js deleted file mode 100644 index da75e2e..0000000 --- a/test/unit/pixi/core/Matrix.js +++ /dev/null @@ -1,14 +0,0 @@ -describe('pixi/core/Matrix', function () { - 'use strict'; - - var expect = chai.expect; - - it('Matrix exists', function () { - expect(PIXI.Matrix).to.be.an('function'); - }); - - it('Confirm new Matrix', function () { - var matrix = new PIXI.Matrix(); - pixi_core_Matrix_confirmNewMatrix(matrix); - }); -}); diff --git a/test/unit/pixi/core/Point.js b/test/unit/pixi/core/Point.js deleted file mode 100644 index c4d5163..0000000 --- a/test/unit/pixi/core/Point.js +++ /dev/null @@ -1,15 +0,0 @@ -describe('pixi/core/Point', function () { - 'use strict'; - - var expect = chai.expect; - var Point = PIXI.Point; - - it('Module exists', function () { - expect(Point).to.be.a('function'); - }); - - it('Confirm new instance', function () { - var obj = new Point(); - pixi_core_Point_confirm(obj, 0, 0); - }); -}); diff --git a/test/unit/pixi/core/Polygon.js b/test/unit/pixi/core/Polygon.js deleted file mode 100644 index dc8c918..0000000 --- a/test/unit/pixi/core/Polygon.js +++ /dev/null @@ -1,20 +0,0 @@ -describe('pixi/core/Polygon', function () { - 'use strict'; - - var expect = chai.expect; - var Polygon = PIXI.Polygon; - - it('Module exists', function () { - expect(Polygon).to.be.a('function'); - }); - - it('Confirm new instance', function () { - var obj = new Polygon(); - - expect(obj).to.be.an.instanceof(Polygon); - expect(obj).to.respondTo('clone'); - expect(obj).to.respondTo('contains'); - - expect(obj).to.have.deep.property('points.length', 0); - }); -}); diff --git a/test/unit/pixi/core/Rectangle.js b/test/unit/pixi/core/Rectangle.js deleted file mode 100644 index d43316e..0000000 --- a/test/unit/pixi/core/Rectangle.js +++ /dev/null @@ -1,15 +0,0 @@ -describe('pixi/core/Rectangle', function () { - 'use strict'; - - var expect = chai.expect; - var Rectangle = PIXI.Rectangle; - - it('Module exists', function () { - expect(Rectangle).to.be.a('function'); - }); - - it('Confirm new instance', function () { - var rect = new Rectangle(); - pixi_core_Rectangle_confirm(rect, 0, 0, 0, 0); - }); -}); diff --git a/test/unit/pixi/display/DisplayObject.js b/test/unit/pixi/display/DisplayObject.js deleted file mode 100644 index 044acf8..0000000 --- a/test/unit/pixi/display/DisplayObject.js +++ /dev/null @@ -1,21 +0,0 @@ -describe('pixi/display/DisplayObject', function () { - 'use strict'; - - var expect = chai.expect; - var DisplayObject = PIXI.DisplayObject; - - it('Module exists', function () { - expect(DisplayObject).to.be.a('function'); - // expect(PIXI).to.have.property('visibleCount', 0); - }); - - it('Confirm new instance', function () { - var obj = new DisplayObject(); - - pixi_display_DisplayObject_confirmNew(obj); - expect(obj).to.have.property('hitArea', null); - expect(obj).to.have.property('interactive', false); - expect(obj).to.have.property('renderable', false); - expect(obj).to.have.property('stage', null); - }); -}); diff --git a/test/unit/pixi/display/DisplayObjectContainer.js b/test/unit/pixi/display/DisplayObjectContainer.js deleted file mode 100644 index 15a3376..0000000 --- a/test/unit/pixi/display/DisplayObjectContainer.js +++ /dev/null @@ -1,67 +0,0 @@ -describe('pixi/display/DisplayObjectContainer', function () { - 'use strict'; - - var expect = chai.expect; - var DisplayObjectContainer = PIXI.DisplayObjectContainer; - - it('Module exists', function () { - expect(DisplayObjectContainer).to.be.a('function'); - }); - - it('Confirm new instance', function () { - var obj = new DisplayObjectContainer(); - - pixi_display_DisplayObjectContainer_confirmNew(obj); - expect(obj).to.have.property('hitArea', null); - expect(obj).to.have.property('interactive', false); - expect(obj).to.have.property('renderable', false); - expect(obj).to.have.property('stage', null); - }); - - it('Gets child index', function() { - var container = new PIXI.DisplayObjectContainer(); - var children = []; - for (var i = 0; i < 10; i++) { - var child = new PIXI.DisplayObject(); - children.push(child); - container.addChild(child); - } - - for (i = 0; i < children.length; i++) { - expect(i).to.eql(container.getChildIndex(children[i])); - } - }); - - it('throws error when trying to get index of not a child', function() { - var container = new PIXI.DisplayObjectContainer(); - var child = new PIXI.DisplayObject(); - - expect(function() { container.getChildIndex(child); }).to.throw(); - }); - - it('Sets child index', function() { - var container = new PIXI.DisplayObjectContainer(); - var children = []; - - for (var i = 0; i < 10; i++) { - var child = new PIXI.DisplayObject(); - children.push(child); - container.addChild(child); - } - children.reverse(); - - for (i = 0; i < children.length; i++) { - container.setChildIndex(children[i], i); - expect(i).to.eql(container.getChildIndex(children[i])); - } - }); - - it('throws error when trying to set incorect index', function() { - var container = new PIXI.DisplayObjectContainer(); - var child = new PIXI.DisplayObject(); - container.addChild(child); - - expect(function() { container.setChildIndex(child, -1); }).to.throw(); - expect(function() { container.setChildIndex(child, 1); }).to.throw(); - }); -}); diff --git a/test/unit/pixi/display/MovieClip.js b/test/unit/pixi/display/MovieClip.js deleted file mode 100644 index f3c6c6a..0000000 --- a/test/unit/pixi/display/MovieClip.js +++ /dev/null @@ -1,33 +0,0 @@ -describe('pixi/display/MovieClip', function () { - 'use strict'; - - var expect = chai.expect; - var MovieClip = PIXI.MovieClip; - var Texture = PIXI.Texture; - - it('Module exists', function () { - expect(MovieClip).to.be.a('function'); - }); - - it('Confirm new instance', function (done) { - var texture = Texture.fromImage('/base/test/textures/SpriteSheet-Explosion.png'); - var obj = new MovieClip([texture]); - - pixi_display_Sprite_confirmNew(obj, done); - - expect(obj).to.be.an.instanceof(MovieClip); - expect(obj).to.respondTo('stop'); - expect(obj).to.respondTo('play'); - expect(obj).to.respondTo('gotoAndStop'); - expect(obj).to.respondTo('gotoAndPlay'); - expect(obj).to.respondTo('updateTransform'); - - expect(obj).to.have.deep.property('textures.length', 1); - expect(obj).to.have.deep.property('textures[0]', texture); - expect(obj).to.have.property('animationSpeed', 1); - expect(obj).to.have.property('loop', true); - expect(obj).to.have.property('onComplete', null); - expect(obj).to.have.property('currentFrame', 0); - expect(obj).to.have.property('playing', false); - }); -}); diff --git a/test/unit/pixi/display/Sprite.js b/test/unit/pixi/display/Sprite.js deleted file mode 100644 index 30c8076..0000000 --- a/test/unit/pixi/display/Sprite.js +++ /dev/null @@ -1,28 +0,0 @@ -describe('pixi/display/Sprite', function () { - 'use strict'; - - var expect = chai.expect; - var Sprite = PIXI.Sprite; - var Texture = PIXI.Texture; - - it('Module exists', function () { - expect(Sprite).to.be.a('function'); - expect(PIXI).to.have.deep.property('blendModes.NORMAL', 0); - expect(PIXI).to.have.deep.property('blendModes.ADD', 1); - expect(PIXI).to.have.deep.property('blendModes.MULTIPLY', 2); - expect(PIXI).to.have.deep.property('blendModes.SCREEN', 3); - }); - - - it('Members exist', function () { - expect(Sprite).itself.to.respondTo('fromImage'); - expect(Sprite).itself.to.respondTo('fromFrame'); - }); - - it('Confirm new instance', function (done) { - var texture = Texture.fromImage('/base/test/textures/SpriteSheet-Aliens.png'); - var obj = new Sprite(texture); - - pixi_display_Sprite_confirmNew(obj, done); - }); -}); diff --git a/test/unit/pixi/display/Stage.js b/test/unit/pixi/display/Stage.js deleted file mode 100644 index 6974c2e..0000000 --- a/test/unit/pixi/display/Stage.js +++ /dev/null @@ -1,49 +0,0 @@ -describe('pixi/display/Stage', function () { - 'use strict'; - - var expect = chai.expect; - var Stage = PIXI.Stage; - var InteractionManager = PIXI.InteractionManager; - var Rectangle = PIXI.Rectangle; - - it('Module exists', function () { - expect(Stage).to.be.a('function'); - }); - - it('Confirm new instance', function () { - var obj = new Stage(null, true); - - pixi_display_DisplayObjectContainer_confirmNew(obj); - - expect(obj).to.be.an.instanceof(Stage); - expect(obj).to.respondTo('updateTransform'); - expect(obj).to.respondTo('setBackgroundColor'); - expect(obj).to.respondTo('getMousePosition'); - // FIXME: duplicate member in DisplayObject - pixi_core_Matrix_confirmNewMatrix(obj.worldTransform); - // FIXME: convert arg to bool in constructor - expect(obj).to.have.property('interactive', true); - - expect(obj).to.have.property('interactionManager') - .and.to.be.an.instanceof(InteractionManager) - .and.to.have.property('stage', obj); - - expect(obj).to.have.property('dirty', true); - - expect(obj).to.have.property('stage', obj); - - expect(obj).to.have.property('hitArea') - .and.to.be.an.instanceof(Rectangle); - pixi_core_Rectangle_confirm(obj.hitArea, 0, 0, 100000, 100000); - - expect(obj).to.have.property('backgroundColor', 0x000000); - expect(obj).to.have.deep.property('backgroundColorSplit.length', 3); - expect(obj).to.have.deep.property('backgroundColorSplit[0]', 0); - expect(obj).to.have.deep.property('backgroundColorSplit[1]', 0); - expect(obj).to.have.deep.property('backgroundColorSplit[2]', 0); - expect(obj).to.have.property('backgroundColorString', '#000000'); - - - expect(obj).to.have.property('worldVisible', true); - }); -}); diff --git a/test/unit/pixi-v2/InteractionManager.js b/test/unit/pixi-v2/InteractionManager.js new file mode 100644 index 0000000..ed3001f --- /dev/null +++ b/test/unit/pixi-v2/InteractionManager.js @@ -0,0 +1,10 @@ +describe('pixi/InteractionManager', function () { + 'use strict'; + + var expect = chai.expect; + var InteractionManager = PIXI.InteractionManager; + + it('Module exists', function () { + expect(InteractionManager).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/Pixi.js b/test/unit/pixi-v2/Pixi.js new file mode 100644 index 0000000..27debc1 --- /dev/null +++ b/test/unit/pixi-v2/Pixi.js @@ -0,0 +1,9 @@ +describe('pixi/Pixi', function () { + 'use strict'; + + var expect = chai.expect; + + it('Module exists', function () { + expect(global).to.have.property('PIXI').and.to.be.an('object'); + }); +}); diff --git a/test/unit/pixi-v2/core/Circle.js b/test/unit/pixi-v2/core/Circle.js new file mode 100644 index 0000000..fbcfa17 --- /dev/null +++ b/test/unit/pixi-v2/core/Circle.js @@ -0,0 +1,21 @@ +describe('pixi/core/Circle', function () { + 'use strict'; + + var expect = chai.expect; + var Circle = PIXI.Circle; + + it('Module exists', function () { + expect(Circle).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Circle(); + pixi_core_Circle_confirmNewCircle(obj); + }); + + it("getBounds should return Rectangle that bounds the circle", function() { + var obj = new Circle(100, 250, 50); + var bounds = obj.getBounds(); + pixi_core_Circle_isBoundedByRectangle(obj, bounds); + }); +}); diff --git a/test/unit/pixi-v2/core/Ellipse.js b/test/unit/pixi-v2/core/Ellipse.js new file mode 100644 index 0000000..026b56f --- /dev/null +++ b/test/unit/pixi-v2/core/Ellipse.js @@ -0,0 +1,24 @@ +describe('pixi/core/Ellipse', function () { + 'use strict'; + + var expect = chai.expect; + var Ellipse = PIXI.Ellipse; + + it('Module exists', function () { + expect(Ellipse).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Ellipse(); + + expect(obj).to.be.an.instanceof(Ellipse); + expect(obj).to.respondTo('clone'); + expect(obj).to.respondTo('contains'); + expect(obj).to.respondTo('getBounds'); + + expect(obj).to.have.property('x', 0); + expect(obj).to.have.property('y', 0); + expect(obj).to.have.property('width', 0); + expect(obj).to.have.property('height', 0); + }); +}); diff --git a/test/unit/pixi-v2/core/Matrix.js b/test/unit/pixi-v2/core/Matrix.js new file mode 100644 index 0000000..da75e2e --- /dev/null +++ b/test/unit/pixi-v2/core/Matrix.js @@ -0,0 +1,14 @@ +describe('pixi/core/Matrix', function () { + 'use strict'; + + var expect = chai.expect; + + it('Matrix exists', function () { + expect(PIXI.Matrix).to.be.an('function'); + }); + + it('Confirm new Matrix', function () { + var matrix = new PIXI.Matrix(); + pixi_core_Matrix_confirmNewMatrix(matrix); + }); +}); diff --git a/test/unit/pixi-v2/core/Point.js b/test/unit/pixi-v2/core/Point.js new file mode 100644 index 0000000..c4d5163 --- /dev/null +++ b/test/unit/pixi-v2/core/Point.js @@ -0,0 +1,15 @@ +describe('pixi/core/Point', function () { + 'use strict'; + + var expect = chai.expect; + var Point = PIXI.Point; + + it('Module exists', function () { + expect(Point).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Point(); + pixi_core_Point_confirm(obj, 0, 0); + }); +}); diff --git a/test/unit/pixi-v2/core/Polygon.js b/test/unit/pixi-v2/core/Polygon.js new file mode 100644 index 0000000..dc8c918 --- /dev/null +++ b/test/unit/pixi-v2/core/Polygon.js @@ -0,0 +1,20 @@ +describe('pixi/core/Polygon', function () { + 'use strict'; + + var expect = chai.expect; + var Polygon = PIXI.Polygon; + + it('Module exists', function () { + expect(Polygon).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Polygon(); + + expect(obj).to.be.an.instanceof(Polygon); + expect(obj).to.respondTo('clone'); + expect(obj).to.respondTo('contains'); + + expect(obj).to.have.deep.property('points.length', 0); + }); +}); diff --git a/test/unit/pixi-v2/core/Rectangle.js b/test/unit/pixi-v2/core/Rectangle.js new file mode 100644 index 0000000..d43316e --- /dev/null +++ b/test/unit/pixi-v2/core/Rectangle.js @@ -0,0 +1,15 @@ +describe('pixi/core/Rectangle', function () { + 'use strict'; + + var expect = chai.expect; + var Rectangle = PIXI.Rectangle; + + it('Module exists', function () { + expect(Rectangle).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var rect = new Rectangle(); + pixi_core_Rectangle_confirm(rect, 0, 0, 0, 0); + }); +}); diff --git a/test/unit/pixi-v2/display/DisplayObject.js b/test/unit/pixi-v2/display/DisplayObject.js new file mode 100644 index 0000000..044acf8 --- /dev/null +++ b/test/unit/pixi-v2/display/DisplayObject.js @@ -0,0 +1,21 @@ +describe('pixi/display/DisplayObject', function () { + 'use strict'; + + var expect = chai.expect; + var DisplayObject = PIXI.DisplayObject; + + it('Module exists', function () { + expect(DisplayObject).to.be.a('function'); + // expect(PIXI).to.have.property('visibleCount', 0); + }); + + it('Confirm new instance', function () { + var obj = new DisplayObject(); + + pixi_display_DisplayObject_confirmNew(obj); + expect(obj).to.have.property('hitArea', null); + expect(obj).to.have.property('interactive', false); + expect(obj).to.have.property('renderable', false); + expect(obj).to.have.property('stage', null); + }); +}); diff --git a/test/unit/pixi-v2/display/DisplayObjectContainer.js b/test/unit/pixi-v2/display/DisplayObjectContainer.js new file mode 100644 index 0000000..15a3376 --- /dev/null +++ b/test/unit/pixi-v2/display/DisplayObjectContainer.js @@ -0,0 +1,67 @@ +describe('pixi/display/DisplayObjectContainer', function () { + 'use strict'; + + var expect = chai.expect; + var DisplayObjectContainer = PIXI.DisplayObjectContainer; + + it('Module exists', function () { + expect(DisplayObjectContainer).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new DisplayObjectContainer(); + + pixi_display_DisplayObjectContainer_confirmNew(obj); + expect(obj).to.have.property('hitArea', null); + expect(obj).to.have.property('interactive', false); + expect(obj).to.have.property('renderable', false); + expect(obj).to.have.property('stage', null); + }); + + it('Gets child index', function() { + var container = new PIXI.DisplayObjectContainer(); + var children = []; + for (var i = 0; i < 10; i++) { + var child = new PIXI.DisplayObject(); + children.push(child); + container.addChild(child); + } + + for (i = 0; i < children.length; i++) { + expect(i).to.eql(container.getChildIndex(children[i])); + } + }); + + it('throws error when trying to get index of not a child', function() { + var container = new PIXI.DisplayObjectContainer(); + var child = new PIXI.DisplayObject(); + + expect(function() { container.getChildIndex(child); }).to.throw(); + }); + + it('Sets child index', function() { + var container = new PIXI.DisplayObjectContainer(); + var children = []; + + for (var i = 0; i < 10; i++) { + var child = new PIXI.DisplayObject(); + children.push(child); + container.addChild(child); + } + children.reverse(); + + for (i = 0; i < children.length; i++) { + container.setChildIndex(children[i], i); + expect(i).to.eql(container.getChildIndex(children[i])); + } + }); + + it('throws error when trying to set incorect index', function() { + var container = new PIXI.DisplayObjectContainer(); + var child = new PIXI.DisplayObject(); + container.addChild(child); + + expect(function() { container.setChildIndex(child, -1); }).to.throw(); + expect(function() { container.setChildIndex(child, 1); }).to.throw(); + }); +}); diff --git a/test/unit/pixi-v2/display/MovieClip.js b/test/unit/pixi-v2/display/MovieClip.js new file mode 100644 index 0000000..f3c6c6a --- /dev/null +++ b/test/unit/pixi-v2/display/MovieClip.js @@ -0,0 +1,33 @@ +describe('pixi/display/MovieClip', function () { + 'use strict'; + + var expect = chai.expect; + var MovieClip = PIXI.MovieClip; + var Texture = PIXI.Texture; + + it('Module exists', function () { + expect(MovieClip).to.be.a('function'); + }); + + it('Confirm new instance', function (done) { + var texture = Texture.fromImage('/base/test/textures/SpriteSheet-Explosion.png'); + var obj = new MovieClip([texture]); + + pixi_display_Sprite_confirmNew(obj, done); + + expect(obj).to.be.an.instanceof(MovieClip); + expect(obj).to.respondTo('stop'); + expect(obj).to.respondTo('play'); + expect(obj).to.respondTo('gotoAndStop'); + expect(obj).to.respondTo('gotoAndPlay'); + expect(obj).to.respondTo('updateTransform'); + + expect(obj).to.have.deep.property('textures.length', 1); + expect(obj).to.have.deep.property('textures[0]', texture); + expect(obj).to.have.property('animationSpeed', 1); + expect(obj).to.have.property('loop', true); + expect(obj).to.have.property('onComplete', null); + expect(obj).to.have.property('currentFrame', 0); + expect(obj).to.have.property('playing', false); + }); +}); diff --git a/test/unit/pixi-v2/display/Sprite.js b/test/unit/pixi-v2/display/Sprite.js new file mode 100644 index 0000000..30c8076 --- /dev/null +++ b/test/unit/pixi-v2/display/Sprite.js @@ -0,0 +1,28 @@ +describe('pixi/display/Sprite', function () { + 'use strict'; + + var expect = chai.expect; + var Sprite = PIXI.Sprite; + var Texture = PIXI.Texture; + + it('Module exists', function () { + expect(Sprite).to.be.a('function'); + expect(PIXI).to.have.deep.property('blendModes.NORMAL', 0); + expect(PIXI).to.have.deep.property('blendModes.ADD', 1); + expect(PIXI).to.have.deep.property('blendModes.MULTIPLY', 2); + expect(PIXI).to.have.deep.property('blendModes.SCREEN', 3); + }); + + + it('Members exist', function () { + expect(Sprite).itself.to.respondTo('fromImage'); + expect(Sprite).itself.to.respondTo('fromFrame'); + }); + + it('Confirm new instance', function (done) { + var texture = Texture.fromImage('/base/test/textures/SpriteSheet-Aliens.png'); + var obj = new Sprite(texture); + + pixi_display_Sprite_confirmNew(obj, done); + }); +}); diff --git a/test/unit/pixi-v2/display/Stage.js b/test/unit/pixi-v2/display/Stage.js new file mode 100644 index 0000000..6974c2e --- /dev/null +++ b/test/unit/pixi-v2/display/Stage.js @@ -0,0 +1,49 @@ +describe('pixi/display/Stage', function () { + 'use strict'; + + var expect = chai.expect; + var Stage = PIXI.Stage; + var InteractionManager = PIXI.InteractionManager; + var Rectangle = PIXI.Rectangle; + + it('Module exists', function () { + expect(Stage).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Stage(null, true); + + pixi_display_DisplayObjectContainer_confirmNew(obj); + + expect(obj).to.be.an.instanceof(Stage); + expect(obj).to.respondTo('updateTransform'); + expect(obj).to.respondTo('setBackgroundColor'); + expect(obj).to.respondTo('getMousePosition'); + // FIXME: duplicate member in DisplayObject + pixi_core_Matrix_confirmNewMatrix(obj.worldTransform); + // FIXME: convert arg to bool in constructor + expect(obj).to.have.property('interactive', true); + + expect(obj).to.have.property('interactionManager') + .and.to.be.an.instanceof(InteractionManager) + .and.to.have.property('stage', obj); + + expect(obj).to.have.property('dirty', true); + + expect(obj).to.have.property('stage', obj); + + expect(obj).to.have.property('hitArea') + .and.to.be.an.instanceof(Rectangle); + pixi_core_Rectangle_confirm(obj.hitArea, 0, 0, 100000, 100000); + + expect(obj).to.have.property('backgroundColor', 0x000000); + expect(obj).to.have.deep.property('backgroundColorSplit.length', 3); + expect(obj).to.have.deep.property('backgroundColorSplit[0]', 0); + expect(obj).to.have.deep.property('backgroundColorSplit[1]', 0); + expect(obj).to.have.deep.property('backgroundColorSplit[2]', 0); + expect(obj).to.have.property('backgroundColorString', '#000000'); + + + expect(obj).to.have.property('worldVisible', true); + }); +}); diff --git a/test/unit/pixi-v2/extras/Rope.js b/test/unit/pixi-v2/extras/Rope.js new file mode 100644 index 0000000..05885ac --- /dev/null +++ b/test/unit/pixi-v2/extras/Rope.js @@ -0,0 +1,31 @@ +describe('pixi/extras/Rope', function () { + 'use strict'; + + var expect = chai.expect; + var Rope = PIXI.Rope; + var Texture = PIXI.Texture; + var Point = PIXI.Point; + + it('Module exists', function () { + expect(Rope).to.be.a('function'); + }); + + it('Confirm new instance', function () { + + var texture = Texture.fromImage('/base/test/textures/bunny.png'); + + // TODO-Alvin + // Same as Strip + + // var obj = new Rope(texture, [new Point(), new Point(5, 10), new Point(10, 20)]); + + // pixi_extras_Strip_confirmNew(obj); + + // expect(obj).to.be.an.instanceof(Rope); + // expect(obj).to.respondTo('refresh'); + // expect(obj).to.respondTo('updateTransform'); + // expect(obj).to.respondTo('setTexture'); + + // TODO: Test properties + }); +}); diff --git a/test/unit/pixi-v2/extras/Spine.js b/test/unit/pixi-v2/extras/Spine.js new file mode 100644 index 0000000..0708bc0 --- /dev/null +++ b/test/unit/pixi-v2/extras/Spine.js @@ -0,0 +1,10 @@ +describe('pixi/extras/Spine', function () { + 'use strict'; + + var expect = chai.expect; + var Spine = PIXI.Spine; + + it('Module exists', function () { + expect(Spine).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/extras/Strip.js b/test/unit/pixi-v2/extras/Strip.js new file mode 100644 index 0000000..230af90 --- /dev/null +++ b/test/unit/pixi-v2/extras/Strip.js @@ -0,0 +1,26 @@ +describe('pixi/extras/Strip', function () { + 'use strict'; + + var expect = chai.expect; + var Strip = PIXI.Strip; + var Texture = PIXI.Texture; + + it('Module exists', function () { + expect(Strip).to.be.a('function'); + }); + + it('Confirm new instance', function () { + + + // TODO-Alvin + // We tweaked it to make it pass the tests, but the whole strip class needs + // to be re-coded + + var texture = Texture.fromImage('/base/test/textures/bunny.png'); + + // var obj = new Strip(texture, 20, 10000); + + + // pixi_extras_Strip_confirmNew(obj); + }); +}); diff --git a/test/unit/pixi-v2/extras/TilingSprite.js b/test/unit/pixi-v2/extras/TilingSprite.js new file mode 100644 index 0000000..56aea14 --- /dev/null +++ b/test/unit/pixi-v2/extras/TilingSprite.js @@ -0,0 +1,24 @@ +describe('pixi/extras/TilingSprite', function () { + 'use strict'; + + var expect = chai.expect; + var TilingSprite = PIXI.TilingSprite; + var Texture = PIXI.Texture; + + it('Module exists', function () { + expect(TilingSprite).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var texture = Texture.fromImage('/base/test/textures/bunny.png'); + var obj = new TilingSprite(texture, 6000, 12000); + + pixi_display_DisplayObjectContainer_confirmNew(obj); + + expect(obj).to.be.an.instanceof(TilingSprite); + expect(obj).to.respondTo('setTexture'); + expect(obj).to.respondTo('onTextureUpdate'); + + // TODO: Test properties + }); +}); diff --git a/test/unit/pixi-v2/filters/FilterBlock.js b/test/unit/pixi-v2/filters/FilterBlock.js new file mode 100644 index 0000000..870cec0 --- /dev/null +++ b/test/unit/pixi-v2/filters/FilterBlock.js @@ -0,0 +1,10 @@ +describe('pixi/filters/FilterBlock', function () { + 'use strict'; + + var expect = chai.expect; + var FilterBlock = PIXI.FilterBlock; + + it('Module exists', function () { + expect(FilterBlock).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/AssetLoader.js b/test/unit/pixi-v2/loaders/AssetLoader.js new file mode 100644 index 0000000..a0aa0b5 --- /dev/null +++ b/test/unit/pixi-v2/loaders/AssetLoader.js @@ -0,0 +1,10 @@ +describe('pixi/loaders/AssetLoader', function () { + 'use strict'; + + var expect = chai.expect; + var AssetLoader = PIXI.AssetLoader; + + it('Module exists', function () { + expect(AssetLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/BitmapFontLoader.js b/test/unit/pixi-v2/loaders/BitmapFontLoader.js new file mode 100644 index 0000000..046f018 --- /dev/null +++ b/test/unit/pixi-v2/loaders/BitmapFontLoader.js @@ -0,0 +1,9 @@ +describe('pixi/loaders/BitmapFontLoader', function () { + 'use strict'; + + var expect = chai.expect; + + it('Module exists', function () { + expect(PIXI.BitmapFontLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/ImageLoader.js b/test/unit/pixi-v2/loaders/ImageLoader.js new file mode 100644 index 0000000..8b1f556 --- /dev/null +++ b/test/unit/pixi-v2/loaders/ImageLoader.js @@ -0,0 +1,10 @@ +describe('pixi/loaders/ImageLoader', function () { + 'use strict'; + + var expect = chai.expect; + var ImageLoader = PIXI.ImageLoader; + + it('Module exists', function () { + expect(ImageLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/JsonLoader.js b/test/unit/pixi-v2/loaders/JsonLoader.js new file mode 100644 index 0000000..c577e83 --- /dev/null +++ b/test/unit/pixi-v2/loaders/JsonLoader.js @@ -0,0 +1,10 @@ +describe('pixi/loaders/JsonLoader', function () { + 'use strict'; + + var expect = chai.expect; + var JsonLoader = PIXI.JsonLoader; + + it('Module exists', function () { + expect(JsonLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/SpineLoader.js b/test/unit/pixi-v2/loaders/SpineLoader.js new file mode 100644 index 0000000..fdcc0b8 --- /dev/null +++ b/test/unit/pixi-v2/loaders/SpineLoader.js @@ -0,0 +1,10 @@ +describe('pixi/loaders/SpineLoader', function () { + 'use strict'; + + var expect = chai.expect; + var SpineLoader = PIXI.SpineLoader; + + it('Module exists', function () { + expect(SpineLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/SpriteSheetLoader.js b/test/unit/pixi-v2/loaders/SpriteSheetLoader.js new file mode 100644 index 0000000..57beb27 --- /dev/null +++ b/test/unit/pixi-v2/loaders/SpriteSheetLoader.js @@ -0,0 +1,10 @@ +describe('pixi/loaders/SpriteSheetLoader', function () { + 'use strict'; + + var expect = chai.expect; + var SpriteSheetLoader = PIXI.SpriteSheetLoader; + + it('Module exists', function () { + expect(SpriteSheetLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/primitives/Graphics.js b/test/unit/pixi-v2/primitives/Graphics.js new file mode 100644 index 0000000..f3849eb --- /dev/null +++ b/test/unit/pixi-v2/primitives/Graphics.js @@ -0,0 +1,44 @@ +describe('pixi/primitives/Graphics', function () { + 'use strict'; + + var expect = chai.expect; + var Graphics = PIXI.Graphics; + + it('Module exists', function () { + expect(Graphics).to.be.a('function'); + + expect(Graphics).itself.to.have.property('POLY', 0); + expect(Graphics).itself.to.have.property('RECT', 1); + expect(Graphics).itself.to.have.property('CIRC', 2); + expect(Graphics).itself.to.have.property('ELIP', 3); + expect(Graphics).itself.to.have.property('RREC', 4); + }); + + it('Confirm new instance', function () { + var obj = new Graphics(); + + pixi_display_DisplayObjectContainer_confirmNew(obj); + + expect(obj).to.be.an.instanceof(Graphics); + expect(obj).to.respondTo('lineStyle'); + expect(obj).to.respondTo('lineStyle'); + expect(obj).to.respondTo('moveTo'); + expect(obj).to.respondTo('lineTo'); + expect(obj).to.respondTo('beginFill'); + expect(obj).to.respondTo('endFill'); + expect(obj).to.respondTo('drawRect'); + // expect(obj).to.respondTo('drawRoundedRect'); + expect(obj).to.respondTo('drawCircle'); + expect(obj).to.respondTo('drawEllipse'); + expect(obj).to.respondTo('clear'); + + expect(obj).to.have.property('renderable', true); + expect(obj).to.have.property('fillAlpha', 1); + expect(obj).to.have.property('lineWidth', 0); + expect(obj).to.have.property('width', 0); + expect(obj).to.have.property('height', 0); + expect(obj).to.have.property('lineColor', 0); + expect(obj).to.have.deep.property('graphicsData.length', 0); + // expect(obj).to.have.deep.property('currentPath.points.length', 0); + }); +}); diff --git a/test/unit/pixi-v2/renderers/canvas/CanvasGraphics.js b/test/unit/pixi-v2/renderers/canvas/CanvasGraphics.js new file mode 100644 index 0000000..8f44472 --- /dev/null +++ b/test/unit/pixi-v2/renderers/canvas/CanvasGraphics.js @@ -0,0 +1,15 @@ +describe('renders/canvas/CanvasGraphics', function () { + 'use strict'; + + var expect = chai.expect; + var CanvasGraphics = PIXI.CanvasGraphics; + + it('Module exists', function () { + expect(CanvasGraphics).to.be.a('function'); + }); + + it('Members exist', function () { + expect(CanvasGraphics).itself.to.respondTo('renderGraphics'); + expect(CanvasGraphics).itself.to.respondTo('renderGraphicsMask'); + }); +}); diff --git a/test/unit/pixi-v2/renderers/canvas/CanvasRenderer.js b/test/unit/pixi-v2/renderers/canvas/CanvasRenderer.js new file mode 100644 index 0000000..1646444 --- /dev/null +++ b/test/unit/pixi-v2/renderers/canvas/CanvasRenderer.js @@ -0,0 +1,36 @@ +describe('renderers/canvas/CanvasRenderer', function () { + 'use strict'; + + var expect = chai.expect; + var CanvasRenderer = PIXI.CanvasRenderer; + + it('Module exists', function () { + expect(CanvasRenderer).to.be.a('function'); + }); + + describe('.autoResize', function () { + it('Should automatically resize view if enabled', function () { + var renderer = new CanvasRenderer(200, 200, { + autoResize: true + }); + + expect(renderer.view.style.width).to.equal('200px'); + }); + + it('Should not automatically resize view if disabled', function () { + var renderer = new CanvasRenderer(200, 200, { + autoResize: false + }); + + expect(renderer.view.style.width).to.equal(''); + }); + + it('Should not automatically resize view if not specified', function () { + var renderer = new CanvasRenderer(200, 200, { + resolution: 2 + }); + + expect(renderer.view.style.width).to.equal(''); + }); + }); +}); diff --git a/test/unit/pixi-v2/renderers/webgl/WebGLGraphics.js b/test/unit/pixi-v2/renderers/webgl/WebGLGraphics.js new file mode 100644 index 0000000..5867b28 --- /dev/null +++ b/test/unit/pixi-v2/renderers/webgl/WebGLGraphics.js @@ -0,0 +1,20 @@ +describe('renderers/wegbl/WebGLGraphics', function () { + 'use strict'; + + var expect = chai.expect; + var WebGLGraphics = PIXI.WebGLGraphics; + + it('Module exists', function () { + expect(WebGLGraphics).to.be.a('function'); + }); + + it('Members exist', function () { + expect(WebGLGraphics).itself.to.respondTo('renderGraphics'); + expect(WebGLGraphics).itself.to.respondTo('updateGraphics'); + expect(WebGLGraphics).itself.to.respondTo('buildRectangle'); + expect(WebGLGraphics).itself.to.respondTo('buildRoundedRectangle'); + expect(WebGLGraphics).itself.to.respondTo('buildCircle'); + expect(WebGLGraphics).itself.to.respondTo('buildLine'); + expect(WebGLGraphics).itself.to.respondTo('buildPoly'); + }); +}); diff --git a/test/unit/pixi-v2/renderers/webgl/WebGLRenderer.js b/test/unit/pixi-v2/renderers/webgl/WebGLRenderer.js new file mode 100644 index 0000000..1680a80 --- /dev/null +++ b/test/unit/pixi-v2/renderers/webgl/WebGLRenderer.js @@ -0,0 +1,49 @@ +describe('renderers/webgl/WebGLRenderer', function () { + 'use strict'; + + var expect = chai.expect; + var WebGLRenderer = PIXI.WebGLRenderer; + + it('Module exists', function () { + expect(WebGLRenderer).to.be.a('function'); + }); + + // Skip tests if WebGL is not available (WebGL not supported in Travis CI) + try { + var renderer = new WebGLRenderer(400, 300, {}); + renderer.destroy(); + } catch (error) { + return; + } + + it('Destroy renderer', function () { + var renderer = new WebGLRenderer(400, 300, {}); + renderer.destroy(); + }); + + describe('.autoResize', function () { + it('Should automatically resize view if enabled', function () { + var renderer = new WebGLRenderer(200, 200, { + autoResize: true + }); + + expect(renderer.view.style.width).to.equal('200px'); + }); + + it('Should not automatically resize view if disabled', function () { + var renderer = new WebGLRenderer(200, 200, { + autoResize: false + }); + + expect(renderer.view.style.width).to.equal(''); + }); + + it('Should not automatically resize view if not specified', function () { + var renderer = new WebGLRenderer(200, 200, { + resolution: 2 + }); + + expect(renderer.view.style.width).to.equal(''); + }); + }); +}); diff --git a/test/unit/pixi-v2/renderers/webgl/WebGLShaders.js b/test/unit/pixi-v2/renderers/webgl/WebGLShaders.js new file mode 100644 index 0000000..6e33e4f --- /dev/null +++ b/test/unit/pixi-v2/renderers/webgl/WebGLShaders.js @@ -0,0 +1,13 @@ +describe('renderers/webgl/WebGLShaders', function () { + 'use strict'; + + var expect = chai.expect; + + it('Module members exist', function () { + + expect(PIXI).to.respondTo('CompileVertexShader'); + expect(PIXI).to.respondTo('CompileFragmentShader'); + expect(PIXI).to.respondTo('_CompileShader'); + expect(PIXI).to.respondTo('compileProgram'); + }); +}); diff --git a/test/unit/pixi-v2/renderers/webgl/WebGLSpriteBatch.js b/test/unit/pixi-v2/renderers/webgl/WebGLSpriteBatch.js new file mode 100644 index 0000000..e662b63 --- /dev/null +++ b/test/unit/pixi-v2/renderers/webgl/WebGLSpriteBatch.js @@ -0,0 +1,10 @@ +describe('renderers/webgl/utils/WebGLSpriteBatch', function () { + 'use strict'; + + var expect = chai.expect; + var WebGLSpriteBatch = PIXI.WebGLSpriteBatch; + + it('Module exists', function () { + expect(WebGLSpriteBatch).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/text/BitmapText.js b/test/unit/pixi-v2/text/BitmapText.js new file mode 100644 index 0000000..9388e3d --- /dev/null +++ b/test/unit/pixi-v2/text/BitmapText.js @@ -0,0 +1,10 @@ +describe('pixi/text/BitmapText', function () { + 'use strict'; + + var expect = chai.expect; + var BitmapText = PIXI.BitmapText; + + it('Module exists', function () { + expect(BitmapText).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/text/Text.js b/test/unit/pixi-v2/text/Text.js new file mode 100644 index 0000000..9bc9ac5 --- /dev/null +++ b/test/unit/pixi-v2/text/Text.js @@ -0,0 +1,10 @@ +describe('pixi/text/Text', function () { + 'use strict'; + + var expect = chai.expect; + var Text = PIXI.Text; + + it('Module exists', function () { + expect(Text).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/textures/BaseTexture.js b/test/unit/pixi-v2/textures/BaseTexture.js new file mode 100644 index 0000000..502b724 --- /dev/null +++ b/test/unit/pixi-v2/textures/BaseTexture.js @@ -0,0 +1,11 @@ +describe('pixi/textures/BaseTexture', function () { + 'use strict'; + + var expect = chai.expect; + var BaseTexture = PIXI.BaseTexture; + + it('Module exists', function () { + expect(BaseTexture).to.be.a('function'); + expect(PIXI).to.have.property('BaseTextureCache').and.to.be.an('object'); + }); +}); diff --git a/test/unit/pixi-v2/textures/RenderTexture.js b/test/unit/pixi-v2/textures/RenderTexture.js new file mode 100644 index 0000000..96acdb4 --- /dev/null +++ b/test/unit/pixi-v2/textures/RenderTexture.js @@ -0,0 +1,15 @@ +describe('pixi/textures/RenderTexture', function () { + 'use strict'; + + var expect = chai.expect; + var RenderTexture = PIXI.RenderTexture; + + it('Module exists', function () { + expect(RenderTexture).to.be.a('function'); + }); + + it('Confirm new instance', function (done) { + var texture = new RenderTexture(100, 100, new PIXI.CanvasRenderer()); + pixi_textures_RenderTexture_confirmNew(texture, done); + }); +}); diff --git a/test/unit/pixi-v2/textures/Texture.js b/test/unit/pixi-v2/textures/Texture.js new file mode 100644 index 0000000..090f64d --- /dev/null +++ b/test/unit/pixi-v2/textures/Texture.js @@ -0,0 +1,26 @@ +describe('pixi/textures/Texture', function () { + 'use strict'; + + var expect = chai.expect; + var Texture = PIXI.Texture; + + it('Module exists', function () { + expect(Texture).to.be.a('function'); + expect(PIXI).to.have.property('TextureCache').and.to.be.an('object'); + }); + + it('Members exist', function () { + expect(Texture).itself.to.respondTo('fromImage'); + expect(Texture).itself.to.respondTo('fromFrame'); + expect(Texture).itself.to.respondTo('fromCanvas'); + expect(Texture).itself.to.respondTo('addTextureToCache'); + expect(Texture).itself.to.respondTo('removeTextureFromCache'); + + // expect(Texture).itself.to.have.deep.property('frameUpdates.length', 0); + }); + + it('Confirm new instance', function (done) { + var texture = Texture.fromImage('/base/test/textures/bunny.png'); + pixi_textures_Texture_confirmNew(texture, done); + }); +}); diff --git a/test/unit/pixi-v2/utils/Detector.js b/test/unit/pixi-v2/utils/Detector.js new file mode 100644 index 0000000..4cf6008 --- /dev/null +++ b/test/unit/pixi-v2/utils/Detector.js @@ -0,0 +1,10 @@ +describe('pixi/utils/Detector', function () { + 'use strict'; + + var expect = chai.expect; + var autoDetectRenderer = PIXI.autoDetectRenderer; + + it('Module exists', function () { + expect(autoDetectRenderer).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/utils/EventTarget.js b/test/unit/pixi-v2/utils/EventTarget.js new file mode 100644 index 0000000..1cfc3a4 --- /dev/null +++ b/test/unit/pixi-v2/utils/EventTarget.js @@ -0,0 +1,361 @@ +describe('pixi/utils/EventTarget', function () { + 'use strict'; + + var expect = chai.expect; + + var Clazz, PClazz, obj, pobj, obj2; + beforeEach(function () { + Clazz = function () {}; + PClazz = function () {}; + + PIXI.EventTarget.mixin(Clazz.prototype); + PIXI.EventTarget.mixin(PClazz.prototype); + + obj = new Clazz(); + obj2 = new Clazz(); + pobj = new PClazz(); + + obj.parent = pobj; + obj2.parent = obj; + }); + + it('Module exists', function () { + expect(PIXI.EventTarget).to.be.an('object'); + }); + + it('Confirm new instance', function () { + pixi_utils_EventTarget_confirm(obj); + }); + + it('simple on/emit case works', function () { + var myData = {}; + + obj.on('myevent', function (event) { + pixi_utils_EventTarget_Event_confirm(event, obj, myData); + }); + + obj.emit('myevent', myData); + }); + + it('simple once case works', function () { + var called = 0; + + obj.once('myevent', function() { called++; }); + + obj.emit('myevent'); + obj.emit('myevent'); + obj.emit('myevent'); + obj.emit('myevent'); + obj.emit('myevent'); + + expect(called).to.equal(1); + }); + + it('simple off case works', function (done) { + function onMyEvent() { + done(new Error('Event listener should not have been called')); + } + + obj.on('myevent', onMyEvent); + obj.off('myevent', onMyEvent); + obj.emit('myevent'); + + done(); + }); + + it('simple propagation case works', function (done) { + var myData = {}; + + pobj.on('myevent', function () { + done(); + }); + + obj.emit('myevent'); + }); + + it('simple stopPropagation case works', function (done) { + var myData = {}; + + pobj.on('myevent', function () { + done(new Error('Event listener should not have been called on the parent element')); + }); + + obj.on('myevent', function (evt) { + evt.stopPropagation(); + }); + + obj.emit('myevent'); + + done(); + }); + + it('simple stopImmediatePropagation case works', function (done) { + var myData = {}; + + pobj.on('myevent', function () { + done(new Error('Event listener should not have been called on the parent')); + }); + + obj.on('myevent', function (evt) { + evt.stopImmediatePropagation(); + }); + + obj.on('myevent', function () { + done(new Error('Event listener should not have been called on the second')); + }); + + obj.emit('myevent'); + + done(); + }); + + it('multiple dispatches work properly', function () { + var called = 0; + + function onMyEvent() { + called++; + } + + obj.on('myevent', onMyEvent); + obj.emit('myevent'); + obj.emit('myevent'); + obj.emit('myevent'); + obj.emit('myevent'); + + expect(called).to.equal(4); + }); + + it('multiple events work properly', function () { + var called = 0; + + function onMyEvent() { + called++; + } + + obj.on('myevent1', onMyEvent); + obj.on('myevent2', onMyEvent); + obj.on('myevent3', onMyEvent); + obj.emit('myevent1'); + obj.emit('myevent2'); + obj.emit('myevent3'); + + expect(called).to.equal(3); + }); + + it('multiple events one removed works properly', function () { + var called = 0; + + function onMyEvent() { + called++; + } + + obj.on('myevent1', onMyEvent); + obj.on('myevent2', onMyEvent); + obj.on('myevent3', onMyEvent); + + obj.emit('myevent1'); + obj.emit('myevent2'); + obj.emit('myevent3'); + + obj.off('myevent2', onMyEvent); + + obj.emit('myevent1'); + obj.emit('myevent2'); + obj.emit('myevent3'); + + expect(called).to.equal(5); + }); + + it('multiple handlers for one event with some removed', function () { + var called = 0; + + var onMyEvent = function () { + called++; + }, + onMyEvent2 = function () { + called++; + }; + + // add 2 handlers and confirm they both get called + obj.on('myevent', onMyEvent); + obj.on('myevent', onMyEvent); + obj.on('myevent', onMyEvent2); + obj.on('myevent', onMyEvent2); + + obj.emit('myevent'); + + expect(called).to.equal(4); + + // remove one of the handlers, emit again, then ensure 1 more call is made + obj.off('myevent', onMyEvent); + + obj.emit('myevent'); + + expect(called).to.equal(6); + }); + + it('calls to off without a handler do nothing', function () { + var called = 0; + + var onMyEvent = function () { + called++; + }; + + obj.on('myevent', onMyEvent); + obj.on('myevent', onMyEvent); + + obj.emit('myevent'); + + expect(called).to.equal(2); + + obj.off('myevent'); + + obj.emit('myevent'); + + expect(called).to.equal(4); + + obj.off('myevent', onMyEvent); + + obj.emit('myevent'); + + expect(called).to.equal(4); + }); + + it('handles multiple instances with the same prototype', function () { + var called = 0; + + function onMyEvent(e) { + called++; + } + + obj.on('myevent1', onMyEvent); + obj.on('myevent2', onMyEvent); + + obj2.istwo = true; + obj2.on('myevent1', onMyEvent); + obj2.on('myevent2', onMyEvent); + + obj.emit('myevent1'); + obj.emit('myevent2'); + obj2.emit('myevent1'); + obj2.emit('myevent2'); + + //we emit 4 times, but since obj2 is a child of obj the event should bubble + //up to obj and show up there as well. So the obj2.emit() calls each increment + //the counter twice. + expect(called).to.equal(6); + }); + + it('is backwards compatible with older .dispatchEvent({})', function () { + var called = 0, + data = { + some: 'thing', + hello: true + }; + + function onMyEvent(event) { + pixi_utils_EventTarget_Event_confirm(event, obj, data); + + called++; + } + + obj.on('myevent1', onMyEvent); + obj.on('myevent2', onMyEvent); + obj.on('myevent3', onMyEvent); + + data.type = 'myevent1'; + obj.emit(data); + + data.type = 'myevent2'; + obj.emit(data); + + data.type = 'myevent3'; + obj.emit(data); + + obj.off('myevent2', onMyEvent); + + data.type = 'myevent1'; + obj.emit(data); + + data.type = 'myevent2'; + obj.emit(data); + + data.type = 'myevent3'; + obj.emit(data); + + expect(called).to.equal(5); + }); + + it('is backwards compatible with older .call(this)', function () { + var Fn = function() { + PIXI.EventTarget.call(this); + }, + o = new Fn(); + + pixi_utils_EventTarget_confirm(o); + }); + + it('is backwards compatible with older .addEventListener("")', function () { + var called = 0, + data = { + some: 'thing', + hello: true + }; + + function onMyEvent(event) { + pixi_utils_EventTarget_Event_confirm(event, obj, data); + + called++; + } + + obj.addEventListener('myevent1', onMyEvent); + obj.addEventListener('myevent2', onMyEvent); + obj.addEventListener('myevent3', onMyEvent); + + data.type = 'myevent1'; + obj.emit(data); + + data.type = 'myevent2'; + obj.emit(data); + + data.type = 'myevent3'; + obj.emit(data); + + obj.off('myevent2', onMyEvent); + + data.type = 'myevent1'; + obj.emit(data); + + data.type = 'myevent2'; + obj.emit(data); + + data.type = 'myevent3'; + obj.emit(data); + + expect(called).to.equal(5); + }); + + it('event remove during emit call properly', function () { + var called = 0; + + function cb1() { + called++; + obj.off('myevent', cb1); + } + function cb2() { + called++; + obj.off('myevent', cb2); + } + function cb3() { + called++; + obj.off('myevent', cb3); + } + + obj.on('myevent', cb1); + obj.on('myevent', cb2); + obj.on('myevent', cb3); + obj.emit('myevent', ''); + + expect(called).to.equal(3); + }); +}); diff --git a/test/unit/pixi-v2/utils/Polyk.js b/test/unit/pixi-v2/utils/Polyk.js new file mode 100644 index 0000000..dfc7128 --- /dev/null +++ b/test/unit/pixi-v2/utils/Polyk.js @@ -0,0 +1,14 @@ +describe('pixi/utils/Polyk', function () { + 'use strict'; + + var expect = chai.expect; + var PolyK = PIXI.PolyK; + + it('Module exists', function () { + expect(PolyK).to.be.an('object'); + }); + + it('Members exist', function () { + expect(PolyK).to.respondTo('Triangulate'); + }); +}); diff --git a/test/unit/pixi-v2/utils/Utils.js b/test/unit/pixi-v2/utils/Utils.js new file mode 100644 index 0000000..c97b3c6 --- /dev/null +++ b/test/unit/pixi-v2/utils/Utils.js @@ -0,0 +1,17 @@ +describe('Utils', function () { + 'use strict'; + + var expect = chai.expect; + + it('requestAnimationFrame exists', function () { + expect(global).to.respondTo('requestAnimationFrame'); + }); + + it('cancelAnimationFrame exists', function () { + expect(global).to.respondTo('cancelAnimationFrame'); + }); + + it('requestAnimFrame exists', function () { + expect(global).to.respondTo('requestAnimFrame'); + }); +}); diff --git a/test/unit/pixi/InteractionManager.js b/test/unit/pixi/InteractionManager.js deleted file mode 100644 index ed3001f..0000000 --- a/test/unit/pixi/InteractionManager.js +++ /dev/null @@ -1,10 +0,0 @@ -describe('pixi/InteractionManager', function () { - 'use strict'; - - var expect = chai.expect; - var InteractionManager = PIXI.InteractionManager; - - it('Module exists', function () { - expect(InteractionManager).to.be.a('function'); - }); -}); diff --git a/test/unit/pixi/Pixi.js b/test/unit/pixi/Pixi.js deleted file mode 100644 index 27debc1..0000000 --- a/test/unit/pixi/Pixi.js +++ /dev/null @@ -1,9 +0,0 @@ -describe('pixi/Pixi', function () { - 'use strict'; - - var expect = chai.expect; - - it('Module exists', function () { - expect(global).to.have.property('PIXI').and.to.be.an('object'); - }); -}); diff --git a/test/unit/pixi/core/Circle.js b/test/unit/pixi/core/Circle.js deleted file mode 100644 index fbcfa17..0000000 --- a/test/unit/pixi/core/Circle.js +++ /dev/null @@ -1,21 +0,0 @@ -describe('pixi/core/Circle', function () { - 'use strict'; - - var expect = chai.expect; - var Circle = PIXI.Circle; - - it('Module exists', function () { - expect(Circle).to.be.a('function'); - }); - - it('Confirm new instance', function () { - var obj = new Circle(); - pixi_core_Circle_confirmNewCircle(obj); - }); - - it("getBounds should return Rectangle that bounds the circle", function() { - var obj = new Circle(100, 250, 50); - var bounds = obj.getBounds(); - pixi_core_Circle_isBoundedByRectangle(obj, bounds); - }); -}); diff --git a/test/unit/pixi/core/Ellipse.js b/test/unit/pixi/core/Ellipse.js deleted file mode 100644 index 026b56f..0000000 --- a/test/unit/pixi/core/Ellipse.js +++ /dev/null @@ -1,24 +0,0 @@ -describe('pixi/core/Ellipse', function () { - 'use strict'; - - var expect = chai.expect; - var Ellipse = PIXI.Ellipse; - - it('Module exists', function () { - expect(Ellipse).to.be.a('function'); - }); - - it('Confirm new instance', function () { - var obj = new Ellipse(); - - expect(obj).to.be.an.instanceof(Ellipse); - expect(obj).to.respondTo('clone'); - expect(obj).to.respondTo('contains'); - expect(obj).to.respondTo('getBounds'); - - expect(obj).to.have.property('x', 0); - expect(obj).to.have.property('y', 0); - expect(obj).to.have.property('width', 0); - expect(obj).to.have.property('height', 0); - }); -}); diff --git a/test/unit/pixi/core/Matrix.js b/test/unit/pixi/core/Matrix.js deleted file mode 100644 index da75e2e..0000000 --- a/test/unit/pixi/core/Matrix.js +++ /dev/null @@ -1,14 +0,0 @@ -describe('pixi/core/Matrix', function () { - 'use strict'; - - var expect = chai.expect; - - it('Matrix exists', function () { - expect(PIXI.Matrix).to.be.an('function'); - }); - - it('Confirm new Matrix', function () { - var matrix = new PIXI.Matrix(); - pixi_core_Matrix_confirmNewMatrix(matrix); - }); -}); diff --git a/test/unit/pixi/core/Point.js b/test/unit/pixi/core/Point.js deleted file mode 100644 index c4d5163..0000000 --- a/test/unit/pixi/core/Point.js +++ /dev/null @@ -1,15 +0,0 @@ -describe('pixi/core/Point', function () { - 'use strict'; - - var expect = chai.expect; - var Point = PIXI.Point; - - it('Module exists', function () { - expect(Point).to.be.a('function'); - }); - - it('Confirm new instance', function () { - var obj = new Point(); - pixi_core_Point_confirm(obj, 0, 0); - }); -}); diff --git a/test/unit/pixi/core/Polygon.js b/test/unit/pixi/core/Polygon.js deleted file mode 100644 index dc8c918..0000000 --- a/test/unit/pixi/core/Polygon.js +++ /dev/null @@ -1,20 +0,0 @@ -describe('pixi/core/Polygon', function () { - 'use strict'; - - var expect = chai.expect; - var Polygon = PIXI.Polygon; - - it('Module exists', function () { - expect(Polygon).to.be.a('function'); - }); - - it('Confirm new instance', function () { - var obj = new Polygon(); - - expect(obj).to.be.an.instanceof(Polygon); - expect(obj).to.respondTo('clone'); - expect(obj).to.respondTo('contains'); - - expect(obj).to.have.deep.property('points.length', 0); - }); -}); diff --git a/test/unit/pixi/core/Rectangle.js b/test/unit/pixi/core/Rectangle.js deleted file mode 100644 index d43316e..0000000 --- a/test/unit/pixi/core/Rectangle.js +++ /dev/null @@ -1,15 +0,0 @@ -describe('pixi/core/Rectangle', function () { - 'use strict'; - - var expect = chai.expect; - var Rectangle = PIXI.Rectangle; - - it('Module exists', function () { - expect(Rectangle).to.be.a('function'); - }); - - it('Confirm new instance', function () { - var rect = new Rectangle(); - pixi_core_Rectangle_confirm(rect, 0, 0, 0, 0); - }); -}); diff --git a/test/unit/pixi/display/DisplayObject.js b/test/unit/pixi/display/DisplayObject.js deleted file mode 100644 index 044acf8..0000000 --- a/test/unit/pixi/display/DisplayObject.js +++ /dev/null @@ -1,21 +0,0 @@ -describe('pixi/display/DisplayObject', function () { - 'use strict'; - - var expect = chai.expect; - var DisplayObject = PIXI.DisplayObject; - - it('Module exists', function () { - expect(DisplayObject).to.be.a('function'); - // expect(PIXI).to.have.property('visibleCount', 0); - }); - - it('Confirm new instance', function () { - var obj = new DisplayObject(); - - pixi_display_DisplayObject_confirmNew(obj); - expect(obj).to.have.property('hitArea', null); - expect(obj).to.have.property('interactive', false); - expect(obj).to.have.property('renderable', false); - expect(obj).to.have.property('stage', null); - }); -}); diff --git a/test/unit/pixi/display/DisplayObjectContainer.js b/test/unit/pixi/display/DisplayObjectContainer.js deleted file mode 100644 index 15a3376..0000000 --- a/test/unit/pixi/display/DisplayObjectContainer.js +++ /dev/null @@ -1,67 +0,0 @@ -describe('pixi/display/DisplayObjectContainer', function () { - 'use strict'; - - var expect = chai.expect; - var DisplayObjectContainer = PIXI.DisplayObjectContainer; - - it('Module exists', function () { - expect(DisplayObjectContainer).to.be.a('function'); - }); - - it('Confirm new instance', function () { - var obj = new DisplayObjectContainer(); - - pixi_display_DisplayObjectContainer_confirmNew(obj); - expect(obj).to.have.property('hitArea', null); - expect(obj).to.have.property('interactive', false); - expect(obj).to.have.property('renderable', false); - expect(obj).to.have.property('stage', null); - }); - - it('Gets child index', function() { - var container = new PIXI.DisplayObjectContainer(); - var children = []; - for (var i = 0; i < 10; i++) { - var child = new PIXI.DisplayObject(); - children.push(child); - container.addChild(child); - } - - for (i = 0; i < children.length; i++) { - expect(i).to.eql(container.getChildIndex(children[i])); - } - }); - - it('throws error when trying to get index of not a child', function() { - var container = new PIXI.DisplayObjectContainer(); - var child = new PIXI.DisplayObject(); - - expect(function() { container.getChildIndex(child); }).to.throw(); - }); - - it('Sets child index', function() { - var container = new PIXI.DisplayObjectContainer(); - var children = []; - - for (var i = 0; i < 10; i++) { - var child = new PIXI.DisplayObject(); - children.push(child); - container.addChild(child); - } - children.reverse(); - - for (i = 0; i < children.length; i++) { - container.setChildIndex(children[i], i); - expect(i).to.eql(container.getChildIndex(children[i])); - } - }); - - it('throws error when trying to set incorect index', function() { - var container = new PIXI.DisplayObjectContainer(); - var child = new PIXI.DisplayObject(); - container.addChild(child); - - expect(function() { container.setChildIndex(child, -1); }).to.throw(); - expect(function() { container.setChildIndex(child, 1); }).to.throw(); - }); -}); diff --git a/test/unit/pixi/display/MovieClip.js b/test/unit/pixi/display/MovieClip.js deleted file mode 100644 index f3c6c6a..0000000 --- a/test/unit/pixi/display/MovieClip.js +++ /dev/null @@ -1,33 +0,0 @@ -describe('pixi/display/MovieClip', function () { - 'use strict'; - - var expect = chai.expect; - var MovieClip = PIXI.MovieClip; - var Texture = PIXI.Texture; - - it('Module exists', function () { - expect(MovieClip).to.be.a('function'); - }); - - it('Confirm new instance', function (done) { - var texture = Texture.fromImage('/base/test/textures/SpriteSheet-Explosion.png'); - var obj = new MovieClip([texture]); - - pixi_display_Sprite_confirmNew(obj, done); - - expect(obj).to.be.an.instanceof(MovieClip); - expect(obj).to.respondTo('stop'); - expect(obj).to.respondTo('play'); - expect(obj).to.respondTo('gotoAndStop'); - expect(obj).to.respondTo('gotoAndPlay'); - expect(obj).to.respondTo('updateTransform'); - - expect(obj).to.have.deep.property('textures.length', 1); - expect(obj).to.have.deep.property('textures[0]', texture); - expect(obj).to.have.property('animationSpeed', 1); - expect(obj).to.have.property('loop', true); - expect(obj).to.have.property('onComplete', null); - expect(obj).to.have.property('currentFrame', 0); - expect(obj).to.have.property('playing', false); - }); -}); diff --git a/test/unit/pixi/display/Sprite.js b/test/unit/pixi/display/Sprite.js deleted file mode 100644 index 30c8076..0000000 --- a/test/unit/pixi/display/Sprite.js +++ /dev/null @@ -1,28 +0,0 @@ -describe('pixi/display/Sprite', function () { - 'use strict'; - - var expect = chai.expect; - var Sprite = PIXI.Sprite; - var Texture = PIXI.Texture; - - it('Module exists', function () { - expect(Sprite).to.be.a('function'); - expect(PIXI).to.have.deep.property('blendModes.NORMAL', 0); - expect(PIXI).to.have.deep.property('blendModes.ADD', 1); - expect(PIXI).to.have.deep.property('blendModes.MULTIPLY', 2); - expect(PIXI).to.have.deep.property('blendModes.SCREEN', 3); - }); - - - it('Members exist', function () { - expect(Sprite).itself.to.respondTo('fromImage'); - expect(Sprite).itself.to.respondTo('fromFrame'); - }); - - it('Confirm new instance', function (done) { - var texture = Texture.fromImage('/base/test/textures/SpriteSheet-Aliens.png'); - var obj = new Sprite(texture); - - pixi_display_Sprite_confirmNew(obj, done); - }); -}); diff --git a/test/unit/pixi/display/Stage.js b/test/unit/pixi/display/Stage.js deleted file mode 100644 index 6974c2e..0000000 --- a/test/unit/pixi/display/Stage.js +++ /dev/null @@ -1,49 +0,0 @@ -describe('pixi/display/Stage', function () { - 'use strict'; - - var expect = chai.expect; - var Stage = PIXI.Stage; - var InteractionManager = PIXI.InteractionManager; - var Rectangle = PIXI.Rectangle; - - it('Module exists', function () { - expect(Stage).to.be.a('function'); - }); - - it('Confirm new instance', function () { - var obj = new Stage(null, true); - - pixi_display_DisplayObjectContainer_confirmNew(obj); - - expect(obj).to.be.an.instanceof(Stage); - expect(obj).to.respondTo('updateTransform'); - expect(obj).to.respondTo('setBackgroundColor'); - expect(obj).to.respondTo('getMousePosition'); - // FIXME: duplicate member in DisplayObject - pixi_core_Matrix_confirmNewMatrix(obj.worldTransform); - // FIXME: convert arg to bool in constructor - expect(obj).to.have.property('interactive', true); - - expect(obj).to.have.property('interactionManager') - .and.to.be.an.instanceof(InteractionManager) - .and.to.have.property('stage', obj); - - expect(obj).to.have.property('dirty', true); - - expect(obj).to.have.property('stage', obj); - - expect(obj).to.have.property('hitArea') - .and.to.be.an.instanceof(Rectangle); - pixi_core_Rectangle_confirm(obj.hitArea, 0, 0, 100000, 100000); - - expect(obj).to.have.property('backgroundColor', 0x000000); - expect(obj).to.have.deep.property('backgroundColorSplit.length', 3); - expect(obj).to.have.deep.property('backgroundColorSplit[0]', 0); - expect(obj).to.have.deep.property('backgroundColorSplit[1]', 0); - expect(obj).to.have.deep.property('backgroundColorSplit[2]', 0); - expect(obj).to.have.property('backgroundColorString', '#000000'); - - - expect(obj).to.have.property('worldVisible', true); - }); -}); diff --git a/test/unit/pixi/extras/Rope.js b/test/unit/pixi/extras/Rope.js deleted file mode 100644 index 05885ac..0000000 --- a/test/unit/pixi/extras/Rope.js +++ /dev/null @@ -1,31 +0,0 @@ -describe('pixi/extras/Rope', function () { - 'use strict'; - - var expect = chai.expect; - var Rope = PIXI.Rope; - var Texture = PIXI.Texture; - var Point = PIXI.Point; - - it('Module exists', function () { - expect(Rope).to.be.a('function'); - }); - - it('Confirm new instance', function () { - - var texture = Texture.fromImage('/base/test/textures/bunny.png'); - - // TODO-Alvin - // Same as Strip - - // var obj = new Rope(texture, [new Point(), new Point(5, 10), new Point(10, 20)]); - - // pixi_extras_Strip_confirmNew(obj); - - // expect(obj).to.be.an.instanceof(Rope); - // expect(obj).to.respondTo('refresh'); - // expect(obj).to.respondTo('updateTransform'); - // expect(obj).to.respondTo('setTexture'); - - // TODO: Test properties - }); -}); diff --git a/test/unit/pixi-v2/InteractionManager.js b/test/unit/pixi-v2/InteractionManager.js new file mode 100644 index 0000000..ed3001f --- /dev/null +++ b/test/unit/pixi-v2/InteractionManager.js @@ -0,0 +1,10 @@ +describe('pixi/InteractionManager', function () { + 'use strict'; + + var expect = chai.expect; + var InteractionManager = PIXI.InteractionManager; + + it('Module exists', function () { + expect(InteractionManager).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/Pixi.js b/test/unit/pixi-v2/Pixi.js new file mode 100644 index 0000000..27debc1 --- /dev/null +++ b/test/unit/pixi-v2/Pixi.js @@ -0,0 +1,9 @@ +describe('pixi/Pixi', function () { + 'use strict'; + + var expect = chai.expect; + + it('Module exists', function () { + expect(global).to.have.property('PIXI').and.to.be.an('object'); + }); +}); diff --git a/test/unit/pixi-v2/core/Circle.js b/test/unit/pixi-v2/core/Circle.js new file mode 100644 index 0000000..fbcfa17 --- /dev/null +++ b/test/unit/pixi-v2/core/Circle.js @@ -0,0 +1,21 @@ +describe('pixi/core/Circle', function () { + 'use strict'; + + var expect = chai.expect; + var Circle = PIXI.Circle; + + it('Module exists', function () { + expect(Circle).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Circle(); + pixi_core_Circle_confirmNewCircle(obj); + }); + + it("getBounds should return Rectangle that bounds the circle", function() { + var obj = new Circle(100, 250, 50); + var bounds = obj.getBounds(); + pixi_core_Circle_isBoundedByRectangle(obj, bounds); + }); +}); diff --git a/test/unit/pixi-v2/core/Ellipse.js b/test/unit/pixi-v2/core/Ellipse.js new file mode 100644 index 0000000..026b56f --- /dev/null +++ b/test/unit/pixi-v2/core/Ellipse.js @@ -0,0 +1,24 @@ +describe('pixi/core/Ellipse', function () { + 'use strict'; + + var expect = chai.expect; + var Ellipse = PIXI.Ellipse; + + it('Module exists', function () { + expect(Ellipse).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Ellipse(); + + expect(obj).to.be.an.instanceof(Ellipse); + expect(obj).to.respondTo('clone'); + expect(obj).to.respondTo('contains'); + expect(obj).to.respondTo('getBounds'); + + expect(obj).to.have.property('x', 0); + expect(obj).to.have.property('y', 0); + expect(obj).to.have.property('width', 0); + expect(obj).to.have.property('height', 0); + }); +}); diff --git a/test/unit/pixi-v2/core/Matrix.js b/test/unit/pixi-v2/core/Matrix.js new file mode 100644 index 0000000..da75e2e --- /dev/null +++ b/test/unit/pixi-v2/core/Matrix.js @@ -0,0 +1,14 @@ +describe('pixi/core/Matrix', function () { + 'use strict'; + + var expect = chai.expect; + + it('Matrix exists', function () { + expect(PIXI.Matrix).to.be.an('function'); + }); + + it('Confirm new Matrix', function () { + var matrix = new PIXI.Matrix(); + pixi_core_Matrix_confirmNewMatrix(matrix); + }); +}); diff --git a/test/unit/pixi-v2/core/Point.js b/test/unit/pixi-v2/core/Point.js new file mode 100644 index 0000000..c4d5163 --- /dev/null +++ b/test/unit/pixi-v2/core/Point.js @@ -0,0 +1,15 @@ +describe('pixi/core/Point', function () { + 'use strict'; + + var expect = chai.expect; + var Point = PIXI.Point; + + it('Module exists', function () { + expect(Point).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Point(); + pixi_core_Point_confirm(obj, 0, 0); + }); +}); diff --git a/test/unit/pixi-v2/core/Polygon.js b/test/unit/pixi-v2/core/Polygon.js new file mode 100644 index 0000000..dc8c918 --- /dev/null +++ b/test/unit/pixi-v2/core/Polygon.js @@ -0,0 +1,20 @@ +describe('pixi/core/Polygon', function () { + 'use strict'; + + var expect = chai.expect; + var Polygon = PIXI.Polygon; + + it('Module exists', function () { + expect(Polygon).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Polygon(); + + expect(obj).to.be.an.instanceof(Polygon); + expect(obj).to.respondTo('clone'); + expect(obj).to.respondTo('contains'); + + expect(obj).to.have.deep.property('points.length', 0); + }); +}); diff --git a/test/unit/pixi-v2/core/Rectangle.js b/test/unit/pixi-v2/core/Rectangle.js new file mode 100644 index 0000000..d43316e --- /dev/null +++ b/test/unit/pixi-v2/core/Rectangle.js @@ -0,0 +1,15 @@ +describe('pixi/core/Rectangle', function () { + 'use strict'; + + var expect = chai.expect; + var Rectangle = PIXI.Rectangle; + + it('Module exists', function () { + expect(Rectangle).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var rect = new Rectangle(); + pixi_core_Rectangle_confirm(rect, 0, 0, 0, 0); + }); +}); diff --git a/test/unit/pixi-v2/display/DisplayObject.js b/test/unit/pixi-v2/display/DisplayObject.js new file mode 100644 index 0000000..044acf8 --- /dev/null +++ b/test/unit/pixi-v2/display/DisplayObject.js @@ -0,0 +1,21 @@ +describe('pixi/display/DisplayObject', function () { + 'use strict'; + + var expect = chai.expect; + var DisplayObject = PIXI.DisplayObject; + + it('Module exists', function () { + expect(DisplayObject).to.be.a('function'); + // expect(PIXI).to.have.property('visibleCount', 0); + }); + + it('Confirm new instance', function () { + var obj = new DisplayObject(); + + pixi_display_DisplayObject_confirmNew(obj); + expect(obj).to.have.property('hitArea', null); + expect(obj).to.have.property('interactive', false); + expect(obj).to.have.property('renderable', false); + expect(obj).to.have.property('stage', null); + }); +}); diff --git a/test/unit/pixi-v2/display/DisplayObjectContainer.js b/test/unit/pixi-v2/display/DisplayObjectContainer.js new file mode 100644 index 0000000..15a3376 --- /dev/null +++ b/test/unit/pixi-v2/display/DisplayObjectContainer.js @@ -0,0 +1,67 @@ +describe('pixi/display/DisplayObjectContainer', function () { + 'use strict'; + + var expect = chai.expect; + var DisplayObjectContainer = PIXI.DisplayObjectContainer; + + it('Module exists', function () { + expect(DisplayObjectContainer).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new DisplayObjectContainer(); + + pixi_display_DisplayObjectContainer_confirmNew(obj); + expect(obj).to.have.property('hitArea', null); + expect(obj).to.have.property('interactive', false); + expect(obj).to.have.property('renderable', false); + expect(obj).to.have.property('stage', null); + }); + + it('Gets child index', function() { + var container = new PIXI.DisplayObjectContainer(); + var children = []; + for (var i = 0; i < 10; i++) { + var child = new PIXI.DisplayObject(); + children.push(child); + container.addChild(child); + } + + for (i = 0; i < children.length; i++) { + expect(i).to.eql(container.getChildIndex(children[i])); + } + }); + + it('throws error when trying to get index of not a child', function() { + var container = new PIXI.DisplayObjectContainer(); + var child = new PIXI.DisplayObject(); + + expect(function() { container.getChildIndex(child); }).to.throw(); + }); + + it('Sets child index', function() { + var container = new PIXI.DisplayObjectContainer(); + var children = []; + + for (var i = 0; i < 10; i++) { + var child = new PIXI.DisplayObject(); + children.push(child); + container.addChild(child); + } + children.reverse(); + + for (i = 0; i < children.length; i++) { + container.setChildIndex(children[i], i); + expect(i).to.eql(container.getChildIndex(children[i])); + } + }); + + it('throws error when trying to set incorect index', function() { + var container = new PIXI.DisplayObjectContainer(); + var child = new PIXI.DisplayObject(); + container.addChild(child); + + expect(function() { container.setChildIndex(child, -1); }).to.throw(); + expect(function() { container.setChildIndex(child, 1); }).to.throw(); + }); +}); diff --git a/test/unit/pixi-v2/display/MovieClip.js b/test/unit/pixi-v2/display/MovieClip.js new file mode 100644 index 0000000..f3c6c6a --- /dev/null +++ b/test/unit/pixi-v2/display/MovieClip.js @@ -0,0 +1,33 @@ +describe('pixi/display/MovieClip', function () { + 'use strict'; + + var expect = chai.expect; + var MovieClip = PIXI.MovieClip; + var Texture = PIXI.Texture; + + it('Module exists', function () { + expect(MovieClip).to.be.a('function'); + }); + + it('Confirm new instance', function (done) { + var texture = Texture.fromImage('/base/test/textures/SpriteSheet-Explosion.png'); + var obj = new MovieClip([texture]); + + pixi_display_Sprite_confirmNew(obj, done); + + expect(obj).to.be.an.instanceof(MovieClip); + expect(obj).to.respondTo('stop'); + expect(obj).to.respondTo('play'); + expect(obj).to.respondTo('gotoAndStop'); + expect(obj).to.respondTo('gotoAndPlay'); + expect(obj).to.respondTo('updateTransform'); + + expect(obj).to.have.deep.property('textures.length', 1); + expect(obj).to.have.deep.property('textures[0]', texture); + expect(obj).to.have.property('animationSpeed', 1); + expect(obj).to.have.property('loop', true); + expect(obj).to.have.property('onComplete', null); + expect(obj).to.have.property('currentFrame', 0); + expect(obj).to.have.property('playing', false); + }); +}); diff --git a/test/unit/pixi-v2/display/Sprite.js b/test/unit/pixi-v2/display/Sprite.js new file mode 100644 index 0000000..30c8076 --- /dev/null +++ b/test/unit/pixi-v2/display/Sprite.js @@ -0,0 +1,28 @@ +describe('pixi/display/Sprite', function () { + 'use strict'; + + var expect = chai.expect; + var Sprite = PIXI.Sprite; + var Texture = PIXI.Texture; + + it('Module exists', function () { + expect(Sprite).to.be.a('function'); + expect(PIXI).to.have.deep.property('blendModes.NORMAL', 0); + expect(PIXI).to.have.deep.property('blendModes.ADD', 1); + expect(PIXI).to.have.deep.property('blendModes.MULTIPLY', 2); + expect(PIXI).to.have.deep.property('blendModes.SCREEN', 3); + }); + + + it('Members exist', function () { + expect(Sprite).itself.to.respondTo('fromImage'); + expect(Sprite).itself.to.respondTo('fromFrame'); + }); + + it('Confirm new instance', function (done) { + var texture = Texture.fromImage('/base/test/textures/SpriteSheet-Aliens.png'); + var obj = new Sprite(texture); + + pixi_display_Sprite_confirmNew(obj, done); + }); +}); diff --git a/test/unit/pixi-v2/display/Stage.js b/test/unit/pixi-v2/display/Stage.js new file mode 100644 index 0000000..6974c2e --- /dev/null +++ b/test/unit/pixi-v2/display/Stage.js @@ -0,0 +1,49 @@ +describe('pixi/display/Stage', function () { + 'use strict'; + + var expect = chai.expect; + var Stage = PIXI.Stage; + var InteractionManager = PIXI.InteractionManager; + var Rectangle = PIXI.Rectangle; + + it('Module exists', function () { + expect(Stage).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Stage(null, true); + + pixi_display_DisplayObjectContainer_confirmNew(obj); + + expect(obj).to.be.an.instanceof(Stage); + expect(obj).to.respondTo('updateTransform'); + expect(obj).to.respondTo('setBackgroundColor'); + expect(obj).to.respondTo('getMousePosition'); + // FIXME: duplicate member in DisplayObject + pixi_core_Matrix_confirmNewMatrix(obj.worldTransform); + // FIXME: convert arg to bool in constructor + expect(obj).to.have.property('interactive', true); + + expect(obj).to.have.property('interactionManager') + .and.to.be.an.instanceof(InteractionManager) + .and.to.have.property('stage', obj); + + expect(obj).to.have.property('dirty', true); + + expect(obj).to.have.property('stage', obj); + + expect(obj).to.have.property('hitArea') + .and.to.be.an.instanceof(Rectangle); + pixi_core_Rectangle_confirm(obj.hitArea, 0, 0, 100000, 100000); + + expect(obj).to.have.property('backgroundColor', 0x000000); + expect(obj).to.have.deep.property('backgroundColorSplit.length', 3); + expect(obj).to.have.deep.property('backgroundColorSplit[0]', 0); + expect(obj).to.have.deep.property('backgroundColorSplit[1]', 0); + expect(obj).to.have.deep.property('backgroundColorSplit[2]', 0); + expect(obj).to.have.property('backgroundColorString', '#000000'); + + + expect(obj).to.have.property('worldVisible', true); + }); +}); diff --git a/test/unit/pixi-v2/extras/Rope.js b/test/unit/pixi-v2/extras/Rope.js new file mode 100644 index 0000000..05885ac --- /dev/null +++ b/test/unit/pixi-v2/extras/Rope.js @@ -0,0 +1,31 @@ +describe('pixi/extras/Rope', function () { + 'use strict'; + + var expect = chai.expect; + var Rope = PIXI.Rope; + var Texture = PIXI.Texture; + var Point = PIXI.Point; + + it('Module exists', function () { + expect(Rope).to.be.a('function'); + }); + + it('Confirm new instance', function () { + + var texture = Texture.fromImage('/base/test/textures/bunny.png'); + + // TODO-Alvin + // Same as Strip + + // var obj = new Rope(texture, [new Point(), new Point(5, 10), new Point(10, 20)]); + + // pixi_extras_Strip_confirmNew(obj); + + // expect(obj).to.be.an.instanceof(Rope); + // expect(obj).to.respondTo('refresh'); + // expect(obj).to.respondTo('updateTransform'); + // expect(obj).to.respondTo('setTexture'); + + // TODO: Test properties + }); +}); diff --git a/test/unit/pixi-v2/extras/Spine.js b/test/unit/pixi-v2/extras/Spine.js new file mode 100644 index 0000000..0708bc0 --- /dev/null +++ b/test/unit/pixi-v2/extras/Spine.js @@ -0,0 +1,10 @@ +describe('pixi/extras/Spine', function () { + 'use strict'; + + var expect = chai.expect; + var Spine = PIXI.Spine; + + it('Module exists', function () { + expect(Spine).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/extras/Strip.js b/test/unit/pixi-v2/extras/Strip.js new file mode 100644 index 0000000..230af90 --- /dev/null +++ b/test/unit/pixi-v2/extras/Strip.js @@ -0,0 +1,26 @@ +describe('pixi/extras/Strip', function () { + 'use strict'; + + var expect = chai.expect; + var Strip = PIXI.Strip; + var Texture = PIXI.Texture; + + it('Module exists', function () { + expect(Strip).to.be.a('function'); + }); + + it('Confirm new instance', function () { + + + // TODO-Alvin + // We tweaked it to make it pass the tests, but the whole strip class needs + // to be re-coded + + var texture = Texture.fromImage('/base/test/textures/bunny.png'); + + // var obj = new Strip(texture, 20, 10000); + + + // pixi_extras_Strip_confirmNew(obj); + }); +}); diff --git a/test/unit/pixi-v2/extras/TilingSprite.js b/test/unit/pixi-v2/extras/TilingSprite.js new file mode 100644 index 0000000..56aea14 --- /dev/null +++ b/test/unit/pixi-v2/extras/TilingSprite.js @@ -0,0 +1,24 @@ +describe('pixi/extras/TilingSprite', function () { + 'use strict'; + + var expect = chai.expect; + var TilingSprite = PIXI.TilingSprite; + var Texture = PIXI.Texture; + + it('Module exists', function () { + expect(TilingSprite).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var texture = Texture.fromImage('/base/test/textures/bunny.png'); + var obj = new TilingSprite(texture, 6000, 12000); + + pixi_display_DisplayObjectContainer_confirmNew(obj); + + expect(obj).to.be.an.instanceof(TilingSprite); + expect(obj).to.respondTo('setTexture'); + expect(obj).to.respondTo('onTextureUpdate'); + + // TODO: Test properties + }); +}); diff --git a/test/unit/pixi-v2/filters/FilterBlock.js b/test/unit/pixi-v2/filters/FilterBlock.js new file mode 100644 index 0000000..870cec0 --- /dev/null +++ b/test/unit/pixi-v2/filters/FilterBlock.js @@ -0,0 +1,10 @@ +describe('pixi/filters/FilterBlock', function () { + 'use strict'; + + var expect = chai.expect; + var FilterBlock = PIXI.FilterBlock; + + it('Module exists', function () { + expect(FilterBlock).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/AssetLoader.js b/test/unit/pixi-v2/loaders/AssetLoader.js new file mode 100644 index 0000000..a0aa0b5 --- /dev/null +++ b/test/unit/pixi-v2/loaders/AssetLoader.js @@ -0,0 +1,10 @@ +describe('pixi/loaders/AssetLoader', function () { + 'use strict'; + + var expect = chai.expect; + var AssetLoader = PIXI.AssetLoader; + + it('Module exists', function () { + expect(AssetLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/BitmapFontLoader.js b/test/unit/pixi-v2/loaders/BitmapFontLoader.js new file mode 100644 index 0000000..046f018 --- /dev/null +++ b/test/unit/pixi-v2/loaders/BitmapFontLoader.js @@ -0,0 +1,9 @@ +describe('pixi/loaders/BitmapFontLoader', function () { + 'use strict'; + + var expect = chai.expect; + + it('Module exists', function () { + expect(PIXI.BitmapFontLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/ImageLoader.js b/test/unit/pixi-v2/loaders/ImageLoader.js new file mode 100644 index 0000000..8b1f556 --- /dev/null +++ b/test/unit/pixi-v2/loaders/ImageLoader.js @@ -0,0 +1,10 @@ +describe('pixi/loaders/ImageLoader', function () { + 'use strict'; + + var expect = chai.expect; + var ImageLoader = PIXI.ImageLoader; + + it('Module exists', function () { + expect(ImageLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/JsonLoader.js b/test/unit/pixi-v2/loaders/JsonLoader.js new file mode 100644 index 0000000..c577e83 --- /dev/null +++ b/test/unit/pixi-v2/loaders/JsonLoader.js @@ -0,0 +1,10 @@ +describe('pixi/loaders/JsonLoader', function () { + 'use strict'; + + var expect = chai.expect; + var JsonLoader = PIXI.JsonLoader; + + it('Module exists', function () { + expect(JsonLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/SpineLoader.js b/test/unit/pixi-v2/loaders/SpineLoader.js new file mode 100644 index 0000000..fdcc0b8 --- /dev/null +++ b/test/unit/pixi-v2/loaders/SpineLoader.js @@ -0,0 +1,10 @@ +describe('pixi/loaders/SpineLoader', function () { + 'use strict'; + + var expect = chai.expect; + var SpineLoader = PIXI.SpineLoader; + + it('Module exists', function () { + expect(SpineLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/SpriteSheetLoader.js b/test/unit/pixi-v2/loaders/SpriteSheetLoader.js new file mode 100644 index 0000000..57beb27 --- /dev/null +++ b/test/unit/pixi-v2/loaders/SpriteSheetLoader.js @@ -0,0 +1,10 @@ +describe('pixi/loaders/SpriteSheetLoader', function () { + 'use strict'; + + var expect = chai.expect; + var SpriteSheetLoader = PIXI.SpriteSheetLoader; + + it('Module exists', function () { + expect(SpriteSheetLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/primitives/Graphics.js b/test/unit/pixi-v2/primitives/Graphics.js new file mode 100644 index 0000000..f3849eb --- /dev/null +++ b/test/unit/pixi-v2/primitives/Graphics.js @@ -0,0 +1,44 @@ +describe('pixi/primitives/Graphics', function () { + 'use strict'; + + var expect = chai.expect; + var Graphics = PIXI.Graphics; + + it('Module exists', function () { + expect(Graphics).to.be.a('function'); + + expect(Graphics).itself.to.have.property('POLY', 0); + expect(Graphics).itself.to.have.property('RECT', 1); + expect(Graphics).itself.to.have.property('CIRC', 2); + expect(Graphics).itself.to.have.property('ELIP', 3); + expect(Graphics).itself.to.have.property('RREC', 4); + }); + + it('Confirm new instance', function () { + var obj = new Graphics(); + + pixi_display_DisplayObjectContainer_confirmNew(obj); + + expect(obj).to.be.an.instanceof(Graphics); + expect(obj).to.respondTo('lineStyle'); + expect(obj).to.respondTo('lineStyle'); + expect(obj).to.respondTo('moveTo'); + expect(obj).to.respondTo('lineTo'); + expect(obj).to.respondTo('beginFill'); + expect(obj).to.respondTo('endFill'); + expect(obj).to.respondTo('drawRect'); + // expect(obj).to.respondTo('drawRoundedRect'); + expect(obj).to.respondTo('drawCircle'); + expect(obj).to.respondTo('drawEllipse'); + expect(obj).to.respondTo('clear'); + + expect(obj).to.have.property('renderable', true); + expect(obj).to.have.property('fillAlpha', 1); + expect(obj).to.have.property('lineWidth', 0); + expect(obj).to.have.property('width', 0); + expect(obj).to.have.property('height', 0); + expect(obj).to.have.property('lineColor', 0); + expect(obj).to.have.deep.property('graphicsData.length', 0); + // expect(obj).to.have.deep.property('currentPath.points.length', 0); + }); +}); diff --git a/test/unit/pixi-v2/renderers/canvas/CanvasGraphics.js b/test/unit/pixi-v2/renderers/canvas/CanvasGraphics.js new file mode 100644 index 0000000..8f44472 --- /dev/null +++ b/test/unit/pixi-v2/renderers/canvas/CanvasGraphics.js @@ -0,0 +1,15 @@ +describe('renders/canvas/CanvasGraphics', function () { + 'use strict'; + + var expect = chai.expect; + var CanvasGraphics = PIXI.CanvasGraphics; + + it('Module exists', function () { + expect(CanvasGraphics).to.be.a('function'); + }); + + it('Members exist', function () { + expect(CanvasGraphics).itself.to.respondTo('renderGraphics'); + expect(CanvasGraphics).itself.to.respondTo('renderGraphicsMask'); + }); +}); diff --git a/test/unit/pixi-v2/renderers/canvas/CanvasRenderer.js b/test/unit/pixi-v2/renderers/canvas/CanvasRenderer.js new file mode 100644 index 0000000..1646444 --- /dev/null +++ b/test/unit/pixi-v2/renderers/canvas/CanvasRenderer.js @@ -0,0 +1,36 @@ +describe('renderers/canvas/CanvasRenderer', function () { + 'use strict'; + + var expect = chai.expect; + var CanvasRenderer = PIXI.CanvasRenderer; + + it('Module exists', function () { + expect(CanvasRenderer).to.be.a('function'); + }); + + describe('.autoResize', function () { + it('Should automatically resize view if enabled', function () { + var renderer = new CanvasRenderer(200, 200, { + autoResize: true + }); + + expect(renderer.view.style.width).to.equal('200px'); + }); + + it('Should not automatically resize view if disabled', function () { + var renderer = new CanvasRenderer(200, 200, { + autoResize: false + }); + + expect(renderer.view.style.width).to.equal(''); + }); + + it('Should not automatically resize view if not specified', function () { + var renderer = new CanvasRenderer(200, 200, { + resolution: 2 + }); + + expect(renderer.view.style.width).to.equal(''); + }); + }); +}); diff --git a/test/unit/pixi-v2/renderers/webgl/WebGLGraphics.js b/test/unit/pixi-v2/renderers/webgl/WebGLGraphics.js new file mode 100644 index 0000000..5867b28 --- /dev/null +++ b/test/unit/pixi-v2/renderers/webgl/WebGLGraphics.js @@ -0,0 +1,20 @@ +describe('renderers/wegbl/WebGLGraphics', function () { + 'use strict'; + + var expect = chai.expect; + var WebGLGraphics = PIXI.WebGLGraphics; + + it('Module exists', function () { + expect(WebGLGraphics).to.be.a('function'); + }); + + it('Members exist', function () { + expect(WebGLGraphics).itself.to.respondTo('renderGraphics'); + expect(WebGLGraphics).itself.to.respondTo('updateGraphics'); + expect(WebGLGraphics).itself.to.respondTo('buildRectangle'); + expect(WebGLGraphics).itself.to.respondTo('buildRoundedRectangle'); + expect(WebGLGraphics).itself.to.respondTo('buildCircle'); + expect(WebGLGraphics).itself.to.respondTo('buildLine'); + expect(WebGLGraphics).itself.to.respondTo('buildPoly'); + }); +}); diff --git a/test/unit/pixi-v2/renderers/webgl/WebGLRenderer.js b/test/unit/pixi-v2/renderers/webgl/WebGLRenderer.js new file mode 100644 index 0000000..1680a80 --- /dev/null +++ b/test/unit/pixi-v2/renderers/webgl/WebGLRenderer.js @@ -0,0 +1,49 @@ +describe('renderers/webgl/WebGLRenderer', function () { + 'use strict'; + + var expect = chai.expect; + var WebGLRenderer = PIXI.WebGLRenderer; + + it('Module exists', function () { + expect(WebGLRenderer).to.be.a('function'); + }); + + // Skip tests if WebGL is not available (WebGL not supported in Travis CI) + try { + var renderer = new WebGLRenderer(400, 300, {}); + renderer.destroy(); + } catch (error) { + return; + } + + it('Destroy renderer', function () { + var renderer = new WebGLRenderer(400, 300, {}); + renderer.destroy(); + }); + + describe('.autoResize', function () { + it('Should automatically resize view if enabled', function () { + var renderer = new WebGLRenderer(200, 200, { + autoResize: true + }); + + expect(renderer.view.style.width).to.equal('200px'); + }); + + it('Should not automatically resize view if disabled', function () { + var renderer = new WebGLRenderer(200, 200, { + autoResize: false + }); + + expect(renderer.view.style.width).to.equal(''); + }); + + it('Should not automatically resize view if not specified', function () { + var renderer = new WebGLRenderer(200, 200, { + resolution: 2 + }); + + expect(renderer.view.style.width).to.equal(''); + }); + }); +}); diff --git a/test/unit/pixi-v2/renderers/webgl/WebGLShaders.js b/test/unit/pixi-v2/renderers/webgl/WebGLShaders.js new file mode 100644 index 0000000..6e33e4f --- /dev/null +++ b/test/unit/pixi-v2/renderers/webgl/WebGLShaders.js @@ -0,0 +1,13 @@ +describe('renderers/webgl/WebGLShaders', function () { + 'use strict'; + + var expect = chai.expect; + + it('Module members exist', function () { + + expect(PIXI).to.respondTo('CompileVertexShader'); + expect(PIXI).to.respondTo('CompileFragmentShader'); + expect(PIXI).to.respondTo('_CompileShader'); + expect(PIXI).to.respondTo('compileProgram'); + }); +}); diff --git a/test/unit/pixi-v2/renderers/webgl/WebGLSpriteBatch.js b/test/unit/pixi-v2/renderers/webgl/WebGLSpriteBatch.js new file mode 100644 index 0000000..e662b63 --- /dev/null +++ b/test/unit/pixi-v2/renderers/webgl/WebGLSpriteBatch.js @@ -0,0 +1,10 @@ +describe('renderers/webgl/utils/WebGLSpriteBatch', function () { + 'use strict'; + + var expect = chai.expect; + var WebGLSpriteBatch = PIXI.WebGLSpriteBatch; + + it('Module exists', function () { + expect(WebGLSpriteBatch).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/text/BitmapText.js b/test/unit/pixi-v2/text/BitmapText.js new file mode 100644 index 0000000..9388e3d --- /dev/null +++ b/test/unit/pixi-v2/text/BitmapText.js @@ -0,0 +1,10 @@ +describe('pixi/text/BitmapText', function () { + 'use strict'; + + var expect = chai.expect; + var BitmapText = PIXI.BitmapText; + + it('Module exists', function () { + expect(BitmapText).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/text/Text.js b/test/unit/pixi-v2/text/Text.js new file mode 100644 index 0000000..9bc9ac5 --- /dev/null +++ b/test/unit/pixi-v2/text/Text.js @@ -0,0 +1,10 @@ +describe('pixi/text/Text', function () { + 'use strict'; + + var expect = chai.expect; + var Text = PIXI.Text; + + it('Module exists', function () { + expect(Text).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/textures/BaseTexture.js b/test/unit/pixi-v2/textures/BaseTexture.js new file mode 100644 index 0000000..502b724 --- /dev/null +++ b/test/unit/pixi-v2/textures/BaseTexture.js @@ -0,0 +1,11 @@ +describe('pixi/textures/BaseTexture', function () { + 'use strict'; + + var expect = chai.expect; + var BaseTexture = PIXI.BaseTexture; + + it('Module exists', function () { + expect(BaseTexture).to.be.a('function'); + expect(PIXI).to.have.property('BaseTextureCache').and.to.be.an('object'); + }); +}); diff --git a/test/unit/pixi-v2/textures/RenderTexture.js b/test/unit/pixi-v2/textures/RenderTexture.js new file mode 100644 index 0000000..96acdb4 --- /dev/null +++ b/test/unit/pixi-v2/textures/RenderTexture.js @@ -0,0 +1,15 @@ +describe('pixi/textures/RenderTexture', function () { + 'use strict'; + + var expect = chai.expect; + var RenderTexture = PIXI.RenderTexture; + + it('Module exists', function () { + expect(RenderTexture).to.be.a('function'); + }); + + it('Confirm new instance', function (done) { + var texture = new RenderTexture(100, 100, new PIXI.CanvasRenderer()); + pixi_textures_RenderTexture_confirmNew(texture, done); + }); +}); diff --git a/test/unit/pixi-v2/textures/Texture.js b/test/unit/pixi-v2/textures/Texture.js new file mode 100644 index 0000000..090f64d --- /dev/null +++ b/test/unit/pixi-v2/textures/Texture.js @@ -0,0 +1,26 @@ +describe('pixi/textures/Texture', function () { + 'use strict'; + + var expect = chai.expect; + var Texture = PIXI.Texture; + + it('Module exists', function () { + expect(Texture).to.be.a('function'); + expect(PIXI).to.have.property('TextureCache').and.to.be.an('object'); + }); + + it('Members exist', function () { + expect(Texture).itself.to.respondTo('fromImage'); + expect(Texture).itself.to.respondTo('fromFrame'); + expect(Texture).itself.to.respondTo('fromCanvas'); + expect(Texture).itself.to.respondTo('addTextureToCache'); + expect(Texture).itself.to.respondTo('removeTextureFromCache'); + + // expect(Texture).itself.to.have.deep.property('frameUpdates.length', 0); + }); + + it('Confirm new instance', function (done) { + var texture = Texture.fromImage('/base/test/textures/bunny.png'); + pixi_textures_Texture_confirmNew(texture, done); + }); +}); diff --git a/test/unit/pixi-v2/utils/Detector.js b/test/unit/pixi-v2/utils/Detector.js new file mode 100644 index 0000000..4cf6008 --- /dev/null +++ b/test/unit/pixi-v2/utils/Detector.js @@ -0,0 +1,10 @@ +describe('pixi/utils/Detector', function () { + 'use strict'; + + var expect = chai.expect; + var autoDetectRenderer = PIXI.autoDetectRenderer; + + it('Module exists', function () { + expect(autoDetectRenderer).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/utils/EventTarget.js b/test/unit/pixi-v2/utils/EventTarget.js new file mode 100644 index 0000000..1cfc3a4 --- /dev/null +++ b/test/unit/pixi-v2/utils/EventTarget.js @@ -0,0 +1,361 @@ +describe('pixi/utils/EventTarget', function () { + 'use strict'; + + var expect = chai.expect; + + var Clazz, PClazz, obj, pobj, obj2; + beforeEach(function () { + Clazz = function () {}; + PClazz = function () {}; + + PIXI.EventTarget.mixin(Clazz.prototype); + PIXI.EventTarget.mixin(PClazz.prototype); + + obj = new Clazz(); + obj2 = new Clazz(); + pobj = new PClazz(); + + obj.parent = pobj; + obj2.parent = obj; + }); + + it('Module exists', function () { + expect(PIXI.EventTarget).to.be.an('object'); + }); + + it('Confirm new instance', function () { + pixi_utils_EventTarget_confirm(obj); + }); + + it('simple on/emit case works', function () { + var myData = {}; + + obj.on('myevent', function (event) { + pixi_utils_EventTarget_Event_confirm(event, obj, myData); + }); + + obj.emit('myevent', myData); + }); + + it('simple once case works', function () { + var called = 0; + + obj.once('myevent', function() { called++; }); + + obj.emit('myevent'); + obj.emit('myevent'); + obj.emit('myevent'); + obj.emit('myevent'); + obj.emit('myevent'); + + expect(called).to.equal(1); + }); + + it('simple off case works', function (done) { + function onMyEvent() { + done(new Error('Event listener should not have been called')); + } + + obj.on('myevent', onMyEvent); + obj.off('myevent', onMyEvent); + obj.emit('myevent'); + + done(); + }); + + it('simple propagation case works', function (done) { + var myData = {}; + + pobj.on('myevent', function () { + done(); + }); + + obj.emit('myevent'); + }); + + it('simple stopPropagation case works', function (done) { + var myData = {}; + + pobj.on('myevent', function () { + done(new Error('Event listener should not have been called on the parent element')); + }); + + obj.on('myevent', function (evt) { + evt.stopPropagation(); + }); + + obj.emit('myevent'); + + done(); + }); + + it('simple stopImmediatePropagation case works', function (done) { + var myData = {}; + + pobj.on('myevent', function () { + done(new Error('Event listener should not have been called on the parent')); + }); + + obj.on('myevent', function (evt) { + evt.stopImmediatePropagation(); + }); + + obj.on('myevent', function () { + done(new Error('Event listener should not have been called on the second')); + }); + + obj.emit('myevent'); + + done(); + }); + + it('multiple dispatches work properly', function () { + var called = 0; + + function onMyEvent() { + called++; + } + + obj.on('myevent', onMyEvent); + obj.emit('myevent'); + obj.emit('myevent'); + obj.emit('myevent'); + obj.emit('myevent'); + + expect(called).to.equal(4); + }); + + it('multiple events work properly', function () { + var called = 0; + + function onMyEvent() { + called++; + } + + obj.on('myevent1', onMyEvent); + obj.on('myevent2', onMyEvent); + obj.on('myevent3', onMyEvent); + obj.emit('myevent1'); + obj.emit('myevent2'); + obj.emit('myevent3'); + + expect(called).to.equal(3); + }); + + it('multiple events one removed works properly', function () { + var called = 0; + + function onMyEvent() { + called++; + } + + obj.on('myevent1', onMyEvent); + obj.on('myevent2', onMyEvent); + obj.on('myevent3', onMyEvent); + + obj.emit('myevent1'); + obj.emit('myevent2'); + obj.emit('myevent3'); + + obj.off('myevent2', onMyEvent); + + obj.emit('myevent1'); + obj.emit('myevent2'); + obj.emit('myevent3'); + + expect(called).to.equal(5); + }); + + it('multiple handlers for one event with some removed', function () { + var called = 0; + + var onMyEvent = function () { + called++; + }, + onMyEvent2 = function () { + called++; + }; + + // add 2 handlers and confirm they both get called + obj.on('myevent', onMyEvent); + obj.on('myevent', onMyEvent); + obj.on('myevent', onMyEvent2); + obj.on('myevent', onMyEvent2); + + obj.emit('myevent'); + + expect(called).to.equal(4); + + // remove one of the handlers, emit again, then ensure 1 more call is made + obj.off('myevent', onMyEvent); + + obj.emit('myevent'); + + expect(called).to.equal(6); + }); + + it('calls to off without a handler do nothing', function () { + var called = 0; + + var onMyEvent = function () { + called++; + }; + + obj.on('myevent', onMyEvent); + obj.on('myevent', onMyEvent); + + obj.emit('myevent'); + + expect(called).to.equal(2); + + obj.off('myevent'); + + obj.emit('myevent'); + + expect(called).to.equal(4); + + obj.off('myevent', onMyEvent); + + obj.emit('myevent'); + + expect(called).to.equal(4); + }); + + it('handles multiple instances with the same prototype', function () { + var called = 0; + + function onMyEvent(e) { + called++; + } + + obj.on('myevent1', onMyEvent); + obj.on('myevent2', onMyEvent); + + obj2.istwo = true; + obj2.on('myevent1', onMyEvent); + obj2.on('myevent2', onMyEvent); + + obj.emit('myevent1'); + obj.emit('myevent2'); + obj2.emit('myevent1'); + obj2.emit('myevent2'); + + //we emit 4 times, but since obj2 is a child of obj the event should bubble + //up to obj and show up there as well. So the obj2.emit() calls each increment + //the counter twice. + expect(called).to.equal(6); + }); + + it('is backwards compatible with older .dispatchEvent({})', function () { + var called = 0, + data = { + some: 'thing', + hello: true + }; + + function onMyEvent(event) { + pixi_utils_EventTarget_Event_confirm(event, obj, data); + + called++; + } + + obj.on('myevent1', onMyEvent); + obj.on('myevent2', onMyEvent); + obj.on('myevent3', onMyEvent); + + data.type = 'myevent1'; + obj.emit(data); + + data.type = 'myevent2'; + obj.emit(data); + + data.type = 'myevent3'; + obj.emit(data); + + obj.off('myevent2', onMyEvent); + + data.type = 'myevent1'; + obj.emit(data); + + data.type = 'myevent2'; + obj.emit(data); + + data.type = 'myevent3'; + obj.emit(data); + + expect(called).to.equal(5); + }); + + it('is backwards compatible with older .call(this)', function () { + var Fn = function() { + PIXI.EventTarget.call(this); + }, + o = new Fn(); + + pixi_utils_EventTarget_confirm(o); + }); + + it('is backwards compatible with older .addEventListener("")', function () { + var called = 0, + data = { + some: 'thing', + hello: true + }; + + function onMyEvent(event) { + pixi_utils_EventTarget_Event_confirm(event, obj, data); + + called++; + } + + obj.addEventListener('myevent1', onMyEvent); + obj.addEventListener('myevent2', onMyEvent); + obj.addEventListener('myevent3', onMyEvent); + + data.type = 'myevent1'; + obj.emit(data); + + data.type = 'myevent2'; + obj.emit(data); + + data.type = 'myevent3'; + obj.emit(data); + + obj.off('myevent2', onMyEvent); + + data.type = 'myevent1'; + obj.emit(data); + + data.type = 'myevent2'; + obj.emit(data); + + data.type = 'myevent3'; + obj.emit(data); + + expect(called).to.equal(5); + }); + + it('event remove during emit call properly', function () { + var called = 0; + + function cb1() { + called++; + obj.off('myevent', cb1); + } + function cb2() { + called++; + obj.off('myevent', cb2); + } + function cb3() { + called++; + obj.off('myevent', cb3); + } + + obj.on('myevent', cb1); + obj.on('myevent', cb2); + obj.on('myevent', cb3); + obj.emit('myevent', ''); + + expect(called).to.equal(3); + }); +}); diff --git a/test/unit/pixi-v2/utils/Polyk.js b/test/unit/pixi-v2/utils/Polyk.js new file mode 100644 index 0000000..dfc7128 --- /dev/null +++ b/test/unit/pixi-v2/utils/Polyk.js @@ -0,0 +1,14 @@ +describe('pixi/utils/Polyk', function () { + 'use strict'; + + var expect = chai.expect; + var PolyK = PIXI.PolyK; + + it('Module exists', function () { + expect(PolyK).to.be.an('object'); + }); + + it('Members exist', function () { + expect(PolyK).to.respondTo('Triangulate'); + }); +}); diff --git a/test/unit/pixi-v2/utils/Utils.js b/test/unit/pixi-v2/utils/Utils.js new file mode 100644 index 0000000..c97b3c6 --- /dev/null +++ b/test/unit/pixi-v2/utils/Utils.js @@ -0,0 +1,17 @@ +describe('Utils', function () { + 'use strict'; + + var expect = chai.expect; + + it('requestAnimationFrame exists', function () { + expect(global).to.respondTo('requestAnimationFrame'); + }); + + it('cancelAnimationFrame exists', function () { + expect(global).to.respondTo('cancelAnimationFrame'); + }); + + it('requestAnimFrame exists', function () { + expect(global).to.respondTo('requestAnimFrame'); + }); +}); diff --git a/test/unit/pixi/InteractionManager.js b/test/unit/pixi/InteractionManager.js deleted file mode 100644 index ed3001f..0000000 --- a/test/unit/pixi/InteractionManager.js +++ /dev/null @@ -1,10 +0,0 @@ -describe('pixi/InteractionManager', function () { - 'use strict'; - - var expect = chai.expect; - var InteractionManager = PIXI.InteractionManager; - - it('Module exists', function () { - expect(InteractionManager).to.be.a('function'); - }); -}); diff --git a/test/unit/pixi/Pixi.js b/test/unit/pixi/Pixi.js deleted file mode 100644 index 27debc1..0000000 --- a/test/unit/pixi/Pixi.js +++ /dev/null @@ -1,9 +0,0 @@ -describe('pixi/Pixi', function () { - 'use strict'; - - var expect = chai.expect; - - it('Module exists', function () { - expect(global).to.have.property('PIXI').and.to.be.an('object'); - }); -}); diff --git a/test/unit/pixi/core/Circle.js b/test/unit/pixi/core/Circle.js deleted file mode 100644 index fbcfa17..0000000 --- a/test/unit/pixi/core/Circle.js +++ /dev/null @@ -1,21 +0,0 @@ -describe('pixi/core/Circle', function () { - 'use strict'; - - var expect = chai.expect; - var Circle = PIXI.Circle; - - it('Module exists', function () { - expect(Circle).to.be.a('function'); - }); - - it('Confirm new instance', function () { - var obj = new Circle(); - pixi_core_Circle_confirmNewCircle(obj); - }); - - it("getBounds should return Rectangle that bounds the circle", function() { - var obj = new Circle(100, 250, 50); - var bounds = obj.getBounds(); - pixi_core_Circle_isBoundedByRectangle(obj, bounds); - }); -}); diff --git a/test/unit/pixi/core/Ellipse.js b/test/unit/pixi/core/Ellipse.js deleted file mode 100644 index 026b56f..0000000 --- a/test/unit/pixi/core/Ellipse.js +++ /dev/null @@ -1,24 +0,0 @@ -describe('pixi/core/Ellipse', function () { - 'use strict'; - - var expect = chai.expect; - var Ellipse = PIXI.Ellipse; - - it('Module exists', function () { - expect(Ellipse).to.be.a('function'); - }); - - it('Confirm new instance', function () { - var obj = new Ellipse(); - - expect(obj).to.be.an.instanceof(Ellipse); - expect(obj).to.respondTo('clone'); - expect(obj).to.respondTo('contains'); - expect(obj).to.respondTo('getBounds'); - - expect(obj).to.have.property('x', 0); - expect(obj).to.have.property('y', 0); - expect(obj).to.have.property('width', 0); - expect(obj).to.have.property('height', 0); - }); -}); diff --git a/test/unit/pixi/core/Matrix.js b/test/unit/pixi/core/Matrix.js deleted file mode 100644 index da75e2e..0000000 --- a/test/unit/pixi/core/Matrix.js +++ /dev/null @@ -1,14 +0,0 @@ -describe('pixi/core/Matrix', function () { - 'use strict'; - - var expect = chai.expect; - - it('Matrix exists', function () { - expect(PIXI.Matrix).to.be.an('function'); - }); - - it('Confirm new Matrix', function () { - var matrix = new PIXI.Matrix(); - pixi_core_Matrix_confirmNewMatrix(matrix); - }); -}); diff --git a/test/unit/pixi/core/Point.js b/test/unit/pixi/core/Point.js deleted file mode 100644 index c4d5163..0000000 --- a/test/unit/pixi/core/Point.js +++ /dev/null @@ -1,15 +0,0 @@ -describe('pixi/core/Point', function () { - 'use strict'; - - var expect = chai.expect; - var Point = PIXI.Point; - - it('Module exists', function () { - expect(Point).to.be.a('function'); - }); - - it('Confirm new instance', function () { - var obj = new Point(); - pixi_core_Point_confirm(obj, 0, 0); - }); -}); diff --git a/test/unit/pixi/core/Polygon.js b/test/unit/pixi/core/Polygon.js deleted file mode 100644 index dc8c918..0000000 --- a/test/unit/pixi/core/Polygon.js +++ /dev/null @@ -1,20 +0,0 @@ -describe('pixi/core/Polygon', function () { - 'use strict'; - - var expect = chai.expect; - var Polygon = PIXI.Polygon; - - it('Module exists', function () { - expect(Polygon).to.be.a('function'); - }); - - it('Confirm new instance', function () { - var obj = new Polygon(); - - expect(obj).to.be.an.instanceof(Polygon); - expect(obj).to.respondTo('clone'); - expect(obj).to.respondTo('contains'); - - expect(obj).to.have.deep.property('points.length', 0); - }); -}); diff --git a/test/unit/pixi/core/Rectangle.js b/test/unit/pixi/core/Rectangle.js deleted file mode 100644 index d43316e..0000000 --- a/test/unit/pixi/core/Rectangle.js +++ /dev/null @@ -1,15 +0,0 @@ -describe('pixi/core/Rectangle', function () { - 'use strict'; - - var expect = chai.expect; - var Rectangle = PIXI.Rectangle; - - it('Module exists', function () { - expect(Rectangle).to.be.a('function'); - }); - - it('Confirm new instance', function () { - var rect = new Rectangle(); - pixi_core_Rectangle_confirm(rect, 0, 0, 0, 0); - }); -}); diff --git a/test/unit/pixi/display/DisplayObject.js b/test/unit/pixi/display/DisplayObject.js deleted file mode 100644 index 044acf8..0000000 --- a/test/unit/pixi/display/DisplayObject.js +++ /dev/null @@ -1,21 +0,0 @@ -describe('pixi/display/DisplayObject', function () { - 'use strict'; - - var expect = chai.expect; - var DisplayObject = PIXI.DisplayObject; - - it('Module exists', function () { - expect(DisplayObject).to.be.a('function'); - // expect(PIXI).to.have.property('visibleCount', 0); - }); - - it('Confirm new instance', function () { - var obj = new DisplayObject(); - - pixi_display_DisplayObject_confirmNew(obj); - expect(obj).to.have.property('hitArea', null); - expect(obj).to.have.property('interactive', false); - expect(obj).to.have.property('renderable', false); - expect(obj).to.have.property('stage', null); - }); -}); diff --git a/test/unit/pixi/display/DisplayObjectContainer.js b/test/unit/pixi/display/DisplayObjectContainer.js deleted file mode 100644 index 15a3376..0000000 --- a/test/unit/pixi/display/DisplayObjectContainer.js +++ /dev/null @@ -1,67 +0,0 @@ -describe('pixi/display/DisplayObjectContainer', function () { - 'use strict'; - - var expect = chai.expect; - var DisplayObjectContainer = PIXI.DisplayObjectContainer; - - it('Module exists', function () { - expect(DisplayObjectContainer).to.be.a('function'); - }); - - it('Confirm new instance', function () { - var obj = new DisplayObjectContainer(); - - pixi_display_DisplayObjectContainer_confirmNew(obj); - expect(obj).to.have.property('hitArea', null); - expect(obj).to.have.property('interactive', false); - expect(obj).to.have.property('renderable', false); - expect(obj).to.have.property('stage', null); - }); - - it('Gets child index', function() { - var container = new PIXI.DisplayObjectContainer(); - var children = []; - for (var i = 0; i < 10; i++) { - var child = new PIXI.DisplayObject(); - children.push(child); - container.addChild(child); - } - - for (i = 0; i < children.length; i++) { - expect(i).to.eql(container.getChildIndex(children[i])); - } - }); - - it('throws error when trying to get index of not a child', function() { - var container = new PIXI.DisplayObjectContainer(); - var child = new PIXI.DisplayObject(); - - expect(function() { container.getChildIndex(child); }).to.throw(); - }); - - it('Sets child index', function() { - var container = new PIXI.DisplayObjectContainer(); - var children = []; - - for (var i = 0; i < 10; i++) { - var child = new PIXI.DisplayObject(); - children.push(child); - container.addChild(child); - } - children.reverse(); - - for (i = 0; i < children.length; i++) { - container.setChildIndex(children[i], i); - expect(i).to.eql(container.getChildIndex(children[i])); - } - }); - - it('throws error when trying to set incorect index', function() { - var container = new PIXI.DisplayObjectContainer(); - var child = new PIXI.DisplayObject(); - container.addChild(child); - - expect(function() { container.setChildIndex(child, -1); }).to.throw(); - expect(function() { container.setChildIndex(child, 1); }).to.throw(); - }); -}); diff --git a/test/unit/pixi/display/MovieClip.js b/test/unit/pixi/display/MovieClip.js deleted file mode 100644 index f3c6c6a..0000000 --- a/test/unit/pixi/display/MovieClip.js +++ /dev/null @@ -1,33 +0,0 @@ -describe('pixi/display/MovieClip', function () { - 'use strict'; - - var expect = chai.expect; - var MovieClip = PIXI.MovieClip; - var Texture = PIXI.Texture; - - it('Module exists', function () { - expect(MovieClip).to.be.a('function'); - }); - - it('Confirm new instance', function (done) { - var texture = Texture.fromImage('/base/test/textures/SpriteSheet-Explosion.png'); - var obj = new MovieClip([texture]); - - pixi_display_Sprite_confirmNew(obj, done); - - expect(obj).to.be.an.instanceof(MovieClip); - expect(obj).to.respondTo('stop'); - expect(obj).to.respondTo('play'); - expect(obj).to.respondTo('gotoAndStop'); - expect(obj).to.respondTo('gotoAndPlay'); - expect(obj).to.respondTo('updateTransform'); - - expect(obj).to.have.deep.property('textures.length', 1); - expect(obj).to.have.deep.property('textures[0]', texture); - expect(obj).to.have.property('animationSpeed', 1); - expect(obj).to.have.property('loop', true); - expect(obj).to.have.property('onComplete', null); - expect(obj).to.have.property('currentFrame', 0); - expect(obj).to.have.property('playing', false); - }); -}); diff --git a/test/unit/pixi/display/Sprite.js b/test/unit/pixi/display/Sprite.js deleted file mode 100644 index 30c8076..0000000 --- a/test/unit/pixi/display/Sprite.js +++ /dev/null @@ -1,28 +0,0 @@ -describe('pixi/display/Sprite', function () { - 'use strict'; - - var expect = chai.expect; - var Sprite = PIXI.Sprite; - var Texture = PIXI.Texture; - - it('Module exists', function () { - expect(Sprite).to.be.a('function'); - expect(PIXI).to.have.deep.property('blendModes.NORMAL', 0); - expect(PIXI).to.have.deep.property('blendModes.ADD', 1); - expect(PIXI).to.have.deep.property('blendModes.MULTIPLY', 2); - expect(PIXI).to.have.deep.property('blendModes.SCREEN', 3); - }); - - - it('Members exist', function () { - expect(Sprite).itself.to.respondTo('fromImage'); - expect(Sprite).itself.to.respondTo('fromFrame'); - }); - - it('Confirm new instance', function (done) { - var texture = Texture.fromImage('/base/test/textures/SpriteSheet-Aliens.png'); - var obj = new Sprite(texture); - - pixi_display_Sprite_confirmNew(obj, done); - }); -}); diff --git a/test/unit/pixi/display/Stage.js b/test/unit/pixi/display/Stage.js deleted file mode 100644 index 6974c2e..0000000 --- a/test/unit/pixi/display/Stage.js +++ /dev/null @@ -1,49 +0,0 @@ -describe('pixi/display/Stage', function () { - 'use strict'; - - var expect = chai.expect; - var Stage = PIXI.Stage; - var InteractionManager = PIXI.InteractionManager; - var Rectangle = PIXI.Rectangle; - - it('Module exists', function () { - expect(Stage).to.be.a('function'); - }); - - it('Confirm new instance', function () { - var obj = new Stage(null, true); - - pixi_display_DisplayObjectContainer_confirmNew(obj); - - expect(obj).to.be.an.instanceof(Stage); - expect(obj).to.respondTo('updateTransform'); - expect(obj).to.respondTo('setBackgroundColor'); - expect(obj).to.respondTo('getMousePosition'); - // FIXME: duplicate member in DisplayObject - pixi_core_Matrix_confirmNewMatrix(obj.worldTransform); - // FIXME: convert arg to bool in constructor - expect(obj).to.have.property('interactive', true); - - expect(obj).to.have.property('interactionManager') - .and.to.be.an.instanceof(InteractionManager) - .and.to.have.property('stage', obj); - - expect(obj).to.have.property('dirty', true); - - expect(obj).to.have.property('stage', obj); - - expect(obj).to.have.property('hitArea') - .and.to.be.an.instanceof(Rectangle); - pixi_core_Rectangle_confirm(obj.hitArea, 0, 0, 100000, 100000); - - expect(obj).to.have.property('backgroundColor', 0x000000); - expect(obj).to.have.deep.property('backgroundColorSplit.length', 3); - expect(obj).to.have.deep.property('backgroundColorSplit[0]', 0); - expect(obj).to.have.deep.property('backgroundColorSplit[1]', 0); - expect(obj).to.have.deep.property('backgroundColorSplit[2]', 0); - expect(obj).to.have.property('backgroundColorString', '#000000'); - - - expect(obj).to.have.property('worldVisible', true); - }); -}); diff --git a/test/unit/pixi/extras/Rope.js b/test/unit/pixi/extras/Rope.js deleted file mode 100644 index 05885ac..0000000 --- a/test/unit/pixi/extras/Rope.js +++ /dev/null @@ -1,31 +0,0 @@ -describe('pixi/extras/Rope', function () { - 'use strict'; - - var expect = chai.expect; - var Rope = PIXI.Rope; - var Texture = PIXI.Texture; - var Point = PIXI.Point; - - it('Module exists', function () { - expect(Rope).to.be.a('function'); - }); - - it('Confirm new instance', function () { - - var texture = Texture.fromImage('/base/test/textures/bunny.png'); - - // TODO-Alvin - // Same as Strip - - // var obj = new Rope(texture, [new Point(), new Point(5, 10), new Point(10, 20)]); - - // pixi_extras_Strip_confirmNew(obj); - - // expect(obj).to.be.an.instanceof(Rope); - // expect(obj).to.respondTo('refresh'); - // expect(obj).to.respondTo('updateTransform'); - // expect(obj).to.respondTo('setTexture'); - - // TODO: Test properties - }); -}); diff --git a/test/unit/pixi/extras/Spine.js b/test/unit/pixi/extras/Spine.js deleted file mode 100644 index 0708bc0..0000000 --- a/test/unit/pixi/extras/Spine.js +++ /dev/null @@ -1,10 +0,0 @@ -describe('pixi/extras/Spine', function () { - 'use strict'; - - var expect = chai.expect; - var Spine = PIXI.Spine; - - it('Module exists', function () { - expect(Spine).to.be.a('function'); - }); -}); diff --git a/test/unit/pixi-v2/InteractionManager.js b/test/unit/pixi-v2/InteractionManager.js new file mode 100644 index 0000000..ed3001f --- /dev/null +++ b/test/unit/pixi-v2/InteractionManager.js @@ -0,0 +1,10 @@ +describe('pixi/InteractionManager', function () { + 'use strict'; + + var expect = chai.expect; + var InteractionManager = PIXI.InteractionManager; + + it('Module exists', function () { + expect(InteractionManager).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/Pixi.js b/test/unit/pixi-v2/Pixi.js new file mode 100644 index 0000000..27debc1 --- /dev/null +++ b/test/unit/pixi-v2/Pixi.js @@ -0,0 +1,9 @@ +describe('pixi/Pixi', function () { + 'use strict'; + + var expect = chai.expect; + + it('Module exists', function () { + expect(global).to.have.property('PIXI').and.to.be.an('object'); + }); +}); diff --git a/test/unit/pixi-v2/core/Circle.js b/test/unit/pixi-v2/core/Circle.js new file mode 100644 index 0000000..fbcfa17 --- /dev/null +++ b/test/unit/pixi-v2/core/Circle.js @@ -0,0 +1,21 @@ +describe('pixi/core/Circle', function () { + 'use strict'; + + var expect = chai.expect; + var Circle = PIXI.Circle; + + it('Module exists', function () { + expect(Circle).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Circle(); + pixi_core_Circle_confirmNewCircle(obj); + }); + + it("getBounds should return Rectangle that bounds the circle", function() { + var obj = new Circle(100, 250, 50); + var bounds = obj.getBounds(); + pixi_core_Circle_isBoundedByRectangle(obj, bounds); + }); +}); diff --git a/test/unit/pixi-v2/core/Ellipse.js b/test/unit/pixi-v2/core/Ellipse.js new file mode 100644 index 0000000..026b56f --- /dev/null +++ b/test/unit/pixi-v2/core/Ellipse.js @@ -0,0 +1,24 @@ +describe('pixi/core/Ellipse', function () { + 'use strict'; + + var expect = chai.expect; + var Ellipse = PIXI.Ellipse; + + it('Module exists', function () { + expect(Ellipse).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Ellipse(); + + expect(obj).to.be.an.instanceof(Ellipse); + expect(obj).to.respondTo('clone'); + expect(obj).to.respondTo('contains'); + expect(obj).to.respondTo('getBounds'); + + expect(obj).to.have.property('x', 0); + expect(obj).to.have.property('y', 0); + expect(obj).to.have.property('width', 0); + expect(obj).to.have.property('height', 0); + }); +}); diff --git a/test/unit/pixi-v2/core/Matrix.js b/test/unit/pixi-v2/core/Matrix.js new file mode 100644 index 0000000..da75e2e --- /dev/null +++ b/test/unit/pixi-v2/core/Matrix.js @@ -0,0 +1,14 @@ +describe('pixi/core/Matrix', function () { + 'use strict'; + + var expect = chai.expect; + + it('Matrix exists', function () { + expect(PIXI.Matrix).to.be.an('function'); + }); + + it('Confirm new Matrix', function () { + var matrix = new PIXI.Matrix(); + pixi_core_Matrix_confirmNewMatrix(matrix); + }); +}); diff --git a/test/unit/pixi-v2/core/Point.js b/test/unit/pixi-v2/core/Point.js new file mode 100644 index 0000000..c4d5163 --- /dev/null +++ b/test/unit/pixi-v2/core/Point.js @@ -0,0 +1,15 @@ +describe('pixi/core/Point', function () { + 'use strict'; + + var expect = chai.expect; + var Point = PIXI.Point; + + it('Module exists', function () { + expect(Point).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Point(); + pixi_core_Point_confirm(obj, 0, 0); + }); +}); diff --git a/test/unit/pixi-v2/core/Polygon.js b/test/unit/pixi-v2/core/Polygon.js new file mode 100644 index 0000000..dc8c918 --- /dev/null +++ b/test/unit/pixi-v2/core/Polygon.js @@ -0,0 +1,20 @@ +describe('pixi/core/Polygon', function () { + 'use strict'; + + var expect = chai.expect; + var Polygon = PIXI.Polygon; + + it('Module exists', function () { + expect(Polygon).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Polygon(); + + expect(obj).to.be.an.instanceof(Polygon); + expect(obj).to.respondTo('clone'); + expect(obj).to.respondTo('contains'); + + expect(obj).to.have.deep.property('points.length', 0); + }); +}); diff --git a/test/unit/pixi-v2/core/Rectangle.js b/test/unit/pixi-v2/core/Rectangle.js new file mode 100644 index 0000000..d43316e --- /dev/null +++ b/test/unit/pixi-v2/core/Rectangle.js @@ -0,0 +1,15 @@ +describe('pixi/core/Rectangle', function () { + 'use strict'; + + var expect = chai.expect; + var Rectangle = PIXI.Rectangle; + + it('Module exists', function () { + expect(Rectangle).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var rect = new Rectangle(); + pixi_core_Rectangle_confirm(rect, 0, 0, 0, 0); + }); +}); diff --git a/test/unit/pixi-v2/display/DisplayObject.js b/test/unit/pixi-v2/display/DisplayObject.js new file mode 100644 index 0000000..044acf8 --- /dev/null +++ b/test/unit/pixi-v2/display/DisplayObject.js @@ -0,0 +1,21 @@ +describe('pixi/display/DisplayObject', function () { + 'use strict'; + + var expect = chai.expect; + var DisplayObject = PIXI.DisplayObject; + + it('Module exists', function () { + expect(DisplayObject).to.be.a('function'); + // expect(PIXI).to.have.property('visibleCount', 0); + }); + + it('Confirm new instance', function () { + var obj = new DisplayObject(); + + pixi_display_DisplayObject_confirmNew(obj); + expect(obj).to.have.property('hitArea', null); + expect(obj).to.have.property('interactive', false); + expect(obj).to.have.property('renderable', false); + expect(obj).to.have.property('stage', null); + }); +}); diff --git a/test/unit/pixi-v2/display/DisplayObjectContainer.js b/test/unit/pixi-v2/display/DisplayObjectContainer.js new file mode 100644 index 0000000..15a3376 --- /dev/null +++ b/test/unit/pixi-v2/display/DisplayObjectContainer.js @@ -0,0 +1,67 @@ +describe('pixi/display/DisplayObjectContainer', function () { + 'use strict'; + + var expect = chai.expect; + var DisplayObjectContainer = PIXI.DisplayObjectContainer; + + it('Module exists', function () { + expect(DisplayObjectContainer).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new DisplayObjectContainer(); + + pixi_display_DisplayObjectContainer_confirmNew(obj); + expect(obj).to.have.property('hitArea', null); + expect(obj).to.have.property('interactive', false); + expect(obj).to.have.property('renderable', false); + expect(obj).to.have.property('stage', null); + }); + + it('Gets child index', function() { + var container = new PIXI.DisplayObjectContainer(); + var children = []; + for (var i = 0; i < 10; i++) { + var child = new PIXI.DisplayObject(); + children.push(child); + container.addChild(child); + } + + for (i = 0; i < children.length; i++) { + expect(i).to.eql(container.getChildIndex(children[i])); + } + }); + + it('throws error when trying to get index of not a child', function() { + var container = new PIXI.DisplayObjectContainer(); + var child = new PIXI.DisplayObject(); + + expect(function() { container.getChildIndex(child); }).to.throw(); + }); + + it('Sets child index', function() { + var container = new PIXI.DisplayObjectContainer(); + var children = []; + + for (var i = 0; i < 10; i++) { + var child = new PIXI.DisplayObject(); + children.push(child); + container.addChild(child); + } + children.reverse(); + + for (i = 0; i < children.length; i++) { + container.setChildIndex(children[i], i); + expect(i).to.eql(container.getChildIndex(children[i])); + } + }); + + it('throws error when trying to set incorect index', function() { + var container = new PIXI.DisplayObjectContainer(); + var child = new PIXI.DisplayObject(); + container.addChild(child); + + expect(function() { container.setChildIndex(child, -1); }).to.throw(); + expect(function() { container.setChildIndex(child, 1); }).to.throw(); + }); +}); diff --git a/test/unit/pixi-v2/display/MovieClip.js b/test/unit/pixi-v2/display/MovieClip.js new file mode 100644 index 0000000..f3c6c6a --- /dev/null +++ b/test/unit/pixi-v2/display/MovieClip.js @@ -0,0 +1,33 @@ +describe('pixi/display/MovieClip', function () { + 'use strict'; + + var expect = chai.expect; + var MovieClip = PIXI.MovieClip; + var Texture = PIXI.Texture; + + it('Module exists', function () { + expect(MovieClip).to.be.a('function'); + }); + + it('Confirm new instance', function (done) { + var texture = Texture.fromImage('/base/test/textures/SpriteSheet-Explosion.png'); + var obj = new MovieClip([texture]); + + pixi_display_Sprite_confirmNew(obj, done); + + expect(obj).to.be.an.instanceof(MovieClip); + expect(obj).to.respondTo('stop'); + expect(obj).to.respondTo('play'); + expect(obj).to.respondTo('gotoAndStop'); + expect(obj).to.respondTo('gotoAndPlay'); + expect(obj).to.respondTo('updateTransform'); + + expect(obj).to.have.deep.property('textures.length', 1); + expect(obj).to.have.deep.property('textures[0]', texture); + expect(obj).to.have.property('animationSpeed', 1); + expect(obj).to.have.property('loop', true); + expect(obj).to.have.property('onComplete', null); + expect(obj).to.have.property('currentFrame', 0); + expect(obj).to.have.property('playing', false); + }); +}); diff --git a/test/unit/pixi-v2/display/Sprite.js b/test/unit/pixi-v2/display/Sprite.js new file mode 100644 index 0000000..30c8076 --- /dev/null +++ b/test/unit/pixi-v2/display/Sprite.js @@ -0,0 +1,28 @@ +describe('pixi/display/Sprite', function () { + 'use strict'; + + var expect = chai.expect; + var Sprite = PIXI.Sprite; + var Texture = PIXI.Texture; + + it('Module exists', function () { + expect(Sprite).to.be.a('function'); + expect(PIXI).to.have.deep.property('blendModes.NORMAL', 0); + expect(PIXI).to.have.deep.property('blendModes.ADD', 1); + expect(PIXI).to.have.deep.property('blendModes.MULTIPLY', 2); + expect(PIXI).to.have.deep.property('blendModes.SCREEN', 3); + }); + + + it('Members exist', function () { + expect(Sprite).itself.to.respondTo('fromImage'); + expect(Sprite).itself.to.respondTo('fromFrame'); + }); + + it('Confirm new instance', function (done) { + var texture = Texture.fromImage('/base/test/textures/SpriteSheet-Aliens.png'); + var obj = new Sprite(texture); + + pixi_display_Sprite_confirmNew(obj, done); + }); +}); diff --git a/test/unit/pixi-v2/display/Stage.js b/test/unit/pixi-v2/display/Stage.js new file mode 100644 index 0000000..6974c2e --- /dev/null +++ b/test/unit/pixi-v2/display/Stage.js @@ -0,0 +1,49 @@ +describe('pixi/display/Stage', function () { + 'use strict'; + + var expect = chai.expect; + var Stage = PIXI.Stage; + var InteractionManager = PIXI.InteractionManager; + var Rectangle = PIXI.Rectangle; + + it('Module exists', function () { + expect(Stage).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Stage(null, true); + + pixi_display_DisplayObjectContainer_confirmNew(obj); + + expect(obj).to.be.an.instanceof(Stage); + expect(obj).to.respondTo('updateTransform'); + expect(obj).to.respondTo('setBackgroundColor'); + expect(obj).to.respondTo('getMousePosition'); + // FIXME: duplicate member in DisplayObject + pixi_core_Matrix_confirmNewMatrix(obj.worldTransform); + // FIXME: convert arg to bool in constructor + expect(obj).to.have.property('interactive', true); + + expect(obj).to.have.property('interactionManager') + .and.to.be.an.instanceof(InteractionManager) + .and.to.have.property('stage', obj); + + expect(obj).to.have.property('dirty', true); + + expect(obj).to.have.property('stage', obj); + + expect(obj).to.have.property('hitArea') + .and.to.be.an.instanceof(Rectangle); + pixi_core_Rectangle_confirm(obj.hitArea, 0, 0, 100000, 100000); + + expect(obj).to.have.property('backgroundColor', 0x000000); + expect(obj).to.have.deep.property('backgroundColorSplit.length', 3); + expect(obj).to.have.deep.property('backgroundColorSplit[0]', 0); + expect(obj).to.have.deep.property('backgroundColorSplit[1]', 0); + expect(obj).to.have.deep.property('backgroundColorSplit[2]', 0); + expect(obj).to.have.property('backgroundColorString', '#000000'); + + + expect(obj).to.have.property('worldVisible', true); + }); +}); diff --git a/test/unit/pixi-v2/extras/Rope.js b/test/unit/pixi-v2/extras/Rope.js new file mode 100644 index 0000000..05885ac --- /dev/null +++ b/test/unit/pixi-v2/extras/Rope.js @@ -0,0 +1,31 @@ +describe('pixi/extras/Rope', function () { + 'use strict'; + + var expect = chai.expect; + var Rope = PIXI.Rope; + var Texture = PIXI.Texture; + var Point = PIXI.Point; + + it('Module exists', function () { + expect(Rope).to.be.a('function'); + }); + + it('Confirm new instance', function () { + + var texture = Texture.fromImage('/base/test/textures/bunny.png'); + + // TODO-Alvin + // Same as Strip + + // var obj = new Rope(texture, [new Point(), new Point(5, 10), new Point(10, 20)]); + + // pixi_extras_Strip_confirmNew(obj); + + // expect(obj).to.be.an.instanceof(Rope); + // expect(obj).to.respondTo('refresh'); + // expect(obj).to.respondTo('updateTransform'); + // expect(obj).to.respondTo('setTexture'); + + // TODO: Test properties + }); +}); diff --git a/test/unit/pixi-v2/extras/Spine.js b/test/unit/pixi-v2/extras/Spine.js new file mode 100644 index 0000000..0708bc0 --- /dev/null +++ b/test/unit/pixi-v2/extras/Spine.js @@ -0,0 +1,10 @@ +describe('pixi/extras/Spine', function () { + 'use strict'; + + var expect = chai.expect; + var Spine = PIXI.Spine; + + it('Module exists', function () { + expect(Spine).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/extras/Strip.js b/test/unit/pixi-v2/extras/Strip.js new file mode 100644 index 0000000..230af90 --- /dev/null +++ b/test/unit/pixi-v2/extras/Strip.js @@ -0,0 +1,26 @@ +describe('pixi/extras/Strip', function () { + 'use strict'; + + var expect = chai.expect; + var Strip = PIXI.Strip; + var Texture = PIXI.Texture; + + it('Module exists', function () { + expect(Strip).to.be.a('function'); + }); + + it('Confirm new instance', function () { + + + // TODO-Alvin + // We tweaked it to make it pass the tests, but the whole strip class needs + // to be re-coded + + var texture = Texture.fromImage('/base/test/textures/bunny.png'); + + // var obj = new Strip(texture, 20, 10000); + + + // pixi_extras_Strip_confirmNew(obj); + }); +}); diff --git a/test/unit/pixi-v2/extras/TilingSprite.js b/test/unit/pixi-v2/extras/TilingSprite.js new file mode 100644 index 0000000..56aea14 --- /dev/null +++ b/test/unit/pixi-v2/extras/TilingSprite.js @@ -0,0 +1,24 @@ +describe('pixi/extras/TilingSprite', function () { + 'use strict'; + + var expect = chai.expect; + var TilingSprite = PIXI.TilingSprite; + var Texture = PIXI.Texture; + + it('Module exists', function () { + expect(TilingSprite).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var texture = Texture.fromImage('/base/test/textures/bunny.png'); + var obj = new TilingSprite(texture, 6000, 12000); + + pixi_display_DisplayObjectContainer_confirmNew(obj); + + expect(obj).to.be.an.instanceof(TilingSprite); + expect(obj).to.respondTo('setTexture'); + expect(obj).to.respondTo('onTextureUpdate'); + + // TODO: Test properties + }); +}); diff --git a/test/unit/pixi-v2/filters/FilterBlock.js b/test/unit/pixi-v2/filters/FilterBlock.js new file mode 100644 index 0000000..870cec0 --- /dev/null +++ b/test/unit/pixi-v2/filters/FilterBlock.js @@ -0,0 +1,10 @@ +describe('pixi/filters/FilterBlock', function () { + 'use strict'; + + var expect = chai.expect; + var FilterBlock = PIXI.FilterBlock; + + it('Module exists', function () { + expect(FilterBlock).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/AssetLoader.js b/test/unit/pixi-v2/loaders/AssetLoader.js new file mode 100644 index 0000000..a0aa0b5 --- /dev/null +++ b/test/unit/pixi-v2/loaders/AssetLoader.js @@ -0,0 +1,10 @@ +describe('pixi/loaders/AssetLoader', function () { + 'use strict'; + + var expect = chai.expect; + var AssetLoader = PIXI.AssetLoader; + + it('Module exists', function () { + expect(AssetLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/BitmapFontLoader.js b/test/unit/pixi-v2/loaders/BitmapFontLoader.js new file mode 100644 index 0000000..046f018 --- /dev/null +++ b/test/unit/pixi-v2/loaders/BitmapFontLoader.js @@ -0,0 +1,9 @@ +describe('pixi/loaders/BitmapFontLoader', function () { + 'use strict'; + + var expect = chai.expect; + + it('Module exists', function () { + expect(PIXI.BitmapFontLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/ImageLoader.js b/test/unit/pixi-v2/loaders/ImageLoader.js new file mode 100644 index 0000000..8b1f556 --- /dev/null +++ b/test/unit/pixi-v2/loaders/ImageLoader.js @@ -0,0 +1,10 @@ +describe('pixi/loaders/ImageLoader', function () { + 'use strict'; + + var expect = chai.expect; + var ImageLoader = PIXI.ImageLoader; + + it('Module exists', function () { + expect(ImageLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/JsonLoader.js b/test/unit/pixi-v2/loaders/JsonLoader.js new file mode 100644 index 0000000..c577e83 --- /dev/null +++ b/test/unit/pixi-v2/loaders/JsonLoader.js @@ -0,0 +1,10 @@ +describe('pixi/loaders/JsonLoader', function () { + 'use strict'; + + var expect = chai.expect; + var JsonLoader = PIXI.JsonLoader; + + it('Module exists', function () { + expect(JsonLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/SpineLoader.js b/test/unit/pixi-v2/loaders/SpineLoader.js new file mode 100644 index 0000000..fdcc0b8 --- /dev/null +++ b/test/unit/pixi-v2/loaders/SpineLoader.js @@ -0,0 +1,10 @@ +describe('pixi/loaders/SpineLoader', function () { + 'use strict'; + + var expect = chai.expect; + var SpineLoader = PIXI.SpineLoader; + + it('Module exists', function () { + expect(SpineLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/SpriteSheetLoader.js b/test/unit/pixi-v2/loaders/SpriteSheetLoader.js new file mode 100644 index 0000000..57beb27 --- /dev/null +++ b/test/unit/pixi-v2/loaders/SpriteSheetLoader.js @@ -0,0 +1,10 @@ +describe('pixi/loaders/SpriteSheetLoader', function () { + 'use strict'; + + var expect = chai.expect; + var SpriteSheetLoader = PIXI.SpriteSheetLoader; + + it('Module exists', function () { + expect(SpriteSheetLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/primitives/Graphics.js b/test/unit/pixi-v2/primitives/Graphics.js new file mode 100644 index 0000000..f3849eb --- /dev/null +++ b/test/unit/pixi-v2/primitives/Graphics.js @@ -0,0 +1,44 @@ +describe('pixi/primitives/Graphics', function () { + 'use strict'; + + var expect = chai.expect; + var Graphics = PIXI.Graphics; + + it('Module exists', function () { + expect(Graphics).to.be.a('function'); + + expect(Graphics).itself.to.have.property('POLY', 0); + expect(Graphics).itself.to.have.property('RECT', 1); + expect(Graphics).itself.to.have.property('CIRC', 2); + expect(Graphics).itself.to.have.property('ELIP', 3); + expect(Graphics).itself.to.have.property('RREC', 4); + }); + + it('Confirm new instance', function () { + var obj = new Graphics(); + + pixi_display_DisplayObjectContainer_confirmNew(obj); + + expect(obj).to.be.an.instanceof(Graphics); + expect(obj).to.respondTo('lineStyle'); + expect(obj).to.respondTo('lineStyle'); + expect(obj).to.respondTo('moveTo'); + expect(obj).to.respondTo('lineTo'); + expect(obj).to.respondTo('beginFill'); + expect(obj).to.respondTo('endFill'); + expect(obj).to.respondTo('drawRect'); + // expect(obj).to.respondTo('drawRoundedRect'); + expect(obj).to.respondTo('drawCircle'); + expect(obj).to.respondTo('drawEllipse'); + expect(obj).to.respondTo('clear'); + + expect(obj).to.have.property('renderable', true); + expect(obj).to.have.property('fillAlpha', 1); + expect(obj).to.have.property('lineWidth', 0); + expect(obj).to.have.property('width', 0); + expect(obj).to.have.property('height', 0); + expect(obj).to.have.property('lineColor', 0); + expect(obj).to.have.deep.property('graphicsData.length', 0); + // expect(obj).to.have.deep.property('currentPath.points.length', 0); + }); +}); diff --git a/test/unit/pixi-v2/renderers/canvas/CanvasGraphics.js b/test/unit/pixi-v2/renderers/canvas/CanvasGraphics.js new file mode 100644 index 0000000..8f44472 --- /dev/null +++ b/test/unit/pixi-v2/renderers/canvas/CanvasGraphics.js @@ -0,0 +1,15 @@ +describe('renders/canvas/CanvasGraphics', function () { + 'use strict'; + + var expect = chai.expect; + var CanvasGraphics = PIXI.CanvasGraphics; + + it('Module exists', function () { + expect(CanvasGraphics).to.be.a('function'); + }); + + it('Members exist', function () { + expect(CanvasGraphics).itself.to.respondTo('renderGraphics'); + expect(CanvasGraphics).itself.to.respondTo('renderGraphicsMask'); + }); +}); diff --git a/test/unit/pixi-v2/renderers/canvas/CanvasRenderer.js b/test/unit/pixi-v2/renderers/canvas/CanvasRenderer.js new file mode 100644 index 0000000..1646444 --- /dev/null +++ b/test/unit/pixi-v2/renderers/canvas/CanvasRenderer.js @@ -0,0 +1,36 @@ +describe('renderers/canvas/CanvasRenderer', function () { + 'use strict'; + + var expect = chai.expect; + var CanvasRenderer = PIXI.CanvasRenderer; + + it('Module exists', function () { + expect(CanvasRenderer).to.be.a('function'); + }); + + describe('.autoResize', function () { + it('Should automatically resize view if enabled', function () { + var renderer = new CanvasRenderer(200, 200, { + autoResize: true + }); + + expect(renderer.view.style.width).to.equal('200px'); + }); + + it('Should not automatically resize view if disabled', function () { + var renderer = new CanvasRenderer(200, 200, { + autoResize: false + }); + + expect(renderer.view.style.width).to.equal(''); + }); + + it('Should not automatically resize view if not specified', function () { + var renderer = new CanvasRenderer(200, 200, { + resolution: 2 + }); + + expect(renderer.view.style.width).to.equal(''); + }); + }); +}); diff --git a/test/unit/pixi-v2/renderers/webgl/WebGLGraphics.js b/test/unit/pixi-v2/renderers/webgl/WebGLGraphics.js new file mode 100644 index 0000000..5867b28 --- /dev/null +++ b/test/unit/pixi-v2/renderers/webgl/WebGLGraphics.js @@ -0,0 +1,20 @@ +describe('renderers/wegbl/WebGLGraphics', function () { + 'use strict'; + + var expect = chai.expect; + var WebGLGraphics = PIXI.WebGLGraphics; + + it('Module exists', function () { + expect(WebGLGraphics).to.be.a('function'); + }); + + it('Members exist', function () { + expect(WebGLGraphics).itself.to.respondTo('renderGraphics'); + expect(WebGLGraphics).itself.to.respondTo('updateGraphics'); + expect(WebGLGraphics).itself.to.respondTo('buildRectangle'); + expect(WebGLGraphics).itself.to.respondTo('buildRoundedRectangle'); + expect(WebGLGraphics).itself.to.respondTo('buildCircle'); + expect(WebGLGraphics).itself.to.respondTo('buildLine'); + expect(WebGLGraphics).itself.to.respondTo('buildPoly'); + }); +}); diff --git a/test/unit/pixi-v2/renderers/webgl/WebGLRenderer.js b/test/unit/pixi-v2/renderers/webgl/WebGLRenderer.js new file mode 100644 index 0000000..1680a80 --- /dev/null +++ b/test/unit/pixi-v2/renderers/webgl/WebGLRenderer.js @@ -0,0 +1,49 @@ +describe('renderers/webgl/WebGLRenderer', function () { + 'use strict'; + + var expect = chai.expect; + var WebGLRenderer = PIXI.WebGLRenderer; + + it('Module exists', function () { + expect(WebGLRenderer).to.be.a('function'); + }); + + // Skip tests if WebGL is not available (WebGL not supported in Travis CI) + try { + var renderer = new WebGLRenderer(400, 300, {}); + renderer.destroy(); + } catch (error) { + return; + } + + it('Destroy renderer', function () { + var renderer = new WebGLRenderer(400, 300, {}); + renderer.destroy(); + }); + + describe('.autoResize', function () { + it('Should automatically resize view if enabled', function () { + var renderer = new WebGLRenderer(200, 200, { + autoResize: true + }); + + expect(renderer.view.style.width).to.equal('200px'); + }); + + it('Should not automatically resize view if disabled', function () { + var renderer = new WebGLRenderer(200, 200, { + autoResize: false + }); + + expect(renderer.view.style.width).to.equal(''); + }); + + it('Should not automatically resize view if not specified', function () { + var renderer = new WebGLRenderer(200, 200, { + resolution: 2 + }); + + expect(renderer.view.style.width).to.equal(''); + }); + }); +}); diff --git a/test/unit/pixi-v2/renderers/webgl/WebGLShaders.js b/test/unit/pixi-v2/renderers/webgl/WebGLShaders.js new file mode 100644 index 0000000..6e33e4f --- /dev/null +++ b/test/unit/pixi-v2/renderers/webgl/WebGLShaders.js @@ -0,0 +1,13 @@ +describe('renderers/webgl/WebGLShaders', function () { + 'use strict'; + + var expect = chai.expect; + + it('Module members exist', function () { + + expect(PIXI).to.respondTo('CompileVertexShader'); + expect(PIXI).to.respondTo('CompileFragmentShader'); + expect(PIXI).to.respondTo('_CompileShader'); + expect(PIXI).to.respondTo('compileProgram'); + }); +}); diff --git a/test/unit/pixi-v2/renderers/webgl/WebGLSpriteBatch.js b/test/unit/pixi-v2/renderers/webgl/WebGLSpriteBatch.js new file mode 100644 index 0000000..e662b63 --- /dev/null +++ b/test/unit/pixi-v2/renderers/webgl/WebGLSpriteBatch.js @@ -0,0 +1,10 @@ +describe('renderers/webgl/utils/WebGLSpriteBatch', function () { + 'use strict'; + + var expect = chai.expect; + var WebGLSpriteBatch = PIXI.WebGLSpriteBatch; + + it('Module exists', function () { + expect(WebGLSpriteBatch).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/text/BitmapText.js b/test/unit/pixi-v2/text/BitmapText.js new file mode 100644 index 0000000..9388e3d --- /dev/null +++ b/test/unit/pixi-v2/text/BitmapText.js @@ -0,0 +1,10 @@ +describe('pixi/text/BitmapText', function () { + 'use strict'; + + var expect = chai.expect; + var BitmapText = PIXI.BitmapText; + + it('Module exists', function () { + expect(BitmapText).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/text/Text.js b/test/unit/pixi-v2/text/Text.js new file mode 100644 index 0000000..9bc9ac5 --- /dev/null +++ b/test/unit/pixi-v2/text/Text.js @@ -0,0 +1,10 @@ +describe('pixi/text/Text', function () { + 'use strict'; + + var expect = chai.expect; + var Text = PIXI.Text; + + it('Module exists', function () { + expect(Text).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/textures/BaseTexture.js b/test/unit/pixi-v2/textures/BaseTexture.js new file mode 100644 index 0000000..502b724 --- /dev/null +++ b/test/unit/pixi-v2/textures/BaseTexture.js @@ -0,0 +1,11 @@ +describe('pixi/textures/BaseTexture', function () { + 'use strict'; + + var expect = chai.expect; + var BaseTexture = PIXI.BaseTexture; + + it('Module exists', function () { + expect(BaseTexture).to.be.a('function'); + expect(PIXI).to.have.property('BaseTextureCache').and.to.be.an('object'); + }); +}); diff --git a/test/unit/pixi-v2/textures/RenderTexture.js b/test/unit/pixi-v2/textures/RenderTexture.js new file mode 100644 index 0000000..96acdb4 --- /dev/null +++ b/test/unit/pixi-v2/textures/RenderTexture.js @@ -0,0 +1,15 @@ +describe('pixi/textures/RenderTexture', function () { + 'use strict'; + + var expect = chai.expect; + var RenderTexture = PIXI.RenderTexture; + + it('Module exists', function () { + expect(RenderTexture).to.be.a('function'); + }); + + it('Confirm new instance', function (done) { + var texture = new RenderTexture(100, 100, new PIXI.CanvasRenderer()); + pixi_textures_RenderTexture_confirmNew(texture, done); + }); +}); diff --git a/test/unit/pixi-v2/textures/Texture.js b/test/unit/pixi-v2/textures/Texture.js new file mode 100644 index 0000000..090f64d --- /dev/null +++ b/test/unit/pixi-v2/textures/Texture.js @@ -0,0 +1,26 @@ +describe('pixi/textures/Texture', function () { + 'use strict'; + + var expect = chai.expect; + var Texture = PIXI.Texture; + + it('Module exists', function () { + expect(Texture).to.be.a('function'); + expect(PIXI).to.have.property('TextureCache').and.to.be.an('object'); + }); + + it('Members exist', function () { + expect(Texture).itself.to.respondTo('fromImage'); + expect(Texture).itself.to.respondTo('fromFrame'); + expect(Texture).itself.to.respondTo('fromCanvas'); + expect(Texture).itself.to.respondTo('addTextureToCache'); + expect(Texture).itself.to.respondTo('removeTextureFromCache'); + + // expect(Texture).itself.to.have.deep.property('frameUpdates.length', 0); + }); + + it('Confirm new instance', function (done) { + var texture = Texture.fromImage('/base/test/textures/bunny.png'); + pixi_textures_Texture_confirmNew(texture, done); + }); +}); diff --git a/test/unit/pixi-v2/utils/Detector.js b/test/unit/pixi-v2/utils/Detector.js new file mode 100644 index 0000000..4cf6008 --- /dev/null +++ b/test/unit/pixi-v2/utils/Detector.js @@ -0,0 +1,10 @@ +describe('pixi/utils/Detector', function () { + 'use strict'; + + var expect = chai.expect; + var autoDetectRenderer = PIXI.autoDetectRenderer; + + it('Module exists', function () { + expect(autoDetectRenderer).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/utils/EventTarget.js b/test/unit/pixi-v2/utils/EventTarget.js new file mode 100644 index 0000000..1cfc3a4 --- /dev/null +++ b/test/unit/pixi-v2/utils/EventTarget.js @@ -0,0 +1,361 @@ +describe('pixi/utils/EventTarget', function () { + 'use strict'; + + var expect = chai.expect; + + var Clazz, PClazz, obj, pobj, obj2; + beforeEach(function () { + Clazz = function () {}; + PClazz = function () {}; + + PIXI.EventTarget.mixin(Clazz.prototype); + PIXI.EventTarget.mixin(PClazz.prototype); + + obj = new Clazz(); + obj2 = new Clazz(); + pobj = new PClazz(); + + obj.parent = pobj; + obj2.parent = obj; + }); + + it('Module exists', function () { + expect(PIXI.EventTarget).to.be.an('object'); + }); + + it('Confirm new instance', function () { + pixi_utils_EventTarget_confirm(obj); + }); + + it('simple on/emit case works', function () { + var myData = {}; + + obj.on('myevent', function (event) { + pixi_utils_EventTarget_Event_confirm(event, obj, myData); + }); + + obj.emit('myevent', myData); + }); + + it('simple once case works', function () { + var called = 0; + + obj.once('myevent', function() { called++; }); + + obj.emit('myevent'); + obj.emit('myevent'); + obj.emit('myevent'); + obj.emit('myevent'); + obj.emit('myevent'); + + expect(called).to.equal(1); + }); + + it('simple off case works', function (done) { + function onMyEvent() { + done(new Error('Event listener should not have been called')); + } + + obj.on('myevent', onMyEvent); + obj.off('myevent', onMyEvent); + obj.emit('myevent'); + + done(); + }); + + it('simple propagation case works', function (done) { + var myData = {}; + + pobj.on('myevent', function () { + done(); + }); + + obj.emit('myevent'); + }); + + it('simple stopPropagation case works', function (done) { + var myData = {}; + + pobj.on('myevent', function () { + done(new Error('Event listener should not have been called on the parent element')); + }); + + obj.on('myevent', function (evt) { + evt.stopPropagation(); + }); + + obj.emit('myevent'); + + done(); + }); + + it('simple stopImmediatePropagation case works', function (done) { + var myData = {}; + + pobj.on('myevent', function () { + done(new Error('Event listener should not have been called on the parent')); + }); + + obj.on('myevent', function (evt) { + evt.stopImmediatePropagation(); + }); + + obj.on('myevent', function () { + done(new Error('Event listener should not have been called on the second')); + }); + + obj.emit('myevent'); + + done(); + }); + + it('multiple dispatches work properly', function () { + var called = 0; + + function onMyEvent() { + called++; + } + + obj.on('myevent', onMyEvent); + obj.emit('myevent'); + obj.emit('myevent'); + obj.emit('myevent'); + obj.emit('myevent'); + + expect(called).to.equal(4); + }); + + it('multiple events work properly', function () { + var called = 0; + + function onMyEvent() { + called++; + } + + obj.on('myevent1', onMyEvent); + obj.on('myevent2', onMyEvent); + obj.on('myevent3', onMyEvent); + obj.emit('myevent1'); + obj.emit('myevent2'); + obj.emit('myevent3'); + + expect(called).to.equal(3); + }); + + it('multiple events one removed works properly', function () { + var called = 0; + + function onMyEvent() { + called++; + } + + obj.on('myevent1', onMyEvent); + obj.on('myevent2', onMyEvent); + obj.on('myevent3', onMyEvent); + + obj.emit('myevent1'); + obj.emit('myevent2'); + obj.emit('myevent3'); + + obj.off('myevent2', onMyEvent); + + obj.emit('myevent1'); + obj.emit('myevent2'); + obj.emit('myevent3'); + + expect(called).to.equal(5); + }); + + it('multiple handlers for one event with some removed', function () { + var called = 0; + + var onMyEvent = function () { + called++; + }, + onMyEvent2 = function () { + called++; + }; + + // add 2 handlers and confirm they both get called + obj.on('myevent', onMyEvent); + obj.on('myevent', onMyEvent); + obj.on('myevent', onMyEvent2); + obj.on('myevent', onMyEvent2); + + obj.emit('myevent'); + + expect(called).to.equal(4); + + // remove one of the handlers, emit again, then ensure 1 more call is made + obj.off('myevent', onMyEvent); + + obj.emit('myevent'); + + expect(called).to.equal(6); + }); + + it('calls to off without a handler do nothing', function () { + var called = 0; + + var onMyEvent = function () { + called++; + }; + + obj.on('myevent', onMyEvent); + obj.on('myevent', onMyEvent); + + obj.emit('myevent'); + + expect(called).to.equal(2); + + obj.off('myevent'); + + obj.emit('myevent'); + + expect(called).to.equal(4); + + obj.off('myevent', onMyEvent); + + obj.emit('myevent'); + + expect(called).to.equal(4); + }); + + it('handles multiple instances with the same prototype', function () { + var called = 0; + + function onMyEvent(e) { + called++; + } + + obj.on('myevent1', onMyEvent); + obj.on('myevent2', onMyEvent); + + obj2.istwo = true; + obj2.on('myevent1', onMyEvent); + obj2.on('myevent2', onMyEvent); + + obj.emit('myevent1'); + obj.emit('myevent2'); + obj2.emit('myevent1'); + obj2.emit('myevent2'); + + //we emit 4 times, but since obj2 is a child of obj the event should bubble + //up to obj and show up there as well. So the obj2.emit() calls each increment + //the counter twice. + expect(called).to.equal(6); + }); + + it('is backwards compatible with older .dispatchEvent({})', function () { + var called = 0, + data = { + some: 'thing', + hello: true + }; + + function onMyEvent(event) { + pixi_utils_EventTarget_Event_confirm(event, obj, data); + + called++; + } + + obj.on('myevent1', onMyEvent); + obj.on('myevent2', onMyEvent); + obj.on('myevent3', onMyEvent); + + data.type = 'myevent1'; + obj.emit(data); + + data.type = 'myevent2'; + obj.emit(data); + + data.type = 'myevent3'; + obj.emit(data); + + obj.off('myevent2', onMyEvent); + + data.type = 'myevent1'; + obj.emit(data); + + data.type = 'myevent2'; + obj.emit(data); + + data.type = 'myevent3'; + obj.emit(data); + + expect(called).to.equal(5); + }); + + it('is backwards compatible with older .call(this)', function () { + var Fn = function() { + PIXI.EventTarget.call(this); + }, + o = new Fn(); + + pixi_utils_EventTarget_confirm(o); + }); + + it('is backwards compatible with older .addEventListener("")', function () { + var called = 0, + data = { + some: 'thing', + hello: true + }; + + function onMyEvent(event) { + pixi_utils_EventTarget_Event_confirm(event, obj, data); + + called++; + } + + obj.addEventListener('myevent1', onMyEvent); + obj.addEventListener('myevent2', onMyEvent); + obj.addEventListener('myevent3', onMyEvent); + + data.type = 'myevent1'; + obj.emit(data); + + data.type = 'myevent2'; + obj.emit(data); + + data.type = 'myevent3'; + obj.emit(data); + + obj.off('myevent2', onMyEvent); + + data.type = 'myevent1'; + obj.emit(data); + + data.type = 'myevent2'; + obj.emit(data); + + data.type = 'myevent3'; + obj.emit(data); + + expect(called).to.equal(5); + }); + + it('event remove during emit call properly', function () { + var called = 0; + + function cb1() { + called++; + obj.off('myevent', cb1); + } + function cb2() { + called++; + obj.off('myevent', cb2); + } + function cb3() { + called++; + obj.off('myevent', cb3); + } + + obj.on('myevent', cb1); + obj.on('myevent', cb2); + obj.on('myevent', cb3); + obj.emit('myevent', ''); + + expect(called).to.equal(3); + }); +}); diff --git a/test/unit/pixi-v2/utils/Polyk.js b/test/unit/pixi-v2/utils/Polyk.js new file mode 100644 index 0000000..dfc7128 --- /dev/null +++ b/test/unit/pixi-v2/utils/Polyk.js @@ -0,0 +1,14 @@ +describe('pixi/utils/Polyk', function () { + 'use strict'; + + var expect = chai.expect; + var PolyK = PIXI.PolyK; + + it('Module exists', function () { + expect(PolyK).to.be.an('object'); + }); + + it('Members exist', function () { + expect(PolyK).to.respondTo('Triangulate'); + }); +}); diff --git a/test/unit/pixi-v2/utils/Utils.js b/test/unit/pixi-v2/utils/Utils.js new file mode 100644 index 0000000..c97b3c6 --- /dev/null +++ b/test/unit/pixi-v2/utils/Utils.js @@ -0,0 +1,17 @@ +describe('Utils', function () { + 'use strict'; + + var expect = chai.expect; + + it('requestAnimationFrame exists', function () { + expect(global).to.respondTo('requestAnimationFrame'); + }); + + it('cancelAnimationFrame exists', function () { + expect(global).to.respondTo('cancelAnimationFrame'); + }); + + it('requestAnimFrame exists', function () { + expect(global).to.respondTo('requestAnimFrame'); + }); +}); diff --git a/test/unit/pixi/InteractionManager.js b/test/unit/pixi/InteractionManager.js deleted file mode 100644 index ed3001f..0000000 --- a/test/unit/pixi/InteractionManager.js +++ /dev/null @@ -1,10 +0,0 @@ -describe('pixi/InteractionManager', function () { - 'use strict'; - - var expect = chai.expect; - var InteractionManager = PIXI.InteractionManager; - - it('Module exists', function () { - expect(InteractionManager).to.be.a('function'); - }); -}); diff --git a/test/unit/pixi/Pixi.js b/test/unit/pixi/Pixi.js deleted file mode 100644 index 27debc1..0000000 --- a/test/unit/pixi/Pixi.js +++ /dev/null @@ -1,9 +0,0 @@ -describe('pixi/Pixi', function () { - 'use strict'; - - var expect = chai.expect; - - it('Module exists', function () { - expect(global).to.have.property('PIXI').and.to.be.an('object'); - }); -}); diff --git a/test/unit/pixi/core/Circle.js b/test/unit/pixi/core/Circle.js deleted file mode 100644 index fbcfa17..0000000 --- a/test/unit/pixi/core/Circle.js +++ /dev/null @@ -1,21 +0,0 @@ -describe('pixi/core/Circle', function () { - 'use strict'; - - var expect = chai.expect; - var Circle = PIXI.Circle; - - it('Module exists', function () { - expect(Circle).to.be.a('function'); - }); - - it('Confirm new instance', function () { - var obj = new Circle(); - pixi_core_Circle_confirmNewCircle(obj); - }); - - it("getBounds should return Rectangle that bounds the circle", function() { - var obj = new Circle(100, 250, 50); - var bounds = obj.getBounds(); - pixi_core_Circle_isBoundedByRectangle(obj, bounds); - }); -}); diff --git a/test/unit/pixi/core/Ellipse.js b/test/unit/pixi/core/Ellipse.js deleted file mode 100644 index 026b56f..0000000 --- a/test/unit/pixi/core/Ellipse.js +++ /dev/null @@ -1,24 +0,0 @@ -describe('pixi/core/Ellipse', function () { - 'use strict'; - - var expect = chai.expect; - var Ellipse = PIXI.Ellipse; - - it('Module exists', function () { - expect(Ellipse).to.be.a('function'); - }); - - it('Confirm new instance', function () { - var obj = new Ellipse(); - - expect(obj).to.be.an.instanceof(Ellipse); - expect(obj).to.respondTo('clone'); - expect(obj).to.respondTo('contains'); - expect(obj).to.respondTo('getBounds'); - - expect(obj).to.have.property('x', 0); - expect(obj).to.have.property('y', 0); - expect(obj).to.have.property('width', 0); - expect(obj).to.have.property('height', 0); - }); -}); diff --git a/test/unit/pixi/core/Matrix.js b/test/unit/pixi/core/Matrix.js deleted file mode 100644 index da75e2e..0000000 --- a/test/unit/pixi/core/Matrix.js +++ /dev/null @@ -1,14 +0,0 @@ -describe('pixi/core/Matrix', function () { - 'use strict'; - - var expect = chai.expect; - - it('Matrix exists', function () { - expect(PIXI.Matrix).to.be.an('function'); - }); - - it('Confirm new Matrix', function () { - var matrix = new PIXI.Matrix(); - pixi_core_Matrix_confirmNewMatrix(matrix); - }); -}); diff --git a/test/unit/pixi/core/Point.js b/test/unit/pixi/core/Point.js deleted file mode 100644 index c4d5163..0000000 --- a/test/unit/pixi/core/Point.js +++ /dev/null @@ -1,15 +0,0 @@ -describe('pixi/core/Point', function () { - 'use strict'; - - var expect = chai.expect; - var Point = PIXI.Point; - - it('Module exists', function () { - expect(Point).to.be.a('function'); - }); - - it('Confirm new instance', function () { - var obj = new Point(); - pixi_core_Point_confirm(obj, 0, 0); - }); -}); diff --git a/test/unit/pixi/core/Polygon.js b/test/unit/pixi/core/Polygon.js deleted file mode 100644 index dc8c918..0000000 --- a/test/unit/pixi/core/Polygon.js +++ /dev/null @@ -1,20 +0,0 @@ -describe('pixi/core/Polygon', function () { - 'use strict'; - - var expect = chai.expect; - var Polygon = PIXI.Polygon; - - it('Module exists', function () { - expect(Polygon).to.be.a('function'); - }); - - it('Confirm new instance', function () { - var obj = new Polygon(); - - expect(obj).to.be.an.instanceof(Polygon); - expect(obj).to.respondTo('clone'); - expect(obj).to.respondTo('contains'); - - expect(obj).to.have.deep.property('points.length', 0); - }); -}); diff --git a/test/unit/pixi/core/Rectangle.js b/test/unit/pixi/core/Rectangle.js deleted file mode 100644 index d43316e..0000000 --- a/test/unit/pixi/core/Rectangle.js +++ /dev/null @@ -1,15 +0,0 @@ -describe('pixi/core/Rectangle', function () { - 'use strict'; - - var expect = chai.expect; - var Rectangle = PIXI.Rectangle; - - it('Module exists', function () { - expect(Rectangle).to.be.a('function'); - }); - - it('Confirm new instance', function () { - var rect = new Rectangle(); - pixi_core_Rectangle_confirm(rect, 0, 0, 0, 0); - }); -}); diff --git a/test/unit/pixi/display/DisplayObject.js b/test/unit/pixi/display/DisplayObject.js deleted file mode 100644 index 044acf8..0000000 --- a/test/unit/pixi/display/DisplayObject.js +++ /dev/null @@ -1,21 +0,0 @@ -describe('pixi/display/DisplayObject', function () { - 'use strict'; - - var expect = chai.expect; - var DisplayObject = PIXI.DisplayObject; - - it('Module exists', function () { - expect(DisplayObject).to.be.a('function'); - // expect(PIXI).to.have.property('visibleCount', 0); - }); - - it('Confirm new instance', function () { - var obj = new DisplayObject(); - - pixi_display_DisplayObject_confirmNew(obj); - expect(obj).to.have.property('hitArea', null); - expect(obj).to.have.property('interactive', false); - expect(obj).to.have.property('renderable', false); - expect(obj).to.have.property('stage', null); - }); -}); diff --git a/test/unit/pixi/display/DisplayObjectContainer.js b/test/unit/pixi/display/DisplayObjectContainer.js deleted file mode 100644 index 15a3376..0000000 --- a/test/unit/pixi/display/DisplayObjectContainer.js +++ /dev/null @@ -1,67 +0,0 @@ -describe('pixi/display/DisplayObjectContainer', function () { - 'use strict'; - - var expect = chai.expect; - var DisplayObjectContainer = PIXI.DisplayObjectContainer; - - it('Module exists', function () { - expect(DisplayObjectContainer).to.be.a('function'); - }); - - it('Confirm new instance', function () { - var obj = new DisplayObjectContainer(); - - pixi_display_DisplayObjectContainer_confirmNew(obj); - expect(obj).to.have.property('hitArea', null); - expect(obj).to.have.property('interactive', false); - expect(obj).to.have.property('renderable', false); - expect(obj).to.have.property('stage', null); - }); - - it('Gets child index', function() { - var container = new PIXI.DisplayObjectContainer(); - var children = []; - for (var i = 0; i < 10; i++) { - var child = new PIXI.DisplayObject(); - children.push(child); - container.addChild(child); - } - - for (i = 0; i < children.length; i++) { - expect(i).to.eql(container.getChildIndex(children[i])); - } - }); - - it('throws error when trying to get index of not a child', function() { - var container = new PIXI.DisplayObjectContainer(); - var child = new PIXI.DisplayObject(); - - expect(function() { container.getChildIndex(child); }).to.throw(); - }); - - it('Sets child index', function() { - var container = new PIXI.DisplayObjectContainer(); - var children = []; - - for (var i = 0; i < 10; i++) { - var child = new PIXI.DisplayObject(); - children.push(child); - container.addChild(child); - } - children.reverse(); - - for (i = 0; i < children.length; i++) { - container.setChildIndex(children[i], i); - expect(i).to.eql(container.getChildIndex(children[i])); - } - }); - - it('throws error when trying to set incorect index', function() { - var container = new PIXI.DisplayObjectContainer(); - var child = new PIXI.DisplayObject(); - container.addChild(child); - - expect(function() { container.setChildIndex(child, -1); }).to.throw(); - expect(function() { container.setChildIndex(child, 1); }).to.throw(); - }); -}); diff --git a/test/unit/pixi/display/MovieClip.js b/test/unit/pixi/display/MovieClip.js deleted file mode 100644 index f3c6c6a..0000000 --- a/test/unit/pixi/display/MovieClip.js +++ /dev/null @@ -1,33 +0,0 @@ -describe('pixi/display/MovieClip', function () { - 'use strict'; - - var expect = chai.expect; - var MovieClip = PIXI.MovieClip; - var Texture = PIXI.Texture; - - it('Module exists', function () { - expect(MovieClip).to.be.a('function'); - }); - - it('Confirm new instance', function (done) { - var texture = Texture.fromImage('/base/test/textures/SpriteSheet-Explosion.png'); - var obj = new MovieClip([texture]); - - pixi_display_Sprite_confirmNew(obj, done); - - expect(obj).to.be.an.instanceof(MovieClip); - expect(obj).to.respondTo('stop'); - expect(obj).to.respondTo('play'); - expect(obj).to.respondTo('gotoAndStop'); - expect(obj).to.respondTo('gotoAndPlay'); - expect(obj).to.respondTo('updateTransform'); - - expect(obj).to.have.deep.property('textures.length', 1); - expect(obj).to.have.deep.property('textures[0]', texture); - expect(obj).to.have.property('animationSpeed', 1); - expect(obj).to.have.property('loop', true); - expect(obj).to.have.property('onComplete', null); - expect(obj).to.have.property('currentFrame', 0); - expect(obj).to.have.property('playing', false); - }); -}); diff --git a/test/unit/pixi/display/Sprite.js b/test/unit/pixi/display/Sprite.js deleted file mode 100644 index 30c8076..0000000 --- a/test/unit/pixi/display/Sprite.js +++ /dev/null @@ -1,28 +0,0 @@ -describe('pixi/display/Sprite', function () { - 'use strict'; - - var expect = chai.expect; - var Sprite = PIXI.Sprite; - var Texture = PIXI.Texture; - - it('Module exists', function () { - expect(Sprite).to.be.a('function'); - expect(PIXI).to.have.deep.property('blendModes.NORMAL', 0); - expect(PIXI).to.have.deep.property('blendModes.ADD', 1); - expect(PIXI).to.have.deep.property('blendModes.MULTIPLY', 2); - expect(PIXI).to.have.deep.property('blendModes.SCREEN', 3); - }); - - - it('Members exist', function () { - expect(Sprite).itself.to.respondTo('fromImage'); - expect(Sprite).itself.to.respondTo('fromFrame'); - }); - - it('Confirm new instance', function (done) { - var texture = Texture.fromImage('/base/test/textures/SpriteSheet-Aliens.png'); - var obj = new Sprite(texture); - - pixi_display_Sprite_confirmNew(obj, done); - }); -}); diff --git a/test/unit/pixi/display/Stage.js b/test/unit/pixi/display/Stage.js deleted file mode 100644 index 6974c2e..0000000 --- a/test/unit/pixi/display/Stage.js +++ /dev/null @@ -1,49 +0,0 @@ -describe('pixi/display/Stage', function () { - 'use strict'; - - var expect = chai.expect; - var Stage = PIXI.Stage; - var InteractionManager = PIXI.InteractionManager; - var Rectangle = PIXI.Rectangle; - - it('Module exists', function () { - expect(Stage).to.be.a('function'); - }); - - it('Confirm new instance', function () { - var obj = new Stage(null, true); - - pixi_display_DisplayObjectContainer_confirmNew(obj); - - expect(obj).to.be.an.instanceof(Stage); - expect(obj).to.respondTo('updateTransform'); - expect(obj).to.respondTo('setBackgroundColor'); - expect(obj).to.respondTo('getMousePosition'); - // FIXME: duplicate member in DisplayObject - pixi_core_Matrix_confirmNewMatrix(obj.worldTransform); - // FIXME: convert arg to bool in constructor - expect(obj).to.have.property('interactive', true); - - expect(obj).to.have.property('interactionManager') - .and.to.be.an.instanceof(InteractionManager) - .and.to.have.property('stage', obj); - - expect(obj).to.have.property('dirty', true); - - expect(obj).to.have.property('stage', obj); - - expect(obj).to.have.property('hitArea') - .and.to.be.an.instanceof(Rectangle); - pixi_core_Rectangle_confirm(obj.hitArea, 0, 0, 100000, 100000); - - expect(obj).to.have.property('backgroundColor', 0x000000); - expect(obj).to.have.deep.property('backgroundColorSplit.length', 3); - expect(obj).to.have.deep.property('backgroundColorSplit[0]', 0); - expect(obj).to.have.deep.property('backgroundColorSplit[1]', 0); - expect(obj).to.have.deep.property('backgroundColorSplit[2]', 0); - expect(obj).to.have.property('backgroundColorString', '#000000'); - - - expect(obj).to.have.property('worldVisible', true); - }); -}); diff --git a/test/unit/pixi/extras/Rope.js b/test/unit/pixi/extras/Rope.js deleted file mode 100644 index 05885ac..0000000 --- a/test/unit/pixi/extras/Rope.js +++ /dev/null @@ -1,31 +0,0 @@ -describe('pixi/extras/Rope', function () { - 'use strict'; - - var expect = chai.expect; - var Rope = PIXI.Rope; - var Texture = PIXI.Texture; - var Point = PIXI.Point; - - it('Module exists', function () { - expect(Rope).to.be.a('function'); - }); - - it('Confirm new instance', function () { - - var texture = Texture.fromImage('/base/test/textures/bunny.png'); - - // TODO-Alvin - // Same as Strip - - // var obj = new Rope(texture, [new Point(), new Point(5, 10), new Point(10, 20)]); - - // pixi_extras_Strip_confirmNew(obj); - - // expect(obj).to.be.an.instanceof(Rope); - // expect(obj).to.respondTo('refresh'); - // expect(obj).to.respondTo('updateTransform'); - // expect(obj).to.respondTo('setTexture'); - - // TODO: Test properties - }); -}); diff --git a/test/unit/pixi/extras/Spine.js b/test/unit/pixi/extras/Spine.js deleted file mode 100644 index 0708bc0..0000000 --- a/test/unit/pixi/extras/Spine.js +++ /dev/null @@ -1,10 +0,0 @@ -describe('pixi/extras/Spine', function () { - 'use strict'; - - var expect = chai.expect; - var Spine = PIXI.Spine; - - it('Module exists', function () { - expect(Spine).to.be.a('function'); - }); -}); diff --git a/test/unit/pixi/extras/Strip.js b/test/unit/pixi/extras/Strip.js deleted file mode 100644 index 230af90..0000000 --- a/test/unit/pixi/extras/Strip.js +++ /dev/null @@ -1,26 +0,0 @@ -describe('pixi/extras/Strip', function () { - 'use strict'; - - var expect = chai.expect; - var Strip = PIXI.Strip; - var Texture = PIXI.Texture; - - it('Module exists', function () { - expect(Strip).to.be.a('function'); - }); - - it('Confirm new instance', function () { - - - // TODO-Alvin - // We tweaked it to make it pass the tests, but the whole strip class needs - // to be re-coded - - var texture = Texture.fromImage('/base/test/textures/bunny.png'); - - // var obj = new Strip(texture, 20, 10000); - - - // pixi_extras_Strip_confirmNew(obj); - }); -}); diff --git a/test/unit/pixi-v2/InteractionManager.js b/test/unit/pixi-v2/InteractionManager.js new file mode 100644 index 0000000..ed3001f --- /dev/null +++ b/test/unit/pixi-v2/InteractionManager.js @@ -0,0 +1,10 @@ +describe('pixi/InteractionManager', function () { + 'use strict'; + + var expect = chai.expect; + var InteractionManager = PIXI.InteractionManager; + + it('Module exists', function () { + expect(InteractionManager).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/Pixi.js b/test/unit/pixi-v2/Pixi.js new file mode 100644 index 0000000..27debc1 --- /dev/null +++ b/test/unit/pixi-v2/Pixi.js @@ -0,0 +1,9 @@ +describe('pixi/Pixi', function () { + 'use strict'; + + var expect = chai.expect; + + it('Module exists', function () { + expect(global).to.have.property('PIXI').and.to.be.an('object'); + }); +}); diff --git a/test/unit/pixi-v2/core/Circle.js b/test/unit/pixi-v2/core/Circle.js new file mode 100644 index 0000000..fbcfa17 --- /dev/null +++ b/test/unit/pixi-v2/core/Circle.js @@ -0,0 +1,21 @@ +describe('pixi/core/Circle', function () { + 'use strict'; + + var expect = chai.expect; + var Circle = PIXI.Circle; + + it('Module exists', function () { + expect(Circle).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Circle(); + pixi_core_Circle_confirmNewCircle(obj); + }); + + it("getBounds should return Rectangle that bounds the circle", function() { + var obj = new Circle(100, 250, 50); + var bounds = obj.getBounds(); + pixi_core_Circle_isBoundedByRectangle(obj, bounds); + }); +}); diff --git a/test/unit/pixi-v2/core/Ellipse.js b/test/unit/pixi-v2/core/Ellipse.js new file mode 100644 index 0000000..026b56f --- /dev/null +++ b/test/unit/pixi-v2/core/Ellipse.js @@ -0,0 +1,24 @@ +describe('pixi/core/Ellipse', function () { + 'use strict'; + + var expect = chai.expect; + var Ellipse = PIXI.Ellipse; + + it('Module exists', function () { + expect(Ellipse).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Ellipse(); + + expect(obj).to.be.an.instanceof(Ellipse); + expect(obj).to.respondTo('clone'); + expect(obj).to.respondTo('contains'); + expect(obj).to.respondTo('getBounds'); + + expect(obj).to.have.property('x', 0); + expect(obj).to.have.property('y', 0); + expect(obj).to.have.property('width', 0); + expect(obj).to.have.property('height', 0); + }); +}); diff --git a/test/unit/pixi-v2/core/Matrix.js b/test/unit/pixi-v2/core/Matrix.js new file mode 100644 index 0000000..da75e2e --- /dev/null +++ b/test/unit/pixi-v2/core/Matrix.js @@ -0,0 +1,14 @@ +describe('pixi/core/Matrix', function () { + 'use strict'; + + var expect = chai.expect; + + it('Matrix exists', function () { + expect(PIXI.Matrix).to.be.an('function'); + }); + + it('Confirm new Matrix', function () { + var matrix = new PIXI.Matrix(); + pixi_core_Matrix_confirmNewMatrix(matrix); + }); +}); diff --git a/test/unit/pixi-v2/core/Point.js b/test/unit/pixi-v2/core/Point.js new file mode 100644 index 0000000..c4d5163 --- /dev/null +++ b/test/unit/pixi-v2/core/Point.js @@ -0,0 +1,15 @@ +describe('pixi/core/Point', function () { + 'use strict'; + + var expect = chai.expect; + var Point = PIXI.Point; + + it('Module exists', function () { + expect(Point).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Point(); + pixi_core_Point_confirm(obj, 0, 0); + }); +}); diff --git a/test/unit/pixi-v2/core/Polygon.js b/test/unit/pixi-v2/core/Polygon.js new file mode 100644 index 0000000..dc8c918 --- /dev/null +++ b/test/unit/pixi-v2/core/Polygon.js @@ -0,0 +1,20 @@ +describe('pixi/core/Polygon', function () { + 'use strict'; + + var expect = chai.expect; + var Polygon = PIXI.Polygon; + + it('Module exists', function () { + expect(Polygon).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Polygon(); + + expect(obj).to.be.an.instanceof(Polygon); + expect(obj).to.respondTo('clone'); + expect(obj).to.respondTo('contains'); + + expect(obj).to.have.deep.property('points.length', 0); + }); +}); diff --git a/test/unit/pixi-v2/core/Rectangle.js b/test/unit/pixi-v2/core/Rectangle.js new file mode 100644 index 0000000..d43316e --- /dev/null +++ b/test/unit/pixi-v2/core/Rectangle.js @@ -0,0 +1,15 @@ +describe('pixi/core/Rectangle', function () { + 'use strict'; + + var expect = chai.expect; + var Rectangle = PIXI.Rectangle; + + it('Module exists', function () { + expect(Rectangle).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var rect = new Rectangle(); + pixi_core_Rectangle_confirm(rect, 0, 0, 0, 0); + }); +}); diff --git a/test/unit/pixi-v2/display/DisplayObject.js b/test/unit/pixi-v2/display/DisplayObject.js new file mode 100644 index 0000000..044acf8 --- /dev/null +++ b/test/unit/pixi-v2/display/DisplayObject.js @@ -0,0 +1,21 @@ +describe('pixi/display/DisplayObject', function () { + 'use strict'; + + var expect = chai.expect; + var DisplayObject = PIXI.DisplayObject; + + it('Module exists', function () { + expect(DisplayObject).to.be.a('function'); + // expect(PIXI).to.have.property('visibleCount', 0); + }); + + it('Confirm new instance', function () { + var obj = new DisplayObject(); + + pixi_display_DisplayObject_confirmNew(obj); + expect(obj).to.have.property('hitArea', null); + expect(obj).to.have.property('interactive', false); + expect(obj).to.have.property('renderable', false); + expect(obj).to.have.property('stage', null); + }); +}); diff --git a/test/unit/pixi-v2/display/DisplayObjectContainer.js b/test/unit/pixi-v2/display/DisplayObjectContainer.js new file mode 100644 index 0000000..15a3376 --- /dev/null +++ b/test/unit/pixi-v2/display/DisplayObjectContainer.js @@ -0,0 +1,67 @@ +describe('pixi/display/DisplayObjectContainer', function () { + 'use strict'; + + var expect = chai.expect; + var DisplayObjectContainer = PIXI.DisplayObjectContainer; + + it('Module exists', function () { + expect(DisplayObjectContainer).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new DisplayObjectContainer(); + + pixi_display_DisplayObjectContainer_confirmNew(obj); + expect(obj).to.have.property('hitArea', null); + expect(obj).to.have.property('interactive', false); + expect(obj).to.have.property('renderable', false); + expect(obj).to.have.property('stage', null); + }); + + it('Gets child index', function() { + var container = new PIXI.DisplayObjectContainer(); + var children = []; + for (var i = 0; i < 10; i++) { + var child = new PIXI.DisplayObject(); + children.push(child); + container.addChild(child); + } + + for (i = 0; i < children.length; i++) { + expect(i).to.eql(container.getChildIndex(children[i])); + } + }); + + it('throws error when trying to get index of not a child', function() { + var container = new PIXI.DisplayObjectContainer(); + var child = new PIXI.DisplayObject(); + + expect(function() { container.getChildIndex(child); }).to.throw(); + }); + + it('Sets child index', function() { + var container = new PIXI.DisplayObjectContainer(); + var children = []; + + for (var i = 0; i < 10; i++) { + var child = new PIXI.DisplayObject(); + children.push(child); + container.addChild(child); + } + children.reverse(); + + for (i = 0; i < children.length; i++) { + container.setChildIndex(children[i], i); + expect(i).to.eql(container.getChildIndex(children[i])); + } + }); + + it('throws error when trying to set incorect index', function() { + var container = new PIXI.DisplayObjectContainer(); + var child = new PIXI.DisplayObject(); + container.addChild(child); + + expect(function() { container.setChildIndex(child, -1); }).to.throw(); + expect(function() { container.setChildIndex(child, 1); }).to.throw(); + }); +}); diff --git a/test/unit/pixi-v2/display/MovieClip.js b/test/unit/pixi-v2/display/MovieClip.js new file mode 100644 index 0000000..f3c6c6a --- /dev/null +++ b/test/unit/pixi-v2/display/MovieClip.js @@ -0,0 +1,33 @@ +describe('pixi/display/MovieClip', function () { + 'use strict'; + + var expect = chai.expect; + var MovieClip = PIXI.MovieClip; + var Texture = PIXI.Texture; + + it('Module exists', function () { + expect(MovieClip).to.be.a('function'); + }); + + it('Confirm new instance', function (done) { + var texture = Texture.fromImage('/base/test/textures/SpriteSheet-Explosion.png'); + var obj = new MovieClip([texture]); + + pixi_display_Sprite_confirmNew(obj, done); + + expect(obj).to.be.an.instanceof(MovieClip); + expect(obj).to.respondTo('stop'); + expect(obj).to.respondTo('play'); + expect(obj).to.respondTo('gotoAndStop'); + expect(obj).to.respondTo('gotoAndPlay'); + expect(obj).to.respondTo('updateTransform'); + + expect(obj).to.have.deep.property('textures.length', 1); + expect(obj).to.have.deep.property('textures[0]', texture); + expect(obj).to.have.property('animationSpeed', 1); + expect(obj).to.have.property('loop', true); + expect(obj).to.have.property('onComplete', null); + expect(obj).to.have.property('currentFrame', 0); + expect(obj).to.have.property('playing', false); + }); +}); diff --git a/test/unit/pixi-v2/display/Sprite.js b/test/unit/pixi-v2/display/Sprite.js new file mode 100644 index 0000000..30c8076 --- /dev/null +++ b/test/unit/pixi-v2/display/Sprite.js @@ -0,0 +1,28 @@ +describe('pixi/display/Sprite', function () { + 'use strict'; + + var expect = chai.expect; + var Sprite = PIXI.Sprite; + var Texture = PIXI.Texture; + + it('Module exists', function () { + expect(Sprite).to.be.a('function'); + expect(PIXI).to.have.deep.property('blendModes.NORMAL', 0); + expect(PIXI).to.have.deep.property('blendModes.ADD', 1); + expect(PIXI).to.have.deep.property('blendModes.MULTIPLY', 2); + expect(PIXI).to.have.deep.property('blendModes.SCREEN', 3); + }); + + + it('Members exist', function () { + expect(Sprite).itself.to.respondTo('fromImage'); + expect(Sprite).itself.to.respondTo('fromFrame'); + }); + + it('Confirm new instance', function (done) { + var texture = Texture.fromImage('/base/test/textures/SpriteSheet-Aliens.png'); + var obj = new Sprite(texture); + + pixi_display_Sprite_confirmNew(obj, done); + }); +}); diff --git a/test/unit/pixi-v2/display/Stage.js b/test/unit/pixi-v2/display/Stage.js new file mode 100644 index 0000000..6974c2e --- /dev/null +++ b/test/unit/pixi-v2/display/Stage.js @@ -0,0 +1,49 @@ +describe('pixi/display/Stage', function () { + 'use strict'; + + var expect = chai.expect; + var Stage = PIXI.Stage; + var InteractionManager = PIXI.InteractionManager; + var Rectangle = PIXI.Rectangle; + + it('Module exists', function () { + expect(Stage).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Stage(null, true); + + pixi_display_DisplayObjectContainer_confirmNew(obj); + + expect(obj).to.be.an.instanceof(Stage); + expect(obj).to.respondTo('updateTransform'); + expect(obj).to.respondTo('setBackgroundColor'); + expect(obj).to.respondTo('getMousePosition'); + // FIXME: duplicate member in DisplayObject + pixi_core_Matrix_confirmNewMatrix(obj.worldTransform); + // FIXME: convert arg to bool in constructor + expect(obj).to.have.property('interactive', true); + + expect(obj).to.have.property('interactionManager') + .and.to.be.an.instanceof(InteractionManager) + .and.to.have.property('stage', obj); + + expect(obj).to.have.property('dirty', true); + + expect(obj).to.have.property('stage', obj); + + expect(obj).to.have.property('hitArea') + .and.to.be.an.instanceof(Rectangle); + pixi_core_Rectangle_confirm(obj.hitArea, 0, 0, 100000, 100000); + + expect(obj).to.have.property('backgroundColor', 0x000000); + expect(obj).to.have.deep.property('backgroundColorSplit.length', 3); + expect(obj).to.have.deep.property('backgroundColorSplit[0]', 0); + expect(obj).to.have.deep.property('backgroundColorSplit[1]', 0); + expect(obj).to.have.deep.property('backgroundColorSplit[2]', 0); + expect(obj).to.have.property('backgroundColorString', '#000000'); + + + expect(obj).to.have.property('worldVisible', true); + }); +}); diff --git a/test/unit/pixi-v2/extras/Rope.js b/test/unit/pixi-v2/extras/Rope.js new file mode 100644 index 0000000..05885ac --- /dev/null +++ b/test/unit/pixi-v2/extras/Rope.js @@ -0,0 +1,31 @@ +describe('pixi/extras/Rope', function () { + 'use strict'; + + var expect = chai.expect; + var Rope = PIXI.Rope; + var Texture = PIXI.Texture; + var Point = PIXI.Point; + + it('Module exists', function () { + expect(Rope).to.be.a('function'); + }); + + it('Confirm new instance', function () { + + var texture = Texture.fromImage('/base/test/textures/bunny.png'); + + // TODO-Alvin + // Same as Strip + + // var obj = new Rope(texture, [new Point(), new Point(5, 10), new Point(10, 20)]); + + // pixi_extras_Strip_confirmNew(obj); + + // expect(obj).to.be.an.instanceof(Rope); + // expect(obj).to.respondTo('refresh'); + // expect(obj).to.respondTo('updateTransform'); + // expect(obj).to.respondTo('setTexture'); + + // TODO: Test properties + }); +}); diff --git a/test/unit/pixi-v2/extras/Spine.js b/test/unit/pixi-v2/extras/Spine.js new file mode 100644 index 0000000..0708bc0 --- /dev/null +++ b/test/unit/pixi-v2/extras/Spine.js @@ -0,0 +1,10 @@ +describe('pixi/extras/Spine', function () { + 'use strict'; + + var expect = chai.expect; + var Spine = PIXI.Spine; + + it('Module exists', function () { + expect(Spine).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/extras/Strip.js b/test/unit/pixi-v2/extras/Strip.js new file mode 100644 index 0000000..230af90 --- /dev/null +++ b/test/unit/pixi-v2/extras/Strip.js @@ -0,0 +1,26 @@ +describe('pixi/extras/Strip', function () { + 'use strict'; + + var expect = chai.expect; + var Strip = PIXI.Strip; + var Texture = PIXI.Texture; + + it('Module exists', function () { + expect(Strip).to.be.a('function'); + }); + + it('Confirm new instance', function () { + + + // TODO-Alvin + // We tweaked it to make it pass the tests, but the whole strip class needs + // to be re-coded + + var texture = Texture.fromImage('/base/test/textures/bunny.png'); + + // var obj = new Strip(texture, 20, 10000); + + + // pixi_extras_Strip_confirmNew(obj); + }); +}); diff --git a/test/unit/pixi-v2/extras/TilingSprite.js b/test/unit/pixi-v2/extras/TilingSprite.js new file mode 100644 index 0000000..56aea14 --- /dev/null +++ b/test/unit/pixi-v2/extras/TilingSprite.js @@ -0,0 +1,24 @@ +describe('pixi/extras/TilingSprite', function () { + 'use strict'; + + var expect = chai.expect; + var TilingSprite = PIXI.TilingSprite; + var Texture = PIXI.Texture; + + it('Module exists', function () { + expect(TilingSprite).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var texture = Texture.fromImage('/base/test/textures/bunny.png'); + var obj = new TilingSprite(texture, 6000, 12000); + + pixi_display_DisplayObjectContainer_confirmNew(obj); + + expect(obj).to.be.an.instanceof(TilingSprite); + expect(obj).to.respondTo('setTexture'); + expect(obj).to.respondTo('onTextureUpdate'); + + // TODO: Test properties + }); +}); diff --git a/test/unit/pixi-v2/filters/FilterBlock.js b/test/unit/pixi-v2/filters/FilterBlock.js new file mode 100644 index 0000000..870cec0 --- /dev/null +++ b/test/unit/pixi-v2/filters/FilterBlock.js @@ -0,0 +1,10 @@ +describe('pixi/filters/FilterBlock', function () { + 'use strict'; + + var expect = chai.expect; + var FilterBlock = PIXI.FilterBlock; + + it('Module exists', function () { + expect(FilterBlock).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/AssetLoader.js b/test/unit/pixi-v2/loaders/AssetLoader.js new file mode 100644 index 0000000..a0aa0b5 --- /dev/null +++ b/test/unit/pixi-v2/loaders/AssetLoader.js @@ -0,0 +1,10 @@ +describe('pixi/loaders/AssetLoader', function () { + 'use strict'; + + var expect = chai.expect; + var AssetLoader = PIXI.AssetLoader; + + it('Module exists', function () { + expect(AssetLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/BitmapFontLoader.js b/test/unit/pixi-v2/loaders/BitmapFontLoader.js new file mode 100644 index 0000000..046f018 --- /dev/null +++ b/test/unit/pixi-v2/loaders/BitmapFontLoader.js @@ -0,0 +1,9 @@ +describe('pixi/loaders/BitmapFontLoader', function () { + 'use strict'; + + var expect = chai.expect; + + it('Module exists', function () { + expect(PIXI.BitmapFontLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/ImageLoader.js b/test/unit/pixi-v2/loaders/ImageLoader.js new file mode 100644 index 0000000..8b1f556 --- /dev/null +++ b/test/unit/pixi-v2/loaders/ImageLoader.js @@ -0,0 +1,10 @@ +describe('pixi/loaders/ImageLoader', function () { + 'use strict'; + + var expect = chai.expect; + var ImageLoader = PIXI.ImageLoader; + + it('Module exists', function () { + expect(ImageLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/JsonLoader.js b/test/unit/pixi-v2/loaders/JsonLoader.js new file mode 100644 index 0000000..c577e83 --- /dev/null +++ b/test/unit/pixi-v2/loaders/JsonLoader.js @@ -0,0 +1,10 @@ +describe('pixi/loaders/JsonLoader', function () { + 'use strict'; + + var expect = chai.expect; + var JsonLoader = PIXI.JsonLoader; + + it('Module exists', function () { + expect(JsonLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/SpineLoader.js b/test/unit/pixi-v2/loaders/SpineLoader.js new file mode 100644 index 0000000..fdcc0b8 --- /dev/null +++ b/test/unit/pixi-v2/loaders/SpineLoader.js @@ -0,0 +1,10 @@ +describe('pixi/loaders/SpineLoader', function () { + 'use strict'; + + var expect = chai.expect; + var SpineLoader = PIXI.SpineLoader; + + it('Module exists', function () { + expect(SpineLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/SpriteSheetLoader.js b/test/unit/pixi-v2/loaders/SpriteSheetLoader.js new file mode 100644 index 0000000..57beb27 --- /dev/null +++ b/test/unit/pixi-v2/loaders/SpriteSheetLoader.js @@ -0,0 +1,10 @@ +describe('pixi/loaders/SpriteSheetLoader', function () { + 'use strict'; + + var expect = chai.expect; + var SpriteSheetLoader = PIXI.SpriteSheetLoader; + + it('Module exists', function () { + expect(SpriteSheetLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/primitives/Graphics.js b/test/unit/pixi-v2/primitives/Graphics.js new file mode 100644 index 0000000..f3849eb --- /dev/null +++ b/test/unit/pixi-v2/primitives/Graphics.js @@ -0,0 +1,44 @@ +describe('pixi/primitives/Graphics', function () { + 'use strict'; + + var expect = chai.expect; + var Graphics = PIXI.Graphics; + + it('Module exists', function () { + expect(Graphics).to.be.a('function'); + + expect(Graphics).itself.to.have.property('POLY', 0); + expect(Graphics).itself.to.have.property('RECT', 1); + expect(Graphics).itself.to.have.property('CIRC', 2); + expect(Graphics).itself.to.have.property('ELIP', 3); + expect(Graphics).itself.to.have.property('RREC', 4); + }); + + it('Confirm new instance', function () { + var obj = new Graphics(); + + pixi_display_DisplayObjectContainer_confirmNew(obj); + + expect(obj).to.be.an.instanceof(Graphics); + expect(obj).to.respondTo('lineStyle'); + expect(obj).to.respondTo('lineStyle'); + expect(obj).to.respondTo('moveTo'); + expect(obj).to.respondTo('lineTo'); + expect(obj).to.respondTo('beginFill'); + expect(obj).to.respondTo('endFill'); + expect(obj).to.respondTo('drawRect'); + // expect(obj).to.respondTo('drawRoundedRect'); + expect(obj).to.respondTo('drawCircle'); + expect(obj).to.respondTo('drawEllipse'); + expect(obj).to.respondTo('clear'); + + expect(obj).to.have.property('renderable', true); + expect(obj).to.have.property('fillAlpha', 1); + expect(obj).to.have.property('lineWidth', 0); + expect(obj).to.have.property('width', 0); + expect(obj).to.have.property('height', 0); + expect(obj).to.have.property('lineColor', 0); + expect(obj).to.have.deep.property('graphicsData.length', 0); + // expect(obj).to.have.deep.property('currentPath.points.length', 0); + }); +}); diff --git a/test/unit/pixi-v2/renderers/canvas/CanvasGraphics.js b/test/unit/pixi-v2/renderers/canvas/CanvasGraphics.js new file mode 100644 index 0000000..8f44472 --- /dev/null +++ b/test/unit/pixi-v2/renderers/canvas/CanvasGraphics.js @@ -0,0 +1,15 @@ +describe('renders/canvas/CanvasGraphics', function () { + 'use strict'; + + var expect = chai.expect; + var CanvasGraphics = PIXI.CanvasGraphics; + + it('Module exists', function () { + expect(CanvasGraphics).to.be.a('function'); + }); + + it('Members exist', function () { + expect(CanvasGraphics).itself.to.respondTo('renderGraphics'); + expect(CanvasGraphics).itself.to.respondTo('renderGraphicsMask'); + }); +}); diff --git a/test/unit/pixi-v2/renderers/canvas/CanvasRenderer.js b/test/unit/pixi-v2/renderers/canvas/CanvasRenderer.js new file mode 100644 index 0000000..1646444 --- /dev/null +++ b/test/unit/pixi-v2/renderers/canvas/CanvasRenderer.js @@ -0,0 +1,36 @@ +describe('renderers/canvas/CanvasRenderer', function () { + 'use strict'; + + var expect = chai.expect; + var CanvasRenderer = PIXI.CanvasRenderer; + + it('Module exists', function () { + expect(CanvasRenderer).to.be.a('function'); + }); + + describe('.autoResize', function () { + it('Should automatically resize view if enabled', function () { + var renderer = new CanvasRenderer(200, 200, { + autoResize: true + }); + + expect(renderer.view.style.width).to.equal('200px'); + }); + + it('Should not automatically resize view if disabled', function () { + var renderer = new CanvasRenderer(200, 200, { + autoResize: false + }); + + expect(renderer.view.style.width).to.equal(''); + }); + + it('Should not automatically resize view if not specified', function () { + var renderer = new CanvasRenderer(200, 200, { + resolution: 2 + }); + + expect(renderer.view.style.width).to.equal(''); + }); + }); +}); diff --git a/test/unit/pixi-v2/renderers/webgl/WebGLGraphics.js b/test/unit/pixi-v2/renderers/webgl/WebGLGraphics.js new file mode 100644 index 0000000..5867b28 --- /dev/null +++ b/test/unit/pixi-v2/renderers/webgl/WebGLGraphics.js @@ -0,0 +1,20 @@ +describe('renderers/wegbl/WebGLGraphics', function () { + 'use strict'; + + var expect = chai.expect; + var WebGLGraphics = PIXI.WebGLGraphics; + + it('Module exists', function () { + expect(WebGLGraphics).to.be.a('function'); + }); + + it('Members exist', function () { + expect(WebGLGraphics).itself.to.respondTo('renderGraphics'); + expect(WebGLGraphics).itself.to.respondTo('updateGraphics'); + expect(WebGLGraphics).itself.to.respondTo('buildRectangle'); + expect(WebGLGraphics).itself.to.respondTo('buildRoundedRectangle'); + expect(WebGLGraphics).itself.to.respondTo('buildCircle'); + expect(WebGLGraphics).itself.to.respondTo('buildLine'); + expect(WebGLGraphics).itself.to.respondTo('buildPoly'); + }); +}); diff --git a/test/unit/pixi-v2/renderers/webgl/WebGLRenderer.js b/test/unit/pixi-v2/renderers/webgl/WebGLRenderer.js new file mode 100644 index 0000000..1680a80 --- /dev/null +++ b/test/unit/pixi-v2/renderers/webgl/WebGLRenderer.js @@ -0,0 +1,49 @@ +describe('renderers/webgl/WebGLRenderer', function () { + 'use strict'; + + var expect = chai.expect; + var WebGLRenderer = PIXI.WebGLRenderer; + + it('Module exists', function () { + expect(WebGLRenderer).to.be.a('function'); + }); + + // Skip tests if WebGL is not available (WebGL not supported in Travis CI) + try { + var renderer = new WebGLRenderer(400, 300, {}); + renderer.destroy(); + } catch (error) { + return; + } + + it('Destroy renderer', function () { + var renderer = new WebGLRenderer(400, 300, {}); + renderer.destroy(); + }); + + describe('.autoResize', function () { + it('Should automatically resize view if enabled', function () { + var renderer = new WebGLRenderer(200, 200, { + autoResize: true + }); + + expect(renderer.view.style.width).to.equal('200px'); + }); + + it('Should not automatically resize view if disabled', function () { + var renderer = new WebGLRenderer(200, 200, { + autoResize: false + }); + + expect(renderer.view.style.width).to.equal(''); + }); + + it('Should not automatically resize view if not specified', function () { + var renderer = new WebGLRenderer(200, 200, { + resolution: 2 + }); + + expect(renderer.view.style.width).to.equal(''); + }); + }); +}); diff --git a/test/unit/pixi-v2/renderers/webgl/WebGLShaders.js b/test/unit/pixi-v2/renderers/webgl/WebGLShaders.js new file mode 100644 index 0000000..6e33e4f --- /dev/null +++ b/test/unit/pixi-v2/renderers/webgl/WebGLShaders.js @@ -0,0 +1,13 @@ +describe('renderers/webgl/WebGLShaders', function () { + 'use strict'; + + var expect = chai.expect; + + it('Module members exist', function () { + + expect(PIXI).to.respondTo('CompileVertexShader'); + expect(PIXI).to.respondTo('CompileFragmentShader'); + expect(PIXI).to.respondTo('_CompileShader'); + expect(PIXI).to.respondTo('compileProgram'); + }); +}); diff --git a/test/unit/pixi-v2/renderers/webgl/WebGLSpriteBatch.js b/test/unit/pixi-v2/renderers/webgl/WebGLSpriteBatch.js new file mode 100644 index 0000000..e662b63 --- /dev/null +++ b/test/unit/pixi-v2/renderers/webgl/WebGLSpriteBatch.js @@ -0,0 +1,10 @@ +describe('renderers/webgl/utils/WebGLSpriteBatch', function () { + 'use strict'; + + var expect = chai.expect; + var WebGLSpriteBatch = PIXI.WebGLSpriteBatch; + + it('Module exists', function () { + expect(WebGLSpriteBatch).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/text/BitmapText.js b/test/unit/pixi-v2/text/BitmapText.js new file mode 100644 index 0000000..9388e3d --- /dev/null +++ b/test/unit/pixi-v2/text/BitmapText.js @@ -0,0 +1,10 @@ +describe('pixi/text/BitmapText', function () { + 'use strict'; + + var expect = chai.expect; + var BitmapText = PIXI.BitmapText; + + it('Module exists', function () { + expect(BitmapText).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/text/Text.js b/test/unit/pixi-v2/text/Text.js new file mode 100644 index 0000000..9bc9ac5 --- /dev/null +++ b/test/unit/pixi-v2/text/Text.js @@ -0,0 +1,10 @@ +describe('pixi/text/Text', function () { + 'use strict'; + + var expect = chai.expect; + var Text = PIXI.Text; + + it('Module exists', function () { + expect(Text).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/textures/BaseTexture.js b/test/unit/pixi-v2/textures/BaseTexture.js new file mode 100644 index 0000000..502b724 --- /dev/null +++ b/test/unit/pixi-v2/textures/BaseTexture.js @@ -0,0 +1,11 @@ +describe('pixi/textures/BaseTexture', function () { + 'use strict'; + + var expect = chai.expect; + var BaseTexture = PIXI.BaseTexture; + + it('Module exists', function () { + expect(BaseTexture).to.be.a('function'); + expect(PIXI).to.have.property('BaseTextureCache').and.to.be.an('object'); + }); +}); diff --git a/test/unit/pixi-v2/textures/RenderTexture.js b/test/unit/pixi-v2/textures/RenderTexture.js new file mode 100644 index 0000000..96acdb4 --- /dev/null +++ b/test/unit/pixi-v2/textures/RenderTexture.js @@ -0,0 +1,15 @@ +describe('pixi/textures/RenderTexture', function () { + 'use strict'; + + var expect = chai.expect; + var RenderTexture = PIXI.RenderTexture; + + it('Module exists', function () { + expect(RenderTexture).to.be.a('function'); + }); + + it('Confirm new instance', function (done) { + var texture = new RenderTexture(100, 100, new PIXI.CanvasRenderer()); + pixi_textures_RenderTexture_confirmNew(texture, done); + }); +}); diff --git a/test/unit/pixi-v2/textures/Texture.js b/test/unit/pixi-v2/textures/Texture.js new file mode 100644 index 0000000..090f64d --- /dev/null +++ b/test/unit/pixi-v2/textures/Texture.js @@ -0,0 +1,26 @@ +describe('pixi/textures/Texture', function () { + 'use strict'; + + var expect = chai.expect; + var Texture = PIXI.Texture; + + it('Module exists', function () { + expect(Texture).to.be.a('function'); + expect(PIXI).to.have.property('TextureCache').and.to.be.an('object'); + }); + + it('Members exist', function () { + expect(Texture).itself.to.respondTo('fromImage'); + expect(Texture).itself.to.respondTo('fromFrame'); + expect(Texture).itself.to.respondTo('fromCanvas'); + expect(Texture).itself.to.respondTo('addTextureToCache'); + expect(Texture).itself.to.respondTo('removeTextureFromCache'); + + // expect(Texture).itself.to.have.deep.property('frameUpdates.length', 0); + }); + + it('Confirm new instance', function (done) { + var texture = Texture.fromImage('/base/test/textures/bunny.png'); + pixi_textures_Texture_confirmNew(texture, done); + }); +}); diff --git a/test/unit/pixi-v2/utils/Detector.js b/test/unit/pixi-v2/utils/Detector.js new file mode 100644 index 0000000..4cf6008 --- /dev/null +++ b/test/unit/pixi-v2/utils/Detector.js @@ -0,0 +1,10 @@ +describe('pixi/utils/Detector', function () { + 'use strict'; + + var expect = chai.expect; + var autoDetectRenderer = PIXI.autoDetectRenderer; + + it('Module exists', function () { + expect(autoDetectRenderer).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/utils/EventTarget.js b/test/unit/pixi-v2/utils/EventTarget.js new file mode 100644 index 0000000..1cfc3a4 --- /dev/null +++ b/test/unit/pixi-v2/utils/EventTarget.js @@ -0,0 +1,361 @@ +describe('pixi/utils/EventTarget', function () { + 'use strict'; + + var expect = chai.expect; + + var Clazz, PClazz, obj, pobj, obj2; + beforeEach(function () { + Clazz = function () {}; + PClazz = function () {}; + + PIXI.EventTarget.mixin(Clazz.prototype); + PIXI.EventTarget.mixin(PClazz.prototype); + + obj = new Clazz(); + obj2 = new Clazz(); + pobj = new PClazz(); + + obj.parent = pobj; + obj2.parent = obj; + }); + + it('Module exists', function () { + expect(PIXI.EventTarget).to.be.an('object'); + }); + + it('Confirm new instance', function () { + pixi_utils_EventTarget_confirm(obj); + }); + + it('simple on/emit case works', function () { + var myData = {}; + + obj.on('myevent', function (event) { + pixi_utils_EventTarget_Event_confirm(event, obj, myData); + }); + + obj.emit('myevent', myData); + }); + + it('simple once case works', function () { + var called = 0; + + obj.once('myevent', function() { called++; }); + + obj.emit('myevent'); + obj.emit('myevent'); + obj.emit('myevent'); + obj.emit('myevent'); + obj.emit('myevent'); + + expect(called).to.equal(1); + }); + + it('simple off case works', function (done) { + function onMyEvent() { + done(new Error('Event listener should not have been called')); + } + + obj.on('myevent', onMyEvent); + obj.off('myevent', onMyEvent); + obj.emit('myevent'); + + done(); + }); + + it('simple propagation case works', function (done) { + var myData = {}; + + pobj.on('myevent', function () { + done(); + }); + + obj.emit('myevent'); + }); + + it('simple stopPropagation case works', function (done) { + var myData = {}; + + pobj.on('myevent', function () { + done(new Error('Event listener should not have been called on the parent element')); + }); + + obj.on('myevent', function (evt) { + evt.stopPropagation(); + }); + + obj.emit('myevent'); + + done(); + }); + + it('simple stopImmediatePropagation case works', function (done) { + var myData = {}; + + pobj.on('myevent', function () { + done(new Error('Event listener should not have been called on the parent')); + }); + + obj.on('myevent', function (evt) { + evt.stopImmediatePropagation(); + }); + + obj.on('myevent', function () { + done(new Error('Event listener should not have been called on the second')); + }); + + obj.emit('myevent'); + + done(); + }); + + it('multiple dispatches work properly', function () { + var called = 0; + + function onMyEvent() { + called++; + } + + obj.on('myevent', onMyEvent); + obj.emit('myevent'); + obj.emit('myevent'); + obj.emit('myevent'); + obj.emit('myevent'); + + expect(called).to.equal(4); + }); + + it('multiple events work properly', function () { + var called = 0; + + function onMyEvent() { + called++; + } + + obj.on('myevent1', onMyEvent); + obj.on('myevent2', onMyEvent); + obj.on('myevent3', onMyEvent); + obj.emit('myevent1'); + obj.emit('myevent2'); + obj.emit('myevent3'); + + expect(called).to.equal(3); + }); + + it('multiple events one removed works properly', function () { + var called = 0; + + function onMyEvent() { + called++; + } + + obj.on('myevent1', onMyEvent); + obj.on('myevent2', onMyEvent); + obj.on('myevent3', onMyEvent); + + obj.emit('myevent1'); + obj.emit('myevent2'); + obj.emit('myevent3'); + + obj.off('myevent2', onMyEvent); + + obj.emit('myevent1'); + obj.emit('myevent2'); + obj.emit('myevent3'); + + expect(called).to.equal(5); + }); + + it('multiple handlers for one event with some removed', function () { + var called = 0; + + var onMyEvent = function () { + called++; + }, + onMyEvent2 = function () { + called++; + }; + + // add 2 handlers and confirm they both get called + obj.on('myevent', onMyEvent); + obj.on('myevent', onMyEvent); + obj.on('myevent', onMyEvent2); + obj.on('myevent', onMyEvent2); + + obj.emit('myevent'); + + expect(called).to.equal(4); + + // remove one of the handlers, emit again, then ensure 1 more call is made + obj.off('myevent', onMyEvent); + + obj.emit('myevent'); + + expect(called).to.equal(6); + }); + + it('calls to off without a handler do nothing', function () { + var called = 0; + + var onMyEvent = function () { + called++; + }; + + obj.on('myevent', onMyEvent); + obj.on('myevent', onMyEvent); + + obj.emit('myevent'); + + expect(called).to.equal(2); + + obj.off('myevent'); + + obj.emit('myevent'); + + expect(called).to.equal(4); + + obj.off('myevent', onMyEvent); + + obj.emit('myevent'); + + expect(called).to.equal(4); + }); + + it('handles multiple instances with the same prototype', function () { + var called = 0; + + function onMyEvent(e) { + called++; + } + + obj.on('myevent1', onMyEvent); + obj.on('myevent2', onMyEvent); + + obj2.istwo = true; + obj2.on('myevent1', onMyEvent); + obj2.on('myevent2', onMyEvent); + + obj.emit('myevent1'); + obj.emit('myevent2'); + obj2.emit('myevent1'); + obj2.emit('myevent2'); + + //we emit 4 times, but since obj2 is a child of obj the event should bubble + //up to obj and show up there as well. So the obj2.emit() calls each increment + //the counter twice. + expect(called).to.equal(6); + }); + + it('is backwards compatible with older .dispatchEvent({})', function () { + var called = 0, + data = { + some: 'thing', + hello: true + }; + + function onMyEvent(event) { + pixi_utils_EventTarget_Event_confirm(event, obj, data); + + called++; + } + + obj.on('myevent1', onMyEvent); + obj.on('myevent2', onMyEvent); + obj.on('myevent3', onMyEvent); + + data.type = 'myevent1'; + obj.emit(data); + + data.type = 'myevent2'; + obj.emit(data); + + data.type = 'myevent3'; + obj.emit(data); + + obj.off('myevent2', onMyEvent); + + data.type = 'myevent1'; + obj.emit(data); + + data.type = 'myevent2'; + obj.emit(data); + + data.type = 'myevent3'; + obj.emit(data); + + expect(called).to.equal(5); + }); + + it('is backwards compatible with older .call(this)', function () { + var Fn = function() { + PIXI.EventTarget.call(this); + }, + o = new Fn(); + + pixi_utils_EventTarget_confirm(o); + }); + + it('is backwards compatible with older .addEventListener("")', function () { + var called = 0, + data = { + some: 'thing', + hello: true + }; + + function onMyEvent(event) { + pixi_utils_EventTarget_Event_confirm(event, obj, data); + + called++; + } + + obj.addEventListener('myevent1', onMyEvent); + obj.addEventListener('myevent2', onMyEvent); + obj.addEventListener('myevent3', onMyEvent); + + data.type = 'myevent1'; + obj.emit(data); + + data.type = 'myevent2'; + obj.emit(data); + + data.type = 'myevent3'; + obj.emit(data); + + obj.off('myevent2', onMyEvent); + + data.type = 'myevent1'; + obj.emit(data); + + data.type = 'myevent2'; + obj.emit(data); + + data.type = 'myevent3'; + obj.emit(data); + + expect(called).to.equal(5); + }); + + it('event remove during emit call properly', function () { + var called = 0; + + function cb1() { + called++; + obj.off('myevent', cb1); + } + function cb2() { + called++; + obj.off('myevent', cb2); + } + function cb3() { + called++; + obj.off('myevent', cb3); + } + + obj.on('myevent', cb1); + obj.on('myevent', cb2); + obj.on('myevent', cb3); + obj.emit('myevent', ''); + + expect(called).to.equal(3); + }); +}); diff --git a/test/unit/pixi-v2/utils/Polyk.js b/test/unit/pixi-v2/utils/Polyk.js new file mode 100644 index 0000000..dfc7128 --- /dev/null +++ b/test/unit/pixi-v2/utils/Polyk.js @@ -0,0 +1,14 @@ +describe('pixi/utils/Polyk', function () { + 'use strict'; + + var expect = chai.expect; + var PolyK = PIXI.PolyK; + + it('Module exists', function () { + expect(PolyK).to.be.an('object'); + }); + + it('Members exist', function () { + expect(PolyK).to.respondTo('Triangulate'); + }); +}); diff --git a/test/unit/pixi-v2/utils/Utils.js b/test/unit/pixi-v2/utils/Utils.js new file mode 100644 index 0000000..c97b3c6 --- /dev/null +++ b/test/unit/pixi-v2/utils/Utils.js @@ -0,0 +1,17 @@ +describe('Utils', function () { + 'use strict'; + + var expect = chai.expect; + + it('requestAnimationFrame exists', function () { + expect(global).to.respondTo('requestAnimationFrame'); + }); + + it('cancelAnimationFrame exists', function () { + expect(global).to.respondTo('cancelAnimationFrame'); + }); + + it('requestAnimFrame exists', function () { + expect(global).to.respondTo('requestAnimFrame'); + }); +}); diff --git a/test/unit/pixi/InteractionManager.js b/test/unit/pixi/InteractionManager.js deleted file mode 100644 index ed3001f..0000000 --- a/test/unit/pixi/InteractionManager.js +++ /dev/null @@ -1,10 +0,0 @@ -describe('pixi/InteractionManager', function () { - 'use strict'; - - var expect = chai.expect; - var InteractionManager = PIXI.InteractionManager; - - it('Module exists', function () { - expect(InteractionManager).to.be.a('function'); - }); -}); diff --git a/test/unit/pixi/Pixi.js b/test/unit/pixi/Pixi.js deleted file mode 100644 index 27debc1..0000000 --- a/test/unit/pixi/Pixi.js +++ /dev/null @@ -1,9 +0,0 @@ -describe('pixi/Pixi', function () { - 'use strict'; - - var expect = chai.expect; - - it('Module exists', function () { - expect(global).to.have.property('PIXI').and.to.be.an('object'); - }); -}); diff --git a/test/unit/pixi/core/Circle.js b/test/unit/pixi/core/Circle.js deleted file mode 100644 index fbcfa17..0000000 --- a/test/unit/pixi/core/Circle.js +++ /dev/null @@ -1,21 +0,0 @@ -describe('pixi/core/Circle', function () { - 'use strict'; - - var expect = chai.expect; - var Circle = PIXI.Circle; - - it('Module exists', function () { - expect(Circle).to.be.a('function'); - }); - - it('Confirm new instance', function () { - var obj = new Circle(); - pixi_core_Circle_confirmNewCircle(obj); - }); - - it("getBounds should return Rectangle that bounds the circle", function() { - var obj = new Circle(100, 250, 50); - var bounds = obj.getBounds(); - pixi_core_Circle_isBoundedByRectangle(obj, bounds); - }); -}); diff --git a/test/unit/pixi/core/Ellipse.js b/test/unit/pixi/core/Ellipse.js deleted file mode 100644 index 026b56f..0000000 --- a/test/unit/pixi/core/Ellipse.js +++ /dev/null @@ -1,24 +0,0 @@ -describe('pixi/core/Ellipse', function () { - 'use strict'; - - var expect = chai.expect; - var Ellipse = PIXI.Ellipse; - - it('Module exists', function () { - expect(Ellipse).to.be.a('function'); - }); - - it('Confirm new instance', function () { - var obj = new Ellipse(); - - expect(obj).to.be.an.instanceof(Ellipse); - expect(obj).to.respondTo('clone'); - expect(obj).to.respondTo('contains'); - expect(obj).to.respondTo('getBounds'); - - expect(obj).to.have.property('x', 0); - expect(obj).to.have.property('y', 0); - expect(obj).to.have.property('width', 0); - expect(obj).to.have.property('height', 0); - }); -}); diff --git a/test/unit/pixi/core/Matrix.js b/test/unit/pixi/core/Matrix.js deleted file mode 100644 index da75e2e..0000000 --- a/test/unit/pixi/core/Matrix.js +++ /dev/null @@ -1,14 +0,0 @@ -describe('pixi/core/Matrix', function () { - 'use strict'; - - var expect = chai.expect; - - it('Matrix exists', function () { - expect(PIXI.Matrix).to.be.an('function'); - }); - - it('Confirm new Matrix', function () { - var matrix = new PIXI.Matrix(); - pixi_core_Matrix_confirmNewMatrix(matrix); - }); -}); diff --git a/test/unit/pixi/core/Point.js b/test/unit/pixi/core/Point.js deleted file mode 100644 index c4d5163..0000000 --- a/test/unit/pixi/core/Point.js +++ /dev/null @@ -1,15 +0,0 @@ -describe('pixi/core/Point', function () { - 'use strict'; - - var expect = chai.expect; - var Point = PIXI.Point; - - it('Module exists', function () { - expect(Point).to.be.a('function'); - }); - - it('Confirm new instance', function () { - var obj = new Point(); - pixi_core_Point_confirm(obj, 0, 0); - }); -}); diff --git a/test/unit/pixi/core/Polygon.js b/test/unit/pixi/core/Polygon.js deleted file mode 100644 index dc8c918..0000000 --- a/test/unit/pixi/core/Polygon.js +++ /dev/null @@ -1,20 +0,0 @@ -describe('pixi/core/Polygon', function () { - 'use strict'; - - var expect = chai.expect; - var Polygon = PIXI.Polygon; - - it('Module exists', function () { - expect(Polygon).to.be.a('function'); - }); - - it('Confirm new instance', function () { - var obj = new Polygon(); - - expect(obj).to.be.an.instanceof(Polygon); - expect(obj).to.respondTo('clone'); - expect(obj).to.respondTo('contains'); - - expect(obj).to.have.deep.property('points.length', 0); - }); -}); diff --git a/test/unit/pixi/core/Rectangle.js b/test/unit/pixi/core/Rectangle.js deleted file mode 100644 index d43316e..0000000 --- a/test/unit/pixi/core/Rectangle.js +++ /dev/null @@ -1,15 +0,0 @@ -describe('pixi/core/Rectangle', function () { - 'use strict'; - - var expect = chai.expect; - var Rectangle = PIXI.Rectangle; - - it('Module exists', function () { - expect(Rectangle).to.be.a('function'); - }); - - it('Confirm new instance', function () { - var rect = new Rectangle(); - pixi_core_Rectangle_confirm(rect, 0, 0, 0, 0); - }); -}); diff --git a/test/unit/pixi/display/DisplayObject.js b/test/unit/pixi/display/DisplayObject.js deleted file mode 100644 index 044acf8..0000000 --- a/test/unit/pixi/display/DisplayObject.js +++ /dev/null @@ -1,21 +0,0 @@ -describe('pixi/display/DisplayObject', function () { - 'use strict'; - - var expect = chai.expect; - var DisplayObject = PIXI.DisplayObject; - - it('Module exists', function () { - expect(DisplayObject).to.be.a('function'); - // expect(PIXI).to.have.property('visibleCount', 0); - }); - - it('Confirm new instance', function () { - var obj = new DisplayObject(); - - pixi_display_DisplayObject_confirmNew(obj); - expect(obj).to.have.property('hitArea', null); - expect(obj).to.have.property('interactive', false); - expect(obj).to.have.property('renderable', false); - expect(obj).to.have.property('stage', null); - }); -}); diff --git a/test/unit/pixi/display/DisplayObjectContainer.js b/test/unit/pixi/display/DisplayObjectContainer.js deleted file mode 100644 index 15a3376..0000000 --- a/test/unit/pixi/display/DisplayObjectContainer.js +++ /dev/null @@ -1,67 +0,0 @@ -describe('pixi/display/DisplayObjectContainer', function () { - 'use strict'; - - var expect = chai.expect; - var DisplayObjectContainer = PIXI.DisplayObjectContainer; - - it('Module exists', function () { - expect(DisplayObjectContainer).to.be.a('function'); - }); - - it('Confirm new instance', function () { - var obj = new DisplayObjectContainer(); - - pixi_display_DisplayObjectContainer_confirmNew(obj); - expect(obj).to.have.property('hitArea', null); - expect(obj).to.have.property('interactive', false); - expect(obj).to.have.property('renderable', false); - expect(obj).to.have.property('stage', null); - }); - - it('Gets child index', function() { - var container = new PIXI.DisplayObjectContainer(); - var children = []; - for (var i = 0; i < 10; i++) { - var child = new PIXI.DisplayObject(); - children.push(child); - container.addChild(child); - } - - for (i = 0; i < children.length; i++) { - expect(i).to.eql(container.getChildIndex(children[i])); - } - }); - - it('throws error when trying to get index of not a child', function() { - var container = new PIXI.DisplayObjectContainer(); - var child = new PIXI.DisplayObject(); - - expect(function() { container.getChildIndex(child); }).to.throw(); - }); - - it('Sets child index', function() { - var container = new PIXI.DisplayObjectContainer(); - var children = []; - - for (var i = 0; i < 10; i++) { - var child = new PIXI.DisplayObject(); - children.push(child); - container.addChild(child); - } - children.reverse(); - - for (i = 0; i < children.length; i++) { - container.setChildIndex(children[i], i); - expect(i).to.eql(container.getChildIndex(children[i])); - } - }); - - it('throws error when trying to set incorect index', function() { - var container = new PIXI.DisplayObjectContainer(); - var child = new PIXI.DisplayObject(); - container.addChild(child); - - expect(function() { container.setChildIndex(child, -1); }).to.throw(); - expect(function() { container.setChildIndex(child, 1); }).to.throw(); - }); -}); diff --git a/test/unit/pixi/display/MovieClip.js b/test/unit/pixi/display/MovieClip.js deleted file mode 100644 index f3c6c6a..0000000 --- a/test/unit/pixi/display/MovieClip.js +++ /dev/null @@ -1,33 +0,0 @@ -describe('pixi/display/MovieClip', function () { - 'use strict'; - - var expect = chai.expect; - var MovieClip = PIXI.MovieClip; - var Texture = PIXI.Texture; - - it('Module exists', function () { - expect(MovieClip).to.be.a('function'); - }); - - it('Confirm new instance', function (done) { - var texture = Texture.fromImage('/base/test/textures/SpriteSheet-Explosion.png'); - var obj = new MovieClip([texture]); - - pixi_display_Sprite_confirmNew(obj, done); - - expect(obj).to.be.an.instanceof(MovieClip); - expect(obj).to.respondTo('stop'); - expect(obj).to.respondTo('play'); - expect(obj).to.respondTo('gotoAndStop'); - expect(obj).to.respondTo('gotoAndPlay'); - expect(obj).to.respondTo('updateTransform'); - - expect(obj).to.have.deep.property('textures.length', 1); - expect(obj).to.have.deep.property('textures[0]', texture); - expect(obj).to.have.property('animationSpeed', 1); - expect(obj).to.have.property('loop', true); - expect(obj).to.have.property('onComplete', null); - expect(obj).to.have.property('currentFrame', 0); - expect(obj).to.have.property('playing', false); - }); -}); diff --git a/test/unit/pixi/display/Sprite.js b/test/unit/pixi/display/Sprite.js deleted file mode 100644 index 30c8076..0000000 --- a/test/unit/pixi/display/Sprite.js +++ /dev/null @@ -1,28 +0,0 @@ -describe('pixi/display/Sprite', function () { - 'use strict'; - - var expect = chai.expect; - var Sprite = PIXI.Sprite; - var Texture = PIXI.Texture; - - it('Module exists', function () { - expect(Sprite).to.be.a('function'); - expect(PIXI).to.have.deep.property('blendModes.NORMAL', 0); - expect(PIXI).to.have.deep.property('blendModes.ADD', 1); - expect(PIXI).to.have.deep.property('blendModes.MULTIPLY', 2); - expect(PIXI).to.have.deep.property('blendModes.SCREEN', 3); - }); - - - it('Members exist', function () { - expect(Sprite).itself.to.respondTo('fromImage'); - expect(Sprite).itself.to.respondTo('fromFrame'); - }); - - it('Confirm new instance', function (done) { - var texture = Texture.fromImage('/base/test/textures/SpriteSheet-Aliens.png'); - var obj = new Sprite(texture); - - pixi_display_Sprite_confirmNew(obj, done); - }); -}); diff --git a/test/unit/pixi/display/Stage.js b/test/unit/pixi/display/Stage.js deleted file mode 100644 index 6974c2e..0000000 --- a/test/unit/pixi/display/Stage.js +++ /dev/null @@ -1,49 +0,0 @@ -describe('pixi/display/Stage', function () { - 'use strict'; - - var expect = chai.expect; - var Stage = PIXI.Stage; - var InteractionManager = PIXI.InteractionManager; - var Rectangle = PIXI.Rectangle; - - it('Module exists', function () { - expect(Stage).to.be.a('function'); - }); - - it('Confirm new instance', function () { - var obj = new Stage(null, true); - - pixi_display_DisplayObjectContainer_confirmNew(obj); - - expect(obj).to.be.an.instanceof(Stage); - expect(obj).to.respondTo('updateTransform'); - expect(obj).to.respondTo('setBackgroundColor'); - expect(obj).to.respondTo('getMousePosition'); - // FIXME: duplicate member in DisplayObject - pixi_core_Matrix_confirmNewMatrix(obj.worldTransform); - // FIXME: convert arg to bool in constructor - expect(obj).to.have.property('interactive', true); - - expect(obj).to.have.property('interactionManager') - .and.to.be.an.instanceof(InteractionManager) - .and.to.have.property('stage', obj); - - expect(obj).to.have.property('dirty', true); - - expect(obj).to.have.property('stage', obj); - - expect(obj).to.have.property('hitArea') - .and.to.be.an.instanceof(Rectangle); - pixi_core_Rectangle_confirm(obj.hitArea, 0, 0, 100000, 100000); - - expect(obj).to.have.property('backgroundColor', 0x000000); - expect(obj).to.have.deep.property('backgroundColorSplit.length', 3); - expect(obj).to.have.deep.property('backgroundColorSplit[0]', 0); - expect(obj).to.have.deep.property('backgroundColorSplit[1]', 0); - expect(obj).to.have.deep.property('backgroundColorSplit[2]', 0); - expect(obj).to.have.property('backgroundColorString', '#000000'); - - - expect(obj).to.have.property('worldVisible', true); - }); -}); diff --git a/test/unit/pixi/extras/Rope.js b/test/unit/pixi/extras/Rope.js deleted file mode 100644 index 05885ac..0000000 --- a/test/unit/pixi/extras/Rope.js +++ /dev/null @@ -1,31 +0,0 @@ -describe('pixi/extras/Rope', function () { - 'use strict'; - - var expect = chai.expect; - var Rope = PIXI.Rope; - var Texture = PIXI.Texture; - var Point = PIXI.Point; - - it('Module exists', function () { - expect(Rope).to.be.a('function'); - }); - - it('Confirm new instance', function () { - - var texture = Texture.fromImage('/base/test/textures/bunny.png'); - - // TODO-Alvin - // Same as Strip - - // var obj = new Rope(texture, [new Point(), new Point(5, 10), new Point(10, 20)]); - - // pixi_extras_Strip_confirmNew(obj); - - // expect(obj).to.be.an.instanceof(Rope); - // expect(obj).to.respondTo('refresh'); - // expect(obj).to.respondTo('updateTransform'); - // expect(obj).to.respondTo('setTexture'); - - // TODO: Test properties - }); -}); diff --git a/test/unit/pixi/extras/Spine.js b/test/unit/pixi/extras/Spine.js deleted file mode 100644 index 0708bc0..0000000 --- a/test/unit/pixi/extras/Spine.js +++ /dev/null @@ -1,10 +0,0 @@ -describe('pixi/extras/Spine', function () { - 'use strict'; - - var expect = chai.expect; - var Spine = PIXI.Spine; - - it('Module exists', function () { - expect(Spine).to.be.a('function'); - }); -}); diff --git a/test/unit/pixi/extras/Strip.js b/test/unit/pixi/extras/Strip.js deleted file mode 100644 index 230af90..0000000 --- a/test/unit/pixi/extras/Strip.js +++ /dev/null @@ -1,26 +0,0 @@ -describe('pixi/extras/Strip', function () { - 'use strict'; - - var expect = chai.expect; - var Strip = PIXI.Strip; - var Texture = PIXI.Texture; - - it('Module exists', function () { - expect(Strip).to.be.a('function'); - }); - - it('Confirm new instance', function () { - - - // TODO-Alvin - // We tweaked it to make it pass the tests, but the whole strip class needs - // to be re-coded - - var texture = Texture.fromImage('/base/test/textures/bunny.png'); - - // var obj = new Strip(texture, 20, 10000); - - - // pixi_extras_Strip_confirmNew(obj); - }); -}); diff --git a/test/unit/pixi/extras/TilingSprite.js b/test/unit/pixi/extras/TilingSprite.js deleted file mode 100644 index 56aea14..0000000 --- a/test/unit/pixi/extras/TilingSprite.js +++ /dev/null @@ -1,24 +0,0 @@ -describe('pixi/extras/TilingSprite', function () { - 'use strict'; - - var expect = chai.expect; - var TilingSprite = PIXI.TilingSprite; - var Texture = PIXI.Texture; - - it('Module exists', function () { - expect(TilingSprite).to.be.a('function'); - }); - - it('Confirm new instance', function () { - var texture = Texture.fromImage('/base/test/textures/bunny.png'); - var obj = new TilingSprite(texture, 6000, 12000); - - pixi_display_DisplayObjectContainer_confirmNew(obj); - - expect(obj).to.be.an.instanceof(TilingSprite); - expect(obj).to.respondTo('setTexture'); - expect(obj).to.respondTo('onTextureUpdate'); - - // TODO: Test properties - }); -}); diff --git a/test/unit/pixi-v2/InteractionManager.js b/test/unit/pixi-v2/InteractionManager.js new file mode 100644 index 0000000..ed3001f --- /dev/null +++ b/test/unit/pixi-v2/InteractionManager.js @@ -0,0 +1,10 @@ +describe('pixi/InteractionManager', function () { + 'use strict'; + + var expect = chai.expect; + var InteractionManager = PIXI.InteractionManager; + + it('Module exists', function () { + expect(InteractionManager).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/Pixi.js b/test/unit/pixi-v2/Pixi.js new file mode 100644 index 0000000..27debc1 --- /dev/null +++ b/test/unit/pixi-v2/Pixi.js @@ -0,0 +1,9 @@ +describe('pixi/Pixi', function () { + 'use strict'; + + var expect = chai.expect; + + it('Module exists', function () { + expect(global).to.have.property('PIXI').and.to.be.an('object'); + }); +}); diff --git a/test/unit/pixi-v2/core/Circle.js b/test/unit/pixi-v2/core/Circle.js new file mode 100644 index 0000000..fbcfa17 --- /dev/null +++ b/test/unit/pixi-v2/core/Circle.js @@ -0,0 +1,21 @@ +describe('pixi/core/Circle', function () { + 'use strict'; + + var expect = chai.expect; + var Circle = PIXI.Circle; + + it('Module exists', function () { + expect(Circle).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Circle(); + pixi_core_Circle_confirmNewCircle(obj); + }); + + it("getBounds should return Rectangle that bounds the circle", function() { + var obj = new Circle(100, 250, 50); + var bounds = obj.getBounds(); + pixi_core_Circle_isBoundedByRectangle(obj, bounds); + }); +}); diff --git a/test/unit/pixi-v2/core/Ellipse.js b/test/unit/pixi-v2/core/Ellipse.js new file mode 100644 index 0000000..026b56f --- /dev/null +++ b/test/unit/pixi-v2/core/Ellipse.js @@ -0,0 +1,24 @@ +describe('pixi/core/Ellipse', function () { + 'use strict'; + + var expect = chai.expect; + var Ellipse = PIXI.Ellipse; + + it('Module exists', function () { + expect(Ellipse).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Ellipse(); + + expect(obj).to.be.an.instanceof(Ellipse); + expect(obj).to.respondTo('clone'); + expect(obj).to.respondTo('contains'); + expect(obj).to.respondTo('getBounds'); + + expect(obj).to.have.property('x', 0); + expect(obj).to.have.property('y', 0); + expect(obj).to.have.property('width', 0); + expect(obj).to.have.property('height', 0); + }); +}); diff --git a/test/unit/pixi-v2/core/Matrix.js b/test/unit/pixi-v2/core/Matrix.js new file mode 100644 index 0000000..da75e2e --- /dev/null +++ b/test/unit/pixi-v2/core/Matrix.js @@ -0,0 +1,14 @@ +describe('pixi/core/Matrix', function () { + 'use strict'; + + var expect = chai.expect; + + it('Matrix exists', function () { + expect(PIXI.Matrix).to.be.an('function'); + }); + + it('Confirm new Matrix', function () { + var matrix = new PIXI.Matrix(); + pixi_core_Matrix_confirmNewMatrix(matrix); + }); +}); diff --git a/test/unit/pixi-v2/core/Point.js b/test/unit/pixi-v2/core/Point.js new file mode 100644 index 0000000..c4d5163 --- /dev/null +++ b/test/unit/pixi-v2/core/Point.js @@ -0,0 +1,15 @@ +describe('pixi/core/Point', function () { + 'use strict'; + + var expect = chai.expect; + var Point = PIXI.Point; + + it('Module exists', function () { + expect(Point).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Point(); + pixi_core_Point_confirm(obj, 0, 0); + }); +}); diff --git a/test/unit/pixi-v2/core/Polygon.js b/test/unit/pixi-v2/core/Polygon.js new file mode 100644 index 0000000..dc8c918 --- /dev/null +++ b/test/unit/pixi-v2/core/Polygon.js @@ -0,0 +1,20 @@ +describe('pixi/core/Polygon', function () { + 'use strict'; + + var expect = chai.expect; + var Polygon = PIXI.Polygon; + + it('Module exists', function () { + expect(Polygon).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Polygon(); + + expect(obj).to.be.an.instanceof(Polygon); + expect(obj).to.respondTo('clone'); + expect(obj).to.respondTo('contains'); + + expect(obj).to.have.deep.property('points.length', 0); + }); +}); diff --git a/test/unit/pixi-v2/core/Rectangle.js b/test/unit/pixi-v2/core/Rectangle.js new file mode 100644 index 0000000..d43316e --- /dev/null +++ b/test/unit/pixi-v2/core/Rectangle.js @@ -0,0 +1,15 @@ +describe('pixi/core/Rectangle', function () { + 'use strict'; + + var expect = chai.expect; + var Rectangle = PIXI.Rectangle; + + it('Module exists', function () { + expect(Rectangle).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var rect = new Rectangle(); + pixi_core_Rectangle_confirm(rect, 0, 0, 0, 0); + }); +}); diff --git a/test/unit/pixi-v2/display/DisplayObject.js b/test/unit/pixi-v2/display/DisplayObject.js new file mode 100644 index 0000000..044acf8 --- /dev/null +++ b/test/unit/pixi-v2/display/DisplayObject.js @@ -0,0 +1,21 @@ +describe('pixi/display/DisplayObject', function () { + 'use strict'; + + var expect = chai.expect; + var DisplayObject = PIXI.DisplayObject; + + it('Module exists', function () { + expect(DisplayObject).to.be.a('function'); + // expect(PIXI).to.have.property('visibleCount', 0); + }); + + it('Confirm new instance', function () { + var obj = new DisplayObject(); + + pixi_display_DisplayObject_confirmNew(obj); + expect(obj).to.have.property('hitArea', null); + expect(obj).to.have.property('interactive', false); + expect(obj).to.have.property('renderable', false); + expect(obj).to.have.property('stage', null); + }); +}); diff --git a/test/unit/pixi-v2/display/DisplayObjectContainer.js b/test/unit/pixi-v2/display/DisplayObjectContainer.js new file mode 100644 index 0000000..15a3376 --- /dev/null +++ b/test/unit/pixi-v2/display/DisplayObjectContainer.js @@ -0,0 +1,67 @@ +describe('pixi/display/DisplayObjectContainer', function () { + 'use strict'; + + var expect = chai.expect; + var DisplayObjectContainer = PIXI.DisplayObjectContainer; + + it('Module exists', function () { + expect(DisplayObjectContainer).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new DisplayObjectContainer(); + + pixi_display_DisplayObjectContainer_confirmNew(obj); + expect(obj).to.have.property('hitArea', null); + expect(obj).to.have.property('interactive', false); + expect(obj).to.have.property('renderable', false); + expect(obj).to.have.property('stage', null); + }); + + it('Gets child index', function() { + var container = new PIXI.DisplayObjectContainer(); + var children = []; + for (var i = 0; i < 10; i++) { + var child = new PIXI.DisplayObject(); + children.push(child); + container.addChild(child); + } + + for (i = 0; i < children.length; i++) { + expect(i).to.eql(container.getChildIndex(children[i])); + } + }); + + it('throws error when trying to get index of not a child', function() { + var container = new PIXI.DisplayObjectContainer(); + var child = new PIXI.DisplayObject(); + + expect(function() { container.getChildIndex(child); }).to.throw(); + }); + + it('Sets child index', function() { + var container = new PIXI.DisplayObjectContainer(); + var children = []; + + for (var i = 0; i < 10; i++) { + var child = new PIXI.DisplayObject(); + children.push(child); + container.addChild(child); + } + children.reverse(); + + for (i = 0; i < children.length; i++) { + container.setChildIndex(children[i], i); + expect(i).to.eql(container.getChildIndex(children[i])); + } + }); + + it('throws error when trying to set incorect index', function() { + var container = new PIXI.DisplayObjectContainer(); + var child = new PIXI.DisplayObject(); + container.addChild(child); + + expect(function() { container.setChildIndex(child, -1); }).to.throw(); + expect(function() { container.setChildIndex(child, 1); }).to.throw(); + }); +}); diff --git a/test/unit/pixi-v2/display/MovieClip.js b/test/unit/pixi-v2/display/MovieClip.js new file mode 100644 index 0000000..f3c6c6a --- /dev/null +++ b/test/unit/pixi-v2/display/MovieClip.js @@ -0,0 +1,33 @@ +describe('pixi/display/MovieClip', function () { + 'use strict'; + + var expect = chai.expect; + var MovieClip = PIXI.MovieClip; + var Texture = PIXI.Texture; + + it('Module exists', function () { + expect(MovieClip).to.be.a('function'); + }); + + it('Confirm new instance', function (done) { + var texture = Texture.fromImage('/base/test/textures/SpriteSheet-Explosion.png'); + var obj = new MovieClip([texture]); + + pixi_display_Sprite_confirmNew(obj, done); + + expect(obj).to.be.an.instanceof(MovieClip); + expect(obj).to.respondTo('stop'); + expect(obj).to.respondTo('play'); + expect(obj).to.respondTo('gotoAndStop'); + expect(obj).to.respondTo('gotoAndPlay'); + expect(obj).to.respondTo('updateTransform'); + + expect(obj).to.have.deep.property('textures.length', 1); + expect(obj).to.have.deep.property('textures[0]', texture); + expect(obj).to.have.property('animationSpeed', 1); + expect(obj).to.have.property('loop', true); + expect(obj).to.have.property('onComplete', null); + expect(obj).to.have.property('currentFrame', 0); + expect(obj).to.have.property('playing', false); + }); +}); diff --git a/test/unit/pixi-v2/display/Sprite.js b/test/unit/pixi-v2/display/Sprite.js new file mode 100644 index 0000000..30c8076 --- /dev/null +++ b/test/unit/pixi-v2/display/Sprite.js @@ -0,0 +1,28 @@ +describe('pixi/display/Sprite', function () { + 'use strict'; + + var expect = chai.expect; + var Sprite = PIXI.Sprite; + var Texture = PIXI.Texture; + + it('Module exists', function () { + expect(Sprite).to.be.a('function'); + expect(PIXI).to.have.deep.property('blendModes.NORMAL', 0); + expect(PIXI).to.have.deep.property('blendModes.ADD', 1); + expect(PIXI).to.have.deep.property('blendModes.MULTIPLY', 2); + expect(PIXI).to.have.deep.property('blendModes.SCREEN', 3); + }); + + + it('Members exist', function () { + expect(Sprite).itself.to.respondTo('fromImage'); + expect(Sprite).itself.to.respondTo('fromFrame'); + }); + + it('Confirm new instance', function (done) { + var texture = Texture.fromImage('/base/test/textures/SpriteSheet-Aliens.png'); + var obj = new Sprite(texture); + + pixi_display_Sprite_confirmNew(obj, done); + }); +}); diff --git a/test/unit/pixi-v2/display/Stage.js b/test/unit/pixi-v2/display/Stage.js new file mode 100644 index 0000000..6974c2e --- /dev/null +++ b/test/unit/pixi-v2/display/Stage.js @@ -0,0 +1,49 @@ +describe('pixi/display/Stage', function () { + 'use strict'; + + var expect = chai.expect; + var Stage = PIXI.Stage; + var InteractionManager = PIXI.InteractionManager; + var Rectangle = PIXI.Rectangle; + + it('Module exists', function () { + expect(Stage).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Stage(null, true); + + pixi_display_DisplayObjectContainer_confirmNew(obj); + + expect(obj).to.be.an.instanceof(Stage); + expect(obj).to.respondTo('updateTransform'); + expect(obj).to.respondTo('setBackgroundColor'); + expect(obj).to.respondTo('getMousePosition'); + // FIXME: duplicate member in DisplayObject + pixi_core_Matrix_confirmNewMatrix(obj.worldTransform); + // FIXME: convert arg to bool in constructor + expect(obj).to.have.property('interactive', true); + + expect(obj).to.have.property('interactionManager') + .and.to.be.an.instanceof(InteractionManager) + .and.to.have.property('stage', obj); + + expect(obj).to.have.property('dirty', true); + + expect(obj).to.have.property('stage', obj); + + expect(obj).to.have.property('hitArea') + .and.to.be.an.instanceof(Rectangle); + pixi_core_Rectangle_confirm(obj.hitArea, 0, 0, 100000, 100000); + + expect(obj).to.have.property('backgroundColor', 0x000000); + expect(obj).to.have.deep.property('backgroundColorSplit.length', 3); + expect(obj).to.have.deep.property('backgroundColorSplit[0]', 0); + expect(obj).to.have.deep.property('backgroundColorSplit[1]', 0); + expect(obj).to.have.deep.property('backgroundColorSplit[2]', 0); + expect(obj).to.have.property('backgroundColorString', '#000000'); + + + expect(obj).to.have.property('worldVisible', true); + }); +}); diff --git a/test/unit/pixi-v2/extras/Rope.js b/test/unit/pixi-v2/extras/Rope.js new file mode 100644 index 0000000..05885ac --- /dev/null +++ b/test/unit/pixi-v2/extras/Rope.js @@ -0,0 +1,31 @@ +describe('pixi/extras/Rope', function () { + 'use strict'; + + var expect = chai.expect; + var Rope = PIXI.Rope; + var Texture = PIXI.Texture; + var Point = PIXI.Point; + + it('Module exists', function () { + expect(Rope).to.be.a('function'); + }); + + it('Confirm new instance', function () { + + var texture = Texture.fromImage('/base/test/textures/bunny.png'); + + // TODO-Alvin + // Same as Strip + + // var obj = new Rope(texture, [new Point(), new Point(5, 10), new Point(10, 20)]); + + // pixi_extras_Strip_confirmNew(obj); + + // expect(obj).to.be.an.instanceof(Rope); + // expect(obj).to.respondTo('refresh'); + // expect(obj).to.respondTo('updateTransform'); + // expect(obj).to.respondTo('setTexture'); + + // TODO: Test properties + }); +}); diff --git a/test/unit/pixi-v2/extras/Spine.js b/test/unit/pixi-v2/extras/Spine.js new file mode 100644 index 0000000..0708bc0 --- /dev/null +++ b/test/unit/pixi-v2/extras/Spine.js @@ -0,0 +1,10 @@ +describe('pixi/extras/Spine', function () { + 'use strict'; + + var expect = chai.expect; + var Spine = PIXI.Spine; + + it('Module exists', function () { + expect(Spine).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/extras/Strip.js b/test/unit/pixi-v2/extras/Strip.js new file mode 100644 index 0000000..230af90 --- /dev/null +++ b/test/unit/pixi-v2/extras/Strip.js @@ -0,0 +1,26 @@ +describe('pixi/extras/Strip', function () { + 'use strict'; + + var expect = chai.expect; + var Strip = PIXI.Strip; + var Texture = PIXI.Texture; + + it('Module exists', function () { + expect(Strip).to.be.a('function'); + }); + + it('Confirm new instance', function () { + + + // TODO-Alvin + // We tweaked it to make it pass the tests, but the whole strip class needs + // to be re-coded + + var texture = Texture.fromImage('/base/test/textures/bunny.png'); + + // var obj = new Strip(texture, 20, 10000); + + + // pixi_extras_Strip_confirmNew(obj); + }); +}); diff --git a/test/unit/pixi-v2/extras/TilingSprite.js b/test/unit/pixi-v2/extras/TilingSprite.js new file mode 100644 index 0000000..56aea14 --- /dev/null +++ b/test/unit/pixi-v2/extras/TilingSprite.js @@ -0,0 +1,24 @@ +describe('pixi/extras/TilingSprite', function () { + 'use strict'; + + var expect = chai.expect; + var TilingSprite = PIXI.TilingSprite; + var Texture = PIXI.Texture; + + it('Module exists', function () { + expect(TilingSprite).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var texture = Texture.fromImage('/base/test/textures/bunny.png'); + var obj = new TilingSprite(texture, 6000, 12000); + + pixi_display_DisplayObjectContainer_confirmNew(obj); + + expect(obj).to.be.an.instanceof(TilingSprite); + expect(obj).to.respondTo('setTexture'); + expect(obj).to.respondTo('onTextureUpdate'); + + // TODO: Test properties + }); +}); diff --git a/test/unit/pixi-v2/filters/FilterBlock.js b/test/unit/pixi-v2/filters/FilterBlock.js new file mode 100644 index 0000000..870cec0 --- /dev/null +++ b/test/unit/pixi-v2/filters/FilterBlock.js @@ -0,0 +1,10 @@ +describe('pixi/filters/FilterBlock', function () { + 'use strict'; + + var expect = chai.expect; + var FilterBlock = PIXI.FilterBlock; + + it('Module exists', function () { + expect(FilterBlock).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/AssetLoader.js b/test/unit/pixi-v2/loaders/AssetLoader.js new file mode 100644 index 0000000..a0aa0b5 --- /dev/null +++ b/test/unit/pixi-v2/loaders/AssetLoader.js @@ -0,0 +1,10 @@ +describe('pixi/loaders/AssetLoader', function () { + 'use strict'; + + var expect = chai.expect; + var AssetLoader = PIXI.AssetLoader; + + it('Module exists', function () { + expect(AssetLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/BitmapFontLoader.js b/test/unit/pixi-v2/loaders/BitmapFontLoader.js new file mode 100644 index 0000000..046f018 --- /dev/null +++ b/test/unit/pixi-v2/loaders/BitmapFontLoader.js @@ -0,0 +1,9 @@ +describe('pixi/loaders/BitmapFontLoader', function () { + 'use strict'; + + var expect = chai.expect; + + it('Module exists', function () { + expect(PIXI.BitmapFontLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/ImageLoader.js b/test/unit/pixi-v2/loaders/ImageLoader.js new file mode 100644 index 0000000..8b1f556 --- /dev/null +++ b/test/unit/pixi-v2/loaders/ImageLoader.js @@ -0,0 +1,10 @@ +describe('pixi/loaders/ImageLoader', function () { + 'use strict'; + + var expect = chai.expect; + var ImageLoader = PIXI.ImageLoader; + + it('Module exists', function () { + expect(ImageLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/JsonLoader.js b/test/unit/pixi-v2/loaders/JsonLoader.js new file mode 100644 index 0000000..c577e83 --- /dev/null +++ b/test/unit/pixi-v2/loaders/JsonLoader.js @@ -0,0 +1,10 @@ +describe('pixi/loaders/JsonLoader', function () { + 'use strict'; + + var expect = chai.expect; + var JsonLoader = PIXI.JsonLoader; + + it('Module exists', function () { + expect(JsonLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/SpineLoader.js b/test/unit/pixi-v2/loaders/SpineLoader.js new file mode 100644 index 0000000..fdcc0b8 --- /dev/null +++ b/test/unit/pixi-v2/loaders/SpineLoader.js @@ -0,0 +1,10 @@ +describe('pixi/loaders/SpineLoader', function () { + 'use strict'; + + var expect = chai.expect; + var SpineLoader = PIXI.SpineLoader; + + it('Module exists', function () { + expect(SpineLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/SpriteSheetLoader.js b/test/unit/pixi-v2/loaders/SpriteSheetLoader.js new file mode 100644 index 0000000..57beb27 --- /dev/null +++ b/test/unit/pixi-v2/loaders/SpriteSheetLoader.js @@ -0,0 +1,10 @@ +describe('pixi/loaders/SpriteSheetLoader', function () { + 'use strict'; + + var expect = chai.expect; + var SpriteSheetLoader = PIXI.SpriteSheetLoader; + + it('Module exists', function () { + expect(SpriteSheetLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/primitives/Graphics.js b/test/unit/pixi-v2/primitives/Graphics.js new file mode 100644 index 0000000..f3849eb --- /dev/null +++ b/test/unit/pixi-v2/primitives/Graphics.js @@ -0,0 +1,44 @@ +describe('pixi/primitives/Graphics', function () { + 'use strict'; + + var expect = chai.expect; + var Graphics = PIXI.Graphics; + + it('Module exists', function () { + expect(Graphics).to.be.a('function'); + + expect(Graphics).itself.to.have.property('POLY', 0); + expect(Graphics).itself.to.have.property('RECT', 1); + expect(Graphics).itself.to.have.property('CIRC', 2); + expect(Graphics).itself.to.have.property('ELIP', 3); + expect(Graphics).itself.to.have.property('RREC', 4); + }); + + it('Confirm new instance', function () { + var obj = new Graphics(); + + pixi_display_DisplayObjectContainer_confirmNew(obj); + + expect(obj).to.be.an.instanceof(Graphics); + expect(obj).to.respondTo('lineStyle'); + expect(obj).to.respondTo('lineStyle'); + expect(obj).to.respondTo('moveTo'); + expect(obj).to.respondTo('lineTo'); + expect(obj).to.respondTo('beginFill'); + expect(obj).to.respondTo('endFill'); + expect(obj).to.respondTo('drawRect'); + // expect(obj).to.respondTo('drawRoundedRect'); + expect(obj).to.respondTo('drawCircle'); + expect(obj).to.respondTo('drawEllipse'); + expect(obj).to.respondTo('clear'); + + expect(obj).to.have.property('renderable', true); + expect(obj).to.have.property('fillAlpha', 1); + expect(obj).to.have.property('lineWidth', 0); + expect(obj).to.have.property('width', 0); + expect(obj).to.have.property('height', 0); + expect(obj).to.have.property('lineColor', 0); + expect(obj).to.have.deep.property('graphicsData.length', 0); + // expect(obj).to.have.deep.property('currentPath.points.length', 0); + }); +}); diff --git a/test/unit/pixi-v2/renderers/canvas/CanvasGraphics.js b/test/unit/pixi-v2/renderers/canvas/CanvasGraphics.js new file mode 100644 index 0000000..8f44472 --- /dev/null +++ b/test/unit/pixi-v2/renderers/canvas/CanvasGraphics.js @@ -0,0 +1,15 @@ +describe('renders/canvas/CanvasGraphics', function () { + 'use strict'; + + var expect = chai.expect; + var CanvasGraphics = PIXI.CanvasGraphics; + + it('Module exists', function () { + expect(CanvasGraphics).to.be.a('function'); + }); + + it('Members exist', function () { + expect(CanvasGraphics).itself.to.respondTo('renderGraphics'); + expect(CanvasGraphics).itself.to.respondTo('renderGraphicsMask'); + }); +}); diff --git a/test/unit/pixi-v2/renderers/canvas/CanvasRenderer.js b/test/unit/pixi-v2/renderers/canvas/CanvasRenderer.js new file mode 100644 index 0000000..1646444 --- /dev/null +++ b/test/unit/pixi-v2/renderers/canvas/CanvasRenderer.js @@ -0,0 +1,36 @@ +describe('renderers/canvas/CanvasRenderer', function () { + 'use strict'; + + var expect = chai.expect; + var CanvasRenderer = PIXI.CanvasRenderer; + + it('Module exists', function () { + expect(CanvasRenderer).to.be.a('function'); + }); + + describe('.autoResize', function () { + it('Should automatically resize view if enabled', function () { + var renderer = new CanvasRenderer(200, 200, { + autoResize: true + }); + + expect(renderer.view.style.width).to.equal('200px'); + }); + + it('Should not automatically resize view if disabled', function () { + var renderer = new CanvasRenderer(200, 200, { + autoResize: false + }); + + expect(renderer.view.style.width).to.equal(''); + }); + + it('Should not automatically resize view if not specified', function () { + var renderer = new CanvasRenderer(200, 200, { + resolution: 2 + }); + + expect(renderer.view.style.width).to.equal(''); + }); + }); +}); diff --git a/test/unit/pixi-v2/renderers/webgl/WebGLGraphics.js b/test/unit/pixi-v2/renderers/webgl/WebGLGraphics.js new file mode 100644 index 0000000..5867b28 --- /dev/null +++ b/test/unit/pixi-v2/renderers/webgl/WebGLGraphics.js @@ -0,0 +1,20 @@ +describe('renderers/wegbl/WebGLGraphics', function () { + 'use strict'; + + var expect = chai.expect; + var WebGLGraphics = PIXI.WebGLGraphics; + + it('Module exists', function () { + expect(WebGLGraphics).to.be.a('function'); + }); + + it('Members exist', function () { + expect(WebGLGraphics).itself.to.respondTo('renderGraphics'); + expect(WebGLGraphics).itself.to.respondTo('updateGraphics'); + expect(WebGLGraphics).itself.to.respondTo('buildRectangle'); + expect(WebGLGraphics).itself.to.respondTo('buildRoundedRectangle'); + expect(WebGLGraphics).itself.to.respondTo('buildCircle'); + expect(WebGLGraphics).itself.to.respondTo('buildLine'); + expect(WebGLGraphics).itself.to.respondTo('buildPoly'); + }); +}); diff --git a/test/unit/pixi-v2/renderers/webgl/WebGLRenderer.js b/test/unit/pixi-v2/renderers/webgl/WebGLRenderer.js new file mode 100644 index 0000000..1680a80 --- /dev/null +++ b/test/unit/pixi-v2/renderers/webgl/WebGLRenderer.js @@ -0,0 +1,49 @@ +describe('renderers/webgl/WebGLRenderer', function () { + 'use strict'; + + var expect = chai.expect; + var WebGLRenderer = PIXI.WebGLRenderer; + + it('Module exists', function () { + expect(WebGLRenderer).to.be.a('function'); + }); + + // Skip tests if WebGL is not available (WebGL not supported in Travis CI) + try { + var renderer = new WebGLRenderer(400, 300, {}); + renderer.destroy(); + } catch (error) { + return; + } + + it('Destroy renderer', function () { + var renderer = new WebGLRenderer(400, 300, {}); + renderer.destroy(); + }); + + describe('.autoResize', function () { + it('Should automatically resize view if enabled', function () { + var renderer = new WebGLRenderer(200, 200, { + autoResize: true + }); + + expect(renderer.view.style.width).to.equal('200px'); + }); + + it('Should not automatically resize view if disabled', function () { + var renderer = new WebGLRenderer(200, 200, { + autoResize: false + }); + + expect(renderer.view.style.width).to.equal(''); + }); + + it('Should not automatically resize view if not specified', function () { + var renderer = new WebGLRenderer(200, 200, { + resolution: 2 + }); + + expect(renderer.view.style.width).to.equal(''); + }); + }); +}); diff --git a/test/unit/pixi-v2/renderers/webgl/WebGLShaders.js b/test/unit/pixi-v2/renderers/webgl/WebGLShaders.js new file mode 100644 index 0000000..6e33e4f --- /dev/null +++ b/test/unit/pixi-v2/renderers/webgl/WebGLShaders.js @@ -0,0 +1,13 @@ +describe('renderers/webgl/WebGLShaders', function () { + 'use strict'; + + var expect = chai.expect; + + it('Module members exist', function () { + + expect(PIXI).to.respondTo('CompileVertexShader'); + expect(PIXI).to.respondTo('CompileFragmentShader'); + expect(PIXI).to.respondTo('_CompileShader'); + expect(PIXI).to.respondTo('compileProgram'); + }); +}); diff --git a/test/unit/pixi-v2/renderers/webgl/WebGLSpriteBatch.js b/test/unit/pixi-v2/renderers/webgl/WebGLSpriteBatch.js new file mode 100644 index 0000000..e662b63 --- /dev/null +++ b/test/unit/pixi-v2/renderers/webgl/WebGLSpriteBatch.js @@ -0,0 +1,10 @@ +describe('renderers/webgl/utils/WebGLSpriteBatch', function () { + 'use strict'; + + var expect = chai.expect; + var WebGLSpriteBatch = PIXI.WebGLSpriteBatch; + + it('Module exists', function () { + expect(WebGLSpriteBatch).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/text/BitmapText.js b/test/unit/pixi-v2/text/BitmapText.js new file mode 100644 index 0000000..9388e3d --- /dev/null +++ b/test/unit/pixi-v2/text/BitmapText.js @@ -0,0 +1,10 @@ +describe('pixi/text/BitmapText', function () { + 'use strict'; + + var expect = chai.expect; + var BitmapText = PIXI.BitmapText; + + it('Module exists', function () { + expect(BitmapText).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/text/Text.js b/test/unit/pixi-v2/text/Text.js new file mode 100644 index 0000000..9bc9ac5 --- /dev/null +++ b/test/unit/pixi-v2/text/Text.js @@ -0,0 +1,10 @@ +describe('pixi/text/Text', function () { + 'use strict'; + + var expect = chai.expect; + var Text = PIXI.Text; + + it('Module exists', function () { + expect(Text).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/textures/BaseTexture.js b/test/unit/pixi-v2/textures/BaseTexture.js new file mode 100644 index 0000000..502b724 --- /dev/null +++ b/test/unit/pixi-v2/textures/BaseTexture.js @@ -0,0 +1,11 @@ +describe('pixi/textures/BaseTexture', function () { + 'use strict'; + + var expect = chai.expect; + var BaseTexture = PIXI.BaseTexture; + + it('Module exists', function () { + expect(BaseTexture).to.be.a('function'); + expect(PIXI).to.have.property('BaseTextureCache').and.to.be.an('object'); + }); +}); diff --git a/test/unit/pixi-v2/textures/RenderTexture.js b/test/unit/pixi-v2/textures/RenderTexture.js new file mode 100644 index 0000000..96acdb4 --- /dev/null +++ b/test/unit/pixi-v2/textures/RenderTexture.js @@ -0,0 +1,15 @@ +describe('pixi/textures/RenderTexture', function () { + 'use strict'; + + var expect = chai.expect; + var RenderTexture = PIXI.RenderTexture; + + it('Module exists', function () { + expect(RenderTexture).to.be.a('function'); + }); + + it('Confirm new instance', function (done) { + var texture = new RenderTexture(100, 100, new PIXI.CanvasRenderer()); + pixi_textures_RenderTexture_confirmNew(texture, done); + }); +}); diff --git a/test/unit/pixi-v2/textures/Texture.js b/test/unit/pixi-v2/textures/Texture.js new file mode 100644 index 0000000..090f64d --- /dev/null +++ b/test/unit/pixi-v2/textures/Texture.js @@ -0,0 +1,26 @@ +describe('pixi/textures/Texture', function () { + 'use strict'; + + var expect = chai.expect; + var Texture = PIXI.Texture; + + it('Module exists', function () { + expect(Texture).to.be.a('function'); + expect(PIXI).to.have.property('TextureCache').and.to.be.an('object'); + }); + + it('Members exist', function () { + expect(Texture).itself.to.respondTo('fromImage'); + expect(Texture).itself.to.respondTo('fromFrame'); + expect(Texture).itself.to.respondTo('fromCanvas'); + expect(Texture).itself.to.respondTo('addTextureToCache'); + expect(Texture).itself.to.respondTo('removeTextureFromCache'); + + // expect(Texture).itself.to.have.deep.property('frameUpdates.length', 0); + }); + + it('Confirm new instance', function (done) { + var texture = Texture.fromImage('/base/test/textures/bunny.png'); + pixi_textures_Texture_confirmNew(texture, done); + }); +}); diff --git a/test/unit/pixi-v2/utils/Detector.js b/test/unit/pixi-v2/utils/Detector.js new file mode 100644 index 0000000..4cf6008 --- /dev/null +++ b/test/unit/pixi-v2/utils/Detector.js @@ -0,0 +1,10 @@ +describe('pixi/utils/Detector', function () { + 'use strict'; + + var expect = chai.expect; + var autoDetectRenderer = PIXI.autoDetectRenderer; + + it('Module exists', function () { + expect(autoDetectRenderer).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/utils/EventTarget.js b/test/unit/pixi-v2/utils/EventTarget.js new file mode 100644 index 0000000..1cfc3a4 --- /dev/null +++ b/test/unit/pixi-v2/utils/EventTarget.js @@ -0,0 +1,361 @@ +describe('pixi/utils/EventTarget', function () { + 'use strict'; + + var expect = chai.expect; + + var Clazz, PClazz, obj, pobj, obj2; + beforeEach(function () { + Clazz = function () {}; + PClazz = function () {}; + + PIXI.EventTarget.mixin(Clazz.prototype); + PIXI.EventTarget.mixin(PClazz.prototype); + + obj = new Clazz(); + obj2 = new Clazz(); + pobj = new PClazz(); + + obj.parent = pobj; + obj2.parent = obj; + }); + + it('Module exists', function () { + expect(PIXI.EventTarget).to.be.an('object'); + }); + + it('Confirm new instance', function () { + pixi_utils_EventTarget_confirm(obj); + }); + + it('simple on/emit case works', function () { + var myData = {}; + + obj.on('myevent', function (event) { + pixi_utils_EventTarget_Event_confirm(event, obj, myData); + }); + + obj.emit('myevent', myData); + }); + + it('simple once case works', function () { + var called = 0; + + obj.once('myevent', function() { called++; }); + + obj.emit('myevent'); + obj.emit('myevent'); + obj.emit('myevent'); + obj.emit('myevent'); + obj.emit('myevent'); + + expect(called).to.equal(1); + }); + + it('simple off case works', function (done) { + function onMyEvent() { + done(new Error('Event listener should not have been called')); + } + + obj.on('myevent', onMyEvent); + obj.off('myevent', onMyEvent); + obj.emit('myevent'); + + done(); + }); + + it('simple propagation case works', function (done) { + var myData = {}; + + pobj.on('myevent', function () { + done(); + }); + + obj.emit('myevent'); + }); + + it('simple stopPropagation case works', function (done) { + var myData = {}; + + pobj.on('myevent', function () { + done(new Error('Event listener should not have been called on the parent element')); + }); + + obj.on('myevent', function (evt) { + evt.stopPropagation(); + }); + + obj.emit('myevent'); + + done(); + }); + + it('simple stopImmediatePropagation case works', function (done) { + var myData = {}; + + pobj.on('myevent', function () { + done(new Error('Event listener should not have been called on the parent')); + }); + + obj.on('myevent', function (evt) { + evt.stopImmediatePropagation(); + }); + + obj.on('myevent', function () { + done(new Error('Event listener should not have been called on the second')); + }); + + obj.emit('myevent'); + + done(); + }); + + it('multiple dispatches work properly', function () { + var called = 0; + + function onMyEvent() { + called++; + } + + obj.on('myevent', onMyEvent); + obj.emit('myevent'); + obj.emit('myevent'); + obj.emit('myevent'); + obj.emit('myevent'); + + expect(called).to.equal(4); + }); + + it('multiple events work properly', function () { + var called = 0; + + function onMyEvent() { + called++; + } + + obj.on('myevent1', onMyEvent); + obj.on('myevent2', onMyEvent); + obj.on('myevent3', onMyEvent); + obj.emit('myevent1'); + obj.emit('myevent2'); + obj.emit('myevent3'); + + expect(called).to.equal(3); + }); + + it('multiple events one removed works properly', function () { + var called = 0; + + function onMyEvent() { + called++; + } + + obj.on('myevent1', onMyEvent); + obj.on('myevent2', onMyEvent); + obj.on('myevent3', onMyEvent); + + obj.emit('myevent1'); + obj.emit('myevent2'); + obj.emit('myevent3'); + + obj.off('myevent2', onMyEvent); + + obj.emit('myevent1'); + obj.emit('myevent2'); + obj.emit('myevent3'); + + expect(called).to.equal(5); + }); + + it('multiple handlers for one event with some removed', function () { + var called = 0; + + var onMyEvent = function () { + called++; + }, + onMyEvent2 = function () { + called++; + }; + + // add 2 handlers and confirm they both get called + obj.on('myevent', onMyEvent); + obj.on('myevent', onMyEvent); + obj.on('myevent', onMyEvent2); + obj.on('myevent', onMyEvent2); + + obj.emit('myevent'); + + expect(called).to.equal(4); + + // remove one of the handlers, emit again, then ensure 1 more call is made + obj.off('myevent', onMyEvent); + + obj.emit('myevent'); + + expect(called).to.equal(6); + }); + + it('calls to off without a handler do nothing', function () { + var called = 0; + + var onMyEvent = function () { + called++; + }; + + obj.on('myevent', onMyEvent); + obj.on('myevent', onMyEvent); + + obj.emit('myevent'); + + expect(called).to.equal(2); + + obj.off('myevent'); + + obj.emit('myevent'); + + expect(called).to.equal(4); + + obj.off('myevent', onMyEvent); + + obj.emit('myevent'); + + expect(called).to.equal(4); + }); + + it('handles multiple instances with the same prototype', function () { + var called = 0; + + function onMyEvent(e) { + called++; + } + + obj.on('myevent1', onMyEvent); + obj.on('myevent2', onMyEvent); + + obj2.istwo = true; + obj2.on('myevent1', onMyEvent); + obj2.on('myevent2', onMyEvent); + + obj.emit('myevent1'); + obj.emit('myevent2'); + obj2.emit('myevent1'); + obj2.emit('myevent2'); + + //we emit 4 times, but since obj2 is a child of obj the event should bubble + //up to obj and show up there as well. So the obj2.emit() calls each increment + //the counter twice. + expect(called).to.equal(6); + }); + + it('is backwards compatible with older .dispatchEvent({})', function () { + var called = 0, + data = { + some: 'thing', + hello: true + }; + + function onMyEvent(event) { + pixi_utils_EventTarget_Event_confirm(event, obj, data); + + called++; + } + + obj.on('myevent1', onMyEvent); + obj.on('myevent2', onMyEvent); + obj.on('myevent3', onMyEvent); + + data.type = 'myevent1'; + obj.emit(data); + + data.type = 'myevent2'; + obj.emit(data); + + data.type = 'myevent3'; + obj.emit(data); + + obj.off('myevent2', onMyEvent); + + data.type = 'myevent1'; + obj.emit(data); + + data.type = 'myevent2'; + obj.emit(data); + + data.type = 'myevent3'; + obj.emit(data); + + expect(called).to.equal(5); + }); + + it('is backwards compatible with older .call(this)', function () { + var Fn = function() { + PIXI.EventTarget.call(this); + }, + o = new Fn(); + + pixi_utils_EventTarget_confirm(o); + }); + + it('is backwards compatible with older .addEventListener("")', function () { + var called = 0, + data = { + some: 'thing', + hello: true + }; + + function onMyEvent(event) { + pixi_utils_EventTarget_Event_confirm(event, obj, data); + + called++; + } + + obj.addEventListener('myevent1', onMyEvent); + obj.addEventListener('myevent2', onMyEvent); + obj.addEventListener('myevent3', onMyEvent); + + data.type = 'myevent1'; + obj.emit(data); + + data.type = 'myevent2'; + obj.emit(data); + + data.type = 'myevent3'; + obj.emit(data); + + obj.off('myevent2', onMyEvent); + + data.type = 'myevent1'; + obj.emit(data); + + data.type = 'myevent2'; + obj.emit(data); + + data.type = 'myevent3'; + obj.emit(data); + + expect(called).to.equal(5); + }); + + it('event remove during emit call properly', function () { + var called = 0; + + function cb1() { + called++; + obj.off('myevent', cb1); + } + function cb2() { + called++; + obj.off('myevent', cb2); + } + function cb3() { + called++; + obj.off('myevent', cb3); + } + + obj.on('myevent', cb1); + obj.on('myevent', cb2); + obj.on('myevent', cb3); + obj.emit('myevent', ''); + + expect(called).to.equal(3); + }); +}); diff --git a/test/unit/pixi-v2/utils/Polyk.js b/test/unit/pixi-v2/utils/Polyk.js new file mode 100644 index 0000000..dfc7128 --- /dev/null +++ b/test/unit/pixi-v2/utils/Polyk.js @@ -0,0 +1,14 @@ +describe('pixi/utils/Polyk', function () { + 'use strict'; + + var expect = chai.expect; + var PolyK = PIXI.PolyK; + + it('Module exists', function () { + expect(PolyK).to.be.an('object'); + }); + + it('Members exist', function () { + expect(PolyK).to.respondTo('Triangulate'); + }); +}); diff --git a/test/unit/pixi-v2/utils/Utils.js b/test/unit/pixi-v2/utils/Utils.js new file mode 100644 index 0000000..c97b3c6 --- /dev/null +++ b/test/unit/pixi-v2/utils/Utils.js @@ -0,0 +1,17 @@ +describe('Utils', function () { + 'use strict'; + + var expect = chai.expect; + + it('requestAnimationFrame exists', function () { + expect(global).to.respondTo('requestAnimationFrame'); + }); + + it('cancelAnimationFrame exists', function () { + expect(global).to.respondTo('cancelAnimationFrame'); + }); + + it('requestAnimFrame exists', function () { + expect(global).to.respondTo('requestAnimFrame'); + }); +}); diff --git a/test/unit/pixi/InteractionManager.js b/test/unit/pixi/InteractionManager.js deleted file mode 100644 index ed3001f..0000000 --- a/test/unit/pixi/InteractionManager.js +++ /dev/null @@ -1,10 +0,0 @@ -describe('pixi/InteractionManager', function () { - 'use strict'; - - var expect = chai.expect; - var InteractionManager = PIXI.InteractionManager; - - it('Module exists', function () { - expect(InteractionManager).to.be.a('function'); - }); -}); diff --git a/test/unit/pixi/Pixi.js b/test/unit/pixi/Pixi.js deleted file mode 100644 index 27debc1..0000000 --- a/test/unit/pixi/Pixi.js +++ /dev/null @@ -1,9 +0,0 @@ -describe('pixi/Pixi', function () { - 'use strict'; - - var expect = chai.expect; - - it('Module exists', function () { - expect(global).to.have.property('PIXI').and.to.be.an('object'); - }); -}); diff --git a/test/unit/pixi/core/Circle.js b/test/unit/pixi/core/Circle.js deleted file mode 100644 index fbcfa17..0000000 --- a/test/unit/pixi/core/Circle.js +++ /dev/null @@ -1,21 +0,0 @@ -describe('pixi/core/Circle', function () { - 'use strict'; - - var expect = chai.expect; - var Circle = PIXI.Circle; - - it('Module exists', function () { - expect(Circle).to.be.a('function'); - }); - - it('Confirm new instance', function () { - var obj = new Circle(); - pixi_core_Circle_confirmNewCircle(obj); - }); - - it("getBounds should return Rectangle that bounds the circle", function() { - var obj = new Circle(100, 250, 50); - var bounds = obj.getBounds(); - pixi_core_Circle_isBoundedByRectangle(obj, bounds); - }); -}); diff --git a/test/unit/pixi/core/Ellipse.js b/test/unit/pixi/core/Ellipse.js deleted file mode 100644 index 026b56f..0000000 --- a/test/unit/pixi/core/Ellipse.js +++ /dev/null @@ -1,24 +0,0 @@ -describe('pixi/core/Ellipse', function () { - 'use strict'; - - var expect = chai.expect; - var Ellipse = PIXI.Ellipse; - - it('Module exists', function () { - expect(Ellipse).to.be.a('function'); - }); - - it('Confirm new instance', function () { - var obj = new Ellipse(); - - expect(obj).to.be.an.instanceof(Ellipse); - expect(obj).to.respondTo('clone'); - expect(obj).to.respondTo('contains'); - expect(obj).to.respondTo('getBounds'); - - expect(obj).to.have.property('x', 0); - expect(obj).to.have.property('y', 0); - expect(obj).to.have.property('width', 0); - expect(obj).to.have.property('height', 0); - }); -}); diff --git a/test/unit/pixi/core/Matrix.js b/test/unit/pixi/core/Matrix.js deleted file mode 100644 index da75e2e..0000000 --- a/test/unit/pixi/core/Matrix.js +++ /dev/null @@ -1,14 +0,0 @@ -describe('pixi/core/Matrix', function () { - 'use strict'; - - var expect = chai.expect; - - it('Matrix exists', function () { - expect(PIXI.Matrix).to.be.an('function'); - }); - - it('Confirm new Matrix', function () { - var matrix = new PIXI.Matrix(); - pixi_core_Matrix_confirmNewMatrix(matrix); - }); -}); diff --git a/test/unit/pixi/core/Point.js b/test/unit/pixi/core/Point.js deleted file mode 100644 index c4d5163..0000000 --- a/test/unit/pixi/core/Point.js +++ /dev/null @@ -1,15 +0,0 @@ -describe('pixi/core/Point', function () { - 'use strict'; - - var expect = chai.expect; - var Point = PIXI.Point; - - it('Module exists', function () { - expect(Point).to.be.a('function'); - }); - - it('Confirm new instance', function () { - var obj = new Point(); - pixi_core_Point_confirm(obj, 0, 0); - }); -}); diff --git a/test/unit/pixi/core/Polygon.js b/test/unit/pixi/core/Polygon.js deleted file mode 100644 index dc8c918..0000000 --- a/test/unit/pixi/core/Polygon.js +++ /dev/null @@ -1,20 +0,0 @@ -describe('pixi/core/Polygon', function () { - 'use strict'; - - var expect = chai.expect; - var Polygon = PIXI.Polygon; - - it('Module exists', function () { - expect(Polygon).to.be.a('function'); - }); - - it('Confirm new instance', function () { - var obj = new Polygon(); - - expect(obj).to.be.an.instanceof(Polygon); - expect(obj).to.respondTo('clone'); - expect(obj).to.respondTo('contains'); - - expect(obj).to.have.deep.property('points.length', 0); - }); -}); diff --git a/test/unit/pixi/core/Rectangle.js b/test/unit/pixi/core/Rectangle.js deleted file mode 100644 index d43316e..0000000 --- a/test/unit/pixi/core/Rectangle.js +++ /dev/null @@ -1,15 +0,0 @@ -describe('pixi/core/Rectangle', function () { - 'use strict'; - - var expect = chai.expect; - var Rectangle = PIXI.Rectangle; - - it('Module exists', function () { - expect(Rectangle).to.be.a('function'); - }); - - it('Confirm new instance', function () { - var rect = new Rectangle(); - pixi_core_Rectangle_confirm(rect, 0, 0, 0, 0); - }); -}); diff --git a/test/unit/pixi/display/DisplayObject.js b/test/unit/pixi/display/DisplayObject.js deleted file mode 100644 index 044acf8..0000000 --- a/test/unit/pixi/display/DisplayObject.js +++ /dev/null @@ -1,21 +0,0 @@ -describe('pixi/display/DisplayObject', function () { - 'use strict'; - - var expect = chai.expect; - var DisplayObject = PIXI.DisplayObject; - - it('Module exists', function () { - expect(DisplayObject).to.be.a('function'); - // expect(PIXI).to.have.property('visibleCount', 0); - }); - - it('Confirm new instance', function () { - var obj = new DisplayObject(); - - pixi_display_DisplayObject_confirmNew(obj); - expect(obj).to.have.property('hitArea', null); - expect(obj).to.have.property('interactive', false); - expect(obj).to.have.property('renderable', false); - expect(obj).to.have.property('stage', null); - }); -}); diff --git a/test/unit/pixi/display/DisplayObjectContainer.js b/test/unit/pixi/display/DisplayObjectContainer.js deleted file mode 100644 index 15a3376..0000000 --- a/test/unit/pixi/display/DisplayObjectContainer.js +++ /dev/null @@ -1,67 +0,0 @@ -describe('pixi/display/DisplayObjectContainer', function () { - 'use strict'; - - var expect = chai.expect; - var DisplayObjectContainer = PIXI.DisplayObjectContainer; - - it('Module exists', function () { - expect(DisplayObjectContainer).to.be.a('function'); - }); - - it('Confirm new instance', function () { - var obj = new DisplayObjectContainer(); - - pixi_display_DisplayObjectContainer_confirmNew(obj); - expect(obj).to.have.property('hitArea', null); - expect(obj).to.have.property('interactive', false); - expect(obj).to.have.property('renderable', false); - expect(obj).to.have.property('stage', null); - }); - - it('Gets child index', function() { - var container = new PIXI.DisplayObjectContainer(); - var children = []; - for (var i = 0; i < 10; i++) { - var child = new PIXI.DisplayObject(); - children.push(child); - container.addChild(child); - } - - for (i = 0; i < children.length; i++) { - expect(i).to.eql(container.getChildIndex(children[i])); - } - }); - - it('throws error when trying to get index of not a child', function() { - var container = new PIXI.DisplayObjectContainer(); - var child = new PIXI.DisplayObject(); - - expect(function() { container.getChildIndex(child); }).to.throw(); - }); - - it('Sets child index', function() { - var container = new PIXI.DisplayObjectContainer(); - var children = []; - - for (var i = 0; i < 10; i++) { - var child = new PIXI.DisplayObject(); - children.push(child); - container.addChild(child); - } - children.reverse(); - - for (i = 0; i < children.length; i++) { - container.setChildIndex(children[i], i); - expect(i).to.eql(container.getChildIndex(children[i])); - } - }); - - it('throws error when trying to set incorect index', function() { - var container = new PIXI.DisplayObjectContainer(); - var child = new PIXI.DisplayObject(); - container.addChild(child); - - expect(function() { container.setChildIndex(child, -1); }).to.throw(); - expect(function() { container.setChildIndex(child, 1); }).to.throw(); - }); -}); diff --git a/test/unit/pixi/display/MovieClip.js b/test/unit/pixi/display/MovieClip.js deleted file mode 100644 index f3c6c6a..0000000 --- a/test/unit/pixi/display/MovieClip.js +++ /dev/null @@ -1,33 +0,0 @@ -describe('pixi/display/MovieClip', function () { - 'use strict'; - - var expect = chai.expect; - var MovieClip = PIXI.MovieClip; - var Texture = PIXI.Texture; - - it('Module exists', function () { - expect(MovieClip).to.be.a('function'); - }); - - it('Confirm new instance', function (done) { - var texture = Texture.fromImage('/base/test/textures/SpriteSheet-Explosion.png'); - var obj = new MovieClip([texture]); - - pixi_display_Sprite_confirmNew(obj, done); - - expect(obj).to.be.an.instanceof(MovieClip); - expect(obj).to.respondTo('stop'); - expect(obj).to.respondTo('play'); - expect(obj).to.respondTo('gotoAndStop'); - expect(obj).to.respondTo('gotoAndPlay'); - expect(obj).to.respondTo('updateTransform'); - - expect(obj).to.have.deep.property('textures.length', 1); - expect(obj).to.have.deep.property('textures[0]', texture); - expect(obj).to.have.property('animationSpeed', 1); - expect(obj).to.have.property('loop', true); - expect(obj).to.have.property('onComplete', null); - expect(obj).to.have.property('currentFrame', 0); - expect(obj).to.have.property('playing', false); - }); -}); diff --git a/test/unit/pixi/display/Sprite.js b/test/unit/pixi/display/Sprite.js deleted file mode 100644 index 30c8076..0000000 --- a/test/unit/pixi/display/Sprite.js +++ /dev/null @@ -1,28 +0,0 @@ -describe('pixi/display/Sprite', function () { - 'use strict'; - - var expect = chai.expect; - var Sprite = PIXI.Sprite; - var Texture = PIXI.Texture; - - it('Module exists', function () { - expect(Sprite).to.be.a('function'); - expect(PIXI).to.have.deep.property('blendModes.NORMAL', 0); - expect(PIXI).to.have.deep.property('blendModes.ADD', 1); - expect(PIXI).to.have.deep.property('blendModes.MULTIPLY', 2); - expect(PIXI).to.have.deep.property('blendModes.SCREEN', 3); - }); - - - it('Members exist', function () { - expect(Sprite).itself.to.respondTo('fromImage'); - expect(Sprite).itself.to.respondTo('fromFrame'); - }); - - it('Confirm new instance', function (done) { - var texture = Texture.fromImage('/base/test/textures/SpriteSheet-Aliens.png'); - var obj = new Sprite(texture); - - pixi_display_Sprite_confirmNew(obj, done); - }); -}); diff --git a/test/unit/pixi/display/Stage.js b/test/unit/pixi/display/Stage.js deleted file mode 100644 index 6974c2e..0000000 --- a/test/unit/pixi/display/Stage.js +++ /dev/null @@ -1,49 +0,0 @@ -describe('pixi/display/Stage', function () { - 'use strict'; - - var expect = chai.expect; - var Stage = PIXI.Stage; - var InteractionManager = PIXI.InteractionManager; - var Rectangle = PIXI.Rectangle; - - it('Module exists', function () { - expect(Stage).to.be.a('function'); - }); - - it('Confirm new instance', function () { - var obj = new Stage(null, true); - - pixi_display_DisplayObjectContainer_confirmNew(obj); - - expect(obj).to.be.an.instanceof(Stage); - expect(obj).to.respondTo('updateTransform'); - expect(obj).to.respondTo('setBackgroundColor'); - expect(obj).to.respondTo('getMousePosition'); - // FIXME: duplicate member in DisplayObject - pixi_core_Matrix_confirmNewMatrix(obj.worldTransform); - // FIXME: convert arg to bool in constructor - expect(obj).to.have.property('interactive', true); - - expect(obj).to.have.property('interactionManager') - .and.to.be.an.instanceof(InteractionManager) - .and.to.have.property('stage', obj); - - expect(obj).to.have.property('dirty', true); - - expect(obj).to.have.property('stage', obj); - - expect(obj).to.have.property('hitArea') - .and.to.be.an.instanceof(Rectangle); - pixi_core_Rectangle_confirm(obj.hitArea, 0, 0, 100000, 100000); - - expect(obj).to.have.property('backgroundColor', 0x000000); - expect(obj).to.have.deep.property('backgroundColorSplit.length', 3); - expect(obj).to.have.deep.property('backgroundColorSplit[0]', 0); - expect(obj).to.have.deep.property('backgroundColorSplit[1]', 0); - expect(obj).to.have.deep.property('backgroundColorSplit[2]', 0); - expect(obj).to.have.property('backgroundColorString', '#000000'); - - - expect(obj).to.have.property('worldVisible', true); - }); -}); diff --git a/test/unit/pixi/extras/Rope.js b/test/unit/pixi/extras/Rope.js deleted file mode 100644 index 05885ac..0000000 --- a/test/unit/pixi/extras/Rope.js +++ /dev/null @@ -1,31 +0,0 @@ -describe('pixi/extras/Rope', function () { - 'use strict'; - - var expect = chai.expect; - var Rope = PIXI.Rope; - var Texture = PIXI.Texture; - var Point = PIXI.Point; - - it('Module exists', function () { - expect(Rope).to.be.a('function'); - }); - - it('Confirm new instance', function () { - - var texture = Texture.fromImage('/base/test/textures/bunny.png'); - - // TODO-Alvin - // Same as Strip - - // var obj = new Rope(texture, [new Point(), new Point(5, 10), new Point(10, 20)]); - - // pixi_extras_Strip_confirmNew(obj); - - // expect(obj).to.be.an.instanceof(Rope); - // expect(obj).to.respondTo('refresh'); - // expect(obj).to.respondTo('updateTransform'); - // expect(obj).to.respondTo('setTexture'); - - // TODO: Test properties - }); -}); diff --git a/test/unit/pixi/extras/Spine.js b/test/unit/pixi/extras/Spine.js deleted file mode 100644 index 0708bc0..0000000 --- a/test/unit/pixi/extras/Spine.js +++ /dev/null @@ -1,10 +0,0 @@ -describe('pixi/extras/Spine', function () { - 'use strict'; - - var expect = chai.expect; - var Spine = PIXI.Spine; - - it('Module exists', function () { - expect(Spine).to.be.a('function'); - }); -}); diff --git a/test/unit/pixi/extras/Strip.js b/test/unit/pixi/extras/Strip.js deleted file mode 100644 index 230af90..0000000 --- a/test/unit/pixi/extras/Strip.js +++ /dev/null @@ -1,26 +0,0 @@ -describe('pixi/extras/Strip', function () { - 'use strict'; - - var expect = chai.expect; - var Strip = PIXI.Strip; - var Texture = PIXI.Texture; - - it('Module exists', function () { - expect(Strip).to.be.a('function'); - }); - - it('Confirm new instance', function () { - - - // TODO-Alvin - // We tweaked it to make it pass the tests, but the whole strip class needs - // to be re-coded - - var texture = Texture.fromImage('/base/test/textures/bunny.png'); - - // var obj = new Strip(texture, 20, 10000); - - - // pixi_extras_Strip_confirmNew(obj); - }); -}); diff --git a/test/unit/pixi/extras/TilingSprite.js b/test/unit/pixi/extras/TilingSprite.js deleted file mode 100644 index 56aea14..0000000 --- a/test/unit/pixi/extras/TilingSprite.js +++ /dev/null @@ -1,24 +0,0 @@ -describe('pixi/extras/TilingSprite', function () { - 'use strict'; - - var expect = chai.expect; - var TilingSprite = PIXI.TilingSprite; - var Texture = PIXI.Texture; - - it('Module exists', function () { - expect(TilingSprite).to.be.a('function'); - }); - - it('Confirm new instance', function () { - var texture = Texture.fromImage('/base/test/textures/bunny.png'); - var obj = new TilingSprite(texture, 6000, 12000); - - pixi_display_DisplayObjectContainer_confirmNew(obj); - - expect(obj).to.be.an.instanceof(TilingSprite); - expect(obj).to.respondTo('setTexture'); - expect(obj).to.respondTo('onTextureUpdate'); - - // TODO: Test properties - }); -}); diff --git a/test/unit/pixi/filters/FilterBlock.js b/test/unit/pixi/filters/FilterBlock.js deleted file mode 100644 index 870cec0..0000000 --- a/test/unit/pixi/filters/FilterBlock.js +++ /dev/null @@ -1,10 +0,0 @@ -describe('pixi/filters/FilterBlock', function () { - 'use strict'; - - var expect = chai.expect; - var FilterBlock = PIXI.FilterBlock; - - it('Module exists', function () { - expect(FilterBlock).to.be.a('function'); - }); -}); diff --git a/test/unit/pixi-v2/InteractionManager.js b/test/unit/pixi-v2/InteractionManager.js new file mode 100644 index 0000000..ed3001f --- /dev/null +++ b/test/unit/pixi-v2/InteractionManager.js @@ -0,0 +1,10 @@ +describe('pixi/InteractionManager', function () { + 'use strict'; + + var expect = chai.expect; + var InteractionManager = PIXI.InteractionManager; + + it('Module exists', function () { + expect(InteractionManager).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/Pixi.js b/test/unit/pixi-v2/Pixi.js new file mode 100644 index 0000000..27debc1 --- /dev/null +++ b/test/unit/pixi-v2/Pixi.js @@ -0,0 +1,9 @@ +describe('pixi/Pixi', function () { + 'use strict'; + + var expect = chai.expect; + + it('Module exists', function () { + expect(global).to.have.property('PIXI').and.to.be.an('object'); + }); +}); diff --git a/test/unit/pixi-v2/core/Circle.js b/test/unit/pixi-v2/core/Circle.js new file mode 100644 index 0000000..fbcfa17 --- /dev/null +++ b/test/unit/pixi-v2/core/Circle.js @@ -0,0 +1,21 @@ +describe('pixi/core/Circle', function () { + 'use strict'; + + var expect = chai.expect; + var Circle = PIXI.Circle; + + it('Module exists', function () { + expect(Circle).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Circle(); + pixi_core_Circle_confirmNewCircle(obj); + }); + + it("getBounds should return Rectangle that bounds the circle", function() { + var obj = new Circle(100, 250, 50); + var bounds = obj.getBounds(); + pixi_core_Circle_isBoundedByRectangle(obj, bounds); + }); +}); diff --git a/test/unit/pixi-v2/core/Ellipse.js b/test/unit/pixi-v2/core/Ellipse.js new file mode 100644 index 0000000..026b56f --- /dev/null +++ b/test/unit/pixi-v2/core/Ellipse.js @@ -0,0 +1,24 @@ +describe('pixi/core/Ellipse', function () { + 'use strict'; + + var expect = chai.expect; + var Ellipse = PIXI.Ellipse; + + it('Module exists', function () { + expect(Ellipse).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Ellipse(); + + expect(obj).to.be.an.instanceof(Ellipse); + expect(obj).to.respondTo('clone'); + expect(obj).to.respondTo('contains'); + expect(obj).to.respondTo('getBounds'); + + expect(obj).to.have.property('x', 0); + expect(obj).to.have.property('y', 0); + expect(obj).to.have.property('width', 0); + expect(obj).to.have.property('height', 0); + }); +}); diff --git a/test/unit/pixi-v2/core/Matrix.js b/test/unit/pixi-v2/core/Matrix.js new file mode 100644 index 0000000..da75e2e --- /dev/null +++ b/test/unit/pixi-v2/core/Matrix.js @@ -0,0 +1,14 @@ +describe('pixi/core/Matrix', function () { + 'use strict'; + + var expect = chai.expect; + + it('Matrix exists', function () { + expect(PIXI.Matrix).to.be.an('function'); + }); + + it('Confirm new Matrix', function () { + var matrix = new PIXI.Matrix(); + pixi_core_Matrix_confirmNewMatrix(matrix); + }); +}); diff --git a/test/unit/pixi-v2/core/Point.js b/test/unit/pixi-v2/core/Point.js new file mode 100644 index 0000000..c4d5163 --- /dev/null +++ b/test/unit/pixi-v2/core/Point.js @@ -0,0 +1,15 @@ +describe('pixi/core/Point', function () { + 'use strict'; + + var expect = chai.expect; + var Point = PIXI.Point; + + it('Module exists', function () { + expect(Point).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Point(); + pixi_core_Point_confirm(obj, 0, 0); + }); +}); diff --git a/test/unit/pixi-v2/core/Polygon.js b/test/unit/pixi-v2/core/Polygon.js new file mode 100644 index 0000000..dc8c918 --- /dev/null +++ b/test/unit/pixi-v2/core/Polygon.js @@ -0,0 +1,20 @@ +describe('pixi/core/Polygon', function () { + 'use strict'; + + var expect = chai.expect; + var Polygon = PIXI.Polygon; + + it('Module exists', function () { + expect(Polygon).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Polygon(); + + expect(obj).to.be.an.instanceof(Polygon); + expect(obj).to.respondTo('clone'); + expect(obj).to.respondTo('contains'); + + expect(obj).to.have.deep.property('points.length', 0); + }); +}); diff --git a/test/unit/pixi-v2/core/Rectangle.js b/test/unit/pixi-v2/core/Rectangle.js new file mode 100644 index 0000000..d43316e --- /dev/null +++ b/test/unit/pixi-v2/core/Rectangle.js @@ -0,0 +1,15 @@ +describe('pixi/core/Rectangle', function () { + 'use strict'; + + var expect = chai.expect; + var Rectangle = PIXI.Rectangle; + + it('Module exists', function () { + expect(Rectangle).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var rect = new Rectangle(); + pixi_core_Rectangle_confirm(rect, 0, 0, 0, 0); + }); +}); diff --git a/test/unit/pixi-v2/display/DisplayObject.js b/test/unit/pixi-v2/display/DisplayObject.js new file mode 100644 index 0000000..044acf8 --- /dev/null +++ b/test/unit/pixi-v2/display/DisplayObject.js @@ -0,0 +1,21 @@ +describe('pixi/display/DisplayObject', function () { + 'use strict'; + + var expect = chai.expect; + var DisplayObject = PIXI.DisplayObject; + + it('Module exists', function () { + expect(DisplayObject).to.be.a('function'); + // expect(PIXI).to.have.property('visibleCount', 0); + }); + + it('Confirm new instance', function () { + var obj = new DisplayObject(); + + pixi_display_DisplayObject_confirmNew(obj); + expect(obj).to.have.property('hitArea', null); + expect(obj).to.have.property('interactive', false); + expect(obj).to.have.property('renderable', false); + expect(obj).to.have.property('stage', null); + }); +}); diff --git a/test/unit/pixi-v2/display/DisplayObjectContainer.js b/test/unit/pixi-v2/display/DisplayObjectContainer.js new file mode 100644 index 0000000..15a3376 --- /dev/null +++ b/test/unit/pixi-v2/display/DisplayObjectContainer.js @@ -0,0 +1,67 @@ +describe('pixi/display/DisplayObjectContainer', function () { + 'use strict'; + + var expect = chai.expect; + var DisplayObjectContainer = PIXI.DisplayObjectContainer; + + it('Module exists', function () { + expect(DisplayObjectContainer).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new DisplayObjectContainer(); + + pixi_display_DisplayObjectContainer_confirmNew(obj); + expect(obj).to.have.property('hitArea', null); + expect(obj).to.have.property('interactive', false); + expect(obj).to.have.property('renderable', false); + expect(obj).to.have.property('stage', null); + }); + + it('Gets child index', function() { + var container = new PIXI.DisplayObjectContainer(); + var children = []; + for (var i = 0; i < 10; i++) { + var child = new PIXI.DisplayObject(); + children.push(child); + container.addChild(child); + } + + for (i = 0; i < children.length; i++) { + expect(i).to.eql(container.getChildIndex(children[i])); + } + }); + + it('throws error when trying to get index of not a child', function() { + var container = new PIXI.DisplayObjectContainer(); + var child = new PIXI.DisplayObject(); + + expect(function() { container.getChildIndex(child); }).to.throw(); + }); + + it('Sets child index', function() { + var container = new PIXI.DisplayObjectContainer(); + var children = []; + + for (var i = 0; i < 10; i++) { + var child = new PIXI.DisplayObject(); + children.push(child); + container.addChild(child); + } + children.reverse(); + + for (i = 0; i < children.length; i++) { + container.setChildIndex(children[i], i); + expect(i).to.eql(container.getChildIndex(children[i])); + } + }); + + it('throws error when trying to set incorect index', function() { + var container = new PIXI.DisplayObjectContainer(); + var child = new PIXI.DisplayObject(); + container.addChild(child); + + expect(function() { container.setChildIndex(child, -1); }).to.throw(); + expect(function() { container.setChildIndex(child, 1); }).to.throw(); + }); +}); diff --git a/test/unit/pixi-v2/display/MovieClip.js b/test/unit/pixi-v2/display/MovieClip.js new file mode 100644 index 0000000..f3c6c6a --- /dev/null +++ b/test/unit/pixi-v2/display/MovieClip.js @@ -0,0 +1,33 @@ +describe('pixi/display/MovieClip', function () { + 'use strict'; + + var expect = chai.expect; + var MovieClip = PIXI.MovieClip; + var Texture = PIXI.Texture; + + it('Module exists', function () { + expect(MovieClip).to.be.a('function'); + }); + + it('Confirm new instance', function (done) { + var texture = Texture.fromImage('/base/test/textures/SpriteSheet-Explosion.png'); + var obj = new MovieClip([texture]); + + pixi_display_Sprite_confirmNew(obj, done); + + expect(obj).to.be.an.instanceof(MovieClip); + expect(obj).to.respondTo('stop'); + expect(obj).to.respondTo('play'); + expect(obj).to.respondTo('gotoAndStop'); + expect(obj).to.respondTo('gotoAndPlay'); + expect(obj).to.respondTo('updateTransform'); + + expect(obj).to.have.deep.property('textures.length', 1); + expect(obj).to.have.deep.property('textures[0]', texture); + expect(obj).to.have.property('animationSpeed', 1); + expect(obj).to.have.property('loop', true); + expect(obj).to.have.property('onComplete', null); + expect(obj).to.have.property('currentFrame', 0); + expect(obj).to.have.property('playing', false); + }); +}); diff --git a/test/unit/pixi-v2/display/Sprite.js b/test/unit/pixi-v2/display/Sprite.js new file mode 100644 index 0000000..30c8076 --- /dev/null +++ b/test/unit/pixi-v2/display/Sprite.js @@ -0,0 +1,28 @@ +describe('pixi/display/Sprite', function () { + 'use strict'; + + var expect = chai.expect; + var Sprite = PIXI.Sprite; + var Texture = PIXI.Texture; + + it('Module exists', function () { + expect(Sprite).to.be.a('function'); + expect(PIXI).to.have.deep.property('blendModes.NORMAL', 0); + expect(PIXI).to.have.deep.property('blendModes.ADD', 1); + expect(PIXI).to.have.deep.property('blendModes.MULTIPLY', 2); + expect(PIXI).to.have.deep.property('blendModes.SCREEN', 3); + }); + + + it('Members exist', function () { + expect(Sprite).itself.to.respondTo('fromImage'); + expect(Sprite).itself.to.respondTo('fromFrame'); + }); + + it('Confirm new instance', function (done) { + var texture = Texture.fromImage('/base/test/textures/SpriteSheet-Aliens.png'); + var obj = new Sprite(texture); + + pixi_display_Sprite_confirmNew(obj, done); + }); +}); diff --git a/test/unit/pixi-v2/display/Stage.js b/test/unit/pixi-v2/display/Stage.js new file mode 100644 index 0000000..6974c2e --- /dev/null +++ b/test/unit/pixi-v2/display/Stage.js @@ -0,0 +1,49 @@ +describe('pixi/display/Stage', function () { + 'use strict'; + + var expect = chai.expect; + var Stage = PIXI.Stage; + var InteractionManager = PIXI.InteractionManager; + var Rectangle = PIXI.Rectangle; + + it('Module exists', function () { + expect(Stage).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Stage(null, true); + + pixi_display_DisplayObjectContainer_confirmNew(obj); + + expect(obj).to.be.an.instanceof(Stage); + expect(obj).to.respondTo('updateTransform'); + expect(obj).to.respondTo('setBackgroundColor'); + expect(obj).to.respondTo('getMousePosition'); + // FIXME: duplicate member in DisplayObject + pixi_core_Matrix_confirmNewMatrix(obj.worldTransform); + // FIXME: convert arg to bool in constructor + expect(obj).to.have.property('interactive', true); + + expect(obj).to.have.property('interactionManager') + .and.to.be.an.instanceof(InteractionManager) + .and.to.have.property('stage', obj); + + expect(obj).to.have.property('dirty', true); + + expect(obj).to.have.property('stage', obj); + + expect(obj).to.have.property('hitArea') + .and.to.be.an.instanceof(Rectangle); + pixi_core_Rectangle_confirm(obj.hitArea, 0, 0, 100000, 100000); + + expect(obj).to.have.property('backgroundColor', 0x000000); + expect(obj).to.have.deep.property('backgroundColorSplit.length', 3); + expect(obj).to.have.deep.property('backgroundColorSplit[0]', 0); + expect(obj).to.have.deep.property('backgroundColorSplit[1]', 0); + expect(obj).to.have.deep.property('backgroundColorSplit[2]', 0); + expect(obj).to.have.property('backgroundColorString', '#000000'); + + + expect(obj).to.have.property('worldVisible', true); + }); +}); diff --git a/test/unit/pixi-v2/extras/Rope.js b/test/unit/pixi-v2/extras/Rope.js new file mode 100644 index 0000000..05885ac --- /dev/null +++ b/test/unit/pixi-v2/extras/Rope.js @@ -0,0 +1,31 @@ +describe('pixi/extras/Rope', function () { + 'use strict'; + + var expect = chai.expect; + var Rope = PIXI.Rope; + var Texture = PIXI.Texture; + var Point = PIXI.Point; + + it('Module exists', function () { + expect(Rope).to.be.a('function'); + }); + + it('Confirm new instance', function () { + + var texture = Texture.fromImage('/base/test/textures/bunny.png'); + + // TODO-Alvin + // Same as Strip + + // var obj = new Rope(texture, [new Point(), new Point(5, 10), new Point(10, 20)]); + + // pixi_extras_Strip_confirmNew(obj); + + // expect(obj).to.be.an.instanceof(Rope); + // expect(obj).to.respondTo('refresh'); + // expect(obj).to.respondTo('updateTransform'); + // expect(obj).to.respondTo('setTexture'); + + // TODO: Test properties + }); +}); diff --git a/test/unit/pixi-v2/extras/Spine.js b/test/unit/pixi-v2/extras/Spine.js new file mode 100644 index 0000000..0708bc0 --- /dev/null +++ b/test/unit/pixi-v2/extras/Spine.js @@ -0,0 +1,10 @@ +describe('pixi/extras/Spine', function () { + 'use strict'; + + var expect = chai.expect; + var Spine = PIXI.Spine; + + it('Module exists', function () { + expect(Spine).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/extras/Strip.js b/test/unit/pixi-v2/extras/Strip.js new file mode 100644 index 0000000..230af90 --- /dev/null +++ b/test/unit/pixi-v2/extras/Strip.js @@ -0,0 +1,26 @@ +describe('pixi/extras/Strip', function () { + 'use strict'; + + var expect = chai.expect; + var Strip = PIXI.Strip; + var Texture = PIXI.Texture; + + it('Module exists', function () { + expect(Strip).to.be.a('function'); + }); + + it('Confirm new instance', function () { + + + // TODO-Alvin + // We tweaked it to make it pass the tests, but the whole strip class needs + // to be re-coded + + var texture = Texture.fromImage('/base/test/textures/bunny.png'); + + // var obj = new Strip(texture, 20, 10000); + + + // pixi_extras_Strip_confirmNew(obj); + }); +}); diff --git a/test/unit/pixi-v2/extras/TilingSprite.js b/test/unit/pixi-v2/extras/TilingSprite.js new file mode 100644 index 0000000..56aea14 --- /dev/null +++ b/test/unit/pixi-v2/extras/TilingSprite.js @@ -0,0 +1,24 @@ +describe('pixi/extras/TilingSprite', function () { + 'use strict'; + + var expect = chai.expect; + var TilingSprite = PIXI.TilingSprite; + var Texture = PIXI.Texture; + + it('Module exists', function () { + expect(TilingSprite).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var texture = Texture.fromImage('/base/test/textures/bunny.png'); + var obj = new TilingSprite(texture, 6000, 12000); + + pixi_display_DisplayObjectContainer_confirmNew(obj); + + expect(obj).to.be.an.instanceof(TilingSprite); + expect(obj).to.respondTo('setTexture'); + expect(obj).to.respondTo('onTextureUpdate'); + + // TODO: Test properties + }); +}); diff --git a/test/unit/pixi-v2/filters/FilterBlock.js b/test/unit/pixi-v2/filters/FilterBlock.js new file mode 100644 index 0000000..870cec0 --- /dev/null +++ b/test/unit/pixi-v2/filters/FilterBlock.js @@ -0,0 +1,10 @@ +describe('pixi/filters/FilterBlock', function () { + 'use strict'; + + var expect = chai.expect; + var FilterBlock = PIXI.FilterBlock; + + it('Module exists', function () { + expect(FilterBlock).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/AssetLoader.js b/test/unit/pixi-v2/loaders/AssetLoader.js new file mode 100644 index 0000000..a0aa0b5 --- /dev/null +++ b/test/unit/pixi-v2/loaders/AssetLoader.js @@ -0,0 +1,10 @@ +describe('pixi/loaders/AssetLoader', function () { + 'use strict'; + + var expect = chai.expect; + var AssetLoader = PIXI.AssetLoader; + + it('Module exists', function () { + expect(AssetLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/BitmapFontLoader.js b/test/unit/pixi-v2/loaders/BitmapFontLoader.js new file mode 100644 index 0000000..046f018 --- /dev/null +++ b/test/unit/pixi-v2/loaders/BitmapFontLoader.js @@ -0,0 +1,9 @@ +describe('pixi/loaders/BitmapFontLoader', function () { + 'use strict'; + + var expect = chai.expect; + + it('Module exists', function () { + expect(PIXI.BitmapFontLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/ImageLoader.js b/test/unit/pixi-v2/loaders/ImageLoader.js new file mode 100644 index 0000000..8b1f556 --- /dev/null +++ b/test/unit/pixi-v2/loaders/ImageLoader.js @@ -0,0 +1,10 @@ +describe('pixi/loaders/ImageLoader', function () { + 'use strict'; + + var expect = chai.expect; + var ImageLoader = PIXI.ImageLoader; + + it('Module exists', function () { + expect(ImageLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/JsonLoader.js b/test/unit/pixi-v2/loaders/JsonLoader.js new file mode 100644 index 0000000..c577e83 --- /dev/null +++ b/test/unit/pixi-v2/loaders/JsonLoader.js @@ -0,0 +1,10 @@ +describe('pixi/loaders/JsonLoader', function () { + 'use strict'; + + var expect = chai.expect; + var JsonLoader = PIXI.JsonLoader; + + it('Module exists', function () { + expect(JsonLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/SpineLoader.js b/test/unit/pixi-v2/loaders/SpineLoader.js new file mode 100644 index 0000000..fdcc0b8 --- /dev/null +++ b/test/unit/pixi-v2/loaders/SpineLoader.js @@ -0,0 +1,10 @@ +describe('pixi/loaders/SpineLoader', function () { + 'use strict'; + + var expect = chai.expect; + var SpineLoader = PIXI.SpineLoader; + + it('Module exists', function () { + expect(SpineLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/SpriteSheetLoader.js b/test/unit/pixi-v2/loaders/SpriteSheetLoader.js new file mode 100644 index 0000000..57beb27 --- /dev/null +++ b/test/unit/pixi-v2/loaders/SpriteSheetLoader.js @@ -0,0 +1,10 @@ +describe('pixi/loaders/SpriteSheetLoader', function () { + 'use strict'; + + var expect = chai.expect; + var SpriteSheetLoader = PIXI.SpriteSheetLoader; + + it('Module exists', function () { + expect(SpriteSheetLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/primitives/Graphics.js b/test/unit/pixi-v2/primitives/Graphics.js new file mode 100644 index 0000000..f3849eb --- /dev/null +++ b/test/unit/pixi-v2/primitives/Graphics.js @@ -0,0 +1,44 @@ +describe('pixi/primitives/Graphics', function () { + 'use strict'; + + var expect = chai.expect; + var Graphics = PIXI.Graphics; + + it('Module exists', function () { + expect(Graphics).to.be.a('function'); + + expect(Graphics).itself.to.have.property('POLY', 0); + expect(Graphics).itself.to.have.property('RECT', 1); + expect(Graphics).itself.to.have.property('CIRC', 2); + expect(Graphics).itself.to.have.property('ELIP', 3); + expect(Graphics).itself.to.have.property('RREC', 4); + }); + + it('Confirm new instance', function () { + var obj = new Graphics(); + + pixi_display_DisplayObjectContainer_confirmNew(obj); + + expect(obj).to.be.an.instanceof(Graphics); + expect(obj).to.respondTo('lineStyle'); + expect(obj).to.respondTo('lineStyle'); + expect(obj).to.respondTo('moveTo'); + expect(obj).to.respondTo('lineTo'); + expect(obj).to.respondTo('beginFill'); + expect(obj).to.respondTo('endFill'); + expect(obj).to.respondTo('drawRect'); + // expect(obj).to.respondTo('drawRoundedRect'); + expect(obj).to.respondTo('drawCircle'); + expect(obj).to.respondTo('drawEllipse'); + expect(obj).to.respondTo('clear'); + + expect(obj).to.have.property('renderable', true); + expect(obj).to.have.property('fillAlpha', 1); + expect(obj).to.have.property('lineWidth', 0); + expect(obj).to.have.property('width', 0); + expect(obj).to.have.property('height', 0); + expect(obj).to.have.property('lineColor', 0); + expect(obj).to.have.deep.property('graphicsData.length', 0); + // expect(obj).to.have.deep.property('currentPath.points.length', 0); + }); +}); diff --git a/test/unit/pixi-v2/renderers/canvas/CanvasGraphics.js b/test/unit/pixi-v2/renderers/canvas/CanvasGraphics.js new file mode 100644 index 0000000..8f44472 --- /dev/null +++ b/test/unit/pixi-v2/renderers/canvas/CanvasGraphics.js @@ -0,0 +1,15 @@ +describe('renders/canvas/CanvasGraphics', function () { + 'use strict'; + + var expect = chai.expect; + var CanvasGraphics = PIXI.CanvasGraphics; + + it('Module exists', function () { + expect(CanvasGraphics).to.be.a('function'); + }); + + it('Members exist', function () { + expect(CanvasGraphics).itself.to.respondTo('renderGraphics'); + expect(CanvasGraphics).itself.to.respondTo('renderGraphicsMask'); + }); +}); diff --git a/test/unit/pixi-v2/renderers/canvas/CanvasRenderer.js b/test/unit/pixi-v2/renderers/canvas/CanvasRenderer.js new file mode 100644 index 0000000..1646444 --- /dev/null +++ b/test/unit/pixi-v2/renderers/canvas/CanvasRenderer.js @@ -0,0 +1,36 @@ +describe('renderers/canvas/CanvasRenderer', function () { + 'use strict'; + + var expect = chai.expect; + var CanvasRenderer = PIXI.CanvasRenderer; + + it('Module exists', function () { + expect(CanvasRenderer).to.be.a('function'); + }); + + describe('.autoResize', function () { + it('Should automatically resize view if enabled', function () { + var renderer = new CanvasRenderer(200, 200, { + autoResize: true + }); + + expect(renderer.view.style.width).to.equal('200px'); + }); + + it('Should not automatically resize view if disabled', function () { + var renderer = new CanvasRenderer(200, 200, { + autoResize: false + }); + + expect(renderer.view.style.width).to.equal(''); + }); + + it('Should not automatically resize view if not specified', function () { + var renderer = new CanvasRenderer(200, 200, { + resolution: 2 + }); + + expect(renderer.view.style.width).to.equal(''); + }); + }); +}); diff --git a/test/unit/pixi-v2/renderers/webgl/WebGLGraphics.js b/test/unit/pixi-v2/renderers/webgl/WebGLGraphics.js new file mode 100644 index 0000000..5867b28 --- /dev/null +++ b/test/unit/pixi-v2/renderers/webgl/WebGLGraphics.js @@ -0,0 +1,20 @@ +describe('renderers/wegbl/WebGLGraphics', function () { + 'use strict'; + + var expect = chai.expect; + var WebGLGraphics = PIXI.WebGLGraphics; + + it('Module exists', function () { + expect(WebGLGraphics).to.be.a('function'); + }); + + it('Members exist', function () { + expect(WebGLGraphics).itself.to.respondTo('renderGraphics'); + expect(WebGLGraphics).itself.to.respondTo('updateGraphics'); + expect(WebGLGraphics).itself.to.respondTo('buildRectangle'); + expect(WebGLGraphics).itself.to.respondTo('buildRoundedRectangle'); + expect(WebGLGraphics).itself.to.respondTo('buildCircle'); + expect(WebGLGraphics).itself.to.respondTo('buildLine'); + expect(WebGLGraphics).itself.to.respondTo('buildPoly'); + }); +}); diff --git a/test/unit/pixi-v2/renderers/webgl/WebGLRenderer.js b/test/unit/pixi-v2/renderers/webgl/WebGLRenderer.js new file mode 100644 index 0000000..1680a80 --- /dev/null +++ b/test/unit/pixi-v2/renderers/webgl/WebGLRenderer.js @@ -0,0 +1,49 @@ +describe('renderers/webgl/WebGLRenderer', function () { + 'use strict'; + + var expect = chai.expect; + var WebGLRenderer = PIXI.WebGLRenderer; + + it('Module exists', function () { + expect(WebGLRenderer).to.be.a('function'); + }); + + // Skip tests if WebGL is not available (WebGL not supported in Travis CI) + try { + var renderer = new WebGLRenderer(400, 300, {}); + renderer.destroy(); + } catch (error) { + return; + } + + it('Destroy renderer', function () { + var renderer = new WebGLRenderer(400, 300, {}); + renderer.destroy(); + }); + + describe('.autoResize', function () { + it('Should automatically resize view if enabled', function () { + var renderer = new WebGLRenderer(200, 200, { + autoResize: true + }); + + expect(renderer.view.style.width).to.equal('200px'); + }); + + it('Should not automatically resize view if disabled', function () { + var renderer = new WebGLRenderer(200, 200, { + autoResize: false + }); + + expect(renderer.view.style.width).to.equal(''); + }); + + it('Should not automatically resize view if not specified', function () { + var renderer = new WebGLRenderer(200, 200, { + resolution: 2 + }); + + expect(renderer.view.style.width).to.equal(''); + }); + }); +}); diff --git a/test/unit/pixi-v2/renderers/webgl/WebGLShaders.js b/test/unit/pixi-v2/renderers/webgl/WebGLShaders.js new file mode 100644 index 0000000..6e33e4f --- /dev/null +++ b/test/unit/pixi-v2/renderers/webgl/WebGLShaders.js @@ -0,0 +1,13 @@ +describe('renderers/webgl/WebGLShaders', function () { + 'use strict'; + + var expect = chai.expect; + + it('Module members exist', function () { + + expect(PIXI).to.respondTo('CompileVertexShader'); + expect(PIXI).to.respondTo('CompileFragmentShader'); + expect(PIXI).to.respondTo('_CompileShader'); + expect(PIXI).to.respondTo('compileProgram'); + }); +}); diff --git a/test/unit/pixi-v2/renderers/webgl/WebGLSpriteBatch.js b/test/unit/pixi-v2/renderers/webgl/WebGLSpriteBatch.js new file mode 100644 index 0000000..e662b63 --- /dev/null +++ b/test/unit/pixi-v2/renderers/webgl/WebGLSpriteBatch.js @@ -0,0 +1,10 @@ +describe('renderers/webgl/utils/WebGLSpriteBatch', function () { + 'use strict'; + + var expect = chai.expect; + var WebGLSpriteBatch = PIXI.WebGLSpriteBatch; + + it('Module exists', function () { + expect(WebGLSpriteBatch).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/text/BitmapText.js b/test/unit/pixi-v2/text/BitmapText.js new file mode 100644 index 0000000..9388e3d --- /dev/null +++ b/test/unit/pixi-v2/text/BitmapText.js @@ -0,0 +1,10 @@ +describe('pixi/text/BitmapText', function () { + 'use strict'; + + var expect = chai.expect; + var BitmapText = PIXI.BitmapText; + + it('Module exists', function () { + expect(BitmapText).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/text/Text.js b/test/unit/pixi-v2/text/Text.js new file mode 100644 index 0000000..9bc9ac5 --- /dev/null +++ b/test/unit/pixi-v2/text/Text.js @@ -0,0 +1,10 @@ +describe('pixi/text/Text', function () { + 'use strict'; + + var expect = chai.expect; + var Text = PIXI.Text; + + it('Module exists', function () { + expect(Text).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/textures/BaseTexture.js b/test/unit/pixi-v2/textures/BaseTexture.js new file mode 100644 index 0000000..502b724 --- /dev/null +++ b/test/unit/pixi-v2/textures/BaseTexture.js @@ -0,0 +1,11 @@ +describe('pixi/textures/BaseTexture', function () { + 'use strict'; + + var expect = chai.expect; + var BaseTexture = PIXI.BaseTexture; + + it('Module exists', function () { + expect(BaseTexture).to.be.a('function'); + expect(PIXI).to.have.property('BaseTextureCache').and.to.be.an('object'); + }); +}); diff --git a/test/unit/pixi-v2/textures/RenderTexture.js b/test/unit/pixi-v2/textures/RenderTexture.js new file mode 100644 index 0000000..96acdb4 --- /dev/null +++ b/test/unit/pixi-v2/textures/RenderTexture.js @@ -0,0 +1,15 @@ +describe('pixi/textures/RenderTexture', function () { + 'use strict'; + + var expect = chai.expect; + var RenderTexture = PIXI.RenderTexture; + + it('Module exists', function () { + expect(RenderTexture).to.be.a('function'); + }); + + it('Confirm new instance', function (done) { + var texture = new RenderTexture(100, 100, new PIXI.CanvasRenderer()); + pixi_textures_RenderTexture_confirmNew(texture, done); + }); +}); diff --git a/test/unit/pixi-v2/textures/Texture.js b/test/unit/pixi-v2/textures/Texture.js new file mode 100644 index 0000000..090f64d --- /dev/null +++ b/test/unit/pixi-v2/textures/Texture.js @@ -0,0 +1,26 @@ +describe('pixi/textures/Texture', function () { + 'use strict'; + + var expect = chai.expect; + var Texture = PIXI.Texture; + + it('Module exists', function () { + expect(Texture).to.be.a('function'); + expect(PIXI).to.have.property('TextureCache').and.to.be.an('object'); + }); + + it('Members exist', function () { + expect(Texture).itself.to.respondTo('fromImage'); + expect(Texture).itself.to.respondTo('fromFrame'); + expect(Texture).itself.to.respondTo('fromCanvas'); + expect(Texture).itself.to.respondTo('addTextureToCache'); + expect(Texture).itself.to.respondTo('removeTextureFromCache'); + + // expect(Texture).itself.to.have.deep.property('frameUpdates.length', 0); + }); + + it('Confirm new instance', function (done) { + var texture = Texture.fromImage('/base/test/textures/bunny.png'); + pixi_textures_Texture_confirmNew(texture, done); + }); +}); diff --git a/test/unit/pixi-v2/utils/Detector.js b/test/unit/pixi-v2/utils/Detector.js new file mode 100644 index 0000000..4cf6008 --- /dev/null +++ b/test/unit/pixi-v2/utils/Detector.js @@ -0,0 +1,10 @@ +describe('pixi/utils/Detector', function () { + 'use strict'; + + var expect = chai.expect; + var autoDetectRenderer = PIXI.autoDetectRenderer; + + it('Module exists', function () { + expect(autoDetectRenderer).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/utils/EventTarget.js b/test/unit/pixi-v2/utils/EventTarget.js new file mode 100644 index 0000000..1cfc3a4 --- /dev/null +++ b/test/unit/pixi-v2/utils/EventTarget.js @@ -0,0 +1,361 @@ +describe('pixi/utils/EventTarget', function () { + 'use strict'; + + var expect = chai.expect; + + var Clazz, PClazz, obj, pobj, obj2; + beforeEach(function () { + Clazz = function () {}; + PClazz = function () {}; + + PIXI.EventTarget.mixin(Clazz.prototype); + PIXI.EventTarget.mixin(PClazz.prototype); + + obj = new Clazz(); + obj2 = new Clazz(); + pobj = new PClazz(); + + obj.parent = pobj; + obj2.parent = obj; + }); + + it('Module exists', function () { + expect(PIXI.EventTarget).to.be.an('object'); + }); + + it('Confirm new instance', function () { + pixi_utils_EventTarget_confirm(obj); + }); + + it('simple on/emit case works', function () { + var myData = {}; + + obj.on('myevent', function (event) { + pixi_utils_EventTarget_Event_confirm(event, obj, myData); + }); + + obj.emit('myevent', myData); + }); + + it('simple once case works', function () { + var called = 0; + + obj.once('myevent', function() { called++; }); + + obj.emit('myevent'); + obj.emit('myevent'); + obj.emit('myevent'); + obj.emit('myevent'); + obj.emit('myevent'); + + expect(called).to.equal(1); + }); + + it('simple off case works', function (done) { + function onMyEvent() { + done(new Error('Event listener should not have been called')); + } + + obj.on('myevent', onMyEvent); + obj.off('myevent', onMyEvent); + obj.emit('myevent'); + + done(); + }); + + it('simple propagation case works', function (done) { + var myData = {}; + + pobj.on('myevent', function () { + done(); + }); + + obj.emit('myevent'); + }); + + it('simple stopPropagation case works', function (done) { + var myData = {}; + + pobj.on('myevent', function () { + done(new Error('Event listener should not have been called on the parent element')); + }); + + obj.on('myevent', function (evt) { + evt.stopPropagation(); + }); + + obj.emit('myevent'); + + done(); + }); + + it('simple stopImmediatePropagation case works', function (done) { + var myData = {}; + + pobj.on('myevent', function () { + done(new Error('Event listener should not have been called on the parent')); + }); + + obj.on('myevent', function (evt) { + evt.stopImmediatePropagation(); + }); + + obj.on('myevent', function () { + done(new Error('Event listener should not have been called on the second')); + }); + + obj.emit('myevent'); + + done(); + }); + + it('multiple dispatches work properly', function () { + var called = 0; + + function onMyEvent() { + called++; + } + + obj.on('myevent', onMyEvent); + obj.emit('myevent'); + obj.emit('myevent'); + obj.emit('myevent'); + obj.emit('myevent'); + + expect(called).to.equal(4); + }); + + it('multiple events work properly', function () { + var called = 0; + + function onMyEvent() { + called++; + } + + obj.on('myevent1', onMyEvent); + obj.on('myevent2', onMyEvent); + obj.on('myevent3', onMyEvent); + obj.emit('myevent1'); + obj.emit('myevent2'); + obj.emit('myevent3'); + + expect(called).to.equal(3); + }); + + it('multiple events one removed works properly', function () { + var called = 0; + + function onMyEvent() { + called++; + } + + obj.on('myevent1', onMyEvent); + obj.on('myevent2', onMyEvent); + obj.on('myevent3', onMyEvent); + + obj.emit('myevent1'); + obj.emit('myevent2'); + obj.emit('myevent3'); + + obj.off('myevent2', onMyEvent); + + obj.emit('myevent1'); + obj.emit('myevent2'); + obj.emit('myevent3'); + + expect(called).to.equal(5); + }); + + it('multiple handlers for one event with some removed', function () { + var called = 0; + + var onMyEvent = function () { + called++; + }, + onMyEvent2 = function () { + called++; + }; + + // add 2 handlers and confirm they both get called + obj.on('myevent', onMyEvent); + obj.on('myevent', onMyEvent); + obj.on('myevent', onMyEvent2); + obj.on('myevent', onMyEvent2); + + obj.emit('myevent'); + + expect(called).to.equal(4); + + // remove one of the handlers, emit again, then ensure 1 more call is made + obj.off('myevent', onMyEvent); + + obj.emit('myevent'); + + expect(called).to.equal(6); + }); + + it('calls to off without a handler do nothing', function () { + var called = 0; + + var onMyEvent = function () { + called++; + }; + + obj.on('myevent', onMyEvent); + obj.on('myevent', onMyEvent); + + obj.emit('myevent'); + + expect(called).to.equal(2); + + obj.off('myevent'); + + obj.emit('myevent'); + + expect(called).to.equal(4); + + obj.off('myevent', onMyEvent); + + obj.emit('myevent'); + + expect(called).to.equal(4); + }); + + it('handles multiple instances with the same prototype', function () { + var called = 0; + + function onMyEvent(e) { + called++; + } + + obj.on('myevent1', onMyEvent); + obj.on('myevent2', onMyEvent); + + obj2.istwo = true; + obj2.on('myevent1', onMyEvent); + obj2.on('myevent2', onMyEvent); + + obj.emit('myevent1'); + obj.emit('myevent2'); + obj2.emit('myevent1'); + obj2.emit('myevent2'); + + //we emit 4 times, but since obj2 is a child of obj the event should bubble + //up to obj and show up there as well. So the obj2.emit() calls each increment + //the counter twice. + expect(called).to.equal(6); + }); + + it('is backwards compatible with older .dispatchEvent({})', function () { + var called = 0, + data = { + some: 'thing', + hello: true + }; + + function onMyEvent(event) { + pixi_utils_EventTarget_Event_confirm(event, obj, data); + + called++; + } + + obj.on('myevent1', onMyEvent); + obj.on('myevent2', onMyEvent); + obj.on('myevent3', onMyEvent); + + data.type = 'myevent1'; + obj.emit(data); + + data.type = 'myevent2'; + obj.emit(data); + + data.type = 'myevent3'; + obj.emit(data); + + obj.off('myevent2', onMyEvent); + + data.type = 'myevent1'; + obj.emit(data); + + data.type = 'myevent2'; + obj.emit(data); + + data.type = 'myevent3'; + obj.emit(data); + + expect(called).to.equal(5); + }); + + it('is backwards compatible with older .call(this)', function () { + var Fn = function() { + PIXI.EventTarget.call(this); + }, + o = new Fn(); + + pixi_utils_EventTarget_confirm(o); + }); + + it('is backwards compatible with older .addEventListener("")', function () { + var called = 0, + data = { + some: 'thing', + hello: true + }; + + function onMyEvent(event) { + pixi_utils_EventTarget_Event_confirm(event, obj, data); + + called++; + } + + obj.addEventListener('myevent1', onMyEvent); + obj.addEventListener('myevent2', onMyEvent); + obj.addEventListener('myevent3', onMyEvent); + + data.type = 'myevent1'; + obj.emit(data); + + data.type = 'myevent2'; + obj.emit(data); + + data.type = 'myevent3'; + obj.emit(data); + + obj.off('myevent2', onMyEvent); + + data.type = 'myevent1'; + obj.emit(data); + + data.type = 'myevent2'; + obj.emit(data); + + data.type = 'myevent3'; + obj.emit(data); + + expect(called).to.equal(5); + }); + + it('event remove during emit call properly', function () { + var called = 0; + + function cb1() { + called++; + obj.off('myevent', cb1); + } + function cb2() { + called++; + obj.off('myevent', cb2); + } + function cb3() { + called++; + obj.off('myevent', cb3); + } + + obj.on('myevent', cb1); + obj.on('myevent', cb2); + obj.on('myevent', cb3); + obj.emit('myevent', ''); + + expect(called).to.equal(3); + }); +}); diff --git a/test/unit/pixi-v2/utils/Polyk.js b/test/unit/pixi-v2/utils/Polyk.js new file mode 100644 index 0000000..dfc7128 --- /dev/null +++ b/test/unit/pixi-v2/utils/Polyk.js @@ -0,0 +1,14 @@ +describe('pixi/utils/Polyk', function () { + 'use strict'; + + var expect = chai.expect; + var PolyK = PIXI.PolyK; + + it('Module exists', function () { + expect(PolyK).to.be.an('object'); + }); + + it('Members exist', function () { + expect(PolyK).to.respondTo('Triangulate'); + }); +}); diff --git a/test/unit/pixi-v2/utils/Utils.js b/test/unit/pixi-v2/utils/Utils.js new file mode 100644 index 0000000..c97b3c6 --- /dev/null +++ b/test/unit/pixi-v2/utils/Utils.js @@ -0,0 +1,17 @@ +describe('Utils', function () { + 'use strict'; + + var expect = chai.expect; + + it('requestAnimationFrame exists', function () { + expect(global).to.respondTo('requestAnimationFrame'); + }); + + it('cancelAnimationFrame exists', function () { + expect(global).to.respondTo('cancelAnimationFrame'); + }); + + it('requestAnimFrame exists', function () { + expect(global).to.respondTo('requestAnimFrame'); + }); +}); diff --git a/test/unit/pixi/InteractionManager.js b/test/unit/pixi/InteractionManager.js deleted file mode 100644 index ed3001f..0000000 --- a/test/unit/pixi/InteractionManager.js +++ /dev/null @@ -1,10 +0,0 @@ -describe('pixi/InteractionManager', function () { - 'use strict'; - - var expect = chai.expect; - var InteractionManager = PIXI.InteractionManager; - - it('Module exists', function () { - expect(InteractionManager).to.be.a('function'); - }); -}); diff --git a/test/unit/pixi/Pixi.js b/test/unit/pixi/Pixi.js deleted file mode 100644 index 27debc1..0000000 --- a/test/unit/pixi/Pixi.js +++ /dev/null @@ -1,9 +0,0 @@ -describe('pixi/Pixi', function () { - 'use strict'; - - var expect = chai.expect; - - it('Module exists', function () { - expect(global).to.have.property('PIXI').and.to.be.an('object'); - }); -}); diff --git a/test/unit/pixi/core/Circle.js b/test/unit/pixi/core/Circle.js deleted file mode 100644 index fbcfa17..0000000 --- a/test/unit/pixi/core/Circle.js +++ /dev/null @@ -1,21 +0,0 @@ -describe('pixi/core/Circle', function () { - 'use strict'; - - var expect = chai.expect; - var Circle = PIXI.Circle; - - it('Module exists', function () { - expect(Circle).to.be.a('function'); - }); - - it('Confirm new instance', function () { - var obj = new Circle(); - pixi_core_Circle_confirmNewCircle(obj); - }); - - it("getBounds should return Rectangle that bounds the circle", function() { - var obj = new Circle(100, 250, 50); - var bounds = obj.getBounds(); - pixi_core_Circle_isBoundedByRectangle(obj, bounds); - }); -}); diff --git a/test/unit/pixi/core/Ellipse.js b/test/unit/pixi/core/Ellipse.js deleted file mode 100644 index 026b56f..0000000 --- a/test/unit/pixi/core/Ellipse.js +++ /dev/null @@ -1,24 +0,0 @@ -describe('pixi/core/Ellipse', function () { - 'use strict'; - - var expect = chai.expect; - var Ellipse = PIXI.Ellipse; - - it('Module exists', function () { - expect(Ellipse).to.be.a('function'); - }); - - it('Confirm new instance', function () { - var obj = new Ellipse(); - - expect(obj).to.be.an.instanceof(Ellipse); - expect(obj).to.respondTo('clone'); - expect(obj).to.respondTo('contains'); - expect(obj).to.respondTo('getBounds'); - - expect(obj).to.have.property('x', 0); - expect(obj).to.have.property('y', 0); - expect(obj).to.have.property('width', 0); - expect(obj).to.have.property('height', 0); - }); -}); diff --git a/test/unit/pixi/core/Matrix.js b/test/unit/pixi/core/Matrix.js deleted file mode 100644 index da75e2e..0000000 --- a/test/unit/pixi/core/Matrix.js +++ /dev/null @@ -1,14 +0,0 @@ -describe('pixi/core/Matrix', function () { - 'use strict'; - - var expect = chai.expect; - - it('Matrix exists', function () { - expect(PIXI.Matrix).to.be.an('function'); - }); - - it('Confirm new Matrix', function () { - var matrix = new PIXI.Matrix(); - pixi_core_Matrix_confirmNewMatrix(matrix); - }); -}); diff --git a/test/unit/pixi/core/Point.js b/test/unit/pixi/core/Point.js deleted file mode 100644 index c4d5163..0000000 --- a/test/unit/pixi/core/Point.js +++ /dev/null @@ -1,15 +0,0 @@ -describe('pixi/core/Point', function () { - 'use strict'; - - var expect = chai.expect; - var Point = PIXI.Point; - - it('Module exists', function () { - expect(Point).to.be.a('function'); - }); - - it('Confirm new instance', function () { - var obj = new Point(); - pixi_core_Point_confirm(obj, 0, 0); - }); -}); diff --git a/test/unit/pixi/core/Polygon.js b/test/unit/pixi/core/Polygon.js deleted file mode 100644 index dc8c918..0000000 --- a/test/unit/pixi/core/Polygon.js +++ /dev/null @@ -1,20 +0,0 @@ -describe('pixi/core/Polygon', function () { - 'use strict'; - - var expect = chai.expect; - var Polygon = PIXI.Polygon; - - it('Module exists', function () { - expect(Polygon).to.be.a('function'); - }); - - it('Confirm new instance', function () { - var obj = new Polygon(); - - expect(obj).to.be.an.instanceof(Polygon); - expect(obj).to.respondTo('clone'); - expect(obj).to.respondTo('contains'); - - expect(obj).to.have.deep.property('points.length', 0); - }); -}); diff --git a/test/unit/pixi/core/Rectangle.js b/test/unit/pixi/core/Rectangle.js deleted file mode 100644 index d43316e..0000000 --- a/test/unit/pixi/core/Rectangle.js +++ /dev/null @@ -1,15 +0,0 @@ -describe('pixi/core/Rectangle', function () { - 'use strict'; - - var expect = chai.expect; - var Rectangle = PIXI.Rectangle; - - it('Module exists', function () { - expect(Rectangle).to.be.a('function'); - }); - - it('Confirm new instance', function () { - var rect = new Rectangle(); - pixi_core_Rectangle_confirm(rect, 0, 0, 0, 0); - }); -}); diff --git a/test/unit/pixi/display/DisplayObject.js b/test/unit/pixi/display/DisplayObject.js deleted file mode 100644 index 044acf8..0000000 --- a/test/unit/pixi/display/DisplayObject.js +++ /dev/null @@ -1,21 +0,0 @@ -describe('pixi/display/DisplayObject', function () { - 'use strict'; - - var expect = chai.expect; - var DisplayObject = PIXI.DisplayObject; - - it('Module exists', function () { - expect(DisplayObject).to.be.a('function'); - // expect(PIXI).to.have.property('visibleCount', 0); - }); - - it('Confirm new instance', function () { - var obj = new DisplayObject(); - - pixi_display_DisplayObject_confirmNew(obj); - expect(obj).to.have.property('hitArea', null); - expect(obj).to.have.property('interactive', false); - expect(obj).to.have.property('renderable', false); - expect(obj).to.have.property('stage', null); - }); -}); diff --git a/test/unit/pixi/display/DisplayObjectContainer.js b/test/unit/pixi/display/DisplayObjectContainer.js deleted file mode 100644 index 15a3376..0000000 --- a/test/unit/pixi/display/DisplayObjectContainer.js +++ /dev/null @@ -1,67 +0,0 @@ -describe('pixi/display/DisplayObjectContainer', function () { - 'use strict'; - - var expect = chai.expect; - var DisplayObjectContainer = PIXI.DisplayObjectContainer; - - it('Module exists', function () { - expect(DisplayObjectContainer).to.be.a('function'); - }); - - it('Confirm new instance', function () { - var obj = new DisplayObjectContainer(); - - pixi_display_DisplayObjectContainer_confirmNew(obj); - expect(obj).to.have.property('hitArea', null); - expect(obj).to.have.property('interactive', false); - expect(obj).to.have.property('renderable', false); - expect(obj).to.have.property('stage', null); - }); - - it('Gets child index', function() { - var container = new PIXI.DisplayObjectContainer(); - var children = []; - for (var i = 0; i < 10; i++) { - var child = new PIXI.DisplayObject(); - children.push(child); - container.addChild(child); - } - - for (i = 0; i < children.length; i++) { - expect(i).to.eql(container.getChildIndex(children[i])); - } - }); - - it('throws error when trying to get index of not a child', function() { - var container = new PIXI.DisplayObjectContainer(); - var child = new PIXI.DisplayObject(); - - expect(function() { container.getChildIndex(child); }).to.throw(); - }); - - it('Sets child index', function() { - var container = new PIXI.DisplayObjectContainer(); - var children = []; - - for (var i = 0; i < 10; i++) { - var child = new PIXI.DisplayObject(); - children.push(child); - container.addChild(child); - } - children.reverse(); - - for (i = 0; i < children.length; i++) { - container.setChildIndex(children[i], i); - expect(i).to.eql(container.getChildIndex(children[i])); - } - }); - - it('throws error when trying to set incorect index', function() { - var container = new PIXI.DisplayObjectContainer(); - var child = new PIXI.DisplayObject(); - container.addChild(child); - - expect(function() { container.setChildIndex(child, -1); }).to.throw(); - expect(function() { container.setChildIndex(child, 1); }).to.throw(); - }); -}); diff --git a/test/unit/pixi/display/MovieClip.js b/test/unit/pixi/display/MovieClip.js deleted file mode 100644 index f3c6c6a..0000000 --- a/test/unit/pixi/display/MovieClip.js +++ /dev/null @@ -1,33 +0,0 @@ -describe('pixi/display/MovieClip', function () { - 'use strict'; - - var expect = chai.expect; - var MovieClip = PIXI.MovieClip; - var Texture = PIXI.Texture; - - it('Module exists', function () { - expect(MovieClip).to.be.a('function'); - }); - - it('Confirm new instance', function (done) { - var texture = Texture.fromImage('/base/test/textures/SpriteSheet-Explosion.png'); - var obj = new MovieClip([texture]); - - pixi_display_Sprite_confirmNew(obj, done); - - expect(obj).to.be.an.instanceof(MovieClip); - expect(obj).to.respondTo('stop'); - expect(obj).to.respondTo('play'); - expect(obj).to.respondTo('gotoAndStop'); - expect(obj).to.respondTo('gotoAndPlay'); - expect(obj).to.respondTo('updateTransform'); - - expect(obj).to.have.deep.property('textures.length', 1); - expect(obj).to.have.deep.property('textures[0]', texture); - expect(obj).to.have.property('animationSpeed', 1); - expect(obj).to.have.property('loop', true); - expect(obj).to.have.property('onComplete', null); - expect(obj).to.have.property('currentFrame', 0); - expect(obj).to.have.property('playing', false); - }); -}); diff --git a/test/unit/pixi/display/Sprite.js b/test/unit/pixi/display/Sprite.js deleted file mode 100644 index 30c8076..0000000 --- a/test/unit/pixi/display/Sprite.js +++ /dev/null @@ -1,28 +0,0 @@ -describe('pixi/display/Sprite', function () { - 'use strict'; - - var expect = chai.expect; - var Sprite = PIXI.Sprite; - var Texture = PIXI.Texture; - - it('Module exists', function () { - expect(Sprite).to.be.a('function'); - expect(PIXI).to.have.deep.property('blendModes.NORMAL', 0); - expect(PIXI).to.have.deep.property('blendModes.ADD', 1); - expect(PIXI).to.have.deep.property('blendModes.MULTIPLY', 2); - expect(PIXI).to.have.deep.property('blendModes.SCREEN', 3); - }); - - - it('Members exist', function () { - expect(Sprite).itself.to.respondTo('fromImage'); - expect(Sprite).itself.to.respondTo('fromFrame'); - }); - - it('Confirm new instance', function (done) { - var texture = Texture.fromImage('/base/test/textures/SpriteSheet-Aliens.png'); - var obj = new Sprite(texture); - - pixi_display_Sprite_confirmNew(obj, done); - }); -}); diff --git a/test/unit/pixi/display/Stage.js b/test/unit/pixi/display/Stage.js deleted file mode 100644 index 6974c2e..0000000 --- a/test/unit/pixi/display/Stage.js +++ /dev/null @@ -1,49 +0,0 @@ -describe('pixi/display/Stage', function () { - 'use strict'; - - var expect = chai.expect; - var Stage = PIXI.Stage; - var InteractionManager = PIXI.InteractionManager; - var Rectangle = PIXI.Rectangle; - - it('Module exists', function () { - expect(Stage).to.be.a('function'); - }); - - it('Confirm new instance', function () { - var obj = new Stage(null, true); - - pixi_display_DisplayObjectContainer_confirmNew(obj); - - expect(obj).to.be.an.instanceof(Stage); - expect(obj).to.respondTo('updateTransform'); - expect(obj).to.respondTo('setBackgroundColor'); - expect(obj).to.respondTo('getMousePosition'); - // FIXME: duplicate member in DisplayObject - pixi_core_Matrix_confirmNewMatrix(obj.worldTransform); - // FIXME: convert arg to bool in constructor - expect(obj).to.have.property('interactive', true); - - expect(obj).to.have.property('interactionManager') - .and.to.be.an.instanceof(InteractionManager) - .and.to.have.property('stage', obj); - - expect(obj).to.have.property('dirty', true); - - expect(obj).to.have.property('stage', obj); - - expect(obj).to.have.property('hitArea') - .and.to.be.an.instanceof(Rectangle); - pixi_core_Rectangle_confirm(obj.hitArea, 0, 0, 100000, 100000); - - expect(obj).to.have.property('backgroundColor', 0x000000); - expect(obj).to.have.deep.property('backgroundColorSplit.length', 3); - expect(obj).to.have.deep.property('backgroundColorSplit[0]', 0); - expect(obj).to.have.deep.property('backgroundColorSplit[1]', 0); - expect(obj).to.have.deep.property('backgroundColorSplit[2]', 0); - expect(obj).to.have.property('backgroundColorString', '#000000'); - - - expect(obj).to.have.property('worldVisible', true); - }); -}); diff --git a/test/unit/pixi/extras/Rope.js b/test/unit/pixi/extras/Rope.js deleted file mode 100644 index 05885ac..0000000 --- a/test/unit/pixi/extras/Rope.js +++ /dev/null @@ -1,31 +0,0 @@ -describe('pixi/extras/Rope', function () { - 'use strict'; - - var expect = chai.expect; - var Rope = PIXI.Rope; - var Texture = PIXI.Texture; - var Point = PIXI.Point; - - it('Module exists', function () { - expect(Rope).to.be.a('function'); - }); - - it('Confirm new instance', function () { - - var texture = Texture.fromImage('/base/test/textures/bunny.png'); - - // TODO-Alvin - // Same as Strip - - // var obj = new Rope(texture, [new Point(), new Point(5, 10), new Point(10, 20)]); - - // pixi_extras_Strip_confirmNew(obj); - - // expect(obj).to.be.an.instanceof(Rope); - // expect(obj).to.respondTo('refresh'); - // expect(obj).to.respondTo('updateTransform'); - // expect(obj).to.respondTo('setTexture'); - - // TODO: Test properties - }); -}); diff --git a/test/unit/pixi/extras/Spine.js b/test/unit/pixi/extras/Spine.js deleted file mode 100644 index 0708bc0..0000000 --- a/test/unit/pixi/extras/Spine.js +++ /dev/null @@ -1,10 +0,0 @@ -describe('pixi/extras/Spine', function () { - 'use strict'; - - var expect = chai.expect; - var Spine = PIXI.Spine; - - it('Module exists', function () { - expect(Spine).to.be.a('function'); - }); -}); diff --git a/test/unit/pixi/extras/Strip.js b/test/unit/pixi/extras/Strip.js deleted file mode 100644 index 230af90..0000000 --- a/test/unit/pixi/extras/Strip.js +++ /dev/null @@ -1,26 +0,0 @@ -describe('pixi/extras/Strip', function () { - 'use strict'; - - var expect = chai.expect; - var Strip = PIXI.Strip; - var Texture = PIXI.Texture; - - it('Module exists', function () { - expect(Strip).to.be.a('function'); - }); - - it('Confirm new instance', function () { - - - // TODO-Alvin - // We tweaked it to make it pass the tests, but the whole strip class needs - // to be re-coded - - var texture = Texture.fromImage('/base/test/textures/bunny.png'); - - // var obj = new Strip(texture, 20, 10000); - - - // pixi_extras_Strip_confirmNew(obj); - }); -}); diff --git a/test/unit/pixi/extras/TilingSprite.js b/test/unit/pixi/extras/TilingSprite.js deleted file mode 100644 index 56aea14..0000000 --- a/test/unit/pixi/extras/TilingSprite.js +++ /dev/null @@ -1,24 +0,0 @@ -describe('pixi/extras/TilingSprite', function () { - 'use strict'; - - var expect = chai.expect; - var TilingSprite = PIXI.TilingSprite; - var Texture = PIXI.Texture; - - it('Module exists', function () { - expect(TilingSprite).to.be.a('function'); - }); - - it('Confirm new instance', function () { - var texture = Texture.fromImage('/base/test/textures/bunny.png'); - var obj = new TilingSprite(texture, 6000, 12000); - - pixi_display_DisplayObjectContainer_confirmNew(obj); - - expect(obj).to.be.an.instanceof(TilingSprite); - expect(obj).to.respondTo('setTexture'); - expect(obj).to.respondTo('onTextureUpdate'); - - // TODO: Test properties - }); -}); diff --git a/test/unit/pixi/filters/FilterBlock.js b/test/unit/pixi/filters/FilterBlock.js deleted file mode 100644 index 870cec0..0000000 --- a/test/unit/pixi/filters/FilterBlock.js +++ /dev/null @@ -1,10 +0,0 @@ -describe('pixi/filters/FilterBlock', function () { - 'use strict'; - - var expect = chai.expect; - var FilterBlock = PIXI.FilterBlock; - - it('Module exists', function () { - expect(FilterBlock).to.be.a('function'); - }); -}); diff --git a/test/unit/pixi/loaders/AssetLoader.js b/test/unit/pixi/loaders/AssetLoader.js deleted file mode 100644 index a0aa0b5..0000000 --- a/test/unit/pixi/loaders/AssetLoader.js +++ /dev/null @@ -1,10 +0,0 @@ -describe('pixi/loaders/AssetLoader', function () { - 'use strict'; - - var expect = chai.expect; - var AssetLoader = PIXI.AssetLoader; - - it('Module exists', function () { - expect(AssetLoader).to.be.a('function'); - }); -}); diff --git a/test/unit/pixi-v2/InteractionManager.js b/test/unit/pixi-v2/InteractionManager.js new file mode 100644 index 0000000..ed3001f --- /dev/null +++ b/test/unit/pixi-v2/InteractionManager.js @@ -0,0 +1,10 @@ +describe('pixi/InteractionManager', function () { + 'use strict'; + + var expect = chai.expect; + var InteractionManager = PIXI.InteractionManager; + + it('Module exists', function () { + expect(InteractionManager).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/Pixi.js b/test/unit/pixi-v2/Pixi.js new file mode 100644 index 0000000..27debc1 --- /dev/null +++ b/test/unit/pixi-v2/Pixi.js @@ -0,0 +1,9 @@ +describe('pixi/Pixi', function () { + 'use strict'; + + var expect = chai.expect; + + it('Module exists', function () { + expect(global).to.have.property('PIXI').and.to.be.an('object'); + }); +}); diff --git a/test/unit/pixi-v2/core/Circle.js b/test/unit/pixi-v2/core/Circle.js new file mode 100644 index 0000000..fbcfa17 --- /dev/null +++ b/test/unit/pixi-v2/core/Circle.js @@ -0,0 +1,21 @@ +describe('pixi/core/Circle', function () { + 'use strict'; + + var expect = chai.expect; + var Circle = PIXI.Circle; + + it('Module exists', function () { + expect(Circle).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Circle(); + pixi_core_Circle_confirmNewCircle(obj); + }); + + it("getBounds should return Rectangle that bounds the circle", function() { + var obj = new Circle(100, 250, 50); + var bounds = obj.getBounds(); + pixi_core_Circle_isBoundedByRectangle(obj, bounds); + }); +}); diff --git a/test/unit/pixi-v2/core/Ellipse.js b/test/unit/pixi-v2/core/Ellipse.js new file mode 100644 index 0000000..026b56f --- /dev/null +++ b/test/unit/pixi-v2/core/Ellipse.js @@ -0,0 +1,24 @@ +describe('pixi/core/Ellipse', function () { + 'use strict'; + + var expect = chai.expect; + var Ellipse = PIXI.Ellipse; + + it('Module exists', function () { + expect(Ellipse).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Ellipse(); + + expect(obj).to.be.an.instanceof(Ellipse); + expect(obj).to.respondTo('clone'); + expect(obj).to.respondTo('contains'); + expect(obj).to.respondTo('getBounds'); + + expect(obj).to.have.property('x', 0); + expect(obj).to.have.property('y', 0); + expect(obj).to.have.property('width', 0); + expect(obj).to.have.property('height', 0); + }); +}); diff --git a/test/unit/pixi-v2/core/Matrix.js b/test/unit/pixi-v2/core/Matrix.js new file mode 100644 index 0000000..da75e2e --- /dev/null +++ b/test/unit/pixi-v2/core/Matrix.js @@ -0,0 +1,14 @@ +describe('pixi/core/Matrix', function () { + 'use strict'; + + var expect = chai.expect; + + it('Matrix exists', function () { + expect(PIXI.Matrix).to.be.an('function'); + }); + + it('Confirm new Matrix', function () { + var matrix = new PIXI.Matrix(); + pixi_core_Matrix_confirmNewMatrix(matrix); + }); +}); diff --git a/test/unit/pixi-v2/core/Point.js b/test/unit/pixi-v2/core/Point.js new file mode 100644 index 0000000..c4d5163 --- /dev/null +++ b/test/unit/pixi-v2/core/Point.js @@ -0,0 +1,15 @@ +describe('pixi/core/Point', function () { + 'use strict'; + + var expect = chai.expect; + var Point = PIXI.Point; + + it('Module exists', function () { + expect(Point).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Point(); + pixi_core_Point_confirm(obj, 0, 0); + }); +}); diff --git a/test/unit/pixi-v2/core/Polygon.js b/test/unit/pixi-v2/core/Polygon.js new file mode 100644 index 0000000..dc8c918 --- /dev/null +++ b/test/unit/pixi-v2/core/Polygon.js @@ -0,0 +1,20 @@ +describe('pixi/core/Polygon', function () { + 'use strict'; + + var expect = chai.expect; + var Polygon = PIXI.Polygon; + + it('Module exists', function () { + expect(Polygon).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Polygon(); + + expect(obj).to.be.an.instanceof(Polygon); + expect(obj).to.respondTo('clone'); + expect(obj).to.respondTo('contains'); + + expect(obj).to.have.deep.property('points.length', 0); + }); +}); diff --git a/test/unit/pixi-v2/core/Rectangle.js b/test/unit/pixi-v2/core/Rectangle.js new file mode 100644 index 0000000..d43316e --- /dev/null +++ b/test/unit/pixi-v2/core/Rectangle.js @@ -0,0 +1,15 @@ +describe('pixi/core/Rectangle', function () { + 'use strict'; + + var expect = chai.expect; + var Rectangle = PIXI.Rectangle; + + it('Module exists', function () { + expect(Rectangle).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var rect = new Rectangle(); + pixi_core_Rectangle_confirm(rect, 0, 0, 0, 0); + }); +}); diff --git a/test/unit/pixi-v2/display/DisplayObject.js b/test/unit/pixi-v2/display/DisplayObject.js new file mode 100644 index 0000000..044acf8 --- /dev/null +++ b/test/unit/pixi-v2/display/DisplayObject.js @@ -0,0 +1,21 @@ +describe('pixi/display/DisplayObject', function () { + 'use strict'; + + var expect = chai.expect; + var DisplayObject = PIXI.DisplayObject; + + it('Module exists', function () { + expect(DisplayObject).to.be.a('function'); + // expect(PIXI).to.have.property('visibleCount', 0); + }); + + it('Confirm new instance', function () { + var obj = new DisplayObject(); + + pixi_display_DisplayObject_confirmNew(obj); + expect(obj).to.have.property('hitArea', null); + expect(obj).to.have.property('interactive', false); + expect(obj).to.have.property('renderable', false); + expect(obj).to.have.property('stage', null); + }); +}); diff --git a/test/unit/pixi-v2/display/DisplayObjectContainer.js b/test/unit/pixi-v2/display/DisplayObjectContainer.js new file mode 100644 index 0000000..15a3376 --- /dev/null +++ b/test/unit/pixi-v2/display/DisplayObjectContainer.js @@ -0,0 +1,67 @@ +describe('pixi/display/DisplayObjectContainer', function () { + 'use strict'; + + var expect = chai.expect; + var DisplayObjectContainer = PIXI.DisplayObjectContainer; + + it('Module exists', function () { + expect(DisplayObjectContainer).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new DisplayObjectContainer(); + + pixi_display_DisplayObjectContainer_confirmNew(obj); + expect(obj).to.have.property('hitArea', null); + expect(obj).to.have.property('interactive', false); + expect(obj).to.have.property('renderable', false); + expect(obj).to.have.property('stage', null); + }); + + it('Gets child index', function() { + var container = new PIXI.DisplayObjectContainer(); + var children = []; + for (var i = 0; i < 10; i++) { + var child = new PIXI.DisplayObject(); + children.push(child); + container.addChild(child); + } + + for (i = 0; i < children.length; i++) { + expect(i).to.eql(container.getChildIndex(children[i])); + } + }); + + it('throws error when trying to get index of not a child', function() { + var container = new PIXI.DisplayObjectContainer(); + var child = new PIXI.DisplayObject(); + + expect(function() { container.getChildIndex(child); }).to.throw(); + }); + + it('Sets child index', function() { + var container = new PIXI.DisplayObjectContainer(); + var children = []; + + for (var i = 0; i < 10; i++) { + var child = new PIXI.DisplayObject(); + children.push(child); + container.addChild(child); + } + children.reverse(); + + for (i = 0; i < children.length; i++) { + container.setChildIndex(children[i], i); + expect(i).to.eql(container.getChildIndex(children[i])); + } + }); + + it('throws error when trying to set incorect index', function() { + var container = new PIXI.DisplayObjectContainer(); + var child = new PIXI.DisplayObject(); + container.addChild(child); + + expect(function() { container.setChildIndex(child, -1); }).to.throw(); + expect(function() { container.setChildIndex(child, 1); }).to.throw(); + }); +}); diff --git a/test/unit/pixi-v2/display/MovieClip.js b/test/unit/pixi-v2/display/MovieClip.js new file mode 100644 index 0000000..f3c6c6a --- /dev/null +++ b/test/unit/pixi-v2/display/MovieClip.js @@ -0,0 +1,33 @@ +describe('pixi/display/MovieClip', function () { + 'use strict'; + + var expect = chai.expect; + var MovieClip = PIXI.MovieClip; + var Texture = PIXI.Texture; + + it('Module exists', function () { + expect(MovieClip).to.be.a('function'); + }); + + it('Confirm new instance', function (done) { + var texture = Texture.fromImage('/base/test/textures/SpriteSheet-Explosion.png'); + var obj = new MovieClip([texture]); + + pixi_display_Sprite_confirmNew(obj, done); + + expect(obj).to.be.an.instanceof(MovieClip); + expect(obj).to.respondTo('stop'); + expect(obj).to.respondTo('play'); + expect(obj).to.respondTo('gotoAndStop'); + expect(obj).to.respondTo('gotoAndPlay'); + expect(obj).to.respondTo('updateTransform'); + + expect(obj).to.have.deep.property('textures.length', 1); + expect(obj).to.have.deep.property('textures[0]', texture); + expect(obj).to.have.property('animationSpeed', 1); + expect(obj).to.have.property('loop', true); + expect(obj).to.have.property('onComplete', null); + expect(obj).to.have.property('currentFrame', 0); + expect(obj).to.have.property('playing', false); + }); +}); diff --git a/test/unit/pixi-v2/display/Sprite.js b/test/unit/pixi-v2/display/Sprite.js new file mode 100644 index 0000000..30c8076 --- /dev/null +++ b/test/unit/pixi-v2/display/Sprite.js @@ -0,0 +1,28 @@ +describe('pixi/display/Sprite', function () { + 'use strict'; + + var expect = chai.expect; + var Sprite = PIXI.Sprite; + var Texture = PIXI.Texture; + + it('Module exists', function () { + expect(Sprite).to.be.a('function'); + expect(PIXI).to.have.deep.property('blendModes.NORMAL', 0); + expect(PIXI).to.have.deep.property('blendModes.ADD', 1); + expect(PIXI).to.have.deep.property('blendModes.MULTIPLY', 2); + expect(PIXI).to.have.deep.property('blendModes.SCREEN', 3); + }); + + + it('Members exist', function () { + expect(Sprite).itself.to.respondTo('fromImage'); + expect(Sprite).itself.to.respondTo('fromFrame'); + }); + + it('Confirm new instance', function (done) { + var texture = Texture.fromImage('/base/test/textures/SpriteSheet-Aliens.png'); + var obj = new Sprite(texture); + + pixi_display_Sprite_confirmNew(obj, done); + }); +}); diff --git a/test/unit/pixi-v2/display/Stage.js b/test/unit/pixi-v2/display/Stage.js new file mode 100644 index 0000000..6974c2e --- /dev/null +++ b/test/unit/pixi-v2/display/Stage.js @@ -0,0 +1,49 @@ +describe('pixi/display/Stage', function () { + 'use strict'; + + var expect = chai.expect; + var Stage = PIXI.Stage; + var InteractionManager = PIXI.InteractionManager; + var Rectangle = PIXI.Rectangle; + + it('Module exists', function () { + expect(Stage).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Stage(null, true); + + pixi_display_DisplayObjectContainer_confirmNew(obj); + + expect(obj).to.be.an.instanceof(Stage); + expect(obj).to.respondTo('updateTransform'); + expect(obj).to.respondTo('setBackgroundColor'); + expect(obj).to.respondTo('getMousePosition'); + // FIXME: duplicate member in DisplayObject + pixi_core_Matrix_confirmNewMatrix(obj.worldTransform); + // FIXME: convert arg to bool in constructor + expect(obj).to.have.property('interactive', true); + + expect(obj).to.have.property('interactionManager') + .and.to.be.an.instanceof(InteractionManager) + .and.to.have.property('stage', obj); + + expect(obj).to.have.property('dirty', true); + + expect(obj).to.have.property('stage', obj); + + expect(obj).to.have.property('hitArea') + .and.to.be.an.instanceof(Rectangle); + pixi_core_Rectangle_confirm(obj.hitArea, 0, 0, 100000, 100000); + + expect(obj).to.have.property('backgroundColor', 0x000000); + expect(obj).to.have.deep.property('backgroundColorSplit.length', 3); + expect(obj).to.have.deep.property('backgroundColorSplit[0]', 0); + expect(obj).to.have.deep.property('backgroundColorSplit[1]', 0); + expect(obj).to.have.deep.property('backgroundColorSplit[2]', 0); + expect(obj).to.have.property('backgroundColorString', '#000000'); + + + expect(obj).to.have.property('worldVisible', true); + }); +}); diff --git a/test/unit/pixi-v2/extras/Rope.js b/test/unit/pixi-v2/extras/Rope.js new file mode 100644 index 0000000..05885ac --- /dev/null +++ b/test/unit/pixi-v2/extras/Rope.js @@ -0,0 +1,31 @@ +describe('pixi/extras/Rope', function () { + 'use strict'; + + var expect = chai.expect; + var Rope = PIXI.Rope; + var Texture = PIXI.Texture; + var Point = PIXI.Point; + + it('Module exists', function () { + expect(Rope).to.be.a('function'); + }); + + it('Confirm new instance', function () { + + var texture = Texture.fromImage('/base/test/textures/bunny.png'); + + // TODO-Alvin + // Same as Strip + + // var obj = new Rope(texture, [new Point(), new Point(5, 10), new Point(10, 20)]); + + // pixi_extras_Strip_confirmNew(obj); + + // expect(obj).to.be.an.instanceof(Rope); + // expect(obj).to.respondTo('refresh'); + // expect(obj).to.respondTo('updateTransform'); + // expect(obj).to.respondTo('setTexture'); + + // TODO: Test properties + }); +}); diff --git a/test/unit/pixi-v2/extras/Spine.js b/test/unit/pixi-v2/extras/Spine.js new file mode 100644 index 0000000..0708bc0 --- /dev/null +++ b/test/unit/pixi-v2/extras/Spine.js @@ -0,0 +1,10 @@ +describe('pixi/extras/Spine', function () { + 'use strict'; + + var expect = chai.expect; + var Spine = PIXI.Spine; + + it('Module exists', function () { + expect(Spine).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/extras/Strip.js b/test/unit/pixi-v2/extras/Strip.js new file mode 100644 index 0000000..230af90 --- /dev/null +++ b/test/unit/pixi-v2/extras/Strip.js @@ -0,0 +1,26 @@ +describe('pixi/extras/Strip', function () { + 'use strict'; + + var expect = chai.expect; + var Strip = PIXI.Strip; + var Texture = PIXI.Texture; + + it('Module exists', function () { + expect(Strip).to.be.a('function'); + }); + + it('Confirm new instance', function () { + + + // TODO-Alvin + // We tweaked it to make it pass the tests, but the whole strip class needs + // to be re-coded + + var texture = Texture.fromImage('/base/test/textures/bunny.png'); + + // var obj = new Strip(texture, 20, 10000); + + + // pixi_extras_Strip_confirmNew(obj); + }); +}); diff --git a/test/unit/pixi-v2/extras/TilingSprite.js b/test/unit/pixi-v2/extras/TilingSprite.js new file mode 100644 index 0000000..56aea14 --- /dev/null +++ b/test/unit/pixi-v2/extras/TilingSprite.js @@ -0,0 +1,24 @@ +describe('pixi/extras/TilingSprite', function () { + 'use strict'; + + var expect = chai.expect; + var TilingSprite = PIXI.TilingSprite; + var Texture = PIXI.Texture; + + it('Module exists', function () { + expect(TilingSprite).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var texture = Texture.fromImage('/base/test/textures/bunny.png'); + var obj = new TilingSprite(texture, 6000, 12000); + + pixi_display_DisplayObjectContainer_confirmNew(obj); + + expect(obj).to.be.an.instanceof(TilingSprite); + expect(obj).to.respondTo('setTexture'); + expect(obj).to.respondTo('onTextureUpdate'); + + // TODO: Test properties + }); +}); diff --git a/test/unit/pixi-v2/filters/FilterBlock.js b/test/unit/pixi-v2/filters/FilterBlock.js new file mode 100644 index 0000000..870cec0 --- /dev/null +++ b/test/unit/pixi-v2/filters/FilterBlock.js @@ -0,0 +1,10 @@ +describe('pixi/filters/FilterBlock', function () { + 'use strict'; + + var expect = chai.expect; + var FilterBlock = PIXI.FilterBlock; + + it('Module exists', function () { + expect(FilterBlock).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/AssetLoader.js b/test/unit/pixi-v2/loaders/AssetLoader.js new file mode 100644 index 0000000..a0aa0b5 --- /dev/null +++ b/test/unit/pixi-v2/loaders/AssetLoader.js @@ -0,0 +1,10 @@ +describe('pixi/loaders/AssetLoader', function () { + 'use strict'; + + var expect = chai.expect; + var AssetLoader = PIXI.AssetLoader; + + it('Module exists', function () { + expect(AssetLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/BitmapFontLoader.js b/test/unit/pixi-v2/loaders/BitmapFontLoader.js new file mode 100644 index 0000000..046f018 --- /dev/null +++ b/test/unit/pixi-v2/loaders/BitmapFontLoader.js @@ -0,0 +1,9 @@ +describe('pixi/loaders/BitmapFontLoader', function () { + 'use strict'; + + var expect = chai.expect; + + it('Module exists', function () { + expect(PIXI.BitmapFontLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/ImageLoader.js b/test/unit/pixi-v2/loaders/ImageLoader.js new file mode 100644 index 0000000..8b1f556 --- /dev/null +++ b/test/unit/pixi-v2/loaders/ImageLoader.js @@ -0,0 +1,10 @@ +describe('pixi/loaders/ImageLoader', function () { + 'use strict'; + + var expect = chai.expect; + var ImageLoader = PIXI.ImageLoader; + + it('Module exists', function () { + expect(ImageLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/JsonLoader.js b/test/unit/pixi-v2/loaders/JsonLoader.js new file mode 100644 index 0000000..c577e83 --- /dev/null +++ b/test/unit/pixi-v2/loaders/JsonLoader.js @@ -0,0 +1,10 @@ +describe('pixi/loaders/JsonLoader', function () { + 'use strict'; + + var expect = chai.expect; + var JsonLoader = PIXI.JsonLoader; + + it('Module exists', function () { + expect(JsonLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/SpineLoader.js b/test/unit/pixi-v2/loaders/SpineLoader.js new file mode 100644 index 0000000..fdcc0b8 --- /dev/null +++ b/test/unit/pixi-v2/loaders/SpineLoader.js @@ -0,0 +1,10 @@ +describe('pixi/loaders/SpineLoader', function () { + 'use strict'; + + var expect = chai.expect; + var SpineLoader = PIXI.SpineLoader; + + it('Module exists', function () { + expect(SpineLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/SpriteSheetLoader.js b/test/unit/pixi-v2/loaders/SpriteSheetLoader.js new file mode 100644 index 0000000..57beb27 --- /dev/null +++ b/test/unit/pixi-v2/loaders/SpriteSheetLoader.js @@ -0,0 +1,10 @@ +describe('pixi/loaders/SpriteSheetLoader', function () { + 'use strict'; + + var expect = chai.expect; + var SpriteSheetLoader = PIXI.SpriteSheetLoader; + + it('Module exists', function () { + expect(SpriteSheetLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/primitives/Graphics.js b/test/unit/pixi-v2/primitives/Graphics.js new file mode 100644 index 0000000..f3849eb --- /dev/null +++ b/test/unit/pixi-v2/primitives/Graphics.js @@ -0,0 +1,44 @@ +describe('pixi/primitives/Graphics', function () { + 'use strict'; + + var expect = chai.expect; + var Graphics = PIXI.Graphics; + + it('Module exists', function () { + expect(Graphics).to.be.a('function'); + + expect(Graphics).itself.to.have.property('POLY', 0); + expect(Graphics).itself.to.have.property('RECT', 1); + expect(Graphics).itself.to.have.property('CIRC', 2); + expect(Graphics).itself.to.have.property('ELIP', 3); + expect(Graphics).itself.to.have.property('RREC', 4); + }); + + it('Confirm new instance', function () { + var obj = new Graphics(); + + pixi_display_DisplayObjectContainer_confirmNew(obj); + + expect(obj).to.be.an.instanceof(Graphics); + expect(obj).to.respondTo('lineStyle'); + expect(obj).to.respondTo('lineStyle'); + expect(obj).to.respondTo('moveTo'); + expect(obj).to.respondTo('lineTo'); + expect(obj).to.respondTo('beginFill'); + expect(obj).to.respondTo('endFill'); + expect(obj).to.respondTo('drawRect'); + // expect(obj).to.respondTo('drawRoundedRect'); + expect(obj).to.respondTo('drawCircle'); + expect(obj).to.respondTo('drawEllipse'); + expect(obj).to.respondTo('clear'); + + expect(obj).to.have.property('renderable', true); + expect(obj).to.have.property('fillAlpha', 1); + expect(obj).to.have.property('lineWidth', 0); + expect(obj).to.have.property('width', 0); + expect(obj).to.have.property('height', 0); + expect(obj).to.have.property('lineColor', 0); + expect(obj).to.have.deep.property('graphicsData.length', 0); + // expect(obj).to.have.deep.property('currentPath.points.length', 0); + }); +}); diff --git a/test/unit/pixi-v2/renderers/canvas/CanvasGraphics.js b/test/unit/pixi-v2/renderers/canvas/CanvasGraphics.js new file mode 100644 index 0000000..8f44472 --- /dev/null +++ b/test/unit/pixi-v2/renderers/canvas/CanvasGraphics.js @@ -0,0 +1,15 @@ +describe('renders/canvas/CanvasGraphics', function () { + 'use strict'; + + var expect = chai.expect; + var CanvasGraphics = PIXI.CanvasGraphics; + + it('Module exists', function () { + expect(CanvasGraphics).to.be.a('function'); + }); + + it('Members exist', function () { + expect(CanvasGraphics).itself.to.respondTo('renderGraphics'); + expect(CanvasGraphics).itself.to.respondTo('renderGraphicsMask'); + }); +}); diff --git a/test/unit/pixi-v2/renderers/canvas/CanvasRenderer.js b/test/unit/pixi-v2/renderers/canvas/CanvasRenderer.js new file mode 100644 index 0000000..1646444 --- /dev/null +++ b/test/unit/pixi-v2/renderers/canvas/CanvasRenderer.js @@ -0,0 +1,36 @@ +describe('renderers/canvas/CanvasRenderer', function () { + 'use strict'; + + var expect = chai.expect; + var CanvasRenderer = PIXI.CanvasRenderer; + + it('Module exists', function () { + expect(CanvasRenderer).to.be.a('function'); + }); + + describe('.autoResize', function () { + it('Should automatically resize view if enabled', function () { + var renderer = new CanvasRenderer(200, 200, { + autoResize: true + }); + + expect(renderer.view.style.width).to.equal('200px'); + }); + + it('Should not automatically resize view if disabled', function () { + var renderer = new CanvasRenderer(200, 200, { + autoResize: false + }); + + expect(renderer.view.style.width).to.equal(''); + }); + + it('Should not automatically resize view if not specified', function () { + var renderer = new CanvasRenderer(200, 200, { + resolution: 2 + }); + + expect(renderer.view.style.width).to.equal(''); + }); + }); +}); diff --git a/test/unit/pixi-v2/renderers/webgl/WebGLGraphics.js b/test/unit/pixi-v2/renderers/webgl/WebGLGraphics.js new file mode 100644 index 0000000..5867b28 --- /dev/null +++ b/test/unit/pixi-v2/renderers/webgl/WebGLGraphics.js @@ -0,0 +1,20 @@ +describe('renderers/wegbl/WebGLGraphics', function () { + 'use strict'; + + var expect = chai.expect; + var WebGLGraphics = PIXI.WebGLGraphics; + + it('Module exists', function () { + expect(WebGLGraphics).to.be.a('function'); + }); + + it('Members exist', function () { + expect(WebGLGraphics).itself.to.respondTo('renderGraphics'); + expect(WebGLGraphics).itself.to.respondTo('updateGraphics'); + expect(WebGLGraphics).itself.to.respondTo('buildRectangle'); + expect(WebGLGraphics).itself.to.respondTo('buildRoundedRectangle'); + expect(WebGLGraphics).itself.to.respondTo('buildCircle'); + expect(WebGLGraphics).itself.to.respondTo('buildLine'); + expect(WebGLGraphics).itself.to.respondTo('buildPoly'); + }); +}); diff --git a/test/unit/pixi-v2/renderers/webgl/WebGLRenderer.js b/test/unit/pixi-v2/renderers/webgl/WebGLRenderer.js new file mode 100644 index 0000000..1680a80 --- /dev/null +++ b/test/unit/pixi-v2/renderers/webgl/WebGLRenderer.js @@ -0,0 +1,49 @@ +describe('renderers/webgl/WebGLRenderer', function () { + 'use strict'; + + var expect = chai.expect; + var WebGLRenderer = PIXI.WebGLRenderer; + + it('Module exists', function () { + expect(WebGLRenderer).to.be.a('function'); + }); + + // Skip tests if WebGL is not available (WebGL not supported in Travis CI) + try { + var renderer = new WebGLRenderer(400, 300, {}); + renderer.destroy(); + } catch (error) { + return; + } + + it('Destroy renderer', function () { + var renderer = new WebGLRenderer(400, 300, {}); + renderer.destroy(); + }); + + describe('.autoResize', function () { + it('Should automatically resize view if enabled', function () { + var renderer = new WebGLRenderer(200, 200, { + autoResize: true + }); + + expect(renderer.view.style.width).to.equal('200px'); + }); + + it('Should not automatically resize view if disabled', function () { + var renderer = new WebGLRenderer(200, 200, { + autoResize: false + }); + + expect(renderer.view.style.width).to.equal(''); + }); + + it('Should not automatically resize view if not specified', function () { + var renderer = new WebGLRenderer(200, 200, { + resolution: 2 + }); + + expect(renderer.view.style.width).to.equal(''); + }); + }); +}); diff --git a/test/unit/pixi-v2/renderers/webgl/WebGLShaders.js b/test/unit/pixi-v2/renderers/webgl/WebGLShaders.js new file mode 100644 index 0000000..6e33e4f --- /dev/null +++ b/test/unit/pixi-v2/renderers/webgl/WebGLShaders.js @@ -0,0 +1,13 @@ +describe('renderers/webgl/WebGLShaders', function () { + 'use strict'; + + var expect = chai.expect; + + it('Module members exist', function () { + + expect(PIXI).to.respondTo('CompileVertexShader'); + expect(PIXI).to.respondTo('CompileFragmentShader'); + expect(PIXI).to.respondTo('_CompileShader'); + expect(PIXI).to.respondTo('compileProgram'); + }); +}); diff --git a/test/unit/pixi-v2/renderers/webgl/WebGLSpriteBatch.js b/test/unit/pixi-v2/renderers/webgl/WebGLSpriteBatch.js new file mode 100644 index 0000000..e662b63 --- /dev/null +++ b/test/unit/pixi-v2/renderers/webgl/WebGLSpriteBatch.js @@ -0,0 +1,10 @@ +describe('renderers/webgl/utils/WebGLSpriteBatch', function () { + 'use strict'; + + var expect = chai.expect; + var WebGLSpriteBatch = PIXI.WebGLSpriteBatch; + + it('Module exists', function () { + expect(WebGLSpriteBatch).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/text/BitmapText.js b/test/unit/pixi-v2/text/BitmapText.js new file mode 100644 index 0000000..9388e3d --- /dev/null +++ b/test/unit/pixi-v2/text/BitmapText.js @@ -0,0 +1,10 @@ +describe('pixi/text/BitmapText', function () { + 'use strict'; + + var expect = chai.expect; + var BitmapText = PIXI.BitmapText; + + it('Module exists', function () { + expect(BitmapText).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/text/Text.js b/test/unit/pixi-v2/text/Text.js new file mode 100644 index 0000000..9bc9ac5 --- /dev/null +++ b/test/unit/pixi-v2/text/Text.js @@ -0,0 +1,10 @@ +describe('pixi/text/Text', function () { + 'use strict'; + + var expect = chai.expect; + var Text = PIXI.Text; + + it('Module exists', function () { + expect(Text).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/textures/BaseTexture.js b/test/unit/pixi-v2/textures/BaseTexture.js new file mode 100644 index 0000000..502b724 --- /dev/null +++ b/test/unit/pixi-v2/textures/BaseTexture.js @@ -0,0 +1,11 @@ +describe('pixi/textures/BaseTexture', function () { + 'use strict'; + + var expect = chai.expect; + var BaseTexture = PIXI.BaseTexture; + + it('Module exists', function () { + expect(BaseTexture).to.be.a('function'); + expect(PIXI).to.have.property('BaseTextureCache').and.to.be.an('object'); + }); +}); diff --git a/test/unit/pixi-v2/textures/RenderTexture.js b/test/unit/pixi-v2/textures/RenderTexture.js new file mode 100644 index 0000000..96acdb4 --- /dev/null +++ b/test/unit/pixi-v2/textures/RenderTexture.js @@ -0,0 +1,15 @@ +describe('pixi/textures/RenderTexture', function () { + 'use strict'; + + var expect = chai.expect; + var RenderTexture = PIXI.RenderTexture; + + it('Module exists', function () { + expect(RenderTexture).to.be.a('function'); + }); + + it('Confirm new instance', function (done) { + var texture = new RenderTexture(100, 100, new PIXI.CanvasRenderer()); + pixi_textures_RenderTexture_confirmNew(texture, done); + }); +}); diff --git a/test/unit/pixi-v2/textures/Texture.js b/test/unit/pixi-v2/textures/Texture.js new file mode 100644 index 0000000..090f64d --- /dev/null +++ b/test/unit/pixi-v2/textures/Texture.js @@ -0,0 +1,26 @@ +describe('pixi/textures/Texture', function () { + 'use strict'; + + var expect = chai.expect; + var Texture = PIXI.Texture; + + it('Module exists', function () { + expect(Texture).to.be.a('function'); + expect(PIXI).to.have.property('TextureCache').and.to.be.an('object'); + }); + + it('Members exist', function () { + expect(Texture).itself.to.respondTo('fromImage'); + expect(Texture).itself.to.respondTo('fromFrame'); + expect(Texture).itself.to.respondTo('fromCanvas'); + expect(Texture).itself.to.respondTo('addTextureToCache'); + expect(Texture).itself.to.respondTo('removeTextureFromCache'); + + // expect(Texture).itself.to.have.deep.property('frameUpdates.length', 0); + }); + + it('Confirm new instance', function (done) { + var texture = Texture.fromImage('/base/test/textures/bunny.png'); + pixi_textures_Texture_confirmNew(texture, done); + }); +}); diff --git a/test/unit/pixi-v2/utils/Detector.js b/test/unit/pixi-v2/utils/Detector.js new file mode 100644 index 0000000..4cf6008 --- /dev/null +++ b/test/unit/pixi-v2/utils/Detector.js @@ -0,0 +1,10 @@ +describe('pixi/utils/Detector', function () { + 'use strict'; + + var expect = chai.expect; + var autoDetectRenderer = PIXI.autoDetectRenderer; + + it('Module exists', function () { + expect(autoDetectRenderer).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/utils/EventTarget.js b/test/unit/pixi-v2/utils/EventTarget.js new file mode 100644 index 0000000..1cfc3a4 --- /dev/null +++ b/test/unit/pixi-v2/utils/EventTarget.js @@ -0,0 +1,361 @@ +describe('pixi/utils/EventTarget', function () { + 'use strict'; + + var expect = chai.expect; + + var Clazz, PClazz, obj, pobj, obj2; + beforeEach(function () { + Clazz = function () {}; + PClazz = function () {}; + + PIXI.EventTarget.mixin(Clazz.prototype); + PIXI.EventTarget.mixin(PClazz.prototype); + + obj = new Clazz(); + obj2 = new Clazz(); + pobj = new PClazz(); + + obj.parent = pobj; + obj2.parent = obj; + }); + + it('Module exists', function () { + expect(PIXI.EventTarget).to.be.an('object'); + }); + + it('Confirm new instance', function () { + pixi_utils_EventTarget_confirm(obj); + }); + + it('simple on/emit case works', function () { + var myData = {}; + + obj.on('myevent', function (event) { + pixi_utils_EventTarget_Event_confirm(event, obj, myData); + }); + + obj.emit('myevent', myData); + }); + + it('simple once case works', function () { + var called = 0; + + obj.once('myevent', function() { called++; }); + + obj.emit('myevent'); + obj.emit('myevent'); + obj.emit('myevent'); + obj.emit('myevent'); + obj.emit('myevent'); + + expect(called).to.equal(1); + }); + + it('simple off case works', function (done) { + function onMyEvent() { + done(new Error('Event listener should not have been called')); + } + + obj.on('myevent', onMyEvent); + obj.off('myevent', onMyEvent); + obj.emit('myevent'); + + done(); + }); + + it('simple propagation case works', function (done) { + var myData = {}; + + pobj.on('myevent', function () { + done(); + }); + + obj.emit('myevent'); + }); + + it('simple stopPropagation case works', function (done) { + var myData = {}; + + pobj.on('myevent', function () { + done(new Error('Event listener should not have been called on the parent element')); + }); + + obj.on('myevent', function (evt) { + evt.stopPropagation(); + }); + + obj.emit('myevent'); + + done(); + }); + + it('simple stopImmediatePropagation case works', function (done) { + var myData = {}; + + pobj.on('myevent', function () { + done(new Error('Event listener should not have been called on the parent')); + }); + + obj.on('myevent', function (evt) { + evt.stopImmediatePropagation(); + }); + + obj.on('myevent', function () { + done(new Error('Event listener should not have been called on the second')); + }); + + obj.emit('myevent'); + + done(); + }); + + it('multiple dispatches work properly', function () { + var called = 0; + + function onMyEvent() { + called++; + } + + obj.on('myevent', onMyEvent); + obj.emit('myevent'); + obj.emit('myevent'); + obj.emit('myevent'); + obj.emit('myevent'); + + expect(called).to.equal(4); + }); + + it('multiple events work properly', function () { + var called = 0; + + function onMyEvent() { + called++; + } + + obj.on('myevent1', onMyEvent); + obj.on('myevent2', onMyEvent); + obj.on('myevent3', onMyEvent); + obj.emit('myevent1'); + obj.emit('myevent2'); + obj.emit('myevent3'); + + expect(called).to.equal(3); + }); + + it('multiple events one removed works properly', function () { + var called = 0; + + function onMyEvent() { + called++; + } + + obj.on('myevent1', onMyEvent); + obj.on('myevent2', onMyEvent); + obj.on('myevent3', onMyEvent); + + obj.emit('myevent1'); + obj.emit('myevent2'); + obj.emit('myevent3'); + + obj.off('myevent2', onMyEvent); + + obj.emit('myevent1'); + obj.emit('myevent2'); + obj.emit('myevent3'); + + expect(called).to.equal(5); + }); + + it('multiple handlers for one event with some removed', function () { + var called = 0; + + var onMyEvent = function () { + called++; + }, + onMyEvent2 = function () { + called++; + }; + + // add 2 handlers and confirm they both get called + obj.on('myevent', onMyEvent); + obj.on('myevent', onMyEvent); + obj.on('myevent', onMyEvent2); + obj.on('myevent', onMyEvent2); + + obj.emit('myevent'); + + expect(called).to.equal(4); + + // remove one of the handlers, emit again, then ensure 1 more call is made + obj.off('myevent', onMyEvent); + + obj.emit('myevent'); + + expect(called).to.equal(6); + }); + + it('calls to off without a handler do nothing', function () { + var called = 0; + + var onMyEvent = function () { + called++; + }; + + obj.on('myevent', onMyEvent); + obj.on('myevent', onMyEvent); + + obj.emit('myevent'); + + expect(called).to.equal(2); + + obj.off('myevent'); + + obj.emit('myevent'); + + expect(called).to.equal(4); + + obj.off('myevent', onMyEvent); + + obj.emit('myevent'); + + expect(called).to.equal(4); + }); + + it('handles multiple instances with the same prototype', function () { + var called = 0; + + function onMyEvent(e) { + called++; + } + + obj.on('myevent1', onMyEvent); + obj.on('myevent2', onMyEvent); + + obj2.istwo = true; + obj2.on('myevent1', onMyEvent); + obj2.on('myevent2', onMyEvent); + + obj.emit('myevent1'); + obj.emit('myevent2'); + obj2.emit('myevent1'); + obj2.emit('myevent2'); + + //we emit 4 times, but since obj2 is a child of obj the event should bubble + //up to obj and show up there as well. So the obj2.emit() calls each increment + //the counter twice. + expect(called).to.equal(6); + }); + + it('is backwards compatible with older .dispatchEvent({})', function () { + var called = 0, + data = { + some: 'thing', + hello: true + }; + + function onMyEvent(event) { + pixi_utils_EventTarget_Event_confirm(event, obj, data); + + called++; + } + + obj.on('myevent1', onMyEvent); + obj.on('myevent2', onMyEvent); + obj.on('myevent3', onMyEvent); + + data.type = 'myevent1'; + obj.emit(data); + + data.type = 'myevent2'; + obj.emit(data); + + data.type = 'myevent3'; + obj.emit(data); + + obj.off('myevent2', onMyEvent); + + data.type = 'myevent1'; + obj.emit(data); + + data.type = 'myevent2'; + obj.emit(data); + + data.type = 'myevent3'; + obj.emit(data); + + expect(called).to.equal(5); + }); + + it('is backwards compatible with older .call(this)', function () { + var Fn = function() { + PIXI.EventTarget.call(this); + }, + o = new Fn(); + + pixi_utils_EventTarget_confirm(o); + }); + + it('is backwards compatible with older .addEventListener("")', function () { + var called = 0, + data = { + some: 'thing', + hello: true + }; + + function onMyEvent(event) { + pixi_utils_EventTarget_Event_confirm(event, obj, data); + + called++; + } + + obj.addEventListener('myevent1', onMyEvent); + obj.addEventListener('myevent2', onMyEvent); + obj.addEventListener('myevent3', onMyEvent); + + data.type = 'myevent1'; + obj.emit(data); + + data.type = 'myevent2'; + obj.emit(data); + + data.type = 'myevent3'; + obj.emit(data); + + obj.off('myevent2', onMyEvent); + + data.type = 'myevent1'; + obj.emit(data); + + data.type = 'myevent2'; + obj.emit(data); + + data.type = 'myevent3'; + obj.emit(data); + + expect(called).to.equal(5); + }); + + it('event remove during emit call properly', function () { + var called = 0; + + function cb1() { + called++; + obj.off('myevent', cb1); + } + function cb2() { + called++; + obj.off('myevent', cb2); + } + function cb3() { + called++; + obj.off('myevent', cb3); + } + + obj.on('myevent', cb1); + obj.on('myevent', cb2); + obj.on('myevent', cb3); + obj.emit('myevent', ''); + + expect(called).to.equal(3); + }); +}); diff --git a/test/unit/pixi-v2/utils/Polyk.js b/test/unit/pixi-v2/utils/Polyk.js new file mode 100644 index 0000000..dfc7128 --- /dev/null +++ b/test/unit/pixi-v2/utils/Polyk.js @@ -0,0 +1,14 @@ +describe('pixi/utils/Polyk', function () { + 'use strict'; + + var expect = chai.expect; + var PolyK = PIXI.PolyK; + + it('Module exists', function () { + expect(PolyK).to.be.an('object'); + }); + + it('Members exist', function () { + expect(PolyK).to.respondTo('Triangulate'); + }); +}); diff --git a/test/unit/pixi-v2/utils/Utils.js b/test/unit/pixi-v2/utils/Utils.js new file mode 100644 index 0000000..c97b3c6 --- /dev/null +++ b/test/unit/pixi-v2/utils/Utils.js @@ -0,0 +1,17 @@ +describe('Utils', function () { + 'use strict'; + + var expect = chai.expect; + + it('requestAnimationFrame exists', function () { + expect(global).to.respondTo('requestAnimationFrame'); + }); + + it('cancelAnimationFrame exists', function () { + expect(global).to.respondTo('cancelAnimationFrame'); + }); + + it('requestAnimFrame exists', function () { + expect(global).to.respondTo('requestAnimFrame'); + }); +}); diff --git a/test/unit/pixi/InteractionManager.js b/test/unit/pixi/InteractionManager.js deleted file mode 100644 index ed3001f..0000000 --- a/test/unit/pixi/InteractionManager.js +++ /dev/null @@ -1,10 +0,0 @@ -describe('pixi/InteractionManager', function () { - 'use strict'; - - var expect = chai.expect; - var InteractionManager = PIXI.InteractionManager; - - it('Module exists', function () { - expect(InteractionManager).to.be.a('function'); - }); -}); diff --git a/test/unit/pixi/Pixi.js b/test/unit/pixi/Pixi.js deleted file mode 100644 index 27debc1..0000000 --- a/test/unit/pixi/Pixi.js +++ /dev/null @@ -1,9 +0,0 @@ -describe('pixi/Pixi', function () { - 'use strict'; - - var expect = chai.expect; - - it('Module exists', function () { - expect(global).to.have.property('PIXI').and.to.be.an('object'); - }); -}); diff --git a/test/unit/pixi/core/Circle.js b/test/unit/pixi/core/Circle.js deleted file mode 100644 index fbcfa17..0000000 --- a/test/unit/pixi/core/Circle.js +++ /dev/null @@ -1,21 +0,0 @@ -describe('pixi/core/Circle', function () { - 'use strict'; - - var expect = chai.expect; - var Circle = PIXI.Circle; - - it('Module exists', function () { - expect(Circle).to.be.a('function'); - }); - - it('Confirm new instance', function () { - var obj = new Circle(); - pixi_core_Circle_confirmNewCircle(obj); - }); - - it("getBounds should return Rectangle that bounds the circle", function() { - var obj = new Circle(100, 250, 50); - var bounds = obj.getBounds(); - pixi_core_Circle_isBoundedByRectangle(obj, bounds); - }); -}); diff --git a/test/unit/pixi/core/Ellipse.js b/test/unit/pixi/core/Ellipse.js deleted file mode 100644 index 026b56f..0000000 --- a/test/unit/pixi/core/Ellipse.js +++ /dev/null @@ -1,24 +0,0 @@ -describe('pixi/core/Ellipse', function () { - 'use strict'; - - var expect = chai.expect; - var Ellipse = PIXI.Ellipse; - - it('Module exists', function () { - expect(Ellipse).to.be.a('function'); - }); - - it('Confirm new instance', function () { - var obj = new Ellipse(); - - expect(obj).to.be.an.instanceof(Ellipse); - expect(obj).to.respondTo('clone'); - expect(obj).to.respondTo('contains'); - expect(obj).to.respondTo('getBounds'); - - expect(obj).to.have.property('x', 0); - expect(obj).to.have.property('y', 0); - expect(obj).to.have.property('width', 0); - expect(obj).to.have.property('height', 0); - }); -}); diff --git a/test/unit/pixi/core/Matrix.js b/test/unit/pixi/core/Matrix.js deleted file mode 100644 index da75e2e..0000000 --- a/test/unit/pixi/core/Matrix.js +++ /dev/null @@ -1,14 +0,0 @@ -describe('pixi/core/Matrix', function () { - 'use strict'; - - var expect = chai.expect; - - it('Matrix exists', function () { - expect(PIXI.Matrix).to.be.an('function'); - }); - - it('Confirm new Matrix', function () { - var matrix = new PIXI.Matrix(); - pixi_core_Matrix_confirmNewMatrix(matrix); - }); -}); diff --git a/test/unit/pixi/core/Point.js b/test/unit/pixi/core/Point.js deleted file mode 100644 index c4d5163..0000000 --- a/test/unit/pixi/core/Point.js +++ /dev/null @@ -1,15 +0,0 @@ -describe('pixi/core/Point', function () { - 'use strict'; - - var expect = chai.expect; - var Point = PIXI.Point; - - it('Module exists', function () { - expect(Point).to.be.a('function'); - }); - - it('Confirm new instance', function () { - var obj = new Point(); - pixi_core_Point_confirm(obj, 0, 0); - }); -}); diff --git a/test/unit/pixi/core/Polygon.js b/test/unit/pixi/core/Polygon.js deleted file mode 100644 index dc8c918..0000000 --- a/test/unit/pixi/core/Polygon.js +++ /dev/null @@ -1,20 +0,0 @@ -describe('pixi/core/Polygon', function () { - 'use strict'; - - var expect = chai.expect; - var Polygon = PIXI.Polygon; - - it('Module exists', function () { - expect(Polygon).to.be.a('function'); - }); - - it('Confirm new instance', function () { - var obj = new Polygon(); - - expect(obj).to.be.an.instanceof(Polygon); - expect(obj).to.respondTo('clone'); - expect(obj).to.respondTo('contains'); - - expect(obj).to.have.deep.property('points.length', 0); - }); -}); diff --git a/test/unit/pixi/core/Rectangle.js b/test/unit/pixi/core/Rectangle.js deleted file mode 100644 index d43316e..0000000 --- a/test/unit/pixi/core/Rectangle.js +++ /dev/null @@ -1,15 +0,0 @@ -describe('pixi/core/Rectangle', function () { - 'use strict'; - - var expect = chai.expect; - var Rectangle = PIXI.Rectangle; - - it('Module exists', function () { - expect(Rectangle).to.be.a('function'); - }); - - it('Confirm new instance', function () { - var rect = new Rectangle(); - pixi_core_Rectangle_confirm(rect, 0, 0, 0, 0); - }); -}); diff --git a/test/unit/pixi/display/DisplayObject.js b/test/unit/pixi/display/DisplayObject.js deleted file mode 100644 index 044acf8..0000000 --- a/test/unit/pixi/display/DisplayObject.js +++ /dev/null @@ -1,21 +0,0 @@ -describe('pixi/display/DisplayObject', function () { - 'use strict'; - - var expect = chai.expect; - var DisplayObject = PIXI.DisplayObject; - - it('Module exists', function () { - expect(DisplayObject).to.be.a('function'); - // expect(PIXI).to.have.property('visibleCount', 0); - }); - - it('Confirm new instance', function () { - var obj = new DisplayObject(); - - pixi_display_DisplayObject_confirmNew(obj); - expect(obj).to.have.property('hitArea', null); - expect(obj).to.have.property('interactive', false); - expect(obj).to.have.property('renderable', false); - expect(obj).to.have.property('stage', null); - }); -}); diff --git a/test/unit/pixi/display/DisplayObjectContainer.js b/test/unit/pixi/display/DisplayObjectContainer.js deleted file mode 100644 index 15a3376..0000000 --- a/test/unit/pixi/display/DisplayObjectContainer.js +++ /dev/null @@ -1,67 +0,0 @@ -describe('pixi/display/DisplayObjectContainer', function () { - 'use strict'; - - var expect = chai.expect; - var DisplayObjectContainer = PIXI.DisplayObjectContainer; - - it('Module exists', function () { - expect(DisplayObjectContainer).to.be.a('function'); - }); - - it('Confirm new instance', function () { - var obj = new DisplayObjectContainer(); - - pixi_display_DisplayObjectContainer_confirmNew(obj); - expect(obj).to.have.property('hitArea', null); - expect(obj).to.have.property('interactive', false); - expect(obj).to.have.property('renderable', false); - expect(obj).to.have.property('stage', null); - }); - - it('Gets child index', function() { - var container = new PIXI.DisplayObjectContainer(); - var children = []; - for (var i = 0; i < 10; i++) { - var child = new PIXI.DisplayObject(); - children.push(child); - container.addChild(child); - } - - for (i = 0; i < children.length; i++) { - expect(i).to.eql(container.getChildIndex(children[i])); - } - }); - - it('throws error when trying to get index of not a child', function() { - var container = new PIXI.DisplayObjectContainer(); - var child = new PIXI.DisplayObject(); - - expect(function() { container.getChildIndex(child); }).to.throw(); - }); - - it('Sets child index', function() { - var container = new PIXI.DisplayObjectContainer(); - var children = []; - - for (var i = 0; i < 10; i++) { - var child = new PIXI.DisplayObject(); - children.push(child); - container.addChild(child); - } - children.reverse(); - - for (i = 0; i < children.length; i++) { - container.setChildIndex(children[i], i); - expect(i).to.eql(container.getChildIndex(children[i])); - } - }); - - it('throws error when trying to set incorect index', function() { - var container = new PIXI.DisplayObjectContainer(); - var child = new PIXI.DisplayObject(); - container.addChild(child); - - expect(function() { container.setChildIndex(child, -1); }).to.throw(); - expect(function() { container.setChildIndex(child, 1); }).to.throw(); - }); -}); diff --git a/test/unit/pixi/display/MovieClip.js b/test/unit/pixi/display/MovieClip.js deleted file mode 100644 index f3c6c6a..0000000 --- a/test/unit/pixi/display/MovieClip.js +++ /dev/null @@ -1,33 +0,0 @@ -describe('pixi/display/MovieClip', function () { - 'use strict'; - - var expect = chai.expect; - var MovieClip = PIXI.MovieClip; - var Texture = PIXI.Texture; - - it('Module exists', function () { - expect(MovieClip).to.be.a('function'); - }); - - it('Confirm new instance', function (done) { - var texture = Texture.fromImage('/base/test/textures/SpriteSheet-Explosion.png'); - var obj = new MovieClip([texture]); - - pixi_display_Sprite_confirmNew(obj, done); - - expect(obj).to.be.an.instanceof(MovieClip); - expect(obj).to.respondTo('stop'); - expect(obj).to.respondTo('play'); - expect(obj).to.respondTo('gotoAndStop'); - expect(obj).to.respondTo('gotoAndPlay'); - expect(obj).to.respondTo('updateTransform'); - - expect(obj).to.have.deep.property('textures.length', 1); - expect(obj).to.have.deep.property('textures[0]', texture); - expect(obj).to.have.property('animationSpeed', 1); - expect(obj).to.have.property('loop', true); - expect(obj).to.have.property('onComplete', null); - expect(obj).to.have.property('currentFrame', 0); - expect(obj).to.have.property('playing', false); - }); -}); diff --git a/test/unit/pixi/display/Sprite.js b/test/unit/pixi/display/Sprite.js deleted file mode 100644 index 30c8076..0000000 --- a/test/unit/pixi/display/Sprite.js +++ /dev/null @@ -1,28 +0,0 @@ -describe('pixi/display/Sprite', function () { - 'use strict'; - - var expect = chai.expect; - var Sprite = PIXI.Sprite; - var Texture = PIXI.Texture; - - it('Module exists', function () { - expect(Sprite).to.be.a('function'); - expect(PIXI).to.have.deep.property('blendModes.NORMAL', 0); - expect(PIXI).to.have.deep.property('blendModes.ADD', 1); - expect(PIXI).to.have.deep.property('blendModes.MULTIPLY', 2); - expect(PIXI).to.have.deep.property('blendModes.SCREEN', 3); - }); - - - it('Members exist', function () { - expect(Sprite).itself.to.respondTo('fromImage'); - expect(Sprite).itself.to.respondTo('fromFrame'); - }); - - it('Confirm new instance', function (done) { - var texture = Texture.fromImage('/base/test/textures/SpriteSheet-Aliens.png'); - var obj = new Sprite(texture); - - pixi_display_Sprite_confirmNew(obj, done); - }); -}); diff --git a/test/unit/pixi/display/Stage.js b/test/unit/pixi/display/Stage.js deleted file mode 100644 index 6974c2e..0000000 --- a/test/unit/pixi/display/Stage.js +++ /dev/null @@ -1,49 +0,0 @@ -describe('pixi/display/Stage', function () { - 'use strict'; - - var expect = chai.expect; - var Stage = PIXI.Stage; - var InteractionManager = PIXI.InteractionManager; - var Rectangle = PIXI.Rectangle; - - it('Module exists', function () { - expect(Stage).to.be.a('function'); - }); - - it('Confirm new instance', function () { - var obj = new Stage(null, true); - - pixi_display_DisplayObjectContainer_confirmNew(obj); - - expect(obj).to.be.an.instanceof(Stage); - expect(obj).to.respondTo('updateTransform'); - expect(obj).to.respondTo('setBackgroundColor'); - expect(obj).to.respondTo('getMousePosition'); - // FIXME: duplicate member in DisplayObject - pixi_core_Matrix_confirmNewMatrix(obj.worldTransform); - // FIXME: convert arg to bool in constructor - expect(obj).to.have.property('interactive', true); - - expect(obj).to.have.property('interactionManager') - .and.to.be.an.instanceof(InteractionManager) - .and.to.have.property('stage', obj); - - expect(obj).to.have.property('dirty', true); - - expect(obj).to.have.property('stage', obj); - - expect(obj).to.have.property('hitArea') - .and.to.be.an.instanceof(Rectangle); - pixi_core_Rectangle_confirm(obj.hitArea, 0, 0, 100000, 100000); - - expect(obj).to.have.property('backgroundColor', 0x000000); - expect(obj).to.have.deep.property('backgroundColorSplit.length', 3); - expect(obj).to.have.deep.property('backgroundColorSplit[0]', 0); - expect(obj).to.have.deep.property('backgroundColorSplit[1]', 0); - expect(obj).to.have.deep.property('backgroundColorSplit[2]', 0); - expect(obj).to.have.property('backgroundColorString', '#000000'); - - - expect(obj).to.have.property('worldVisible', true); - }); -}); diff --git a/test/unit/pixi/extras/Rope.js b/test/unit/pixi/extras/Rope.js deleted file mode 100644 index 05885ac..0000000 --- a/test/unit/pixi/extras/Rope.js +++ /dev/null @@ -1,31 +0,0 @@ -describe('pixi/extras/Rope', function () { - 'use strict'; - - var expect = chai.expect; - var Rope = PIXI.Rope; - var Texture = PIXI.Texture; - var Point = PIXI.Point; - - it('Module exists', function () { - expect(Rope).to.be.a('function'); - }); - - it('Confirm new instance', function () { - - var texture = Texture.fromImage('/base/test/textures/bunny.png'); - - // TODO-Alvin - // Same as Strip - - // var obj = new Rope(texture, [new Point(), new Point(5, 10), new Point(10, 20)]); - - // pixi_extras_Strip_confirmNew(obj); - - // expect(obj).to.be.an.instanceof(Rope); - // expect(obj).to.respondTo('refresh'); - // expect(obj).to.respondTo('updateTransform'); - // expect(obj).to.respondTo('setTexture'); - - // TODO: Test properties - }); -}); diff --git a/test/unit/pixi/extras/Spine.js b/test/unit/pixi/extras/Spine.js deleted file mode 100644 index 0708bc0..0000000 --- a/test/unit/pixi/extras/Spine.js +++ /dev/null @@ -1,10 +0,0 @@ -describe('pixi/extras/Spine', function () { - 'use strict'; - - var expect = chai.expect; - var Spine = PIXI.Spine; - - it('Module exists', function () { - expect(Spine).to.be.a('function'); - }); -}); diff --git a/test/unit/pixi/extras/Strip.js b/test/unit/pixi/extras/Strip.js deleted file mode 100644 index 230af90..0000000 --- a/test/unit/pixi/extras/Strip.js +++ /dev/null @@ -1,26 +0,0 @@ -describe('pixi/extras/Strip', function () { - 'use strict'; - - var expect = chai.expect; - var Strip = PIXI.Strip; - var Texture = PIXI.Texture; - - it('Module exists', function () { - expect(Strip).to.be.a('function'); - }); - - it('Confirm new instance', function () { - - - // TODO-Alvin - // We tweaked it to make it pass the tests, but the whole strip class needs - // to be re-coded - - var texture = Texture.fromImage('/base/test/textures/bunny.png'); - - // var obj = new Strip(texture, 20, 10000); - - - // pixi_extras_Strip_confirmNew(obj); - }); -}); diff --git a/test/unit/pixi/extras/TilingSprite.js b/test/unit/pixi/extras/TilingSprite.js deleted file mode 100644 index 56aea14..0000000 --- a/test/unit/pixi/extras/TilingSprite.js +++ /dev/null @@ -1,24 +0,0 @@ -describe('pixi/extras/TilingSprite', function () { - 'use strict'; - - var expect = chai.expect; - var TilingSprite = PIXI.TilingSprite; - var Texture = PIXI.Texture; - - it('Module exists', function () { - expect(TilingSprite).to.be.a('function'); - }); - - it('Confirm new instance', function () { - var texture = Texture.fromImage('/base/test/textures/bunny.png'); - var obj = new TilingSprite(texture, 6000, 12000); - - pixi_display_DisplayObjectContainer_confirmNew(obj); - - expect(obj).to.be.an.instanceof(TilingSprite); - expect(obj).to.respondTo('setTexture'); - expect(obj).to.respondTo('onTextureUpdate'); - - // TODO: Test properties - }); -}); diff --git a/test/unit/pixi/filters/FilterBlock.js b/test/unit/pixi/filters/FilterBlock.js deleted file mode 100644 index 870cec0..0000000 --- a/test/unit/pixi/filters/FilterBlock.js +++ /dev/null @@ -1,10 +0,0 @@ -describe('pixi/filters/FilterBlock', function () { - 'use strict'; - - var expect = chai.expect; - var FilterBlock = PIXI.FilterBlock; - - it('Module exists', function () { - expect(FilterBlock).to.be.a('function'); - }); -}); diff --git a/test/unit/pixi/loaders/AssetLoader.js b/test/unit/pixi/loaders/AssetLoader.js deleted file mode 100644 index a0aa0b5..0000000 --- a/test/unit/pixi/loaders/AssetLoader.js +++ /dev/null @@ -1,10 +0,0 @@ -describe('pixi/loaders/AssetLoader', function () { - 'use strict'; - - var expect = chai.expect; - var AssetLoader = PIXI.AssetLoader; - - it('Module exists', function () { - expect(AssetLoader).to.be.a('function'); - }); -}); diff --git a/test/unit/pixi/loaders/BitmapFontLoader.js b/test/unit/pixi/loaders/BitmapFontLoader.js deleted file mode 100644 index 046f018..0000000 --- a/test/unit/pixi/loaders/BitmapFontLoader.js +++ /dev/null @@ -1,9 +0,0 @@ -describe('pixi/loaders/BitmapFontLoader', function () { - 'use strict'; - - var expect = chai.expect; - - it('Module exists', function () { - expect(PIXI.BitmapFontLoader).to.be.a('function'); - }); -}); diff --git a/test/unit/pixi-v2/InteractionManager.js b/test/unit/pixi-v2/InteractionManager.js new file mode 100644 index 0000000..ed3001f --- /dev/null +++ b/test/unit/pixi-v2/InteractionManager.js @@ -0,0 +1,10 @@ +describe('pixi/InteractionManager', function () { + 'use strict'; + + var expect = chai.expect; + var InteractionManager = PIXI.InteractionManager; + + it('Module exists', function () { + expect(InteractionManager).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/Pixi.js b/test/unit/pixi-v2/Pixi.js new file mode 100644 index 0000000..27debc1 --- /dev/null +++ b/test/unit/pixi-v2/Pixi.js @@ -0,0 +1,9 @@ +describe('pixi/Pixi', function () { + 'use strict'; + + var expect = chai.expect; + + it('Module exists', function () { + expect(global).to.have.property('PIXI').and.to.be.an('object'); + }); +}); diff --git a/test/unit/pixi-v2/core/Circle.js b/test/unit/pixi-v2/core/Circle.js new file mode 100644 index 0000000..fbcfa17 --- /dev/null +++ b/test/unit/pixi-v2/core/Circle.js @@ -0,0 +1,21 @@ +describe('pixi/core/Circle', function () { + 'use strict'; + + var expect = chai.expect; + var Circle = PIXI.Circle; + + it('Module exists', function () { + expect(Circle).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Circle(); + pixi_core_Circle_confirmNewCircle(obj); + }); + + it("getBounds should return Rectangle that bounds the circle", function() { + var obj = new Circle(100, 250, 50); + var bounds = obj.getBounds(); + pixi_core_Circle_isBoundedByRectangle(obj, bounds); + }); +}); diff --git a/test/unit/pixi-v2/core/Ellipse.js b/test/unit/pixi-v2/core/Ellipse.js new file mode 100644 index 0000000..026b56f --- /dev/null +++ b/test/unit/pixi-v2/core/Ellipse.js @@ -0,0 +1,24 @@ +describe('pixi/core/Ellipse', function () { + 'use strict'; + + var expect = chai.expect; + var Ellipse = PIXI.Ellipse; + + it('Module exists', function () { + expect(Ellipse).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Ellipse(); + + expect(obj).to.be.an.instanceof(Ellipse); + expect(obj).to.respondTo('clone'); + expect(obj).to.respondTo('contains'); + expect(obj).to.respondTo('getBounds'); + + expect(obj).to.have.property('x', 0); + expect(obj).to.have.property('y', 0); + expect(obj).to.have.property('width', 0); + expect(obj).to.have.property('height', 0); + }); +}); diff --git a/test/unit/pixi-v2/core/Matrix.js b/test/unit/pixi-v2/core/Matrix.js new file mode 100644 index 0000000..da75e2e --- /dev/null +++ b/test/unit/pixi-v2/core/Matrix.js @@ -0,0 +1,14 @@ +describe('pixi/core/Matrix', function () { + 'use strict'; + + var expect = chai.expect; + + it('Matrix exists', function () { + expect(PIXI.Matrix).to.be.an('function'); + }); + + it('Confirm new Matrix', function () { + var matrix = new PIXI.Matrix(); + pixi_core_Matrix_confirmNewMatrix(matrix); + }); +}); diff --git a/test/unit/pixi-v2/core/Point.js b/test/unit/pixi-v2/core/Point.js new file mode 100644 index 0000000..c4d5163 --- /dev/null +++ b/test/unit/pixi-v2/core/Point.js @@ -0,0 +1,15 @@ +describe('pixi/core/Point', function () { + 'use strict'; + + var expect = chai.expect; + var Point = PIXI.Point; + + it('Module exists', function () { + expect(Point).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Point(); + pixi_core_Point_confirm(obj, 0, 0); + }); +}); diff --git a/test/unit/pixi-v2/core/Polygon.js b/test/unit/pixi-v2/core/Polygon.js new file mode 100644 index 0000000..dc8c918 --- /dev/null +++ b/test/unit/pixi-v2/core/Polygon.js @@ -0,0 +1,20 @@ +describe('pixi/core/Polygon', function () { + 'use strict'; + + var expect = chai.expect; + var Polygon = PIXI.Polygon; + + it('Module exists', function () { + expect(Polygon).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Polygon(); + + expect(obj).to.be.an.instanceof(Polygon); + expect(obj).to.respondTo('clone'); + expect(obj).to.respondTo('contains'); + + expect(obj).to.have.deep.property('points.length', 0); + }); +}); diff --git a/test/unit/pixi-v2/core/Rectangle.js b/test/unit/pixi-v2/core/Rectangle.js new file mode 100644 index 0000000..d43316e --- /dev/null +++ b/test/unit/pixi-v2/core/Rectangle.js @@ -0,0 +1,15 @@ +describe('pixi/core/Rectangle', function () { + 'use strict'; + + var expect = chai.expect; + var Rectangle = PIXI.Rectangle; + + it('Module exists', function () { + expect(Rectangle).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var rect = new Rectangle(); + pixi_core_Rectangle_confirm(rect, 0, 0, 0, 0); + }); +}); diff --git a/test/unit/pixi-v2/display/DisplayObject.js b/test/unit/pixi-v2/display/DisplayObject.js new file mode 100644 index 0000000..044acf8 --- /dev/null +++ b/test/unit/pixi-v2/display/DisplayObject.js @@ -0,0 +1,21 @@ +describe('pixi/display/DisplayObject', function () { + 'use strict'; + + var expect = chai.expect; + var DisplayObject = PIXI.DisplayObject; + + it('Module exists', function () { + expect(DisplayObject).to.be.a('function'); + // expect(PIXI).to.have.property('visibleCount', 0); + }); + + it('Confirm new instance', function () { + var obj = new DisplayObject(); + + pixi_display_DisplayObject_confirmNew(obj); + expect(obj).to.have.property('hitArea', null); + expect(obj).to.have.property('interactive', false); + expect(obj).to.have.property('renderable', false); + expect(obj).to.have.property('stage', null); + }); +}); diff --git a/test/unit/pixi-v2/display/DisplayObjectContainer.js b/test/unit/pixi-v2/display/DisplayObjectContainer.js new file mode 100644 index 0000000..15a3376 --- /dev/null +++ b/test/unit/pixi-v2/display/DisplayObjectContainer.js @@ -0,0 +1,67 @@ +describe('pixi/display/DisplayObjectContainer', function () { + 'use strict'; + + var expect = chai.expect; + var DisplayObjectContainer = PIXI.DisplayObjectContainer; + + it('Module exists', function () { + expect(DisplayObjectContainer).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new DisplayObjectContainer(); + + pixi_display_DisplayObjectContainer_confirmNew(obj); + expect(obj).to.have.property('hitArea', null); + expect(obj).to.have.property('interactive', false); + expect(obj).to.have.property('renderable', false); + expect(obj).to.have.property('stage', null); + }); + + it('Gets child index', function() { + var container = new PIXI.DisplayObjectContainer(); + var children = []; + for (var i = 0; i < 10; i++) { + var child = new PIXI.DisplayObject(); + children.push(child); + container.addChild(child); + } + + for (i = 0; i < children.length; i++) { + expect(i).to.eql(container.getChildIndex(children[i])); + } + }); + + it('throws error when trying to get index of not a child', function() { + var container = new PIXI.DisplayObjectContainer(); + var child = new PIXI.DisplayObject(); + + expect(function() { container.getChildIndex(child); }).to.throw(); + }); + + it('Sets child index', function() { + var container = new PIXI.DisplayObjectContainer(); + var children = []; + + for (var i = 0; i < 10; i++) { + var child = new PIXI.DisplayObject(); + children.push(child); + container.addChild(child); + } + children.reverse(); + + for (i = 0; i < children.length; i++) { + container.setChildIndex(children[i], i); + expect(i).to.eql(container.getChildIndex(children[i])); + } + }); + + it('throws error when trying to set incorect index', function() { + var container = new PIXI.DisplayObjectContainer(); + var child = new PIXI.DisplayObject(); + container.addChild(child); + + expect(function() { container.setChildIndex(child, -1); }).to.throw(); + expect(function() { container.setChildIndex(child, 1); }).to.throw(); + }); +}); diff --git a/test/unit/pixi-v2/display/MovieClip.js b/test/unit/pixi-v2/display/MovieClip.js new file mode 100644 index 0000000..f3c6c6a --- /dev/null +++ b/test/unit/pixi-v2/display/MovieClip.js @@ -0,0 +1,33 @@ +describe('pixi/display/MovieClip', function () { + 'use strict'; + + var expect = chai.expect; + var MovieClip = PIXI.MovieClip; + var Texture = PIXI.Texture; + + it('Module exists', function () { + expect(MovieClip).to.be.a('function'); + }); + + it('Confirm new instance', function (done) { + var texture = Texture.fromImage('/base/test/textures/SpriteSheet-Explosion.png'); + var obj = new MovieClip([texture]); + + pixi_display_Sprite_confirmNew(obj, done); + + expect(obj).to.be.an.instanceof(MovieClip); + expect(obj).to.respondTo('stop'); + expect(obj).to.respondTo('play'); + expect(obj).to.respondTo('gotoAndStop'); + expect(obj).to.respondTo('gotoAndPlay'); + expect(obj).to.respondTo('updateTransform'); + + expect(obj).to.have.deep.property('textures.length', 1); + expect(obj).to.have.deep.property('textures[0]', texture); + expect(obj).to.have.property('animationSpeed', 1); + expect(obj).to.have.property('loop', true); + expect(obj).to.have.property('onComplete', null); + expect(obj).to.have.property('currentFrame', 0); + expect(obj).to.have.property('playing', false); + }); +}); diff --git a/test/unit/pixi-v2/display/Sprite.js b/test/unit/pixi-v2/display/Sprite.js new file mode 100644 index 0000000..30c8076 --- /dev/null +++ b/test/unit/pixi-v2/display/Sprite.js @@ -0,0 +1,28 @@ +describe('pixi/display/Sprite', function () { + 'use strict'; + + var expect = chai.expect; + var Sprite = PIXI.Sprite; + var Texture = PIXI.Texture; + + it('Module exists', function () { + expect(Sprite).to.be.a('function'); + expect(PIXI).to.have.deep.property('blendModes.NORMAL', 0); + expect(PIXI).to.have.deep.property('blendModes.ADD', 1); + expect(PIXI).to.have.deep.property('blendModes.MULTIPLY', 2); + expect(PIXI).to.have.deep.property('blendModes.SCREEN', 3); + }); + + + it('Members exist', function () { + expect(Sprite).itself.to.respondTo('fromImage'); + expect(Sprite).itself.to.respondTo('fromFrame'); + }); + + it('Confirm new instance', function (done) { + var texture = Texture.fromImage('/base/test/textures/SpriteSheet-Aliens.png'); + var obj = new Sprite(texture); + + pixi_display_Sprite_confirmNew(obj, done); + }); +}); diff --git a/test/unit/pixi-v2/display/Stage.js b/test/unit/pixi-v2/display/Stage.js new file mode 100644 index 0000000..6974c2e --- /dev/null +++ b/test/unit/pixi-v2/display/Stage.js @@ -0,0 +1,49 @@ +describe('pixi/display/Stage', function () { + 'use strict'; + + var expect = chai.expect; + var Stage = PIXI.Stage; + var InteractionManager = PIXI.InteractionManager; + var Rectangle = PIXI.Rectangle; + + it('Module exists', function () { + expect(Stage).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Stage(null, true); + + pixi_display_DisplayObjectContainer_confirmNew(obj); + + expect(obj).to.be.an.instanceof(Stage); + expect(obj).to.respondTo('updateTransform'); + expect(obj).to.respondTo('setBackgroundColor'); + expect(obj).to.respondTo('getMousePosition'); + // FIXME: duplicate member in DisplayObject + pixi_core_Matrix_confirmNewMatrix(obj.worldTransform); + // FIXME: convert arg to bool in constructor + expect(obj).to.have.property('interactive', true); + + expect(obj).to.have.property('interactionManager') + .and.to.be.an.instanceof(InteractionManager) + .and.to.have.property('stage', obj); + + expect(obj).to.have.property('dirty', true); + + expect(obj).to.have.property('stage', obj); + + expect(obj).to.have.property('hitArea') + .and.to.be.an.instanceof(Rectangle); + pixi_core_Rectangle_confirm(obj.hitArea, 0, 0, 100000, 100000); + + expect(obj).to.have.property('backgroundColor', 0x000000); + expect(obj).to.have.deep.property('backgroundColorSplit.length', 3); + expect(obj).to.have.deep.property('backgroundColorSplit[0]', 0); + expect(obj).to.have.deep.property('backgroundColorSplit[1]', 0); + expect(obj).to.have.deep.property('backgroundColorSplit[2]', 0); + expect(obj).to.have.property('backgroundColorString', '#000000'); + + + expect(obj).to.have.property('worldVisible', true); + }); +}); diff --git a/test/unit/pixi-v2/extras/Rope.js b/test/unit/pixi-v2/extras/Rope.js new file mode 100644 index 0000000..05885ac --- /dev/null +++ b/test/unit/pixi-v2/extras/Rope.js @@ -0,0 +1,31 @@ +describe('pixi/extras/Rope', function () { + 'use strict'; + + var expect = chai.expect; + var Rope = PIXI.Rope; + var Texture = PIXI.Texture; + var Point = PIXI.Point; + + it('Module exists', function () { + expect(Rope).to.be.a('function'); + }); + + it('Confirm new instance', function () { + + var texture = Texture.fromImage('/base/test/textures/bunny.png'); + + // TODO-Alvin + // Same as Strip + + // var obj = new Rope(texture, [new Point(), new Point(5, 10), new Point(10, 20)]); + + // pixi_extras_Strip_confirmNew(obj); + + // expect(obj).to.be.an.instanceof(Rope); + // expect(obj).to.respondTo('refresh'); + // expect(obj).to.respondTo('updateTransform'); + // expect(obj).to.respondTo('setTexture'); + + // TODO: Test properties + }); +}); diff --git a/test/unit/pixi-v2/extras/Spine.js b/test/unit/pixi-v2/extras/Spine.js new file mode 100644 index 0000000..0708bc0 --- /dev/null +++ b/test/unit/pixi-v2/extras/Spine.js @@ -0,0 +1,10 @@ +describe('pixi/extras/Spine', function () { + 'use strict'; + + var expect = chai.expect; + var Spine = PIXI.Spine; + + it('Module exists', function () { + expect(Spine).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/extras/Strip.js b/test/unit/pixi-v2/extras/Strip.js new file mode 100644 index 0000000..230af90 --- /dev/null +++ b/test/unit/pixi-v2/extras/Strip.js @@ -0,0 +1,26 @@ +describe('pixi/extras/Strip', function () { + 'use strict'; + + var expect = chai.expect; + var Strip = PIXI.Strip; + var Texture = PIXI.Texture; + + it('Module exists', function () { + expect(Strip).to.be.a('function'); + }); + + it('Confirm new instance', function () { + + + // TODO-Alvin + // We tweaked it to make it pass the tests, but the whole strip class needs + // to be re-coded + + var texture = Texture.fromImage('/base/test/textures/bunny.png'); + + // var obj = new Strip(texture, 20, 10000); + + + // pixi_extras_Strip_confirmNew(obj); + }); +}); diff --git a/test/unit/pixi-v2/extras/TilingSprite.js b/test/unit/pixi-v2/extras/TilingSprite.js new file mode 100644 index 0000000..56aea14 --- /dev/null +++ b/test/unit/pixi-v2/extras/TilingSprite.js @@ -0,0 +1,24 @@ +describe('pixi/extras/TilingSprite', function () { + 'use strict'; + + var expect = chai.expect; + var TilingSprite = PIXI.TilingSprite; + var Texture = PIXI.Texture; + + it('Module exists', function () { + expect(TilingSprite).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var texture = Texture.fromImage('/base/test/textures/bunny.png'); + var obj = new TilingSprite(texture, 6000, 12000); + + pixi_display_DisplayObjectContainer_confirmNew(obj); + + expect(obj).to.be.an.instanceof(TilingSprite); + expect(obj).to.respondTo('setTexture'); + expect(obj).to.respondTo('onTextureUpdate'); + + // TODO: Test properties + }); +}); diff --git a/test/unit/pixi-v2/filters/FilterBlock.js b/test/unit/pixi-v2/filters/FilterBlock.js new file mode 100644 index 0000000..870cec0 --- /dev/null +++ b/test/unit/pixi-v2/filters/FilterBlock.js @@ -0,0 +1,10 @@ +describe('pixi/filters/FilterBlock', function () { + 'use strict'; + + var expect = chai.expect; + var FilterBlock = PIXI.FilterBlock; + + it('Module exists', function () { + expect(FilterBlock).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/AssetLoader.js b/test/unit/pixi-v2/loaders/AssetLoader.js new file mode 100644 index 0000000..a0aa0b5 --- /dev/null +++ b/test/unit/pixi-v2/loaders/AssetLoader.js @@ -0,0 +1,10 @@ +describe('pixi/loaders/AssetLoader', function () { + 'use strict'; + + var expect = chai.expect; + var AssetLoader = PIXI.AssetLoader; + + it('Module exists', function () { + expect(AssetLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/BitmapFontLoader.js b/test/unit/pixi-v2/loaders/BitmapFontLoader.js new file mode 100644 index 0000000..046f018 --- /dev/null +++ b/test/unit/pixi-v2/loaders/BitmapFontLoader.js @@ -0,0 +1,9 @@ +describe('pixi/loaders/BitmapFontLoader', function () { + 'use strict'; + + var expect = chai.expect; + + it('Module exists', function () { + expect(PIXI.BitmapFontLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/ImageLoader.js b/test/unit/pixi-v2/loaders/ImageLoader.js new file mode 100644 index 0000000..8b1f556 --- /dev/null +++ b/test/unit/pixi-v2/loaders/ImageLoader.js @@ -0,0 +1,10 @@ +describe('pixi/loaders/ImageLoader', function () { + 'use strict'; + + var expect = chai.expect; + var ImageLoader = PIXI.ImageLoader; + + it('Module exists', function () { + expect(ImageLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/JsonLoader.js b/test/unit/pixi-v2/loaders/JsonLoader.js new file mode 100644 index 0000000..c577e83 --- /dev/null +++ b/test/unit/pixi-v2/loaders/JsonLoader.js @@ -0,0 +1,10 @@ +describe('pixi/loaders/JsonLoader', function () { + 'use strict'; + + var expect = chai.expect; + var JsonLoader = PIXI.JsonLoader; + + it('Module exists', function () { + expect(JsonLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/SpineLoader.js b/test/unit/pixi-v2/loaders/SpineLoader.js new file mode 100644 index 0000000..fdcc0b8 --- /dev/null +++ b/test/unit/pixi-v2/loaders/SpineLoader.js @@ -0,0 +1,10 @@ +describe('pixi/loaders/SpineLoader', function () { + 'use strict'; + + var expect = chai.expect; + var SpineLoader = PIXI.SpineLoader; + + it('Module exists', function () { + expect(SpineLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/SpriteSheetLoader.js b/test/unit/pixi-v2/loaders/SpriteSheetLoader.js new file mode 100644 index 0000000..57beb27 --- /dev/null +++ b/test/unit/pixi-v2/loaders/SpriteSheetLoader.js @@ -0,0 +1,10 @@ +describe('pixi/loaders/SpriteSheetLoader', function () { + 'use strict'; + + var expect = chai.expect; + var SpriteSheetLoader = PIXI.SpriteSheetLoader; + + it('Module exists', function () { + expect(SpriteSheetLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/primitives/Graphics.js b/test/unit/pixi-v2/primitives/Graphics.js new file mode 100644 index 0000000..f3849eb --- /dev/null +++ b/test/unit/pixi-v2/primitives/Graphics.js @@ -0,0 +1,44 @@ +describe('pixi/primitives/Graphics', function () { + 'use strict'; + + var expect = chai.expect; + var Graphics = PIXI.Graphics; + + it('Module exists', function () { + expect(Graphics).to.be.a('function'); + + expect(Graphics).itself.to.have.property('POLY', 0); + expect(Graphics).itself.to.have.property('RECT', 1); + expect(Graphics).itself.to.have.property('CIRC', 2); + expect(Graphics).itself.to.have.property('ELIP', 3); + expect(Graphics).itself.to.have.property('RREC', 4); + }); + + it('Confirm new instance', function () { + var obj = new Graphics(); + + pixi_display_DisplayObjectContainer_confirmNew(obj); + + expect(obj).to.be.an.instanceof(Graphics); + expect(obj).to.respondTo('lineStyle'); + expect(obj).to.respondTo('lineStyle'); + expect(obj).to.respondTo('moveTo'); + expect(obj).to.respondTo('lineTo'); + expect(obj).to.respondTo('beginFill'); + expect(obj).to.respondTo('endFill'); + expect(obj).to.respondTo('drawRect'); + // expect(obj).to.respondTo('drawRoundedRect'); + expect(obj).to.respondTo('drawCircle'); + expect(obj).to.respondTo('drawEllipse'); + expect(obj).to.respondTo('clear'); + + expect(obj).to.have.property('renderable', true); + expect(obj).to.have.property('fillAlpha', 1); + expect(obj).to.have.property('lineWidth', 0); + expect(obj).to.have.property('width', 0); + expect(obj).to.have.property('height', 0); + expect(obj).to.have.property('lineColor', 0); + expect(obj).to.have.deep.property('graphicsData.length', 0); + // expect(obj).to.have.deep.property('currentPath.points.length', 0); + }); +}); diff --git a/test/unit/pixi-v2/renderers/canvas/CanvasGraphics.js b/test/unit/pixi-v2/renderers/canvas/CanvasGraphics.js new file mode 100644 index 0000000..8f44472 --- /dev/null +++ b/test/unit/pixi-v2/renderers/canvas/CanvasGraphics.js @@ -0,0 +1,15 @@ +describe('renders/canvas/CanvasGraphics', function () { + 'use strict'; + + var expect = chai.expect; + var CanvasGraphics = PIXI.CanvasGraphics; + + it('Module exists', function () { + expect(CanvasGraphics).to.be.a('function'); + }); + + it('Members exist', function () { + expect(CanvasGraphics).itself.to.respondTo('renderGraphics'); + expect(CanvasGraphics).itself.to.respondTo('renderGraphicsMask'); + }); +}); diff --git a/test/unit/pixi-v2/renderers/canvas/CanvasRenderer.js b/test/unit/pixi-v2/renderers/canvas/CanvasRenderer.js new file mode 100644 index 0000000..1646444 --- /dev/null +++ b/test/unit/pixi-v2/renderers/canvas/CanvasRenderer.js @@ -0,0 +1,36 @@ +describe('renderers/canvas/CanvasRenderer', function () { + 'use strict'; + + var expect = chai.expect; + var CanvasRenderer = PIXI.CanvasRenderer; + + it('Module exists', function () { + expect(CanvasRenderer).to.be.a('function'); + }); + + describe('.autoResize', function () { + it('Should automatically resize view if enabled', function () { + var renderer = new CanvasRenderer(200, 200, { + autoResize: true + }); + + expect(renderer.view.style.width).to.equal('200px'); + }); + + it('Should not automatically resize view if disabled', function () { + var renderer = new CanvasRenderer(200, 200, { + autoResize: false + }); + + expect(renderer.view.style.width).to.equal(''); + }); + + it('Should not automatically resize view if not specified', function () { + var renderer = new CanvasRenderer(200, 200, { + resolution: 2 + }); + + expect(renderer.view.style.width).to.equal(''); + }); + }); +}); diff --git a/test/unit/pixi-v2/renderers/webgl/WebGLGraphics.js b/test/unit/pixi-v2/renderers/webgl/WebGLGraphics.js new file mode 100644 index 0000000..5867b28 --- /dev/null +++ b/test/unit/pixi-v2/renderers/webgl/WebGLGraphics.js @@ -0,0 +1,20 @@ +describe('renderers/wegbl/WebGLGraphics', function () { + 'use strict'; + + var expect = chai.expect; + var WebGLGraphics = PIXI.WebGLGraphics; + + it('Module exists', function () { + expect(WebGLGraphics).to.be.a('function'); + }); + + it('Members exist', function () { + expect(WebGLGraphics).itself.to.respondTo('renderGraphics'); + expect(WebGLGraphics).itself.to.respondTo('updateGraphics'); + expect(WebGLGraphics).itself.to.respondTo('buildRectangle'); + expect(WebGLGraphics).itself.to.respondTo('buildRoundedRectangle'); + expect(WebGLGraphics).itself.to.respondTo('buildCircle'); + expect(WebGLGraphics).itself.to.respondTo('buildLine'); + expect(WebGLGraphics).itself.to.respondTo('buildPoly'); + }); +}); diff --git a/test/unit/pixi-v2/renderers/webgl/WebGLRenderer.js b/test/unit/pixi-v2/renderers/webgl/WebGLRenderer.js new file mode 100644 index 0000000..1680a80 --- /dev/null +++ b/test/unit/pixi-v2/renderers/webgl/WebGLRenderer.js @@ -0,0 +1,49 @@ +describe('renderers/webgl/WebGLRenderer', function () { + 'use strict'; + + var expect = chai.expect; + var WebGLRenderer = PIXI.WebGLRenderer; + + it('Module exists', function () { + expect(WebGLRenderer).to.be.a('function'); + }); + + // Skip tests if WebGL is not available (WebGL not supported in Travis CI) + try { + var renderer = new WebGLRenderer(400, 300, {}); + renderer.destroy(); + } catch (error) { + return; + } + + it('Destroy renderer', function () { + var renderer = new WebGLRenderer(400, 300, {}); + renderer.destroy(); + }); + + describe('.autoResize', function () { + it('Should automatically resize view if enabled', function () { + var renderer = new WebGLRenderer(200, 200, { + autoResize: true + }); + + expect(renderer.view.style.width).to.equal('200px'); + }); + + it('Should not automatically resize view if disabled', function () { + var renderer = new WebGLRenderer(200, 200, { + autoResize: false + }); + + expect(renderer.view.style.width).to.equal(''); + }); + + it('Should not automatically resize view if not specified', function () { + var renderer = new WebGLRenderer(200, 200, { + resolution: 2 + }); + + expect(renderer.view.style.width).to.equal(''); + }); + }); +}); diff --git a/test/unit/pixi-v2/renderers/webgl/WebGLShaders.js b/test/unit/pixi-v2/renderers/webgl/WebGLShaders.js new file mode 100644 index 0000000..6e33e4f --- /dev/null +++ b/test/unit/pixi-v2/renderers/webgl/WebGLShaders.js @@ -0,0 +1,13 @@ +describe('renderers/webgl/WebGLShaders', function () { + 'use strict'; + + var expect = chai.expect; + + it('Module members exist', function () { + + expect(PIXI).to.respondTo('CompileVertexShader'); + expect(PIXI).to.respondTo('CompileFragmentShader'); + expect(PIXI).to.respondTo('_CompileShader'); + expect(PIXI).to.respondTo('compileProgram'); + }); +}); diff --git a/test/unit/pixi-v2/renderers/webgl/WebGLSpriteBatch.js b/test/unit/pixi-v2/renderers/webgl/WebGLSpriteBatch.js new file mode 100644 index 0000000..e662b63 --- /dev/null +++ b/test/unit/pixi-v2/renderers/webgl/WebGLSpriteBatch.js @@ -0,0 +1,10 @@ +describe('renderers/webgl/utils/WebGLSpriteBatch', function () { + 'use strict'; + + var expect = chai.expect; + var WebGLSpriteBatch = PIXI.WebGLSpriteBatch; + + it('Module exists', function () { + expect(WebGLSpriteBatch).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/text/BitmapText.js b/test/unit/pixi-v2/text/BitmapText.js new file mode 100644 index 0000000..9388e3d --- /dev/null +++ b/test/unit/pixi-v2/text/BitmapText.js @@ -0,0 +1,10 @@ +describe('pixi/text/BitmapText', function () { + 'use strict'; + + var expect = chai.expect; + var BitmapText = PIXI.BitmapText; + + it('Module exists', function () { + expect(BitmapText).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/text/Text.js b/test/unit/pixi-v2/text/Text.js new file mode 100644 index 0000000..9bc9ac5 --- /dev/null +++ b/test/unit/pixi-v2/text/Text.js @@ -0,0 +1,10 @@ +describe('pixi/text/Text', function () { + 'use strict'; + + var expect = chai.expect; + var Text = PIXI.Text; + + it('Module exists', function () { + expect(Text).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/textures/BaseTexture.js b/test/unit/pixi-v2/textures/BaseTexture.js new file mode 100644 index 0000000..502b724 --- /dev/null +++ b/test/unit/pixi-v2/textures/BaseTexture.js @@ -0,0 +1,11 @@ +describe('pixi/textures/BaseTexture', function () { + 'use strict'; + + var expect = chai.expect; + var BaseTexture = PIXI.BaseTexture; + + it('Module exists', function () { + expect(BaseTexture).to.be.a('function'); + expect(PIXI).to.have.property('BaseTextureCache').and.to.be.an('object'); + }); +}); diff --git a/test/unit/pixi-v2/textures/RenderTexture.js b/test/unit/pixi-v2/textures/RenderTexture.js new file mode 100644 index 0000000..96acdb4 --- /dev/null +++ b/test/unit/pixi-v2/textures/RenderTexture.js @@ -0,0 +1,15 @@ +describe('pixi/textures/RenderTexture', function () { + 'use strict'; + + var expect = chai.expect; + var RenderTexture = PIXI.RenderTexture; + + it('Module exists', function () { + expect(RenderTexture).to.be.a('function'); + }); + + it('Confirm new instance', function (done) { + var texture = new RenderTexture(100, 100, new PIXI.CanvasRenderer()); + pixi_textures_RenderTexture_confirmNew(texture, done); + }); +}); diff --git a/test/unit/pixi-v2/textures/Texture.js b/test/unit/pixi-v2/textures/Texture.js new file mode 100644 index 0000000..090f64d --- /dev/null +++ b/test/unit/pixi-v2/textures/Texture.js @@ -0,0 +1,26 @@ +describe('pixi/textures/Texture', function () { + 'use strict'; + + var expect = chai.expect; + var Texture = PIXI.Texture; + + it('Module exists', function () { + expect(Texture).to.be.a('function'); + expect(PIXI).to.have.property('TextureCache').and.to.be.an('object'); + }); + + it('Members exist', function () { + expect(Texture).itself.to.respondTo('fromImage'); + expect(Texture).itself.to.respondTo('fromFrame'); + expect(Texture).itself.to.respondTo('fromCanvas'); + expect(Texture).itself.to.respondTo('addTextureToCache'); + expect(Texture).itself.to.respondTo('removeTextureFromCache'); + + // expect(Texture).itself.to.have.deep.property('frameUpdates.length', 0); + }); + + it('Confirm new instance', function (done) { + var texture = Texture.fromImage('/base/test/textures/bunny.png'); + pixi_textures_Texture_confirmNew(texture, done); + }); +}); diff --git a/test/unit/pixi-v2/utils/Detector.js b/test/unit/pixi-v2/utils/Detector.js new file mode 100644 index 0000000..4cf6008 --- /dev/null +++ b/test/unit/pixi-v2/utils/Detector.js @@ -0,0 +1,10 @@ +describe('pixi/utils/Detector', function () { + 'use strict'; + + var expect = chai.expect; + var autoDetectRenderer = PIXI.autoDetectRenderer; + + it('Module exists', function () { + expect(autoDetectRenderer).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/utils/EventTarget.js b/test/unit/pixi-v2/utils/EventTarget.js new file mode 100644 index 0000000..1cfc3a4 --- /dev/null +++ b/test/unit/pixi-v2/utils/EventTarget.js @@ -0,0 +1,361 @@ +describe('pixi/utils/EventTarget', function () { + 'use strict'; + + var expect = chai.expect; + + var Clazz, PClazz, obj, pobj, obj2; + beforeEach(function () { + Clazz = function () {}; + PClazz = function () {}; + + PIXI.EventTarget.mixin(Clazz.prototype); + PIXI.EventTarget.mixin(PClazz.prototype); + + obj = new Clazz(); + obj2 = new Clazz(); + pobj = new PClazz(); + + obj.parent = pobj; + obj2.parent = obj; + }); + + it('Module exists', function () { + expect(PIXI.EventTarget).to.be.an('object'); + }); + + it('Confirm new instance', function () { + pixi_utils_EventTarget_confirm(obj); + }); + + it('simple on/emit case works', function () { + var myData = {}; + + obj.on('myevent', function (event) { + pixi_utils_EventTarget_Event_confirm(event, obj, myData); + }); + + obj.emit('myevent', myData); + }); + + it('simple once case works', function () { + var called = 0; + + obj.once('myevent', function() { called++; }); + + obj.emit('myevent'); + obj.emit('myevent'); + obj.emit('myevent'); + obj.emit('myevent'); + obj.emit('myevent'); + + expect(called).to.equal(1); + }); + + it('simple off case works', function (done) { + function onMyEvent() { + done(new Error('Event listener should not have been called')); + } + + obj.on('myevent', onMyEvent); + obj.off('myevent', onMyEvent); + obj.emit('myevent'); + + done(); + }); + + it('simple propagation case works', function (done) { + var myData = {}; + + pobj.on('myevent', function () { + done(); + }); + + obj.emit('myevent'); + }); + + it('simple stopPropagation case works', function (done) { + var myData = {}; + + pobj.on('myevent', function () { + done(new Error('Event listener should not have been called on the parent element')); + }); + + obj.on('myevent', function (evt) { + evt.stopPropagation(); + }); + + obj.emit('myevent'); + + done(); + }); + + it('simple stopImmediatePropagation case works', function (done) { + var myData = {}; + + pobj.on('myevent', function () { + done(new Error('Event listener should not have been called on the parent')); + }); + + obj.on('myevent', function (evt) { + evt.stopImmediatePropagation(); + }); + + obj.on('myevent', function () { + done(new Error('Event listener should not have been called on the second')); + }); + + obj.emit('myevent'); + + done(); + }); + + it('multiple dispatches work properly', function () { + var called = 0; + + function onMyEvent() { + called++; + } + + obj.on('myevent', onMyEvent); + obj.emit('myevent'); + obj.emit('myevent'); + obj.emit('myevent'); + obj.emit('myevent'); + + expect(called).to.equal(4); + }); + + it('multiple events work properly', function () { + var called = 0; + + function onMyEvent() { + called++; + } + + obj.on('myevent1', onMyEvent); + obj.on('myevent2', onMyEvent); + obj.on('myevent3', onMyEvent); + obj.emit('myevent1'); + obj.emit('myevent2'); + obj.emit('myevent3'); + + expect(called).to.equal(3); + }); + + it('multiple events one removed works properly', function () { + var called = 0; + + function onMyEvent() { + called++; + } + + obj.on('myevent1', onMyEvent); + obj.on('myevent2', onMyEvent); + obj.on('myevent3', onMyEvent); + + obj.emit('myevent1'); + obj.emit('myevent2'); + obj.emit('myevent3'); + + obj.off('myevent2', onMyEvent); + + obj.emit('myevent1'); + obj.emit('myevent2'); + obj.emit('myevent3'); + + expect(called).to.equal(5); + }); + + it('multiple handlers for one event with some removed', function () { + var called = 0; + + var onMyEvent = function () { + called++; + }, + onMyEvent2 = function () { + called++; + }; + + // add 2 handlers and confirm they both get called + obj.on('myevent', onMyEvent); + obj.on('myevent', onMyEvent); + obj.on('myevent', onMyEvent2); + obj.on('myevent', onMyEvent2); + + obj.emit('myevent'); + + expect(called).to.equal(4); + + // remove one of the handlers, emit again, then ensure 1 more call is made + obj.off('myevent', onMyEvent); + + obj.emit('myevent'); + + expect(called).to.equal(6); + }); + + it('calls to off without a handler do nothing', function () { + var called = 0; + + var onMyEvent = function () { + called++; + }; + + obj.on('myevent', onMyEvent); + obj.on('myevent', onMyEvent); + + obj.emit('myevent'); + + expect(called).to.equal(2); + + obj.off('myevent'); + + obj.emit('myevent'); + + expect(called).to.equal(4); + + obj.off('myevent', onMyEvent); + + obj.emit('myevent'); + + expect(called).to.equal(4); + }); + + it('handles multiple instances with the same prototype', function () { + var called = 0; + + function onMyEvent(e) { + called++; + } + + obj.on('myevent1', onMyEvent); + obj.on('myevent2', onMyEvent); + + obj2.istwo = true; + obj2.on('myevent1', onMyEvent); + obj2.on('myevent2', onMyEvent); + + obj.emit('myevent1'); + obj.emit('myevent2'); + obj2.emit('myevent1'); + obj2.emit('myevent2'); + + //we emit 4 times, but since obj2 is a child of obj the event should bubble + //up to obj and show up there as well. So the obj2.emit() calls each increment + //the counter twice. + expect(called).to.equal(6); + }); + + it('is backwards compatible with older .dispatchEvent({})', function () { + var called = 0, + data = { + some: 'thing', + hello: true + }; + + function onMyEvent(event) { + pixi_utils_EventTarget_Event_confirm(event, obj, data); + + called++; + } + + obj.on('myevent1', onMyEvent); + obj.on('myevent2', onMyEvent); + obj.on('myevent3', onMyEvent); + + data.type = 'myevent1'; + obj.emit(data); + + data.type = 'myevent2'; + obj.emit(data); + + data.type = 'myevent3'; + obj.emit(data); + + obj.off('myevent2', onMyEvent); + + data.type = 'myevent1'; + obj.emit(data); + + data.type = 'myevent2'; + obj.emit(data); + + data.type = 'myevent3'; + obj.emit(data); + + expect(called).to.equal(5); + }); + + it('is backwards compatible with older .call(this)', function () { + var Fn = function() { + PIXI.EventTarget.call(this); + }, + o = new Fn(); + + pixi_utils_EventTarget_confirm(o); + }); + + it('is backwards compatible with older .addEventListener("")', function () { + var called = 0, + data = { + some: 'thing', + hello: true + }; + + function onMyEvent(event) { + pixi_utils_EventTarget_Event_confirm(event, obj, data); + + called++; + } + + obj.addEventListener('myevent1', onMyEvent); + obj.addEventListener('myevent2', onMyEvent); + obj.addEventListener('myevent3', onMyEvent); + + data.type = 'myevent1'; + obj.emit(data); + + data.type = 'myevent2'; + obj.emit(data); + + data.type = 'myevent3'; + obj.emit(data); + + obj.off('myevent2', onMyEvent); + + data.type = 'myevent1'; + obj.emit(data); + + data.type = 'myevent2'; + obj.emit(data); + + data.type = 'myevent3'; + obj.emit(data); + + expect(called).to.equal(5); + }); + + it('event remove during emit call properly', function () { + var called = 0; + + function cb1() { + called++; + obj.off('myevent', cb1); + } + function cb2() { + called++; + obj.off('myevent', cb2); + } + function cb3() { + called++; + obj.off('myevent', cb3); + } + + obj.on('myevent', cb1); + obj.on('myevent', cb2); + obj.on('myevent', cb3); + obj.emit('myevent', ''); + + expect(called).to.equal(3); + }); +}); diff --git a/test/unit/pixi-v2/utils/Polyk.js b/test/unit/pixi-v2/utils/Polyk.js new file mode 100644 index 0000000..dfc7128 --- /dev/null +++ b/test/unit/pixi-v2/utils/Polyk.js @@ -0,0 +1,14 @@ +describe('pixi/utils/Polyk', function () { + 'use strict'; + + var expect = chai.expect; + var PolyK = PIXI.PolyK; + + it('Module exists', function () { + expect(PolyK).to.be.an('object'); + }); + + it('Members exist', function () { + expect(PolyK).to.respondTo('Triangulate'); + }); +}); diff --git a/test/unit/pixi-v2/utils/Utils.js b/test/unit/pixi-v2/utils/Utils.js new file mode 100644 index 0000000..c97b3c6 --- /dev/null +++ b/test/unit/pixi-v2/utils/Utils.js @@ -0,0 +1,17 @@ +describe('Utils', function () { + 'use strict'; + + var expect = chai.expect; + + it('requestAnimationFrame exists', function () { + expect(global).to.respondTo('requestAnimationFrame'); + }); + + it('cancelAnimationFrame exists', function () { + expect(global).to.respondTo('cancelAnimationFrame'); + }); + + it('requestAnimFrame exists', function () { + expect(global).to.respondTo('requestAnimFrame'); + }); +}); diff --git a/test/unit/pixi/InteractionManager.js b/test/unit/pixi/InteractionManager.js deleted file mode 100644 index ed3001f..0000000 --- a/test/unit/pixi/InteractionManager.js +++ /dev/null @@ -1,10 +0,0 @@ -describe('pixi/InteractionManager', function () { - 'use strict'; - - var expect = chai.expect; - var InteractionManager = PIXI.InteractionManager; - - it('Module exists', function () { - expect(InteractionManager).to.be.a('function'); - }); -}); diff --git a/test/unit/pixi/Pixi.js b/test/unit/pixi/Pixi.js deleted file mode 100644 index 27debc1..0000000 --- a/test/unit/pixi/Pixi.js +++ /dev/null @@ -1,9 +0,0 @@ -describe('pixi/Pixi', function () { - 'use strict'; - - var expect = chai.expect; - - it('Module exists', function () { - expect(global).to.have.property('PIXI').and.to.be.an('object'); - }); -}); diff --git a/test/unit/pixi/core/Circle.js b/test/unit/pixi/core/Circle.js deleted file mode 100644 index fbcfa17..0000000 --- a/test/unit/pixi/core/Circle.js +++ /dev/null @@ -1,21 +0,0 @@ -describe('pixi/core/Circle', function () { - 'use strict'; - - var expect = chai.expect; - var Circle = PIXI.Circle; - - it('Module exists', function () { - expect(Circle).to.be.a('function'); - }); - - it('Confirm new instance', function () { - var obj = new Circle(); - pixi_core_Circle_confirmNewCircle(obj); - }); - - it("getBounds should return Rectangle that bounds the circle", function() { - var obj = new Circle(100, 250, 50); - var bounds = obj.getBounds(); - pixi_core_Circle_isBoundedByRectangle(obj, bounds); - }); -}); diff --git a/test/unit/pixi/core/Ellipse.js b/test/unit/pixi/core/Ellipse.js deleted file mode 100644 index 026b56f..0000000 --- a/test/unit/pixi/core/Ellipse.js +++ /dev/null @@ -1,24 +0,0 @@ -describe('pixi/core/Ellipse', function () { - 'use strict'; - - var expect = chai.expect; - var Ellipse = PIXI.Ellipse; - - it('Module exists', function () { - expect(Ellipse).to.be.a('function'); - }); - - it('Confirm new instance', function () { - var obj = new Ellipse(); - - expect(obj).to.be.an.instanceof(Ellipse); - expect(obj).to.respondTo('clone'); - expect(obj).to.respondTo('contains'); - expect(obj).to.respondTo('getBounds'); - - expect(obj).to.have.property('x', 0); - expect(obj).to.have.property('y', 0); - expect(obj).to.have.property('width', 0); - expect(obj).to.have.property('height', 0); - }); -}); diff --git a/test/unit/pixi/core/Matrix.js b/test/unit/pixi/core/Matrix.js deleted file mode 100644 index da75e2e..0000000 --- a/test/unit/pixi/core/Matrix.js +++ /dev/null @@ -1,14 +0,0 @@ -describe('pixi/core/Matrix', function () { - 'use strict'; - - var expect = chai.expect; - - it('Matrix exists', function () { - expect(PIXI.Matrix).to.be.an('function'); - }); - - it('Confirm new Matrix', function () { - var matrix = new PIXI.Matrix(); - pixi_core_Matrix_confirmNewMatrix(matrix); - }); -}); diff --git a/test/unit/pixi/core/Point.js b/test/unit/pixi/core/Point.js deleted file mode 100644 index c4d5163..0000000 --- a/test/unit/pixi/core/Point.js +++ /dev/null @@ -1,15 +0,0 @@ -describe('pixi/core/Point', function () { - 'use strict'; - - var expect = chai.expect; - var Point = PIXI.Point; - - it('Module exists', function () { - expect(Point).to.be.a('function'); - }); - - it('Confirm new instance', function () { - var obj = new Point(); - pixi_core_Point_confirm(obj, 0, 0); - }); -}); diff --git a/test/unit/pixi/core/Polygon.js b/test/unit/pixi/core/Polygon.js deleted file mode 100644 index dc8c918..0000000 --- a/test/unit/pixi/core/Polygon.js +++ /dev/null @@ -1,20 +0,0 @@ -describe('pixi/core/Polygon', function () { - 'use strict'; - - var expect = chai.expect; - var Polygon = PIXI.Polygon; - - it('Module exists', function () { - expect(Polygon).to.be.a('function'); - }); - - it('Confirm new instance', function () { - var obj = new Polygon(); - - expect(obj).to.be.an.instanceof(Polygon); - expect(obj).to.respondTo('clone'); - expect(obj).to.respondTo('contains'); - - expect(obj).to.have.deep.property('points.length', 0); - }); -}); diff --git a/test/unit/pixi/core/Rectangle.js b/test/unit/pixi/core/Rectangle.js deleted file mode 100644 index d43316e..0000000 --- a/test/unit/pixi/core/Rectangle.js +++ /dev/null @@ -1,15 +0,0 @@ -describe('pixi/core/Rectangle', function () { - 'use strict'; - - var expect = chai.expect; - var Rectangle = PIXI.Rectangle; - - it('Module exists', function () { - expect(Rectangle).to.be.a('function'); - }); - - it('Confirm new instance', function () { - var rect = new Rectangle(); - pixi_core_Rectangle_confirm(rect, 0, 0, 0, 0); - }); -}); diff --git a/test/unit/pixi/display/DisplayObject.js b/test/unit/pixi/display/DisplayObject.js deleted file mode 100644 index 044acf8..0000000 --- a/test/unit/pixi/display/DisplayObject.js +++ /dev/null @@ -1,21 +0,0 @@ -describe('pixi/display/DisplayObject', function () { - 'use strict'; - - var expect = chai.expect; - var DisplayObject = PIXI.DisplayObject; - - it('Module exists', function () { - expect(DisplayObject).to.be.a('function'); - // expect(PIXI).to.have.property('visibleCount', 0); - }); - - it('Confirm new instance', function () { - var obj = new DisplayObject(); - - pixi_display_DisplayObject_confirmNew(obj); - expect(obj).to.have.property('hitArea', null); - expect(obj).to.have.property('interactive', false); - expect(obj).to.have.property('renderable', false); - expect(obj).to.have.property('stage', null); - }); -}); diff --git a/test/unit/pixi/display/DisplayObjectContainer.js b/test/unit/pixi/display/DisplayObjectContainer.js deleted file mode 100644 index 15a3376..0000000 --- a/test/unit/pixi/display/DisplayObjectContainer.js +++ /dev/null @@ -1,67 +0,0 @@ -describe('pixi/display/DisplayObjectContainer', function () { - 'use strict'; - - var expect = chai.expect; - var DisplayObjectContainer = PIXI.DisplayObjectContainer; - - it('Module exists', function () { - expect(DisplayObjectContainer).to.be.a('function'); - }); - - it('Confirm new instance', function () { - var obj = new DisplayObjectContainer(); - - pixi_display_DisplayObjectContainer_confirmNew(obj); - expect(obj).to.have.property('hitArea', null); - expect(obj).to.have.property('interactive', false); - expect(obj).to.have.property('renderable', false); - expect(obj).to.have.property('stage', null); - }); - - it('Gets child index', function() { - var container = new PIXI.DisplayObjectContainer(); - var children = []; - for (var i = 0; i < 10; i++) { - var child = new PIXI.DisplayObject(); - children.push(child); - container.addChild(child); - } - - for (i = 0; i < children.length; i++) { - expect(i).to.eql(container.getChildIndex(children[i])); - } - }); - - it('throws error when trying to get index of not a child', function() { - var container = new PIXI.DisplayObjectContainer(); - var child = new PIXI.DisplayObject(); - - expect(function() { container.getChildIndex(child); }).to.throw(); - }); - - it('Sets child index', function() { - var container = new PIXI.DisplayObjectContainer(); - var children = []; - - for (var i = 0; i < 10; i++) { - var child = new PIXI.DisplayObject(); - children.push(child); - container.addChild(child); - } - children.reverse(); - - for (i = 0; i < children.length; i++) { - container.setChildIndex(children[i], i); - expect(i).to.eql(container.getChildIndex(children[i])); - } - }); - - it('throws error when trying to set incorect index', function() { - var container = new PIXI.DisplayObjectContainer(); - var child = new PIXI.DisplayObject(); - container.addChild(child); - - expect(function() { container.setChildIndex(child, -1); }).to.throw(); - expect(function() { container.setChildIndex(child, 1); }).to.throw(); - }); -}); diff --git a/test/unit/pixi/display/MovieClip.js b/test/unit/pixi/display/MovieClip.js deleted file mode 100644 index f3c6c6a..0000000 --- a/test/unit/pixi/display/MovieClip.js +++ /dev/null @@ -1,33 +0,0 @@ -describe('pixi/display/MovieClip', function () { - 'use strict'; - - var expect = chai.expect; - var MovieClip = PIXI.MovieClip; - var Texture = PIXI.Texture; - - it('Module exists', function () { - expect(MovieClip).to.be.a('function'); - }); - - it('Confirm new instance', function (done) { - var texture = Texture.fromImage('/base/test/textures/SpriteSheet-Explosion.png'); - var obj = new MovieClip([texture]); - - pixi_display_Sprite_confirmNew(obj, done); - - expect(obj).to.be.an.instanceof(MovieClip); - expect(obj).to.respondTo('stop'); - expect(obj).to.respondTo('play'); - expect(obj).to.respondTo('gotoAndStop'); - expect(obj).to.respondTo('gotoAndPlay'); - expect(obj).to.respondTo('updateTransform'); - - expect(obj).to.have.deep.property('textures.length', 1); - expect(obj).to.have.deep.property('textures[0]', texture); - expect(obj).to.have.property('animationSpeed', 1); - expect(obj).to.have.property('loop', true); - expect(obj).to.have.property('onComplete', null); - expect(obj).to.have.property('currentFrame', 0); - expect(obj).to.have.property('playing', false); - }); -}); diff --git a/test/unit/pixi/display/Sprite.js b/test/unit/pixi/display/Sprite.js deleted file mode 100644 index 30c8076..0000000 --- a/test/unit/pixi/display/Sprite.js +++ /dev/null @@ -1,28 +0,0 @@ -describe('pixi/display/Sprite', function () { - 'use strict'; - - var expect = chai.expect; - var Sprite = PIXI.Sprite; - var Texture = PIXI.Texture; - - it('Module exists', function () { - expect(Sprite).to.be.a('function'); - expect(PIXI).to.have.deep.property('blendModes.NORMAL', 0); - expect(PIXI).to.have.deep.property('blendModes.ADD', 1); - expect(PIXI).to.have.deep.property('blendModes.MULTIPLY', 2); - expect(PIXI).to.have.deep.property('blendModes.SCREEN', 3); - }); - - - it('Members exist', function () { - expect(Sprite).itself.to.respondTo('fromImage'); - expect(Sprite).itself.to.respondTo('fromFrame'); - }); - - it('Confirm new instance', function (done) { - var texture = Texture.fromImage('/base/test/textures/SpriteSheet-Aliens.png'); - var obj = new Sprite(texture); - - pixi_display_Sprite_confirmNew(obj, done); - }); -}); diff --git a/test/unit/pixi/display/Stage.js b/test/unit/pixi/display/Stage.js deleted file mode 100644 index 6974c2e..0000000 --- a/test/unit/pixi/display/Stage.js +++ /dev/null @@ -1,49 +0,0 @@ -describe('pixi/display/Stage', function () { - 'use strict'; - - var expect = chai.expect; - var Stage = PIXI.Stage; - var InteractionManager = PIXI.InteractionManager; - var Rectangle = PIXI.Rectangle; - - it('Module exists', function () { - expect(Stage).to.be.a('function'); - }); - - it('Confirm new instance', function () { - var obj = new Stage(null, true); - - pixi_display_DisplayObjectContainer_confirmNew(obj); - - expect(obj).to.be.an.instanceof(Stage); - expect(obj).to.respondTo('updateTransform'); - expect(obj).to.respondTo('setBackgroundColor'); - expect(obj).to.respondTo('getMousePosition'); - // FIXME: duplicate member in DisplayObject - pixi_core_Matrix_confirmNewMatrix(obj.worldTransform); - // FIXME: convert arg to bool in constructor - expect(obj).to.have.property('interactive', true); - - expect(obj).to.have.property('interactionManager') - .and.to.be.an.instanceof(InteractionManager) - .and.to.have.property('stage', obj); - - expect(obj).to.have.property('dirty', true); - - expect(obj).to.have.property('stage', obj); - - expect(obj).to.have.property('hitArea') - .and.to.be.an.instanceof(Rectangle); - pixi_core_Rectangle_confirm(obj.hitArea, 0, 0, 100000, 100000); - - expect(obj).to.have.property('backgroundColor', 0x000000); - expect(obj).to.have.deep.property('backgroundColorSplit.length', 3); - expect(obj).to.have.deep.property('backgroundColorSplit[0]', 0); - expect(obj).to.have.deep.property('backgroundColorSplit[1]', 0); - expect(obj).to.have.deep.property('backgroundColorSplit[2]', 0); - expect(obj).to.have.property('backgroundColorString', '#000000'); - - - expect(obj).to.have.property('worldVisible', true); - }); -}); diff --git a/test/unit/pixi/extras/Rope.js b/test/unit/pixi/extras/Rope.js deleted file mode 100644 index 05885ac..0000000 --- a/test/unit/pixi/extras/Rope.js +++ /dev/null @@ -1,31 +0,0 @@ -describe('pixi/extras/Rope', function () { - 'use strict'; - - var expect = chai.expect; - var Rope = PIXI.Rope; - var Texture = PIXI.Texture; - var Point = PIXI.Point; - - it('Module exists', function () { - expect(Rope).to.be.a('function'); - }); - - it('Confirm new instance', function () { - - var texture = Texture.fromImage('/base/test/textures/bunny.png'); - - // TODO-Alvin - // Same as Strip - - // var obj = new Rope(texture, [new Point(), new Point(5, 10), new Point(10, 20)]); - - // pixi_extras_Strip_confirmNew(obj); - - // expect(obj).to.be.an.instanceof(Rope); - // expect(obj).to.respondTo('refresh'); - // expect(obj).to.respondTo('updateTransform'); - // expect(obj).to.respondTo('setTexture'); - - // TODO: Test properties - }); -}); diff --git a/test/unit/pixi/extras/Spine.js b/test/unit/pixi/extras/Spine.js deleted file mode 100644 index 0708bc0..0000000 --- a/test/unit/pixi/extras/Spine.js +++ /dev/null @@ -1,10 +0,0 @@ -describe('pixi/extras/Spine', function () { - 'use strict'; - - var expect = chai.expect; - var Spine = PIXI.Spine; - - it('Module exists', function () { - expect(Spine).to.be.a('function'); - }); -}); diff --git a/test/unit/pixi/extras/Strip.js b/test/unit/pixi/extras/Strip.js deleted file mode 100644 index 230af90..0000000 --- a/test/unit/pixi/extras/Strip.js +++ /dev/null @@ -1,26 +0,0 @@ -describe('pixi/extras/Strip', function () { - 'use strict'; - - var expect = chai.expect; - var Strip = PIXI.Strip; - var Texture = PIXI.Texture; - - it('Module exists', function () { - expect(Strip).to.be.a('function'); - }); - - it('Confirm new instance', function () { - - - // TODO-Alvin - // We tweaked it to make it pass the tests, but the whole strip class needs - // to be re-coded - - var texture = Texture.fromImage('/base/test/textures/bunny.png'); - - // var obj = new Strip(texture, 20, 10000); - - - // pixi_extras_Strip_confirmNew(obj); - }); -}); diff --git a/test/unit/pixi/extras/TilingSprite.js b/test/unit/pixi/extras/TilingSprite.js deleted file mode 100644 index 56aea14..0000000 --- a/test/unit/pixi/extras/TilingSprite.js +++ /dev/null @@ -1,24 +0,0 @@ -describe('pixi/extras/TilingSprite', function () { - 'use strict'; - - var expect = chai.expect; - var TilingSprite = PIXI.TilingSprite; - var Texture = PIXI.Texture; - - it('Module exists', function () { - expect(TilingSprite).to.be.a('function'); - }); - - it('Confirm new instance', function () { - var texture = Texture.fromImage('/base/test/textures/bunny.png'); - var obj = new TilingSprite(texture, 6000, 12000); - - pixi_display_DisplayObjectContainer_confirmNew(obj); - - expect(obj).to.be.an.instanceof(TilingSprite); - expect(obj).to.respondTo('setTexture'); - expect(obj).to.respondTo('onTextureUpdate'); - - // TODO: Test properties - }); -}); diff --git a/test/unit/pixi/filters/FilterBlock.js b/test/unit/pixi/filters/FilterBlock.js deleted file mode 100644 index 870cec0..0000000 --- a/test/unit/pixi/filters/FilterBlock.js +++ /dev/null @@ -1,10 +0,0 @@ -describe('pixi/filters/FilterBlock', function () { - 'use strict'; - - var expect = chai.expect; - var FilterBlock = PIXI.FilterBlock; - - it('Module exists', function () { - expect(FilterBlock).to.be.a('function'); - }); -}); diff --git a/test/unit/pixi/loaders/AssetLoader.js b/test/unit/pixi/loaders/AssetLoader.js deleted file mode 100644 index a0aa0b5..0000000 --- a/test/unit/pixi/loaders/AssetLoader.js +++ /dev/null @@ -1,10 +0,0 @@ -describe('pixi/loaders/AssetLoader', function () { - 'use strict'; - - var expect = chai.expect; - var AssetLoader = PIXI.AssetLoader; - - it('Module exists', function () { - expect(AssetLoader).to.be.a('function'); - }); -}); diff --git a/test/unit/pixi/loaders/BitmapFontLoader.js b/test/unit/pixi/loaders/BitmapFontLoader.js deleted file mode 100644 index 046f018..0000000 --- a/test/unit/pixi/loaders/BitmapFontLoader.js +++ /dev/null @@ -1,9 +0,0 @@ -describe('pixi/loaders/BitmapFontLoader', function () { - 'use strict'; - - var expect = chai.expect; - - it('Module exists', function () { - expect(PIXI.BitmapFontLoader).to.be.a('function'); - }); -}); diff --git a/test/unit/pixi/loaders/ImageLoader.js b/test/unit/pixi/loaders/ImageLoader.js deleted file mode 100644 index 8b1f556..0000000 --- a/test/unit/pixi/loaders/ImageLoader.js +++ /dev/null @@ -1,10 +0,0 @@ -describe('pixi/loaders/ImageLoader', function () { - 'use strict'; - - var expect = chai.expect; - var ImageLoader = PIXI.ImageLoader; - - it('Module exists', function () { - expect(ImageLoader).to.be.a('function'); - }); -}); diff --git a/test/unit/pixi-v2/InteractionManager.js b/test/unit/pixi-v2/InteractionManager.js new file mode 100644 index 0000000..ed3001f --- /dev/null +++ b/test/unit/pixi-v2/InteractionManager.js @@ -0,0 +1,10 @@ +describe('pixi/InteractionManager', function () { + 'use strict'; + + var expect = chai.expect; + var InteractionManager = PIXI.InteractionManager; + + it('Module exists', function () { + expect(InteractionManager).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/Pixi.js b/test/unit/pixi-v2/Pixi.js new file mode 100644 index 0000000..27debc1 --- /dev/null +++ b/test/unit/pixi-v2/Pixi.js @@ -0,0 +1,9 @@ +describe('pixi/Pixi', function () { + 'use strict'; + + var expect = chai.expect; + + it('Module exists', function () { + expect(global).to.have.property('PIXI').and.to.be.an('object'); + }); +}); diff --git a/test/unit/pixi-v2/core/Circle.js b/test/unit/pixi-v2/core/Circle.js new file mode 100644 index 0000000..fbcfa17 --- /dev/null +++ b/test/unit/pixi-v2/core/Circle.js @@ -0,0 +1,21 @@ +describe('pixi/core/Circle', function () { + 'use strict'; + + var expect = chai.expect; + var Circle = PIXI.Circle; + + it('Module exists', function () { + expect(Circle).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Circle(); + pixi_core_Circle_confirmNewCircle(obj); + }); + + it("getBounds should return Rectangle that bounds the circle", function() { + var obj = new Circle(100, 250, 50); + var bounds = obj.getBounds(); + pixi_core_Circle_isBoundedByRectangle(obj, bounds); + }); +}); diff --git a/test/unit/pixi-v2/core/Ellipse.js b/test/unit/pixi-v2/core/Ellipse.js new file mode 100644 index 0000000..026b56f --- /dev/null +++ b/test/unit/pixi-v2/core/Ellipse.js @@ -0,0 +1,24 @@ +describe('pixi/core/Ellipse', function () { + 'use strict'; + + var expect = chai.expect; + var Ellipse = PIXI.Ellipse; + + it('Module exists', function () { + expect(Ellipse).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Ellipse(); + + expect(obj).to.be.an.instanceof(Ellipse); + expect(obj).to.respondTo('clone'); + expect(obj).to.respondTo('contains'); + expect(obj).to.respondTo('getBounds'); + + expect(obj).to.have.property('x', 0); + expect(obj).to.have.property('y', 0); + expect(obj).to.have.property('width', 0); + expect(obj).to.have.property('height', 0); + }); +}); diff --git a/test/unit/pixi-v2/core/Matrix.js b/test/unit/pixi-v2/core/Matrix.js new file mode 100644 index 0000000..da75e2e --- /dev/null +++ b/test/unit/pixi-v2/core/Matrix.js @@ -0,0 +1,14 @@ +describe('pixi/core/Matrix', function () { + 'use strict'; + + var expect = chai.expect; + + it('Matrix exists', function () { + expect(PIXI.Matrix).to.be.an('function'); + }); + + it('Confirm new Matrix', function () { + var matrix = new PIXI.Matrix(); + pixi_core_Matrix_confirmNewMatrix(matrix); + }); +}); diff --git a/test/unit/pixi-v2/core/Point.js b/test/unit/pixi-v2/core/Point.js new file mode 100644 index 0000000..c4d5163 --- /dev/null +++ b/test/unit/pixi-v2/core/Point.js @@ -0,0 +1,15 @@ +describe('pixi/core/Point', function () { + 'use strict'; + + var expect = chai.expect; + var Point = PIXI.Point; + + it('Module exists', function () { + expect(Point).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Point(); + pixi_core_Point_confirm(obj, 0, 0); + }); +}); diff --git a/test/unit/pixi-v2/core/Polygon.js b/test/unit/pixi-v2/core/Polygon.js new file mode 100644 index 0000000..dc8c918 --- /dev/null +++ b/test/unit/pixi-v2/core/Polygon.js @@ -0,0 +1,20 @@ +describe('pixi/core/Polygon', function () { + 'use strict'; + + var expect = chai.expect; + var Polygon = PIXI.Polygon; + + it('Module exists', function () { + expect(Polygon).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Polygon(); + + expect(obj).to.be.an.instanceof(Polygon); + expect(obj).to.respondTo('clone'); + expect(obj).to.respondTo('contains'); + + expect(obj).to.have.deep.property('points.length', 0); + }); +}); diff --git a/test/unit/pixi-v2/core/Rectangle.js b/test/unit/pixi-v2/core/Rectangle.js new file mode 100644 index 0000000..d43316e --- /dev/null +++ b/test/unit/pixi-v2/core/Rectangle.js @@ -0,0 +1,15 @@ +describe('pixi/core/Rectangle', function () { + 'use strict'; + + var expect = chai.expect; + var Rectangle = PIXI.Rectangle; + + it('Module exists', function () { + expect(Rectangle).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var rect = new Rectangle(); + pixi_core_Rectangle_confirm(rect, 0, 0, 0, 0); + }); +}); diff --git a/test/unit/pixi-v2/display/DisplayObject.js b/test/unit/pixi-v2/display/DisplayObject.js new file mode 100644 index 0000000..044acf8 --- /dev/null +++ b/test/unit/pixi-v2/display/DisplayObject.js @@ -0,0 +1,21 @@ +describe('pixi/display/DisplayObject', function () { + 'use strict'; + + var expect = chai.expect; + var DisplayObject = PIXI.DisplayObject; + + it('Module exists', function () { + expect(DisplayObject).to.be.a('function'); + // expect(PIXI).to.have.property('visibleCount', 0); + }); + + it('Confirm new instance', function () { + var obj = new DisplayObject(); + + pixi_display_DisplayObject_confirmNew(obj); + expect(obj).to.have.property('hitArea', null); + expect(obj).to.have.property('interactive', false); + expect(obj).to.have.property('renderable', false); + expect(obj).to.have.property('stage', null); + }); +}); diff --git a/test/unit/pixi-v2/display/DisplayObjectContainer.js b/test/unit/pixi-v2/display/DisplayObjectContainer.js new file mode 100644 index 0000000..15a3376 --- /dev/null +++ b/test/unit/pixi-v2/display/DisplayObjectContainer.js @@ -0,0 +1,67 @@ +describe('pixi/display/DisplayObjectContainer', function () { + 'use strict'; + + var expect = chai.expect; + var DisplayObjectContainer = PIXI.DisplayObjectContainer; + + it('Module exists', function () { + expect(DisplayObjectContainer).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new DisplayObjectContainer(); + + pixi_display_DisplayObjectContainer_confirmNew(obj); + expect(obj).to.have.property('hitArea', null); + expect(obj).to.have.property('interactive', false); + expect(obj).to.have.property('renderable', false); + expect(obj).to.have.property('stage', null); + }); + + it('Gets child index', function() { + var container = new PIXI.DisplayObjectContainer(); + var children = []; + for (var i = 0; i < 10; i++) { + var child = new PIXI.DisplayObject(); + children.push(child); + container.addChild(child); + } + + for (i = 0; i < children.length; i++) { + expect(i).to.eql(container.getChildIndex(children[i])); + } + }); + + it('throws error when trying to get index of not a child', function() { + var container = new PIXI.DisplayObjectContainer(); + var child = new PIXI.DisplayObject(); + + expect(function() { container.getChildIndex(child); }).to.throw(); + }); + + it('Sets child index', function() { + var container = new PIXI.DisplayObjectContainer(); + var children = []; + + for (var i = 0; i < 10; i++) { + var child = new PIXI.DisplayObject(); + children.push(child); + container.addChild(child); + } + children.reverse(); + + for (i = 0; i < children.length; i++) { + container.setChildIndex(children[i], i); + expect(i).to.eql(container.getChildIndex(children[i])); + } + }); + + it('throws error when trying to set incorect index', function() { + var container = new PIXI.DisplayObjectContainer(); + var child = new PIXI.DisplayObject(); + container.addChild(child); + + expect(function() { container.setChildIndex(child, -1); }).to.throw(); + expect(function() { container.setChildIndex(child, 1); }).to.throw(); + }); +}); diff --git a/test/unit/pixi-v2/display/MovieClip.js b/test/unit/pixi-v2/display/MovieClip.js new file mode 100644 index 0000000..f3c6c6a --- /dev/null +++ b/test/unit/pixi-v2/display/MovieClip.js @@ -0,0 +1,33 @@ +describe('pixi/display/MovieClip', function () { + 'use strict'; + + var expect = chai.expect; + var MovieClip = PIXI.MovieClip; + var Texture = PIXI.Texture; + + it('Module exists', function () { + expect(MovieClip).to.be.a('function'); + }); + + it('Confirm new instance', function (done) { + var texture = Texture.fromImage('/base/test/textures/SpriteSheet-Explosion.png'); + var obj = new MovieClip([texture]); + + pixi_display_Sprite_confirmNew(obj, done); + + expect(obj).to.be.an.instanceof(MovieClip); + expect(obj).to.respondTo('stop'); + expect(obj).to.respondTo('play'); + expect(obj).to.respondTo('gotoAndStop'); + expect(obj).to.respondTo('gotoAndPlay'); + expect(obj).to.respondTo('updateTransform'); + + expect(obj).to.have.deep.property('textures.length', 1); + expect(obj).to.have.deep.property('textures[0]', texture); + expect(obj).to.have.property('animationSpeed', 1); + expect(obj).to.have.property('loop', true); + expect(obj).to.have.property('onComplete', null); + expect(obj).to.have.property('currentFrame', 0); + expect(obj).to.have.property('playing', false); + }); +}); diff --git a/test/unit/pixi-v2/display/Sprite.js b/test/unit/pixi-v2/display/Sprite.js new file mode 100644 index 0000000..30c8076 --- /dev/null +++ b/test/unit/pixi-v2/display/Sprite.js @@ -0,0 +1,28 @@ +describe('pixi/display/Sprite', function () { + 'use strict'; + + var expect = chai.expect; + var Sprite = PIXI.Sprite; + var Texture = PIXI.Texture; + + it('Module exists', function () { + expect(Sprite).to.be.a('function'); + expect(PIXI).to.have.deep.property('blendModes.NORMAL', 0); + expect(PIXI).to.have.deep.property('blendModes.ADD', 1); + expect(PIXI).to.have.deep.property('blendModes.MULTIPLY', 2); + expect(PIXI).to.have.deep.property('blendModes.SCREEN', 3); + }); + + + it('Members exist', function () { + expect(Sprite).itself.to.respondTo('fromImage'); + expect(Sprite).itself.to.respondTo('fromFrame'); + }); + + it('Confirm new instance', function (done) { + var texture = Texture.fromImage('/base/test/textures/SpriteSheet-Aliens.png'); + var obj = new Sprite(texture); + + pixi_display_Sprite_confirmNew(obj, done); + }); +}); diff --git a/test/unit/pixi-v2/display/Stage.js b/test/unit/pixi-v2/display/Stage.js new file mode 100644 index 0000000..6974c2e --- /dev/null +++ b/test/unit/pixi-v2/display/Stage.js @@ -0,0 +1,49 @@ +describe('pixi/display/Stage', function () { + 'use strict'; + + var expect = chai.expect; + var Stage = PIXI.Stage; + var InteractionManager = PIXI.InteractionManager; + var Rectangle = PIXI.Rectangle; + + it('Module exists', function () { + expect(Stage).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Stage(null, true); + + pixi_display_DisplayObjectContainer_confirmNew(obj); + + expect(obj).to.be.an.instanceof(Stage); + expect(obj).to.respondTo('updateTransform'); + expect(obj).to.respondTo('setBackgroundColor'); + expect(obj).to.respondTo('getMousePosition'); + // FIXME: duplicate member in DisplayObject + pixi_core_Matrix_confirmNewMatrix(obj.worldTransform); + // FIXME: convert arg to bool in constructor + expect(obj).to.have.property('interactive', true); + + expect(obj).to.have.property('interactionManager') + .and.to.be.an.instanceof(InteractionManager) + .and.to.have.property('stage', obj); + + expect(obj).to.have.property('dirty', true); + + expect(obj).to.have.property('stage', obj); + + expect(obj).to.have.property('hitArea') + .and.to.be.an.instanceof(Rectangle); + pixi_core_Rectangle_confirm(obj.hitArea, 0, 0, 100000, 100000); + + expect(obj).to.have.property('backgroundColor', 0x000000); + expect(obj).to.have.deep.property('backgroundColorSplit.length', 3); + expect(obj).to.have.deep.property('backgroundColorSplit[0]', 0); + expect(obj).to.have.deep.property('backgroundColorSplit[1]', 0); + expect(obj).to.have.deep.property('backgroundColorSplit[2]', 0); + expect(obj).to.have.property('backgroundColorString', '#000000'); + + + expect(obj).to.have.property('worldVisible', true); + }); +}); diff --git a/test/unit/pixi-v2/extras/Rope.js b/test/unit/pixi-v2/extras/Rope.js new file mode 100644 index 0000000..05885ac --- /dev/null +++ b/test/unit/pixi-v2/extras/Rope.js @@ -0,0 +1,31 @@ +describe('pixi/extras/Rope', function () { + 'use strict'; + + var expect = chai.expect; + var Rope = PIXI.Rope; + var Texture = PIXI.Texture; + var Point = PIXI.Point; + + it('Module exists', function () { + expect(Rope).to.be.a('function'); + }); + + it('Confirm new instance', function () { + + var texture = Texture.fromImage('/base/test/textures/bunny.png'); + + // TODO-Alvin + // Same as Strip + + // var obj = new Rope(texture, [new Point(), new Point(5, 10), new Point(10, 20)]); + + // pixi_extras_Strip_confirmNew(obj); + + // expect(obj).to.be.an.instanceof(Rope); + // expect(obj).to.respondTo('refresh'); + // expect(obj).to.respondTo('updateTransform'); + // expect(obj).to.respondTo('setTexture'); + + // TODO: Test properties + }); +}); diff --git a/test/unit/pixi-v2/extras/Spine.js b/test/unit/pixi-v2/extras/Spine.js new file mode 100644 index 0000000..0708bc0 --- /dev/null +++ b/test/unit/pixi-v2/extras/Spine.js @@ -0,0 +1,10 @@ +describe('pixi/extras/Spine', function () { + 'use strict'; + + var expect = chai.expect; + var Spine = PIXI.Spine; + + it('Module exists', function () { + expect(Spine).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/extras/Strip.js b/test/unit/pixi-v2/extras/Strip.js new file mode 100644 index 0000000..230af90 --- /dev/null +++ b/test/unit/pixi-v2/extras/Strip.js @@ -0,0 +1,26 @@ +describe('pixi/extras/Strip', function () { + 'use strict'; + + var expect = chai.expect; + var Strip = PIXI.Strip; + var Texture = PIXI.Texture; + + it('Module exists', function () { + expect(Strip).to.be.a('function'); + }); + + it('Confirm new instance', function () { + + + // TODO-Alvin + // We tweaked it to make it pass the tests, but the whole strip class needs + // to be re-coded + + var texture = Texture.fromImage('/base/test/textures/bunny.png'); + + // var obj = new Strip(texture, 20, 10000); + + + // pixi_extras_Strip_confirmNew(obj); + }); +}); diff --git a/test/unit/pixi-v2/extras/TilingSprite.js b/test/unit/pixi-v2/extras/TilingSprite.js new file mode 100644 index 0000000..56aea14 --- /dev/null +++ b/test/unit/pixi-v2/extras/TilingSprite.js @@ -0,0 +1,24 @@ +describe('pixi/extras/TilingSprite', function () { + 'use strict'; + + var expect = chai.expect; + var TilingSprite = PIXI.TilingSprite; + var Texture = PIXI.Texture; + + it('Module exists', function () { + expect(TilingSprite).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var texture = Texture.fromImage('/base/test/textures/bunny.png'); + var obj = new TilingSprite(texture, 6000, 12000); + + pixi_display_DisplayObjectContainer_confirmNew(obj); + + expect(obj).to.be.an.instanceof(TilingSprite); + expect(obj).to.respondTo('setTexture'); + expect(obj).to.respondTo('onTextureUpdate'); + + // TODO: Test properties + }); +}); diff --git a/test/unit/pixi-v2/filters/FilterBlock.js b/test/unit/pixi-v2/filters/FilterBlock.js new file mode 100644 index 0000000..870cec0 --- /dev/null +++ b/test/unit/pixi-v2/filters/FilterBlock.js @@ -0,0 +1,10 @@ +describe('pixi/filters/FilterBlock', function () { + 'use strict'; + + var expect = chai.expect; + var FilterBlock = PIXI.FilterBlock; + + it('Module exists', function () { + expect(FilterBlock).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/AssetLoader.js b/test/unit/pixi-v2/loaders/AssetLoader.js new file mode 100644 index 0000000..a0aa0b5 --- /dev/null +++ b/test/unit/pixi-v2/loaders/AssetLoader.js @@ -0,0 +1,10 @@ +describe('pixi/loaders/AssetLoader', function () { + 'use strict'; + + var expect = chai.expect; + var AssetLoader = PIXI.AssetLoader; + + it('Module exists', function () { + expect(AssetLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/BitmapFontLoader.js b/test/unit/pixi-v2/loaders/BitmapFontLoader.js new file mode 100644 index 0000000..046f018 --- /dev/null +++ b/test/unit/pixi-v2/loaders/BitmapFontLoader.js @@ -0,0 +1,9 @@ +describe('pixi/loaders/BitmapFontLoader', function () { + 'use strict'; + + var expect = chai.expect; + + it('Module exists', function () { + expect(PIXI.BitmapFontLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/ImageLoader.js b/test/unit/pixi-v2/loaders/ImageLoader.js new file mode 100644 index 0000000..8b1f556 --- /dev/null +++ b/test/unit/pixi-v2/loaders/ImageLoader.js @@ -0,0 +1,10 @@ +describe('pixi/loaders/ImageLoader', function () { + 'use strict'; + + var expect = chai.expect; + var ImageLoader = PIXI.ImageLoader; + + it('Module exists', function () { + expect(ImageLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/JsonLoader.js b/test/unit/pixi-v2/loaders/JsonLoader.js new file mode 100644 index 0000000..c577e83 --- /dev/null +++ b/test/unit/pixi-v2/loaders/JsonLoader.js @@ -0,0 +1,10 @@ +describe('pixi/loaders/JsonLoader', function () { + 'use strict'; + + var expect = chai.expect; + var JsonLoader = PIXI.JsonLoader; + + it('Module exists', function () { + expect(JsonLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/SpineLoader.js b/test/unit/pixi-v2/loaders/SpineLoader.js new file mode 100644 index 0000000..fdcc0b8 --- /dev/null +++ b/test/unit/pixi-v2/loaders/SpineLoader.js @@ -0,0 +1,10 @@ +describe('pixi/loaders/SpineLoader', function () { + 'use strict'; + + var expect = chai.expect; + var SpineLoader = PIXI.SpineLoader; + + it('Module exists', function () { + expect(SpineLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/SpriteSheetLoader.js b/test/unit/pixi-v2/loaders/SpriteSheetLoader.js new file mode 100644 index 0000000..57beb27 --- /dev/null +++ b/test/unit/pixi-v2/loaders/SpriteSheetLoader.js @@ -0,0 +1,10 @@ +describe('pixi/loaders/SpriteSheetLoader', function () { + 'use strict'; + + var expect = chai.expect; + var SpriteSheetLoader = PIXI.SpriteSheetLoader; + + it('Module exists', function () { + expect(SpriteSheetLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/primitives/Graphics.js b/test/unit/pixi-v2/primitives/Graphics.js new file mode 100644 index 0000000..f3849eb --- /dev/null +++ b/test/unit/pixi-v2/primitives/Graphics.js @@ -0,0 +1,44 @@ +describe('pixi/primitives/Graphics', function () { + 'use strict'; + + var expect = chai.expect; + var Graphics = PIXI.Graphics; + + it('Module exists', function () { + expect(Graphics).to.be.a('function'); + + expect(Graphics).itself.to.have.property('POLY', 0); + expect(Graphics).itself.to.have.property('RECT', 1); + expect(Graphics).itself.to.have.property('CIRC', 2); + expect(Graphics).itself.to.have.property('ELIP', 3); + expect(Graphics).itself.to.have.property('RREC', 4); + }); + + it('Confirm new instance', function () { + var obj = new Graphics(); + + pixi_display_DisplayObjectContainer_confirmNew(obj); + + expect(obj).to.be.an.instanceof(Graphics); + expect(obj).to.respondTo('lineStyle'); + expect(obj).to.respondTo('lineStyle'); + expect(obj).to.respondTo('moveTo'); + expect(obj).to.respondTo('lineTo'); + expect(obj).to.respondTo('beginFill'); + expect(obj).to.respondTo('endFill'); + expect(obj).to.respondTo('drawRect'); + // expect(obj).to.respondTo('drawRoundedRect'); + expect(obj).to.respondTo('drawCircle'); + expect(obj).to.respondTo('drawEllipse'); + expect(obj).to.respondTo('clear'); + + expect(obj).to.have.property('renderable', true); + expect(obj).to.have.property('fillAlpha', 1); + expect(obj).to.have.property('lineWidth', 0); + expect(obj).to.have.property('width', 0); + expect(obj).to.have.property('height', 0); + expect(obj).to.have.property('lineColor', 0); + expect(obj).to.have.deep.property('graphicsData.length', 0); + // expect(obj).to.have.deep.property('currentPath.points.length', 0); + }); +}); diff --git a/test/unit/pixi-v2/renderers/canvas/CanvasGraphics.js b/test/unit/pixi-v2/renderers/canvas/CanvasGraphics.js new file mode 100644 index 0000000..8f44472 --- /dev/null +++ b/test/unit/pixi-v2/renderers/canvas/CanvasGraphics.js @@ -0,0 +1,15 @@ +describe('renders/canvas/CanvasGraphics', function () { + 'use strict'; + + var expect = chai.expect; + var CanvasGraphics = PIXI.CanvasGraphics; + + it('Module exists', function () { + expect(CanvasGraphics).to.be.a('function'); + }); + + it('Members exist', function () { + expect(CanvasGraphics).itself.to.respondTo('renderGraphics'); + expect(CanvasGraphics).itself.to.respondTo('renderGraphicsMask'); + }); +}); diff --git a/test/unit/pixi-v2/renderers/canvas/CanvasRenderer.js b/test/unit/pixi-v2/renderers/canvas/CanvasRenderer.js new file mode 100644 index 0000000..1646444 --- /dev/null +++ b/test/unit/pixi-v2/renderers/canvas/CanvasRenderer.js @@ -0,0 +1,36 @@ +describe('renderers/canvas/CanvasRenderer', function () { + 'use strict'; + + var expect = chai.expect; + var CanvasRenderer = PIXI.CanvasRenderer; + + it('Module exists', function () { + expect(CanvasRenderer).to.be.a('function'); + }); + + describe('.autoResize', function () { + it('Should automatically resize view if enabled', function () { + var renderer = new CanvasRenderer(200, 200, { + autoResize: true + }); + + expect(renderer.view.style.width).to.equal('200px'); + }); + + it('Should not automatically resize view if disabled', function () { + var renderer = new CanvasRenderer(200, 200, { + autoResize: false + }); + + expect(renderer.view.style.width).to.equal(''); + }); + + it('Should not automatically resize view if not specified', function () { + var renderer = new CanvasRenderer(200, 200, { + resolution: 2 + }); + + expect(renderer.view.style.width).to.equal(''); + }); + }); +}); diff --git a/test/unit/pixi-v2/renderers/webgl/WebGLGraphics.js b/test/unit/pixi-v2/renderers/webgl/WebGLGraphics.js new file mode 100644 index 0000000..5867b28 --- /dev/null +++ b/test/unit/pixi-v2/renderers/webgl/WebGLGraphics.js @@ -0,0 +1,20 @@ +describe('renderers/wegbl/WebGLGraphics', function () { + 'use strict'; + + var expect = chai.expect; + var WebGLGraphics = PIXI.WebGLGraphics; + + it('Module exists', function () { + expect(WebGLGraphics).to.be.a('function'); + }); + + it('Members exist', function () { + expect(WebGLGraphics).itself.to.respondTo('renderGraphics'); + expect(WebGLGraphics).itself.to.respondTo('updateGraphics'); + expect(WebGLGraphics).itself.to.respondTo('buildRectangle'); + expect(WebGLGraphics).itself.to.respondTo('buildRoundedRectangle'); + expect(WebGLGraphics).itself.to.respondTo('buildCircle'); + expect(WebGLGraphics).itself.to.respondTo('buildLine'); + expect(WebGLGraphics).itself.to.respondTo('buildPoly'); + }); +}); diff --git a/test/unit/pixi-v2/renderers/webgl/WebGLRenderer.js b/test/unit/pixi-v2/renderers/webgl/WebGLRenderer.js new file mode 100644 index 0000000..1680a80 --- /dev/null +++ b/test/unit/pixi-v2/renderers/webgl/WebGLRenderer.js @@ -0,0 +1,49 @@ +describe('renderers/webgl/WebGLRenderer', function () { + 'use strict'; + + var expect = chai.expect; + var WebGLRenderer = PIXI.WebGLRenderer; + + it('Module exists', function () { + expect(WebGLRenderer).to.be.a('function'); + }); + + // Skip tests if WebGL is not available (WebGL not supported in Travis CI) + try { + var renderer = new WebGLRenderer(400, 300, {}); + renderer.destroy(); + } catch (error) { + return; + } + + it('Destroy renderer', function () { + var renderer = new WebGLRenderer(400, 300, {}); + renderer.destroy(); + }); + + describe('.autoResize', function () { + it('Should automatically resize view if enabled', function () { + var renderer = new WebGLRenderer(200, 200, { + autoResize: true + }); + + expect(renderer.view.style.width).to.equal('200px'); + }); + + it('Should not automatically resize view if disabled', function () { + var renderer = new WebGLRenderer(200, 200, { + autoResize: false + }); + + expect(renderer.view.style.width).to.equal(''); + }); + + it('Should not automatically resize view if not specified', function () { + var renderer = new WebGLRenderer(200, 200, { + resolution: 2 + }); + + expect(renderer.view.style.width).to.equal(''); + }); + }); +}); diff --git a/test/unit/pixi-v2/renderers/webgl/WebGLShaders.js b/test/unit/pixi-v2/renderers/webgl/WebGLShaders.js new file mode 100644 index 0000000..6e33e4f --- /dev/null +++ b/test/unit/pixi-v2/renderers/webgl/WebGLShaders.js @@ -0,0 +1,13 @@ +describe('renderers/webgl/WebGLShaders', function () { + 'use strict'; + + var expect = chai.expect; + + it('Module members exist', function () { + + expect(PIXI).to.respondTo('CompileVertexShader'); + expect(PIXI).to.respondTo('CompileFragmentShader'); + expect(PIXI).to.respondTo('_CompileShader'); + expect(PIXI).to.respondTo('compileProgram'); + }); +}); diff --git a/test/unit/pixi-v2/renderers/webgl/WebGLSpriteBatch.js b/test/unit/pixi-v2/renderers/webgl/WebGLSpriteBatch.js new file mode 100644 index 0000000..e662b63 --- /dev/null +++ b/test/unit/pixi-v2/renderers/webgl/WebGLSpriteBatch.js @@ -0,0 +1,10 @@ +describe('renderers/webgl/utils/WebGLSpriteBatch', function () { + 'use strict'; + + var expect = chai.expect; + var WebGLSpriteBatch = PIXI.WebGLSpriteBatch; + + it('Module exists', function () { + expect(WebGLSpriteBatch).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/text/BitmapText.js b/test/unit/pixi-v2/text/BitmapText.js new file mode 100644 index 0000000..9388e3d --- /dev/null +++ b/test/unit/pixi-v2/text/BitmapText.js @@ -0,0 +1,10 @@ +describe('pixi/text/BitmapText', function () { + 'use strict'; + + var expect = chai.expect; + var BitmapText = PIXI.BitmapText; + + it('Module exists', function () { + expect(BitmapText).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/text/Text.js b/test/unit/pixi-v2/text/Text.js new file mode 100644 index 0000000..9bc9ac5 --- /dev/null +++ b/test/unit/pixi-v2/text/Text.js @@ -0,0 +1,10 @@ +describe('pixi/text/Text', function () { + 'use strict'; + + var expect = chai.expect; + var Text = PIXI.Text; + + it('Module exists', function () { + expect(Text).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/textures/BaseTexture.js b/test/unit/pixi-v2/textures/BaseTexture.js new file mode 100644 index 0000000..502b724 --- /dev/null +++ b/test/unit/pixi-v2/textures/BaseTexture.js @@ -0,0 +1,11 @@ +describe('pixi/textures/BaseTexture', function () { + 'use strict'; + + var expect = chai.expect; + var BaseTexture = PIXI.BaseTexture; + + it('Module exists', function () { + expect(BaseTexture).to.be.a('function'); + expect(PIXI).to.have.property('BaseTextureCache').and.to.be.an('object'); + }); +}); diff --git a/test/unit/pixi-v2/textures/RenderTexture.js b/test/unit/pixi-v2/textures/RenderTexture.js new file mode 100644 index 0000000..96acdb4 --- /dev/null +++ b/test/unit/pixi-v2/textures/RenderTexture.js @@ -0,0 +1,15 @@ +describe('pixi/textures/RenderTexture', function () { + 'use strict'; + + var expect = chai.expect; + var RenderTexture = PIXI.RenderTexture; + + it('Module exists', function () { + expect(RenderTexture).to.be.a('function'); + }); + + it('Confirm new instance', function (done) { + var texture = new RenderTexture(100, 100, new PIXI.CanvasRenderer()); + pixi_textures_RenderTexture_confirmNew(texture, done); + }); +}); diff --git a/test/unit/pixi-v2/textures/Texture.js b/test/unit/pixi-v2/textures/Texture.js new file mode 100644 index 0000000..090f64d --- /dev/null +++ b/test/unit/pixi-v2/textures/Texture.js @@ -0,0 +1,26 @@ +describe('pixi/textures/Texture', function () { + 'use strict'; + + var expect = chai.expect; + var Texture = PIXI.Texture; + + it('Module exists', function () { + expect(Texture).to.be.a('function'); + expect(PIXI).to.have.property('TextureCache').and.to.be.an('object'); + }); + + it('Members exist', function () { + expect(Texture).itself.to.respondTo('fromImage'); + expect(Texture).itself.to.respondTo('fromFrame'); + expect(Texture).itself.to.respondTo('fromCanvas'); + expect(Texture).itself.to.respondTo('addTextureToCache'); + expect(Texture).itself.to.respondTo('removeTextureFromCache'); + + // expect(Texture).itself.to.have.deep.property('frameUpdates.length', 0); + }); + + it('Confirm new instance', function (done) { + var texture = Texture.fromImage('/base/test/textures/bunny.png'); + pixi_textures_Texture_confirmNew(texture, done); + }); +}); diff --git a/test/unit/pixi-v2/utils/Detector.js b/test/unit/pixi-v2/utils/Detector.js new file mode 100644 index 0000000..4cf6008 --- /dev/null +++ b/test/unit/pixi-v2/utils/Detector.js @@ -0,0 +1,10 @@ +describe('pixi/utils/Detector', function () { + 'use strict'; + + var expect = chai.expect; + var autoDetectRenderer = PIXI.autoDetectRenderer; + + it('Module exists', function () { + expect(autoDetectRenderer).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/utils/EventTarget.js b/test/unit/pixi-v2/utils/EventTarget.js new file mode 100644 index 0000000..1cfc3a4 --- /dev/null +++ b/test/unit/pixi-v2/utils/EventTarget.js @@ -0,0 +1,361 @@ +describe('pixi/utils/EventTarget', function () { + 'use strict'; + + var expect = chai.expect; + + var Clazz, PClazz, obj, pobj, obj2; + beforeEach(function () { + Clazz = function () {}; + PClazz = function () {}; + + PIXI.EventTarget.mixin(Clazz.prototype); + PIXI.EventTarget.mixin(PClazz.prototype); + + obj = new Clazz(); + obj2 = new Clazz(); + pobj = new PClazz(); + + obj.parent = pobj; + obj2.parent = obj; + }); + + it('Module exists', function () { + expect(PIXI.EventTarget).to.be.an('object'); + }); + + it('Confirm new instance', function () { + pixi_utils_EventTarget_confirm(obj); + }); + + it('simple on/emit case works', function () { + var myData = {}; + + obj.on('myevent', function (event) { + pixi_utils_EventTarget_Event_confirm(event, obj, myData); + }); + + obj.emit('myevent', myData); + }); + + it('simple once case works', function () { + var called = 0; + + obj.once('myevent', function() { called++; }); + + obj.emit('myevent'); + obj.emit('myevent'); + obj.emit('myevent'); + obj.emit('myevent'); + obj.emit('myevent'); + + expect(called).to.equal(1); + }); + + it('simple off case works', function (done) { + function onMyEvent() { + done(new Error('Event listener should not have been called')); + } + + obj.on('myevent', onMyEvent); + obj.off('myevent', onMyEvent); + obj.emit('myevent'); + + done(); + }); + + it('simple propagation case works', function (done) { + var myData = {}; + + pobj.on('myevent', function () { + done(); + }); + + obj.emit('myevent'); + }); + + it('simple stopPropagation case works', function (done) { + var myData = {}; + + pobj.on('myevent', function () { + done(new Error('Event listener should not have been called on the parent element')); + }); + + obj.on('myevent', function (evt) { + evt.stopPropagation(); + }); + + obj.emit('myevent'); + + done(); + }); + + it('simple stopImmediatePropagation case works', function (done) { + var myData = {}; + + pobj.on('myevent', function () { + done(new Error('Event listener should not have been called on the parent')); + }); + + obj.on('myevent', function (evt) { + evt.stopImmediatePropagation(); + }); + + obj.on('myevent', function () { + done(new Error('Event listener should not have been called on the second')); + }); + + obj.emit('myevent'); + + done(); + }); + + it('multiple dispatches work properly', function () { + var called = 0; + + function onMyEvent() { + called++; + } + + obj.on('myevent', onMyEvent); + obj.emit('myevent'); + obj.emit('myevent'); + obj.emit('myevent'); + obj.emit('myevent'); + + expect(called).to.equal(4); + }); + + it('multiple events work properly', function () { + var called = 0; + + function onMyEvent() { + called++; + } + + obj.on('myevent1', onMyEvent); + obj.on('myevent2', onMyEvent); + obj.on('myevent3', onMyEvent); + obj.emit('myevent1'); + obj.emit('myevent2'); + obj.emit('myevent3'); + + expect(called).to.equal(3); + }); + + it('multiple events one removed works properly', function () { + var called = 0; + + function onMyEvent() { + called++; + } + + obj.on('myevent1', onMyEvent); + obj.on('myevent2', onMyEvent); + obj.on('myevent3', onMyEvent); + + obj.emit('myevent1'); + obj.emit('myevent2'); + obj.emit('myevent3'); + + obj.off('myevent2', onMyEvent); + + obj.emit('myevent1'); + obj.emit('myevent2'); + obj.emit('myevent3'); + + expect(called).to.equal(5); + }); + + it('multiple handlers for one event with some removed', function () { + var called = 0; + + var onMyEvent = function () { + called++; + }, + onMyEvent2 = function () { + called++; + }; + + // add 2 handlers and confirm they both get called + obj.on('myevent', onMyEvent); + obj.on('myevent', onMyEvent); + obj.on('myevent', onMyEvent2); + obj.on('myevent', onMyEvent2); + + obj.emit('myevent'); + + expect(called).to.equal(4); + + // remove one of the handlers, emit again, then ensure 1 more call is made + obj.off('myevent', onMyEvent); + + obj.emit('myevent'); + + expect(called).to.equal(6); + }); + + it('calls to off without a handler do nothing', function () { + var called = 0; + + var onMyEvent = function () { + called++; + }; + + obj.on('myevent', onMyEvent); + obj.on('myevent', onMyEvent); + + obj.emit('myevent'); + + expect(called).to.equal(2); + + obj.off('myevent'); + + obj.emit('myevent'); + + expect(called).to.equal(4); + + obj.off('myevent', onMyEvent); + + obj.emit('myevent'); + + expect(called).to.equal(4); + }); + + it('handles multiple instances with the same prototype', function () { + var called = 0; + + function onMyEvent(e) { + called++; + } + + obj.on('myevent1', onMyEvent); + obj.on('myevent2', onMyEvent); + + obj2.istwo = true; + obj2.on('myevent1', onMyEvent); + obj2.on('myevent2', onMyEvent); + + obj.emit('myevent1'); + obj.emit('myevent2'); + obj2.emit('myevent1'); + obj2.emit('myevent2'); + + //we emit 4 times, but since obj2 is a child of obj the event should bubble + //up to obj and show up there as well. So the obj2.emit() calls each increment + //the counter twice. + expect(called).to.equal(6); + }); + + it('is backwards compatible with older .dispatchEvent({})', function () { + var called = 0, + data = { + some: 'thing', + hello: true + }; + + function onMyEvent(event) { + pixi_utils_EventTarget_Event_confirm(event, obj, data); + + called++; + } + + obj.on('myevent1', onMyEvent); + obj.on('myevent2', onMyEvent); + obj.on('myevent3', onMyEvent); + + data.type = 'myevent1'; + obj.emit(data); + + data.type = 'myevent2'; + obj.emit(data); + + data.type = 'myevent3'; + obj.emit(data); + + obj.off('myevent2', onMyEvent); + + data.type = 'myevent1'; + obj.emit(data); + + data.type = 'myevent2'; + obj.emit(data); + + data.type = 'myevent3'; + obj.emit(data); + + expect(called).to.equal(5); + }); + + it('is backwards compatible with older .call(this)', function () { + var Fn = function() { + PIXI.EventTarget.call(this); + }, + o = new Fn(); + + pixi_utils_EventTarget_confirm(o); + }); + + it('is backwards compatible with older .addEventListener("")', function () { + var called = 0, + data = { + some: 'thing', + hello: true + }; + + function onMyEvent(event) { + pixi_utils_EventTarget_Event_confirm(event, obj, data); + + called++; + } + + obj.addEventListener('myevent1', onMyEvent); + obj.addEventListener('myevent2', onMyEvent); + obj.addEventListener('myevent3', onMyEvent); + + data.type = 'myevent1'; + obj.emit(data); + + data.type = 'myevent2'; + obj.emit(data); + + data.type = 'myevent3'; + obj.emit(data); + + obj.off('myevent2', onMyEvent); + + data.type = 'myevent1'; + obj.emit(data); + + data.type = 'myevent2'; + obj.emit(data); + + data.type = 'myevent3'; + obj.emit(data); + + expect(called).to.equal(5); + }); + + it('event remove during emit call properly', function () { + var called = 0; + + function cb1() { + called++; + obj.off('myevent', cb1); + } + function cb2() { + called++; + obj.off('myevent', cb2); + } + function cb3() { + called++; + obj.off('myevent', cb3); + } + + obj.on('myevent', cb1); + obj.on('myevent', cb2); + obj.on('myevent', cb3); + obj.emit('myevent', ''); + + expect(called).to.equal(3); + }); +}); diff --git a/test/unit/pixi-v2/utils/Polyk.js b/test/unit/pixi-v2/utils/Polyk.js new file mode 100644 index 0000000..dfc7128 --- /dev/null +++ b/test/unit/pixi-v2/utils/Polyk.js @@ -0,0 +1,14 @@ +describe('pixi/utils/Polyk', function () { + 'use strict'; + + var expect = chai.expect; + var PolyK = PIXI.PolyK; + + it('Module exists', function () { + expect(PolyK).to.be.an('object'); + }); + + it('Members exist', function () { + expect(PolyK).to.respondTo('Triangulate'); + }); +}); diff --git a/test/unit/pixi-v2/utils/Utils.js b/test/unit/pixi-v2/utils/Utils.js new file mode 100644 index 0000000..c97b3c6 --- /dev/null +++ b/test/unit/pixi-v2/utils/Utils.js @@ -0,0 +1,17 @@ +describe('Utils', function () { + 'use strict'; + + var expect = chai.expect; + + it('requestAnimationFrame exists', function () { + expect(global).to.respondTo('requestAnimationFrame'); + }); + + it('cancelAnimationFrame exists', function () { + expect(global).to.respondTo('cancelAnimationFrame'); + }); + + it('requestAnimFrame exists', function () { + expect(global).to.respondTo('requestAnimFrame'); + }); +}); diff --git a/test/unit/pixi/InteractionManager.js b/test/unit/pixi/InteractionManager.js deleted file mode 100644 index ed3001f..0000000 --- a/test/unit/pixi/InteractionManager.js +++ /dev/null @@ -1,10 +0,0 @@ -describe('pixi/InteractionManager', function () { - 'use strict'; - - var expect = chai.expect; - var InteractionManager = PIXI.InteractionManager; - - it('Module exists', function () { - expect(InteractionManager).to.be.a('function'); - }); -}); diff --git a/test/unit/pixi/Pixi.js b/test/unit/pixi/Pixi.js deleted file mode 100644 index 27debc1..0000000 --- a/test/unit/pixi/Pixi.js +++ /dev/null @@ -1,9 +0,0 @@ -describe('pixi/Pixi', function () { - 'use strict'; - - var expect = chai.expect; - - it('Module exists', function () { - expect(global).to.have.property('PIXI').and.to.be.an('object'); - }); -}); diff --git a/test/unit/pixi/core/Circle.js b/test/unit/pixi/core/Circle.js deleted file mode 100644 index fbcfa17..0000000 --- a/test/unit/pixi/core/Circle.js +++ /dev/null @@ -1,21 +0,0 @@ -describe('pixi/core/Circle', function () { - 'use strict'; - - var expect = chai.expect; - var Circle = PIXI.Circle; - - it('Module exists', function () { - expect(Circle).to.be.a('function'); - }); - - it('Confirm new instance', function () { - var obj = new Circle(); - pixi_core_Circle_confirmNewCircle(obj); - }); - - it("getBounds should return Rectangle that bounds the circle", function() { - var obj = new Circle(100, 250, 50); - var bounds = obj.getBounds(); - pixi_core_Circle_isBoundedByRectangle(obj, bounds); - }); -}); diff --git a/test/unit/pixi/core/Ellipse.js b/test/unit/pixi/core/Ellipse.js deleted file mode 100644 index 026b56f..0000000 --- a/test/unit/pixi/core/Ellipse.js +++ /dev/null @@ -1,24 +0,0 @@ -describe('pixi/core/Ellipse', function () { - 'use strict'; - - var expect = chai.expect; - var Ellipse = PIXI.Ellipse; - - it('Module exists', function () { - expect(Ellipse).to.be.a('function'); - }); - - it('Confirm new instance', function () { - var obj = new Ellipse(); - - expect(obj).to.be.an.instanceof(Ellipse); - expect(obj).to.respondTo('clone'); - expect(obj).to.respondTo('contains'); - expect(obj).to.respondTo('getBounds'); - - expect(obj).to.have.property('x', 0); - expect(obj).to.have.property('y', 0); - expect(obj).to.have.property('width', 0); - expect(obj).to.have.property('height', 0); - }); -}); diff --git a/test/unit/pixi/core/Matrix.js b/test/unit/pixi/core/Matrix.js deleted file mode 100644 index da75e2e..0000000 --- a/test/unit/pixi/core/Matrix.js +++ /dev/null @@ -1,14 +0,0 @@ -describe('pixi/core/Matrix', function () { - 'use strict'; - - var expect = chai.expect; - - it('Matrix exists', function () { - expect(PIXI.Matrix).to.be.an('function'); - }); - - it('Confirm new Matrix', function () { - var matrix = new PIXI.Matrix(); - pixi_core_Matrix_confirmNewMatrix(matrix); - }); -}); diff --git a/test/unit/pixi/core/Point.js b/test/unit/pixi/core/Point.js deleted file mode 100644 index c4d5163..0000000 --- a/test/unit/pixi/core/Point.js +++ /dev/null @@ -1,15 +0,0 @@ -describe('pixi/core/Point', function () { - 'use strict'; - - var expect = chai.expect; - var Point = PIXI.Point; - - it('Module exists', function () { - expect(Point).to.be.a('function'); - }); - - it('Confirm new instance', function () { - var obj = new Point(); - pixi_core_Point_confirm(obj, 0, 0); - }); -}); diff --git a/test/unit/pixi/core/Polygon.js b/test/unit/pixi/core/Polygon.js deleted file mode 100644 index dc8c918..0000000 --- a/test/unit/pixi/core/Polygon.js +++ /dev/null @@ -1,20 +0,0 @@ -describe('pixi/core/Polygon', function () { - 'use strict'; - - var expect = chai.expect; - var Polygon = PIXI.Polygon; - - it('Module exists', function () { - expect(Polygon).to.be.a('function'); - }); - - it('Confirm new instance', function () { - var obj = new Polygon(); - - expect(obj).to.be.an.instanceof(Polygon); - expect(obj).to.respondTo('clone'); - expect(obj).to.respondTo('contains'); - - expect(obj).to.have.deep.property('points.length', 0); - }); -}); diff --git a/test/unit/pixi/core/Rectangle.js b/test/unit/pixi/core/Rectangle.js deleted file mode 100644 index d43316e..0000000 --- a/test/unit/pixi/core/Rectangle.js +++ /dev/null @@ -1,15 +0,0 @@ -describe('pixi/core/Rectangle', function () { - 'use strict'; - - var expect = chai.expect; - var Rectangle = PIXI.Rectangle; - - it('Module exists', function () { - expect(Rectangle).to.be.a('function'); - }); - - it('Confirm new instance', function () { - var rect = new Rectangle(); - pixi_core_Rectangle_confirm(rect, 0, 0, 0, 0); - }); -}); diff --git a/test/unit/pixi/display/DisplayObject.js b/test/unit/pixi/display/DisplayObject.js deleted file mode 100644 index 044acf8..0000000 --- a/test/unit/pixi/display/DisplayObject.js +++ /dev/null @@ -1,21 +0,0 @@ -describe('pixi/display/DisplayObject', function () { - 'use strict'; - - var expect = chai.expect; - var DisplayObject = PIXI.DisplayObject; - - it('Module exists', function () { - expect(DisplayObject).to.be.a('function'); - // expect(PIXI).to.have.property('visibleCount', 0); - }); - - it('Confirm new instance', function () { - var obj = new DisplayObject(); - - pixi_display_DisplayObject_confirmNew(obj); - expect(obj).to.have.property('hitArea', null); - expect(obj).to.have.property('interactive', false); - expect(obj).to.have.property('renderable', false); - expect(obj).to.have.property('stage', null); - }); -}); diff --git a/test/unit/pixi/display/DisplayObjectContainer.js b/test/unit/pixi/display/DisplayObjectContainer.js deleted file mode 100644 index 15a3376..0000000 --- a/test/unit/pixi/display/DisplayObjectContainer.js +++ /dev/null @@ -1,67 +0,0 @@ -describe('pixi/display/DisplayObjectContainer', function () { - 'use strict'; - - var expect = chai.expect; - var DisplayObjectContainer = PIXI.DisplayObjectContainer; - - it('Module exists', function () { - expect(DisplayObjectContainer).to.be.a('function'); - }); - - it('Confirm new instance', function () { - var obj = new DisplayObjectContainer(); - - pixi_display_DisplayObjectContainer_confirmNew(obj); - expect(obj).to.have.property('hitArea', null); - expect(obj).to.have.property('interactive', false); - expect(obj).to.have.property('renderable', false); - expect(obj).to.have.property('stage', null); - }); - - it('Gets child index', function() { - var container = new PIXI.DisplayObjectContainer(); - var children = []; - for (var i = 0; i < 10; i++) { - var child = new PIXI.DisplayObject(); - children.push(child); - container.addChild(child); - } - - for (i = 0; i < children.length; i++) { - expect(i).to.eql(container.getChildIndex(children[i])); - } - }); - - it('throws error when trying to get index of not a child', function() { - var container = new PIXI.DisplayObjectContainer(); - var child = new PIXI.DisplayObject(); - - expect(function() { container.getChildIndex(child); }).to.throw(); - }); - - it('Sets child index', function() { - var container = new PIXI.DisplayObjectContainer(); - var children = []; - - for (var i = 0; i < 10; i++) { - var child = new PIXI.DisplayObject(); - children.push(child); - container.addChild(child); - } - children.reverse(); - - for (i = 0; i < children.length; i++) { - container.setChildIndex(children[i], i); - expect(i).to.eql(container.getChildIndex(children[i])); - } - }); - - it('throws error when trying to set incorect index', function() { - var container = new PIXI.DisplayObjectContainer(); - var child = new PIXI.DisplayObject(); - container.addChild(child); - - expect(function() { container.setChildIndex(child, -1); }).to.throw(); - expect(function() { container.setChildIndex(child, 1); }).to.throw(); - }); -}); diff --git a/test/unit/pixi/display/MovieClip.js b/test/unit/pixi/display/MovieClip.js deleted file mode 100644 index f3c6c6a..0000000 --- a/test/unit/pixi/display/MovieClip.js +++ /dev/null @@ -1,33 +0,0 @@ -describe('pixi/display/MovieClip', function () { - 'use strict'; - - var expect = chai.expect; - var MovieClip = PIXI.MovieClip; - var Texture = PIXI.Texture; - - it('Module exists', function () { - expect(MovieClip).to.be.a('function'); - }); - - it('Confirm new instance', function (done) { - var texture = Texture.fromImage('/base/test/textures/SpriteSheet-Explosion.png'); - var obj = new MovieClip([texture]); - - pixi_display_Sprite_confirmNew(obj, done); - - expect(obj).to.be.an.instanceof(MovieClip); - expect(obj).to.respondTo('stop'); - expect(obj).to.respondTo('play'); - expect(obj).to.respondTo('gotoAndStop'); - expect(obj).to.respondTo('gotoAndPlay'); - expect(obj).to.respondTo('updateTransform'); - - expect(obj).to.have.deep.property('textures.length', 1); - expect(obj).to.have.deep.property('textures[0]', texture); - expect(obj).to.have.property('animationSpeed', 1); - expect(obj).to.have.property('loop', true); - expect(obj).to.have.property('onComplete', null); - expect(obj).to.have.property('currentFrame', 0); - expect(obj).to.have.property('playing', false); - }); -}); diff --git a/test/unit/pixi/display/Sprite.js b/test/unit/pixi/display/Sprite.js deleted file mode 100644 index 30c8076..0000000 --- a/test/unit/pixi/display/Sprite.js +++ /dev/null @@ -1,28 +0,0 @@ -describe('pixi/display/Sprite', function () { - 'use strict'; - - var expect = chai.expect; - var Sprite = PIXI.Sprite; - var Texture = PIXI.Texture; - - it('Module exists', function () { - expect(Sprite).to.be.a('function'); - expect(PIXI).to.have.deep.property('blendModes.NORMAL', 0); - expect(PIXI).to.have.deep.property('blendModes.ADD', 1); - expect(PIXI).to.have.deep.property('blendModes.MULTIPLY', 2); - expect(PIXI).to.have.deep.property('blendModes.SCREEN', 3); - }); - - - it('Members exist', function () { - expect(Sprite).itself.to.respondTo('fromImage'); - expect(Sprite).itself.to.respondTo('fromFrame'); - }); - - it('Confirm new instance', function (done) { - var texture = Texture.fromImage('/base/test/textures/SpriteSheet-Aliens.png'); - var obj = new Sprite(texture); - - pixi_display_Sprite_confirmNew(obj, done); - }); -}); diff --git a/test/unit/pixi/display/Stage.js b/test/unit/pixi/display/Stage.js deleted file mode 100644 index 6974c2e..0000000 --- a/test/unit/pixi/display/Stage.js +++ /dev/null @@ -1,49 +0,0 @@ -describe('pixi/display/Stage', function () { - 'use strict'; - - var expect = chai.expect; - var Stage = PIXI.Stage; - var InteractionManager = PIXI.InteractionManager; - var Rectangle = PIXI.Rectangle; - - it('Module exists', function () { - expect(Stage).to.be.a('function'); - }); - - it('Confirm new instance', function () { - var obj = new Stage(null, true); - - pixi_display_DisplayObjectContainer_confirmNew(obj); - - expect(obj).to.be.an.instanceof(Stage); - expect(obj).to.respondTo('updateTransform'); - expect(obj).to.respondTo('setBackgroundColor'); - expect(obj).to.respondTo('getMousePosition'); - // FIXME: duplicate member in DisplayObject - pixi_core_Matrix_confirmNewMatrix(obj.worldTransform); - // FIXME: convert arg to bool in constructor - expect(obj).to.have.property('interactive', true); - - expect(obj).to.have.property('interactionManager') - .and.to.be.an.instanceof(InteractionManager) - .and.to.have.property('stage', obj); - - expect(obj).to.have.property('dirty', true); - - expect(obj).to.have.property('stage', obj); - - expect(obj).to.have.property('hitArea') - .and.to.be.an.instanceof(Rectangle); - pixi_core_Rectangle_confirm(obj.hitArea, 0, 0, 100000, 100000); - - expect(obj).to.have.property('backgroundColor', 0x000000); - expect(obj).to.have.deep.property('backgroundColorSplit.length', 3); - expect(obj).to.have.deep.property('backgroundColorSplit[0]', 0); - expect(obj).to.have.deep.property('backgroundColorSplit[1]', 0); - expect(obj).to.have.deep.property('backgroundColorSplit[2]', 0); - expect(obj).to.have.property('backgroundColorString', '#000000'); - - - expect(obj).to.have.property('worldVisible', true); - }); -}); diff --git a/test/unit/pixi/extras/Rope.js b/test/unit/pixi/extras/Rope.js deleted file mode 100644 index 05885ac..0000000 --- a/test/unit/pixi/extras/Rope.js +++ /dev/null @@ -1,31 +0,0 @@ -describe('pixi/extras/Rope', function () { - 'use strict'; - - var expect = chai.expect; - var Rope = PIXI.Rope; - var Texture = PIXI.Texture; - var Point = PIXI.Point; - - it('Module exists', function () { - expect(Rope).to.be.a('function'); - }); - - it('Confirm new instance', function () { - - var texture = Texture.fromImage('/base/test/textures/bunny.png'); - - // TODO-Alvin - // Same as Strip - - // var obj = new Rope(texture, [new Point(), new Point(5, 10), new Point(10, 20)]); - - // pixi_extras_Strip_confirmNew(obj); - - // expect(obj).to.be.an.instanceof(Rope); - // expect(obj).to.respondTo('refresh'); - // expect(obj).to.respondTo('updateTransform'); - // expect(obj).to.respondTo('setTexture'); - - // TODO: Test properties - }); -}); diff --git a/test/unit/pixi/extras/Spine.js b/test/unit/pixi/extras/Spine.js deleted file mode 100644 index 0708bc0..0000000 --- a/test/unit/pixi/extras/Spine.js +++ /dev/null @@ -1,10 +0,0 @@ -describe('pixi/extras/Spine', function () { - 'use strict'; - - var expect = chai.expect; - var Spine = PIXI.Spine; - - it('Module exists', function () { - expect(Spine).to.be.a('function'); - }); -}); diff --git a/test/unit/pixi/extras/Strip.js b/test/unit/pixi/extras/Strip.js deleted file mode 100644 index 230af90..0000000 --- a/test/unit/pixi/extras/Strip.js +++ /dev/null @@ -1,26 +0,0 @@ -describe('pixi/extras/Strip', function () { - 'use strict'; - - var expect = chai.expect; - var Strip = PIXI.Strip; - var Texture = PIXI.Texture; - - it('Module exists', function () { - expect(Strip).to.be.a('function'); - }); - - it('Confirm new instance', function () { - - - // TODO-Alvin - // We tweaked it to make it pass the tests, but the whole strip class needs - // to be re-coded - - var texture = Texture.fromImage('/base/test/textures/bunny.png'); - - // var obj = new Strip(texture, 20, 10000); - - - // pixi_extras_Strip_confirmNew(obj); - }); -}); diff --git a/test/unit/pixi/extras/TilingSprite.js b/test/unit/pixi/extras/TilingSprite.js deleted file mode 100644 index 56aea14..0000000 --- a/test/unit/pixi/extras/TilingSprite.js +++ /dev/null @@ -1,24 +0,0 @@ -describe('pixi/extras/TilingSprite', function () { - 'use strict'; - - var expect = chai.expect; - var TilingSprite = PIXI.TilingSprite; - var Texture = PIXI.Texture; - - it('Module exists', function () { - expect(TilingSprite).to.be.a('function'); - }); - - it('Confirm new instance', function () { - var texture = Texture.fromImage('/base/test/textures/bunny.png'); - var obj = new TilingSprite(texture, 6000, 12000); - - pixi_display_DisplayObjectContainer_confirmNew(obj); - - expect(obj).to.be.an.instanceof(TilingSprite); - expect(obj).to.respondTo('setTexture'); - expect(obj).to.respondTo('onTextureUpdate'); - - // TODO: Test properties - }); -}); diff --git a/test/unit/pixi/filters/FilterBlock.js b/test/unit/pixi/filters/FilterBlock.js deleted file mode 100644 index 870cec0..0000000 --- a/test/unit/pixi/filters/FilterBlock.js +++ /dev/null @@ -1,10 +0,0 @@ -describe('pixi/filters/FilterBlock', function () { - 'use strict'; - - var expect = chai.expect; - var FilterBlock = PIXI.FilterBlock; - - it('Module exists', function () { - expect(FilterBlock).to.be.a('function'); - }); -}); diff --git a/test/unit/pixi/loaders/AssetLoader.js b/test/unit/pixi/loaders/AssetLoader.js deleted file mode 100644 index a0aa0b5..0000000 --- a/test/unit/pixi/loaders/AssetLoader.js +++ /dev/null @@ -1,10 +0,0 @@ -describe('pixi/loaders/AssetLoader', function () { - 'use strict'; - - var expect = chai.expect; - var AssetLoader = PIXI.AssetLoader; - - it('Module exists', function () { - expect(AssetLoader).to.be.a('function'); - }); -}); diff --git a/test/unit/pixi/loaders/BitmapFontLoader.js b/test/unit/pixi/loaders/BitmapFontLoader.js deleted file mode 100644 index 046f018..0000000 --- a/test/unit/pixi/loaders/BitmapFontLoader.js +++ /dev/null @@ -1,9 +0,0 @@ -describe('pixi/loaders/BitmapFontLoader', function () { - 'use strict'; - - var expect = chai.expect; - - it('Module exists', function () { - expect(PIXI.BitmapFontLoader).to.be.a('function'); - }); -}); diff --git a/test/unit/pixi/loaders/ImageLoader.js b/test/unit/pixi/loaders/ImageLoader.js deleted file mode 100644 index 8b1f556..0000000 --- a/test/unit/pixi/loaders/ImageLoader.js +++ /dev/null @@ -1,10 +0,0 @@ -describe('pixi/loaders/ImageLoader', function () { - 'use strict'; - - var expect = chai.expect; - var ImageLoader = PIXI.ImageLoader; - - it('Module exists', function () { - expect(ImageLoader).to.be.a('function'); - }); -}); diff --git a/test/unit/pixi/loaders/JsonLoader.js b/test/unit/pixi/loaders/JsonLoader.js deleted file mode 100644 index c577e83..0000000 --- a/test/unit/pixi/loaders/JsonLoader.js +++ /dev/null @@ -1,10 +0,0 @@ -describe('pixi/loaders/JsonLoader', function () { - 'use strict'; - - var expect = chai.expect; - var JsonLoader = PIXI.JsonLoader; - - it('Module exists', function () { - expect(JsonLoader).to.be.a('function'); - }); -}); diff --git a/test/unit/pixi-v2/InteractionManager.js b/test/unit/pixi-v2/InteractionManager.js new file mode 100644 index 0000000..ed3001f --- /dev/null +++ b/test/unit/pixi-v2/InteractionManager.js @@ -0,0 +1,10 @@ +describe('pixi/InteractionManager', function () { + 'use strict'; + + var expect = chai.expect; + var InteractionManager = PIXI.InteractionManager; + + it('Module exists', function () { + expect(InteractionManager).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/Pixi.js b/test/unit/pixi-v2/Pixi.js new file mode 100644 index 0000000..27debc1 --- /dev/null +++ b/test/unit/pixi-v2/Pixi.js @@ -0,0 +1,9 @@ +describe('pixi/Pixi', function () { + 'use strict'; + + var expect = chai.expect; + + it('Module exists', function () { + expect(global).to.have.property('PIXI').and.to.be.an('object'); + }); +}); diff --git a/test/unit/pixi-v2/core/Circle.js b/test/unit/pixi-v2/core/Circle.js new file mode 100644 index 0000000..fbcfa17 --- /dev/null +++ b/test/unit/pixi-v2/core/Circle.js @@ -0,0 +1,21 @@ +describe('pixi/core/Circle', function () { + 'use strict'; + + var expect = chai.expect; + var Circle = PIXI.Circle; + + it('Module exists', function () { + expect(Circle).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Circle(); + pixi_core_Circle_confirmNewCircle(obj); + }); + + it("getBounds should return Rectangle that bounds the circle", function() { + var obj = new Circle(100, 250, 50); + var bounds = obj.getBounds(); + pixi_core_Circle_isBoundedByRectangle(obj, bounds); + }); +}); diff --git a/test/unit/pixi-v2/core/Ellipse.js b/test/unit/pixi-v2/core/Ellipse.js new file mode 100644 index 0000000..026b56f --- /dev/null +++ b/test/unit/pixi-v2/core/Ellipse.js @@ -0,0 +1,24 @@ +describe('pixi/core/Ellipse', function () { + 'use strict'; + + var expect = chai.expect; + var Ellipse = PIXI.Ellipse; + + it('Module exists', function () { + expect(Ellipse).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Ellipse(); + + expect(obj).to.be.an.instanceof(Ellipse); + expect(obj).to.respondTo('clone'); + expect(obj).to.respondTo('contains'); + expect(obj).to.respondTo('getBounds'); + + expect(obj).to.have.property('x', 0); + expect(obj).to.have.property('y', 0); + expect(obj).to.have.property('width', 0); + expect(obj).to.have.property('height', 0); + }); +}); diff --git a/test/unit/pixi-v2/core/Matrix.js b/test/unit/pixi-v2/core/Matrix.js new file mode 100644 index 0000000..da75e2e --- /dev/null +++ b/test/unit/pixi-v2/core/Matrix.js @@ -0,0 +1,14 @@ +describe('pixi/core/Matrix', function () { + 'use strict'; + + var expect = chai.expect; + + it('Matrix exists', function () { + expect(PIXI.Matrix).to.be.an('function'); + }); + + it('Confirm new Matrix', function () { + var matrix = new PIXI.Matrix(); + pixi_core_Matrix_confirmNewMatrix(matrix); + }); +}); diff --git a/test/unit/pixi-v2/core/Point.js b/test/unit/pixi-v2/core/Point.js new file mode 100644 index 0000000..c4d5163 --- /dev/null +++ b/test/unit/pixi-v2/core/Point.js @@ -0,0 +1,15 @@ +describe('pixi/core/Point', function () { + 'use strict'; + + var expect = chai.expect; + var Point = PIXI.Point; + + it('Module exists', function () { + expect(Point).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Point(); + pixi_core_Point_confirm(obj, 0, 0); + }); +}); diff --git a/test/unit/pixi-v2/core/Polygon.js b/test/unit/pixi-v2/core/Polygon.js new file mode 100644 index 0000000..dc8c918 --- /dev/null +++ b/test/unit/pixi-v2/core/Polygon.js @@ -0,0 +1,20 @@ +describe('pixi/core/Polygon', function () { + 'use strict'; + + var expect = chai.expect; + var Polygon = PIXI.Polygon; + + it('Module exists', function () { + expect(Polygon).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Polygon(); + + expect(obj).to.be.an.instanceof(Polygon); + expect(obj).to.respondTo('clone'); + expect(obj).to.respondTo('contains'); + + expect(obj).to.have.deep.property('points.length', 0); + }); +}); diff --git a/test/unit/pixi-v2/core/Rectangle.js b/test/unit/pixi-v2/core/Rectangle.js new file mode 100644 index 0000000..d43316e --- /dev/null +++ b/test/unit/pixi-v2/core/Rectangle.js @@ -0,0 +1,15 @@ +describe('pixi/core/Rectangle', function () { + 'use strict'; + + var expect = chai.expect; + var Rectangle = PIXI.Rectangle; + + it('Module exists', function () { + expect(Rectangle).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var rect = new Rectangle(); + pixi_core_Rectangle_confirm(rect, 0, 0, 0, 0); + }); +}); diff --git a/test/unit/pixi-v2/display/DisplayObject.js b/test/unit/pixi-v2/display/DisplayObject.js new file mode 100644 index 0000000..044acf8 --- /dev/null +++ b/test/unit/pixi-v2/display/DisplayObject.js @@ -0,0 +1,21 @@ +describe('pixi/display/DisplayObject', function () { + 'use strict'; + + var expect = chai.expect; + var DisplayObject = PIXI.DisplayObject; + + it('Module exists', function () { + expect(DisplayObject).to.be.a('function'); + // expect(PIXI).to.have.property('visibleCount', 0); + }); + + it('Confirm new instance', function () { + var obj = new DisplayObject(); + + pixi_display_DisplayObject_confirmNew(obj); + expect(obj).to.have.property('hitArea', null); + expect(obj).to.have.property('interactive', false); + expect(obj).to.have.property('renderable', false); + expect(obj).to.have.property('stage', null); + }); +}); diff --git a/test/unit/pixi-v2/display/DisplayObjectContainer.js b/test/unit/pixi-v2/display/DisplayObjectContainer.js new file mode 100644 index 0000000..15a3376 --- /dev/null +++ b/test/unit/pixi-v2/display/DisplayObjectContainer.js @@ -0,0 +1,67 @@ +describe('pixi/display/DisplayObjectContainer', function () { + 'use strict'; + + var expect = chai.expect; + var DisplayObjectContainer = PIXI.DisplayObjectContainer; + + it('Module exists', function () { + expect(DisplayObjectContainer).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new DisplayObjectContainer(); + + pixi_display_DisplayObjectContainer_confirmNew(obj); + expect(obj).to.have.property('hitArea', null); + expect(obj).to.have.property('interactive', false); + expect(obj).to.have.property('renderable', false); + expect(obj).to.have.property('stage', null); + }); + + it('Gets child index', function() { + var container = new PIXI.DisplayObjectContainer(); + var children = []; + for (var i = 0; i < 10; i++) { + var child = new PIXI.DisplayObject(); + children.push(child); + container.addChild(child); + } + + for (i = 0; i < children.length; i++) { + expect(i).to.eql(container.getChildIndex(children[i])); + } + }); + + it('throws error when trying to get index of not a child', function() { + var container = new PIXI.DisplayObjectContainer(); + var child = new PIXI.DisplayObject(); + + expect(function() { container.getChildIndex(child); }).to.throw(); + }); + + it('Sets child index', function() { + var container = new PIXI.DisplayObjectContainer(); + var children = []; + + for (var i = 0; i < 10; i++) { + var child = new PIXI.DisplayObject(); + children.push(child); + container.addChild(child); + } + children.reverse(); + + for (i = 0; i < children.length; i++) { + container.setChildIndex(children[i], i); + expect(i).to.eql(container.getChildIndex(children[i])); + } + }); + + it('throws error when trying to set incorect index', function() { + var container = new PIXI.DisplayObjectContainer(); + var child = new PIXI.DisplayObject(); + container.addChild(child); + + expect(function() { container.setChildIndex(child, -1); }).to.throw(); + expect(function() { container.setChildIndex(child, 1); }).to.throw(); + }); +}); diff --git a/test/unit/pixi-v2/display/MovieClip.js b/test/unit/pixi-v2/display/MovieClip.js new file mode 100644 index 0000000..f3c6c6a --- /dev/null +++ b/test/unit/pixi-v2/display/MovieClip.js @@ -0,0 +1,33 @@ +describe('pixi/display/MovieClip', function () { + 'use strict'; + + var expect = chai.expect; + var MovieClip = PIXI.MovieClip; + var Texture = PIXI.Texture; + + it('Module exists', function () { + expect(MovieClip).to.be.a('function'); + }); + + it('Confirm new instance', function (done) { + var texture = Texture.fromImage('/base/test/textures/SpriteSheet-Explosion.png'); + var obj = new MovieClip([texture]); + + pixi_display_Sprite_confirmNew(obj, done); + + expect(obj).to.be.an.instanceof(MovieClip); + expect(obj).to.respondTo('stop'); + expect(obj).to.respondTo('play'); + expect(obj).to.respondTo('gotoAndStop'); + expect(obj).to.respondTo('gotoAndPlay'); + expect(obj).to.respondTo('updateTransform'); + + expect(obj).to.have.deep.property('textures.length', 1); + expect(obj).to.have.deep.property('textures[0]', texture); + expect(obj).to.have.property('animationSpeed', 1); + expect(obj).to.have.property('loop', true); + expect(obj).to.have.property('onComplete', null); + expect(obj).to.have.property('currentFrame', 0); + expect(obj).to.have.property('playing', false); + }); +}); diff --git a/test/unit/pixi-v2/display/Sprite.js b/test/unit/pixi-v2/display/Sprite.js new file mode 100644 index 0000000..30c8076 --- /dev/null +++ b/test/unit/pixi-v2/display/Sprite.js @@ -0,0 +1,28 @@ +describe('pixi/display/Sprite', function () { + 'use strict'; + + var expect = chai.expect; + var Sprite = PIXI.Sprite; + var Texture = PIXI.Texture; + + it('Module exists', function () { + expect(Sprite).to.be.a('function'); + expect(PIXI).to.have.deep.property('blendModes.NORMAL', 0); + expect(PIXI).to.have.deep.property('blendModes.ADD', 1); + expect(PIXI).to.have.deep.property('blendModes.MULTIPLY', 2); + expect(PIXI).to.have.deep.property('blendModes.SCREEN', 3); + }); + + + it('Members exist', function () { + expect(Sprite).itself.to.respondTo('fromImage'); + expect(Sprite).itself.to.respondTo('fromFrame'); + }); + + it('Confirm new instance', function (done) { + var texture = Texture.fromImage('/base/test/textures/SpriteSheet-Aliens.png'); + var obj = new Sprite(texture); + + pixi_display_Sprite_confirmNew(obj, done); + }); +}); diff --git a/test/unit/pixi-v2/display/Stage.js b/test/unit/pixi-v2/display/Stage.js new file mode 100644 index 0000000..6974c2e --- /dev/null +++ b/test/unit/pixi-v2/display/Stage.js @@ -0,0 +1,49 @@ +describe('pixi/display/Stage', function () { + 'use strict'; + + var expect = chai.expect; + var Stage = PIXI.Stage; + var InteractionManager = PIXI.InteractionManager; + var Rectangle = PIXI.Rectangle; + + it('Module exists', function () { + expect(Stage).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Stage(null, true); + + pixi_display_DisplayObjectContainer_confirmNew(obj); + + expect(obj).to.be.an.instanceof(Stage); + expect(obj).to.respondTo('updateTransform'); + expect(obj).to.respondTo('setBackgroundColor'); + expect(obj).to.respondTo('getMousePosition'); + // FIXME: duplicate member in DisplayObject + pixi_core_Matrix_confirmNewMatrix(obj.worldTransform); + // FIXME: convert arg to bool in constructor + expect(obj).to.have.property('interactive', true); + + expect(obj).to.have.property('interactionManager') + .and.to.be.an.instanceof(InteractionManager) + .and.to.have.property('stage', obj); + + expect(obj).to.have.property('dirty', true); + + expect(obj).to.have.property('stage', obj); + + expect(obj).to.have.property('hitArea') + .and.to.be.an.instanceof(Rectangle); + pixi_core_Rectangle_confirm(obj.hitArea, 0, 0, 100000, 100000); + + expect(obj).to.have.property('backgroundColor', 0x000000); + expect(obj).to.have.deep.property('backgroundColorSplit.length', 3); + expect(obj).to.have.deep.property('backgroundColorSplit[0]', 0); + expect(obj).to.have.deep.property('backgroundColorSplit[1]', 0); + expect(obj).to.have.deep.property('backgroundColorSplit[2]', 0); + expect(obj).to.have.property('backgroundColorString', '#000000'); + + + expect(obj).to.have.property('worldVisible', true); + }); +}); diff --git a/test/unit/pixi-v2/extras/Rope.js b/test/unit/pixi-v2/extras/Rope.js new file mode 100644 index 0000000..05885ac --- /dev/null +++ b/test/unit/pixi-v2/extras/Rope.js @@ -0,0 +1,31 @@ +describe('pixi/extras/Rope', function () { + 'use strict'; + + var expect = chai.expect; + var Rope = PIXI.Rope; + var Texture = PIXI.Texture; + var Point = PIXI.Point; + + it('Module exists', function () { + expect(Rope).to.be.a('function'); + }); + + it('Confirm new instance', function () { + + var texture = Texture.fromImage('/base/test/textures/bunny.png'); + + // TODO-Alvin + // Same as Strip + + // var obj = new Rope(texture, [new Point(), new Point(5, 10), new Point(10, 20)]); + + // pixi_extras_Strip_confirmNew(obj); + + // expect(obj).to.be.an.instanceof(Rope); + // expect(obj).to.respondTo('refresh'); + // expect(obj).to.respondTo('updateTransform'); + // expect(obj).to.respondTo('setTexture'); + + // TODO: Test properties + }); +}); diff --git a/test/unit/pixi-v2/extras/Spine.js b/test/unit/pixi-v2/extras/Spine.js new file mode 100644 index 0000000..0708bc0 --- /dev/null +++ b/test/unit/pixi-v2/extras/Spine.js @@ -0,0 +1,10 @@ +describe('pixi/extras/Spine', function () { + 'use strict'; + + var expect = chai.expect; + var Spine = PIXI.Spine; + + it('Module exists', function () { + expect(Spine).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/extras/Strip.js b/test/unit/pixi-v2/extras/Strip.js new file mode 100644 index 0000000..230af90 --- /dev/null +++ b/test/unit/pixi-v2/extras/Strip.js @@ -0,0 +1,26 @@ +describe('pixi/extras/Strip', function () { + 'use strict'; + + var expect = chai.expect; + var Strip = PIXI.Strip; + var Texture = PIXI.Texture; + + it('Module exists', function () { + expect(Strip).to.be.a('function'); + }); + + it('Confirm new instance', function () { + + + // TODO-Alvin + // We tweaked it to make it pass the tests, but the whole strip class needs + // to be re-coded + + var texture = Texture.fromImage('/base/test/textures/bunny.png'); + + // var obj = new Strip(texture, 20, 10000); + + + // pixi_extras_Strip_confirmNew(obj); + }); +}); diff --git a/test/unit/pixi-v2/extras/TilingSprite.js b/test/unit/pixi-v2/extras/TilingSprite.js new file mode 100644 index 0000000..56aea14 --- /dev/null +++ b/test/unit/pixi-v2/extras/TilingSprite.js @@ -0,0 +1,24 @@ +describe('pixi/extras/TilingSprite', function () { + 'use strict'; + + var expect = chai.expect; + var TilingSprite = PIXI.TilingSprite; + var Texture = PIXI.Texture; + + it('Module exists', function () { + expect(TilingSprite).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var texture = Texture.fromImage('/base/test/textures/bunny.png'); + var obj = new TilingSprite(texture, 6000, 12000); + + pixi_display_DisplayObjectContainer_confirmNew(obj); + + expect(obj).to.be.an.instanceof(TilingSprite); + expect(obj).to.respondTo('setTexture'); + expect(obj).to.respondTo('onTextureUpdate'); + + // TODO: Test properties + }); +}); diff --git a/test/unit/pixi-v2/filters/FilterBlock.js b/test/unit/pixi-v2/filters/FilterBlock.js new file mode 100644 index 0000000..870cec0 --- /dev/null +++ b/test/unit/pixi-v2/filters/FilterBlock.js @@ -0,0 +1,10 @@ +describe('pixi/filters/FilterBlock', function () { + 'use strict'; + + var expect = chai.expect; + var FilterBlock = PIXI.FilterBlock; + + it('Module exists', function () { + expect(FilterBlock).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/AssetLoader.js b/test/unit/pixi-v2/loaders/AssetLoader.js new file mode 100644 index 0000000..a0aa0b5 --- /dev/null +++ b/test/unit/pixi-v2/loaders/AssetLoader.js @@ -0,0 +1,10 @@ +describe('pixi/loaders/AssetLoader', function () { + 'use strict'; + + var expect = chai.expect; + var AssetLoader = PIXI.AssetLoader; + + it('Module exists', function () { + expect(AssetLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/BitmapFontLoader.js b/test/unit/pixi-v2/loaders/BitmapFontLoader.js new file mode 100644 index 0000000..046f018 --- /dev/null +++ b/test/unit/pixi-v2/loaders/BitmapFontLoader.js @@ -0,0 +1,9 @@ +describe('pixi/loaders/BitmapFontLoader', function () { + 'use strict'; + + var expect = chai.expect; + + it('Module exists', function () { + expect(PIXI.BitmapFontLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/ImageLoader.js b/test/unit/pixi-v2/loaders/ImageLoader.js new file mode 100644 index 0000000..8b1f556 --- /dev/null +++ b/test/unit/pixi-v2/loaders/ImageLoader.js @@ -0,0 +1,10 @@ +describe('pixi/loaders/ImageLoader', function () { + 'use strict'; + + var expect = chai.expect; + var ImageLoader = PIXI.ImageLoader; + + it('Module exists', function () { + expect(ImageLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/JsonLoader.js b/test/unit/pixi-v2/loaders/JsonLoader.js new file mode 100644 index 0000000..c577e83 --- /dev/null +++ b/test/unit/pixi-v2/loaders/JsonLoader.js @@ -0,0 +1,10 @@ +describe('pixi/loaders/JsonLoader', function () { + 'use strict'; + + var expect = chai.expect; + var JsonLoader = PIXI.JsonLoader; + + it('Module exists', function () { + expect(JsonLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/SpineLoader.js b/test/unit/pixi-v2/loaders/SpineLoader.js new file mode 100644 index 0000000..fdcc0b8 --- /dev/null +++ b/test/unit/pixi-v2/loaders/SpineLoader.js @@ -0,0 +1,10 @@ +describe('pixi/loaders/SpineLoader', function () { + 'use strict'; + + var expect = chai.expect; + var SpineLoader = PIXI.SpineLoader; + + it('Module exists', function () { + expect(SpineLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/SpriteSheetLoader.js b/test/unit/pixi-v2/loaders/SpriteSheetLoader.js new file mode 100644 index 0000000..57beb27 --- /dev/null +++ b/test/unit/pixi-v2/loaders/SpriteSheetLoader.js @@ -0,0 +1,10 @@ +describe('pixi/loaders/SpriteSheetLoader', function () { + 'use strict'; + + var expect = chai.expect; + var SpriteSheetLoader = PIXI.SpriteSheetLoader; + + it('Module exists', function () { + expect(SpriteSheetLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/primitives/Graphics.js b/test/unit/pixi-v2/primitives/Graphics.js new file mode 100644 index 0000000..f3849eb --- /dev/null +++ b/test/unit/pixi-v2/primitives/Graphics.js @@ -0,0 +1,44 @@ +describe('pixi/primitives/Graphics', function () { + 'use strict'; + + var expect = chai.expect; + var Graphics = PIXI.Graphics; + + it('Module exists', function () { + expect(Graphics).to.be.a('function'); + + expect(Graphics).itself.to.have.property('POLY', 0); + expect(Graphics).itself.to.have.property('RECT', 1); + expect(Graphics).itself.to.have.property('CIRC', 2); + expect(Graphics).itself.to.have.property('ELIP', 3); + expect(Graphics).itself.to.have.property('RREC', 4); + }); + + it('Confirm new instance', function () { + var obj = new Graphics(); + + pixi_display_DisplayObjectContainer_confirmNew(obj); + + expect(obj).to.be.an.instanceof(Graphics); + expect(obj).to.respondTo('lineStyle'); + expect(obj).to.respondTo('lineStyle'); + expect(obj).to.respondTo('moveTo'); + expect(obj).to.respondTo('lineTo'); + expect(obj).to.respondTo('beginFill'); + expect(obj).to.respondTo('endFill'); + expect(obj).to.respondTo('drawRect'); + // expect(obj).to.respondTo('drawRoundedRect'); + expect(obj).to.respondTo('drawCircle'); + expect(obj).to.respondTo('drawEllipse'); + expect(obj).to.respondTo('clear'); + + expect(obj).to.have.property('renderable', true); + expect(obj).to.have.property('fillAlpha', 1); + expect(obj).to.have.property('lineWidth', 0); + expect(obj).to.have.property('width', 0); + expect(obj).to.have.property('height', 0); + expect(obj).to.have.property('lineColor', 0); + expect(obj).to.have.deep.property('graphicsData.length', 0); + // expect(obj).to.have.deep.property('currentPath.points.length', 0); + }); +}); diff --git a/test/unit/pixi-v2/renderers/canvas/CanvasGraphics.js b/test/unit/pixi-v2/renderers/canvas/CanvasGraphics.js new file mode 100644 index 0000000..8f44472 --- /dev/null +++ b/test/unit/pixi-v2/renderers/canvas/CanvasGraphics.js @@ -0,0 +1,15 @@ +describe('renders/canvas/CanvasGraphics', function () { + 'use strict'; + + var expect = chai.expect; + var CanvasGraphics = PIXI.CanvasGraphics; + + it('Module exists', function () { + expect(CanvasGraphics).to.be.a('function'); + }); + + it('Members exist', function () { + expect(CanvasGraphics).itself.to.respondTo('renderGraphics'); + expect(CanvasGraphics).itself.to.respondTo('renderGraphicsMask'); + }); +}); diff --git a/test/unit/pixi-v2/renderers/canvas/CanvasRenderer.js b/test/unit/pixi-v2/renderers/canvas/CanvasRenderer.js new file mode 100644 index 0000000..1646444 --- /dev/null +++ b/test/unit/pixi-v2/renderers/canvas/CanvasRenderer.js @@ -0,0 +1,36 @@ +describe('renderers/canvas/CanvasRenderer', function () { + 'use strict'; + + var expect = chai.expect; + var CanvasRenderer = PIXI.CanvasRenderer; + + it('Module exists', function () { + expect(CanvasRenderer).to.be.a('function'); + }); + + describe('.autoResize', function () { + it('Should automatically resize view if enabled', function () { + var renderer = new CanvasRenderer(200, 200, { + autoResize: true + }); + + expect(renderer.view.style.width).to.equal('200px'); + }); + + it('Should not automatically resize view if disabled', function () { + var renderer = new CanvasRenderer(200, 200, { + autoResize: false + }); + + expect(renderer.view.style.width).to.equal(''); + }); + + it('Should not automatically resize view if not specified', function () { + var renderer = new CanvasRenderer(200, 200, { + resolution: 2 + }); + + expect(renderer.view.style.width).to.equal(''); + }); + }); +}); diff --git a/test/unit/pixi-v2/renderers/webgl/WebGLGraphics.js b/test/unit/pixi-v2/renderers/webgl/WebGLGraphics.js new file mode 100644 index 0000000..5867b28 --- /dev/null +++ b/test/unit/pixi-v2/renderers/webgl/WebGLGraphics.js @@ -0,0 +1,20 @@ +describe('renderers/wegbl/WebGLGraphics', function () { + 'use strict'; + + var expect = chai.expect; + var WebGLGraphics = PIXI.WebGLGraphics; + + it('Module exists', function () { + expect(WebGLGraphics).to.be.a('function'); + }); + + it('Members exist', function () { + expect(WebGLGraphics).itself.to.respondTo('renderGraphics'); + expect(WebGLGraphics).itself.to.respondTo('updateGraphics'); + expect(WebGLGraphics).itself.to.respondTo('buildRectangle'); + expect(WebGLGraphics).itself.to.respondTo('buildRoundedRectangle'); + expect(WebGLGraphics).itself.to.respondTo('buildCircle'); + expect(WebGLGraphics).itself.to.respondTo('buildLine'); + expect(WebGLGraphics).itself.to.respondTo('buildPoly'); + }); +}); diff --git a/test/unit/pixi-v2/renderers/webgl/WebGLRenderer.js b/test/unit/pixi-v2/renderers/webgl/WebGLRenderer.js new file mode 100644 index 0000000..1680a80 --- /dev/null +++ b/test/unit/pixi-v2/renderers/webgl/WebGLRenderer.js @@ -0,0 +1,49 @@ +describe('renderers/webgl/WebGLRenderer', function () { + 'use strict'; + + var expect = chai.expect; + var WebGLRenderer = PIXI.WebGLRenderer; + + it('Module exists', function () { + expect(WebGLRenderer).to.be.a('function'); + }); + + // Skip tests if WebGL is not available (WebGL not supported in Travis CI) + try { + var renderer = new WebGLRenderer(400, 300, {}); + renderer.destroy(); + } catch (error) { + return; + } + + it('Destroy renderer', function () { + var renderer = new WebGLRenderer(400, 300, {}); + renderer.destroy(); + }); + + describe('.autoResize', function () { + it('Should automatically resize view if enabled', function () { + var renderer = new WebGLRenderer(200, 200, { + autoResize: true + }); + + expect(renderer.view.style.width).to.equal('200px'); + }); + + it('Should not automatically resize view if disabled', function () { + var renderer = new WebGLRenderer(200, 200, { + autoResize: false + }); + + expect(renderer.view.style.width).to.equal(''); + }); + + it('Should not automatically resize view if not specified', function () { + var renderer = new WebGLRenderer(200, 200, { + resolution: 2 + }); + + expect(renderer.view.style.width).to.equal(''); + }); + }); +}); diff --git a/test/unit/pixi-v2/renderers/webgl/WebGLShaders.js b/test/unit/pixi-v2/renderers/webgl/WebGLShaders.js new file mode 100644 index 0000000..6e33e4f --- /dev/null +++ b/test/unit/pixi-v2/renderers/webgl/WebGLShaders.js @@ -0,0 +1,13 @@ +describe('renderers/webgl/WebGLShaders', function () { + 'use strict'; + + var expect = chai.expect; + + it('Module members exist', function () { + + expect(PIXI).to.respondTo('CompileVertexShader'); + expect(PIXI).to.respondTo('CompileFragmentShader'); + expect(PIXI).to.respondTo('_CompileShader'); + expect(PIXI).to.respondTo('compileProgram'); + }); +}); diff --git a/test/unit/pixi-v2/renderers/webgl/WebGLSpriteBatch.js b/test/unit/pixi-v2/renderers/webgl/WebGLSpriteBatch.js new file mode 100644 index 0000000..e662b63 --- /dev/null +++ b/test/unit/pixi-v2/renderers/webgl/WebGLSpriteBatch.js @@ -0,0 +1,10 @@ +describe('renderers/webgl/utils/WebGLSpriteBatch', function () { + 'use strict'; + + var expect = chai.expect; + var WebGLSpriteBatch = PIXI.WebGLSpriteBatch; + + it('Module exists', function () { + expect(WebGLSpriteBatch).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/text/BitmapText.js b/test/unit/pixi-v2/text/BitmapText.js new file mode 100644 index 0000000..9388e3d --- /dev/null +++ b/test/unit/pixi-v2/text/BitmapText.js @@ -0,0 +1,10 @@ +describe('pixi/text/BitmapText', function () { + 'use strict'; + + var expect = chai.expect; + var BitmapText = PIXI.BitmapText; + + it('Module exists', function () { + expect(BitmapText).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/text/Text.js b/test/unit/pixi-v2/text/Text.js new file mode 100644 index 0000000..9bc9ac5 --- /dev/null +++ b/test/unit/pixi-v2/text/Text.js @@ -0,0 +1,10 @@ +describe('pixi/text/Text', function () { + 'use strict'; + + var expect = chai.expect; + var Text = PIXI.Text; + + it('Module exists', function () { + expect(Text).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/textures/BaseTexture.js b/test/unit/pixi-v2/textures/BaseTexture.js new file mode 100644 index 0000000..502b724 --- /dev/null +++ b/test/unit/pixi-v2/textures/BaseTexture.js @@ -0,0 +1,11 @@ +describe('pixi/textures/BaseTexture', function () { + 'use strict'; + + var expect = chai.expect; + var BaseTexture = PIXI.BaseTexture; + + it('Module exists', function () { + expect(BaseTexture).to.be.a('function'); + expect(PIXI).to.have.property('BaseTextureCache').and.to.be.an('object'); + }); +}); diff --git a/test/unit/pixi-v2/textures/RenderTexture.js b/test/unit/pixi-v2/textures/RenderTexture.js new file mode 100644 index 0000000..96acdb4 --- /dev/null +++ b/test/unit/pixi-v2/textures/RenderTexture.js @@ -0,0 +1,15 @@ +describe('pixi/textures/RenderTexture', function () { + 'use strict'; + + var expect = chai.expect; + var RenderTexture = PIXI.RenderTexture; + + it('Module exists', function () { + expect(RenderTexture).to.be.a('function'); + }); + + it('Confirm new instance', function (done) { + var texture = new RenderTexture(100, 100, new PIXI.CanvasRenderer()); + pixi_textures_RenderTexture_confirmNew(texture, done); + }); +}); diff --git a/test/unit/pixi-v2/textures/Texture.js b/test/unit/pixi-v2/textures/Texture.js new file mode 100644 index 0000000..090f64d --- /dev/null +++ b/test/unit/pixi-v2/textures/Texture.js @@ -0,0 +1,26 @@ +describe('pixi/textures/Texture', function () { + 'use strict'; + + var expect = chai.expect; + var Texture = PIXI.Texture; + + it('Module exists', function () { + expect(Texture).to.be.a('function'); + expect(PIXI).to.have.property('TextureCache').and.to.be.an('object'); + }); + + it('Members exist', function () { + expect(Texture).itself.to.respondTo('fromImage'); + expect(Texture).itself.to.respondTo('fromFrame'); + expect(Texture).itself.to.respondTo('fromCanvas'); + expect(Texture).itself.to.respondTo('addTextureToCache'); + expect(Texture).itself.to.respondTo('removeTextureFromCache'); + + // expect(Texture).itself.to.have.deep.property('frameUpdates.length', 0); + }); + + it('Confirm new instance', function (done) { + var texture = Texture.fromImage('/base/test/textures/bunny.png'); + pixi_textures_Texture_confirmNew(texture, done); + }); +}); diff --git a/test/unit/pixi-v2/utils/Detector.js b/test/unit/pixi-v2/utils/Detector.js new file mode 100644 index 0000000..4cf6008 --- /dev/null +++ b/test/unit/pixi-v2/utils/Detector.js @@ -0,0 +1,10 @@ +describe('pixi/utils/Detector', function () { + 'use strict'; + + var expect = chai.expect; + var autoDetectRenderer = PIXI.autoDetectRenderer; + + it('Module exists', function () { + expect(autoDetectRenderer).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/utils/EventTarget.js b/test/unit/pixi-v2/utils/EventTarget.js new file mode 100644 index 0000000..1cfc3a4 --- /dev/null +++ b/test/unit/pixi-v2/utils/EventTarget.js @@ -0,0 +1,361 @@ +describe('pixi/utils/EventTarget', function () { + 'use strict'; + + var expect = chai.expect; + + var Clazz, PClazz, obj, pobj, obj2; + beforeEach(function () { + Clazz = function () {}; + PClazz = function () {}; + + PIXI.EventTarget.mixin(Clazz.prototype); + PIXI.EventTarget.mixin(PClazz.prototype); + + obj = new Clazz(); + obj2 = new Clazz(); + pobj = new PClazz(); + + obj.parent = pobj; + obj2.parent = obj; + }); + + it('Module exists', function () { + expect(PIXI.EventTarget).to.be.an('object'); + }); + + it('Confirm new instance', function () { + pixi_utils_EventTarget_confirm(obj); + }); + + it('simple on/emit case works', function () { + var myData = {}; + + obj.on('myevent', function (event) { + pixi_utils_EventTarget_Event_confirm(event, obj, myData); + }); + + obj.emit('myevent', myData); + }); + + it('simple once case works', function () { + var called = 0; + + obj.once('myevent', function() { called++; }); + + obj.emit('myevent'); + obj.emit('myevent'); + obj.emit('myevent'); + obj.emit('myevent'); + obj.emit('myevent'); + + expect(called).to.equal(1); + }); + + it('simple off case works', function (done) { + function onMyEvent() { + done(new Error('Event listener should not have been called')); + } + + obj.on('myevent', onMyEvent); + obj.off('myevent', onMyEvent); + obj.emit('myevent'); + + done(); + }); + + it('simple propagation case works', function (done) { + var myData = {}; + + pobj.on('myevent', function () { + done(); + }); + + obj.emit('myevent'); + }); + + it('simple stopPropagation case works', function (done) { + var myData = {}; + + pobj.on('myevent', function () { + done(new Error('Event listener should not have been called on the parent element')); + }); + + obj.on('myevent', function (evt) { + evt.stopPropagation(); + }); + + obj.emit('myevent'); + + done(); + }); + + it('simple stopImmediatePropagation case works', function (done) { + var myData = {}; + + pobj.on('myevent', function () { + done(new Error('Event listener should not have been called on the parent')); + }); + + obj.on('myevent', function (evt) { + evt.stopImmediatePropagation(); + }); + + obj.on('myevent', function () { + done(new Error('Event listener should not have been called on the second')); + }); + + obj.emit('myevent'); + + done(); + }); + + it('multiple dispatches work properly', function () { + var called = 0; + + function onMyEvent() { + called++; + } + + obj.on('myevent', onMyEvent); + obj.emit('myevent'); + obj.emit('myevent'); + obj.emit('myevent'); + obj.emit('myevent'); + + expect(called).to.equal(4); + }); + + it('multiple events work properly', function () { + var called = 0; + + function onMyEvent() { + called++; + } + + obj.on('myevent1', onMyEvent); + obj.on('myevent2', onMyEvent); + obj.on('myevent3', onMyEvent); + obj.emit('myevent1'); + obj.emit('myevent2'); + obj.emit('myevent3'); + + expect(called).to.equal(3); + }); + + it('multiple events one removed works properly', function () { + var called = 0; + + function onMyEvent() { + called++; + } + + obj.on('myevent1', onMyEvent); + obj.on('myevent2', onMyEvent); + obj.on('myevent3', onMyEvent); + + obj.emit('myevent1'); + obj.emit('myevent2'); + obj.emit('myevent3'); + + obj.off('myevent2', onMyEvent); + + obj.emit('myevent1'); + obj.emit('myevent2'); + obj.emit('myevent3'); + + expect(called).to.equal(5); + }); + + it('multiple handlers for one event with some removed', function () { + var called = 0; + + var onMyEvent = function () { + called++; + }, + onMyEvent2 = function () { + called++; + }; + + // add 2 handlers and confirm they both get called + obj.on('myevent', onMyEvent); + obj.on('myevent', onMyEvent); + obj.on('myevent', onMyEvent2); + obj.on('myevent', onMyEvent2); + + obj.emit('myevent'); + + expect(called).to.equal(4); + + // remove one of the handlers, emit again, then ensure 1 more call is made + obj.off('myevent', onMyEvent); + + obj.emit('myevent'); + + expect(called).to.equal(6); + }); + + it('calls to off without a handler do nothing', function () { + var called = 0; + + var onMyEvent = function () { + called++; + }; + + obj.on('myevent', onMyEvent); + obj.on('myevent', onMyEvent); + + obj.emit('myevent'); + + expect(called).to.equal(2); + + obj.off('myevent'); + + obj.emit('myevent'); + + expect(called).to.equal(4); + + obj.off('myevent', onMyEvent); + + obj.emit('myevent'); + + expect(called).to.equal(4); + }); + + it('handles multiple instances with the same prototype', function () { + var called = 0; + + function onMyEvent(e) { + called++; + } + + obj.on('myevent1', onMyEvent); + obj.on('myevent2', onMyEvent); + + obj2.istwo = true; + obj2.on('myevent1', onMyEvent); + obj2.on('myevent2', onMyEvent); + + obj.emit('myevent1'); + obj.emit('myevent2'); + obj2.emit('myevent1'); + obj2.emit('myevent2'); + + //we emit 4 times, but since obj2 is a child of obj the event should bubble + //up to obj and show up there as well. So the obj2.emit() calls each increment + //the counter twice. + expect(called).to.equal(6); + }); + + it('is backwards compatible with older .dispatchEvent({})', function () { + var called = 0, + data = { + some: 'thing', + hello: true + }; + + function onMyEvent(event) { + pixi_utils_EventTarget_Event_confirm(event, obj, data); + + called++; + } + + obj.on('myevent1', onMyEvent); + obj.on('myevent2', onMyEvent); + obj.on('myevent3', onMyEvent); + + data.type = 'myevent1'; + obj.emit(data); + + data.type = 'myevent2'; + obj.emit(data); + + data.type = 'myevent3'; + obj.emit(data); + + obj.off('myevent2', onMyEvent); + + data.type = 'myevent1'; + obj.emit(data); + + data.type = 'myevent2'; + obj.emit(data); + + data.type = 'myevent3'; + obj.emit(data); + + expect(called).to.equal(5); + }); + + it('is backwards compatible with older .call(this)', function () { + var Fn = function() { + PIXI.EventTarget.call(this); + }, + o = new Fn(); + + pixi_utils_EventTarget_confirm(o); + }); + + it('is backwards compatible with older .addEventListener("")', function () { + var called = 0, + data = { + some: 'thing', + hello: true + }; + + function onMyEvent(event) { + pixi_utils_EventTarget_Event_confirm(event, obj, data); + + called++; + } + + obj.addEventListener('myevent1', onMyEvent); + obj.addEventListener('myevent2', onMyEvent); + obj.addEventListener('myevent3', onMyEvent); + + data.type = 'myevent1'; + obj.emit(data); + + data.type = 'myevent2'; + obj.emit(data); + + data.type = 'myevent3'; + obj.emit(data); + + obj.off('myevent2', onMyEvent); + + data.type = 'myevent1'; + obj.emit(data); + + data.type = 'myevent2'; + obj.emit(data); + + data.type = 'myevent3'; + obj.emit(data); + + expect(called).to.equal(5); + }); + + it('event remove during emit call properly', function () { + var called = 0; + + function cb1() { + called++; + obj.off('myevent', cb1); + } + function cb2() { + called++; + obj.off('myevent', cb2); + } + function cb3() { + called++; + obj.off('myevent', cb3); + } + + obj.on('myevent', cb1); + obj.on('myevent', cb2); + obj.on('myevent', cb3); + obj.emit('myevent', ''); + + expect(called).to.equal(3); + }); +}); diff --git a/test/unit/pixi-v2/utils/Polyk.js b/test/unit/pixi-v2/utils/Polyk.js new file mode 100644 index 0000000..dfc7128 --- /dev/null +++ b/test/unit/pixi-v2/utils/Polyk.js @@ -0,0 +1,14 @@ +describe('pixi/utils/Polyk', function () { + 'use strict'; + + var expect = chai.expect; + var PolyK = PIXI.PolyK; + + it('Module exists', function () { + expect(PolyK).to.be.an('object'); + }); + + it('Members exist', function () { + expect(PolyK).to.respondTo('Triangulate'); + }); +}); diff --git a/test/unit/pixi-v2/utils/Utils.js b/test/unit/pixi-v2/utils/Utils.js new file mode 100644 index 0000000..c97b3c6 --- /dev/null +++ b/test/unit/pixi-v2/utils/Utils.js @@ -0,0 +1,17 @@ +describe('Utils', function () { + 'use strict'; + + var expect = chai.expect; + + it('requestAnimationFrame exists', function () { + expect(global).to.respondTo('requestAnimationFrame'); + }); + + it('cancelAnimationFrame exists', function () { + expect(global).to.respondTo('cancelAnimationFrame'); + }); + + it('requestAnimFrame exists', function () { + expect(global).to.respondTo('requestAnimFrame'); + }); +}); diff --git a/test/unit/pixi/InteractionManager.js b/test/unit/pixi/InteractionManager.js deleted file mode 100644 index ed3001f..0000000 --- a/test/unit/pixi/InteractionManager.js +++ /dev/null @@ -1,10 +0,0 @@ -describe('pixi/InteractionManager', function () { - 'use strict'; - - var expect = chai.expect; - var InteractionManager = PIXI.InteractionManager; - - it('Module exists', function () { - expect(InteractionManager).to.be.a('function'); - }); -}); diff --git a/test/unit/pixi/Pixi.js b/test/unit/pixi/Pixi.js deleted file mode 100644 index 27debc1..0000000 --- a/test/unit/pixi/Pixi.js +++ /dev/null @@ -1,9 +0,0 @@ -describe('pixi/Pixi', function () { - 'use strict'; - - var expect = chai.expect; - - it('Module exists', function () { - expect(global).to.have.property('PIXI').and.to.be.an('object'); - }); -}); diff --git a/test/unit/pixi/core/Circle.js b/test/unit/pixi/core/Circle.js deleted file mode 100644 index fbcfa17..0000000 --- a/test/unit/pixi/core/Circle.js +++ /dev/null @@ -1,21 +0,0 @@ -describe('pixi/core/Circle', function () { - 'use strict'; - - var expect = chai.expect; - var Circle = PIXI.Circle; - - it('Module exists', function () { - expect(Circle).to.be.a('function'); - }); - - it('Confirm new instance', function () { - var obj = new Circle(); - pixi_core_Circle_confirmNewCircle(obj); - }); - - it("getBounds should return Rectangle that bounds the circle", function() { - var obj = new Circle(100, 250, 50); - var bounds = obj.getBounds(); - pixi_core_Circle_isBoundedByRectangle(obj, bounds); - }); -}); diff --git a/test/unit/pixi/core/Ellipse.js b/test/unit/pixi/core/Ellipse.js deleted file mode 100644 index 026b56f..0000000 --- a/test/unit/pixi/core/Ellipse.js +++ /dev/null @@ -1,24 +0,0 @@ -describe('pixi/core/Ellipse', function () { - 'use strict'; - - var expect = chai.expect; - var Ellipse = PIXI.Ellipse; - - it('Module exists', function () { - expect(Ellipse).to.be.a('function'); - }); - - it('Confirm new instance', function () { - var obj = new Ellipse(); - - expect(obj).to.be.an.instanceof(Ellipse); - expect(obj).to.respondTo('clone'); - expect(obj).to.respondTo('contains'); - expect(obj).to.respondTo('getBounds'); - - expect(obj).to.have.property('x', 0); - expect(obj).to.have.property('y', 0); - expect(obj).to.have.property('width', 0); - expect(obj).to.have.property('height', 0); - }); -}); diff --git a/test/unit/pixi/core/Matrix.js b/test/unit/pixi/core/Matrix.js deleted file mode 100644 index da75e2e..0000000 --- a/test/unit/pixi/core/Matrix.js +++ /dev/null @@ -1,14 +0,0 @@ -describe('pixi/core/Matrix', function () { - 'use strict'; - - var expect = chai.expect; - - it('Matrix exists', function () { - expect(PIXI.Matrix).to.be.an('function'); - }); - - it('Confirm new Matrix', function () { - var matrix = new PIXI.Matrix(); - pixi_core_Matrix_confirmNewMatrix(matrix); - }); -}); diff --git a/test/unit/pixi/core/Point.js b/test/unit/pixi/core/Point.js deleted file mode 100644 index c4d5163..0000000 --- a/test/unit/pixi/core/Point.js +++ /dev/null @@ -1,15 +0,0 @@ -describe('pixi/core/Point', function () { - 'use strict'; - - var expect = chai.expect; - var Point = PIXI.Point; - - it('Module exists', function () { - expect(Point).to.be.a('function'); - }); - - it('Confirm new instance', function () { - var obj = new Point(); - pixi_core_Point_confirm(obj, 0, 0); - }); -}); diff --git a/test/unit/pixi/core/Polygon.js b/test/unit/pixi/core/Polygon.js deleted file mode 100644 index dc8c918..0000000 --- a/test/unit/pixi/core/Polygon.js +++ /dev/null @@ -1,20 +0,0 @@ -describe('pixi/core/Polygon', function () { - 'use strict'; - - var expect = chai.expect; - var Polygon = PIXI.Polygon; - - it('Module exists', function () { - expect(Polygon).to.be.a('function'); - }); - - it('Confirm new instance', function () { - var obj = new Polygon(); - - expect(obj).to.be.an.instanceof(Polygon); - expect(obj).to.respondTo('clone'); - expect(obj).to.respondTo('contains'); - - expect(obj).to.have.deep.property('points.length', 0); - }); -}); diff --git a/test/unit/pixi/core/Rectangle.js b/test/unit/pixi/core/Rectangle.js deleted file mode 100644 index d43316e..0000000 --- a/test/unit/pixi/core/Rectangle.js +++ /dev/null @@ -1,15 +0,0 @@ -describe('pixi/core/Rectangle', function () { - 'use strict'; - - var expect = chai.expect; - var Rectangle = PIXI.Rectangle; - - it('Module exists', function () { - expect(Rectangle).to.be.a('function'); - }); - - it('Confirm new instance', function () { - var rect = new Rectangle(); - pixi_core_Rectangle_confirm(rect, 0, 0, 0, 0); - }); -}); diff --git a/test/unit/pixi/display/DisplayObject.js b/test/unit/pixi/display/DisplayObject.js deleted file mode 100644 index 044acf8..0000000 --- a/test/unit/pixi/display/DisplayObject.js +++ /dev/null @@ -1,21 +0,0 @@ -describe('pixi/display/DisplayObject', function () { - 'use strict'; - - var expect = chai.expect; - var DisplayObject = PIXI.DisplayObject; - - it('Module exists', function () { - expect(DisplayObject).to.be.a('function'); - // expect(PIXI).to.have.property('visibleCount', 0); - }); - - it('Confirm new instance', function () { - var obj = new DisplayObject(); - - pixi_display_DisplayObject_confirmNew(obj); - expect(obj).to.have.property('hitArea', null); - expect(obj).to.have.property('interactive', false); - expect(obj).to.have.property('renderable', false); - expect(obj).to.have.property('stage', null); - }); -}); diff --git a/test/unit/pixi/display/DisplayObjectContainer.js b/test/unit/pixi/display/DisplayObjectContainer.js deleted file mode 100644 index 15a3376..0000000 --- a/test/unit/pixi/display/DisplayObjectContainer.js +++ /dev/null @@ -1,67 +0,0 @@ -describe('pixi/display/DisplayObjectContainer', function () { - 'use strict'; - - var expect = chai.expect; - var DisplayObjectContainer = PIXI.DisplayObjectContainer; - - it('Module exists', function () { - expect(DisplayObjectContainer).to.be.a('function'); - }); - - it('Confirm new instance', function () { - var obj = new DisplayObjectContainer(); - - pixi_display_DisplayObjectContainer_confirmNew(obj); - expect(obj).to.have.property('hitArea', null); - expect(obj).to.have.property('interactive', false); - expect(obj).to.have.property('renderable', false); - expect(obj).to.have.property('stage', null); - }); - - it('Gets child index', function() { - var container = new PIXI.DisplayObjectContainer(); - var children = []; - for (var i = 0; i < 10; i++) { - var child = new PIXI.DisplayObject(); - children.push(child); - container.addChild(child); - } - - for (i = 0; i < children.length; i++) { - expect(i).to.eql(container.getChildIndex(children[i])); - } - }); - - it('throws error when trying to get index of not a child', function() { - var container = new PIXI.DisplayObjectContainer(); - var child = new PIXI.DisplayObject(); - - expect(function() { container.getChildIndex(child); }).to.throw(); - }); - - it('Sets child index', function() { - var container = new PIXI.DisplayObjectContainer(); - var children = []; - - for (var i = 0; i < 10; i++) { - var child = new PIXI.DisplayObject(); - children.push(child); - container.addChild(child); - } - children.reverse(); - - for (i = 0; i < children.length; i++) { - container.setChildIndex(children[i], i); - expect(i).to.eql(container.getChildIndex(children[i])); - } - }); - - it('throws error when trying to set incorect index', function() { - var container = new PIXI.DisplayObjectContainer(); - var child = new PIXI.DisplayObject(); - container.addChild(child); - - expect(function() { container.setChildIndex(child, -1); }).to.throw(); - expect(function() { container.setChildIndex(child, 1); }).to.throw(); - }); -}); diff --git a/test/unit/pixi/display/MovieClip.js b/test/unit/pixi/display/MovieClip.js deleted file mode 100644 index f3c6c6a..0000000 --- a/test/unit/pixi/display/MovieClip.js +++ /dev/null @@ -1,33 +0,0 @@ -describe('pixi/display/MovieClip', function () { - 'use strict'; - - var expect = chai.expect; - var MovieClip = PIXI.MovieClip; - var Texture = PIXI.Texture; - - it('Module exists', function () { - expect(MovieClip).to.be.a('function'); - }); - - it('Confirm new instance', function (done) { - var texture = Texture.fromImage('/base/test/textures/SpriteSheet-Explosion.png'); - var obj = new MovieClip([texture]); - - pixi_display_Sprite_confirmNew(obj, done); - - expect(obj).to.be.an.instanceof(MovieClip); - expect(obj).to.respondTo('stop'); - expect(obj).to.respondTo('play'); - expect(obj).to.respondTo('gotoAndStop'); - expect(obj).to.respondTo('gotoAndPlay'); - expect(obj).to.respondTo('updateTransform'); - - expect(obj).to.have.deep.property('textures.length', 1); - expect(obj).to.have.deep.property('textures[0]', texture); - expect(obj).to.have.property('animationSpeed', 1); - expect(obj).to.have.property('loop', true); - expect(obj).to.have.property('onComplete', null); - expect(obj).to.have.property('currentFrame', 0); - expect(obj).to.have.property('playing', false); - }); -}); diff --git a/test/unit/pixi/display/Sprite.js b/test/unit/pixi/display/Sprite.js deleted file mode 100644 index 30c8076..0000000 --- a/test/unit/pixi/display/Sprite.js +++ /dev/null @@ -1,28 +0,0 @@ -describe('pixi/display/Sprite', function () { - 'use strict'; - - var expect = chai.expect; - var Sprite = PIXI.Sprite; - var Texture = PIXI.Texture; - - it('Module exists', function () { - expect(Sprite).to.be.a('function'); - expect(PIXI).to.have.deep.property('blendModes.NORMAL', 0); - expect(PIXI).to.have.deep.property('blendModes.ADD', 1); - expect(PIXI).to.have.deep.property('blendModes.MULTIPLY', 2); - expect(PIXI).to.have.deep.property('blendModes.SCREEN', 3); - }); - - - it('Members exist', function () { - expect(Sprite).itself.to.respondTo('fromImage'); - expect(Sprite).itself.to.respondTo('fromFrame'); - }); - - it('Confirm new instance', function (done) { - var texture = Texture.fromImage('/base/test/textures/SpriteSheet-Aliens.png'); - var obj = new Sprite(texture); - - pixi_display_Sprite_confirmNew(obj, done); - }); -}); diff --git a/test/unit/pixi/display/Stage.js b/test/unit/pixi/display/Stage.js deleted file mode 100644 index 6974c2e..0000000 --- a/test/unit/pixi/display/Stage.js +++ /dev/null @@ -1,49 +0,0 @@ -describe('pixi/display/Stage', function () { - 'use strict'; - - var expect = chai.expect; - var Stage = PIXI.Stage; - var InteractionManager = PIXI.InteractionManager; - var Rectangle = PIXI.Rectangle; - - it('Module exists', function () { - expect(Stage).to.be.a('function'); - }); - - it('Confirm new instance', function () { - var obj = new Stage(null, true); - - pixi_display_DisplayObjectContainer_confirmNew(obj); - - expect(obj).to.be.an.instanceof(Stage); - expect(obj).to.respondTo('updateTransform'); - expect(obj).to.respondTo('setBackgroundColor'); - expect(obj).to.respondTo('getMousePosition'); - // FIXME: duplicate member in DisplayObject - pixi_core_Matrix_confirmNewMatrix(obj.worldTransform); - // FIXME: convert arg to bool in constructor - expect(obj).to.have.property('interactive', true); - - expect(obj).to.have.property('interactionManager') - .and.to.be.an.instanceof(InteractionManager) - .and.to.have.property('stage', obj); - - expect(obj).to.have.property('dirty', true); - - expect(obj).to.have.property('stage', obj); - - expect(obj).to.have.property('hitArea') - .and.to.be.an.instanceof(Rectangle); - pixi_core_Rectangle_confirm(obj.hitArea, 0, 0, 100000, 100000); - - expect(obj).to.have.property('backgroundColor', 0x000000); - expect(obj).to.have.deep.property('backgroundColorSplit.length', 3); - expect(obj).to.have.deep.property('backgroundColorSplit[0]', 0); - expect(obj).to.have.deep.property('backgroundColorSplit[1]', 0); - expect(obj).to.have.deep.property('backgroundColorSplit[2]', 0); - expect(obj).to.have.property('backgroundColorString', '#000000'); - - - expect(obj).to.have.property('worldVisible', true); - }); -}); diff --git a/test/unit/pixi/extras/Rope.js b/test/unit/pixi/extras/Rope.js deleted file mode 100644 index 05885ac..0000000 --- a/test/unit/pixi/extras/Rope.js +++ /dev/null @@ -1,31 +0,0 @@ -describe('pixi/extras/Rope', function () { - 'use strict'; - - var expect = chai.expect; - var Rope = PIXI.Rope; - var Texture = PIXI.Texture; - var Point = PIXI.Point; - - it('Module exists', function () { - expect(Rope).to.be.a('function'); - }); - - it('Confirm new instance', function () { - - var texture = Texture.fromImage('/base/test/textures/bunny.png'); - - // TODO-Alvin - // Same as Strip - - // var obj = new Rope(texture, [new Point(), new Point(5, 10), new Point(10, 20)]); - - // pixi_extras_Strip_confirmNew(obj); - - // expect(obj).to.be.an.instanceof(Rope); - // expect(obj).to.respondTo('refresh'); - // expect(obj).to.respondTo('updateTransform'); - // expect(obj).to.respondTo('setTexture'); - - // TODO: Test properties - }); -}); diff --git a/test/unit/pixi/extras/Spine.js b/test/unit/pixi/extras/Spine.js deleted file mode 100644 index 0708bc0..0000000 --- a/test/unit/pixi/extras/Spine.js +++ /dev/null @@ -1,10 +0,0 @@ -describe('pixi/extras/Spine', function () { - 'use strict'; - - var expect = chai.expect; - var Spine = PIXI.Spine; - - it('Module exists', function () { - expect(Spine).to.be.a('function'); - }); -}); diff --git a/test/unit/pixi/extras/Strip.js b/test/unit/pixi/extras/Strip.js deleted file mode 100644 index 230af90..0000000 --- a/test/unit/pixi/extras/Strip.js +++ /dev/null @@ -1,26 +0,0 @@ -describe('pixi/extras/Strip', function () { - 'use strict'; - - var expect = chai.expect; - var Strip = PIXI.Strip; - var Texture = PIXI.Texture; - - it('Module exists', function () { - expect(Strip).to.be.a('function'); - }); - - it('Confirm new instance', function () { - - - // TODO-Alvin - // We tweaked it to make it pass the tests, but the whole strip class needs - // to be re-coded - - var texture = Texture.fromImage('/base/test/textures/bunny.png'); - - // var obj = new Strip(texture, 20, 10000); - - - // pixi_extras_Strip_confirmNew(obj); - }); -}); diff --git a/test/unit/pixi/extras/TilingSprite.js b/test/unit/pixi/extras/TilingSprite.js deleted file mode 100644 index 56aea14..0000000 --- a/test/unit/pixi/extras/TilingSprite.js +++ /dev/null @@ -1,24 +0,0 @@ -describe('pixi/extras/TilingSprite', function () { - 'use strict'; - - var expect = chai.expect; - var TilingSprite = PIXI.TilingSprite; - var Texture = PIXI.Texture; - - it('Module exists', function () { - expect(TilingSprite).to.be.a('function'); - }); - - it('Confirm new instance', function () { - var texture = Texture.fromImage('/base/test/textures/bunny.png'); - var obj = new TilingSprite(texture, 6000, 12000); - - pixi_display_DisplayObjectContainer_confirmNew(obj); - - expect(obj).to.be.an.instanceof(TilingSprite); - expect(obj).to.respondTo('setTexture'); - expect(obj).to.respondTo('onTextureUpdate'); - - // TODO: Test properties - }); -}); diff --git a/test/unit/pixi/filters/FilterBlock.js b/test/unit/pixi/filters/FilterBlock.js deleted file mode 100644 index 870cec0..0000000 --- a/test/unit/pixi/filters/FilterBlock.js +++ /dev/null @@ -1,10 +0,0 @@ -describe('pixi/filters/FilterBlock', function () { - 'use strict'; - - var expect = chai.expect; - var FilterBlock = PIXI.FilterBlock; - - it('Module exists', function () { - expect(FilterBlock).to.be.a('function'); - }); -}); diff --git a/test/unit/pixi/loaders/AssetLoader.js b/test/unit/pixi/loaders/AssetLoader.js deleted file mode 100644 index a0aa0b5..0000000 --- a/test/unit/pixi/loaders/AssetLoader.js +++ /dev/null @@ -1,10 +0,0 @@ -describe('pixi/loaders/AssetLoader', function () { - 'use strict'; - - var expect = chai.expect; - var AssetLoader = PIXI.AssetLoader; - - it('Module exists', function () { - expect(AssetLoader).to.be.a('function'); - }); -}); diff --git a/test/unit/pixi/loaders/BitmapFontLoader.js b/test/unit/pixi/loaders/BitmapFontLoader.js deleted file mode 100644 index 046f018..0000000 --- a/test/unit/pixi/loaders/BitmapFontLoader.js +++ /dev/null @@ -1,9 +0,0 @@ -describe('pixi/loaders/BitmapFontLoader', function () { - 'use strict'; - - var expect = chai.expect; - - it('Module exists', function () { - expect(PIXI.BitmapFontLoader).to.be.a('function'); - }); -}); diff --git a/test/unit/pixi/loaders/ImageLoader.js b/test/unit/pixi/loaders/ImageLoader.js deleted file mode 100644 index 8b1f556..0000000 --- a/test/unit/pixi/loaders/ImageLoader.js +++ /dev/null @@ -1,10 +0,0 @@ -describe('pixi/loaders/ImageLoader', function () { - 'use strict'; - - var expect = chai.expect; - var ImageLoader = PIXI.ImageLoader; - - it('Module exists', function () { - expect(ImageLoader).to.be.a('function'); - }); -}); diff --git a/test/unit/pixi/loaders/JsonLoader.js b/test/unit/pixi/loaders/JsonLoader.js deleted file mode 100644 index c577e83..0000000 --- a/test/unit/pixi/loaders/JsonLoader.js +++ /dev/null @@ -1,10 +0,0 @@ -describe('pixi/loaders/JsonLoader', function () { - 'use strict'; - - var expect = chai.expect; - var JsonLoader = PIXI.JsonLoader; - - it('Module exists', function () { - expect(JsonLoader).to.be.a('function'); - }); -}); diff --git a/test/unit/pixi/loaders/SpineLoader.js b/test/unit/pixi/loaders/SpineLoader.js deleted file mode 100644 index fdcc0b8..0000000 --- a/test/unit/pixi/loaders/SpineLoader.js +++ /dev/null @@ -1,10 +0,0 @@ -describe('pixi/loaders/SpineLoader', function () { - 'use strict'; - - var expect = chai.expect; - var SpineLoader = PIXI.SpineLoader; - - it('Module exists', function () { - expect(SpineLoader).to.be.a('function'); - }); -}); diff --git a/test/unit/pixi-v2/InteractionManager.js b/test/unit/pixi-v2/InteractionManager.js new file mode 100644 index 0000000..ed3001f --- /dev/null +++ b/test/unit/pixi-v2/InteractionManager.js @@ -0,0 +1,10 @@ +describe('pixi/InteractionManager', function () { + 'use strict'; + + var expect = chai.expect; + var InteractionManager = PIXI.InteractionManager; + + it('Module exists', function () { + expect(InteractionManager).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/Pixi.js b/test/unit/pixi-v2/Pixi.js new file mode 100644 index 0000000..27debc1 --- /dev/null +++ b/test/unit/pixi-v2/Pixi.js @@ -0,0 +1,9 @@ +describe('pixi/Pixi', function () { + 'use strict'; + + var expect = chai.expect; + + it('Module exists', function () { + expect(global).to.have.property('PIXI').and.to.be.an('object'); + }); +}); diff --git a/test/unit/pixi-v2/core/Circle.js b/test/unit/pixi-v2/core/Circle.js new file mode 100644 index 0000000..fbcfa17 --- /dev/null +++ b/test/unit/pixi-v2/core/Circle.js @@ -0,0 +1,21 @@ +describe('pixi/core/Circle', function () { + 'use strict'; + + var expect = chai.expect; + var Circle = PIXI.Circle; + + it('Module exists', function () { + expect(Circle).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Circle(); + pixi_core_Circle_confirmNewCircle(obj); + }); + + it("getBounds should return Rectangle that bounds the circle", function() { + var obj = new Circle(100, 250, 50); + var bounds = obj.getBounds(); + pixi_core_Circle_isBoundedByRectangle(obj, bounds); + }); +}); diff --git a/test/unit/pixi-v2/core/Ellipse.js b/test/unit/pixi-v2/core/Ellipse.js new file mode 100644 index 0000000..026b56f --- /dev/null +++ b/test/unit/pixi-v2/core/Ellipse.js @@ -0,0 +1,24 @@ +describe('pixi/core/Ellipse', function () { + 'use strict'; + + var expect = chai.expect; + var Ellipse = PIXI.Ellipse; + + it('Module exists', function () { + expect(Ellipse).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Ellipse(); + + expect(obj).to.be.an.instanceof(Ellipse); + expect(obj).to.respondTo('clone'); + expect(obj).to.respondTo('contains'); + expect(obj).to.respondTo('getBounds'); + + expect(obj).to.have.property('x', 0); + expect(obj).to.have.property('y', 0); + expect(obj).to.have.property('width', 0); + expect(obj).to.have.property('height', 0); + }); +}); diff --git a/test/unit/pixi-v2/core/Matrix.js b/test/unit/pixi-v2/core/Matrix.js new file mode 100644 index 0000000..da75e2e --- /dev/null +++ b/test/unit/pixi-v2/core/Matrix.js @@ -0,0 +1,14 @@ +describe('pixi/core/Matrix', function () { + 'use strict'; + + var expect = chai.expect; + + it('Matrix exists', function () { + expect(PIXI.Matrix).to.be.an('function'); + }); + + it('Confirm new Matrix', function () { + var matrix = new PIXI.Matrix(); + pixi_core_Matrix_confirmNewMatrix(matrix); + }); +}); diff --git a/test/unit/pixi-v2/core/Point.js b/test/unit/pixi-v2/core/Point.js new file mode 100644 index 0000000..c4d5163 --- /dev/null +++ b/test/unit/pixi-v2/core/Point.js @@ -0,0 +1,15 @@ +describe('pixi/core/Point', function () { + 'use strict'; + + var expect = chai.expect; + var Point = PIXI.Point; + + it('Module exists', function () { + expect(Point).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Point(); + pixi_core_Point_confirm(obj, 0, 0); + }); +}); diff --git a/test/unit/pixi-v2/core/Polygon.js b/test/unit/pixi-v2/core/Polygon.js new file mode 100644 index 0000000..dc8c918 --- /dev/null +++ b/test/unit/pixi-v2/core/Polygon.js @@ -0,0 +1,20 @@ +describe('pixi/core/Polygon', function () { + 'use strict'; + + var expect = chai.expect; + var Polygon = PIXI.Polygon; + + it('Module exists', function () { + expect(Polygon).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Polygon(); + + expect(obj).to.be.an.instanceof(Polygon); + expect(obj).to.respondTo('clone'); + expect(obj).to.respondTo('contains'); + + expect(obj).to.have.deep.property('points.length', 0); + }); +}); diff --git a/test/unit/pixi-v2/core/Rectangle.js b/test/unit/pixi-v2/core/Rectangle.js new file mode 100644 index 0000000..d43316e --- /dev/null +++ b/test/unit/pixi-v2/core/Rectangle.js @@ -0,0 +1,15 @@ +describe('pixi/core/Rectangle', function () { + 'use strict'; + + var expect = chai.expect; + var Rectangle = PIXI.Rectangle; + + it('Module exists', function () { + expect(Rectangle).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var rect = new Rectangle(); + pixi_core_Rectangle_confirm(rect, 0, 0, 0, 0); + }); +}); diff --git a/test/unit/pixi-v2/display/DisplayObject.js b/test/unit/pixi-v2/display/DisplayObject.js new file mode 100644 index 0000000..044acf8 --- /dev/null +++ b/test/unit/pixi-v2/display/DisplayObject.js @@ -0,0 +1,21 @@ +describe('pixi/display/DisplayObject', function () { + 'use strict'; + + var expect = chai.expect; + var DisplayObject = PIXI.DisplayObject; + + it('Module exists', function () { + expect(DisplayObject).to.be.a('function'); + // expect(PIXI).to.have.property('visibleCount', 0); + }); + + it('Confirm new instance', function () { + var obj = new DisplayObject(); + + pixi_display_DisplayObject_confirmNew(obj); + expect(obj).to.have.property('hitArea', null); + expect(obj).to.have.property('interactive', false); + expect(obj).to.have.property('renderable', false); + expect(obj).to.have.property('stage', null); + }); +}); diff --git a/test/unit/pixi-v2/display/DisplayObjectContainer.js b/test/unit/pixi-v2/display/DisplayObjectContainer.js new file mode 100644 index 0000000..15a3376 --- /dev/null +++ b/test/unit/pixi-v2/display/DisplayObjectContainer.js @@ -0,0 +1,67 @@ +describe('pixi/display/DisplayObjectContainer', function () { + 'use strict'; + + var expect = chai.expect; + var DisplayObjectContainer = PIXI.DisplayObjectContainer; + + it('Module exists', function () { + expect(DisplayObjectContainer).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new DisplayObjectContainer(); + + pixi_display_DisplayObjectContainer_confirmNew(obj); + expect(obj).to.have.property('hitArea', null); + expect(obj).to.have.property('interactive', false); + expect(obj).to.have.property('renderable', false); + expect(obj).to.have.property('stage', null); + }); + + it('Gets child index', function() { + var container = new PIXI.DisplayObjectContainer(); + var children = []; + for (var i = 0; i < 10; i++) { + var child = new PIXI.DisplayObject(); + children.push(child); + container.addChild(child); + } + + for (i = 0; i < children.length; i++) { + expect(i).to.eql(container.getChildIndex(children[i])); + } + }); + + it('throws error when trying to get index of not a child', function() { + var container = new PIXI.DisplayObjectContainer(); + var child = new PIXI.DisplayObject(); + + expect(function() { container.getChildIndex(child); }).to.throw(); + }); + + it('Sets child index', function() { + var container = new PIXI.DisplayObjectContainer(); + var children = []; + + for (var i = 0; i < 10; i++) { + var child = new PIXI.DisplayObject(); + children.push(child); + container.addChild(child); + } + children.reverse(); + + for (i = 0; i < children.length; i++) { + container.setChildIndex(children[i], i); + expect(i).to.eql(container.getChildIndex(children[i])); + } + }); + + it('throws error when trying to set incorect index', function() { + var container = new PIXI.DisplayObjectContainer(); + var child = new PIXI.DisplayObject(); + container.addChild(child); + + expect(function() { container.setChildIndex(child, -1); }).to.throw(); + expect(function() { container.setChildIndex(child, 1); }).to.throw(); + }); +}); diff --git a/test/unit/pixi-v2/display/MovieClip.js b/test/unit/pixi-v2/display/MovieClip.js new file mode 100644 index 0000000..f3c6c6a --- /dev/null +++ b/test/unit/pixi-v2/display/MovieClip.js @@ -0,0 +1,33 @@ +describe('pixi/display/MovieClip', function () { + 'use strict'; + + var expect = chai.expect; + var MovieClip = PIXI.MovieClip; + var Texture = PIXI.Texture; + + it('Module exists', function () { + expect(MovieClip).to.be.a('function'); + }); + + it('Confirm new instance', function (done) { + var texture = Texture.fromImage('/base/test/textures/SpriteSheet-Explosion.png'); + var obj = new MovieClip([texture]); + + pixi_display_Sprite_confirmNew(obj, done); + + expect(obj).to.be.an.instanceof(MovieClip); + expect(obj).to.respondTo('stop'); + expect(obj).to.respondTo('play'); + expect(obj).to.respondTo('gotoAndStop'); + expect(obj).to.respondTo('gotoAndPlay'); + expect(obj).to.respondTo('updateTransform'); + + expect(obj).to.have.deep.property('textures.length', 1); + expect(obj).to.have.deep.property('textures[0]', texture); + expect(obj).to.have.property('animationSpeed', 1); + expect(obj).to.have.property('loop', true); + expect(obj).to.have.property('onComplete', null); + expect(obj).to.have.property('currentFrame', 0); + expect(obj).to.have.property('playing', false); + }); +}); diff --git a/test/unit/pixi-v2/display/Sprite.js b/test/unit/pixi-v2/display/Sprite.js new file mode 100644 index 0000000..30c8076 --- /dev/null +++ b/test/unit/pixi-v2/display/Sprite.js @@ -0,0 +1,28 @@ +describe('pixi/display/Sprite', function () { + 'use strict'; + + var expect = chai.expect; + var Sprite = PIXI.Sprite; + var Texture = PIXI.Texture; + + it('Module exists', function () { + expect(Sprite).to.be.a('function'); + expect(PIXI).to.have.deep.property('blendModes.NORMAL', 0); + expect(PIXI).to.have.deep.property('blendModes.ADD', 1); + expect(PIXI).to.have.deep.property('blendModes.MULTIPLY', 2); + expect(PIXI).to.have.deep.property('blendModes.SCREEN', 3); + }); + + + it('Members exist', function () { + expect(Sprite).itself.to.respondTo('fromImage'); + expect(Sprite).itself.to.respondTo('fromFrame'); + }); + + it('Confirm new instance', function (done) { + var texture = Texture.fromImage('/base/test/textures/SpriteSheet-Aliens.png'); + var obj = new Sprite(texture); + + pixi_display_Sprite_confirmNew(obj, done); + }); +}); diff --git a/test/unit/pixi-v2/display/Stage.js b/test/unit/pixi-v2/display/Stage.js new file mode 100644 index 0000000..6974c2e --- /dev/null +++ b/test/unit/pixi-v2/display/Stage.js @@ -0,0 +1,49 @@ +describe('pixi/display/Stage', function () { + 'use strict'; + + var expect = chai.expect; + var Stage = PIXI.Stage; + var InteractionManager = PIXI.InteractionManager; + var Rectangle = PIXI.Rectangle; + + it('Module exists', function () { + expect(Stage).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Stage(null, true); + + pixi_display_DisplayObjectContainer_confirmNew(obj); + + expect(obj).to.be.an.instanceof(Stage); + expect(obj).to.respondTo('updateTransform'); + expect(obj).to.respondTo('setBackgroundColor'); + expect(obj).to.respondTo('getMousePosition'); + // FIXME: duplicate member in DisplayObject + pixi_core_Matrix_confirmNewMatrix(obj.worldTransform); + // FIXME: convert arg to bool in constructor + expect(obj).to.have.property('interactive', true); + + expect(obj).to.have.property('interactionManager') + .and.to.be.an.instanceof(InteractionManager) + .and.to.have.property('stage', obj); + + expect(obj).to.have.property('dirty', true); + + expect(obj).to.have.property('stage', obj); + + expect(obj).to.have.property('hitArea') + .and.to.be.an.instanceof(Rectangle); + pixi_core_Rectangle_confirm(obj.hitArea, 0, 0, 100000, 100000); + + expect(obj).to.have.property('backgroundColor', 0x000000); + expect(obj).to.have.deep.property('backgroundColorSplit.length', 3); + expect(obj).to.have.deep.property('backgroundColorSplit[0]', 0); + expect(obj).to.have.deep.property('backgroundColorSplit[1]', 0); + expect(obj).to.have.deep.property('backgroundColorSplit[2]', 0); + expect(obj).to.have.property('backgroundColorString', '#000000'); + + + expect(obj).to.have.property('worldVisible', true); + }); +}); diff --git a/test/unit/pixi-v2/extras/Rope.js b/test/unit/pixi-v2/extras/Rope.js new file mode 100644 index 0000000..05885ac --- /dev/null +++ b/test/unit/pixi-v2/extras/Rope.js @@ -0,0 +1,31 @@ +describe('pixi/extras/Rope', function () { + 'use strict'; + + var expect = chai.expect; + var Rope = PIXI.Rope; + var Texture = PIXI.Texture; + var Point = PIXI.Point; + + it('Module exists', function () { + expect(Rope).to.be.a('function'); + }); + + it('Confirm new instance', function () { + + var texture = Texture.fromImage('/base/test/textures/bunny.png'); + + // TODO-Alvin + // Same as Strip + + // var obj = new Rope(texture, [new Point(), new Point(5, 10), new Point(10, 20)]); + + // pixi_extras_Strip_confirmNew(obj); + + // expect(obj).to.be.an.instanceof(Rope); + // expect(obj).to.respondTo('refresh'); + // expect(obj).to.respondTo('updateTransform'); + // expect(obj).to.respondTo('setTexture'); + + // TODO: Test properties + }); +}); diff --git a/test/unit/pixi-v2/extras/Spine.js b/test/unit/pixi-v2/extras/Spine.js new file mode 100644 index 0000000..0708bc0 --- /dev/null +++ b/test/unit/pixi-v2/extras/Spine.js @@ -0,0 +1,10 @@ +describe('pixi/extras/Spine', function () { + 'use strict'; + + var expect = chai.expect; + var Spine = PIXI.Spine; + + it('Module exists', function () { + expect(Spine).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/extras/Strip.js b/test/unit/pixi-v2/extras/Strip.js new file mode 100644 index 0000000..230af90 --- /dev/null +++ b/test/unit/pixi-v2/extras/Strip.js @@ -0,0 +1,26 @@ +describe('pixi/extras/Strip', function () { + 'use strict'; + + var expect = chai.expect; + var Strip = PIXI.Strip; + var Texture = PIXI.Texture; + + it('Module exists', function () { + expect(Strip).to.be.a('function'); + }); + + it('Confirm new instance', function () { + + + // TODO-Alvin + // We tweaked it to make it pass the tests, but the whole strip class needs + // to be re-coded + + var texture = Texture.fromImage('/base/test/textures/bunny.png'); + + // var obj = new Strip(texture, 20, 10000); + + + // pixi_extras_Strip_confirmNew(obj); + }); +}); diff --git a/test/unit/pixi-v2/extras/TilingSprite.js b/test/unit/pixi-v2/extras/TilingSprite.js new file mode 100644 index 0000000..56aea14 --- /dev/null +++ b/test/unit/pixi-v2/extras/TilingSprite.js @@ -0,0 +1,24 @@ +describe('pixi/extras/TilingSprite', function () { + 'use strict'; + + var expect = chai.expect; + var TilingSprite = PIXI.TilingSprite; + var Texture = PIXI.Texture; + + it('Module exists', function () { + expect(TilingSprite).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var texture = Texture.fromImage('/base/test/textures/bunny.png'); + var obj = new TilingSprite(texture, 6000, 12000); + + pixi_display_DisplayObjectContainer_confirmNew(obj); + + expect(obj).to.be.an.instanceof(TilingSprite); + expect(obj).to.respondTo('setTexture'); + expect(obj).to.respondTo('onTextureUpdate'); + + // TODO: Test properties + }); +}); diff --git a/test/unit/pixi-v2/filters/FilterBlock.js b/test/unit/pixi-v2/filters/FilterBlock.js new file mode 100644 index 0000000..870cec0 --- /dev/null +++ b/test/unit/pixi-v2/filters/FilterBlock.js @@ -0,0 +1,10 @@ +describe('pixi/filters/FilterBlock', function () { + 'use strict'; + + var expect = chai.expect; + var FilterBlock = PIXI.FilterBlock; + + it('Module exists', function () { + expect(FilterBlock).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/AssetLoader.js b/test/unit/pixi-v2/loaders/AssetLoader.js new file mode 100644 index 0000000..a0aa0b5 --- /dev/null +++ b/test/unit/pixi-v2/loaders/AssetLoader.js @@ -0,0 +1,10 @@ +describe('pixi/loaders/AssetLoader', function () { + 'use strict'; + + var expect = chai.expect; + var AssetLoader = PIXI.AssetLoader; + + it('Module exists', function () { + expect(AssetLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/BitmapFontLoader.js b/test/unit/pixi-v2/loaders/BitmapFontLoader.js new file mode 100644 index 0000000..046f018 --- /dev/null +++ b/test/unit/pixi-v2/loaders/BitmapFontLoader.js @@ -0,0 +1,9 @@ +describe('pixi/loaders/BitmapFontLoader', function () { + 'use strict'; + + var expect = chai.expect; + + it('Module exists', function () { + expect(PIXI.BitmapFontLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/ImageLoader.js b/test/unit/pixi-v2/loaders/ImageLoader.js new file mode 100644 index 0000000..8b1f556 --- /dev/null +++ b/test/unit/pixi-v2/loaders/ImageLoader.js @@ -0,0 +1,10 @@ +describe('pixi/loaders/ImageLoader', function () { + 'use strict'; + + var expect = chai.expect; + var ImageLoader = PIXI.ImageLoader; + + it('Module exists', function () { + expect(ImageLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/JsonLoader.js b/test/unit/pixi-v2/loaders/JsonLoader.js new file mode 100644 index 0000000..c577e83 --- /dev/null +++ b/test/unit/pixi-v2/loaders/JsonLoader.js @@ -0,0 +1,10 @@ +describe('pixi/loaders/JsonLoader', function () { + 'use strict'; + + var expect = chai.expect; + var JsonLoader = PIXI.JsonLoader; + + it('Module exists', function () { + expect(JsonLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/SpineLoader.js b/test/unit/pixi-v2/loaders/SpineLoader.js new file mode 100644 index 0000000..fdcc0b8 --- /dev/null +++ b/test/unit/pixi-v2/loaders/SpineLoader.js @@ -0,0 +1,10 @@ +describe('pixi/loaders/SpineLoader', function () { + 'use strict'; + + var expect = chai.expect; + var SpineLoader = PIXI.SpineLoader; + + it('Module exists', function () { + expect(SpineLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/SpriteSheetLoader.js b/test/unit/pixi-v2/loaders/SpriteSheetLoader.js new file mode 100644 index 0000000..57beb27 --- /dev/null +++ b/test/unit/pixi-v2/loaders/SpriteSheetLoader.js @@ -0,0 +1,10 @@ +describe('pixi/loaders/SpriteSheetLoader', function () { + 'use strict'; + + var expect = chai.expect; + var SpriteSheetLoader = PIXI.SpriteSheetLoader; + + it('Module exists', function () { + expect(SpriteSheetLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/primitives/Graphics.js b/test/unit/pixi-v2/primitives/Graphics.js new file mode 100644 index 0000000..f3849eb --- /dev/null +++ b/test/unit/pixi-v2/primitives/Graphics.js @@ -0,0 +1,44 @@ +describe('pixi/primitives/Graphics', function () { + 'use strict'; + + var expect = chai.expect; + var Graphics = PIXI.Graphics; + + it('Module exists', function () { + expect(Graphics).to.be.a('function'); + + expect(Graphics).itself.to.have.property('POLY', 0); + expect(Graphics).itself.to.have.property('RECT', 1); + expect(Graphics).itself.to.have.property('CIRC', 2); + expect(Graphics).itself.to.have.property('ELIP', 3); + expect(Graphics).itself.to.have.property('RREC', 4); + }); + + it('Confirm new instance', function () { + var obj = new Graphics(); + + pixi_display_DisplayObjectContainer_confirmNew(obj); + + expect(obj).to.be.an.instanceof(Graphics); + expect(obj).to.respondTo('lineStyle'); + expect(obj).to.respondTo('lineStyle'); + expect(obj).to.respondTo('moveTo'); + expect(obj).to.respondTo('lineTo'); + expect(obj).to.respondTo('beginFill'); + expect(obj).to.respondTo('endFill'); + expect(obj).to.respondTo('drawRect'); + // expect(obj).to.respondTo('drawRoundedRect'); + expect(obj).to.respondTo('drawCircle'); + expect(obj).to.respondTo('drawEllipse'); + expect(obj).to.respondTo('clear'); + + expect(obj).to.have.property('renderable', true); + expect(obj).to.have.property('fillAlpha', 1); + expect(obj).to.have.property('lineWidth', 0); + expect(obj).to.have.property('width', 0); + expect(obj).to.have.property('height', 0); + expect(obj).to.have.property('lineColor', 0); + expect(obj).to.have.deep.property('graphicsData.length', 0); + // expect(obj).to.have.deep.property('currentPath.points.length', 0); + }); +}); diff --git a/test/unit/pixi-v2/renderers/canvas/CanvasGraphics.js b/test/unit/pixi-v2/renderers/canvas/CanvasGraphics.js new file mode 100644 index 0000000..8f44472 --- /dev/null +++ b/test/unit/pixi-v2/renderers/canvas/CanvasGraphics.js @@ -0,0 +1,15 @@ +describe('renders/canvas/CanvasGraphics', function () { + 'use strict'; + + var expect = chai.expect; + var CanvasGraphics = PIXI.CanvasGraphics; + + it('Module exists', function () { + expect(CanvasGraphics).to.be.a('function'); + }); + + it('Members exist', function () { + expect(CanvasGraphics).itself.to.respondTo('renderGraphics'); + expect(CanvasGraphics).itself.to.respondTo('renderGraphicsMask'); + }); +}); diff --git a/test/unit/pixi-v2/renderers/canvas/CanvasRenderer.js b/test/unit/pixi-v2/renderers/canvas/CanvasRenderer.js new file mode 100644 index 0000000..1646444 --- /dev/null +++ b/test/unit/pixi-v2/renderers/canvas/CanvasRenderer.js @@ -0,0 +1,36 @@ +describe('renderers/canvas/CanvasRenderer', function () { + 'use strict'; + + var expect = chai.expect; + var CanvasRenderer = PIXI.CanvasRenderer; + + it('Module exists', function () { + expect(CanvasRenderer).to.be.a('function'); + }); + + describe('.autoResize', function () { + it('Should automatically resize view if enabled', function () { + var renderer = new CanvasRenderer(200, 200, { + autoResize: true + }); + + expect(renderer.view.style.width).to.equal('200px'); + }); + + it('Should not automatically resize view if disabled', function () { + var renderer = new CanvasRenderer(200, 200, { + autoResize: false + }); + + expect(renderer.view.style.width).to.equal(''); + }); + + it('Should not automatically resize view if not specified', function () { + var renderer = new CanvasRenderer(200, 200, { + resolution: 2 + }); + + expect(renderer.view.style.width).to.equal(''); + }); + }); +}); diff --git a/test/unit/pixi-v2/renderers/webgl/WebGLGraphics.js b/test/unit/pixi-v2/renderers/webgl/WebGLGraphics.js new file mode 100644 index 0000000..5867b28 --- /dev/null +++ b/test/unit/pixi-v2/renderers/webgl/WebGLGraphics.js @@ -0,0 +1,20 @@ +describe('renderers/wegbl/WebGLGraphics', function () { + 'use strict'; + + var expect = chai.expect; + var WebGLGraphics = PIXI.WebGLGraphics; + + it('Module exists', function () { + expect(WebGLGraphics).to.be.a('function'); + }); + + it('Members exist', function () { + expect(WebGLGraphics).itself.to.respondTo('renderGraphics'); + expect(WebGLGraphics).itself.to.respondTo('updateGraphics'); + expect(WebGLGraphics).itself.to.respondTo('buildRectangle'); + expect(WebGLGraphics).itself.to.respondTo('buildRoundedRectangle'); + expect(WebGLGraphics).itself.to.respondTo('buildCircle'); + expect(WebGLGraphics).itself.to.respondTo('buildLine'); + expect(WebGLGraphics).itself.to.respondTo('buildPoly'); + }); +}); diff --git a/test/unit/pixi-v2/renderers/webgl/WebGLRenderer.js b/test/unit/pixi-v2/renderers/webgl/WebGLRenderer.js new file mode 100644 index 0000000..1680a80 --- /dev/null +++ b/test/unit/pixi-v2/renderers/webgl/WebGLRenderer.js @@ -0,0 +1,49 @@ +describe('renderers/webgl/WebGLRenderer', function () { + 'use strict'; + + var expect = chai.expect; + var WebGLRenderer = PIXI.WebGLRenderer; + + it('Module exists', function () { + expect(WebGLRenderer).to.be.a('function'); + }); + + // Skip tests if WebGL is not available (WebGL not supported in Travis CI) + try { + var renderer = new WebGLRenderer(400, 300, {}); + renderer.destroy(); + } catch (error) { + return; + } + + it('Destroy renderer', function () { + var renderer = new WebGLRenderer(400, 300, {}); + renderer.destroy(); + }); + + describe('.autoResize', function () { + it('Should automatically resize view if enabled', function () { + var renderer = new WebGLRenderer(200, 200, { + autoResize: true + }); + + expect(renderer.view.style.width).to.equal('200px'); + }); + + it('Should not automatically resize view if disabled', function () { + var renderer = new WebGLRenderer(200, 200, { + autoResize: false + }); + + expect(renderer.view.style.width).to.equal(''); + }); + + it('Should not automatically resize view if not specified', function () { + var renderer = new WebGLRenderer(200, 200, { + resolution: 2 + }); + + expect(renderer.view.style.width).to.equal(''); + }); + }); +}); diff --git a/test/unit/pixi-v2/renderers/webgl/WebGLShaders.js b/test/unit/pixi-v2/renderers/webgl/WebGLShaders.js new file mode 100644 index 0000000..6e33e4f --- /dev/null +++ b/test/unit/pixi-v2/renderers/webgl/WebGLShaders.js @@ -0,0 +1,13 @@ +describe('renderers/webgl/WebGLShaders', function () { + 'use strict'; + + var expect = chai.expect; + + it('Module members exist', function () { + + expect(PIXI).to.respondTo('CompileVertexShader'); + expect(PIXI).to.respondTo('CompileFragmentShader'); + expect(PIXI).to.respondTo('_CompileShader'); + expect(PIXI).to.respondTo('compileProgram'); + }); +}); diff --git a/test/unit/pixi-v2/renderers/webgl/WebGLSpriteBatch.js b/test/unit/pixi-v2/renderers/webgl/WebGLSpriteBatch.js new file mode 100644 index 0000000..e662b63 --- /dev/null +++ b/test/unit/pixi-v2/renderers/webgl/WebGLSpriteBatch.js @@ -0,0 +1,10 @@ +describe('renderers/webgl/utils/WebGLSpriteBatch', function () { + 'use strict'; + + var expect = chai.expect; + var WebGLSpriteBatch = PIXI.WebGLSpriteBatch; + + it('Module exists', function () { + expect(WebGLSpriteBatch).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/text/BitmapText.js b/test/unit/pixi-v2/text/BitmapText.js new file mode 100644 index 0000000..9388e3d --- /dev/null +++ b/test/unit/pixi-v2/text/BitmapText.js @@ -0,0 +1,10 @@ +describe('pixi/text/BitmapText', function () { + 'use strict'; + + var expect = chai.expect; + var BitmapText = PIXI.BitmapText; + + it('Module exists', function () { + expect(BitmapText).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/text/Text.js b/test/unit/pixi-v2/text/Text.js new file mode 100644 index 0000000..9bc9ac5 --- /dev/null +++ b/test/unit/pixi-v2/text/Text.js @@ -0,0 +1,10 @@ +describe('pixi/text/Text', function () { + 'use strict'; + + var expect = chai.expect; + var Text = PIXI.Text; + + it('Module exists', function () { + expect(Text).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/textures/BaseTexture.js b/test/unit/pixi-v2/textures/BaseTexture.js new file mode 100644 index 0000000..502b724 --- /dev/null +++ b/test/unit/pixi-v2/textures/BaseTexture.js @@ -0,0 +1,11 @@ +describe('pixi/textures/BaseTexture', function () { + 'use strict'; + + var expect = chai.expect; + var BaseTexture = PIXI.BaseTexture; + + it('Module exists', function () { + expect(BaseTexture).to.be.a('function'); + expect(PIXI).to.have.property('BaseTextureCache').and.to.be.an('object'); + }); +}); diff --git a/test/unit/pixi-v2/textures/RenderTexture.js b/test/unit/pixi-v2/textures/RenderTexture.js new file mode 100644 index 0000000..96acdb4 --- /dev/null +++ b/test/unit/pixi-v2/textures/RenderTexture.js @@ -0,0 +1,15 @@ +describe('pixi/textures/RenderTexture', function () { + 'use strict'; + + var expect = chai.expect; + var RenderTexture = PIXI.RenderTexture; + + it('Module exists', function () { + expect(RenderTexture).to.be.a('function'); + }); + + it('Confirm new instance', function (done) { + var texture = new RenderTexture(100, 100, new PIXI.CanvasRenderer()); + pixi_textures_RenderTexture_confirmNew(texture, done); + }); +}); diff --git a/test/unit/pixi-v2/textures/Texture.js b/test/unit/pixi-v2/textures/Texture.js new file mode 100644 index 0000000..090f64d --- /dev/null +++ b/test/unit/pixi-v2/textures/Texture.js @@ -0,0 +1,26 @@ +describe('pixi/textures/Texture', function () { + 'use strict'; + + var expect = chai.expect; + var Texture = PIXI.Texture; + + it('Module exists', function () { + expect(Texture).to.be.a('function'); + expect(PIXI).to.have.property('TextureCache').and.to.be.an('object'); + }); + + it('Members exist', function () { + expect(Texture).itself.to.respondTo('fromImage'); + expect(Texture).itself.to.respondTo('fromFrame'); + expect(Texture).itself.to.respondTo('fromCanvas'); + expect(Texture).itself.to.respondTo('addTextureToCache'); + expect(Texture).itself.to.respondTo('removeTextureFromCache'); + + // expect(Texture).itself.to.have.deep.property('frameUpdates.length', 0); + }); + + it('Confirm new instance', function (done) { + var texture = Texture.fromImage('/base/test/textures/bunny.png'); + pixi_textures_Texture_confirmNew(texture, done); + }); +}); diff --git a/test/unit/pixi-v2/utils/Detector.js b/test/unit/pixi-v2/utils/Detector.js new file mode 100644 index 0000000..4cf6008 --- /dev/null +++ b/test/unit/pixi-v2/utils/Detector.js @@ -0,0 +1,10 @@ +describe('pixi/utils/Detector', function () { + 'use strict'; + + var expect = chai.expect; + var autoDetectRenderer = PIXI.autoDetectRenderer; + + it('Module exists', function () { + expect(autoDetectRenderer).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/utils/EventTarget.js b/test/unit/pixi-v2/utils/EventTarget.js new file mode 100644 index 0000000..1cfc3a4 --- /dev/null +++ b/test/unit/pixi-v2/utils/EventTarget.js @@ -0,0 +1,361 @@ +describe('pixi/utils/EventTarget', function () { + 'use strict'; + + var expect = chai.expect; + + var Clazz, PClazz, obj, pobj, obj2; + beforeEach(function () { + Clazz = function () {}; + PClazz = function () {}; + + PIXI.EventTarget.mixin(Clazz.prototype); + PIXI.EventTarget.mixin(PClazz.prototype); + + obj = new Clazz(); + obj2 = new Clazz(); + pobj = new PClazz(); + + obj.parent = pobj; + obj2.parent = obj; + }); + + it('Module exists', function () { + expect(PIXI.EventTarget).to.be.an('object'); + }); + + it('Confirm new instance', function () { + pixi_utils_EventTarget_confirm(obj); + }); + + it('simple on/emit case works', function () { + var myData = {}; + + obj.on('myevent', function (event) { + pixi_utils_EventTarget_Event_confirm(event, obj, myData); + }); + + obj.emit('myevent', myData); + }); + + it('simple once case works', function () { + var called = 0; + + obj.once('myevent', function() { called++; }); + + obj.emit('myevent'); + obj.emit('myevent'); + obj.emit('myevent'); + obj.emit('myevent'); + obj.emit('myevent'); + + expect(called).to.equal(1); + }); + + it('simple off case works', function (done) { + function onMyEvent() { + done(new Error('Event listener should not have been called')); + } + + obj.on('myevent', onMyEvent); + obj.off('myevent', onMyEvent); + obj.emit('myevent'); + + done(); + }); + + it('simple propagation case works', function (done) { + var myData = {}; + + pobj.on('myevent', function () { + done(); + }); + + obj.emit('myevent'); + }); + + it('simple stopPropagation case works', function (done) { + var myData = {}; + + pobj.on('myevent', function () { + done(new Error('Event listener should not have been called on the parent element')); + }); + + obj.on('myevent', function (evt) { + evt.stopPropagation(); + }); + + obj.emit('myevent'); + + done(); + }); + + it('simple stopImmediatePropagation case works', function (done) { + var myData = {}; + + pobj.on('myevent', function () { + done(new Error('Event listener should not have been called on the parent')); + }); + + obj.on('myevent', function (evt) { + evt.stopImmediatePropagation(); + }); + + obj.on('myevent', function () { + done(new Error('Event listener should not have been called on the second')); + }); + + obj.emit('myevent'); + + done(); + }); + + it('multiple dispatches work properly', function () { + var called = 0; + + function onMyEvent() { + called++; + } + + obj.on('myevent', onMyEvent); + obj.emit('myevent'); + obj.emit('myevent'); + obj.emit('myevent'); + obj.emit('myevent'); + + expect(called).to.equal(4); + }); + + it('multiple events work properly', function () { + var called = 0; + + function onMyEvent() { + called++; + } + + obj.on('myevent1', onMyEvent); + obj.on('myevent2', onMyEvent); + obj.on('myevent3', onMyEvent); + obj.emit('myevent1'); + obj.emit('myevent2'); + obj.emit('myevent3'); + + expect(called).to.equal(3); + }); + + it('multiple events one removed works properly', function () { + var called = 0; + + function onMyEvent() { + called++; + } + + obj.on('myevent1', onMyEvent); + obj.on('myevent2', onMyEvent); + obj.on('myevent3', onMyEvent); + + obj.emit('myevent1'); + obj.emit('myevent2'); + obj.emit('myevent3'); + + obj.off('myevent2', onMyEvent); + + obj.emit('myevent1'); + obj.emit('myevent2'); + obj.emit('myevent3'); + + expect(called).to.equal(5); + }); + + it('multiple handlers for one event with some removed', function () { + var called = 0; + + var onMyEvent = function () { + called++; + }, + onMyEvent2 = function () { + called++; + }; + + // add 2 handlers and confirm they both get called + obj.on('myevent', onMyEvent); + obj.on('myevent', onMyEvent); + obj.on('myevent', onMyEvent2); + obj.on('myevent', onMyEvent2); + + obj.emit('myevent'); + + expect(called).to.equal(4); + + // remove one of the handlers, emit again, then ensure 1 more call is made + obj.off('myevent', onMyEvent); + + obj.emit('myevent'); + + expect(called).to.equal(6); + }); + + it('calls to off without a handler do nothing', function () { + var called = 0; + + var onMyEvent = function () { + called++; + }; + + obj.on('myevent', onMyEvent); + obj.on('myevent', onMyEvent); + + obj.emit('myevent'); + + expect(called).to.equal(2); + + obj.off('myevent'); + + obj.emit('myevent'); + + expect(called).to.equal(4); + + obj.off('myevent', onMyEvent); + + obj.emit('myevent'); + + expect(called).to.equal(4); + }); + + it('handles multiple instances with the same prototype', function () { + var called = 0; + + function onMyEvent(e) { + called++; + } + + obj.on('myevent1', onMyEvent); + obj.on('myevent2', onMyEvent); + + obj2.istwo = true; + obj2.on('myevent1', onMyEvent); + obj2.on('myevent2', onMyEvent); + + obj.emit('myevent1'); + obj.emit('myevent2'); + obj2.emit('myevent1'); + obj2.emit('myevent2'); + + //we emit 4 times, but since obj2 is a child of obj the event should bubble + //up to obj and show up there as well. So the obj2.emit() calls each increment + //the counter twice. + expect(called).to.equal(6); + }); + + it('is backwards compatible with older .dispatchEvent({})', function () { + var called = 0, + data = { + some: 'thing', + hello: true + }; + + function onMyEvent(event) { + pixi_utils_EventTarget_Event_confirm(event, obj, data); + + called++; + } + + obj.on('myevent1', onMyEvent); + obj.on('myevent2', onMyEvent); + obj.on('myevent3', onMyEvent); + + data.type = 'myevent1'; + obj.emit(data); + + data.type = 'myevent2'; + obj.emit(data); + + data.type = 'myevent3'; + obj.emit(data); + + obj.off('myevent2', onMyEvent); + + data.type = 'myevent1'; + obj.emit(data); + + data.type = 'myevent2'; + obj.emit(data); + + data.type = 'myevent3'; + obj.emit(data); + + expect(called).to.equal(5); + }); + + it('is backwards compatible with older .call(this)', function () { + var Fn = function() { + PIXI.EventTarget.call(this); + }, + o = new Fn(); + + pixi_utils_EventTarget_confirm(o); + }); + + it('is backwards compatible with older .addEventListener("")', function () { + var called = 0, + data = { + some: 'thing', + hello: true + }; + + function onMyEvent(event) { + pixi_utils_EventTarget_Event_confirm(event, obj, data); + + called++; + } + + obj.addEventListener('myevent1', onMyEvent); + obj.addEventListener('myevent2', onMyEvent); + obj.addEventListener('myevent3', onMyEvent); + + data.type = 'myevent1'; + obj.emit(data); + + data.type = 'myevent2'; + obj.emit(data); + + data.type = 'myevent3'; + obj.emit(data); + + obj.off('myevent2', onMyEvent); + + data.type = 'myevent1'; + obj.emit(data); + + data.type = 'myevent2'; + obj.emit(data); + + data.type = 'myevent3'; + obj.emit(data); + + expect(called).to.equal(5); + }); + + it('event remove during emit call properly', function () { + var called = 0; + + function cb1() { + called++; + obj.off('myevent', cb1); + } + function cb2() { + called++; + obj.off('myevent', cb2); + } + function cb3() { + called++; + obj.off('myevent', cb3); + } + + obj.on('myevent', cb1); + obj.on('myevent', cb2); + obj.on('myevent', cb3); + obj.emit('myevent', ''); + + expect(called).to.equal(3); + }); +}); diff --git a/test/unit/pixi-v2/utils/Polyk.js b/test/unit/pixi-v2/utils/Polyk.js new file mode 100644 index 0000000..dfc7128 --- /dev/null +++ b/test/unit/pixi-v2/utils/Polyk.js @@ -0,0 +1,14 @@ +describe('pixi/utils/Polyk', function () { + 'use strict'; + + var expect = chai.expect; + var PolyK = PIXI.PolyK; + + it('Module exists', function () { + expect(PolyK).to.be.an('object'); + }); + + it('Members exist', function () { + expect(PolyK).to.respondTo('Triangulate'); + }); +}); diff --git a/test/unit/pixi-v2/utils/Utils.js b/test/unit/pixi-v2/utils/Utils.js new file mode 100644 index 0000000..c97b3c6 --- /dev/null +++ b/test/unit/pixi-v2/utils/Utils.js @@ -0,0 +1,17 @@ +describe('Utils', function () { + 'use strict'; + + var expect = chai.expect; + + it('requestAnimationFrame exists', function () { + expect(global).to.respondTo('requestAnimationFrame'); + }); + + it('cancelAnimationFrame exists', function () { + expect(global).to.respondTo('cancelAnimationFrame'); + }); + + it('requestAnimFrame exists', function () { + expect(global).to.respondTo('requestAnimFrame'); + }); +}); diff --git a/test/unit/pixi/InteractionManager.js b/test/unit/pixi/InteractionManager.js deleted file mode 100644 index ed3001f..0000000 --- a/test/unit/pixi/InteractionManager.js +++ /dev/null @@ -1,10 +0,0 @@ -describe('pixi/InteractionManager', function () { - 'use strict'; - - var expect = chai.expect; - var InteractionManager = PIXI.InteractionManager; - - it('Module exists', function () { - expect(InteractionManager).to.be.a('function'); - }); -}); diff --git a/test/unit/pixi/Pixi.js b/test/unit/pixi/Pixi.js deleted file mode 100644 index 27debc1..0000000 --- a/test/unit/pixi/Pixi.js +++ /dev/null @@ -1,9 +0,0 @@ -describe('pixi/Pixi', function () { - 'use strict'; - - var expect = chai.expect; - - it('Module exists', function () { - expect(global).to.have.property('PIXI').and.to.be.an('object'); - }); -}); diff --git a/test/unit/pixi/core/Circle.js b/test/unit/pixi/core/Circle.js deleted file mode 100644 index fbcfa17..0000000 --- a/test/unit/pixi/core/Circle.js +++ /dev/null @@ -1,21 +0,0 @@ -describe('pixi/core/Circle', function () { - 'use strict'; - - var expect = chai.expect; - var Circle = PIXI.Circle; - - it('Module exists', function () { - expect(Circle).to.be.a('function'); - }); - - it('Confirm new instance', function () { - var obj = new Circle(); - pixi_core_Circle_confirmNewCircle(obj); - }); - - it("getBounds should return Rectangle that bounds the circle", function() { - var obj = new Circle(100, 250, 50); - var bounds = obj.getBounds(); - pixi_core_Circle_isBoundedByRectangle(obj, bounds); - }); -}); diff --git a/test/unit/pixi/core/Ellipse.js b/test/unit/pixi/core/Ellipse.js deleted file mode 100644 index 026b56f..0000000 --- a/test/unit/pixi/core/Ellipse.js +++ /dev/null @@ -1,24 +0,0 @@ -describe('pixi/core/Ellipse', function () { - 'use strict'; - - var expect = chai.expect; - var Ellipse = PIXI.Ellipse; - - it('Module exists', function () { - expect(Ellipse).to.be.a('function'); - }); - - it('Confirm new instance', function () { - var obj = new Ellipse(); - - expect(obj).to.be.an.instanceof(Ellipse); - expect(obj).to.respondTo('clone'); - expect(obj).to.respondTo('contains'); - expect(obj).to.respondTo('getBounds'); - - expect(obj).to.have.property('x', 0); - expect(obj).to.have.property('y', 0); - expect(obj).to.have.property('width', 0); - expect(obj).to.have.property('height', 0); - }); -}); diff --git a/test/unit/pixi/core/Matrix.js b/test/unit/pixi/core/Matrix.js deleted file mode 100644 index da75e2e..0000000 --- a/test/unit/pixi/core/Matrix.js +++ /dev/null @@ -1,14 +0,0 @@ -describe('pixi/core/Matrix', function () { - 'use strict'; - - var expect = chai.expect; - - it('Matrix exists', function () { - expect(PIXI.Matrix).to.be.an('function'); - }); - - it('Confirm new Matrix', function () { - var matrix = new PIXI.Matrix(); - pixi_core_Matrix_confirmNewMatrix(matrix); - }); -}); diff --git a/test/unit/pixi/core/Point.js b/test/unit/pixi/core/Point.js deleted file mode 100644 index c4d5163..0000000 --- a/test/unit/pixi/core/Point.js +++ /dev/null @@ -1,15 +0,0 @@ -describe('pixi/core/Point', function () { - 'use strict'; - - var expect = chai.expect; - var Point = PIXI.Point; - - it('Module exists', function () { - expect(Point).to.be.a('function'); - }); - - it('Confirm new instance', function () { - var obj = new Point(); - pixi_core_Point_confirm(obj, 0, 0); - }); -}); diff --git a/test/unit/pixi/core/Polygon.js b/test/unit/pixi/core/Polygon.js deleted file mode 100644 index dc8c918..0000000 --- a/test/unit/pixi/core/Polygon.js +++ /dev/null @@ -1,20 +0,0 @@ -describe('pixi/core/Polygon', function () { - 'use strict'; - - var expect = chai.expect; - var Polygon = PIXI.Polygon; - - it('Module exists', function () { - expect(Polygon).to.be.a('function'); - }); - - it('Confirm new instance', function () { - var obj = new Polygon(); - - expect(obj).to.be.an.instanceof(Polygon); - expect(obj).to.respondTo('clone'); - expect(obj).to.respondTo('contains'); - - expect(obj).to.have.deep.property('points.length', 0); - }); -}); diff --git a/test/unit/pixi/core/Rectangle.js b/test/unit/pixi/core/Rectangle.js deleted file mode 100644 index d43316e..0000000 --- a/test/unit/pixi/core/Rectangle.js +++ /dev/null @@ -1,15 +0,0 @@ -describe('pixi/core/Rectangle', function () { - 'use strict'; - - var expect = chai.expect; - var Rectangle = PIXI.Rectangle; - - it('Module exists', function () { - expect(Rectangle).to.be.a('function'); - }); - - it('Confirm new instance', function () { - var rect = new Rectangle(); - pixi_core_Rectangle_confirm(rect, 0, 0, 0, 0); - }); -}); diff --git a/test/unit/pixi/display/DisplayObject.js b/test/unit/pixi/display/DisplayObject.js deleted file mode 100644 index 044acf8..0000000 --- a/test/unit/pixi/display/DisplayObject.js +++ /dev/null @@ -1,21 +0,0 @@ -describe('pixi/display/DisplayObject', function () { - 'use strict'; - - var expect = chai.expect; - var DisplayObject = PIXI.DisplayObject; - - it('Module exists', function () { - expect(DisplayObject).to.be.a('function'); - // expect(PIXI).to.have.property('visibleCount', 0); - }); - - it('Confirm new instance', function () { - var obj = new DisplayObject(); - - pixi_display_DisplayObject_confirmNew(obj); - expect(obj).to.have.property('hitArea', null); - expect(obj).to.have.property('interactive', false); - expect(obj).to.have.property('renderable', false); - expect(obj).to.have.property('stage', null); - }); -}); diff --git a/test/unit/pixi/display/DisplayObjectContainer.js b/test/unit/pixi/display/DisplayObjectContainer.js deleted file mode 100644 index 15a3376..0000000 --- a/test/unit/pixi/display/DisplayObjectContainer.js +++ /dev/null @@ -1,67 +0,0 @@ -describe('pixi/display/DisplayObjectContainer', function () { - 'use strict'; - - var expect = chai.expect; - var DisplayObjectContainer = PIXI.DisplayObjectContainer; - - it('Module exists', function () { - expect(DisplayObjectContainer).to.be.a('function'); - }); - - it('Confirm new instance', function () { - var obj = new DisplayObjectContainer(); - - pixi_display_DisplayObjectContainer_confirmNew(obj); - expect(obj).to.have.property('hitArea', null); - expect(obj).to.have.property('interactive', false); - expect(obj).to.have.property('renderable', false); - expect(obj).to.have.property('stage', null); - }); - - it('Gets child index', function() { - var container = new PIXI.DisplayObjectContainer(); - var children = []; - for (var i = 0; i < 10; i++) { - var child = new PIXI.DisplayObject(); - children.push(child); - container.addChild(child); - } - - for (i = 0; i < children.length; i++) { - expect(i).to.eql(container.getChildIndex(children[i])); - } - }); - - it('throws error when trying to get index of not a child', function() { - var container = new PIXI.DisplayObjectContainer(); - var child = new PIXI.DisplayObject(); - - expect(function() { container.getChildIndex(child); }).to.throw(); - }); - - it('Sets child index', function() { - var container = new PIXI.DisplayObjectContainer(); - var children = []; - - for (var i = 0; i < 10; i++) { - var child = new PIXI.DisplayObject(); - children.push(child); - container.addChild(child); - } - children.reverse(); - - for (i = 0; i < children.length; i++) { - container.setChildIndex(children[i], i); - expect(i).to.eql(container.getChildIndex(children[i])); - } - }); - - it('throws error when trying to set incorect index', function() { - var container = new PIXI.DisplayObjectContainer(); - var child = new PIXI.DisplayObject(); - container.addChild(child); - - expect(function() { container.setChildIndex(child, -1); }).to.throw(); - expect(function() { container.setChildIndex(child, 1); }).to.throw(); - }); -}); diff --git a/test/unit/pixi/display/MovieClip.js b/test/unit/pixi/display/MovieClip.js deleted file mode 100644 index f3c6c6a..0000000 --- a/test/unit/pixi/display/MovieClip.js +++ /dev/null @@ -1,33 +0,0 @@ -describe('pixi/display/MovieClip', function () { - 'use strict'; - - var expect = chai.expect; - var MovieClip = PIXI.MovieClip; - var Texture = PIXI.Texture; - - it('Module exists', function () { - expect(MovieClip).to.be.a('function'); - }); - - it('Confirm new instance', function (done) { - var texture = Texture.fromImage('/base/test/textures/SpriteSheet-Explosion.png'); - var obj = new MovieClip([texture]); - - pixi_display_Sprite_confirmNew(obj, done); - - expect(obj).to.be.an.instanceof(MovieClip); - expect(obj).to.respondTo('stop'); - expect(obj).to.respondTo('play'); - expect(obj).to.respondTo('gotoAndStop'); - expect(obj).to.respondTo('gotoAndPlay'); - expect(obj).to.respondTo('updateTransform'); - - expect(obj).to.have.deep.property('textures.length', 1); - expect(obj).to.have.deep.property('textures[0]', texture); - expect(obj).to.have.property('animationSpeed', 1); - expect(obj).to.have.property('loop', true); - expect(obj).to.have.property('onComplete', null); - expect(obj).to.have.property('currentFrame', 0); - expect(obj).to.have.property('playing', false); - }); -}); diff --git a/test/unit/pixi/display/Sprite.js b/test/unit/pixi/display/Sprite.js deleted file mode 100644 index 30c8076..0000000 --- a/test/unit/pixi/display/Sprite.js +++ /dev/null @@ -1,28 +0,0 @@ -describe('pixi/display/Sprite', function () { - 'use strict'; - - var expect = chai.expect; - var Sprite = PIXI.Sprite; - var Texture = PIXI.Texture; - - it('Module exists', function () { - expect(Sprite).to.be.a('function'); - expect(PIXI).to.have.deep.property('blendModes.NORMAL', 0); - expect(PIXI).to.have.deep.property('blendModes.ADD', 1); - expect(PIXI).to.have.deep.property('blendModes.MULTIPLY', 2); - expect(PIXI).to.have.deep.property('blendModes.SCREEN', 3); - }); - - - it('Members exist', function () { - expect(Sprite).itself.to.respondTo('fromImage'); - expect(Sprite).itself.to.respondTo('fromFrame'); - }); - - it('Confirm new instance', function (done) { - var texture = Texture.fromImage('/base/test/textures/SpriteSheet-Aliens.png'); - var obj = new Sprite(texture); - - pixi_display_Sprite_confirmNew(obj, done); - }); -}); diff --git a/test/unit/pixi/display/Stage.js b/test/unit/pixi/display/Stage.js deleted file mode 100644 index 6974c2e..0000000 --- a/test/unit/pixi/display/Stage.js +++ /dev/null @@ -1,49 +0,0 @@ -describe('pixi/display/Stage', function () { - 'use strict'; - - var expect = chai.expect; - var Stage = PIXI.Stage; - var InteractionManager = PIXI.InteractionManager; - var Rectangle = PIXI.Rectangle; - - it('Module exists', function () { - expect(Stage).to.be.a('function'); - }); - - it('Confirm new instance', function () { - var obj = new Stage(null, true); - - pixi_display_DisplayObjectContainer_confirmNew(obj); - - expect(obj).to.be.an.instanceof(Stage); - expect(obj).to.respondTo('updateTransform'); - expect(obj).to.respondTo('setBackgroundColor'); - expect(obj).to.respondTo('getMousePosition'); - // FIXME: duplicate member in DisplayObject - pixi_core_Matrix_confirmNewMatrix(obj.worldTransform); - // FIXME: convert arg to bool in constructor - expect(obj).to.have.property('interactive', true); - - expect(obj).to.have.property('interactionManager') - .and.to.be.an.instanceof(InteractionManager) - .and.to.have.property('stage', obj); - - expect(obj).to.have.property('dirty', true); - - expect(obj).to.have.property('stage', obj); - - expect(obj).to.have.property('hitArea') - .and.to.be.an.instanceof(Rectangle); - pixi_core_Rectangle_confirm(obj.hitArea, 0, 0, 100000, 100000); - - expect(obj).to.have.property('backgroundColor', 0x000000); - expect(obj).to.have.deep.property('backgroundColorSplit.length', 3); - expect(obj).to.have.deep.property('backgroundColorSplit[0]', 0); - expect(obj).to.have.deep.property('backgroundColorSplit[1]', 0); - expect(obj).to.have.deep.property('backgroundColorSplit[2]', 0); - expect(obj).to.have.property('backgroundColorString', '#000000'); - - - expect(obj).to.have.property('worldVisible', true); - }); -}); diff --git a/test/unit/pixi/extras/Rope.js b/test/unit/pixi/extras/Rope.js deleted file mode 100644 index 05885ac..0000000 --- a/test/unit/pixi/extras/Rope.js +++ /dev/null @@ -1,31 +0,0 @@ -describe('pixi/extras/Rope', function () { - 'use strict'; - - var expect = chai.expect; - var Rope = PIXI.Rope; - var Texture = PIXI.Texture; - var Point = PIXI.Point; - - it('Module exists', function () { - expect(Rope).to.be.a('function'); - }); - - it('Confirm new instance', function () { - - var texture = Texture.fromImage('/base/test/textures/bunny.png'); - - // TODO-Alvin - // Same as Strip - - // var obj = new Rope(texture, [new Point(), new Point(5, 10), new Point(10, 20)]); - - // pixi_extras_Strip_confirmNew(obj); - - // expect(obj).to.be.an.instanceof(Rope); - // expect(obj).to.respondTo('refresh'); - // expect(obj).to.respondTo('updateTransform'); - // expect(obj).to.respondTo('setTexture'); - - // TODO: Test properties - }); -}); diff --git a/test/unit/pixi/extras/Spine.js b/test/unit/pixi/extras/Spine.js deleted file mode 100644 index 0708bc0..0000000 --- a/test/unit/pixi/extras/Spine.js +++ /dev/null @@ -1,10 +0,0 @@ -describe('pixi/extras/Spine', function () { - 'use strict'; - - var expect = chai.expect; - var Spine = PIXI.Spine; - - it('Module exists', function () { - expect(Spine).to.be.a('function'); - }); -}); diff --git a/test/unit/pixi/extras/Strip.js b/test/unit/pixi/extras/Strip.js deleted file mode 100644 index 230af90..0000000 --- a/test/unit/pixi/extras/Strip.js +++ /dev/null @@ -1,26 +0,0 @@ -describe('pixi/extras/Strip', function () { - 'use strict'; - - var expect = chai.expect; - var Strip = PIXI.Strip; - var Texture = PIXI.Texture; - - it('Module exists', function () { - expect(Strip).to.be.a('function'); - }); - - it('Confirm new instance', function () { - - - // TODO-Alvin - // We tweaked it to make it pass the tests, but the whole strip class needs - // to be re-coded - - var texture = Texture.fromImage('/base/test/textures/bunny.png'); - - // var obj = new Strip(texture, 20, 10000); - - - // pixi_extras_Strip_confirmNew(obj); - }); -}); diff --git a/test/unit/pixi/extras/TilingSprite.js b/test/unit/pixi/extras/TilingSprite.js deleted file mode 100644 index 56aea14..0000000 --- a/test/unit/pixi/extras/TilingSprite.js +++ /dev/null @@ -1,24 +0,0 @@ -describe('pixi/extras/TilingSprite', function () { - 'use strict'; - - var expect = chai.expect; - var TilingSprite = PIXI.TilingSprite; - var Texture = PIXI.Texture; - - it('Module exists', function () { - expect(TilingSprite).to.be.a('function'); - }); - - it('Confirm new instance', function () { - var texture = Texture.fromImage('/base/test/textures/bunny.png'); - var obj = new TilingSprite(texture, 6000, 12000); - - pixi_display_DisplayObjectContainer_confirmNew(obj); - - expect(obj).to.be.an.instanceof(TilingSprite); - expect(obj).to.respondTo('setTexture'); - expect(obj).to.respondTo('onTextureUpdate'); - - // TODO: Test properties - }); -}); diff --git a/test/unit/pixi/filters/FilterBlock.js b/test/unit/pixi/filters/FilterBlock.js deleted file mode 100644 index 870cec0..0000000 --- a/test/unit/pixi/filters/FilterBlock.js +++ /dev/null @@ -1,10 +0,0 @@ -describe('pixi/filters/FilterBlock', function () { - 'use strict'; - - var expect = chai.expect; - var FilterBlock = PIXI.FilterBlock; - - it('Module exists', function () { - expect(FilterBlock).to.be.a('function'); - }); -}); diff --git a/test/unit/pixi/loaders/AssetLoader.js b/test/unit/pixi/loaders/AssetLoader.js deleted file mode 100644 index a0aa0b5..0000000 --- a/test/unit/pixi/loaders/AssetLoader.js +++ /dev/null @@ -1,10 +0,0 @@ -describe('pixi/loaders/AssetLoader', function () { - 'use strict'; - - var expect = chai.expect; - var AssetLoader = PIXI.AssetLoader; - - it('Module exists', function () { - expect(AssetLoader).to.be.a('function'); - }); -}); diff --git a/test/unit/pixi/loaders/BitmapFontLoader.js b/test/unit/pixi/loaders/BitmapFontLoader.js deleted file mode 100644 index 046f018..0000000 --- a/test/unit/pixi/loaders/BitmapFontLoader.js +++ /dev/null @@ -1,9 +0,0 @@ -describe('pixi/loaders/BitmapFontLoader', function () { - 'use strict'; - - var expect = chai.expect; - - it('Module exists', function () { - expect(PIXI.BitmapFontLoader).to.be.a('function'); - }); -}); diff --git a/test/unit/pixi/loaders/ImageLoader.js b/test/unit/pixi/loaders/ImageLoader.js deleted file mode 100644 index 8b1f556..0000000 --- a/test/unit/pixi/loaders/ImageLoader.js +++ /dev/null @@ -1,10 +0,0 @@ -describe('pixi/loaders/ImageLoader', function () { - 'use strict'; - - var expect = chai.expect; - var ImageLoader = PIXI.ImageLoader; - - it('Module exists', function () { - expect(ImageLoader).to.be.a('function'); - }); -}); diff --git a/test/unit/pixi/loaders/JsonLoader.js b/test/unit/pixi/loaders/JsonLoader.js deleted file mode 100644 index c577e83..0000000 --- a/test/unit/pixi/loaders/JsonLoader.js +++ /dev/null @@ -1,10 +0,0 @@ -describe('pixi/loaders/JsonLoader', function () { - 'use strict'; - - var expect = chai.expect; - var JsonLoader = PIXI.JsonLoader; - - it('Module exists', function () { - expect(JsonLoader).to.be.a('function'); - }); -}); diff --git a/test/unit/pixi/loaders/SpineLoader.js b/test/unit/pixi/loaders/SpineLoader.js deleted file mode 100644 index fdcc0b8..0000000 --- a/test/unit/pixi/loaders/SpineLoader.js +++ /dev/null @@ -1,10 +0,0 @@ -describe('pixi/loaders/SpineLoader', function () { - 'use strict'; - - var expect = chai.expect; - var SpineLoader = PIXI.SpineLoader; - - it('Module exists', function () { - expect(SpineLoader).to.be.a('function'); - }); -}); diff --git a/test/unit/pixi/loaders/SpriteSheetLoader.js b/test/unit/pixi/loaders/SpriteSheetLoader.js deleted file mode 100644 index 57beb27..0000000 --- a/test/unit/pixi/loaders/SpriteSheetLoader.js +++ /dev/null @@ -1,10 +0,0 @@ -describe('pixi/loaders/SpriteSheetLoader', function () { - 'use strict'; - - var expect = chai.expect; - var SpriteSheetLoader = PIXI.SpriteSheetLoader; - - it('Module exists', function () { - expect(SpriteSheetLoader).to.be.a('function'); - }); -}); diff --git a/test/unit/pixi-v2/InteractionManager.js b/test/unit/pixi-v2/InteractionManager.js new file mode 100644 index 0000000..ed3001f --- /dev/null +++ b/test/unit/pixi-v2/InteractionManager.js @@ -0,0 +1,10 @@ +describe('pixi/InteractionManager', function () { + 'use strict'; + + var expect = chai.expect; + var InteractionManager = PIXI.InteractionManager; + + it('Module exists', function () { + expect(InteractionManager).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/Pixi.js b/test/unit/pixi-v2/Pixi.js new file mode 100644 index 0000000..27debc1 --- /dev/null +++ b/test/unit/pixi-v2/Pixi.js @@ -0,0 +1,9 @@ +describe('pixi/Pixi', function () { + 'use strict'; + + var expect = chai.expect; + + it('Module exists', function () { + expect(global).to.have.property('PIXI').and.to.be.an('object'); + }); +}); diff --git a/test/unit/pixi-v2/core/Circle.js b/test/unit/pixi-v2/core/Circle.js new file mode 100644 index 0000000..fbcfa17 --- /dev/null +++ b/test/unit/pixi-v2/core/Circle.js @@ -0,0 +1,21 @@ +describe('pixi/core/Circle', function () { + 'use strict'; + + var expect = chai.expect; + var Circle = PIXI.Circle; + + it('Module exists', function () { + expect(Circle).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Circle(); + pixi_core_Circle_confirmNewCircle(obj); + }); + + it("getBounds should return Rectangle that bounds the circle", function() { + var obj = new Circle(100, 250, 50); + var bounds = obj.getBounds(); + pixi_core_Circle_isBoundedByRectangle(obj, bounds); + }); +}); diff --git a/test/unit/pixi-v2/core/Ellipse.js b/test/unit/pixi-v2/core/Ellipse.js new file mode 100644 index 0000000..026b56f --- /dev/null +++ b/test/unit/pixi-v2/core/Ellipse.js @@ -0,0 +1,24 @@ +describe('pixi/core/Ellipse', function () { + 'use strict'; + + var expect = chai.expect; + var Ellipse = PIXI.Ellipse; + + it('Module exists', function () { + expect(Ellipse).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Ellipse(); + + expect(obj).to.be.an.instanceof(Ellipse); + expect(obj).to.respondTo('clone'); + expect(obj).to.respondTo('contains'); + expect(obj).to.respondTo('getBounds'); + + expect(obj).to.have.property('x', 0); + expect(obj).to.have.property('y', 0); + expect(obj).to.have.property('width', 0); + expect(obj).to.have.property('height', 0); + }); +}); diff --git a/test/unit/pixi-v2/core/Matrix.js b/test/unit/pixi-v2/core/Matrix.js new file mode 100644 index 0000000..da75e2e --- /dev/null +++ b/test/unit/pixi-v2/core/Matrix.js @@ -0,0 +1,14 @@ +describe('pixi/core/Matrix', function () { + 'use strict'; + + var expect = chai.expect; + + it('Matrix exists', function () { + expect(PIXI.Matrix).to.be.an('function'); + }); + + it('Confirm new Matrix', function () { + var matrix = new PIXI.Matrix(); + pixi_core_Matrix_confirmNewMatrix(matrix); + }); +}); diff --git a/test/unit/pixi-v2/core/Point.js b/test/unit/pixi-v2/core/Point.js new file mode 100644 index 0000000..c4d5163 --- /dev/null +++ b/test/unit/pixi-v2/core/Point.js @@ -0,0 +1,15 @@ +describe('pixi/core/Point', function () { + 'use strict'; + + var expect = chai.expect; + var Point = PIXI.Point; + + it('Module exists', function () { + expect(Point).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Point(); + pixi_core_Point_confirm(obj, 0, 0); + }); +}); diff --git a/test/unit/pixi-v2/core/Polygon.js b/test/unit/pixi-v2/core/Polygon.js new file mode 100644 index 0000000..dc8c918 --- /dev/null +++ b/test/unit/pixi-v2/core/Polygon.js @@ -0,0 +1,20 @@ +describe('pixi/core/Polygon', function () { + 'use strict'; + + var expect = chai.expect; + var Polygon = PIXI.Polygon; + + it('Module exists', function () { + expect(Polygon).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Polygon(); + + expect(obj).to.be.an.instanceof(Polygon); + expect(obj).to.respondTo('clone'); + expect(obj).to.respondTo('contains'); + + expect(obj).to.have.deep.property('points.length', 0); + }); +}); diff --git a/test/unit/pixi-v2/core/Rectangle.js b/test/unit/pixi-v2/core/Rectangle.js new file mode 100644 index 0000000..d43316e --- /dev/null +++ b/test/unit/pixi-v2/core/Rectangle.js @@ -0,0 +1,15 @@ +describe('pixi/core/Rectangle', function () { + 'use strict'; + + var expect = chai.expect; + var Rectangle = PIXI.Rectangle; + + it('Module exists', function () { + expect(Rectangle).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var rect = new Rectangle(); + pixi_core_Rectangle_confirm(rect, 0, 0, 0, 0); + }); +}); diff --git a/test/unit/pixi-v2/display/DisplayObject.js b/test/unit/pixi-v2/display/DisplayObject.js new file mode 100644 index 0000000..044acf8 --- /dev/null +++ b/test/unit/pixi-v2/display/DisplayObject.js @@ -0,0 +1,21 @@ +describe('pixi/display/DisplayObject', function () { + 'use strict'; + + var expect = chai.expect; + var DisplayObject = PIXI.DisplayObject; + + it('Module exists', function () { + expect(DisplayObject).to.be.a('function'); + // expect(PIXI).to.have.property('visibleCount', 0); + }); + + it('Confirm new instance', function () { + var obj = new DisplayObject(); + + pixi_display_DisplayObject_confirmNew(obj); + expect(obj).to.have.property('hitArea', null); + expect(obj).to.have.property('interactive', false); + expect(obj).to.have.property('renderable', false); + expect(obj).to.have.property('stage', null); + }); +}); diff --git a/test/unit/pixi-v2/display/DisplayObjectContainer.js b/test/unit/pixi-v2/display/DisplayObjectContainer.js new file mode 100644 index 0000000..15a3376 --- /dev/null +++ b/test/unit/pixi-v2/display/DisplayObjectContainer.js @@ -0,0 +1,67 @@ +describe('pixi/display/DisplayObjectContainer', function () { + 'use strict'; + + var expect = chai.expect; + var DisplayObjectContainer = PIXI.DisplayObjectContainer; + + it('Module exists', function () { + expect(DisplayObjectContainer).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new DisplayObjectContainer(); + + pixi_display_DisplayObjectContainer_confirmNew(obj); + expect(obj).to.have.property('hitArea', null); + expect(obj).to.have.property('interactive', false); + expect(obj).to.have.property('renderable', false); + expect(obj).to.have.property('stage', null); + }); + + it('Gets child index', function() { + var container = new PIXI.DisplayObjectContainer(); + var children = []; + for (var i = 0; i < 10; i++) { + var child = new PIXI.DisplayObject(); + children.push(child); + container.addChild(child); + } + + for (i = 0; i < children.length; i++) { + expect(i).to.eql(container.getChildIndex(children[i])); + } + }); + + it('throws error when trying to get index of not a child', function() { + var container = new PIXI.DisplayObjectContainer(); + var child = new PIXI.DisplayObject(); + + expect(function() { container.getChildIndex(child); }).to.throw(); + }); + + it('Sets child index', function() { + var container = new PIXI.DisplayObjectContainer(); + var children = []; + + for (var i = 0; i < 10; i++) { + var child = new PIXI.DisplayObject(); + children.push(child); + container.addChild(child); + } + children.reverse(); + + for (i = 0; i < children.length; i++) { + container.setChildIndex(children[i], i); + expect(i).to.eql(container.getChildIndex(children[i])); + } + }); + + it('throws error when trying to set incorect index', function() { + var container = new PIXI.DisplayObjectContainer(); + var child = new PIXI.DisplayObject(); + container.addChild(child); + + expect(function() { container.setChildIndex(child, -1); }).to.throw(); + expect(function() { container.setChildIndex(child, 1); }).to.throw(); + }); +}); diff --git a/test/unit/pixi-v2/display/MovieClip.js b/test/unit/pixi-v2/display/MovieClip.js new file mode 100644 index 0000000..f3c6c6a --- /dev/null +++ b/test/unit/pixi-v2/display/MovieClip.js @@ -0,0 +1,33 @@ +describe('pixi/display/MovieClip', function () { + 'use strict'; + + var expect = chai.expect; + var MovieClip = PIXI.MovieClip; + var Texture = PIXI.Texture; + + it('Module exists', function () { + expect(MovieClip).to.be.a('function'); + }); + + it('Confirm new instance', function (done) { + var texture = Texture.fromImage('/base/test/textures/SpriteSheet-Explosion.png'); + var obj = new MovieClip([texture]); + + pixi_display_Sprite_confirmNew(obj, done); + + expect(obj).to.be.an.instanceof(MovieClip); + expect(obj).to.respondTo('stop'); + expect(obj).to.respondTo('play'); + expect(obj).to.respondTo('gotoAndStop'); + expect(obj).to.respondTo('gotoAndPlay'); + expect(obj).to.respondTo('updateTransform'); + + expect(obj).to.have.deep.property('textures.length', 1); + expect(obj).to.have.deep.property('textures[0]', texture); + expect(obj).to.have.property('animationSpeed', 1); + expect(obj).to.have.property('loop', true); + expect(obj).to.have.property('onComplete', null); + expect(obj).to.have.property('currentFrame', 0); + expect(obj).to.have.property('playing', false); + }); +}); diff --git a/test/unit/pixi-v2/display/Sprite.js b/test/unit/pixi-v2/display/Sprite.js new file mode 100644 index 0000000..30c8076 --- /dev/null +++ b/test/unit/pixi-v2/display/Sprite.js @@ -0,0 +1,28 @@ +describe('pixi/display/Sprite', function () { + 'use strict'; + + var expect = chai.expect; + var Sprite = PIXI.Sprite; + var Texture = PIXI.Texture; + + it('Module exists', function () { + expect(Sprite).to.be.a('function'); + expect(PIXI).to.have.deep.property('blendModes.NORMAL', 0); + expect(PIXI).to.have.deep.property('blendModes.ADD', 1); + expect(PIXI).to.have.deep.property('blendModes.MULTIPLY', 2); + expect(PIXI).to.have.deep.property('blendModes.SCREEN', 3); + }); + + + it('Members exist', function () { + expect(Sprite).itself.to.respondTo('fromImage'); + expect(Sprite).itself.to.respondTo('fromFrame'); + }); + + it('Confirm new instance', function (done) { + var texture = Texture.fromImage('/base/test/textures/SpriteSheet-Aliens.png'); + var obj = new Sprite(texture); + + pixi_display_Sprite_confirmNew(obj, done); + }); +}); diff --git a/test/unit/pixi-v2/display/Stage.js b/test/unit/pixi-v2/display/Stage.js new file mode 100644 index 0000000..6974c2e --- /dev/null +++ b/test/unit/pixi-v2/display/Stage.js @@ -0,0 +1,49 @@ +describe('pixi/display/Stage', function () { + 'use strict'; + + var expect = chai.expect; + var Stage = PIXI.Stage; + var InteractionManager = PIXI.InteractionManager; + var Rectangle = PIXI.Rectangle; + + it('Module exists', function () { + expect(Stage).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Stage(null, true); + + pixi_display_DisplayObjectContainer_confirmNew(obj); + + expect(obj).to.be.an.instanceof(Stage); + expect(obj).to.respondTo('updateTransform'); + expect(obj).to.respondTo('setBackgroundColor'); + expect(obj).to.respondTo('getMousePosition'); + // FIXME: duplicate member in DisplayObject + pixi_core_Matrix_confirmNewMatrix(obj.worldTransform); + // FIXME: convert arg to bool in constructor + expect(obj).to.have.property('interactive', true); + + expect(obj).to.have.property('interactionManager') + .and.to.be.an.instanceof(InteractionManager) + .and.to.have.property('stage', obj); + + expect(obj).to.have.property('dirty', true); + + expect(obj).to.have.property('stage', obj); + + expect(obj).to.have.property('hitArea') + .and.to.be.an.instanceof(Rectangle); + pixi_core_Rectangle_confirm(obj.hitArea, 0, 0, 100000, 100000); + + expect(obj).to.have.property('backgroundColor', 0x000000); + expect(obj).to.have.deep.property('backgroundColorSplit.length', 3); + expect(obj).to.have.deep.property('backgroundColorSplit[0]', 0); + expect(obj).to.have.deep.property('backgroundColorSplit[1]', 0); + expect(obj).to.have.deep.property('backgroundColorSplit[2]', 0); + expect(obj).to.have.property('backgroundColorString', '#000000'); + + + expect(obj).to.have.property('worldVisible', true); + }); +}); diff --git a/test/unit/pixi-v2/extras/Rope.js b/test/unit/pixi-v2/extras/Rope.js new file mode 100644 index 0000000..05885ac --- /dev/null +++ b/test/unit/pixi-v2/extras/Rope.js @@ -0,0 +1,31 @@ +describe('pixi/extras/Rope', function () { + 'use strict'; + + var expect = chai.expect; + var Rope = PIXI.Rope; + var Texture = PIXI.Texture; + var Point = PIXI.Point; + + it('Module exists', function () { + expect(Rope).to.be.a('function'); + }); + + it('Confirm new instance', function () { + + var texture = Texture.fromImage('/base/test/textures/bunny.png'); + + // TODO-Alvin + // Same as Strip + + // var obj = new Rope(texture, [new Point(), new Point(5, 10), new Point(10, 20)]); + + // pixi_extras_Strip_confirmNew(obj); + + // expect(obj).to.be.an.instanceof(Rope); + // expect(obj).to.respondTo('refresh'); + // expect(obj).to.respondTo('updateTransform'); + // expect(obj).to.respondTo('setTexture'); + + // TODO: Test properties + }); +}); diff --git a/test/unit/pixi-v2/extras/Spine.js b/test/unit/pixi-v2/extras/Spine.js new file mode 100644 index 0000000..0708bc0 --- /dev/null +++ b/test/unit/pixi-v2/extras/Spine.js @@ -0,0 +1,10 @@ +describe('pixi/extras/Spine', function () { + 'use strict'; + + var expect = chai.expect; + var Spine = PIXI.Spine; + + it('Module exists', function () { + expect(Spine).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/extras/Strip.js b/test/unit/pixi-v2/extras/Strip.js new file mode 100644 index 0000000..230af90 --- /dev/null +++ b/test/unit/pixi-v2/extras/Strip.js @@ -0,0 +1,26 @@ +describe('pixi/extras/Strip', function () { + 'use strict'; + + var expect = chai.expect; + var Strip = PIXI.Strip; + var Texture = PIXI.Texture; + + it('Module exists', function () { + expect(Strip).to.be.a('function'); + }); + + it('Confirm new instance', function () { + + + // TODO-Alvin + // We tweaked it to make it pass the tests, but the whole strip class needs + // to be re-coded + + var texture = Texture.fromImage('/base/test/textures/bunny.png'); + + // var obj = new Strip(texture, 20, 10000); + + + // pixi_extras_Strip_confirmNew(obj); + }); +}); diff --git a/test/unit/pixi-v2/extras/TilingSprite.js b/test/unit/pixi-v2/extras/TilingSprite.js new file mode 100644 index 0000000..56aea14 --- /dev/null +++ b/test/unit/pixi-v2/extras/TilingSprite.js @@ -0,0 +1,24 @@ +describe('pixi/extras/TilingSprite', function () { + 'use strict'; + + var expect = chai.expect; + var TilingSprite = PIXI.TilingSprite; + var Texture = PIXI.Texture; + + it('Module exists', function () { + expect(TilingSprite).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var texture = Texture.fromImage('/base/test/textures/bunny.png'); + var obj = new TilingSprite(texture, 6000, 12000); + + pixi_display_DisplayObjectContainer_confirmNew(obj); + + expect(obj).to.be.an.instanceof(TilingSprite); + expect(obj).to.respondTo('setTexture'); + expect(obj).to.respondTo('onTextureUpdate'); + + // TODO: Test properties + }); +}); diff --git a/test/unit/pixi-v2/filters/FilterBlock.js b/test/unit/pixi-v2/filters/FilterBlock.js new file mode 100644 index 0000000..870cec0 --- /dev/null +++ b/test/unit/pixi-v2/filters/FilterBlock.js @@ -0,0 +1,10 @@ +describe('pixi/filters/FilterBlock', function () { + 'use strict'; + + var expect = chai.expect; + var FilterBlock = PIXI.FilterBlock; + + it('Module exists', function () { + expect(FilterBlock).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/AssetLoader.js b/test/unit/pixi-v2/loaders/AssetLoader.js new file mode 100644 index 0000000..a0aa0b5 --- /dev/null +++ b/test/unit/pixi-v2/loaders/AssetLoader.js @@ -0,0 +1,10 @@ +describe('pixi/loaders/AssetLoader', function () { + 'use strict'; + + var expect = chai.expect; + var AssetLoader = PIXI.AssetLoader; + + it('Module exists', function () { + expect(AssetLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/BitmapFontLoader.js b/test/unit/pixi-v2/loaders/BitmapFontLoader.js new file mode 100644 index 0000000..046f018 --- /dev/null +++ b/test/unit/pixi-v2/loaders/BitmapFontLoader.js @@ -0,0 +1,9 @@ +describe('pixi/loaders/BitmapFontLoader', function () { + 'use strict'; + + var expect = chai.expect; + + it('Module exists', function () { + expect(PIXI.BitmapFontLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/ImageLoader.js b/test/unit/pixi-v2/loaders/ImageLoader.js new file mode 100644 index 0000000..8b1f556 --- /dev/null +++ b/test/unit/pixi-v2/loaders/ImageLoader.js @@ -0,0 +1,10 @@ +describe('pixi/loaders/ImageLoader', function () { + 'use strict'; + + var expect = chai.expect; + var ImageLoader = PIXI.ImageLoader; + + it('Module exists', function () { + expect(ImageLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/JsonLoader.js b/test/unit/pixi-v2/loaders/JsonLoader.js new file mode 100644 index 0000000..c577e83 --- /dev/null +++ b/test/unit/pixi-v2/loaders/JsonLoader.js @@ -0,0 +1,10 @@ +describe('pixi/loaders/JsonLoader', function () { + 'use strict'; + + var expect = chai.expect; + var JsonLoader = PIXI.JsonLoader; + + it('Module exists', function () { + expect(JsonLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/SpineLoader.js b/test/unit/pixi-v2/loaders/SpineLoader.js new file mode 100644 index 0000000..fdcc0b8 --- /dev/null +++ b/test/unit/pixi-v2/loaders/SpineLoader.js @@ -0,0 +1,10 @@ +describe('pixi/loaders/SpineLoader', function () { + 'use strict'; + + var expect = chai.expect; + var SpineLoader = PIXI.SpineLoader; + + it('Module exists', function () { + expect(SpineLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/SpriteSheetLoader.js b/test/unit/pixi-v2/loaders/SpriteSheetLoader.js new file mode 100644 index 0000000..57beb27 --- /dev/null +++ b/test/unit/pixi-v2/loaders/SpriteSheetLoader.js @@ -0,0 +1,10 @@ +describe('pixi/loaders/SpriteSheetLoader', function () { + 'use strict'; + + var expect = chai.expect; + var SpriteSheetLoader = PIXI.SpriteSheetLoader; + + it('Module exists', function () { + expect(SpriteSheetLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/primitives/Graphics.js b/test/unit/pixi-v2/primitives/Graphics.js new file mode 100644 index 0000000..f3849eb --- /dev/null +++ b/test/unit/pixi-v2/primitives/Graphics.js @@ -0,0 +1,44 @@ +describe('pixi/primitives/Graphics', function () { + 'use strict'; + + var expect = chai.expect; + var Graphics = PIXI.Graphics; + + it('Module exists', function () { + expect(Graphics).to.be.a('function'); + + expect(Graphics).itself.to.have.property('POLY', 0); + expect(Graphics).itself.to.have.property('RECT', 1); + expect(Graphics).itself.to.have.property('CIRC', 2); + expect(Graphics).itself.to.have.property('ELIP', 3); + expect(Graphics).itself.to.have.property('RREC', 4); + }); + + it('Confirm new instance', function () { + var obj = new Graphics(); + + pixi_display_DisplayObjectContainer_confirmNew(obj); + + expect(obj).to.be.an.instanceof(Graphics); + expect(obj).to.respondTo('lineStyle'); + expect(obj).to.respondTo('lineStyle'); + expect(obj).to.respondTo('moveTo'); + expect(obj).to.respondTo('lineTo'); + expect(obj).to.respondTo('beginFill'); + expect(obj).to.respondTo('endFill'); + expect(obj).to.respondTo('drawRect'); + // expect(obj).to.respondTo('drawRoundedRect'); + expect(obj).to.respondTo('drawCircle'); + expect(obj).to.respondTo('drawEllipse'); + expect(obj).to.respondTo('clear'); + + expect(obj).to.have.property('renderable', true); + expect(obj).to.have.property('fillAlpha', 1); + expect(obj).to.have.property('lineWidth', 0); + expect(obj).to.have.property('width', 0); + expect(obj).to.have.property('height', 0); + expect(obj).to.have.property('lineColor', 0); + expect(obj).to.have.deep.property('graphicsData.length', 0); + // expect(obj).to.have.deep.property('currentPath.points.length', 0); + }); +}); diff --git a/test/unit/pixi-v2/renderers/canvas/CanvasGraphics.js b/test/unit/pixi-v2/renderers/canvas/CanvasGraphics.js new file mode 100644 index 0000000..8f44472 --- /dev/null +++ b/test/unit/pixi-v2/renderers/canvas/CanvasGraphics.js @@ -0,0 +1,15 @@ +describe('renders/canvas/CanvasGraphics', function () { + 'use strict'; + + var expect = chai.expect; + var CanvasGraphics = PIXI.CanvasGraphics; + + it('Module exists', function () { + expect(CanvasGraphics).to.be.a('function'); + }); + + it('Members exist', function () { + expect(CanvasGraphics).itself.to.respondTo('renderGraphics'); + expect(CanvasGraphics).itself.to.respondTo('renderGraphicsMask'); + }); +}); diff --git a/test/unit/pixi-v2/renderers/canvas/CanvasRenderer.js b/test/unit/pixi-v2/renderers/canvas/CanvasRenderer.js new file mode 100644 index 0000000..1646444 --- /dev/null +++ b/test/unit/pixi-v2/renderers/canvas/CanvasRenderer.js @@ -0,0 +1,36 @@ +describe('renderers/canvas/CanvasRenderer', function () { + 'use strict'; + + var expect = chai.expect; + var CanvasRenderer = PIXI.CanvasRenderer; + + it('Module exists', function () { + expect(CanvasRenderer).to.be.a('function'); + }); + + describe('.autoResize', function () { + it('Should automatically resize view if enabled', function () { + var renderer = new CanvasRenderer(200, 200, { + autoResize: true + }); + + expect(renderer.view.style.width).to.equal('200px'); + }); + + it('Should not automatically resize view if disabled', function () { + var renderer = new CanvasRenderer(200, 200, { + autoResize: false + }); + + expect(renderer.view.style.width).to.equal(''); + }); + + it('Should not automatically resize view if not specified', function () { + var renderer = new CanvasRenderer(200, 200, { + resolution: 2 + }); + + expect(renderer.view.style.width).to.equal(''); + }); + }); +}); diff --git a/test/unit/pixi-v2/renderers/webgl/WebGLGraphics.js b/test/unit/pixi-v2/renderers/webgl/WebGLGraphics.js new file mode 100644 index 0000000..5867b28 --- /dev/null +++ b/test/unit/pixi-v2/renderers/webgl/WebGLGraphics.js @@ -0,0 +1,20 @@ +describe('renderers/wegbl/WebGLGraphics', function () { + 'use strict'; + + var expect = chai.expect; + var WebGLGraphics = PIXI.WebGLGraphics; + + it('Module exists', function () { + expect(WebGLGraphics).to.be.a('function'); + }); + + it('Members exist', function () { + expect(WebGLGraphics).itself.to.respondTo('renderGraphics'); + expect(WebGLGraphics).itself.to.respondTo('updateGraphics'); + expect(WebGLGraphics).itself.to.respondTo('buildRectangle'); + expect(WebGLGraphics).itself.to.respondTo('buildRoundedRectangle'); + expect(WebGLGraphics).itself.to.respondTo('buildCircle'); + expect(WebGLGraphics).itself.to.respondTo('buildLine'); + expect(WebGLGraphics).itself.to.respondTo('buildPoly'); + }); +}); diff --git a/test/unit/pixi-v2/renderers/webgl/WebGLRenderer.js b/test/unit/pixi-v2/renderers/webgl/WebGLRenderer.js new file mode 100644 index 0000000..1680a80 --- /dev/null +++ b/test/unit/pixi-v2/renderers/webgl/WebGLRenderer.js @@ -0,0 +1,49 @@ +describe('renderers/webgl/WebGLRenderer', function () { + 'use strict'; + + var expect = chai.expect; + var WebGLRenderer = PIXI.WebGLRenderer; + + it('Module exists', function () { + expect(WebGLRenderer).to.be.a('function'); + }); + + // Skip tests if WebGL is not available (WebGL not supported in Travis CI) + try { + var renderer = new WebGLRenderer(400, 300, {}); + renderer.destroy(); + } catch (error) { + return; + } + + it('Destroy renderer', function () { + var renderer = new WebGLRenderer(400, 300, {}); + renderer.destroy(); + }); + + describe('.autoResize', function () { + it('Should automatically resize view if enabled', function () { + var renderer = new WebGLRenderer(200, 200, { + autoResize: true + }); + + expect(renderer.view.style.width).to.equal('200px'); + }); + + it('Should not automatically resize view if disabled', function () { + var renderer = new WebGLRenderer(200, 200, { + autoResize: false + }); + + expect(renderer.view.style.width).to.equal(''); + }); + + it('Should not automatically resize view if not specified', function () { + var renderer = new WebGLRenderer(200, 200, { + resolution: 2 + }); + + expect(renderer.view.style.width).to.equal(''); + }); + }); +}); diff --git a/test/unit/pixi-v2/renderers/webgl/WebGLShaders.js b/test/unit/pixi-v2/renderers/webgl/WebGLShaders.js new file mode 100644 index 0000000..6e33e4f --- /dev/null +++ b/test/unit/pixi-v2/renderers/webgl/WebGLShaders.js @@ -0,0 +1,13 @@ +describe('renderers/webgl/WebGLShaders', function () { + 'use strict'; + + var expect = chai.expect; + + it('Module members exist', function () { + + expect(PIXI).to.respondTo('CompileVertexShader'); + expect(PIXI).to.respondTo('CompileFragmentShader'); + expect(PIXI).to.respondTo('_CompileShader'); + expect(PIXI).to.respondTo('compileProgram'); + }); +}); diff --git a/test/unit/pixi-v2/renderers/webgl/WebGLSpriteBatch.js b/test/unit/pixi-v2/renderers/webgl/WebGLSpriteBatch.js new file mode 100644 index 0000000..e662b63 --- /dev/null +++ b/test/unit/pixi-v2/renderers/webgl/WebGLSpriteBatch.js @@ -0,0 +1,10 @@ +describe('renderers/webgl/utils/WebGLSpriteBatch', function () { + 'use strict'; + + var expect = chai.expect; + var WebGLSpriteBatch = PIXI.WebGLSpriteBatch; + + it('Module exists', function () { + expect(WebGLSpriteBatch).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/text/BitmapText.js b/test/unit/pixi-v2/text/BitmapText.js new file mode 100644 index 0000000..9388e3d --- /dev/null +++ b/test/unit/pixi-v2/text/BitmapText.js @@ -0,0 +1,10 @@ +describe('pixi/text/BitmapText', function () { + 'use strict'; + + var expect = chai.expect; + var BitmapText = PIXI.BitmapText; + + it('Module exists', function () { + expect(BitmapText).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/text/Text.js b/test/unit/pixi-v2/text/Text.js new file mode 100644 index 0000000..9bc9ac5 --- /dev/null +++ b/test/unit/pixi-v2/text/Text.js @@ -0,0 +1,10 @@ +describe('pixi/text/Text', function () { + 'use strict'; + + var expect = chai.expect; + var Text = PIXI.Text; + + it('Module exists', function () { + expect(Text).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/textures/BaseTexture.js b/test/unit/pixi-v2/textures/BaseTexture.js new file mode 100644 index 0000000..502b724 --- /dev/null +++ b/test/unit/pixi-v2/textures/BaseTexture.js @@ -0,0 +1,11 @@ +describe('pixi/textures/BaseTexture', function () { + 'use strict'; + + var expect = chai.expect; + var BaseTexture = PIXI.BaseTexture; + + it('Module exists', function () { + expect(BaseTexture).to.be.a('function'); + expect(PIXI).to.have.property('BaseTextureCache').and.to.be.an('object'); + }); +}); diff --git a/test/unit/pixi-v2/textures/RenderTexture.js b/test/unit/pixi-v2/textures/RenderTexture.js new file mode 100644 index 0000000..96acdb4 --- /dev/null +++ b/test/unit/pixi-v2/textures/RenderTexture.js @@ -0,0 +1,15 @@ +describe('pixi/textures/RenderTexture', function () { + 'use strict'; + + var expect = chai.expect; + var RenderTexture = PIXI.RenderTexture; + + it('Module exists', function () { + expect(RenderTexture).to.be.a('function'); + }); + + it('Confirm new instance', function (done) { + var texture = new RenderTexture(100, 100, new PIXI.CanvasRenderer()); + pixi_textures_RenderTexture_confirmNew(texture, done); + }); +}); diff --git a/test/unit/pixi-v2/textures/Texture.js b/test/unit/pixi-v2/textures/Texture.js new file mode 100644 index 0000000..090f64d --- /dev/null +++ b/test/unit/pixi-v2/textures/Texture.js @@ -0,0 +1,26 @@ +describe('pixi/textures/Texture', function () { + 'use strict'; + + var expect = chai.expect; + var Texture = PIXI.Texture; + + it('Module exists', function () { + expect(Texture).to.be.a('function'); + expect(PIXI).to.have.property('TextureCache').and.to.be.an('object'); + }); + + it('Members exist', function () { + expect(Texture).itself.to.respondTo('fromImage'); + expect(Texture).itself.to.respondTo('fromFrame'); + expect(Texture).itself.to.respondTo('fromCanvas'); + expect(Texture).itself.to.respondTo('addTextureToCache'); + expect(Texture).itself.to.respondTo('removeTextureFromCache'); + + // expect(Texture).itself.to.have.deep.property('frameUpdates.length', 0); + }); + + it('Confirm new instance', function (done) { + var texture = Texture.fromImage('/base/test/textures/bunny.png'); + pixi_textures_Texture_confirmNew(texture, done); + }); +}); diff --git a/test/unit/pixi-v2/utils/Detector.js b/test/unit/pixi-v2/utils/Detector.js new file mode 100644 index 0000000..4cf6008 --- /dev/null +++ b/test/unit/pixi-v2/utils/Detector.js @@ -0,0 +1,10 @@ +describe('pixi/utils/Detector', function () { + 'use strict'; + + var expect = chai.expect; + var autoDetectRenderer = PIXI.autoDetectRenderer; + + it('Module exists', function () { + expect(autoDetectRenderer).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/utils/EventTarget.js b/test/unit/pixi-v2/utils/EventTarget.js new file mode 100644 index 0000000..1cfc3a4 --- /dev/null +++ b/test/unit/pixi-v2/utils/EventTarget.js @@ -0,0 +1,361 @@ +describe('pixi/utils/EventTarget', function () { + 'use strict'; + + var expect = chai.expect; + + var Clazz, PClazz, obj, pobj, obj2; + beforeEach(function () { + Clazz = function () {}; + PClazz = function () {}; + + PIXI.EventTarget.mixin(Clazz.prototype); + PIXI.EventTarget.mixin(PClazz.prototype); + + obj = new Clazz(); + obj2 = new Clazz(); + pobj = new PClazz(); + + obj.parent = pobj; + obj2.parent = obj; + }); + + it('Module exists', function () { + expect(PIXI.EventTarget).to.be.an('object'); + }); + + it('Confirm new instance', function () { + pixi_utils_EventTarget_confirm(obj); + }); + + it('simple on/emit case works', function () { + var myData = {}; + + obj.on('myevent', function (event) { + pixi_utils_EventTarget_Event_confirm(event, obj, myData); + }); + + obj.emit('myevent', myData); + }); + + it('simple once case works', function () { + var called = 0; + + obj.once('myevent', function() { called++; }); + + obj.emit('myevent'); + obj.emit('myevent'); + obj.emit('myevent'); + obj.emit('myevent'); + obj.emit('myevent'); + + expect(called).to.equal(1); + }); + + it('simple off case works', function (done) { + function onMyEvent() { + done(new Error('Event listener should not have been called')); + } + + obj.on('myevent', onMyEvent); + obj.off('myevent', onMyEvent); + obj.emit('myevent'); + + done(); + }); + + it('simple propagation case works', function (done) { + var myData = {}; + + pobj.on('myevent', function () { + done(); + }); + + obj.emit('myevent'); + }); + + it('simple stopPropagation case works', function (done) { + var myData = {}; + + pobj.on('myevent', function () { + done(new Error('Event listener should not have been called on the parent element')); + }); + + obj.on('myevent', function (evt) { + evt.stopPropagation(); + }); + + obj.emit('myevent'); + + done(); + }); + + it('simple stopImmediatePropagation case works', function (done) { + var myData = {}; + + pobj.on('myevent', function () { + done(new Error('Event listener should not have been called on the parent')); + }); + + obj.on('myevent', function (evt) { + evt.stopImmediatePropagation(); + }); + + obj.on('myevent', function () { + done(new Error('Event listener should not have been called on the second')); + }); + + obj.emit('myevent'); + + done(); + }); + + it('multiple dispatches work properly', function () { + var called = 0; + + function onMyEvent() { + called++; + } + + obj.on('myevent', onMyEvent); + obj.emit('myevent'); + obj.emit('myevent'); + obj.emit('myevent'); + obj.emit('myevent'); + + expect(called).to.equal(4); + }); + + it('multiple events work properly', function () { + var called = 0; + + function onMyEvent() { + called++; + } + + obj.on('myevent1', onMyEvent); + obj.on('myevent2', onMyEvent); + obj.on('myevent3', onMyEvent); + obj.emit('myevent1'); + obj.emit('myevent2'); + obj.emit('myevent3'); + + expect(called).to.equal(3); + }); + + it('multiple events one removed works properly', function () { + var called = 0; + + function onMyEvent() { + called++; + } + + obj.on('myevent1', onMyEvent); + obj.on('myevent2', onMyEvent); + obj.on('myevent3', onMyEvent); + + obj.emit('myevent1'); + obj.emit('myevent2'); + obj.emit('myevent3'); + + obj.off('myevent2', onMyEvent); + + obj.emit('myevent1'); + obj.emit('myevent2'); + obj.emit('myevent3'); + + expect(called).to.equal(5); + }); + + it('multiple handlers for one event with some removed', function () { + var called = 0; + + var onMyEvent = function () { + called++; + }, + onMyEvent2 = function () { + called++; + }; + + // add 2 handlers and confirm they both get called + obj.on('myevent', onMyEvent); + obj.on('myevent', onMyEvent); + obj.on('myevent', onMyEvent2); + obj.on('myevent', onMyEvent2); + + obj.emit('myevent'); + + expect(called).to.equal(4); + + // remove one of the handlers, emit again, then ensure 1 more call is made + obj.off('myevent', onMyEvent); + + obj.emit('myevent'); + + expect(called).to.equal(6); + }); + + it('calls to off without a handler do nothing', function () { + var called = 0; + + var onMyEvent = function () { + called++; + }; + + obj.on('myevent', onMyEvent); + obj.on('myevent', onMyEvent); + + obj.emit('myevent'); + + expect(called).to.equal(2); + + obj.off('myevent'); + + obj.emit('myevent'); + + expect(called).to.equal(4); + + obj.off('myevent', onMyEvent); + + obj.emit('myevent'); + + expect(called).to.equal(4); + }); + + it('handles multiple instances with the same prototype', function () { + var called = 0; + + function onMyEvent(e) { + called++; + } + + obj.on('myevent1', onMyEvent); + obj.on('myevent2', onMyEvent); + + obj2.istwo = true; + obj2.on('myevent1', onMyEvent); + obj2.on('myevent2', onMyEvent); + + obj.emit('myevent1'); + obj.emit('myevent2'); + obj2.emit('myevent1'); + obj2.emit('myevent2'); + + //we emit 4 times, but since obj2 is a child of obj the event should bubble + //up to obj and show up there as well. So the obj2.emit() calls each increment + //the counter twice. + expect(called).to.equal(6); + }); + + it('is backwards compatible with older .dispatchEvent({})', function () { + var called = 0, + data = { + some: 'thing', + hello: true + }; + + function onMyEvent(event) { + pixi_utils_EventTarget_Event_confirm(event, obj, data); + + called++; + } + + obj.on('myevent1', onMyEvent); + obj.on('myevent2', onMyEvent); + obj.on('myevent3', onMyEvent); + + data.type = 'myevent1'; + obj.emit(data); + + data.type = 'myevent2'; + obj.emit(data); + + data.type = 'myevent3'; + obj.emit(data); + + obj.off('myevent2', onMyEvent); + + data.type = 'myevent1'; + obj.emit(data); + + data.type = 'myevent2'; + obj.emit(data); + + data.type = 'myevent3'; + obj.emit(data); + + expect(called).to.equal(5); + }); + + it('is backwards compatible with older .call(this)', function () { + var Fn = function() { + PIXI.EventTarget.call(this); + }, + o = new Fn(); + + pixi_utils_EventTarget_confirm(o); + }); + + it('is backwards compatible with older .addEventListener("")', function () { + var called = 0, + data = { + some: 'thing', + hello: true + }; + + function onMyEvent(event) { + pixi_utils_EventTarget_Event_confirm(event, obj, data); + + called++; + } + + obj.addEventListener('myevent1', onMyEvent); + obj.addEventListener('myevent2', onMyEvent); + obj.addEventListener('myevent3', onMyEvent); + + data.type = 'myevent1'; + obj.emit(data); + + data.type = 'myevent2'; + obj.emit(data); + + data.type = 'myevent3'; + obj.emit(data); + + obj.off('myevent2', onMyEvent); + + data.type = 'myevent1'; + obj.emit(data); + + data.type = 'myevent2'; + obj.emit(data); + + data.type = 'myevent3'; + obj.emit(data); + + expect(called).to.equal(5); + }); + + it('event remove during emit call properly', function () { + var called = 0; + + function cb1() { + called++; + obj.off('myevent', cb1); + } + function cb2() { + called++; + obj.off('myevent', cb2); + } + function cb3() { + called++; + obj.off('myevent', cb3); + } + + obj.on('myevent', cb1); + obj.on('myevent', cb2); + obj.on('myevent', cb3); + obj.emit('myevent', ''); + + expect(called).to.equal(3); + }); +}); diff --git a/test/unit/pixi-v2/utils/Polyk.js b/test/unit/pixi-v2/utils/Polyk.js new file mode 100644 index 0000000..dfc7128 --- /dev/null +++ b/test/unit/pixi-v2/utils/Polyk.js @@ -0,0 +1,14 @@ +describe('pixi/utils/Polyk', function () { + 'use strict'; + + var expect = chai.expect; + var PolyK = PIXI.PolyK; + + it('Module exists', function () { + expect(PolyK).to.be.an('object'); + }); + + it('Members exist', function () { + expect(PolyK).to.respondTo('Triangulate'); + }); +}); diff --git a/test/unit/pixi-v2/utils/Utils.js b/test/unit/pixi-v2/utils/Utils.js new file mode 100644 index 0000000..c97b3c6 --- /dev/null +++ b/test/unit/pixi-v2/utils/Utils.js @@ -0,0 +1,17 @@ +describe('Utils', function () { + 'use strict'; + + var expect = chai.expect; + + it('requestAnimationFrame exists', function () { + expect(global).to.respondTo('requestAnimationFrame'); + }); + + it('cancelAnimationFrame exists', function () { + expect(global).to.respondTo('cancelAnimationFrame'); + }); + + it('requestAnimFrame exists', function () { + expect(global).to.respondTo('requestAnimFrame'); + }); +}); diff --git a/test/unit/pixi/InteractionManager.js b/test/unit/pixi/InteractionManager.js deleted file mode 100644 index ed3001f..0000000 --- a/test/unit/pixi/InteractionManager.js +++ /dev/null @@ -1,10 +0,0 @@ -describe('pixi/InteractionManager', function () { - 'use strict'; - - var expect = chai.expect; - var InteractionManager = PIXI.InteractionManager; - - it('Module exists', function () { - expect(InteractionManager).to.be.a('function'); - }); -}); diff --git a/test/unit/pixi/Pixi.js b/test/unit/pixi/Pixi.js deleted file mode 100644 index 27debc1..0000000 --- a/test/unit/pixi/Pixi.js +++ /dev/null @@ -1,9 +0,0 @@ -describe('pixi/Pixi', function () { - 'use strict'; - - var expect = chai.expect; - - it('Module exists', function () { - expect(global).to.have.property('PIXI').and.to.be.an('object'); - }); -}); diff --git a/test/unit/pixi/core/Circle.js b/test/unit/pixi/core/Circle.js deleted file mode 100644 index fbcfa17..0000000 --- a/test/unit/pixi/core/Circle.js +++ /dev/null @@ -1,21 +0,0 @@ -describe('pixi/core/Circle', function () { - 'use strict'; - - var expect = chai.expect; - var Circle = PIXI.Circle; - - it('Module exists', function () { - expect(Circle).to.be.a('function'); - }); - - it('Confirm new instance', function () { - var obj = new Circle(); - pixi_core_Circle_confirmNewCircle(obj); - }); - - it("getBounds should return Rectangle that bounds the circle", function() { - var obj = new Circle(100, 250, 50); - var bounds = obj.getBounds(); - pixi_core_Circle_isBoundedByRectangle(obj, bounds); - }); -}); diff --git a/test/unit/pixi/core/Ellipse.js b/test/unit/pixi/core/Ellipse.js deleted file mode 100644 index 026b56f..0000000 --- a/test/unit/pixi/core/Ellipse.js +++ /dev/null @@ -1,24 +0,0 @@ -describe('pixi/core/Ellipse', function () { - 'use strict'; - - var expect = chai.expect; - var Ellipse = PIXI.Ellipse; - - it('Module exists', function () { - expect(Ellipse).to.be.a('function'); - }); - - it('Confirm new instance', function () { - var obj = new Ellipse(); - - expect(obj).to.be.an.instanceof(Ellipse); - expect(obj).to.respondTo('clone'); - expect(obj).to.respondTo('contains'); - expect(obj).to.respondTo('getBounds'); - - expect(obj).to.have.property('x', 0); - expect(obj).to.have.property('y', 0); - expect(obj).to.have.property('width', 0); - expect(obj).to.have.property('height', 0); - }); -}); diff --git a/test/unit/pixi/core/Matrix.js b/test/unit/pixi/core/Matrix.js deleted file mode 100644 index da75e2e..0000000 --- a/test/unit/pixi/core/Matrix.js +++ /dev/null @@ -1,14 +0,0 @@ -describe('pixi/core/Matrix', function () { - 'use strict'; - - var expect = chai.expect; - - it('Matrix exists', function () { - expect(PIXI.Matrix).to.be.an('function'); - }); - - it('Confirm new Matrix', function () { - var matrix = new PIXI.Matrix(); - pixi_core_Matrix_confirmNewMatrix(matrix); - }); -}); diff --git a/test/unit/pixi/core/Point.js b/test/unit/pixi/core/Point.js deleted file mode 100644 index c4d5163..0000000 --- a/test/unit/pixi/core/Point.js +++ /dev/null @@ -1,15 +0,0 @@ -describe('pixi/core/Point', function () { - 'use strict'; - - var expect = chai.expect; - var Point = PIXI.Point; - - it('Module exists', function () { - expect(Point).to.be.a('function'); - }); - - it('Confirm new instance', function () { - var obj = new Point(); - pixi_core_Point_confirm(obj, 0, 0); - }); -}); diff --git a/test/unit/pixi/core/Polygon.js b/test/unit/pixi/core/Polygon.js deleted file mode 100644 index dc8c918..0000000 --- a/test/unit/pixi/core/Polygon.js +++ /dev/null @@ -1,20 +0,0 @@ -describe('pixi/core/Polygon', function () { - 'use strict'; - - var expect = chai.expect; - var Polygon = PIXI.Polygon; - - it('Module exists', function () { - expect(Polygon).to.be.a('function'); - }); - - it('Confirm new instance', function () { - var obj = new Polygon(); - - expect(obj).to.be.an.instanceof(Polygon); - expect(obj).to.respondTo('clone'); - expect(obj).to.respondTo('contains'); - - expect(obj).to.have.deep.property('points.length', 0); - }); -}); diff --git a/test/unit/pixi/core/Rectangle.js b/test/unit/pixi/core/Rectangle.js deleted file mode 100644 index d43316e..0000000 --- a/test/unit/pixi/core/Rectangle.js +++ /dev/null @@ -1,15 +0,0 @@ -describe('pixi/core/Rectangle', function () { - 'use strict'; - - var expect = chai.expect; - var Rectangle = PIXI.Rectangle; - - it('Module exists', function () { - expect(Rectangle).to.be.a('function'); - }); - - it('Confirm new instance', function () { - var rect = new Rectangle(); - pixi_core_Rectangle_confirm(rect, 0, 0, 0, 0); - }); -}); diff --git a/test/unit/pixi/display/DisplayObject.js b/test/unit/pixi/display/DisplayObject.js deleted file mode 100644 index 044acf8..0000000 --- a/test/unit/pixi/display/DisplayObject.js +++ /dev/null @@ -1,21 +0,0 @@ -describe('pixi/display/DisplayObject', function () { - 'use strict'; - - var expect = chai.expect; - var DisplayObject = PIXI.DisplayObject; - - it('Module exists', function () { - expect(DisplayObject).to.be.a('function'); - // expect(PIXI).to.have.property('visibleCount', 0); - }); - - it('Confirm new instance', function () { - var obj = new DisplayObject(); - - pixi_display_DisplayObject_confirmNew(obj); - expect(obj).to.have.property('hitArea', null); - expect(obj).to.have.property('interactive', false); - expect(obj).to.have.property('renderable', false); - expect(obj).to.have.property('stage', null); - }); -}); diff --git a/test/unit/pixi/display/DisplayObjectContainer.js b/test/unit/pixi/display/DisplayObjectContainer.js deleted file mode 100644 index 15a3376..0000000 --- a/test/unit/pixi/display/DisplayObjectContainer.js +++ /dev/null @@ -1,67 +0,0 @@ -describe('pixi/display/DisplayObjectContainer', function () { - 'use strict'; - - var expect = chai.expect; - var DisplayObjectContainer = PIXI.DisplayObjectContainer; - - it('Module exists', function () { - expect(DisplayObjectContainer).to.be.a('function'); - }); - - it('Confirm new instance', function () { - var obj = new DisplayObjectContainer(); - - pixi_display_DisplayObjectContainer_confirmNew(obj); - expect(obj).to.have.property('hitArea', null); - expect(obj).to.have.property('interactive', false); - expect(obj).to.have.property('renderable', false); - expect(obj).to.have.property('stage', null); - }); - - it('Gets child index', function() { - var container = new PIXI.DisplayObjectContainer(); - var children = []; - for (var i = 0; i < 10; i++) { - var child = new PIXI.DisplayObject(); - children.push(child); - container.addChild(child); - } - - for (i = 0; i < children.length; i++) { - expect(i).to.eql(container.getChildIndex(children[i])); - } - }); - - it('throws error when trying to get index of not a child', function() { - var container = new PIXI.DisplayObjectContainer(); - var child = new PIXI.DisplayObject(); - - expect(function() { container.getChildIndex(child); }).to.throw(); - }); - - it('Sets child index', function() { - var container = new PIXI.DisplayObjectContainer(); - var children = []; - - for (var i = 0; i < 10; i++) { - var child = new PIXI.DisplayObject(); - children.push(child); - container.addChild(child); - } - children.reverse(); - - for (i = 0; i < children.length; i++) { - container.setChildIndex(children[i], i); - expect(i).to.eql(container.getChildIndex(children[i])); - } - }); - - it('throws error when trying to set incorect index', function() { - var container = new PIXI.DisplayObjectContainer(); - var child = new PIXI.DisplayObject(); - container.addChild(child); - - expect(function() { container.setChildIndex(child, -1); }).to.throw(); - expect(function() { container.setChildIndex(child, 1); }).to.throw(); - }); -}); diff --git a/test/unit/pixi/display/MovieClip.js b/test/unit/pixi/display/MovieClip.js deleted file mode 100644 index f3c6c6a..0000000 --- a/test/unit/pixi/display/MovieClip.js +++ /dev/null @@ -1,33 +0,0 @@ -describe('pixi/display/MovieClip', function () { - 'use strict'; - - var expect = chai.expect; - var MovieClip = PIXI.MovieClip; - var Texture = PIXI.Texture; - - it('Module exists', function () { - expect(MovieClip).to.be.a('function'); - }); - - it('Confirm new instance', function (done) { - var texture = Texture.fromImage('/base/test/textures/SpriteSheet-Explosion.png'); - var obj = new MovieClip([texture]); - - pixi_display_Sprite_confirmNew(obj, done); - - expect(obj).to.be.an.instanceof(MovieClip); - expect(obj).to.respondTo('stop'); - expect(obj).to.respondTo('play'); - expect(obj).to.respondTo('gotoAndStop'); - expect(obj).to.respondTo('gotoAndPlay'); - expect(obj).to.respondTo('updateTransform'); - - expect(obj).to.have.deep.property('textures.length', 1); - expect(obj).to.have.deep.property('textures[0]', texture); - expect(obj).to.have.property('animationSpeed', 1); - expect(obj).to.have.property('loop', true); - expect(obj).to.have.property('onComplete', null); - expect(obj).to.have.property('currentFrame', 0); - expect(obj).to.have.property('playing', false); - }); -}); diff --git a/test/unit/pixi/display/Sprite.js b/test/unit/pixi/display/Sprite.js deleted file mode 100644 index 30c8076..0000000 --- a/test/unit/pixi/display/Sprite.js +++ /dev/null @@ -1,28 +0,0 @@ -describe('pixi/display/Sprite', function () { - 'use strict'; - - var expect = chai.expect; - var Sprite = PIXI.Sprite; - var Texture = PIXI.Texture; - - it('Module exists', function () { - expect(Sprite).to.be.a('function'); - expect(PIXI).to.have.deep.property('blendModes.NORMAL', 0); - expect(PIXI).to.have.deep.property('blendModes.ADD', 1); - expect(PIXI).to.have.deep.property('blendModes.MULTIPLY', 2); - expect(PIXI).to.have.deep.property('blendModes.SCREEN', 3); - }); - - - it('Members exist', function () { - expect(Sprite).itself.to.respondTo('fromImage'); - expect(Sprite).itself.to.respondTo('fromFrame'); - }); - - it('Confirm new instance', function (done) { - var texture = Texture.fromImage('/base/test/textures/SpriteSheet-Aliens.png'); - var obj = new Sprite(texture); - - pixi_display_Sprite_confirmNew(obj, done); - }); -}); diff --git a/test/unit/pixi/display/Stage.js b/test/unit/pixi/display/Stage.js deleted file mode 100644 index 6974c2e..0000000 --- a/test/unit/pixi/display/Stage.js +++ /dev/null @@ -1,49 +0,0 @@ -describe('pixi/display/Stage', function () { - 'use strict'; - - var expect = chai.expect; - var Stage = PIXI.Stage; - var InteractionManager = PIXI.InteractionManager; - var Rectangle = PIXI.Rectangle; - - it('Module exists', function () { - expect(Stage).to.be.a('function'); - }); - - it('Confirm new instance', function () { - var obj = new Stage(null, true); - - pixi_display_DisplayObjectContainer_confirmNew(obj); - - expect(obj).to.be.an.instanceof(Stage); - expect(obj).to.respondTo('updateTransform'); - expect(obj).to.respondTo('setBackgroundColor'); - expect(obj).to.respondTo('getMousePosition'); - // FIXME: duplicate member in DisplayObject - pixi_core_Matrix_confirmNewMatrix(obj.worldTransform); - // FIXME: convert arg to bool in constructor - expect(obj).to.have.property('interactive', true); - - expect(obj).to.have.property('interactionManager') - .and.to.be.an.instanceof(InteractionManager) - .and.to.have.property('stage', obj); - - expect(obj).to.have.property('dirty', true); - - expect(obj).to.have.property('stage', obj); - - expect(obj).to.have.property('hitArea') - .and.to.be.an.instanceof(Rectangle); - pixi_core_Rectangle_confirm(obj.hitArea, 0, 0, 100000, 100000); - - expect(obj).to.have.property('backgroundColor', 0x000000); - expect(obj).to.have.deep.property('backgroundColorSplit.length', 3); - expect(obj).to.have.deep.property('backgroundColorSplit[0]', 0); - expect(obj).to.have.deep.property('backgroundColorSplit[1]', 0); - expect(obj).to.have.deep.property('backgroundColorSplit[2]', 0); - expect(obj).to.have.property('backgroundColorString', '#000000'); - - - expect(obj).to.have.property('worldVisible', true); - }); -}); diff --git a/test/unit/pixi/extras/Rope.js b/test/unit/pixi/extras/Rope.js deleted file mode 100644 index 05885ac..0000000 --- a/test/unit/pixi/extras/Rope.js +++ /dev/null @@ -1,31 +0,0 @@ -describe('pixi/extras/Rope', function () { - 'use strict'; - - var expect = chai.expect; - var Rope = PIXI.Rope; - var Texture = PIXI.Texture; - var Point = PIXI.Point; - - it('Module exists', function () { - expect(Rope).to.be.a('function'); - }); - - it('Confirm new instance', function () { - - var texture = Texture.fromImage('/base/test/textures/bunny.png'); - - // TODO-Alvin - // Same as Strip - - // var obj = new Rope(texture, [new Point(), new Point(5, 10), new Point(10, 20)]); - - // pixi_extras_Strip_confirmNew(obj); - - // expect(obj).to.be.an.instanceof(Rope); - // expect(obj).to.respondTo('refresh'); - // expect(obj).to.respondTo('updateTransform'); - // expect(obj).to.respondTo('setTexture'); - - // TODO: Test properties - }); -}); diff --git a/test/unit/pixi/extras/Spine.js b/test/unit/pixi/extras/Spine.js deleted file mode 100644 index 0708bc0..0000000 --- a/test/unit/pixi/extras/Spine.js +++ /dev/null @@ -1,10 +0,0 @@ -describe('pixi/extras/Spine', function () { - 'use strict'; - - var expect = chai.expect; - var Spine = PIXI.Spine; - - it('Module exists', function () { - expect(Spine).to.be.a('function'); - }); -}); diff --git a/test/unit/pixi/extras/Strip.js b/test/unit/pixi/extras/Strip.js deleted file mode 100644 index 230af90..0000000 --- a/test/unit/pixi/extras/Strip.js +++ /dev/null @@ -1,26 +0,0 @@ -describe('pixi/extras/Strip', function () { - 'use strict'; - - var expect = chai.expect; - var Strip = PIXI.Strip; - var Texture = PIXI.Texture; - - it('Module exists', function () { - expect(Strip).to.be.a('function'); - }); - - it('Confirm new instance', function () { - - - // TODO-Alvin - // We tweaked it to make it pass the tests, but the whole strip class needs - // to be re-coded - - var texture = Texture.fromImage('/base/test/textures/bunny.png'); - - // var obj = new Strip(texture, 20, 10000); - - - // pixi_extras_Strip_confirmNew(obj); - }); -}); diff --git a/test/unit/pixi/extras/TilingSprite.js b/test/unit/pixi/extras/TilingSprite.js deleted file mode 100644 index 56aea14..0000000 --- a/test/unit/pixi/extras/TilingSprite.js +++ /dev/null @@ -1,24 +0,0 @@ -describe('pixi/extras/TilingSprite', function () { - 'use strict'; - - var expect = chai.expect; - var TilingSprite = PIXI.TilingSprite; - var Texture = PIXI.Texture; - - it('Module exists', function () { - expect(TilingSprite).to.be.a('function'); - }); - - it('Confirm new instance', function () { - var texture = Texture.fromImage('/base/test/textures/bunny.png'); - var obj = new TilingSprite(texture, 6000, 12000); - - pixi_display_DisplayObjectContainer_confirmNew(obj); - - expect(obj).to.be.an.instanceof(TilingSprite); - expect(obj).to.respondTo('setTexture'); - expect(obj).to.respondTo('onTextureUpdate'); - - // TODO: Test properties - }); -}); diff --git a/test/unit/pixi/filters/FilterBlock.js b/test/unit/pixi/filters/FilterBlock.js deleted file mode 100644 index 870cec0..0000000 --- a/test/unit/pixi/filters/FilterBlock.js +++ /dev/null @@ -1,10 +0,0 @@ -describe('pixi/filters/FilterBlock', function () { - 'use strict'; - - var expect = chai.expect; - var FilterBlock = PIXI.FilterBlock; - - it('Module exists', function () { - expect(FilterBlock).to.be.a('function'); - }); -}); diff --git a/test/unit/pixi/loaders/AssetLoader.js b/test/unit/pixi/loaders/AssetLoader.js deleted file mode 100644 index a0aa0b5..0000000 --- a/test/unit/pixi/loaders/AssetLoader.js +++ /dev/null @@ -1,10 +0,0 @@ -describe('pixi/loaders/AssetLoader', function () { - 'use strict'; - - var expect = chai.expect; - var AssetLoader = PIXI.AssetLoader; - - it('Module exists', function () { - expect(AssetLoader).to.be.a('function'); - }); -}); diff --git a/test/unit/pixi/loaders/BitmapFontLoader.js b/test/unit/pixi/loaders/BitmapFontLoader.js deleted file mode 100644 index 046f018..0000000 --- a/test/unit/pixi/loaders/BitmapFontLoader.js +++ /dev/null @@ -1,9 +0,0 @@ -describe('pixi/loaders/BitmapFontLoader', function () { - 'use strict'; - - var expect = chai.expect; - - it('Module exists', function () { - expect(PIXI.BitmapFontLoader).to.be.a('function'); - }); -}); diff --git a/test/unit/pixi/loaders/ImageLoader.js b/test/unit/pixi/loaders/ImageLoader.js deleted file mode 100644 index 8b1f556..0000000 --- a/test/unit/pixi/loaders/ImageLoader.js +++ /dev/null @@ -1,10 +0,0 @@ -describe('pixi/loaders/ImageLoader', function () { - 'use strict'; - - var expect = chai.expect; - var ImageLoader = PIXI.ImageLoader; - - it('Module exists', function () { - expect(ImageLoader).to.be.a('function'); - }); -}); diff --git a/test/unit/pixi/loaders/JsonLoader.js b/test/unit/pixi/loaders/JsonLoader.js deleted file mode 100644 index c577e83..0000000 --- a/test/unit/pixi/loaders/JsonLoader.js +++ /dev/null @@ -1,10 +0,0 @@ -describe('pixi/loaders/JsonLoader', function () { - 'use strict'; - - var expect = chai.expect; - var JsonLoader = PIXI.JsonLoader; - - it('Module exists', function () { - expect(JsonLoader).to.be.a('function'); - }); -}); diff --git a/test/unit/pixi/loaders/SpineLoader.js b/test/unit/pixi/loaders/SpineLoader.js deleted file mode 100644 index fdcc0b8..0000000 --- a/test/unit/pixi/loaders/SpineLoader.js +++ /dev/null @@ -1,10 +0,0 @@ -describe('pixi/loaders/SpineLoader', function () { - 'use strict'; - - var expect = chai.expect; - var SpineLoader = PIXI.SpineLoader; - - it('Module exists', function () { - expect(SpineLoader).to.be.a('function'); - }); -}); diff --git a/test/unit/pixi/loaders/SpriteSheetLoader.js b/test/unit/pixi/loaders/SpriteSheetLoader.js deleted file mode 100644 index 57beb27..0000000 --- a/test/unit/pixi/loaders/SpriteSheetLoader.js +++ /dev/null @@ -1,10 +0,0 @@ -describe('pixi/loaders/SpriteSheetLoader', function () { - 'use strict'; - - var expect = chai.expect; - var SpriteSheetLoader = PIXI.SpriteSheetLoader; - - it('Module exists', function () { - expect(SpriteSheetLoader).to.be.a('function'); - }); -}); diff --git a/test/unit/pixi/primitives/Graphics.js b/test/unit/pixi/primitives/Graphics.js deleted file mode 100644 index f3849eb..0000000 --- a/test/unit/pixi/primitives/Graphics.js +++ /dev/null @@ -1,44 +0,0 @@ -describe('pixi/primitives/Graphics', function () { - 'use strict'; - - var expect = chai.expect; - var Graphics = PIXI.Graphics; - - it('Module exists', function () { - expect(Graphics).to.be.a('function'); - - expect(Graphics).itself.to.have.property('POLY', 0); - expect(Graphics).itself.to.have.property('RECT', 1); - expect(Graphics).itself.to.have.property('CIRC', 2); - expect(Graphics).itself.to.have.property('ELIP', 3); - expect(Graphics).itself.to.have.property('RREC', 4); - }); - - it('Confirm new instance', function () { - var obj = new Graphics(); - - pixi_display_DisplayObjectContainer_confirmNew(obj); - - expect(obj).to.be.an.instanceof(Graphics); - expect(obj).to.respondTo('lineStyle'); - expect(obj).to.respondTo('lineStyle'); - expect(obj).to.respondTo('moveTo'); - expect(obj).to.respondTo('lineTo'); - expect(obj).to.respondTo('beginFill'); - expect(obj).to.respondTo('endFill'); - expect(obj).to.respondTo('drawRect'); - // expect(obj).to.respondTo('drawRoundedRect'); - expect(obj).to.respondTo('drawCircle'); - expect(obj).to.respondTo('drawEllipse'); - expect(obj).to.respondTo('clear'); - - expect(obj).to.have.property('renderable', true); - expect(obj).to.have.property('fillAlpha', 1); - expect(obj).to.have.property('lineWidth', 0); - expect(obj).to.have.property('width', 0); - expect(obj).to.have.property('height', 0); - expect(obj).to.have.property('lineColor', 0); - expect(obj).to.have.deep.property('graphicsData.length', 0); - // expect(obj).to.have.deep.property('currentPath.points.length', 0); - }); -}); diff --git a/test/unit/pixi-v2/InteractionManager.js b/test/unit/pixi-v2/InteractionManager.js new file mode 100644 index 0000000..ed3001f --- /dev/null +++ b/test/unit/pixi-v2/InteractionManager.js @@ -0,0 +1,10 @@ +describe('pixi/InteractionManager', function () { + 'use strict'; + + var expect = chai.expect; + var InteractionManager = PIXI.InteractionManager; + + it('Module exists', function () { + expect(InteractionManager).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/Pixi.js b/test/unit/pixi-v2/Pixi.js new file mode 100644 index 0000000..27debc1 --- /dev/null +++ b/test/unit/pixi-v2/Pixi.js @@ -0,0 +1,9 @@ +describe('pixi/Pixi', function () { + 'use strict'; + + var expect = chai.expect; + + it('Module exists', function () { + expect(global).to.have.property('PIXI').and.to.be.an('object'); + }); +}); diff --git a/test/unit/pixi-v2/core/Circle.js b/test/unit/pixi-v2/core/Circle.js new file mode 100644 index 0000000..fbcfa17 --- /dev/null +++ b/test/unit/pixi-v2/core/Circle.js @@ -0,0 +1,21 @@ +describe('pixi/core/Circle', function () { + 'use strict'; + + var expect = chai.expect; + var Circle = PIXI.Circle; + + it('Module exists', function () { + expect(Circle).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Circle(); + pixi_core_Circle_confirmNewCircle(obj); + }); + + it("getBounds should return Rectangle that bounds the circle", function() { + var obj = new Circle(100, 250, 50); + var bounds = obj.getBounds(); + pixi_core_Circle_isBoundedByRectangle(obj, bounds); + }); +}); diff --git a/test/unit/pixi-v2/core/Ellipse.js b/test/unit/pixi-v2/core/Ellipse.js new file mode 100644 index 0000000..026b56f --- /dev/null +++ b/test/unit/pixi-v2/core/Ellipse.js @@ -0,0 +1,24 @@ +describe('pixi/core/Ellipse', function () { + 'use strict'; + + var expect = chai.expect; + var Ellipse = PIXI.Ellipse; + + it('Module exists', function () { + expect(Ellipse).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Ellipse(); + + expect(obj).to.be.an.instanceof(Ellipse); + expect(obj).to.respondTo('clone'); + expect(obj).to.respondTo('contains'); + expect(obj).to.respondTo('getBounds'); + + expect(obj).to.have.property('x', 0); + expect(obj).to.have.property('y', 0); + expect(obj).to.have.property('width', 0); + expect(obj).to.have.property('height', 0); + }); +}); diff --git a/test/unit/pixi-v2/core/Matrix.js b/test/unit/pixi-v2/core/Matrix.js new file mode 100644 index 0000000..da75e2e --- /dev/null +++ b/test/unit/pixi-v2/core/Matrix.js @@ -0,0 +1,14 @@ +describe('pixi/core/Matrix', function () { + 'use strict'; + + var expect = chai.expect; + + it('Matrix exists', function () { + expect(PIXI.Matrix).to.be.an('function'); + }); + + it('Confirm new Matrix', function () { + var matrix = new PIXI.Matrix(); + pixi_core_Matrix_confirmNewMatrix(matrix); + }); +}); diff --git a/test/unit/pixi-v2/core/Point.js b/test/unit/pixi-v2/core/Point.js new file mode 100644 index 0000000..c4d5163 --- /dev/null +++ b/test/unit/pixi-v2/core/Point.js @@ -0,0 +1,15 @@ +describe('pixi/core/Point', function () { + 'use strict'; + + var expect = chai.expect; + var Point = PIXI.Point; + + it('Module exists', function () { + expect(Point).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Point(); + pixi_core_Point_confirm(obj, 0, 0); + }); +}); diff --git a/test/unit/pixi-v2/core/Polygon.js b/test/unit/pixi-v2/core/Polygon.js new file mode 100644 index 0000000..dc8c918 --- /dev/null +++ b/test/unit/pixi-v2/core/Polygon.js @@ -0,0 +1,20 @@ +describe('pixi/core/Polygon', function () { + 'use strict'; + + var expect = chai.expect; + var Polygon = PIXI.Polygon; + + it('Module exists', function () { + expect(Polygon).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Polygon(); + + expect(obj).to.be.an.instanceof(Polygon); + expect(obj).to.respondTo('clone'); + expect(obj).to.respondTo('contains'); + + expect(obj).to.have.deep.property('points.length', 0); + }); +}); diff --git a/test/unit/pixi-v2/core/Rectangle.js b/test/unit/pixi-v2/core/Rectangle.js new file mode 100644 index 0000000..d43316e --- /dev/null +++ b/test/unit/pixi-v2/core/Rectangle.js @@ -0,0 +1,15 @@ +describe('pixi/core/Rectangle', function () { + 'use strict'; + + var expect = chai.expect; + var Rectangle = PIXI.Rectangle; + + it('Module exists', function () { + expect(Rectangle).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var rect = new Rectangle(); + pixi_core_Rectangle_confirm(rect, 0, 0, 0, 0); + }); +}); diff --git a/test/unit/pixi-v2/display/DisplayObject.js b/test/unit/pixi-v2/display/DisplayObject.js new file mode 100644 index 0000000..044acf8 --- /dev/null +++ b/test/unit/pixi-v2/display/DisplayObject.js @@ -0,0 +1,21 @@ +describe('pixi/display/DisplayObject', function () { + 'use strict'; + + var expect = chai.expect; + var DisplayObject = PIXI.DisplayObject; + + it('Module exists', function () { + expect(DisplayObject).to.be.a('function'); + // expect(PIXI).to.have.property('visibleCount', 0); + }); + + it('Confirm new instance', function () { + var obj = new DisplayObject(); + + pixi_display_DisplayObject_confirmNew(obj); + expect(obj).to.have.property('hitArea', null); + expect(obj).to.have.property('interactive', false); + expect(obj).to.have.property('renderable', false); + expect(obj).to.have.property('stage', null); + }); +}); diff --git a/test/unit/pixi-v2/display/DisplayObjectContainer.js b/test/unit/pixi-v2/display/DisplayObjectContainer.js new file mode 100644 index 0000000..15a3376 --- /dev/null +++ b/test/unit/pixi-v2/display/DisplayObjectContainer.js @@ -0,0 +1,67 @@ +describe('pixi/display/DisplayObjectContainer', function () { + 'use strict'; + + var expect = chai.expect; + var DisplayObjectContainer = PIXI.DisplayObjectContainer; + + it('Module exists', function () { + expect(DisplayObjectContainer).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new DisplayObjectContainer(); + + pixi_display_DisplayObjectContainer_confirmNew(obj); + expect(obj).to.have.property('hitArea', null); + expect(obj).to.have.property('interactive', false); + expect(obj).to.have.property('renderable', false); + expect(obj).to.have.property('stage', null); + }); + + it('Gets child index', function() { + var container = new PIXI.DisplayObjectContainer(); + var children = []; + for (var i = 0; i < 10; i++) { + var child = new PIXI.DisplayObject(); + children.push(child); + container.addChild(child); + } + + for (i = 0; i < children.length; i++) { + expect(i).to.eql(container.getChildIndex(children[i])); + } + }); + + it('throws error when trying to get index of not a child', function() { + var container = new PIXI.DisplayObjectContainer(); + var child = new PIXI.DisplayObject(); + + expect(function() { container.getChildIndex(child); }).to.throw(); + }); + + it('Sets child index', function() { + var container = new PIXI.DisplayObjectContainer(); + var children = []; + + for (var i = 0; i < 10; i++) { + var child = new PIXI.DisplayObject(); + children.push(child); + container.addChild(child); + } + children.reverse(); + + for (i = 0; i < children.length; i++) { + container.setChildIndex(children[i], i); + expect(i).to.eql(container.getChildIndex(children[i])); + } + }); + + it('throws error when trying to set incorect index', function() { + var container = new PIXI.DisplayObjectContainer(); + var child = new PIXI.DisplayObject(); + container.addChild(child); + + expect(function() { container.setChildIndex(child, -1); }).to.throw(); + expect(function() { container.setChildIndex(child, 1); }).to.throw(); + }); +}); diff --git a/test/unit/pixi-v2/display/MovieClip.js b/test/unit/pixi-v2/display/MovieClip.js new file mode 100644 index 0000000..f3c6c6a --- /dev/null +++ b/test/unit/pixi-v2/display/MovieClip.js @@ -0,0 +1,33 @@ +describe('pixi/display/MovieClip', function () { + 'use strict'; + + var expect = chai.expect; + var MovieClip = PIXI.MovieClip; + var Texture = PIXI.Texture; + + it('Module exists', function () { + expect(MovieClip).to.be.a('function'); + }); + + it('Confirm new instance', function (done) { + var texture = Texture.fromImage('/base/test/textures/SpriteSheet-Explosion.png'); + var obj = new MovieClip([texture]); + + pixi_display_Sprite_confirmNew(obj, done); + + expect(obj).to.be.an.instanceof(MovieClip); + expect(obj).to.respondTo('stop'); + expect(obj).to.respondTo('play'); + expect(obj).to.respondTo('gotoAndStop'); + expect(obj).to.respondTo('gotoAndPlay'); + expect(obj).to.respondTo('updateTransform'); + + expect(obj).to.have.deep.property('textures.length', 1); + expect(obj).to.have.deep.property('textures[0]', texture); + expect(obj).to.have.property('animationSpeed', 1); + expect(obj).to.have.property('loop', true); + expect(obj).to.have.property('onComplete', null); + expect(obj).to.have.property('currentFrame', 0); + expect(obj).to.have.property('playing', false); + }); +}); diff --git a/test/unit/pixi-v2/display/Sprite.js b/test/unit/pixi-v2/display/Sprite.js new file mode 100644 index 0000000..30c8076 --- /dev/null +++ b/test/unit/pixi-v2/display/Sprite.js @@ -0,0 +1,28 @@ +describe('pixi/display/Sprite', function () { + 'use strict'; + + var expect = chai.expect; + var Sprite = PIXI.Sprite; + var Texture = PIXI.Texture; + + it('Module exists', function () { + expect(Sprite).to.be.a('function'); + expect(PIXI).to.have.deep.property('blendModes.NORMAL', 0); + expect(PIXI).to.have.deep.property('blendModes.ADD', 1); + expect(PIXI).to.have.deep.property('blendModes.MULTIPLY', 2); + expect(PIXI).to.have.deep.property('blendModes.SCREEN', 3); + }); + + + it('Members exist', function () { + expect(Sprite).itself.to.respondTo('fromImage'); + expect(Sprite).itself.to.respondTo('fromFrame'); + }); + + it('Confirm new instance', function (done) { + var texture = Texture.fromImage('/base/test/textures/SpriteSheet-Aliens.png'); + var obj = new Sprite(texture); + + pixi_display_Sprite_confirmNew(obj, done); + }); +}); diff --git a/test/unit/pixi-v2/display/Stage.js b/test/unit/pixi-v2/display/Stage.js new file mode 100644 index 0000000..6974c2e --- /dev/null +++ b/test/unit/pixi-v2/display/Stage.js @@ -0,0 +1,49 @@ +describe('pixi/display/Stage', function () { + 'use strict'; + + var expect = chai.expect; + var Stage = PIXI.Stage; + var InteractionManager = PIXI.InteractionManager; + var Rectangle = PIXI.Rectangle; + + it('Module exists', function () { + expect(Stage).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Stage(null, true); + + pixi_display_DisplayObjectContainer_confirmNew(obj); + + expect(obj).to.be.an.instanceof(Stage); + expect(obj).to.respondTo('updateTransform'); + expect(obj).to.respondTo('setBackgroundColor'); + expect(obj).to.respondTo('getMousePosition'); + // FIXME: duplicate member in DisplayObject + pixi_core_Matrix_confirmNewMatrix(obj.worldTransform); + // FIXME: convert arg to bool in constructor + expect(obj).to.have.property('interactive', true); + + expect(obj).to.have.property('interactionManager') + .and.to.be.an.instanceof(InteractionManager) + .and.to.have.property('stage', obj); + + expect(obj).to.have.property('dirty', true); + + expect(obj).to.have.property('stage', obj); + + expect(obj).to.have.property('hitArea') + .and.to.be.an.instanceof(Rectangle); + pixi_core_Rectangle_confirm(obj.hitArea, 0, 0, 100000, 100000); + + expect(obj).to.have.property('backgroundColor', 0x000000); + expect(obj).to.have.deep.property('backgroundColorSplit.length', 3); + expect(obj).to.have.deep.property('backgroundColorSplit[0]', 0); + expect(obj).to.have.deep.property('backgroundColorSplit[1]', 0); + expect(obj).to.have.deep.property('backgroundColorSplit[2]', 0); + expect(obj).to.have.property('backgroundColorString', '#000000'); + + + expect(obj).to.have.property('worldVisible', true); + }); +}); diff --git a/test/unit/pixi-v2/extras/Rope.js b/test/unit/pixi-v2/extras/Rope.js new file mode 100644 index 0000000..05885ac --- /dev/null +++ b/test/unit/pixi-v2/extras/Rope.js @@ -0,0 +1,31 @@ +describe('pixi/extras/Rope', function () { + 'use strict'; + + var expect = chai.expect; + var Rope = PIXI.Rope; + var Texture = PIXI.Texture; + var Point = PIXI.Point; + + it('Module exists', function () { + expect(Rope).to.be.a('function'); + }); + + it('Confirm new instance', function () { + + var texture = Texture.fromImage('/base/test/textures/bunny.png'); + + // TODO-Alvin + // Same as Strip + + // var obj = new Rope(texture, [new Point(), new Point(5, 10), new Point(10, 20)]); + + // pixi_extras_Strip_confirmNew(obj); + + // expect(obj).to.be.an.instanceof(Rope); + // expect(obj).to.respondTo('refresh'); + // expect(obj).to.respondTo('updateTransform'); + // expect(obj).to.respondTo('setTexture'); + + // TODO: Test properties + }); +}); diff --git a/test/unit/pixi-v2/extras/Spine.js b/test/unit/pixi-v2/extras/Spine.js new file mode 100644 index 0000000..0708bc0 --- /dev/null +++ b/test/unit/pixi-v2/extras/Spine.js @@ -0,0 +1,10 @@ +describe('pixi/extras/Spine', function () { + 'use strict'; + + var expect = chai.expect; + var Spine = PIXI.Spine; + + it('Module exists', function () { + expect(Spine).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/extras/Strip.js b/test/unit/pixi-v2/extras/Strip.js new file mode 100644 index 0000000..230af90 --- /dev/null +++ b/test/unit/pixi-v2/extras/Strip.js @@ -0,0 +1,26 @@ +describe('pixi/extras/Strip', function () { + 'use strict'; + + var expect = chai.expect; + var Strip = PIXI.Strip; + var Texture = PIXI.Texture; + + it('Module exists', function () { + expect(Strip).to.be.a('function'); + }); + + it('Confirm new instance', function () { + + + // TODO-Alvin + // We tweaked it to make it pass the tests, but the whole strip class needs + // to be re-coded + + var texture = Texture.fromImage('/base/test/textures/bunny.png'); + + // var obj = new Strip(texture, 20, 10000); + + + // pixi_extras_Strip_confirmNew(obj); + }); +}); diff --git a/test/unit/pixi-v2/extras/TilingSprite.js b/test/unit/pixi-v2/extras/TilingSprite.js new file mode 100644 index 0000000..56aea14 --- /dev/null +++ b/test/unit/pixi-v2/extras/TilingSprite.js @@ -0,0 +1,24 @@ +describe('pixi/extras/TilingSprite', function () { + 'use strict'; + + var expect = chai.expect; + var TilingSprite = PIXI.TilingSprite; + var Texture = PIXI.Texture; + + it('Module exists', function () { + expect(TilingSprite).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var texture = Texture.fromImage('/base/test/textures/bunny.png'); + var obj = new TilingSprite(texture, 6000, 12000); + + pixi_display_DisplayObjectContainer_confirmNew(obj); + + expect(obj).to.be.an.instanceof(TilingSprite); + expect(obj).to.respondTo('setTexture'); + expect(obj).to.respondTo('onTextureUpdate'); + + // TODO: Test properties + }); +}); diff --git a/test/unit/pixi-v2/filters/FilterBlock.js b/test/unit/pixi-v2/filters/FilterBlock.js new file mode 100644 index 0000000..870cec0 --- /dev/null +++ b/test/unit/pixi-v2/filters/FilterBlock.js @@ -0,0 +1,10 @@ +describe('pixi/filters/FilterBlock', function () { + 'use strict'; + + var expect = chai.expect; + var FilterBlock = PIXI.FilterBlock; + + it('Module exists', function () { + expect(FilterBlock).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/AssetLoader.js b/test/unit/pixi-v2/loaders/AssetLoader.js new file mode 100644 index 0000000..a0aa0b5 --- /dev/null +++ b/test/unit/pixi-v2/loaders/AssetLoader.js @@ -0,0 +1,10 @@ +describe('pixi/loaders/AssetLoader', function () { + 'use strict'; + + var expect = chai.expect; + var AssetLoader = PIXI.AssetLoader; + + it('Module exists', function () { + expect(AssetLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/BitmapFontLoader.js b/test/unit/pixi-v2/loaders/BitmapFontLoader.js new file mode 100644 index 0000000..046f018 --- /dev/null +++ b/test/unit/pixi-v2/loaders/BitmapFontLoader.js @@ -0,0 +1,9 @@ +describe('pixi/loaders/BitmapFontLoader', function () { + 'use strict'; + + var expect = chai.expect; + + it('Module exists', function () { + expect(PIXI.BitmapFontLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/ImageLoader.js b/test/unit/pixi-v2/loaders/ImageLoader.js new file mode 100644 index 0000000..8b1f556 --- /dev/null +++ b/test/unit/pixi-v2/loaders/ImageLoader.js @@ -0,0 +1,10 @@ +describe('pixi/loaders/ImageLoader', function () { + 'use strict'; + + var expect = chai.expect; + var ImageLoader = PIXI.ImageLoader; + + it('Module exists', function () { + expect(ImageLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/JsonLoader.js b/test/unit/pixi-v2/loaders/JsonLoader.js new file mode 100644 index 0000000..c577e83 --- /dev/null +++ b/test/unit/pixi-v2/loaders/JsonLoader.js @@ -0,0 +1,10 @@ +describe('pixi/loaders/JsonLoader', function () { + 'use strict'; + + var expect = chai.expect; + var JsonLoader = PIXI.JsonLoader; + + it('Module exists', function () { + expect(JsonLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/SpineLoader.js b/test/unit/pixi-v2/loaders/SpineLoader.js new file mode 100644 index 0000000..fdcc0b8 --- /dev/null +++ b/test/unit/pixi-v2/loaders/SpineLoader.js @@ -0,0 +1,10 @@ +describe('pixi/loaders/SpineLoader', function () { + 'use strict'; + + var expect = chai.expect; + var SpineLoader = PIXI.SpineLoader; + + it('Module exists', function () { + expect(SpineLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/SpriteSheetLoader.js b/test/unit/pixi-v2/loaders/SpriteSheetLoader.js new file mode 100644 index 0000000..57beb27 --- /dev/null +++ b/test/unit/pixi-v2/loaders/SpriteSheetLoader.js @@ -0,0 +1,10 @@ +describe('pixi/loaders/SpriteSheetLoader', function () { + 'use strict'; + + var expect = chai.expect; + var SpriteSheetLoader = PIXI.SpriteSheetLoader; + + it('Module exists', function () { + expect(SpriteSheetLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/primitives/Graphics.js b/test/unit/pixi-v2/primitives/Graphics.js new file mode 100644 index 0000000..f3849eb --- /dev/null +++ b/test/unit/pixi-v2/primitives/Graphics.js @@ -0,0 +1,44 @@ +describe('pixi/primitives/Graphics', function () { + 'use strict'; + + var expect = chai.expect; + var Graphics = PIXI.Graphics; + + it('Module exists', function () { + expect(Graphics).to.be.a('function'); + + expect(Graphics).itself.to.have.property('POLY', 0); + expect(Graphics).itself.to.have.property('RECT', 1); + expect(Graphics).itself.to.have.property('CIRC', 2); + expect(Graphics).itself.to.have.property('ELIP', 3); + expect(Graphics).itself.to.have.property('RREC', 4); + }); + + it('Confirm new instance', function () { + var obj = new Graphics(); + + pixi_display_DisplayObjectContainer_confirmNew(obj); + + expect(obj).to.be.an.instanceof(Graphics); + expect(obj).to.respondTo('lineStyle'); + expect(obj).to.respondTo('lineStyle'); + expect(obj).to.respondTo('moveTo'); + expect(obj).to.respondTo('lineTo'); + expect(obj).to.respondTo('beginFill'); + expect(obj).to.respondTo('endFill'); + expect(obj).to.respondTo('drawRect'); + // expect(obj).to.respondTo('drawRoundedRect'); + expect(obj).to.respondTo('drawCircle'); + expect(obj).to.respondTo('drawEllipse'); + expect(obj).to.respondTo('clear'); + + expect(obj).to.have.property('renderable', true); + expect(obj).to.have.property('fillAlpha', 1); + expect(obj).to.have.property('lineWidth', 0); + expect(obj).to.have.property('width', 0); + expect(obj).to.have.property('height', 0); + expect(obj).to.have.property('lineColor', 0); + expect(obj).to.have.deep.property('graphicsData.length', 0); + // expect(obj).to.have.deep.property('currentPath.points.length', 0); + }); +}); diff --git a/test/unit/pixi-v2/renderers/canvas/CanvasGraphics.js b/test/unit/pixi-v2/renderers/canvas/CanvasGraphics.js new file mode 100644 index 0000000..8f44472 --- /dev/null +++ b/test/unit/pixi-v2/renderers/canvas/CanvasGraphics.js @@ -0,0 +1,15 @@ +describe('renders/canvas/CanvasGraphics', function () { + 'use strict'; + + var expect = chai.expect; + var CanvasGraphics = PIXI.CanvasGraphics; + + it('Module exists', function () { + expect(CanvasGraphics).to.be.a('function'); + }); + + it('Members exist', function () { + expect(CanvasGraphics).itself.to.respondTo('renderGraphics'); + expect(CanvasGraphics).itself.to.respondTo('renderGraphicsMask'); + }); +}); diff --git a/test/unit/pixi-v2/renderers/canvas/CanvasRenderer.js b/test/unit/pixi-v2/renderers/canvas/CanvasRenderer.js new file mode 100644 index 0000000..1646444 --- /dev/null +++ b/test/unit/pixi-v2/renderers/canvas/CanvasRenderer.js @@ -0,0 +1,36 @@ +describe('renderers/canvas/CanvasRenderer', function () { + 'use strict'; + + var expect = chai.expect; + var CanvasRenderer = PIXI.CanvasRenderer; + + it('Module exists', function () { + expect(CanvasRenderer).to.be.a('function'); + }); + + describe('.autoResize', function () { + it('Should automatically resize view if enabled', function () { + var renderer = new CanvasRenderer(200, 200, { + autoResize: true + }); + + expect(renderer.view.style.width).to.equal('200px'); + }); + + it('Should not automatically resize view if disabled', function () { + var renderer = new CanvasRenderer(200, 200, { + autoResize: false + }); + + expect(renderer.view.style.width).to.equal(''); + }); + + it('Should not automatically resize view if not specified', function () { + var renderer = new CanvasRenderer(200, 200, { + resolution: 2 + }); + + expect(renderer.view.style.width).to.equal(''); + }); + }); +}); diff --git a/test/unit/pixi-v2/renderers/webgl/WebGLGraphics.js b/test/unit/pixi-v2/renderers/webgl/WebGLGraphics.js new file mode 100644 index 0000000..5867b28 --- /dev/null +++ b/test/unit/pixi-v2/renderers/webgl/WebGLGraphics.js @@ -0,0 +1,20 @@ +describe('renderers/wegbl/WebGLGraphics', function () { + 'use strict'; + + var expect = chai.expect; + var WebGLGraphics = PIXI.WebGLGraphics; + + it('Module exists', function () { + expect(WebGLGraphics).to.be.a('function'); + }); + + it('Members exist', function () { + expect(WebGLGraphics).itself.to.respondTo('renderGraphics'); + expect(WebGLGraphics).itself.to.respondTo('updateGraphics'); + expect(WebGLGraphics).itself.to.respondTo('buildRectangle'); + expect(WebGLGraphics).itself.to.respondTo('buildRoundedRectangle'); + expect(WebGLGraphics).itself.to.respondTo('buildCircle'); + expect(WebGLGraphics).itself.to.respondTo('buildLine'); + expect(WebGLGraphics).itself.to.respondTo('buildPoly'); + }); +}); diff --git a/test/unit/pixi-v2/renderers/webgl/WebGLRenderer.js b/test/unit/pixi-v2/renderers/webgl/WebGLRenderer.js new file mode 100644 index 0000000..1680a80 --- /dev/null +++ b/test/unit/pixi-v2/renderers/webgl/WebGLRenderer.js @@ -0,0 +1,49 @@ +describe('renderers/webgl/WebGLRenderer', function () { + 'use strict'; + + var expect = chai.expect; + var WebGLRenderer = PIXI.WebGLRenderer; + + it('Module exists', function () { + expect(WebGLRenderer).to.be.a('function'); + }); + + // Skip tests if WebGL is not available (WebGL not supported in Travis CI) + try { + var renderer = new WebGLRenderer(400, 300, {}); + renderer.destroy(); + } catch (error) { + return; + } + + it('Destroy renderer', function () { + var renderer = new WebGLRenderer(400, 300, {}); + renderer.destroy(); + }); + + describe('.autoResize', function () { + it('Should automatically resize view if enabled', function () { + var renderer = new WebGLRenderer(200, 200, { + autoResize: true + }); + + expect(renderer.view.style.width).to.equal('200px'); + }); + + it('Should not automatically resize view if disabled', function () { + var renderer = new WebGLRenderer(200, 200, { + autoResize: false + }); + + expect(renderer.view.style.width).to.equal(''); + }); + + it('Should not automatically resize view if not specified', function () { + var renderer = new WebGLRenderer(200, 200, { + resolution: 2 + }); + + expect(renderer.view.style.width).to.equal(''); + }); + }); +}); diff --git a/test/unit/pixi-v2/renderers/webgl/WebGLShaders.js b/test/unit/pixi-v2/renderers/webgl/WebGLShaders.js new file mode 100644 index 0000000..6e33e4f --- /dev/null +++ b/test/unit/pixi-v2/renderers/webgl/WebGLShaders.js @@ -0,0 +1,13 @@ +describe('renderers/webgl/WebGLShaders', function () { + 'use strict'; + + var expect = chai.expect; + + it('Module members exist', function () { + + expect(PIXI).to.respondTo('CompileVertexShader'); + expect(PIXI).to.respondTo('CompileFragmentShader'); + expect(PIXI).to.respondTo('_CompileShader'); + expect(PIXI).to.respondTo('compileProgram'); + }); +}); diff --git a/test/unit/pixi-v2/renderers/webgl/WebGLSpriteBatch.js b/test/unit/pixi-v2/renderers/webgl/WebGLSpriteBatch.js new file mode 100644 index 0000000..e662b63 --- /dev/null +++ b/test/unit/pixi-v2/renderers/webgl/WebGLSpriteBatch.js @@ -0,0 +1,10 @@ +describe('renderers/webgl/utils/WebGLSpriteBatch', function () { + 'use strict'; + + var expect = chai.expect; + var WebGLSpriteBatch = PIXI.WebGLSpriteBatch; + + it('Module exists', function () { + expect(WebGLSpriteBatch).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/text/BitmapText.js b/test/unit/pixi-v2/text/BitmapText.js new file mode 100644 index 0000000..9388e3d --- /dev/null +++ b/test/unit/pixi-v2/text/BitmapText.js @@ -0,0 +1,10 @@ +describe('pixi/text/BitmapText', function () { + 'use strict'; + + var expect = chai.expect; + var BitmapText = PIXI.BitmapText; + + it('Module exists', function () { + expect(BitmapText).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/text/Text.js b/test/unit/pixi-v2/text/Text.js new file mode 100644 index 0000000..9bc9ac5 --- /dev/null +++ b/test/unit/pixi-v2/text/Text.js @@ -0,0 +1,10 @@ +describe('pixi/text/Text', function () { + 'use strict'; + + var expect = chai.expect; + var Text = PIXI.Text; + + it('Module exists', function () { + expect(Text).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/textures/BaseTexture.js b/test/unit/pixi-v2/textures/BaseTexture.js new file mode 100644 index 0000000..502b724 --- /dev/null +++ b/test/unit/pixi-v2/textures/BaseTexture.js @@ -0,0 +1,11 @@ +describe('pixi/textures/BaseTexture', function () { + 'use strict'; + + var expect = chai.expect; + var BaseTexture = PIXI.BaseTexture; + + it('Module exists', function () { + expect(BaseTexture).to.be.a('function'); + expect(PIXI).to.have.property('BaseTextureCache').and.to.be.an('object'); + }); +}); diff --git a/test/unit/pixi-v2/textures/RenderTexture.js b/test/unit/pixi-v2/textures/RenderTexture.js new file mode 100644 index 0000000..96acdb4 --- /dev/null +++ b/test/unit/pixi-v2/textures/RenderTexture.js @@ -0,0 +1,15 @@ +describe('pixi/textures/RenderTexture', function () { + 'use strict'; + + var expect = chai.expect; + var RenderTexture = PIXI.RenderTexture; + + it('Module exists', function () { + expect(RenderTexture).to.be.a('function'); + }); + + it('Confirm new instance', function (done) { + var texture = new RenderTexture(100, 100, new PIXI.CanvasRenderer()); + pixi_textures_RenderTexture_confirmNew(texture, done); + }); +}); diff --git a/test/unit/pixi-v2/textures/Texture.js b/test/unit/pixi-v2/textures/Texture.js new file mode 100644 index 0000000..090f64d --- /dev/null +++ b/test/unit/pixi-v2/textures/Texture.js @@ -0,0 +1,26 @@ +describe('pixi/textures/Texture', function () { + 'use strict'; + + var expect = chai.expect; + var Texture = PIXI.Texture; + + it('Module exists', function () { + expect(Texture).to.be.a('function'); + expect(PIXI).to.have.property('TextureCache').and.to.be.an('object'); + }); + + it('Members exist', function () { + expect(Texture).itself.to.respondTo('fromImage'); + expect(Texture).itself.to.respondTo('fromFrame'); + expect(Texture).itself.to.respondTo('fromCanvas'); + expect(Texture).itself.to.respondTo('addTextureToCache'); + expect(Texture).itself.to.respondTo('removeTextureFromCache'); + + // expect(Texture).itself.to.have.deep.property('frameUpdates.length', 0); + }); + + it('Confirm new instance', function (done) { + var texture = Texture.fromImage('/base/test/textures/bunny.png'); + pixi_textures_Texture_confirmNew(texture, done); + }); +}); diff --git a/test/unit/pixi-v2/utils/Detector.js b/test/unit/pixi-v2/utils/Detector.js new file mode 100644 index 0000000..4cf6008 --- /dev/null +++ b/test/unit/pixi-v2/utils/Detector.js @@ -0,0 +1,10 @@ +describe('pixi/utils/Detector', function () { + 'use strict'; + + var expect = chai.expect; + var autoDetectRenderer = PIXI.autoDetectRenderer; + + it('Module exists', function () { + expect(autoDetectRenderer).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/utils/EventTarget.js b/test/unit/pixi-v2/utils/EventTarget.js new file mode 100644 index 0000000..1cfc3a4 --- /dev/null +++ b/test/unit/pixi-v2/utils/EventTarget.js @@ -0,0 +1,361 @@ +describe('pixi/utils/EventTarget', function () { + 'use strict'; + + var expect = chai.expect; + + var Clazz, PClazz, obj, pobj, obj2; + beforeEach(function () { + Clazz = function () {}; + PClazz = function () {}; + + PIXI.EventTarget.mixin(Clazz.prototype); + PIXI.EventTarget.mixin(PClazz.prototype); + + obj = new Clazz(); + obj2 = new Clazz(); + pobj = new PClazz(); + + obj.parent = pobj; + obj2.parent = obj; + }); + + it('Module exists', function () { + expect(PIXI.EventTarget).to.be.an('object'); + }); + + it('Confirm new instance', function () { + pixi_utils_EventTarget_confirm(obj); + }); + + it('simple on/emit case works', function () { + var myData = {}; + + obj.on('myevent', function (event) { + pixi_utils_EventTarget_Event_confirm(event, obj, myData); + }); + + obj.emit('myevent', myData); + }); + + it('simple once case works', function () { + var called = 0; + + obj.once('myevent', function() { called++; }); + + obj.emit('myevent'); + obj.emit('myevent'); + obj.emit('myevent'); + obj.emit('myevent'); + obj.emit('myevent'); + + expect(called).to.equal(1); + }); + + it('simple off case works', function (done) { + function onMyEvent() { + done(new Error('Event listener should not have been called')); + } + + obj.on('myevent', onMyEvent); + obj.off('myevent', onMyEvent); + obj.emit('myevent'); + + done(); + }); + + it('simple propagation case works', function (done) { + var myData = {}; + + pobj.on('myevent', function () { + done(); + }); + + obj.emit('myevent'); + }); + + it('simple stopPropagation case works', function (done) { + var myData = {}; + + pobj.on('myevent', function () { + done(new Error('Event listener should not have been called on the parent element')); + }); + + obj.on('myevent', function (evt) { + evt.stopPropagation(); + }); + + obj.emit('myevent'); + + done(); + }); + + it('simple stopImmediatePropagation case works', function (done) { + var myData = {}; + + pobj.on('myevent', function () { + done(new Error('Event listener should not have been called on the parent')); + }); + + obj.on('myevent', function (evt) { + evt.stopImmediatePropagation(); + }); + + obj.on('myevent', function () { + done(new Error('Event listener should not have been called on the second')); + }); + + obj.emit('myevent'); + + done(); + }); + + it('multiple dispatches work properly', function () { + var called = 0; + + function onMyEvent() { + called++; + } + + obj.on('myevent', onMyEvent); + obj.emit('myevent'); + obj.emit('myevent'); + obj.emit('myevent'); + obj.emit('myevent'); + + expect(called).to.equal(4); + }); + + it('multiple events work properly', function () { + var called = 0; + + function onMyEvent() { + called++; + } + + obj.on('myevent1', onMyEvent); + obj.on('myevent2', onMyEvent); + obj.on('myevent3', onMyEvent); + obj.emit('myevent1'); + obj.emit('myevent2'); + obj.emit('myevent3'); + + expect(called).to.equal(3); + }); + + it('multiple events one removed works properly', function () { + var called = 0; + + function onMyEvent() { + called++; + } + + obj.on('myevent1', onMyEvent); + obj.on('myevent2', onMyEvent); + obj.on('myevent3', onMyEvent); + + obj.emit('myevent1'); + obj.emit('myevent2'); + obj.emit('myevent3'); + + obj.off('myevent2', onMyEvent); + + obj.emit('myevent1'); + obj.emit('myevent2'); + obj.emit('myevent3'); + + expect(called).to.equal(5); + }); + + it('multiple handlers for one event with some removed', function () { + var called = 0; + + var onMyEvent = function () { + called++; + }, + onMyEvent2 = function () { + called++; + }; + + // add 2 handlers and confirm they both get called + obj.on('myevent', onMyEvent); + obj.on('myevent', onMyEvent); + obj.on('myevent', onMyEvent2); + obj.on('myevent', onMyEvent2); + + obj.emit('myevent'); + + expect(called).to.equal(4); + + // remove one of the handlers, emit again, then ensure 1 more call is made + obj.off('myevent', onMyEvent); + + obj.emit('myevent'); + + expect(called).to.equal(6); + }); + + it('calls to off without a handler do nothing', function () { + var called = 0; + + var onMyEvent = function () { + called++; + }; + + obj.on('myevent', onMyEvent); + obj.on('myevent', onMyEvent); + + obj.emit('myevent'); + + expect(called).to.equal(2); + + obj.off('myevent'); + + obj.emit('myevent'); + + expect(called).to.equal(4); + + obj.off('myevent', onMyEvent); + + obj.emit('myevent'); + + expect(called).to.equal(4); + }); + + it('handles multiple instances with the same prototype', function () { + var called = 0; + + function onMyEvent(e) { + called++; + } + + obj.on('myevent1', onMyEvent); + obj.on('myevent2', onMyEvent); + + obj2.istwo = true; + obj2.on('myevent1', onMyEvent); + obj2.on('myevent2', onMyEvent); + + obj.emit('myevent1'); + obj.emit('myevent2'); + obj2.emit('myevent1'); + obj2.emit('myevent2'); + + //we emit 4 times, but since obj2 is a child of obj the event should bubble + //up to obj and show up there as well. So the obj2.emit() calls each increment + //the counter twice. + expect(called).to.equal(6); + }); + + it('is backwards compatible with older .dispatchEvent({})', function () { + var called = 0, + data = { + some: 'thing', + hello: true + }; + + function onMyEvent(event) { + pixi_utils_EventTarget_Event_confirm(event, obj, data); + + called++; + } + + obj.on('myevent1', onMyEvent); + obj.on('myevent2', onMyEvent); + obj.on('myevent3', onMyEvent); + + data.type = 'myevent1'; + obj.emit(data); + + data.type = 'myevent2'; + obj.emit(data); + + data.type = 'myevent3'; + obj.emit(data); + + obj.off('myevent2', onMyEvent); + + data.type = 'myevent1'; + obj.emit(data); + + data.type = 'myevent2'; + obj.emit(data); + + data.type = 'myevent3'; + obj.emit(data); + + expect(called).to.equal(5); + }); + + it('is backwards compatible with older .call(this)', function () { + var Fn = function() { + PIXI.EventTarget.call(this); + }, + o = new Fn(); + + pixi_utils_EventTarget_confirm(o); + }); + + it('is backwards compatible with older .addEventListener("")', function () { + var called = 0, + data = { + some: 'thing', + hello: true + }; + + function onMyEvent(event) { + pixi_utils_EventTarget_Event_confirm(event, obj, data); + + called++; + } + + obj.addEventListener('myevent1', onMyEvent); + obj.addEventListener('myevent2', onMyEvent); + obj.addEventListener('myevent3', onMyEvent); + + data.type = 'myevent1'; + obj.emit(data); + + data.type = 'myevent2'; + obj.emit(data); + + data.type = 'myevent3'; + obj.emit(data); + + obj.off('myevent2', onMyEvent); + + data.type = 'myevent1'; + obj.emit(data); + + data.type = 'myevent2'; + obj.emit(data); + + data.type = 'myevent3'; + obj.emit(data); + + expect(called).to.equal(5); + }); + + it('event remove during emit call properly', function () { + var called = 0; + + function cb1() { + called++; + obj.off('myevent', cb1); + } + function cb2() { + called++; + obj.off('myevent', cb2); + } + function cb3() { + called++; + obj.off('myevent', cb3); + } + + obj.on('myevent', cb1); + obj.on('myevent', cb2); + obj.on('myevent', cb3); + obj.emit('myevent', ''); + + expect(called).to.equal(3); + }); +}); diff --git a/test/unit/pixi-v2/utils/Polyk.js b/test/unit/pixi-v2/utils/Polyk.js new file mode 100644 index 0000000..dfc7128 --- /dev/null +++ b/test/unit/pixi-v2/utils/Polyk.js @@ -0,0 +1,14 @@ +describe('pixi/utils/Polyk', function () { + 'use strict'; + + var expect = chai.expect; + var PolyK = PIXI.PolyK; + + it('Module exists', function () { + expect(PolyK).to.be.an('object'); + }); + + it('Members exist', function () { + expect(PolyK).to.respondTo('Triangulate'); + }); +}); diff --git a/test/unit/pixi-v2/utils/Utils.js b/test/unit/pixi-v2/utils/Utils.js new file mode 100644 index 0000000..c97b3c6 --- /dev/null +++ b/test/unit/pixi-v2/utils/Utils.js @@ -0,0 +1,17 @@ +describe('Utils', function () { + 'use strict'; + + var expect = chai.expect; + + it('requestAnimationFrame exists', function () { + expect(global).to.respondTo('requestAnimationFrame'); + }); + + it('cancelAnimationFrame exists', function () { + expect(global).to.respondTo('cancelAnimationFrame'); + }); + + it('requestAnimFrame exists', function () { + expect(global).to.respondTo('requestAnimFrame'); + }); +}); diff --git a/test/unit/pixi/InteractionManager.js b/test/unit/pixi/InteractionManager.js deleted file mode 100644 index ed3001f..0000000 --- a/test/unit/pixi/InteractionManager.js +++ /dev/null @@ -1,10 +0,0 @@ -describe('pixi/InteractionManager', function () { - 'use strict'; - - var expect = chai.expect; - var InteractionManager = PIXI.InteractionManager; - - it('Module exists', function () { - expect(InteractionManager).to.be.a('function'); - }); -}); diff --git a/test/unit/pixi/Pixi.js b/test/unit/pixi/Pixi.js deleted file mode 100644 index 27debc1..0000000 --- a/test/unit/pixi/Pixi.js +++ /dev/null @@ -1,9 +0,0 @@ -describe('pixi/Pixi', function () { - 'use strict'; - - var expect = chai.expect; - - it('Module exists', function () { - expect(global).to.have.property('PIXI').and.to.be.an('object'); - }); -}); diff --git a/test/unit/pixi/core/Circle.js b/test/unit/pixi/core/Circle.js deleted file mode 100644 index fbcfa17..0000000 --- a/test/unit/pixi/core/Circle.js +++ /dev/null @@ -1,21 +0,0 @@ -describe('pixi/core/Circle', function () { - 'use strict'; - - var expect = chai.expect; - var Circle = PIXI.Circle; - - it('Module exists', function () { - expect(Circle).to.be.a('function'); - }); - - it('Confirm new instance', function () { - var obj = new Circle(); - pixi_core_Circle_confirmNewCircle(obj); - }); - - it("getBounds should return Rectangle that bounds the circle", function() { - var obj = new Circle(100, 250, 50); - var bounds = obj.getBounds(); - pixi_core_Circle_isBoundedByRectangle(obj, bounds); - }); -}); diff --git a/test/unit/pixi/core/Ellipse.js b/test/unit/pixi/core/Ellipse.js deleted file mode 100644 index 026b56f..0000000 --- a/test/unit/pixi/core/Ellipse.js +++ /dev/null @@ -1,24 +0,0 @@ -describe('pixi/core/Ellipse', function () { - 'use strict'; - - var expect = chai.expect; - var Ellipse = PIXI.Ellipse; - - it('Module exists', function () { - expect(Ellipse).to.be.a('function'); - }); - - it('Confirm new instance', function () { - var obj = new Ellipse(); - - expect(obj).to.be.an.instanceof(Ellipse); - expect(obj).to.respondTo('clone'); - expect(obj).to.respondTo('contains'); - expect(obj).to.respondTo('getBounds'); - - expect(obj).to.have.property('x', 0); - expect(obj).to.have.property('y', 0); - expect(obj).to.have.property('width', 0); - expect(obj).to.have.property('height', 0); - }); -}); diff --git a/test/unit/pixi/core/Matrix.js b/test/unit/pixi/core/Matrix.js deleted file mode 100644 index da75e2e..0000000 --- a/test/unit/pixi/core/Matrix.js +++ /dev/null @@ -1,14 +0,0 @@ -describe('pixi/core/Matrix', function () { - 'use strict'; - - var expect = chai.expect; - - it('Matrix exists', function () { - expect(PIXI.Matrix).to.be.an('function'); - }); - - it('Confirm new Matrix', function () { - var matrix = new PIXI.Matrix(); - pixi_core_Matrix_confirmNewMatrix(matrix); - }); -}); diff --git a/test/unit/pixi/core/Point.js b/test/unit/pixi/core/Point.js deleted file mode 100644 index c4d5163..0000000 --- a/test/unit/pixi/core/Point.js +++ /dev/null @@ -1,15 +0,0 @@ -describe('pixi/core/Point', function () { - 'use strict'; - - var expect = chai.expect; - var Point = PIXI.Point; - - it('Module exists', function () { - expect(Point).to.be.a('function'); - }); - - it('Confirm new instance', function () { - var obj = new Point(); - pixi_core_Point_confirm(obj, 0, 0); - }); -}); diff --git a/test/unit/pixi/core/Polygon.js b/test/unit/pixi/core/Polygon.js deleted file mode 100644 index dc8c918..0000000 --- a/test/unit/pixi/core/Polygon.js +++ /dev/null @@ -1,20 +0,0 @@ -describe('pixi/core/Polygon', function () { - 'use strict'; - - var expect = chai.expect; - var Polygon = PIXI.Polygon; - - it('Module exists', function () { - expect(Polygon).to.be.a('function'); - }); - - it('Confirm new instance', function () { - var obj = new Polygon(); - - expect(obj).to.be.an.instanceof(Polygon); - expect(obj).to.respondTo('clone'); - expect(obj).to.respondTo('contains'); - - expect(obj).to.have.deep.property('points.length', 0); - }); -}); diff --git a/test/unit/pixi/core/Rectangle.js b/test/unit/pixi/core/Rectangle.js deleted file mode 100644 index d43316e..0000000 --- a/test/unit/pixi/core/Rectangle.js +++ /dev/null @@ -1,15 +0,0 @@ -describe('pixi/core/Rectangle', function () { - 'use strict'; - - var expect = chai.expect; - var Rectangle = PIXI.Rectangle; - - it('Module exists', function () { - expect(Rectangle).to.be.a('function'); - }); - - it('Confirm new instance', function () { - var rect = new Rectangle(); - pixi_core_Rectangle_confirm(rect, 0, 0, 0, 0); - }); -}); diff --git a/test/unit/pixi/display/DisplayObject.js b/test/unit/pixi/display/DisplayObject.js deleted file mode 100644 index 044acf8..0000000 --- a/test/unit/pixi/display/DisplayObject.js +++ /dev/null @@ -1,21 +0,0 @@ -describe('pixi/display/DisplayObject', function () { - 'use strict'; - - var expect = chai.expect; - var DisplayObject = PIXI.DisplayObject; - - it('Module exists', function () { - expect(DisplayObject).to.be.a('function'); - // expect(PIXI).to.have.property('visibleCount', 0); - }); - - it('Confirm new instance', function () { - var obj = new DisplayObject(); - - pixi_display_DisplayObject_confirmNew(obj); - expect(obj).to.have.property('hitArea', null); - expect(obj).to.have.property('interactive', false); - expect(obj).to.have.property('renderable', false); - expect(obj).to.have.property('stage', null); - }); -}); diff --git a/test/unit/pixi/display/DisplayObjectContainer.js b/test/unit/pixi/display/DisplayObjectContainer.js deleted file mode 100644 index 15a3376..0000000 --- a/test/unit/pixi/display/DisplayObjectContainer.js +++ /dev/null @@ -1,67 +0,0 @@ -describe('pixi/display/DisplayObjectContainer', function () { - 'use strict'; - - var expect = chai.expect; - var DisplayObjectContainer = PIXI.DisplayObjectContainer; - - it('Module exists', function () { - expect(DisplayObjectContainer).to.be.a('function'); - }); - - it('Confirm new instance', function () { - var obj = new DisplayObjectContainer(); - - pixi_display_DisplayObjectContainer_confirmNew(obj); - expect(obj).to.have.property('hitArea', null); - expect(obj).to.have.property('interactive', false); - expect(obj).to.have.property('renderable', false); - expect(obj).to.have.property('stage', null); - }); - - it('Gets child index', function() { - var container = new PIXI.DisplayObjectContainer(); - var children = []; - for (var i = 0; i < 10; i++) { - var child = new PIXI.DisplayObject(); - children.push(child); - container.addChild(child); - } - - for (i = 0; i < children.length; i++) { - expect(i).to.eql(container.getChildIndex(children[i])); - } - }); - - it('throws error when trying to get index of not a child', function() { - var container = new PIXI.DisplayObjectContainer(); - var child = new PIXI.DisplayObject(); - - expect(function() { container.getChildIndex(child); }).to.throw(); - }); - - it('Sets child index', function() { - var container = new PIXI.DisplayObjectContainer(); - var children = []; - - for (var i = 0; i < 10; i++) { - var child = new PIXI.DisplayObject(); - children.push(child); - container.addChild(child); - } - children.reverse(); - - for (i = 0; i < children.length; i++) { - container.setChildIndex(children[i], i); - expect(i).to.eql(container.getChildIndex(children[i])); - } - }); - - it('throws error when trying to set incorect index', function() { - var container = new PIXI.DisplayObjectContainer(); - var child = new PIXI.DisplayObject(); - container.addChild(child); - - expect(function() { container.setChildIndex(child, -1); }).to.throw(); - expect(function() { container.setChildIndex(child, 1); }).to.throw(); - }); -}); diff --git a/test/unit/pixi/display/MovieClip.js b/test/unit/pixi/display/MovieClip.js deleted file mode 100644 index f3c6c6a..0000000 --- a/test/unit/pixi/display/MovieClip.js +++ /dev/null @@ -1,33 +0,0 @@ -describe('pixi/display/MovieClip', function () { - 'use strict'; - - var expect = chai.expect; - var MovieClip = PIXI.MovieClip; - var Texture = PIXI.Texture; - - it('Module exists', function () { - expect(MovieClip).to.be.a('function'); - }); - - it('Confirm new instance', function (done) { - var texture = Texture.fromImage('/base/test/textures/SpriteSheet-Explosion.png'); - var obj = new MovieClip([texture]); - - pixi_display_Sprite_confirmNew(obj, done); - - expect(obj).to.be.an.instanceof(MovieClip); - expect(obj).to.respondTo('stop'); - expect(obj).to.respondTo('play'); - expect(obj).to.respondTo('gotoAndStop'); - expect(obj).to.respondTo('gotoAndPlay'); - expect(obj).to.respondTo('updateTransform'); - - expect(obj).to.have.deep.property('textures.length', 1); - expect(obj).to.have.deep.property('textures[0]', texture); - expect(obj).to.have.property('animationSpeed', 1); - expect(obj).to.have.property('loop', true); - expect(obj).to.have.property('onComplete', null); - expect(obj).to.have.property('currentFrame', 0); - expect(obj).to.have.property('playing', false); - }); -}); diff --git a/test/unit/pixi/display/Sprite.js b/test/unit/pixi/display/Sprite.js deleted file mode 100644 index 30c8076..0000000 --- a/test/unit/pixi/display/Sprite.js +++ /dev/null @@ -1,28 +0,0 @@ -describe('pixi/display/Sprite', function () { - 'use strict'; - - var expect = chai.expect; - var Sprite = PIXI.Sprite; - var Texture = PIXI.Texture; - - it('Module exists', function () { - expect(Sprite).to.be.a('function'); - expect(PIXI).to.have.deep.property('blendModes.NORMAL', 0); - expect(PIXI).to.have.deep.property('blendModes.ADD', 1); - expect(PIXI).to.have.deep.property('blendModes.MULTIPLY', 2); - expect(PIXI).to.have.deep.property('blendModes.SCREEN', 3); - }); - - - it('Members exist', function () { - expect(Sprite).itself.to.respondTo('fromImage'); - expect(Sprite).itself.to.respondTo('fromFrame'); - }); - - it('Confirm new instance', function (done) { - var texture = Texture.fromImage('/base/test/textures/SpriteSheet-Aliens.png'); - var obj = new Sprite(texture); - - pixi_display_Sprite_confirmNew(obj, done); - }); -}); diff --git a/test/unit/pixi/display/Stage.js b/test/unit/pixi/display/Stage.js deleted file mode 100644 index 6974c2e..0000000 --- a/test/unit/pixi/display/Stage.js +++ /dev/null @@ -1,49 +0,0 @@ -describe('pixi/display/Stage', function () { - 'use strict'; - - var expect = chai.expect; - var Stage = PIXI.Stage; - var InteractionManager = PIXI.InteractionManager; - var Rectangle = PIXI.Rectangle; - - it('Module exists', function () { - expect(Stage).to.be.a('function'); - }); - - it('Confirm new instance', function () { - var obj = new Stage(null, true); - - pixi_display_DisplayObjectContainer_confirmNew(obj); - - expect(obj).to.be.an.instanceof(Stage); - expect(obj).to.respondTo('updateTransform'); - expect(obj).to.respondTo('setBackgroundColor'); - expect(obj).to.respondTo('getMousePosition'); - // FIXME: duplicate member in DisplayObject - pixi_core_Matrix_confirmNewMatrix(obj.worldTransform); - // FIXME: convert arg to bool in constructor - expect(obj).to.have.property('interactive', true); - - expect(obj).to.have.property('interactionManager') - .and.to.be.an.instanceof(InteractionManager) - .and.to.have.property('stage', obj); - - expect(obj).to.have.property('dirty', true); - - expect(obj).to.have.property('stage', obj); - - expect(obj).to.have.property('hitArea') - .and.to.be.an.instanceof(Rectangle); - pixi_core_Rectangle_confirm(obj.hitArea, 0, 0, 100000, 100000); - - expect(obj).to.have.property('backgroundColor', 0x000000); - expect(obj).to.have.deep.property('backgroundColorSplit.length', 3); - expect(obj).to.have.deep.property('backgroundColorSplit[0]', 0); - expect(obj).to.have.deep.property('backgroundColorSplit[1]', 0); - expect(obj).to.have.deep.property('backgroundColorSplit[2]', 0); - expect(obj).to.have.property('backgroundColorString', '#000000'); - - - expect(obj).to.have.property('worldVisible', true); - }); -}); diff --git a/test/unit/pixi/extras/Rope.js b/test/unit/pixi/extras/Rope.js deleted file mode 100644 index 05885ac..0000000 --- a/test/unit/pixi/extras/Rope.js +++ /dev/null @@ -1,31 +0,0 @@ -describe('pixi/extras/Rope', function () { - 'use strict'; - - var expect = chai.expect; - var Rope = PIXI.Rope; - var Texture = PIXI.Texture; - var Point = PIXI.Point; - - it('Module exists', function () { - expect(Rope).to.be.a('function'); - }); - - it('Confirm new instance', function () { - - var texture = Texture.fromImage('/base/test/textures/bunny.png'); - - // TODO-Alvin - // Same as Strip - - // var obj = new Rope(texture, [new Point(), new Point(5, 10), new Point(10, 20)]); - - // pixi_extras_Strip_confirmNew(obj); - - // expect(obj).to.be.an.instanceof(Rope); - // expect(obj).to.respondTo('refresh'); - // expect(obj).to.respondTo('updateTransform'); - // expect(obj).to.respondTo('setTexture'); - - // TODO: Test properties - }); -}); diff --git a/test/unit/pixi/extras/Spine.js b/test/unit/pixi/extras/Spine.js deleted file mode 100644 index 0708bc0..0000000 --- a/test/unit/pixi/extras/Spine.js +++ /dev/null @@ -1,10 +0,0 @@ -describe('pixi/extras/Spine', function () { - 'use strict'; - - var expect = chai.expect; - var Spine = PIXI.Spine; - - it('Module exists', function () { - expect(Spine).to.be.a('function'); - }); -}); diff --git a/test/unit/pixi/extras/Strip.js b/test/unit/pixi/extras/Strip.js deleted file mode 100644 index 230af90..0000000 --- a/test/unit/pixi/extras/Strip.js +++ /dev/null @@ -1,26 +0,0 @@ -describe('pixi/extras/Strip', function () { - 'use strict'; - - var expect = chai.expect; - var Strip = PIXI.Strip; - var Texture = PIXI.Texture; - - it('Module exists', function () { - expect(Strip).to.be.a('function'); - }); - - it('Confirm new instance', function () { - - - // TODO-Alvin - // We tweaked it to make it pass the tests, but the whole strip class needs - // to be re-coded - - var texture = Texture.fromImage('/base/test/textures/bunny.png'); - - // var obj = new Strip(texture, 20, 10000); - - - // pixi_extras_Strip_confirmNew(obj); - }); -}); diff --git a/test/unit/pixi/extras/TilingSprite.js b/test/unit/pixi/extras/TilingSprite.js deleted file mode 100644 index 56aea14..0000000 --- a/test/unit/pixi/extras/TilingSprite.js +++ /dev/null @@ -1,24 +0,0 @@ -describe('pixi/extras/TilingSprite', function () { - 'use strict'; - - var expect = chai.expect; - var TilingSprite = PIXI.TilingSprite; - var Texture = PIXI.Texture; - - it('Module exists', function () { - expect(TilingSprite).to.be.a('function'); - }); - - it('Confirm new instance', function () { - var texture = Texture.fromImage('/base/test/textures/bunny.png'); - var obj = new TilingSprite(texture, 6000, 12000); - - pixi_display_DisplayObjectContainer_confirmNew(obj); - - expect(obj).to.be.an.instanceof(TilingSprite); - expect(obj).to.respondTo('setTexture'); - expect(obj).to.respondTo('onTextureUpdate'); - - // TODO: Test properties - }); -}); diff --git a/test/unit/pixi/filters/FilterBlock.js b/test/unit/pixi/filters/FilterBlock.js deleted file mode 100644 index 870cec0..0000000 --- a/test/unit/pixi/filters/FilterBlock.js +++ /dev/null @@ -1,10 +0,0 @@ -describe('pixi/filters/FilterBlock', function () { - 'use strict'; - - var expect = chai.expect; - var FilterBlock = PIXI.FilterBlock; - - it('Module exists', function () { - expect(FilterBlock).to.be.a('function'); - }); -}); diff --git a/test/unit/pixi/loaders/AssetLoader.js b/test/unit/pixi/loaders/AssetLoader.js deleted file mode 100644 index a0aa0b5..0000000 --- a/test/unit/pixi/loaders/AssetLoader.js +++ /dev/null @@ -1,10 +0,0 @@ -describe('pixi/loaders/AssetLoader', function () { - 'use strict'; - - var expect = chai.expect; - var AssetLoader = PIXI.AssetLoader; - - it('Module exists', function () { - expect(AssetLoader).to.be.a('function'); - }); -}); diff --git a/test/unit/pixi/loaders/BitmapFontLoader.js b/test/unit/pixi/loaders/BitmapFontLoader.js deleted file mode 100644 index 046f018..0000000 --- a/test/unit/pixi/loaders/BitmapFontLoader.js +++ /dev/null @@ -1,9 +0,0 @@ -describe('pixi/loaders/BitmapFontLoader', function () { - 'use strict'; - - var expect = chai.expect; - - it('Module exists', function () { - expect(PIXI.BitmapFontLoader).to.be.a('function'); - }); -}); diff --git a/test/unit/pixi/loaders/ImageLoader.js b/test/unit/pixi/loaders/ImageLoader.js deleted file mode 100644 index 8b1f556..0000000 --- a/test/unit/pixi/loaders/ImageLoader.js +++ /dev/null @@ -1,10 +0,0 @@ -describe('pixi/loaders/ImageLoader', function () { - 'use strict'; - - var expect = chai.expect; - var ImageLoader = PIXI.ImageLoader; - - it('Module exists', function () { - expect(ImageLoader).to.be.a('function'); - }); -}); diff --git a/test/unit/pixi/loaders/JsonLoader.js b/test/unit/pixi/loaders/JsonLoader.js deleted file mode 100644 index c577e83..0000000 --- a/test/unit/pixi/loaders/JsonLoader.js +++ /dev/null @@ -1,10 +0,0 @@ -describe('pixi/loaders/JsonLoader', function () { - 'use strict'; - - var expect = chai.expect; - var JsonLoader = PIXI.JsonLoader; - - it('Module exists', function () { - expect(JsonLoader).to.be.a('function'); - }); -}); diff --git a/test/unit/pixi/loaders/SpineLoader.js b/test/unit/pixi/loaders/SpineLoader.js deleted file mode 100644 index fdcc0b8..0000000 --- a/test/unit/pixi/loaders/SpineLoader.js +++ /dev/null @@ -1,10 +0,0 @@ -describe('pixi/loaders/SpineLoader', function () { - 'use strict'; - - var expect = chai.expect; - var SpineLoader = PIXI.SpineLoader; - - it('Module exists', function () { - expect(SpineLoader).to.be.a('function'); - }); -}); diff --git a/test/unit/pixi/loaders/SpriteSheetLoader.js b/test/unit/pixi/loaders/SpriteSheetLoader.js deleted file mode 100644 index 57beb27..0000000 --- a/test/unit/pixi/loaders/SpriteSheetLoader.js +++ /dev/null @@ -1,10 +0,0 @@ -describe('pixi/loaders/SpriteSheetLoader', function () { - 'use strict'; - - var expect = chai.expect; - var SpriteSheetLoader = PIXI.SpriteSheetLoader; - - it('Module exists', function () { - expect(SpriteSheetLoader).to.be.a('function'); - }); -}); diff --git a/test/unit/pixi/primitives/Graphics.js b/test/unit/pixi/primitives/Graphics.js deleted file mode 100644 index f3849eb..0000000 --- a/test/unit/pixi/primitives/Graphics.js +++ /dev/null @@ -1,44 +0,0 @@ -describe('pixi/primitives/Graphics', function () { - 'use strict'; - - var expect = chai.expect; - var Graphics = PIXI.Graphics; - - it('Module exists', function () { - expect(Graphics).to.be.a('function'); - - expect(Graphics).itself.to.have.property('POLY', 0); - expect(Graphics).itself.to.have.property('RECT', 1); - expect(Graphics).itself.to.have.property('CIRC', 2); - expect(Graphics).itself.to.have.property('ELIP', 3); - expect(Graphics).itself.to.have.property('RREC', 4); - }); - - it('Confirm new instance', function () { - var obj = new Graphics(); - - pixi_display_DisplayObjectContainer_confirmNew(obj); - - expect(obj).to.be.an.instanceof(Graphics); - expect(obj).to.respondTo('lineStyle'); - expect(obj).to.respondTo('lineStyle'); - expect(obj).to.respondTo('moveTo'); - expect(obj).to.respondTo('lineTo'); - expect(obj).to.respondTo('beginFill'); - expect(obj).to.respondTo('endFill'); - expect(obj).to.respondTo('drawRect'); - // expect(obj).to.respondTo('drawRoundedRect'); - expect(obj).to.respondTo('drawCircle'); - expect(obj).to.respondTo('drawEllipse'); - expect(obj).to.respondTo('clear'); - - expect(obj).to.have.property('renderable', true); - expect(obj).to.have.property('fillAlpha', 1); - expect(obj).to.have.property('lineWidth', 0); - expect(obj).to.have.property('width', 0); - expect(obj).to.have.property('height', 0); - expect(obj).to.have.property('lineColor', 0); - expect(obj).to.have.deep.property('graphicsData.length', 0); - // expect(obj).to.have.deep.property('currentPath.points.length', 0); - }); -}); diff --git a/test/unit/pixi/renderers/canvas/CanvasGraphics.js b/test/unit/pixi/renderers/canvas/CanvasGraphics.js deleted file mode 100644 index 8f44472..0000000 --- a/test/unit/pixi/renderers/canvas/CanvasGraphics.js +++ /dev/null @@ -1,15 +0,0 @@ -describe('renders/canvas/CanvasGraphics', function () { - 'use strict'; - - var expect = chai.expect; - var CanvasGraphics = PIXI.CanvasGraphics; - - it('Module exists', function () { - expect(CanvasGraphics).to.be.a('function'); - }); - - it('Members exist', function () { - expect(CanvasGraphics).itself.to.respondTo('renderGraphics'); - expect(CanvasGraphics).itself.to.respondTo('renderGraphicsMask'); - }); -}); diff --git a/test/unit/pixi-v2/InteractionManager.js b/test/unit/pixi-v2/InteractionManager.js new file mode 100644 index 0000000..ed3001f --- /dev/null +++ b/test/unit/pixi-v2/InteractionManager.js @@ -0,0 +1,10 @@ +describe('pixi/InteractionManager', function () { + 'use strict'; + + var expect = chai.expect; + var InteractionManager = PIXI.InteractionManager; + + it('Module exists', function () { + expect(InteractionManager).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/Pixi.js b/test/unit/pixi-v2/Pixi.js new file mode 100644 index 0000000..27debc1 --- /dev/null +++ b/test/unit/pixi-v2/Pixi.js @@ -0,0 +1,9 @@ +describe('pixi/Pixi', function () { + 'use strict'; + + var expect = chai.expect; + + it('Module exists', function () { + expect(global).to.have.property('PIXI').and.to.be.an('object'); + }); +}); diff --git a/test/unit/pixi-v2/core/Circle.js b/test/unit/pixi-v2/core/Circle.js new file mode 100644 index 0000000..fbcfa17 --- /dev/null +++ b/test/unit/pixi-v2/core/Circle.js @@ -0,0 +1,21 @@ +describe('pixi/core/Circle', function () { + 'use strict'; + + var expect = chai.expect; + var Circle = PIXI.Circle; + + it('Module exists', function () { + expect(Circle).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Circle(); + pixi_core_Circle_confirmNewCircle(obj); + }); + + it("getBounds should return Rectangle that bounds the circle", function() { + var obj = new Circle(100, 250, 50); + var bounds = obj.getBounds(); + pixi_core_Circle_isBoundedByRectangle(obj, bounds); + }); +}); diff --git a/test/unit/pixi-v2/core/Ellipse.js b/test/unit/pixi-v2/core/Ellipse.js new file mode 100644 index 0000000..026b56f --- /dev/null +++ b/test/unit/pixi-v2/core/Ellipse.js @@ -0,0 +1,24 @@ +describe('pixi/core/Ellipse', function () { + 'use strict'; + + var expect = chai.expect; + var Ellipse = PIXI.Ellipse; + + it('Module exists', function () { + expect(Ellipse).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Ellipse(); + + expect(obj).to.be.an.instanceof(Ellipse); + expect(obj).to.respondTo('clone'); + expect(obj).to.respondTo('contains'); + expect(obj).to.respondTo('getBounds'); + + expect(obj).to.have.property('x', 0); + expect(obj).to.have.property('y', 0); + expect(obj).to.have.property('width', 0); + expect(obj).to.have.property('height', 0); + }); +}); diff --git a/test/unit/pixi-v2/core/Matrix.js b/test/unit/pixi-v2/core/Matrix.js new file mode 100644 index 0000000..da75e2e --- /dev/null +++ b/test/unit/pixi-v2/core/Matrix.js @@ -0,0 +1,14 @@ +describe('pixi/core/Matrix', function () { + 'use strict'; + + var expect = chai.expect; + + it('Matrix exists', function () { + expect(PIXI.Matrix).to.be.an('function'); + }); + + it('Confirm new Matrix', function () { + var matrix = new PIXI.Matrix(); + pixi_core_Matrix_confirmNewMatrix(matrix); + }); +}); diff --git a/test/unit/pixi-v2/core/Point.js b/test/unit/pixi-v2/core/Point.js new file mode 100644 index 0000000..c4d5163 --- /dev/null +++ b/test/unit/pixi-v2/core/Point.js @@ -0,0 +1,15 @@ +describe('pixi/core/Point', function () { + 'use strict'; + + var expect = chai.expect; + var Point = PIXI.Point; + + it('Module exists', function () { + expect(Point).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Point(); + pixi_core_Point_confirm(obj, 0, 0); + }); +}); diff --git a/test/unit/pixi-v2/core/Polygon.js b/test/unit/pixi-v2/core/Polygon.js new file mode 100644 index 0000000..dc8c918 --- /dev/null +++ b/test/unit/pixi-v2/core/Polygon.js @@ -0,0 +1,20 @@ +describe('pixi/core/Polygon', function () { + 'use strict'; + + var expect = chai.expect; + var Polygon = PIXI.Polygon; + + it('Module exists', function () { + expect(Polygon).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Polygon(); + + expect(obj).to.be.an.instanceof(Polygon); + expect(obj).to.respondTo('clone'); + expect(obj).to.respondTo('contains'); + + expect(obj).to.have.deep.property('points.length', 0); + }); +}); diff --git a/test/unit/pixi-v2/core/Rectangle.js b/test/unit/pixi-v2/core/Rectangle.js new file mode 100644 index 0000000..d43316e --- /dev/null +++ b/test/unit/pixi-v2/core/Rectangle.js @@ -0,0 +1,15 @@ +describe('pixi/core/Rectangle', function () { + 'use strict'; + + var expect = chai.expect; + var Rectangle = PIXI.Rectangle; + + it('Module exists', function () { + expect(Rectangle).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var rect = new Rectangle(); + pixi_core_Rectangle_confirm(rect, 0, 0, 0, 0); + }); +}); diff --git a/test/unit/pixi-v2/display/DisplayObject.js b/test/unit/pixi-v2/display/DisplayObject.js new file mode 100644 index 0000000..044acf8 --- /dev/null +++ b/test/unit/pixi-v2/display/DisplayObject.js @@ -0,0 +1,21 @@ +describe('pixi/display/DisplayObject', function () { + 'use strict'; + + var expect = chai.expect; + var DisplayObject = PIXI.DisplayObject; + + it('Module exists', function () { + expect(DisplayObject).to.be.a('function'); + // expect(PIXI).to.have.property('visibleCount', 0); + }); + + it('Confirm new instance', function () { + var obj = new DisplayObject(); + + pixi_display_DisplayObject_confirmNew(obj); + expect(obj).to.have.property('hitArea', null); + expect(obj).to.have.property('interactive', false); + expect(obj).to.have.property('renderable', false); + expect(obj).to.have.property('stage', null); + }); +}); diff --git a/test/unit/pixi-v2/display/DisplayObjectContainer.js b/test/unit/pixi-v2/display/DisplayObjectContainer.js new file mode 100644 index 0000000..15a3376 --- /dev/null +++ b/test/unit/pixi-v2/display/DisplayObjectContainer.js @@ -0,0 +1,67 @@ +describe('pixi/display/DisplayObjectContainer', function () { + 'use strict'; + + var expect = chai.expect; + var DisplayObjectContainer = PIXI.DisplayObjectContainer; + + it('Module exists', function () { + expect(DisplayObjectContainer).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new DisplayObjectContainer(); + + pixi_display_DisplayObjectContainer_confirmNew(obj); + expect(obj).to.have.property('hitArea', null); + expect(obj).to.have.property('interactive', false); + expect(obj).to.have.property('renderable', false); + expect(obj).to.have.property('stage', null); + }); + + it('Gets child index', function() { + var container = new PIXI.DisplayObjectContainer(); + var children = []; + for (var i = 0; i < 10; i++) { + var child = new PIXI.DisplayObject(); + children.push(child); + container.addChild(child); + } + + for (i = 0; i < children.length; i++) { + expect(i).to.eql(container.getChildIndex(children[i])); + } + }); + + it('throws error when trying to get index of not a child', function() { + var container = new PIXI.DisplayObjectContainer(); + var child = new PIXI.DisplayObject(); + + expect(function() { container.getChildIndex(child); }).to.throw(); + }); + + it('Sets child index', function() { + var container = new PIXI.DisplayObjectContainer(); + var children = []; + + for (var i = 0; i < 10; i++) { + var child = new PIXI.DisplayObject(); + children.push(child); + container.addChild(child); + } + children.reverse(); + + for (i = 0; i < children.length; i++) { + container.setChildIndex(children[i], i); + expect(i).to.eql(container.getChildIndex(children[i])); + } + }); + + it('throws error when trying to set incorect index', function() { + var container = new PIXI.DisplayObjectContainer(); + var child = new PIXI.DisplayObject(); + container.addChild(child); + + expect(function() { container.setChildIndex(child, -1); }).to.throw(); + expect(function() { container.setChildIndex(child, 1); }).to.throw(); + }); +}); diff --git a/test/unit/pixi-v2/display/MovieClip.js b/test/unit/pixi-v2/display/MovieClip.js new file mode 100644 index 0000000..f3c6c6a --- /dev/null +++ b/test/unit/pixi-v2/display/MovieClip.js @@ -0,0 +1,33 @@ +describe('pixi/display/MovieClip', function () { + 'use strict'; + + var expect = chai.expect; + var MovieClip = PIXI.MovieClip; + var Texture = PIXI.Texture; + + it('Module exists', function () { + expect(MovieClip).to.be.a('function'); + }); + + it('Confirm new instance', function (done) { + var texture = Texture.fromImage('/base/test/textures/SpriteSheet-Explosion.png'); + var obj = new MovieClip([texture]); + + pixi_display_Sprite_confirmNew(obj, done); + + expect(obj).to.be.an.instanceof(MovieClip); + expect(obj).to.respondTo('stop'); + expect(obj).to.respondTo('play'); + expect(obj).to.respondTo('gotoAndStop'); + expect(obj).to.respondTo('gotoAndPlay'); + expect(obj).to.respondTo('updateTransform'); + + expect(obj).to.have.deep.property('textures.length', 1); + expect(obj).to.have.deep.property('textures[0]', texture); + expect(obj).to.have.property('animationSpeed', 1); + expect(obj).to.have.property('loop', true); + expect(obj).to.have.property('onComplete', null); + expect(obj).to.have.property('currentFrame', 0); + expect(obj).to.have.property('playing', false); + }); +}); diff --git a/test/unit/pixi-v2/display/Sprite.js b/test/unit/pixi-v2/display/Sprite.js new file mode 100644 index 0000000..30c8076 --- /dev/null +++ b/test/unit/pixi-v2/display/Sprite.js @@ -0,0 +1,28 @@ +describe('pixi/display/Sprite', function () { + 'use strict'; + + var expect = chai.expect; + var Sprite = PIXI.Sprite; + var Texture = PIXI.Texture; + + it('Module exists', function () { + expect(Sprite).to.be.a('function'); + expect(PIXI).to.have.deep.property('blendModes.NORMAL', 0); + expect(PIXI).to.have.deep.property('blendModes.ADD', 1); + expect(PIXI).to.have.deep.property('blendModes.MULTIPLY', 2); + expect(PIXI).to.have.deep.property('blendModes.SCREEN', 3); + }); + + + it('Members exist', function () { + expect(Sprite).itself.to.respondTo('fromImage'); + expect(Sprite).itself.to.respondTo('fromFrame'); + }); + + it('Confirm new instance', function (done) { + var texture = Texture.fromImage('/base/test/textures/SpriteSheet-Aliens.png'); + var obj = new Sprite(texture); + + pixi_display_Sprite_confirmNew(obj, done); + }); +}); diff --git a/test/unit/pixi-v2/display/Stage.js b/test/unit/pixi-v2/display/Stage.js new file mode 100644 index 0000000..6974c2e --- /dev/null +++ b/test/unit/pixi-v2/display/Stage.js @@ -0,0 +1,49 @@ +describe('pixi/display/Stage', function () { + 'use strict'; + + var expect = chai.expect; + var Stage = PIXI.Stage; + var InteractionManager = PIXI.InteractionManager; + var Rectangle = PIXI.Rectangle; + + it('Module exists', function () { + expect(Stage).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Stage(null, true); + + pixi_display_DisplayObjectContainer_confirmNew(obj); + + expect(obj).to.be.an.instanceof(Stage); + expect(obj).to.respondTo('updateTransform'); + expect(obj).to.respondTo('setBackgroundColor'); + expect(obj).to.respondTo('getMousePosition'); + // FIXME: duplicate member in DisplayObject + pixi_core_Matrix_confirmNewMatrix(obj.worldTransform); + // FIXME: convert arg to bool in constructor + expect(obj).to.have.property('interactive', true); + + expect(obj).to.have.property('interactionManager') + .and.to.be.an.instanceof(InteractionManager) + .and.to.have.property('stage', obj); + + expect(obj).to.have.property('dirty', true); + + expect(obj).to.have.property('stage', obj); + + expect(obj).to.have.property('hitArea') + .and.to.be.an.instanceof(Rectangle); + pixi_core_Rectangle_confirm(obj.hitArea, 0, 0, 100000, 100000); + + expect(obj).to.have.property('backgroundColor', 0x000000); + expect(obj).to.have.deep.property('backgroundColorSplit.length', 3); + expect(obj).to.have.deep.property('backgroundColorSplit[0]', 0); + expect(obj).to.have.deep.property('backgroundColorSplit[1]', 0); + expect(obj).to.have.deep.property('backgroundColorSplit[2]', 0); + expect(obj).to.have.property('backgroundColorString', '#000000'); + + + expect(obj).to.have.property('worldVisible', true); + }); +}); diff --git a/test/unit/pixi-v2/extras/Rope.js b/test/unit/pixi-v2/extras/Rope.js new file mode 100644 index 0000000..05885ac --- /dev/null +++ b/test/unit/pixi-v2/extras/Rope.js @@ -0,0 +1,31 @@ +describe('pixi/extras/Rope', function () { + 'use strict'; + + var expect = chai.expect; + var Rope = PIXI.Rope; + var Texture = PIXI.Texture; + var Point = PIXI.Point; + + it('Module exists', function () { + expect(Rope).to.be.a('function'); + }); + + it('Confirm new instance', function () { + + var texture = Texture.fromImage('/base/test/textures/bunny.png'); + + // TODO-Alvin + // Same as Strip + + // var obj = new Rope(texture, [new Point(), new Point(5, 10), new Point(10, 20)]); + + // pixi_extras_Strip_confirmNew(obj); + + // expect(obj).to.be.an.instanceof(Rope); + // expect(obj).to.respondTo('refresh'); + // expect(obj).to.respondTo('updateTransform'); + // expect(obj).to.respondTo('setTexture'); + + // TODO: Test properties + }); +}); diff --git a/test/unit/pixi-v2/extras/Spine.js b/test/unit/pixi-v2/extras/Spine.js new file mode 100644 index 0000000..0708bc0 --- /dev/null +++ b/test/unit/pixi-v2/extras/Spine.js @@ -0,0 +1,10 @@ +describe('pixi/extras/Spine', function () { + 'use strict'; + + var expect = chai.expect; + var Spine = PIXI.Spine; + + it('Module exists', function () { + expect(Spine).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/extras/Strip.js b/test/unit/pixi-v2/extras/Strip.js new file mode 100644 index 0000000..230af90 --- /dev/null +++ b/test/unit/pixi-v2/extras/Strip.js @@ -0,0 +1,26 @@ +describe('pixi/extras/Strip', function () { + 'use strict'; + + var expect = chai.expect; + var Strip = PIXI.Strip; + var Texture = PIXI.Texture; + + it('Module exists', function () { + expect(Strip).to.be.a('function'); + }); + + it('Confirm new instance', function () { + + + // TODO-Alvin + // We tweaked it to make it pass the tests, but the whole strip class needs + // to be re-coded + + var texture = Texture.fromImage('/base/test/textures/bunny.png'); + + // var obj = new Strip(texture, 20, 10000); + + + // pixi_extras_Strip_confirmNew(obj); + }); +}); diff --git a/test/unit/pixi-v2/extras/TilingSprite.js b/test/unit/pixi-v2/extras/TilingSprite.js new file mode 100644 index 0000000..56aea14 --- /dev/null +++ b/test/unit/pixi-v2/extras/TilingSprite.js @@ -0,0 +1,24 @@ +describe('pixi/extras/TilingSprite', function () { + 'use strict'; + + var expect = chai.expect; + var TilingSprite = PIXI.TilingSprite; + var Texture = PIXI.Texture; + + it('Module exists', function () { + expect(TilingSprite).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var texture = Texture.fromImage('/base/test/textures/bunny.png'); + var obj = new TilingSprite(texture, 6000, 12000); + + pixi_display_DisplayObjectContainer_confirmNew(obj); + + expect(obj).to.be.an.instanceof(TilingSprite); + expect(obj).to.respondTo('setTexture'); + expect(obj).to.respondTo('onTextureUpdate'); + + // TODO: Test properties + }); +}); diff --git a/test/unit/pixi-v2/filters/FilterBlock.js b/test/unit/pixi-v2/filters/FilterBlock.js new file mode 100644 index 0000000..870cec0 --- /dev/null +++ b/test/unit/pixi-v2/filters/FilterBlock.js @@ -0,0 +1,10 @@ +describe('pixi/filters/FilterBlock', function () { + 'use strict'; + + var expect = chai.expect; + var FilterBlock = PIXI.FilterBlock; + + it('Module exists', function () { + expect(FilterBlock).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/AssetLoader.js b/test/unit/pixi-v2/loaders/AssetLoader.js new file mode 100644 index 0000000..a0aa0b5 --- /dev/null +++ b/test/unit/pixi-v2/loaders/AssetLoader.js @@ -0,0 +1,10 @@ +describe('pixi/loaders/AssetLoader', function () { + 'use strict'; + + var expect = chai.expect; + var AssetLoader = PIXI.AssetLoader; + + it('Module exists', function () { + expect(AssetLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/BitmapFontLoader.js b/test/unit/pixi-v2/loaders/BitmapFontLoader.js new file mode 100644 index 0000000..046f018 --- /dev/null +++ b/test/unit/pixi-v2/loaders/BitmapFontLoader.js @@ -0,0 +1,9 @@ +describe('pixi/loaders/BitmapFontLoader', function () { + 'use strict'; + + var expect = chai.expect; + + it('Module exists', function () { + expect(PIXI.BitmapFontLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/ImageLoader.js b/test/unit/pixi-v2/loaders/ImageLoader.js new file mode 100644 index 0000000..8b1f556 --- /dev/null +++ b/test/unit/pixi-v2/loaders/ImageLoader.js @@ -0,0 +1,10 @@ +describe('pixi/loaders/ImageLoader', function () { + 'use strict'; + + var expect = chai.expect; + var ImageLoader = PIXI.ImageLoader; + + it('Module exists', function () { + expect(ImageLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/JsonLoader.js b/test/unit/pixi-v2/loaders/JsonLoader.js new file mode 100644 index 0000000..c577e83 --- /dev/null +++ b/test/unit/pixi-v2/loaders/JsonLoader.js @@ -0,0 +1,10 @@ +describe('pixi/loaders/JsonLoader', function () { + 'use strict'; + + var expect = chai.expect; + var JsonLoader = PIXI.JsonLoader; + + it('Module exists', function () { + expect(JsonLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/SpineLoader.js b/test/unit/pixi-v2/loaders/SpineLoader.js new file mode 100644 index 0000000..fdcc0b8 --- /dev/null +++ b/test/unit/pixi-v2/loaders/SpineLoader.js @@ -0,0 +1,10 @@ +describe('pixi/loaders/SpineLoader', function () { + 'use strict'; + + var expect = chai.expect; + var SpineLoader = PIXI.SpineLoader; + + it('Module exists', function () { + expect(SpineLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/SpriteSheetLoader.js b/test/unit/pixi-v2/loaders/SpriteSheetLoader.js new file mode 100644 index 0000000..57beb27 --- /dev/null +++ b/test/unit/pixi-v2/loaders/SpriteSheetLoader.js @@ -0,0 +1,10 @@ +describe('pixi/loaders/SpriteSheetLoader', function () { + 'use strict'; + + var expect = chai.expect; + var SpriteSheetLoader = PIXI.SpriteSheetLoader; + + it('Module exists', function () { + expect(SpriteSheetLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/primitives/Graphics.js b/test/unit/pixi-v2/primitives/Graphics.js new file mode 100644 index 0000000..f3849eb --- /dev/null +++ b/test/unit/pixi-v2/primitives/Graphics.js @@ -0,0 +1,44 @@ +describe('pixi/primitives/Graphics', function () { + 'use strict'; + + var expect = chai.expect; + var Graphics = PIXI.Graphics; + + it('Module exists', function () { + expect(Graphics).to.be.a('function'); + + expect(Graphics).itself.to.have.property('POLY', 0); + expect(Graphics).itself.to.have.property('RECT', 1); + expect(Graphics).itself.to.have.property('CIRC', 2); + expect(Graphics).itself.to.have.property('ELIP', 3); + expect(Graphics).itself.to.have.property('RREC', 4); + }); + + it('Confirm new instance', function () { + var obj = new Graphics(); + + pixi_display_DisplayObjectContainer_confirmNew(obj); + + expect(obj).to.be.an.instanceof(Graphics); + expect(obj).to.respondTo('lineStyle'); + expect(obj).to.respondTo('lineStyle'); + expect(obj).to.respondTo('moveTo'); + expect(obj).to.respondTo('lineTo'); + expect(obj).to.respondTo('beginFill'); + expect(obj).to.respondTo('endFill'); + expect(obj).to.respondTo('drawRect'); + // expect(obj).to.respondTo('drawRoundedRect'); + expect(obj).to.respondTo('drawCircle'); + expect(obj).to.respondTo('drawEllipse'); + expect(obj).to.respondTo('clear'); + + expect(obj).to.have.property('renderable', true); + expect(obj).to.have.property('fillAlpha', 1); + expect(obj).to.have.property('lineWidth', 0); + expect(obj).to.have.property('width', 0); + expect(obj).to.have.property('height', 0); + expect(obj).to.have.property('lineColor', 0); + expect(obj).to.have.deep.property('graphicsData.length', 0); + // expect(obj).to.have.deep.property('currentPath.points.length', 0); + }); +}); diff --git a/test/unit/pixi-v2/renderers/canvas/CanvasGraphics.js b/test/unit/pixi-v2/renderers/canvas/CanvasGraphics.js new file mode 100644 index 0000000..8f44472 --- /dev/null +++ b/test/unit/pixi-v2/renderers/canvas/CanvasGraphics.js @@ -0,0 +1,15 @@ +describe('renders/canvas/CanvasGraphics', function () { + 'use strict'; + + var expect = chai.expect; + var CanvasGraphics = PIXI.CanvasGraphics; + + it('Module exists', function () { + expect(CanvasGraphics).to.be.a('function'); + }); + + it('Members exist', function () { + expect(CanvasGraphics).itself.to.respondTo('renderGraphics'); + expect(CanvasGraphics).itself.to.respondTo('renderGraphicsMask'); + }); +}); diff --git a/test/unit/pixi-v2/renderers/canvas/CanvasRenderer.js b/test/unit/pixi-v2/renderers/canvas/CanvasRenderer.js new file mode 100644 index 0000000..1646444 --- /dev/null +++ b/test/unit/pixi-v2/renderers/canvas/CanvasRenderer.js @@ -0,0 +1,36 @@ +describe('renderers/canvas/CanvasRenderer', function () { + 'use strict'; + + var expect = chai.expect; + var CanvasRenderer = PIXI.CanvasRenderer; + + it('Module exists', function () { + expect(CanvasRenderer).to.be.a('function'); + }); + + describe('.autoResize', function () { + it('Should automatically resize view if enabled', function () { + var renderer = new CanvasRenderer(200, 200, { + autoResize: true + }); + + expect(renderer.view.style.width).to.equal('200px'); + }); + + it('Should not automatically resize view if disabled', function () { + var renderer = new CanvasRenderer(200, 200, { + autoResize: false + }); + + expect(renderer.view.style.width).to.equal(''); + }); + + it('Should not automatically resize view if not specified', function () { + var renderer = new CanvasRenderer(200, 200, { + resolution: 2 + }); + + expect(renderer.view.style.width).to.equal(''); + }); + }); +}); diff --git a/test/unit/pixi-v2/renderers/webgl/WebGLGraphics.js b/test/unit/pixi-v2/renderers/webgl/WebGLGraphics.js new file mode 100644 index 0000000..5867b28 --- /dev/null +++ b/test/unit/pixi-v2/renderers/webgl/WebGLGraphics.js @@ -0,0 +1,20 @@ +describe('renderers/wegbl/WebGLGraphics', function () { + 'use strict'; + + var expect = chai.expect; + var WebGLGraphics = PIXI.WebGLGraphics; + + it('Module exists', function () { + expect(WebGLGraphics).to.be.a('function'); + }); + + it('Members exist', function () { + expect(WebGLGraphics).itself.to.respondTo('renderGraphics'); + expect(WebGLGraphics).itself.to.respondTo('updateGraphics'); + expect(WebGLGraphics).itself.to.respondTo('buildRectangle'); + expect(WebGLGraphics).itself.to.respondTo('buildRoundedRectangle'); + expect(WebGLGraphics).itself.to.respondTo('buildCircle'); + expect(WebGLGraphics).itself.to.respondTo('buildLine'); + expect(WebGLGraphics).itself.to.respondTo('buildPoly'); + }); +}); diff --git a/test/unit/pixi-v2/renderers/webgl/WebGLRenderer.js b/test/unit/pixi-v2/renderers/webgl/WebGLRenderer.js new file mode 100644 index 0000000..1680a80 --- /dev/null +++ b/test/unit/pixi-v2/renderers/webgl/WebGLRenderer.js @@ -0,0 +1,49 @@ +describe('renderers/webgl/WebGLRenderer', function () { + 'use strict'; + + var expect = chai.expect; + var WebGLRenderer = PIXI.WebGLRenderer; + + it('Module exists', function () { + expect(WebGLRenderer).to.be.a('function'); + }); + + // Skip tests if WebGL is not available (WebGL not supported in Travis CI) + try { + var renderer = new WebGLRenderer(400, 300, {}); + renderer.destroy(); + } catch (error) { + return; + } + + it('Destroy renderer', function () { + var renderer = new WebGLRenderer(400, 300, {}); + renderer.destroy(); + }); + + describe('.autoResize', function () { + it('Should automatically resize view if enabled', function () { + var renderer = new WebGLRenderer(200, 200, { + autoResize: true + }); + + expect(renderer.view.style.width).to.equal('200px'); + }); + + it('Should not automatically resize view if disabled', function () { + var renderer = new WebGLRenderer(200, 200, { + autoResize: false + }); + + expect(renderer.view.style.width).to.equal(''); + }); + + it('Should not automatically resize view if not specified', function () { + var renderer = new WebGLRenderer(200, 200, { + resolution: 2 + }); + + expect(renderer.view.style.width).to.equal(''); + }); + }); +}); diff --git a/test/unit/pixi-v2/renderers/webgl/WebGLShaders.js b/test/unit/pixi-v2/renderers/webgl/WebGLShaders.js new file mode 100644 index 0000000..6e33e4f --- /dev/null +++ b/test/unit/pixi-v2/renderers/webgl/WebGLShaders.js @@ -0,0 +1,13 @@ +describe('renderers/webgl/WebGLShaders', function () { + 'use strict'; + + var expect = chai.expect; + + it('Module members exist', function () { + + expect(PIXI).to.respondTo('CompileVertexShader'); + expect(PIXI).to.respondTo('CompileFragmentShader'); + expect(PIXI).to.respondTo('_CompileShader'); + expect(PIXI).to.respondTo('compileProgram'); + }); +}); diff --git a/test/unit/pixi-v2/renderers/webgl/WebGLSpriteBatch.js b/test/unit/pixi-v2/renderers/webgl/WebGLSpriteBatch.js new file mode 100644 index 0000000..e662b63 --- /dev/null +++ b/test/unit/pixi-v2/renderers/webgl/WebGLSpriteBatch.js @@ -0,0 +1,10 @@ +describe('renderers/webgl/utils/WebGLSpriteBatch', function () { + 'use strict'; + + var expect = chai.expect; + var WebGLSpriteBatch = PIXI.WebGLSpriteBatch; + + it('Module exists', function () { + expect(WebGLSpriteBatch).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/text/BitmapText.js b/test/unit/pixi-v2/text/BitmapText.js new file mode 100644 index 0000000..9388e3d --- /dev/null +++ b/test/unit/pixi-v2/text/BitmapText.js @@ -0,0 +1,10 @@ +describe('pixi/text/BitmapText', function () { + 'use strict'; + + var expect = chai.expect; + var BitmapText = PIXI.BitmapText; + + it('Module exists', function () { + expect(BitmapText).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/text/Text.js b/test/unit/pixi-v2/text/Text.js new file mode 100644 index 0000000..9bc9ac5 --- /dev/null +++ b/test/unit/pixi-v2/text/Text.js @@ -0,0 +1,10 @@ +describe('pixi/text/Text', function () { + 'use strict'; + + var expect = chai.expect; + var Text = PIXI.Text; + + it('Module exists', function () { + expect(Text).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/textures/BaseTexture.js b/test/unit/pixi-v2/textures/BaseTexture.js new file mode 100644 index 0000000..502b724 --- /dev/null +++ b/test/unit/pixi-v2/textures/BaseTexture.js @@ -0,0 +1,11 @@ +describe('pixi/textures/BaseTexture', function () { + 'use strict'; + + var expect = chai.expect; + var BaseTexture = PIXI.BaseTexture; + + it('Module exists', function () { + expect(BaseTexture).to.be.a('function'); + expect(PIXI).to.have.property('BaseTextureCache').and.to.be.an('object'); + }); +}); diff --git a/test/unit/pixi-v2/textures/RenderTexture.js b/test/unit/pixi-v2/textures/RenderTexture.js new file mode 100644 index 0000000..96acdb4 --- /dev/null +++ b/test/unit/pixi-v2/textures/RenderTexture.js @@ -0,0 +1,15 @@ +describe('pixi/textures/RenderTexture', function () { + 'use strict'; + + var expect = chai.expect; + var RenderTexture = PIXI.RenderTexture; + + it('Module exists', function () { + expect(RenderTexture).to.be.a('function'); + }); + + it('Confirm new instance', function (done) { + var texture = new RenderTexture(100, 100, new PIXI.CanvasRenderer()); + pixi_textures_RenderTexture_confirmNew(texture, done); + }); +}); diff --git a/test/unit/pixi-v2/textures/Texture.js b/test/unit/pixi-v2/textures/Texture.js new file mode 100644 index 0000000..090f64d --- /dev/null +++ b/test/unit/pixi-v2/textures/Texture.js @@ -0,0 +1,26 @@ +describe('pixi/textures/Texture', function () { + 'use strict'; + + var expect = chai.expect; + var Texture = PIXI.Texture; + + it('Module exists', function () { + expect(Texture).to.be.a('function'); + expect(PIXI).to.have.property('TextureCache').and.to.be.an('object'); + }); + + it('Members exist', function () { + expect(Texture).itself.to.respondTo('fromImage'); + expect(Texture).itself.to.respondTo('fromFrame'); + expect(Texture).itself.to.respondTo('fromCanvas'); + expect(Texture).itself.to.respondTo('addTextureToCache'); + expect(Texture).itself.to.respondTo('removeTextureFromCache'); + + // expect(Texture).itself.to.have.deep.property('frameUpdates.length', 0); + }); + + it('Confirm new instance', function (done) { + var texture = Texture.fromImage('/base/test/textures/bunny.png'); + pixi_textures_Texture_confirmNew(texture, done); + }); +}); diff --git a/test/unit/pixi-v2/utils/Detector.js b/test/unit/pixi-v2/utils/Detector.js new file mode 100644 index 0000000..4cf6008 --- /dev/null +++ b/test/unit/pixi-v2/utils/Detector.js @@ -0,0 +1,10 @@ +describe('pixi/utils/Detector', function () { + 'use strict'; + + var expect = chai.expect; + var autoDetectRenderer = PIXI.autoDetectRenderer; + + it('Module exists', function () { + expect(autoDetectRenderer).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/utils/EventTarget.js b/test/unit/pixi-v2/utils/EventTarget.js new file mode 100644 index 0000000..1cfc3a4 --- /dev/null +++ b/test/unit/pixi-v2/utils/EventTarget.js @@ -0,0 +1,361 @@ +describe('pixi/utils/EventTarget', function () { + 'use strict'; + + var expect = chai.expect; + + var Clazz, PClazz, obj, pobj, obj2; + beforeEach(function () { + Clazz = function () {}; + PClazz = function () {}; + + PIXI.EventTarget.mixin(Clazz.prototype); + PIXI.EventTarget.mixin(PClazz.prototype); + + obj = new Clazz(); + obj2 = new Clazz(); + pobj = new PClazz(); + + obj.parent = pobj; + obj2.parent = obj; + }); + + it('Module exists', function () { + expect(PIXI.EventTarget).to.be.an('object'); + }); + + it('Confirm new instance', function () { + pixi_utils_EventTarget_confirm(obj); + }); + + it('simple on/emit case works', function () { + var myData = {}; + + obj.on('myevent', function (event) { + pixi_utils_EventTarget_Event_confirm(event, obj, myData); + }); + + obj.emit('myevent', myData); + }); + + it('simple once case works', function () { + var called = 0; + + obj.once('myevent', function() { called++; }); + + obj.emit('myevent'); + obj.emit('myevent'); + obj.emit('myevent'); + obj.emit('myevent'); + obj.emit('myevent'); + + expect(called).to.equal(1); + }); + + it('simple off case works', function (done) { + function onMyEvent() { + done(new Error('Event listener should not have been called')); + } + + obj.on('myevent', onMyEvent); + obj.off('myevent', onMyEvent); + obj.emit('myevent'); + + done(); + }); + + it('simple propagation case works', function (done) { + var myData = {}; + + pobj.on('myevent', function () { + done(); + }); + + obj.emit('myevent'); + }); + + it('simple stopPropagation case works', function (done) { + var myData = {}; + + pobj.on('myevent', function () { + done(new Error('Event listener should not have been called on the parent element')); + }); + + obj.on('myevent', function (evt) { + evt.stopPropagation(); + }); + + obj.emit('myevent'); + + done(); + }); + + it('simple stopImmediatePropagation case works', function (done) { + var myData = {}; + + pobj.on('myevent', function () { + done(new Error('Event listener should not have been called on the parent')); + }); + + obj.on('myevent', function (evt) { + evt.stopImmediatePropagation(); + }); + + obj.on('myevent', function () { + done(new Error('Event listener should not have been called on the second')); + }); + + obj.emit('myevent'); + + done(); + }); + + it('multiple dispatches work properly', function () { + var called = 0; + + function onMyEvent() { + called++; + } + + obj.on('myevent', onMyEvent); + obj.emit('myevent'); + obj.emit('myevent'); + obj.emit('myevent'); + obj.emit('myevent'); + + expect(called).to.equal(4); + }); + + it('multiple events work properly', function () { + var called = 0; + + function onMyEvent() { + called++; + } + + obj.on('myevent1', onMyEvent); + obj.on('myevent2', onMyEvent); + obj.on('myevent3', onMyEvent); + obj.emit('myevent1'); + obj.emit('myevent2'); + obj.emit('myevent3'); + + expect(called).to.equal(3); + }); + + it('multiple events one removed works properly', function () { + var called = 0; + + function onMyEvent() { + called++; + } + + obj.on('myevent1', onMyEvent); + obj.on('myevent2', onMyEvent); + obj.on('myevent3', onMyEvent); + + obj.emit('myevent1'); + obj.emit('myevent2'); + obj.emit('myevent3'); + + obj.off('myevent2', onMyEvent); + + obj.emit('myevent1'); + obj.emit('myevent2'); + obj.emit('myevent3'); + + expect(called).to.equal(5); + }); + + it('multiple handlers for one event with some removed', function () { + var called = 0; + + var onMyEvent = function () { + called++; + }, + onMyEvent2 = function () { + called++; + }; + + // add 2 handlers and confirm they both get called + obj.on('myevent', onMyEvent); + obj.on('myevent', onMyEvent); + obj.on('myevent', onMyEvent2); + obj.on('myevent', onMyEvent2); + + obj.emit('myevent'); + + expect(called).to.equal(4); + + // remove one of the handlers, emit again, then ensure 1 more call is made + obj.off('myevent', onMyEvent); + + obj.emit('myevent'); + + expect(called).to.equal(6); + }); + + it('calls to off without a handler do nothing', function () { + var called = 0; + + var onMyEvent = function () { + called++; + }; + + obj.on('myevent', onMyEvent); + obj.on('myevent', onMyEvent); + + obj.emit('myevent'); + + expect(called).to.equal(2); + + obj.off('myevent'); + + obj.emit('myevent'); + + expect(called).to.equal(4); + + obj.off('myevent', onMyEvent); + + obj.emit('myevent'); + + expect(called).to.equal(4); + }); + + it('handles multiple instances with the same prototype', function () { + var called = 0; + + function onMyEvent(e) { + called++; + } + + obj.on('myevent1', onMyEvent); + obj.on('myevent2', onMyEvent); + + obj2.istwo = true; + obj2.on('myevent1', onMyEvent); + obj2.on('myevent2', onMyEvent); + + obj.emit('myevent1'); + obj.emit('myevent2'); + obj2.emit('myevent1'); + obj2.emit('myevent2'); + + //we emit 4 times, but since obj2 is a child of obj the event should bubble + //up to obj and show up there as well. So the obj2.emit() calls each increment + //the counter twice. + expect(called).to.equal(6); + }); + + it('is backwards compatible with older .dispatchEvent({})', function () { + var called = 0, + data = { + some: 'thing', + hello: true + }; + + function onMyEvent(event) { + pixi_utils_EventTarget_Event_confirm(event, obj, data); + + called++; + } + + obj.on('myevent1', onMyEvent); + obj.on('myevent2', onMyEvent); + obj.on('myevent3', onMyEvent); + + data.type = 'myevent1'; + obj.emit(data); + + data.type = 'myevent2'; + obj.emit(data); + + data.type = 'myevent3'; + obj.emit(data); + + obj.off('myevent2', onMyEvent); + + data.type = 'myevent1'; + obj.emit(data); + + data.type = 'myevent2'; + obj.emit(data); + + data.type = 'myevent3'; + obj.emit(data); + + expect(called).to.equal(5); + }); + + it('is backwards compatible with older .call(this)', function () { + var Fn = function() { + PIXI.EventTarget.call(this); + }, + o = new Fn(); + + pixi_utils_EventTarget_confirm(o); + }); + + it('is backwards compatible with older .addEventListener("")', function () { + var called = 0, + data = { + some: 'thing', + hello: true + }; + + function onMyEvent(event) { + pixi_utils_EventTarget_Event_confirm(event, obj, data); + + called++; + } + + obj.addEventListener('myevent1', onMyEvent); + obj.addEventListener('myevent2', onMyEvent); + obj.addEventListener('myevent3', onMyEvent); + + data.type = 'myevent1'; + obj.emit(data); + + data.type = 'myevent2'; + obj.emit(data); + + data.type = 'myevent3'; + obj.emit(data); + + obj.off('myevent2', onMyEvent); + + data.type = 'myevent1'; + obj.emit(data); + + data.type = 'myevent2'; + obj.emit(data); + + data.type = 'myevent3'; + obj.emit(data); + + expect(called).to.equal(5); + }); + + it('event remove during emit call properly', function () { + var called = 0; + + function cb1() { + called++; + obj.off('myevent', cb1); + } + function cb2() { + called++; + obj.off('myevent', cb2); + } + function cb3() { + called++; + obj.off('myevent', cb3); + } + + obj.on('myevent', cb1); + obj.on('myevent', cb2); + obj.on('myevent', cb3); + obj.emit('myevent', ''); + + expect(called).to.equal(3); + }); +}); diff --git a/test/unit/pixi-v2/utils/Polyk.js b/test/unit/pixi-v2/utils/Polyk.js new file mode 100644 index 0000000..dfc7128 --- /dev/null +++ b/test/unit/pixi-v2/utils/Polyk.js @@ -0,0 +1,14 @@ +describe('pixi/utils/Polyk', function () { + 'use strict'; + + var expect = chai.expect; + var PolyK = PIXI.PolyK; + + it('Module exists', function () { + expect(PolyK).to.be.an('object'); + }); + + it('Members exist', function () { + expect(PolyK).to.respondTo('Triangulate'); + }); +}); diff --git a/test/unit/pixi-v2/utils/Utils.js b/test/unit/pixi-v2/utils/Utils.js new file mode 100644 index 0000000..c97b3c6 --- /dev/null +++ b/test/unit/pixi-v2/utils/Utils.js @@ -0,0 +1,17 @@ +describe('Utils', function () { + 'use strict'; + + var expect = chai.expect; + + it('requestAnimationFrame exists', function () { + expect(global).to.respondTo('requestAnimationFrame'); + }); + + it('cancelAnimationFrame exists', function () { + expect(global).to.respondTo('cancelAnimationFrame'); + }); + + it('requestAnimFrame exists', function () { + expect(global).to.respondTo('requestAnimFrame'); + }); +}); diff --git a/test/unit/pixi/InteractionManager.js b/test/unit/pixi/InteractionManager.js deleted file mode 100644 index ed3001f..0000000 --- a/test/unit/pixi/InteractionManager.js +++ /dev/null @@ -1,10 +0,0 @@ -describe('pixi/InteractionManager', function () { - 'use strict'; - - var expect = chai.expect; - var InteractionManager = PIXI.InteractionManager; - - it('Module exists', function () { - expect(InteractionManager).to.be.a('function'); - }); -}); diff --git a/test/unit/pixi/Pixi.js b/test/unit/pixi/Pixi.js deleted file mode 100644 index 27debc1..0000000 --- a/test/unit/pixi/Pixi.js +++ /dev/null @@ -1,9 +0,0 @@ -describe('pixi/Pixi', function () { - 'use strict'; - - var expect = chai.expect; - - it('Module exists', function () { - expect(global).to.have.property('PIXI').and.to.be.an('object'); - }); -}); diff --git a/test/unit/pixi/core/Circle.js b/test/unit/pixi/core/Circle.js deleted file mode 100644 index fbcfa17..0000000 --- a/test/unit/pixi/core/Circle.js +++ /dev/null @@ -1,21 +0,0 @@ -describe('pixi/core/Circle', function () { - 'use strict'; - - var expect = chai.expect; - var Circle = PIXI.Circle; - - it('Module exists', function () { - expect(Circle).to.be.a('function'); - }); - - it('Confirm new instance', function () { - var obj = new Circle(); - pixi_core_Circle_confirmNewCircle(obj); - }); - - it("getBounds should return Rectangle that bounds the circle", function() { - var obj = new Circle(100, 250, 50); - var bounds = obj.getBounds(); - pixi_core_Circle_isBoundedByRectangle(obj, bounds); - }); -}); diff --git a/test/unit/pixi/core/Ellipse.js b/test/unit/pixi/core/Ellipse.js deleted file mode 100644 index 026b56f..0000000 --- a/test/unit/pixi/core/Ellipse.js +++ /dev/null @@ -1,24 +0,0 @@ -describe('pixi/core/Ellipse', function () { - 'use strict'; - - var expect = chai.expect; - var Ellipse = PIXI.Ellipse; - - it('Module exists', function () { - expect(Ellipse).to.be.a('function'); - }); - - it('Confirm new instance', function () { - var obj = new Ellipse(); - - expect(obj).to.be.an.instanceof(Ellipse); - expect(obj).to.respondTo('clone'); - expect(obj).to.respondTo('contains'); - expect(obj).to.respondTo('getBounds'); - - expect(obj).to.have.property('x', 0); - expect(obj).to.have.property('y', 0); - expect(obj).to.have.property('width', 0); - expect(obj).to.have.property('height', 0); - }); -}); diff --git a/test/unit/pixi/core/Matrix.js b/test/unit/pixi/core/Matrix.js deleted file mode 100644 index da75e2e..0000000 --- a/test/unit/pixi/core/Matrix.js +++ /dev/null @@ -1,14 +0,0 @@ -describe('pixi/core/Matrix', function () { - 'use strict'; - - var expect = chai.expect; - - it('Matrix exists', function () { - expect(PIXI.Matrix).to.be.an('function'); - }); - - it('Confirm new Matrix', function () { - var matrix = new PIXI.Matrix(); - pixi_core_Matrix_confirmNewMatrix(matrix); - }); -}); diff --git a/test/unit/pixi/core/Point.js b/test/unit/pixi/core/Point.js deleted file mode 100644 index c4d5163..0000000 --- a/test/unit/pixi/core/Point.js +++ /dev/null @@ -1,15 +0,0 @@ -describe('pixi/core/Point', function () { - 'use strict'; - - var expect = chai.expect; - var Point = PIXI.Point; - - it('Module exists', function () { - expect(Point).to.be.a('function'); - }); - - it('Confirm new instance', function () { - var obj = new Point(); - pixi_core_Point_confirm(obj, 0, 0); - }); -}); diff --git a/test/unit/pixi/core/Polygon.js b/test/unit/pixi/core/Polygon.js deleted file mode 100644 index dc8c918..0000000 --- a/test/unit/pixi/core/Polygon.js +++ /dev/null @@ -1,20 +0,0 @@ -describe('pixi/core/Polygon', function () { - 'use strict'; - - var expect = chai.expect; - var Polygon = PIXI.Polygon; - - it('Module exists', function () { - expect(Polygon).to.be.a('function'); - }); - - it('Confirm new instance', function () { - var obj = new Polygon(); - - expect(obj).to.be.an.instanceof(Polygon); - expect(obj).to.respondTo('clone'); - expect(obj).to.respondTo('contains'); - - expect(obj).to.have.deep.property('points.length', 0); - }); -}); diff --git a/test/unit/pixi/core/Rectangle.js b/test/unit/pixi/core/Rectangle.js deleted file mode 100644 index d43316e..0000000 --- a/test/unit/pixi/core/Rectangle.js +++ /dev/null @@ -1,15 +0,0 @@ -describe('pixi/core/Rectangle', function () { - 'use strict'; - - var expect = chai.expect; - var Rectangle = PIXI.Rectangle; - - it('Module exists', function () { - expect(Rectangle).to.be.a('function'); - }); - - it('Confirm new instance', function () { - var rect = new Rectangle(); - pixi_core_Rectangle_confirm(rect, 0, 0, 0, 0); - }); -}); diff --git a/test/unit/pixi/display/DisplayObject.js b/test/unit/pixi/display/DisplayObject.js deleted file mode 100644 index 044acf8..0000000 --- a/test/unit/pixi/display/DisplayObject.js +++ /dev/null @@ -1,21 +0,0 @@ -describe('pixi/display/DisplayObject', function () { - 'use strict'; - - var expect = chai.expect; - var DisplayObject = PIXI.DisplayObject; - - it('Module exists', function () { - expect(DisplayObject).to.be.a('function'); - // expect(PIXI).to.have.property('visibleCount', 0); - }); - - it('Confirm new instance', function () { - var obj = new DisplayObject(); - - pixi_display_DisplayObject_confirmNew(obj); - expect(obj).to.have.property('hitArea', null); - expect(obj).to.have.property('interactive', false); - expect(obj).to.have.property('renderable', false); - expect(obj).to.have.property('stage', null); - }); -}); diff --git a/test/unit/pixi/display/DisplayObjectContainer.js b/test/unit/pixi/display/DisplayObjectContainer.js deleted file mode 100644 index 15a3376..0000000 --- a/test/unit/pixi/display/DisplayObjectContainer.js +++ /dev/null @@ -1,67 +0,0 @@ -describe('pixi/display/DisplayObjectContainer', function () { - 'use strict'; - - var expect = chai.expect; - var DisplayObjectContainer = PIXI.DisplayObjectContainer; - - it('Module exists', function () { - expect(DisplayObjectContainer).to.be.a('function'); - }); - - it('Confirm new instance', function () { - var obj = new DisplayObjectContainer(); - - pixi_display_DisplayObjectContainer_confirmNew(obj); - expect(obj).to.have.property('hitArea', null); - expect(obj).to.have.property('interactive', false); - expect(obj).to.have.property('renderable', false); - expect(obj).to.have.property('stage', null); - }); - - it('Gets child index', function() { - var container = new PIXI.DisplayObjectContainer(); - var children = []; - for (var i = 0; i < 10; i++) { - var child = new PIXI.DisplayObject(); - children.push(child); - container.addChild(child); - } - - for (i = 0; i < children.length; i++) { - expect(i).to.eql(container.getChildIndex(children[i])); - } - }); - - it('throws error when trying to get index of not a child', function() { - var container = new PIXI.DisplayObjectContainer(); - var child = new PIXI.DisplayObject(); - - expect(function() { container.getChildIndex(child); }).to.throw(); - }); - - it('Sets child index', function() { - var container = new PIXI.DisplayObjectContainer(); - var children = []; - - for (var i = 0; i < 10; i++) { - var child = new PIXI.DisplayObject(); - children.push(child); - container.addChild(child); - } - children.reverse(); - - for (i = 0; i < children.length; i++) { - container.setChildIndex(children[i], i); - expect(i).to.eql(container.getChildIndex(children[i])); - } - }); - - it('throws error when trying to set incorect index', function() { - var container = new PIXI.DisplayObjectContainer(); - var child = new PIXI.DisplayObject(); - container.addChild(child); - - expect(function() { container.setChildIndex(child, -1); }).to.throw(); - expect(function() { container.setChildIndex(child, 1); }).to.throw(); - }); -}); diff --git a/test/unit/pixi/display/MovieClip.js b/test/unit/pixi/display/MovieClip.js deleted file mode 100644 index f3c6c6a..0000000 --- a/test/unit/pixi/display/MovieClip.js +++ /dev/null @@ -1,33 +0,0 @@ -describe('pixi/display/MovieClip', function () { - 'use strict'; - - var expect = chai.expect; - var MovieClip = PIXI.MovieClip; - var Texture = PIXI.Texture; - - it('Module exists', function () { - expect(MovieClip).to.be.a('function'); - }); - - it('Confirm new instance', function (done) { - var texture = Texture.fromImage('/base/test/textures/SpriteSheet-Explosion.png'); - var obj = new MovieClip([texture]); - - pixi_display_Sprite_confirmNew(obj, done); - - expect(obj).to.be.an.instanceof(MovieClip); - expect(obj).to.respondTo('stop'); - expect(obj).to.respondTo('play'); - expect(obj).to.respondTo('gotoAndStop'); - expect(obj).to.respondTo('gotoAndPlay'); - expect(obj).to.respondTo('updateTransform'); - - expect(obj).to.have.deep.property('textures.length', 1); - expect(obj).to.have.deep.property('textures[0]', texture); - expect(obj).to.have.property('animationSpeed', 1); - expect(obj).to.have.property('loop', true); - expect(obj).to.have.property('onComplete', null); - expect(obj).to.have.property('currentFrame', 0); - expect(obj).to.have.property('playing', false); - }); -}); diff --git a/test/unit/pixi/display/Sprite.js b/test/unit/pixi/display/Sprite.js deleted file mode 100644 index 30c8076..0000000 --- a/test/unit/pixi/display/Sprite.js +++ /dev/null @@ -1,28 +0,0 @@ -describe('pixi/display/Sprite', function () { - 'use strict'; - - var expect = chai.expect; - var Sprite = PIXI.Sprite; - var Texture = PIXI.Texture; - - it('Module exists', function () { - expect(Sprite).to.be.a('function'); - expect(PIXI).to.have.deep.property('blendModes.NORMAL', 0); - expect(PIXI).to.have.deep.property('blendModes.ADD', 1); - expect(PIXI).to.have.deep.property('blendModes.MULTIPLY', 2); - expect(PIXI).to.have.deep.property('blendModes.SCREEN', 3); - }); - - - it('Members exist', function () { - expect(Sprite).itself.to.respondTo('fromImage'); - expect(Sprite).itself.to.respondTo('fromFrame'); - }); - - it('Confirm new instance', function (done) { - var texture = Texture.fromImage('/base/test/textures/SpriteSheet-Aliens.png'); - var obj = new Sprite(texture); - - pixi_display_Sprite_confirmNew(obj, done); - }); -}); diff --git a/test/unit/pixi/display/Stage.js b/test/unit/pixi/display/Stage.js deleted file mode 100644 index 6974c2e..0000000 --- a/test/unit/pixi/display/Stage.js +++ /dev/null @@ -1,49 +0,0 @@ -describe('pixi/display/Stage', function () { - 'use strict'; - - var expect = chai.expect; - var Stage = PIXI.Stage; - var InteractionManager = PIXI.InteractionManager; - var Rectangle = PIXI.Rectangle; - - it('Module exists', function () { - expect(Stage).to.be.a('function'); - }); - - it('Confirm new instance', function () { - var obj = new Stage(null, true); - - pixi_display_DisplayObjectContainer_confirmNew(obj); - - expect(obj).to.be.an.instanceof(Stage); - expect(obj).to.respondTo('updateTransform'); - expect(obj).to.respondTo('setBackgroundColor'); - expect(obj).to.respondTo('getMousePosition'); - // FIXME: duplicate member in DisplayObject - pixi_core_Matrix_confirmNewMatrix(obj.worldTransform); - // FIXME: convert arg to bool in constructor - expect(obj).to.have.property('interactive', true); - - expect(obj).to.have.property('interactionManager') - .and.to.be.an.instanceof(InteractionManager) - .and.to.have.property('stage', obj); - - expect(obj).to.have.property('dirty', true); - - expect(obj).to.have.property('stage', obj); - - expect(obj).to.have.property('hitArea') - .and.to.be.an.instanceof(Rectangle); - pixi_core_Rectangle_confirm(obj.hitArea, 0, 0, 100000, 100000); - - expect(obj).to.have.property('backgroundColor', 0x000000); - expect(obj).to.have.deep.property('backgroundColorSplit.length', 3); - expect(obj).to.have.deep.property('backgroundColorSplit[0]', 0); - expect(obj).to.have.deep.property('backgroundColorSplit[1]', 0); - expect(obj).to.have.deep.property('backgroundColorSplit[2]', 0); - expect(obj).to.have.property('backgroundColorString', '#000000'); - - - expect(obj).to.have.property('worldVisible', true); - }); -}); diff --git a/test/unit/pixi/extras/Rope.js b/test/unit/pixi/extras/Rope.js deleted file mode 100644 index 05885ac..0000000 --- a/test/unit/pixi/extras/Rope.js +++ /dev/null @@ -1,31 +0,0 @@ -describe('pixi/extras/Rope', function () { - 'use strict'; - - var expect = chai.expect; - var Rope = PIXI.Rope; - var Texture = PIXI.Texture; - var Point = PIXI.Point; - - it('Module exists', function () { - expect(Rope).to.be.a('function'); - }); - - it('Confirm new instance', function () { - - var texture = Texture.fromImage('/base/test/textures/bunny.png'); - - // TODO-Alvin - // Same as Strip - - // var obj = new Rope(texture, [new Point(), new Point(5, 10), new Point(10, 20)]); - - // pixi_extras_Strip_confirmNew(obj); - - // expect(obj).to.be.an.instanceof(Rope); - // expect(obj).to.respondTo('refresh'); - // expect(obj).to.respondTo('updateTransform'); - // expect(obj).to.respondTo('setTexture'); - - // TODO: Test properties - }); -}); diff --git a/test/unit/pixi/extras/Spine.js b/test/unit/pixi/extras/Spine.js deleted file mode 100644 index 0708bc0..0000000 --- a/test/unit/pixi/extras/Spine.js +++ /dev/null @@ -1,10 +0,0 @@ -describe('pixi/extras/Spine', function () { - 'use strict'; - - var expect = chai.expect; - var Spine = PIXI.Spine; - - it('Module exists', function () { - expect(Spine).to.be.a('function'); - }); -}); diff --git a/test/unit/pixi/extras/Strip.js b/test/unit/pixi/extras/Strip.js deleted file mode 100644 index 230af90..0000000 --- a/test/unit/pixi/extras/Strip.js +++ /dev/null @@ -1,26 +0,0 @@ -describe('pixi/extras/Strip', function () { - 'use strict'; - - var expect = chai.expect; - var Strip = PIXI.Strip; - var Texture = PIXI.Texture; - - it('Module exists', function () { - expect(Strip).to.be.a('function'); - }); - - it('Confirm new instance', function () { - - - // TODO-Alvin - // We tweaked it to make it pass the tests, but the whole strip class needs - // to be re-coded - - var texture = Texture.fromImage('/base/test/textures/bunny.png'); - - // var obj = new Strip(texture, 20, 10000); - - - // pixi_extras_Strip_confirmNew(obj); - }); -}); diff --git a/test/unit/pixi/extras/TilingSprite.js b/test/unit/pixi/extras/TilingSprite.js deleted file mode 100644 index 56aea14..0000000 --- a/test/unit/pixi/extras/TilingSprite.js +++ /dev/null @@ -1,24 +0,0 @@ -describe('pixi/extras/TilingSprite', function () { - 'use strict'; - - var expect = chai.expect; - var TilingSprite = PIXI.TilingSprite; - var Texture = PIXI.Texture; - - it('Module exists', function () { - expect(TilingSprite).to.be.a('function'); - }); - - it('Confirm new instance', function () { - var texture = Texture.fromImage('/base/test/textures/bunny.png'); - var obj = new TilingSprite(texture, 6000, 12000); - - pixi_display_DisplayObjectContainer_confirmNew(obj); - - expect(obj).to.be.an.instanceof(TilingSprite); - expect(obj).to.respondTo('setTexture'); - expect(obj).to.respondTo('onTextureUpdate'); - - // TODO: Test properties - }); -}); diff --git a/test/unit/pixi/filters/FilterBlock.js b/test/unit/pixi/filters/FilterBlock.js deleted file mode 100644 index 870cec0..0000000 --- a/test/unit/pixi/filters/FilterBlock.js +++ /dev/null @@ -1,10 +0,0 @@ -describe('pixi/filters/FilterBlock', function () { - 'use strict'; - - var expect = chai.expect; - var FilterBlock = PIXI.FilterBlock; - - it('Module exists', function () { - expect(FilterBlock).to.be.a('function'); - }); -}); diff --git a/test/unit/pixi/loaders/AssetLoader.js b/test/unit/pixi/loaders/AssetLoader.js deleted file mode 100644 index a0aa0b5..0000000 --- a/test/unit/pixi/loaders/AssetLoader.js +++ /dev/null @@ -1,10 +0,0 @@ -describe('pixi/loaders/AssetLoader', function () { - 'use strict'; - - var expect = chai.expect; - var AssetLoader = PIXI.AssetLoader; - - it('Module exists', function () { - expect(AssetLoader).to.be.a('function'); - }); -}); diff --git a/test/unit/pixi/loaders/BitmapFontLoader.js b/test/unit/pixi/loaders/BitmapFontLoader.js deleted file mode 100644 index 046f018..0000000 --- a/test/unit/pixi/loaders/BitmapFontLoader.js +++ /dev/null @@ -1,9 +0,0 @@ -describe('pixi/loaders/BitmapFontLoader', function () { - 'use strict'; - - var expect = chai.expect; - - it('Module exists', function () { - expect(PIXI.BitmapFontLoader).to.be.a('function'); - }); -}); diff --git a/test/unit/pixi/loaders/ImageLoader.js b/test/unit/pixi/loaders/ImageLoader.js deleted file mode 100644 index 8b1f556..0000000 --- a/test/unit/pixi/loaders/ImageLoader.js +++ /dev/null @@ -1,10 +0,0 @@ -describe('pixi/loaders/ImageLoader', function () { - 'use strict'; - - var expect = chai.expect; - var ImageLoader = PIXI.ImageLoader; - - it('Module exists', function () { - expect(ImageLoader).to.be.a('function'); - }); -}); diff --git a/test/unit/pixi/loaders/JsonLoader.js b/test/unit/pixi/loaders/JsonLoader.js deleted file mode 100644 index c577e83..0000000 --- a/test/unit/pixi/loaders/JsonLoader.js +++ /dev/null @@ -1,10 +0,0 @@ -describe('pixi/loaders/JsonLoader', function () { - 'use strict'; - - var expect = chai.expect; - var JsonLoader = PIXI.JsonLoader; - - it('Module exists', function () { - expect(JsonLoader).to.be.a('function'); - }); -}); diff --git a/test/unit/pixi/loaders/SpineLoader.js b/test/unit/pixi/loaders/SpineLoader.js deleted file mode 100644 index fdcc0b8..0000000 --- a/test/unit/pixi/loaders/SpineLoader.js +++ /dev/null @@ -1,10 +0,0 @@ -describe('pixi/loaders/SpineLoader', function () { - 'use strict'; - - var expect = chai.expect; - var SpineLoader = PIXI.SpineLoader; - - it('Module exists', function () { - expect(SpineLoader).to.be.a('function'); - }); -}); diff --git a/test/unit/pixi/loaders/SpriteSheetLoader.js b/test/unit/pixi/loaders/SpriteSheetLoader.js deleted file mode 100644 index 57beb27..0000000 --- a/test/unit/pixi/loaders/SpriteSheetLoader.js +++ /dev/null @@ -1,10 +0,0 @@ -describe('pixi/loaders/SpriteSheetLoader', function () { - 'use strict'; - - var expect = chai.expect; - var SpriteSheetLoader = PIXI.SpriteSheetLoader; - - it('Module exists', function () { - expect(SpriteSheetLoader).to.be.a('function'); - }); -}); diff --git a/test/unit/pixi/primitives/Graphics.js b/test/unit/pixi/primitives/Graphics.js deleted file mode 100644 index f3849eb..0000000 --- a/test/unit/pixi/primitives/Graphics.js +++ /dev/null @@ -1,44 +0,0 @@ -describe('pixi/primitives/Graphics', function () { - 'use strict'; - - var expect = chai.expect; - var Graphics = PIXI.Graphics; - - it('Module exists', function () { - expect(Graphics).to.be.a('function'); - - expect(Graphics).itself.to.have.property('POLY', 0); - expect(Graphics).itself.to.have.property('RECT', 1); - expect(Graphics).itself.to.have.property('CIRC', 2); - expect(Graphics).itself.to.have.property('ELIP', 3); - expect(Graphics).itself.to.have.property('RREC', 4); - }); - - it('Confirm new instance', function () { - var obj = new Graphics(); - - pixi_display_DisplayObjectContainer_confirmNew(obj); - - expect(obj).to.be.an.instanceof(Graphics); - expect(obj).to.respondTo('lineStyle'); - expect(obj).to.respondTo('lineStyle'); - expect(obj).to.respondTo('moveTo'); - expect(obj).to.respondTo('lineTo'); - expect(obj).to.respondTo('beginFill'); - expect(obj).to.respondTo('endFill'); - expect(obj).to.respondTo('drawRect'); - // expect(obj).to.respondTo('drawRoundedRect'); - expect(obj).to.respondTo('drawCircle'); - expect(obj).to.respondTo('drawEllipse'); - expect(obj).to.respondTo('clear'); - - expect(obj).to.have.property('renderable', true); - expect(obj).to.have.property('fillAlpha', 1); - expect(obj).to.have.property('lineWidth', 0); - expect(obj).to.have.property('width', 0); - expect(obj).to.have.property('height', 0); - expect(obj).to.have.property('lineColor', 0); - expect(obj).to.have.deep.property('graphicsData.length', 0); - // expect(obj).to.have.deep.property('currentPath.points.length', 0); - }); -}); diff --git a/test/unit/pixi/renderers/canvas/CanvasGraphics.js b/test/unit/pixi/renderers/canvas/CanvasGraphics.js deleted file mode 100644 index 8f44472..0000000 --- a/test/unit/pixi/renderers/canvas/CanvasGraphics.js +++ /dev/null @@ -1,15 +0,0 @@ -describe('renders/canvas/CanvasGraphics', function () { - 'use strict'; - - var expect = chai.expect; - var CanvasGraphics = PIXI.CanvasGraphics; - - it('Module exists', function () { - expect(CanvasGraphics).to.be.a('function'); - }); - - it('Members exist', function () { - expect(CanvasGraphics).itself.to.respondTo('renderGraphics'); - expect(CanvasGraphics).itself.to.respondTo('renderGraphicsMask'); - }); -}); diff --git a/test/unit/pixi/renderers/canvas/CanvasRenderer.js b/test/unit/pixi/renderers/canvas/CanvasRenderer.js deleted file mode 100644 index 1646444..0000000 --- a/test/unit/pixi/renderers/canvas/CanvasRenderer.js +++ /dev/null @@ -1,36 +0,0 @@ -describe('renderers/canvas/CanvasRenderer', function () { - 'use strict'; - - var expect = chai.expect; - var CanvasRenderer = PIXI.CanvasRenderer; - - it('Module exists', function () { - expect(CanvasRenderer).to.be.a('function'); - }); - - describe('.autoResize', function () { - it('Should automatically resize view if enabled', function () { - var renderer = new CanvasRenderer(200, 200, { - autoResize: true - }); - - expect(renderer.view.style.width).to.equal('200px'); - }); - - it('Should not automatically resize view if disabled', function () { - var renderer = new CanvasRenderer(200, 200, { - autoResize: false - }); - - expect(renderer.view.style.width).to.equal(''); - }); - - it('Should not automatically resize view if not specified', function () { - var renderer = new CanvasRenderer(200, 200, { - resolution: 2 - }); - - expect(renderer.view.style.width).to.equal(''); - }); - }); -}); diff --git a/test/unit/pixi-v2/InteractionManager.js b/test/unit/pixi-v2/InteractionManager.js new file mode 100644 index 0000000..ed3001f --- /dev/null +++ b/test/unit/pixi-v2/InteractionManager.js @@ -0,0 +1,10 @@ +describe('pixi/InteractionManager', function () { + 'use strict'; + + var expect = chai.expect; + var InteractionManager = PIXI.InteractionManager; + + it('Module exists', function () { + expect(InteractionManager).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/Pixi.js b/test/unit/pixi-v2/Pixi.js new file mode 100644 index 0000000..27debc1 --- /dev/null +++ b/test/unit/pixi-v2/Pixi.js @@ -0,0 +1,9 @@ +describe('pixi/Pixi', function () { + 'use strict'; + + var expect = chai.expect; + + it('Module exists', function () { + expect(global).to.have.property('PIXI').and.to.be.an('object'); + }); +}); diff --git a/test/unit/pixi-v2/core/Circle.js b/test/unit/pixi-v2/core/Circle.js new file mode 100644 index 0000000..fbcfa17 --- /dev/null +++ b/test/unit/pixi-v2/core/Circle.js @@ -0,0 +1,21 @@ +describe('pixi/core/Circle', function () { + 'use strict'; + + var expect = chai.expect; + var Circle = PIXI.Circle; + + it('Module exists', function () { + expect(Circle).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Circle(); + pixi_core_Circle_confirmNewCircle(obj); + }); + + it("getBounds should return Rectangle that bounds the circle", function() { + var obj = new Circle(100, 250, 50); + var bounds = obj.getBounds(); + pixi_core_Circle_isBoundedByRectangle(obj, bounds); + }); +}); diff --git a/test/unit/pixi-v2/core/Ellipse.js b/test/unit/pixi-v2/core/Ellipse.js new file mode 100644 index 0000000..026b56f --- /dev/null +++ b/test/unit/pixi-v2/core/Ellipse.js @@ -0,0 +1,24 @@ +describe('pixi/core/Ellipse', function () { + 'use strict'; + + var expect = chai.expect; + var Ellipse = PIXI.Ellipse; + + it('Module exists', function () { + expect(Ellipse).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Ellipse(); + + expect(obj).to.be.an.instanceof(Ellipse); + expect(obj).to.respondTo('clone'); + expect(obj).to.respondTo('contains'); + expect(obj).to.respondTo('getBounds'); + + expect(obj).to.have.property('x', 0); + expect(obj).to.have.property('y', 0); + expect(obj).to.have.property('width', 0); + expect(obj).to.have.property('height', 0); + }); +}); diff --git a/test/unit/pixi-v2/core/Matrix.js b/test/unit/pixi-v2/core/Matrix.js new file mode 100644 index 0000000..da75e2e --- /dev/null +++ b/test/unit/pixi-v2/core/Matrix.js @@ -0,0 +1,14 @@ +describe('pixi/core/Matrix', function () { + 'use strict'; + + var expect = chai.expect; + + it('Matrix exists', function () { + expect(PIXI.Matrix).to.be.an('function'); + }); + + it('Confirm new Matrix', function () { + var matrix = new PIXI.Matrix(); + pixi_core_Matrix_confirmNewMatrix(matrix); + }); +}); diff --git a/test/unit/pixi-v2/core/Point.js b/test/unit/pixi-v2/core/Point.js new file mode 100644 index 0000000..c4d5163 --- /dev/null +++ b/test/unit/pixi-v2/core/Point.js @@ -0,0 +1,15 @@ +describe('pixi/core/Point', function () { + 'use strict'; + + var expect = chai.expect; + var Point = PIXI.Point; + + it('Module exists', function () { + expect(Point).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Point(); + pixi_core_Point_confirm(obj, 0, 0); + }); +}); diff --git a/test/unit/pixi-v2/core/Polygon.js b/test/unit/pixi-v2/core/Polygon.js new file mode 100644 index 0000000..dc8c918 --- /dev/null +++ b/test/unit/pixi-v2/core/Polygon.js @@ -0,0 +1,20 @@ +describe('pixi/core/Polygon', function () { + 'use strict'; + + var expect = chai.expect; + var Polygon = PIXI.Polygon; + + it('Module exists', function () { + expect(Polygon).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Polygon(); + + expect(obj).to.be.an.instanceof(Polygon); + expect(obj).to.respondTo('clone'); + expect(obj).to.respondTo('contains'); + + expect(obj).to.have.deep.property('points.length', 0); + }); +}); diff --git a/test/unit/pixi-v2/core/Rectangle.js b/test/unit/pixi-v2/core/Rectangle.js new file mode 100644 index 0000000..d43316e --- /dev/null +++ b/test/unit/pixi-v2/core/Rectangle.js @@ -0,0 +1,15 @@ +describe('pixi/core/Rectangle', function () { + 'use strict'; + + var expect = chai.expect; + var Rectangle = PIXI.Rectangle; + + it('Module exists', function () { + expect(Rectangle).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var rect = new Rectangle(); + pixi_core_Rectangle_confirm(rect, 0, 0, 0, 0); + }); +}); diff --git a/test/unit/pixi-v2/display/DisplayObject.js b/test/unit/pixi-v2/display/DisplayObject.js new file mode 100644 index 0000000..044acf8 --- /dev/null +++ b/test/unit/pixi-v2/display/DisplayObject.js @@ -0,0 +1,21 @@ +describe('pixi/display/DisplayObject', function () { + 'use strict'; + + var expect = chai.expect; + var DisplayObject = PIXI.DisplayObject; + + it('Module exists', function () { + expect(DisplayObject).to.be.a('function'); + // expect(PIXI).to.have.property('visibleCount', 0); + }); + + it('Confirm new instance', function () { + var obj = new DisplayObject(); + + pixi_display_DisplayObject_confirmNew(obj); + expect(obj).to.have.property('hitArea', null); + expect(obj).to.have.property('interactive', false); + expect(obj).to.have.property('renderable', false); + expect(obj).to.have.property('stage', null); + }); +}); diff --git a/test/unit/pixi-v2/display/DisplayObjectContainer.js b/test/unit/pixi-v2/display/DisplayObjectContainer.js new file mode 100644 index 0000000..15a3376 --- /dev/null +++ b/test/unit/pixi-v2/display/DisplayObjectContainer.js @@ -0,0 +1,67 @@ +describe('pixi/display/DisplayObjectContainer', function () { + 'use strict'; + + var expect = chai.expect; + var DisplayObjectContainer = PIXI.DisplayObjectContainer; + + it('Module exists', function () { + expect(DisplayObjectContainer).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new DisplayObjectContainer(); + + pixi_display_DisplayObjectContainer_confirmNew(obj); + expect(obj).to.have.property('hitArea', null); + expect(obj).to.have.property('interactive', false); + expect(obj).to.have.property('renderable', false); + expect(obj).to.have.property('stage', null); + }); + + it('Gets child index', function() { + var container = new PIXI.DisplayObjectContainer(); + var children = []; + for (var i = 0; i < 10; i++) { + var child = new PIXI.DisplayObject(); + children.push(child); + container.addChild(child); + } + + for (i = 0; i < children.length; i++) { + expect(i).to.eql(container.getChildIndex(children[i])); + } + }); + + it('throws error when trying to get index of not a child', function() { + var container = new PIXI.DisplayObjectContainer(); + var child = new PIXI.DisplayObject(); + + expect(function() { container.getChildIndex(child); }).to.throw(); + }); + + it('Sets child index', function() { + var container = new PIXI.DisplayObjectContainer(); + var children = []; + + for (var i = 0; i < 10; i++) { + var child = new PIXI.DisplayObject(); + children.push(child); + container.addChild(child); + } + children.reverse(); + + for (i = 0; i < children.length; i++) { + container.setChildIndex(children[i], i); + expect(i).to.eql(container.getChildIndex(children[i])); + } + }); + + it('throws error when trying to set incorect index', function() { + var container = new PIXI.DisplayObjectContainer(); + var child = new PIXI.DisplayObject(); + container.addChild(child); + + expect(function() { container.setChildIndex(child, -1); }).to.throw(); + expect(function() { container.setChildIndex(child, 1); }).to.throw(); + }); +}); diff --git a/test/unit/pixi-v2/display/MovieClip.js b/test/unit/pixi-v2/display/MovieClip.js new file mode 100644 index 0000000..f3c6c6a --- /dev/null +++ b/test/unit/pixi-v2/display/MovieClip.js @@ -0,0 +1,33 @@ +describe('pixi/display/MovieClip', function () { + 'use strict'; + + var expect = chai.expect; + var MovieClip = PIXI.MovieClip; + var Texture = PIXI.Texture; + + it('Module exists', function () { + expect(MovieClip).to.be.a('function'); + }); + + it('Confirm new instance', function (done) { + var texture = Texture.fromImage('/base/test/textures/SpriteSheet-Explosion.png'); + var obj = new MovieClip([texture]); + + pixi_display_Sprite_confirmNew(obj, done); + + expect(obj).to.be.an.instanceof(MovieClip); + expect(obj).to.respondTo('stop'); + expect(obj).to.respondTo('play'); + expect(obj).to.respondTo('gotoAndStop'); + expect(obj).to.respondTo('gotoAndPlay'); + expect(obj).to.respondTo('updateTransform'); + + expect(obj).to.have.deep.property('textures.length', 1); + expect(obj).to.have.deep.property('textures[0]', texture); + expect(obj).to.have.property('animationSpeed', 1); + expect(obj).to.have.property('loop', true); + expect(obj).to.have.property('onComplete', null); + expect(obj).to.have.property('currentFrame', 0); + expect(obj).to.have.property('playing', false); + }); +}); diff --git a/test/unit/pixi-v2/display/Sprite.js b/test/unit/pixi-v2/display/Sprite.js new file mode 100644 index 0000000..30c8076 --- /dev/null +++ b/test/unit/pixi-v2/display/Sprite.js @@ -0,0 +1,28 @@ +describe('pixi/display/Sprite', function () { + 'use strict'; + + var expect = chai.expect; + var Sprite = PIXI.Sprite; + var Texture = PIXI.Texture; + + it('Module exists', function () { + expect(Sprite).to.be.a('function'); + expect(PIXI).to.have.deep.property('blendModes.NORMAL', 0); + expect(PIXI).to.have.deep.property('blendModes.ADD', 1); + expect(PIXI).to.have.deep.property('blendModes.MULTIPLY', 2); + expect(PIXI).to.have.deep.property('blendModes.SCREEN', 3); + }); + + + it('Members exist', function () { + expect(Sprite).itself.to.respondTo('fromImage'); + expect(Sprite).itself.to.respondTo('fromFrame'); + }); + + it('Confirm new instance', function (done) { + var texture = Texture.fromImage('/base/test/textures/SpriteSheet-Aliens.png'); + var obj = new Sprite(texture); + + pixi_display_Sprite_confirmNew(obj, done); + }); +}); diff --git a/test/unit/pixi-v2/display/Stage.js b/test/unit/pixi-v2/display/Stage.js new file mode 100644 index 0000000..6974c2e --- /dev/null +++ b/test/unit/pixi-v2/display/Stage.js @@ -0,0 +1,49 @@ +describe('pixi/display/Stage', function () { + 'use strict'; + + var expect = chai.expect; + var Stage = PIXI.Stage; + var InteractionManager = PIXI.InteractionManager; + var Rectangle = PIXI.Rectangle; + + it('Module exists', function () { + expect(Stage).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Stage(null, true); + + pixi_display_DisplayObjectContainer_confirmNew(obj); + + expect(obj).to.be.an.instanceof(Stage); + expect(obj).to.respondTo('updateTransform'); + expect(obj).to.respondTo('setBackgroundColor'); + expect(obj).to.respondTo('getMousePosition'); + // FIXME: duplicate member in DisplayObject + pixi_core_Matrix_confirmNewMatrix(obj.worldTransform); + // FIXME: convert arg to bool in constructor + expect(obj).to.have.property('interactive', true); + + expect(obj).to.have.property('interactionManager') + .and.to.be.an.instanceof(InteractionManager) + .and.to.have.property('stage', obj); + + expect(obj).to.have.property('dirty', true); + + expect(obj).to.have.property('stage', obj); + + expect(obj).to.have.property('hitArea') + .and.to.be.an.instanceof(Rectangle); + pixi_core_Rectangle_confirm(obj.hitArea, 0, 0, 100000, 100000); + + expect(obj).to.have.property('backgroundColor', 0x000000); + expect(obj).to.have.deep.property('backgroundColorSplit.length', 3); + expect(obj).to.have.deep.property('backgroundColorSplit[0]', 0); + expect(obj).to.have.deep.property('backgroundColorSplit[1]', 0); + expect(obj).to.have.deep.property('backgroundColorSplit[2]', 0); + expect(obj).to.have.property('backgroundColorString', '#000000'); + + + expect(obj).to.have.property('worldVisible', true); + }); +}); diff --git a/test/unit/pixi-v2/extras/Rope.js b/test/unit/pixi-v2/extras/Rope.js new file mode 100644 index 0000000..05885ac --- /dev/null +++ b/test/unit/pixi-v2/extras/Rope.js @@ -0,0 +1,31 @@ +describe('pixi/extras/Rope', function () { + 'use strict'; + + var expect = chai.expect; + var Rope = PIXI.Rope; + var Texture = PIXI.Texture; + var Point = PIXI.Point; + + it('Module exists', function () { + expect(Rope).to.be.a('function'); + }); + + it('Confirm new instance', function () { + + var texture = Texture.fromImage('/base/test/textures/bunny.png'); + + // TODO-Alvin + // Same as Strip + + // var obj = new Rope(texture, [new Point(), new Point(5, 10), new Point(10, 20)]); + + // pixi_extras_Strip_confirmNew(obj); + + // expect(obj).to.be.an.instanceof(Rope); + // expect(obj).to.respondTo('refresh'); + // expect(obj).to.respondTo('updateTransform'); + // expect(obj).to.respondTo('setTexture'); + + // TODO: Test properties + }); +}); diff --git a/test/unit/pixi-v2/extras/Spine.js b/test/unit/pixi-v2/extras/Spine.js new file mode 100644 index 0000000..0708bc0 --- /dev/null +++ b/test/unit/pixi-v2/extras/Spine.js @@ -0,0 +1,10 @@ +describe('pixi/extras/Spine', function () { + 'use strict'; + + var expect = chai.expect; + var Spine = PIXI.Spine; + + it('Module exists', function () { + expect(Spine).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/extras/Strip.js b/test/unit/pixi-v2/extras/Strip.js new file mode 100644 index 0000000..230af90 --- /dev/null +++ b/test/unit/pixi-v2/extras/Strip.js @@ -0,0 +1,26 @@ +describe('pixi/extras/Strip', function () { + 'use strict'; + + var expect = chai.expect; + var Strip = PIXI.Strip; + var Texture = PIXI.Texture; + + it('Module exists', function () { + expect(Strip).to.be.a('function'); + }); + + it('Confirm new instance', function () { + + + // TODO-Alvin + // We tweaked it to make it pass the tests, but the whole strip class needs + // to be re-coded + + var texture = Texture.fromImage('/base/test/textures/bunny.png'); + + // var obj = new Strip(texture, 20, 10000); + + + // pixi_extras_Strip_confirmNew(obj); + }); +}); diff --git a/test/unit/pixi-v2/extras/TilingSprite.js b/test/unit/pixi-v2/extras/TilingSprite.js new file mode 100644 index 0000000..56aea14 --- /dev/null +++ b/test/unit/pixi-v2/extras/TilingSprite.js @@ -0,0 +1,24 @@ +describe('pixi/extras/TilingSprite', function () { + 'use strict'; + + var expect = chai.expect; + var TilingSprite = PIXI.TilingSprite; + var Texture = PIXI.Texture; + + it('Module exists', function () { + expect(TilingSprite).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var texture = Texture.fromImage('/base/test/textures/bunny.png'); + var obj = new TilingSprite(texture, 6000, 12000); + + pixi_display_DisplayObjectContainer_confirmNew(obj); + + expect(obj).to.be.an.instanceof(TilingSprite); + expect(obj).to.respondTo('setTexture'); + expect(obj).to.respondTo('onTextureUpdate'); + + // TODO: Test properties + }); +}); diff --git a/test/unit/pixi-v2/filters/FilterBlock.js b/test/unit/pixi-v2/filters/FilterBlock.js new file mode 100644 index 0000000..870cec0 --- /dev/null +++ b/test/unit/pixi-v2/filters/FilterBlock.js @@ -0,0 +1,10 @@ +describe('pixi/filters/FilterBlock', function () { + 'use strict'; + + var expect = chai.expect; + var FilterBlock = PIXI.FilterBlock; + + it('Module exists', function () { + expect(FilterBlock).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/AssetLoader.js b/test/unit/pixi-v2/loaders/AssetLoader.js new file mode 100644 index 0000000..a0aa0b5 --- /dev/null +++ b/test/unit/pixi-v2/loaders/AssetLoader.js @@ -0,0 +1,10 @@ +describe('pixi/loaders/AssetLoader', function () { + 'use strict'; + + var expect = chai.expect; + var AssetLoader = PIXI.AssetLoader; + + it('Module exists', function () { + expect(AssetLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/BitmapFontLoader.js b/test/unit/pixi-v2/loaders/BitmapFontLoader.js new file mode 100644 index 0000000..046f018 --- /dev/null +++ b/test/unit/pixi-v2/loaders/BitmapFontLoader.js @@ -0,0 +1,9 @@ +describe('pixi/loaders/BitmapFontLoader', function () { + 'use strict'; + + var expect = chai.expect; + + it('Module exists', function () { + expect(PIXI.BitmapFontLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/ImageLoader.js b/test/unit/pixi-v2/loaders/ImageLoader.js new file mode 100644 index 0000000..8b1f556 --- /dev/null +++ b/test/unit/pixi-v2/loaders/ImageLoader.js @@ -0,0 +1,10 @@ +describe('pixi/loaders/ImageLoader', function () { + 'use strict'; + + var expect = chai.expect; + var ImageLoader = PIXI.ImageLoader; + + it('Module exists', function () { + expect(ImageLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/JsonLoader.js b/test/unit/pixi-v2/loaders/JsonLoader.js new file mode 100644 index 0000000..c577e83 --- /dev/null +++ b/test/unit/pixi-v2/loaders/JsonLoader.js @@ -0,0 +1,10 @@ +describe('pixi/loaders/JsonLoader', function () { + 'use strict'; + + var expect = chai.expect; + var JsonLoader = PIXI.JsonLoader; + + it('Module exists', function () { + expect(JsonLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/SpineLoader.js b/test/unit/pixi-v2/loaders/SpineLoader.js new file mode 100644 index 0000000..fdcc0b8 --- /dev/null +++ b/test/unit/pixi-v2/loaders/SpineLoader.js @@ -0,0 +1,10 @@ +describe('pixi/loaders/SpineLoader', function () { + 'use strict'; + + var expect = chai.expect; + var SpineLoader = PIXI.SpineLoader; + + it('Module exists', function () { + expect(SpineLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/SpriteSheetLoader.js b/test/unit/pixi-v2/loaders/SpriteSheetLoader.js new file mode 100644 index 0000000..57beb27 --- /dev/null +++ b/test/unit/pixi-v2/loaders/SpriteSheetLoader.js @@ -0,0 +1,10 @@ +describe('pixi/loaders/SpriteSheetLoader', function () { + 'use strict'; + + var expect = chai.expect; + var SpriteSheetLoader = PIXI.SpriteSheetLoader; + + it('Module exists', function () { + expect(SpriteSheetLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/primitives/Graphics.js b/test/unit/pixi-v2/primitives/Graphics.js new file mode 100644 index 0000000..f3849eb --- /dev/null +++ b/test/unit/pixi-v2/primitives/Graphics.js @@ -0,0 +1,44 @@ +describe('pixi/primitives/Graphics', function () { + 'use strict'; + + var expect = chai.expect; + var Graphics = PIXI.Graphics; + + it('Module exists', function () { + expect(Graphics).to.be.a('function'); + + expect(Graphics).itself.to.have.property('POLY', 0); + expect(Graphics).itself.to.have.property('RECT', 1); + expect(Graphics).itself.to.have.property('CIRC', 2); + expect(Graphics).itself.to.have.property('ELIP', 3); + expect(Graphics).itself.to.have.property('RREC', 4); + }); + + it('Confirm new instance', function () { + var obj = new Graphics(); + + pixi_display_DisplayObjectContainer_confirmNew(obj); + + expect(obj).to.be.an.instanceof(Graphics); + expect(obj).to.respondTo('lineStyle'); + expect(obj).to.respondTo('lineStyle'); + expect(obj).to.respondTo('moveTo'); + expect(obj).to.respondTo('lineTo'); + expect(obj).to.respondTo('beginFill'); + expect(obj).to.respondTo('endFill'); + expect(obj).to.respondTo('drawRect'); + // expect(obj).to.respondTo('drawRoundedRect'); + expect(obj).to.respondTo('drawCircle'); + expect(obj).to.respondTo('drawEllipse'); + expect(obj).to.respondTo('clear'); + + expect(obj).to.have.property('renderable', true); + expect(obj).to.have.property('fillAlpha', 1); + expect(obj).to.have.property('lineWidth', 0); + expect(obj).to.have.property('width', 0); + expect(obj).to.have.property('height', 0); + expect(obj).to.have.property('lineColor', 0); + expect(obj).to.have.deep.property('graphicsData.length', 0); + // expect(obj).to.have.deep.property('currentPath.points.length', 0); + }); +}); diff --git a/test/unit/pixi-v2/renderers/canvas/CanvasGraphics.js b/test/unit/pixi-v2/renderers/canvas/CanvasGraphics.js new file mode 100644 index 0000000..8f44472 --- /dev/null +++ b/test/unit/pixi-v2/renderers/canvas/CanvasGraphics.js @@ -0,0 +1,15 @@ +describe('renders/canvas/CanvasGraphics', function () { + 'use strict'; + + var expect = chai.expect; + var CanvasGraphics = PIXI.CanvasGraphics; + + it('Module exists', function () { + expect(CanvasGraphics).to.be.a('function'); + }); + + it('Members exist', function () { + expect(CanvasGraphics).itself.to.respondTo('renderGraphics'); + expect(CanvasGraphics).itself.to.respondTo('renderGraphicsMask'); + }); +}); diff --git a/test/unit/pixi-v2/renderers/canvas/CanvasRenderer.js b/test/unit/pixi-v2/renderers/canvas/CanvasRenderer.js new file mode 100644 index 0000000..1646444 --- /dev/null +++ b/test/unit/pixi-v2/renderers/canvas/CanvasRenderer.js @@ -0,0 +1,36 @@ +describe('renderers/canvas/CanvasRenderer', function () { + 'use strict'; + + var expect = chai.expect; + var CanvasRenderer = PIXI.CanvasRenderer; + + it('Module exists', function () { + expect(CanvasRenderer).to.be.a('function'); + }); + + describe('.autoResize', function () { + it('Should automatically resize view if enabled', function () { + var renderer = new CanvasRenderer(200, 200, { + autoResize: true + }); + + expect(renderer.view.style.width).to.equal('200px'); + }); + + it('Should not automatically resize view if disabled', function () { + var renderer = new CanvasRenderer(200, 200, { + autoResize: false + }); + + expect(renderer.view.style.width).to.equal(''); + }); + + it('Should not automatically resize view if not specified', function () { + var renderer = new CanvasRenderer(200, 200, { + resolution: 2 + }); + + expect(renderer.view.style.width).to.equal(''); + }); + }); +}); diff --git a/test/unit/pixi-v2/renderers/webgl/WebGLGraphics.js b/test/unit/pixi-v2/renderers/webgl/WebGLGraphics.js new file mode 100644 index 0000000..5867b28 --- /dev/null +++ b/test/unit/pixi-v2/renderers/webgl/WebGLGraphics.js @@ -0,0 +1,20 @@ +describe('renderers/wegbl/WebGLGraphics', function () { + 'use strict'; + + var expect = chai.expect; + var WebGLGraphics = PIXI.WebGLGraphics; + + it('Module exists', function () { + expect(WebGLGraphics).to.be.a('function'); + }); + + it('Members exist', function () { + expect(WebGLGraphics).itself.to.respondTo('renderGraphics'); + expect(WebGLGraphics).itself.to.respondTo('updateGraphics'); + expect(WebGLGraphics).itself.to.respondTo('buildRectangle'); + expect(WebGLGraphics).itself.to.respondTo('buildRoundedRectangle'); + expect(WebGLGraphics).itself.to.respondTo('buildCircle'); + expect(WebGLGraphics).itself.to.respondTo('buildLine'); + expect(WebGLGraphics).itself.to.respondTo('buildPoly'); + }); +}); diff --git a/test/unit/pixi-v2/renderers/webgl/WebGLRenderer.js b/test/unit/pixi-v2/renderers/webgl/WebGLRenderer.js new file mode 100644 index 0000000..1680a80 --- /dev/null +++ b/test/unit/pixi-v2/renderers/webgl/WebGLRenderer.js @@ -0,0 +1,49 @@ +describe('renderers/webgl/WebGLRenderer', function () { + 'use strict'; + + var expect = chai.expect; + var WebGLRenderer = PIXI.WebGLRenderer; + + it('Module exists', function () { + expect(WebGLRenderer).to.be.a('function'); + }); + + // Skip tests if WebGL is not available (WebGL not supported in Travis CI) + try { + var renderer = new WebGLRenderer(400, 300, {}); + renderer.destroy(); + } catch (error) { + return; + } + + it('Destroy renderer', function () { + var renderer = new WebGLRenderer(400, 300, {}); + renderer.destroy(); + }); + + describe('.autoResize', function () { + it('Should automatically resize view if enabled', function () { + var renderer = new WebGLRenderer(200, 200, { + autoResize: true + }); + + expect(renderer.view.style.width).to.equal('200px'); + }); + + it('Should not automatically resize view if disabled', function () { + var renderer = new WebGLRenderer(200, 200, { + autoResize: false + }); + + expect(renderer.view.style.width).to.equal(''); + }); + + it('Should not automatically resize view if not specified', function () { + var renderer = new WebGLRenderer(200, 200, { + resolution: 2 + }); + + expect(renderer.view.style.width).to.equal(''); + }); + }); +}); diff --git a/test/unit/pixi-v2/renderers/webgl/WebGLShaders.js b/test/unit/pixi-v2/renderers/webgl/WebGLShaders.js new file mode 100644 index 0000000..6e33e4f --- /dev/null +++ b/test/unit/pixi-v2/renderers/webgl/WebGLShaders.js @@ -0,0 +1,13 @@ +describe('renderers/webgl/WebGLShaders', function () { + 'use strict'; + + var expect = chai.expect; + + it('Module members exist', function () { + + expect(PIXI).to.respondTo('CompileVertexShader'); + expect(PIXI).to.respondTo('CompileFragmentShader'); + expect(PIXI).to.respondTo('_CompileShader'); + expect(PIXI).to.respondTo('compileProgram'); + }); +}); diff --git a/test/unit/pixi-v2/renderers/webgl/WebGLSpriteBatch.js b/test/unit/pixi-v2/renderers/webgl/WebGLSpriteBatch.js new file mode 100644 index 0000000..e662b63 --- /dev/null +++ b/test/unit/pixi-v2/renderers/webgl/WebGLSpriteBatch.js @@ -0,0 +1,10 @@ +describe('renderers/webgl/utils/WebGLSpriteBatch', function () { + 'use strict'; + + var expect = chai.expect; + var WebGLSpriteBatch = PIXI.WebGLSpriteBatch; + + it('Module exists', function () { + expect(WebGLSpriteBatch).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/text/BitmapText.js b/test/unit/pixi-v2/text/BitmapText.js new file mode 100644 index 0000000..9388e3d --- /dev/null +++ b/test/unit/pixi-v2/text/BitmapText.js @@ -0,0 +1,10 @@ +describe('pixi/text/BitmapText', function () { + 'use strict'; + + var expect = chai.expect; + var BitmapText = PIXI.BitmapText; + + it('Module exists', function () { + expect(BitmapText).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/text/Text.js b/test/unit/pixi-v2/text/Text.js new file mode 100644 index 0000000..9bc9ac5 --- /dev/null +++ b/test/unit/pixi-v2/text/Text.js @@ -0,0 +1,10 @@ +describe('pixi/text/Text', function () { + 'use strict'; + + var expect = chai.expect; + var Text = PIXI.Text; + + it('Module exists', function () { + expect(Text).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/textures/BaseTexture.js b/test/unit/pixi-v2/textures/BaseTexture.js new file mode 100644 index 0000000..502b724 --- /dev/null +++ b/test/unit/pixi-v2/textures/BaseTexture.js @@ -0,0 +1,11 @@ +describe('pixi/textures/BaseTexture', function () { + 'use strict'; + + var expect = chai.expect; + var BaseTexture = PIXI.BaseTexture; + + it('Module exists', function () { + expect(BaseTexture).to.be.a('function'); + expect(PIXI).to.have.property('BaseTextureCache').and.to.be.an('object'); + }); +}); diff --git a/test/unit/pixi-v2/textures/RenderTexture.js b/test/unit/pixi-v2/textures/RenderTexture.js new file mode 100644 index 0000000..96acdb4 --- /dev/null +++ b/test/unit/pixi-v2/textures/RenderTexture.js @@ -0,0 +1,15 @@ +describe('pixi/textures/RenderTexture', function () { + 'use strict'; + + var expect = chai.expect; + var RenderTexture = PIXI.RenderTexture; + + it('Module exists', function () { + expect(RenderTexture).to.be.a('function'); + }); + + it('Confirm new instance', function (done) { + var texture = new RenderTexture(100, 100, new PIXI.CanvasRenderer()); + pixi_textures_RenderTexture_confirmNew(texture, done); + }); +}); diff --git a/test/unit/pixi-v2/textures/Texture.js b/test/unit/pixi-v2/textures/Texture.js new file mode 100644 index 0000000..090f64d --- /dev/null +++ b/test/unit/pixi-v2/textures/Texture.js @@ -0,0 +1,26 @@ +describe('pixi/textures/Texture', function () { + 'use strict'; + + var expect = chai.expect; + var Texture = PIXI.Texture; + + it('Module exists', function () { + expect(Texture).to.be.a('function'); + expect(PIXI).to.have.property('TextureCache').and.to.be.an('object'); + }); + + it('Members exist', function () { + expect(Texture).itself.to.respondTo('fromImage'); + expect(Texture).itself.to.respondTo('fromFrame'); + expect(Texture).itself.to.respondTo('fromCanvas'); + expect(Texture).itself.to.respondTo('addTextureToCache'); + expect(Texture).itself.to.respondTo('removeTextureFromCache'); + + // expect(Texture).itself.to.have.deep.property('frameUpdates.length', 0); + }); + + it('Confirm new instance', function (done) { + var texture = Texture.fromImage('/base/test/textures/bunny.png'); + pixi_textures_Texture_confirmNew(texture, done); + }); +}); diff --git a/test/unit/pixi-v2/utils/Detector.js b/test/unit/pixi-v2/utils/Detector.js new file mode 100644 index 0000000..4cf6008 --- /dev/null +++ b/test/unit/pixi-v2/utils/Detector.js @@ -0,0 +1,10 @@ +describe('pixi/utils/Detector', function () { + 'use strict'; + + var expect = chai.expect; + var autoDetectRenderer = PIXI.autoDetectRenderer; + + it('Module exists', function () { + expect(autoDetectRenderer).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/utils/EventTarget.js b/test/unit/pixi-v2/utils/EventTarget.js new file mode 100644 index 0000000..1cfc3a4 --- /dev/null +++ b/test/unit/pixi-v2/utils/EventTarget.js @@ -0,0 +1,361 @@ +describe('pixi/utils/EventTarget', function () { + 'use strict'; + + var expect = chai.expect; + + var Clazz, PClazz, obj, pobj, obj2; + beforeEach(function () { + Clazz = function () {}; + PClazz = function () {}; + + PIXI.EventTarget.mixin(Clazz.prototype); + PIXI.EventTarget.mixin(PClazz.prototype); + + obj = new Clazz(); + obj2 = new Clazz(); + pobj = new PClazz(); + + obj.parent = pobj; + obj2.parent = obj; + }); + + it('Module exists', function () { + expect(PIXI.EventTarget).to.be.an('object'); + }); + + it('Confirm new instance', function () { + pixi_utils_EventTarget_confirm(obj); + }); + + it('simple on/emit case works', function () { + var myData = {}; + + obj.on('myevent', function (event) { + pixi_utils_EventTarget_Event_confirm(event, obj, myData); + }); + + obj.emit('myevent', myData); + }); + + it('simple once case works', function () { + var called = 0; + + obj.once('myevent', function() { called++; }); + + obj.emit('myevent'); + obj.emit('myevent'); + obj.emit('myevent'); + obj.emit('myevent'); + obj.emit('myevent'); + + expect(called).to.equal(1); + }); + + it('simple off case works', function (done) { + function onMyEvent() { + done(new Error('Event listener should not have been called')); + } + + obj.on('myevent', onMyEvent); + obj.off('myevent', onMyEvent); + obj.emit('myevent'); + + done(); + }); + + it('simple propagation case works', function (done) { + var myData = {}; + + pobj.on('myevent', function () { + done(); + }); + + obj.emit('myevent'); + }); + + it('simple stopPropagation case works', function (done) { + var myData = {}; + + pobj.on('myevent', function () { + done(new Error('Event listener should not have been called on the parent element')); + }); + + obj.on('myevent', function (evt) { + evt.stopPropagation(); + }); + + obj.emit('myevent'); + + done(); + }); + + it('simple stopImmediatePropagation case works', function (done) { + var myData = {}; + + pobj.on('myevent', function () { + done(new Error('Event listener should not have been called on the parent')); + }); + + obj.on('myevent', function (evt) { + evt.stopImmediatePropagation(); + }); + + obj.on('myevent', function () { + done(new Error('Event listener should not have been called on the second')); + }); + + obj.emit('myevent'); + + done(); + }); + + it('multiple dispatches work properly', function () { + var called = 0; + + function onMyEvent() { + called++; + } + + obj.on('myevent', onMyEvent); + obj.emit('myevent'); + obj.emit('myevent'); + obj.emit('myevent'); + obj.emit('myevent'); + + expect(called).to.equal(4); + }); + + it('multiple events work properly', function () { + var called = 0; + + function onMyEvent() { + called++; + } + + obj.on('myevent1', onMyEvent); + obj.on('myevent2', onMyEvent); + obj.on('myevent3', onMyEvent); + obj.emit('myevent1'); + obj.emit('myevent2'); + obj.emit('myevent3'); + + expect(called).to.equal(3); + }); + + it('multiple events one removed works properly', function () { + var called = 0; + + function onMyEvent() { + called++; + } + + obj.on('myevent1', onMyEvent); + obj.on('myevent2', onMyEvent); + obj.on('myevent3', onMyEvent); + + obj.emit('myevent1'); + obj.emit('myevent2'); + obj.emit('myevent3'); + + obj.off('myevent2', onMyEvent); + + obj.emit('myevent1'); + obj.emit('myevent2'); + obj.emit('myevent3'); + + expect(called).to.equal(5); + }); + + it('multiple handlers for one event with some removed', function () { + var called = 0; + + var onMyEvent = function () { + called++; + }, + onMyEvent2 = function () { + called++; + }; + + // add 2 handlers and confirm they both get called + obj.on('myevent', onMyEvent); + obj.on('myevent', onMyEvent); + obj.on('myevent', onMyEvent2); + obj.on('myevent', onMyEvent2); + + obj.emit('myevent'); + + expect(called).to.equal(4); + + // remove one of the handlers, emit again, then ensure 1 more call is made + obj.off('myevent', onMyEvent); + + obj.emit('myevent'); + + expect(called).to.equal(6); + }); + + it('calls to off without a handler do nothing', function () { + var called = 0; + + var onMyEvent = function () { + called++; + }; + + obj.on('myevent', onMyEvent); + obj.on('myevent', onMyEvent); + + obj.emit('myevent'); + + expect(called).to.equal(2); + + obj.off('myevent'); + + obj.emit('myevent'); + + expect(called).to.equal(4); + + obj.off('myevent', onMyEvent); + + obj.emit('myevent'); + + expect(called).to.equal(4); + }); + + it('handles multiple instances with the same prototype', function () { + var called = 0; + + function onMyEvent(e) { + called++; + } + + obj.on('myevent1', onMyEvent); + obj.on('myevent2', onMyEvent); + + obj2.istwo = true; + obj2.on('myevent1', onMyEvent); + obj2.on('myevent2', onMyEvent); + + obj.emit('myevent1'); + obj.emit('myevent2'); + obj2.emit('myevent1'); + obj2.emit('myevent2'); + + //we emit 4 times, but since obj2 is a child of obj the event should bubble + //up to obj and show up there as well. So the obj2.emit() calls each increment + //the counter twice. + expect(called).to.equal(6); + }); + + it('is backwards compatible with older .dispatchEvent({})', function () { + var called = 0, + data = { + some: 'thing', + hello: true + }; + + function onMyEvent(event) { + pixi_utils_EventTarget_Event_confirm(event, obj, data); + + called++; + } + + obj.on('myevent1', onMyEvent); + obj.on('myevent2', onMyEvent); + obj.on('myevent3', onMyEvent); + + data.type = 'myevent1'; + obj.emit(data); + + data.type = 'myevent2'; + obj.emit(data); + + data.type = 'myevent3'; + obj.emit(data); + + obj.off('myevent2', onMyEvent); + + data.type = 'myevent1'; + obj.emit(data); + + data.type = 'myevent2'; + obj.emit(data); + + data.type = 'myevent3'; + obj.emit(data); + + expect(called).to.equal(5); + }); + + it('is backwards compatible with older .call(this)', function () { + var Fn = function() { + PIXI.EventTarget.call(this); + }, + o = new Fn(); + + pixi_utils_EventTarget_confirm(o); + }); + + it('is backwards compatible with older .addEventListener("")', function () { + var called = 0, + data = { + some: 'thing', + hello: true + }; + + function onMyEvent(event) { + pixi_utils_EventTarget_Event_confirm(event, obj, data); + + called++; + } + + obj.addEventListener('myevent1', onMyEvent); + obj.addEventListener('myevent2', onMyEvent); + obj.addEventListener('myevent3', onMyEvent); + + data.type = 'myevent1'; + obj.emit(data); + + data.type = 'myevent2'; + obj.emit(data); + + data.type = 'myevent3'; + obj.emit(data); + + obj.off('myevent2', onMyEvent); + + data.type = 'myevent1'; + obj.emit(data); + + data.type = 'myevent2'; + obj.emit(data); + + data.type = 'myevent3'; + obj.emit(data); + + expect(called).to.equal(5); + }); + + it('event remove during emit call properly', function () { + var called = 0; + + function cb1() { + called++; + obj.off('myevent', cb1); + } + function cb2() { + called++; + obj.off('myevent', cb2); + } + function cb3() { + called++; + obj.off('myevent', cb3); + } + + obj.on('myevent', cb1); + obj.on('myevent', cb2); + obj.on('myevent', cb3); + obj.emit('myevent', ''); + + expect(called).to.equal(3); + }); +}); diff --git a/test/unit/pixi-v2/utils/Polyk.js b/test/unit/pixi-v2/utils/Polyk.js new file mode 100644 index 0000000..dfc7128 --- /dev/null +++ b/test/unit/pixi-v2/utils/Polyk.js @@ -0,0 +1,14 @@ +describe('pixi/utils/Polyk', function () { + 'use strict'; + + var expect = chai.expect; + var PolyK = PIXI.PolyK; + + it('Module exists', function () { + expect(PolyK).to.be.an('object'); + }); + + it('Members exist', function () { + expect(PolyK).to.respondTo('Triangulate'); + }); +}); diff --git a/test/unit/pixi-v2/utils/Utils.js b/test/unit/pixi-v2/utils/Utils.js new file mode 100644 index 0000000..c97b3c6 --- /dev/null +++ b/test/unit/pixi-v2/utils/Utils.js @@ -0,0 +1,17 @@ +describe('Utils', function () { + 'use strict'; + + var expect = chai.expect; + + it('requestAnimationFrame exists', function () { + expect(global).to.respondTo('requestAnimationFrame'); + }); + + it('cancelAnimationFrame exists', function () { + expect(global).to.respondTo('cancelAnimationFrame'); + }); + + it('requestAnimFrame exists', function () { + expect(global).to.respondTo('requestAnimFrame'); + }); +}); diff --git a/test/unit/pixi/InteractionManager.js b/test/unit/pixi/InteractionManager.js deleted file mode 100644 index ed3001f..0000000 --- a/test/unit/pixi/InteractionManager.js +++ /dev/null @@ -1,10 +0,0 @@ -describe('pixi/InteractionManager', function () { - 'use strict'; - - var expect = chai.expect; - var InteractionManager = PIXI.InteractionManager; - - it('Module exists', function () { - expect(InteractionManager).to.be.a('function'); - }); -}); diff --git a/test/unit/pixi/Pixi.js b/test/unit/pixi/Pixi.js deleted file mode 100644 index 27debc1..0000000 --- a/test/unit/pixi/Pixi.js +++ /dev/null @@ -1,9 +0,0 @@ -describe('pixi/Pixi', function () { - 'use strict'; - - var expect = chai.expect; - - it('Module exists', function () { - expect(global).to.have.property('PIXI').and.to.be.an('object'); - }); -}); diff --git a/test/unit/pixi/core/Circle.js b/test/unit/pixi/core/Circle.js deleted file mode 100644 index fbcfa17..0000000 --- a/test/unit/pixi/core/Circle.js +++ /dev/null @@ -1,21 +0,0 @@ -describe('pixi/core/Circle', function () { - 'use strict'; - - var expect = chai.expect; - var Circle = PIXI.Circle; - - it('Module exists', function () { - expect(Circle).to.be.a('function'); - }); - - it('Confirm new instance', function () { - var obj = new Circle(); - pixi_core_Circle_confirmNewCircle(obj); - }); - - it("getBounds should return Rectangle that bounds the circle", function() { - var obj = new Circle(100, 250, 50); - var bounds = obj.getBounds(); - pixi_core_Circle_isBoundedByRectangle(obj, bounds); - }); -}); diff --git a/test/unit/pixi/core/Ellipse.js b/test/unit/pixi/core/Ellipse.js deleted file mode 100644 index 026b56f..0000000 --- a/test/unit/pixi/core/Ellipse.js +++ /dev/null @@ -1,24 +0,0 @@ -describe('pixi/core/Ellipse', function () { - 'use strict'; - - var expect = chai.expect; - var Ellipse = PIXI.Ellipse; - - it('Module exists', function () { - expect(Ellipse).to.be.a('function'); - }); - - it('Confirm new instance', function () { - var obj = new Ellipse(); - - expect(obj).to.be.an.instanceof(Ellipse); - expect(obj).to.respondTo('clone'); - expect(obj).to.respondTo('contains'); - expect(obj).to.respondTo('getBounds'); - - expect(obj).to.have.property('x', 0); - expect(obj).to.have.property('y', 0); - expect(obj).to.have.property('width', 0); - expect(obj).to.have.property('height', 0); - }); -}); diff --git a/test/unit/pixi/core/Matrix.js b/test/unit/pixi/core/Matrix.js deleted file mode 100644 index da75e2e..0000000 --- a/test/unit/pixi/core/Matrix.js +++ /dev/null @@ -1,14 +0,0 @@ -describe('pixi/core/Matrix', function () { - 'use strict'; - - var expect = chai.expect; - - it('Matrix exists', function () { - expect(PIXI.Matrix).to.be.an('function'); - }); - - it('Confirm new Matrix', function () { - var matrix = new PIXI.Matrix(); - pixi_core_Matrix_confirmNewMatrix(matrix); - }); -}); diff --git a/test/unit/pixi/core/Point.js b/test/unit/pixi/core/Point.js deleted file mode 100644 index c4d5163..0000000 --- a/test/unit/pixi/core/Point.js +++ /dev/null @@ -1,15 +0,0 @@ -describe('pixi/core/Point', function () { - 'use strict'; - - var expect = chai.expect; - var Point = PIXI.Point; - - it('Module exists', function () { - expect(Point).to.be.a('function'); - }); - - it('Confirm new instance', function () { - var obj = new Point(); - pixi_core_Point_confirm(obj, 0, 0); - }); -}); diff --git a/test/unit/pixi/core/Polygon.js b/test/unit/pixi/core/Polygon.js deleted file mode 100644 index dc8c918..0000000 --- a/test/unit/pixi/core/Polygon.js +++ /dev/null @@ -1,20 +0,0 @@ -describe('pixi/core/Polygon', function () { - 'use strict'; - - var expect = chai.expect; - var Polygon = PIXI.Polygon; - - it('Module exists', function () { - expect(Polygon).to.be.a('function'); - }); - - it('Confirm new instance', function () { - var obj = new Polygon(); - - expect(obj).to.be.an.instanceof(Polygon); - expect(obj).to.respondTo('clone'); - expect(obj).to.respondTo('contains'); - - expect(obj).to.have.deep.property('points.length', 0); - }); -}); diff --git a/test/unit/pixi/core/Rectangle.js b/test/unit/pixi/core/Rectangle.js deleted file mode 100644 index d43316e..0000000 --- a/test/unit/pixi/core/Rectangle.js +++ /dev/null @@ -1,15 +0,0 @@ -describe('pixi/core/Rectangle', function () { - 'use strict'; - - var expect = chai.expect; - var Rectangle = PIXI.Rectangle; - - it('Module exists', function () { - expect(Rectangle).to.be.a('function'); - }); - - it('Confirm new instance', function () { - var rect = new Rectangle(); - pixi_core_Rectangle_confirm(rect, 0, 0, 0, 0); - }); -}); diff --git a/test/unit/pixi/display/DisplayObject.js b/test/unit/pixi/display/DisplayObject.js deleted file mode 100644 index 044acf8..0000000 --- a/test/unit/pixi/display/DisplayObject.js +++ /dev/null @@ -1,21 +0,0 @@ -describe('pixi/display/DisplayObject', function () { - 'use strict'; - - var expect = chai.expect; - var DisplayObject = PIXI.DisplayObject; - - it('Module exists', function () { - expect(DisplayObject).to.be.a('function'); - // expect(PIXI).to.have.property('visibleCount', 0); - }); - - it('Confirm new instance', function () { - var obj = new DisplayObject(); - - pixi_display_DisplayObject_confirmNew(obj); - expect(obj).to.have.property('hitArea', null); - expect(obj).to.have.property('interactive', false); - expect(obj).to.have.property('renderable', false); - expect(obj).to.have.property('stage', null); - }); -}); diff --git a/test/unit/pixi/display/DisplayObjectContainer.js b/test/unit/pixi/display/DisplayObjectContainer.js deleted file mode 100644 index 15a3376..0000000 --- a/test/unit/pixi/display/DisplayObjectContainer.js +++ /dev/null @@ -1,67 +0,0 @@ -describe('pixi/display/DisplayObjectContainer', function () { - 'use strict'; - - var expect = chai.expect; - var DisplayObjectContainer = PIXI.DisplayObjectContainer; - - it('Module exists', function () { - expect(DisplayObjectContainer).to.be.a('function'); - }); - - it('Confirm new instance', function () { - var obj = new DisplayObjectContainer(); - - pixi_display_DisplayObjectContainer_confirmNew(obj); - expect(obj).to.have.property('hitArea', null); - expect(obj).to.have.property('interactive', false); - expect(obj).to.have.property('renderable', false); - expect(obj).to.have.property('stage', null); - }); - - it('Gets child index', function() { - var container = new PIXI.DisplayObjectContainer(); - var children = []; - for (var i = 0; i < 10; i++) { - var child = new PIXI.DisplayObject(); - children.push(child); - container.addChild(child); - } - - for (i = 0; i < children.length; i++) { - expect(i).to.eql(container.getChildIndex(children[i])); - } - }); - - it('throws error when trying to get index of not a child', function() { - var container = new PIXI.DisplayObjectContainer(); - var child = new PIXI.DisplayObject(); - - expect(function() { container.getChildIndex(child); }).to.throw(); - }); - - it('Sets child index', function() { - var container = new PIXI.DisplayObjectContainer(); - var children = []; - - for (var i = 0; i < 10; i++) { - var child = new PIXI.DisplayObject(); - children.push(child); - container.addChild(child); - } - children.reverse(); - - for (i = 0; i < children.length; i++) { - container.setChildIndex(children[i], i); - expect(i).to.eql(container.getChildIndex(children[i])); - } - }); - - it('throws error when trying to set incorect index', function() { - var container = new PIXI.DisplayObjectContainer(); - var child = new PIXI.DisplayObject(); - container.addChild(child); - - expect(function() { container.setChildIndex(child, -1); }).to.throw(); - expect(function() { container.setChildIndex(child, 1); }).to.throw(); - }); -}); diff --git a/test/unit/pixi/display/MovieClip.js b/test/unit/pixi/display/MovieClip.js deleted file mode 100644 index f3c6c6a..0000000 --- a/test/unit/pixi/display/MovieClip.js +++ /dev/null @@ -1,33 +0,0 @@ -describe('pixi/display/MovieClip', function () { - 'use strict'; - - var expect = chai.expect; - var MovieClip = PIXI.MovieClip; - var Texture = PIXI.Texture; - - it('Module exists', function () { - expect(MovieClip).to.be.a('function'); - }); - - it('Confirm new instance', function (done) { - var texture = Texture.fromImage('/base/test/textures/SpriteSheet-Explosion.png'); - var obj = new MovieClip([texture]); - - pixi_display_Sprite_confirmNew(obj, done); - - expect(obj).to.be.an.instanceof(MovieClip); - expect(obj).to.respondTo('stop'); - expect(obj).to.respondTo('play'); - expect(obj).to.respondTo('gotoAndStop'); - expect(obj).to.respondTo('gotoAndPlay'); - expect(obj).to.respondTo('updateTransform'); - - expect(obj).to.have.deep.property('textures.length', 1); - expect(obj).to.have.deep.property('textures[0]', texture); - expect(obj).to.have.property('animationSpeed', 1); - expect(obj).to.have.property('loop', true); - expect(obj).to.have.property('onComplete', null); - expect(obj).to.have.property('currentFrame', 0); - expect(obj).to.have.property('playing', false); - }); -}); diff --git a/test/unit/pixi/display/Sprite.js b/test/unit/pixi/display/Sprite.js deleted file mode 100644 index 30c8076..0000000 --- a/test/unit/pixi/display/Sprite.js +++ /dev/null @@ -1,28 +0,0 @@ -describe('pixi/display/Sprite', function () { - 'use strict'; - - var expect = chai.expect; - var Sprite = PIXI.Sprite; - var Texture = PIXI.Texture; - - it('Module exists', function () { - expect(Sprite).to.be.a('function'); - expect(PIXI).to.have.deep.property('blendModes.NORMAL', 0); - expect(PIXI).to.have.deep.property('blendModes.ADD', 1); - expect(PIXI).to.have.deep.property('blendModes.MULTIPLY', 2); - expect(PIXI).to.have.deep.property('blendModes.SCREEN', 3); - }); - - - it('Members exist', function () { - expect(Sprite).itself.to.respondTo('fromImage'); - expect(Sprite).itself.to.respondTo('fromFrame'); - }); - - it('Confirm new instance', function (done) { - var texture = Texture.fromImage('/base/test/textures/SpriteSheet-Aliens.png'); - var obj = new Sprite(texture); - - pixi_display_Sprite_confirmNew(obj, done); - }); -}); diff --git a/test/unit/pixi/display/Stage.js b/test/unit/pixi/display/Stage.js deleted file mode 100644 index 6974c2e..0000000 --- a/test/unit/pixi/display/Stage.js +++ /dev/null @@ -1,49 +0,0 @@ -describe('pixi/display/Stage', function () { - 'use strict'; - - var expect = chai.expect; - var Stage = PIXI.Stage; - var InteractionManager = PIXI.InteractionManager; - var Rectangle = PIXI.Rectangle; - - it('Module exists', function () { - expect(Stage).to.be.a('function'); - }); - - it('Confirm new instance', function () { - var obj = new Stage(null, true); - - pixi_display_DisplayObjectContainer_confirmNew(obj); - - expect(obj).to.be.an.instanceof(Stage); - expect(obj).to.respondTo('updateTransform'); - expect(obj).to.respondTo('setBackgroundColor'); - expect(obj).to.respondTo('getMousePosition'); - // FIXME: duplicate member in DisplayObject - pixi_core_Matrix_confirmNewMatrix(obj.worldTransform); - // FIXME: convert arg to bool in constructor - expect(obj).to.have.property('interactive', true); - - expect(obj).to.have.property('interactionManager') - .and.to.be.an.instanceof(InteractionManager) - .and.to.have.property('stage', obj); - - expect(obj).to.have.property('dirty', true); - - expect(obj).to.have.property('stage', obj); - - expect(obj).to.have.property('hitArea') - .and.to.be.an.instanceof(Rectangle); - pixi_core_Rectangle_confirm(obj.hitArea, 0, 0, 100000, 100000); - - expect(obj).to.have.property('backgroundColor', 0x000000); - expect(obj).to.have.deep.property('backgroundColorSplit.length', 3); - expect(obj).to.have.deep.property('backgroundColorSplit[0]', 0); - expect(obj).to.have.deep.property('backgroundColorSplit[1]', 0); - expect(obj).to.have.deep.property('backgroundColorSplit[2]', 0); - expect(obj).to.have.property('backgroundColorString', '#000000'); - - - expect(obj).to.have.property('worldVisible', true); - }); -}); diff --git a/test/unit/pixi/extras/Rope.js b/test/unit/pixi/extras/Rope.js deleted file mode 100644 index 05885ac..0000000 --- a/test/unit/pixi/extras/Rope.js +++ /dev/null @@ -1,31 +0,0 @@ -describe('pixi/extras/Rope', function () { - 'use strict'; - - var expect = chai.expect; - var Rope = PIXI.Rope; - var Texture = PIXI.Texture; - var Point = PIXI.Point; - - it('Module exists', function () { - expect(Rope).to.be.a('function'); - }); - - it('Confirm new instance', function () { - - var texture = Texture.fromImage('/base/test/textures/bunny.png'); - - // TODO-Alvin - // Same as Strip - - // var obj = new Rope(texture, [new Point(), new Point(5, 10), new Point(10, 20)]); - - // pixi_extras_Strip_confirmNew(obj); - - // expect(obj).to.be.an.instanceof(Rope); - // expect(obj).to.respondTo('refresh'); - // expect(obj).to.respondTo('updateTransform'); - // expect(obj).to.respondTo('setTexture'); - - // TODO: Test properties - }); -}); diff --git a/test/unit/pixi/extras/Spine.js b/test/unit/pixi/extras/Spine.js deleted file mode 100644 index 0708bc0..0000000 --- a/test/unit/pixi/extras/Spine.js +++ /dev/null @@ -1,10 +0,0 @@ -describe('pixi/extras/Spine', function () { - 'use strict'; - - var expect = chai.expect; - var Spine = PIXI.Spine; - - it('Module exists', function () { - expect(Spine).to.be.a('function'); - }); -}); diff --git a/test/unit/pixi/extras/Strip.js b/test/unit/pixi/extras/Strip.js deleted file mode 100644 index 230af90..0000000 --- a/test/unit/pixi/extras/Strip.js +++ /dev/null @@ -1,26 +0,0 @@ -describe('pixi/extras/Strip', function () { - 'use strict'; - - var expect = chai.expect; - var Strip = PIXI.Strip; - var Texture = PIXI.Texture; - - it('Module exists', function () { - expect(Strip).to.be.a('function'); - }); - - it('Confirm new instance', function () { - - - // TODO-Alvin - // We tweaked it to make it pass the tests, but the whole strip class needs - // to be re-coded - - var texture = Texture.fromImage('/base/test/textures/bunny.png'); - - // var obj = new Strip(texture, 20, 10000); - - - // pixi_extras_Strip_confirmNew(obj); - }); -}); diff --git a/test/unit/pixi/extras/TilingSprite.js b/test/unit/pixi/extras/TilingSprite.js deleted file mode 100644 index 56aea14..0000000 --- a/test/unit/pixi/extras/TilingSprite.js +++ /dev/null @@ -1,24 +0,0 @@ -describe('pixi/extras/TilingSprite', function () { - 'use strict'; - - var expect = chai.expect; - var TilingSprite = PIXI.TilingSprite; - var Texture = PIXI.Texture; - - it('Module exists', function () { - expect(TilingSprite).to.be.a('function'); - }); - - it('Confirm new instance', function () { - var texture = Texture.fromImage('/base/test/textures/bunny.png'); - var obj = new TilingSprite(texture, 6000, 12000); - - pixi_display_DisplayObjectContainer_confirmNew(obj); - - expect(obj).to.be.an.instanceof(TilingSprite); - expect(obj).to.respondTo('setTexture'); - expect(obj).to.respondTo('onTextureUpdate'); - - // TODO: Test properties - }); -}); diff --git a/test/unit/pixi/filters/FilterBlock.js b/test/unit/pixi/filters/FilterBlock.js deleted file mode 100644 index 870cec0..0000000 --- a/test/unit/pixi/filters/FilterBlock.js +++ /dev/null @@ -1,10 +0,0 @@ -describe('pixi/filters/FilterBlock', function () { - 'use strict'; - - var expect = chai.expect; - var FilterBlock = PIXI.FilterBlock; - - it('Module exists', function () { - expect(FilterBlock).to.be.a('function'); - }); -}); diff --git a/test/unit/pixi/loaders/AssetLoader.js b/test/unit/pixi/loaders/AssetLoader.js deleted file mode 100644 index a0aa0b5..0000000 --- a/test/unit/pixi/loaders/AssetLoader.js +++ /dev/null @@ -1,10 +0,0 @@ -describe('pixi/loaders/AssetLoader', function () { - 'use strict'; - - var expect = chai.expect; - var AssetLoader = PIXI.AssetLoader; - - it('Module exists', function () { - expect(AssetLoader).to.be.a('function'); - }); -}); diff --git a/test/unit/pixi/loaders/BitmapFontLoader.js b/test/unit/pixi/loaders/BitmapFontLoader.js deleted file mode 100644 index 046f018..0000000 --- a/test/unit/pixi/loaders/BitmapFontLoader.js +++ /dev/null @@ -1,9 +0,0 @@ -describe('pixi/loaders/BitmapFontLoader', function () { - 'use strict'; - - var expect = chai.expect; - - it('Module exists', function () { - expect(PIXI.BitmapFontLoader).to.be.a('function'); - }); -}); diff --git a/test/unit/pixi/loaders/ImageLoader.js b/test/unit/pixi/loaders/ImageLoader.js deleted file mode 100644 index 8b1f556..0000000 --- a/test/unit/pixi/loaders/ImageLoader.js +++ /dev/null @@ -1,10 +0,0 @@ -describe('pixi/loaders/ImageLoader', function () { - 'use strict'; - - var expect = chai.expect; - var ImageLoader = PIXI.ImageLoader; - - it('Module exists', function () { - expect(ImageLoader).to.be.a('function'); - }); -}); diff --git a/test/unit/pixi/loaders/JsonLoader.js b/test/unit/pixi/loaders/JsonLoader.js deleted file mode 100644 index c577e83..0000000 --- a/test/unit/pixi/loaders/JsonLoader.js +++ /dev/null @@ -1,10 +0,0 @@ -describe('pixi/loaders/JsonLoader', function () { - 'use strict'; - - var expect = chai.expect; - var JsonLoader = PIXI.JsonLoader; - - it('Module exists', function () { - expect(JsonLoader).to.be.a('function'); - }); -}); diff --git a/test/unit/pixi/loaders/SpineLoader.js b/test/unit/pixi/loaders/SpineLoader.js deleted file mode 100644 index fdcc0b8..0000000 --- a/test/unit/pixi/loaders/SpineLoader.js +++ /dev/null @@ -1,10 +0,0 @@ -describe('pixi/loaders/SpineLoader', function () { - 'use strict'; - - var expect = chai.expect; - var SpineLoader = PIXI.SpineLoader; - - it('Module exists', function () { - expect(SpineLoader).to.be.a('function'); - }); -}); diff --git a/test/unit/pixi/loaders/SpriteSheetLoader.js b/test/unit/pixi/loaders/SpriteSheetLoader.js deleted file mode 100644 index 57beb27..0000000 --- a/test/unit/pixi/loaders/SpriteSheetLoader.js +++ /dev/null @@ -1,10 +0,0 @@ -describe('pixi/loaders/SpriteSheetLoader', function () { - 'use strict'; - - var expect = chai.expect; - var SpriteSheetLoader = PIXI.SpriteSheetLoader; - - it('Module exists', function () { - expect(SpriteSheetLoader).to.be.a('function'); - }); -}); diff --git a/test/unit/pixi/primitives/Graphics.js b/test/unit/pixi/primitives/Graphics.js deleted file mode 100644 index f3849eb..0000000 --- a/test/unit/pixi/primitives/Graphics.js +++ /dev/null @@ -1,44 +0,0 @@ -describe('pixi/primitives/Graphics', function () { - 'use strict'; - - var expect = chai.expect; - var Graphics = PIXI.Graphics; - - it('Module exists', function () { - expect(Graphics).to.be.a('function'); - - expect(Graphics).itself.to.have.property('POLY', 0); - expect(Graphics).itself.to.have.property('RECT', 1); - expect(Graphics).itself.to.have.property('CIRC', 2); - expect(Graphics).itself.to.have.property('ELIP', 3); - expect(Graphics).itself.to.have.property('RREC', 4); - }); - - it('Confirm new instance', function () { - var obj = new Graphics(); - - pixi_display_DisplayObjectContainer_confirmNew(obj); - - expect(obj).to.be.an.instanceof(Graphics); - expect(obj).to.respondTo('lineStyle'); - expect(obj).to.respondTo('lineStyle'); - expect(obj).to.respondTo('moveTo'); - expect(obj).to.respondTo('lineTo'); - expect(obj).to.respondTo('beginFill'); - expect(obj).to.respondTo('endFill'); - expect(obj).to.respondTo('drawRect'); - // expect(obj).to.respondTo('drawRoundedRect'); - expect(obj).to.respondTo('drawCircle'); - expect(obj).to.respondTo('drawEllipse'); - expect(obj).to.respondTo('clear'); - - expect(obj).to.have.property('renderable', true); - expect(obj).to.have.property('fillAlpha', 1); - expect(obj).to.have.property('lineWidth', 0); - expect(obj).to.have.property('width', 0); - expect(obj).to.have.property('height', 0); - expect(obj).to.have.property('lineColor', 0); - expect(obj).to.have.deep.property('graphicsData.length', 0); - // expect(obj).to.have.deep.property('currentPath.points.length', 0); - }); -}); diff --git a/test/unit/pixi/renderers/canvas/CanvasGraphics.js b/test/unit/pixi/renderers/canvas/CanvasGraphics.js deleted file mode 100644 index 8f44472..0000000 --- a/test/unit/pixi/renderers/canvas/CanvasGraphics.js +++ /dev/null @@ -1,15 +0,0 @@ -describe('renders/canvas/CanvasGraphics', function () { - 'use strict'; - - var expect = chai.expect; - var CanvasGraphics = PIXI.CanvasGraphics; - - it('Module exists', function () { - expect(CanvasGraphics).to.be.a('function'); - }); - - it('Members exist', function () { - expect(CanvasGraphics).itself.to.respondTo('renderGraphics'); - expect(CanvasGraphics).itself.to.respondTo('renderGraphicsMask'); - }); -}); diff --git a/test/unit/pixi/renderers/canvas/CanvasRenderer.js b/test/unit/pixi/renderers/canvas/CanvasRenderer.js deleted file mode 100644 index 1646444..0000000 --- a/test/unit/pixi/renderers/canvas/CanvasRenderer.js +++ /dev/null @@ -1,36 +0,0 @@ -describe('renderers/canvas/CanvasRenderer', function () { - 'use strict'; - - var expect = chai.expect; - var CanvasRenderer = PIXI.CanvasRenderer; - - it('Module exists', function () { - expect(CanvasRenderer).to.be.a('function'); - }); - - describe('.autoResize', function () { - it('Should automatically resize view if enabled', function () { - var renderer = new CanvasRenderer(200, 200, { - autoResize: true - }); - - expect(renderer.view.style.width).to.equal('200px'); - }); - - it('Should not automatically resize view if disabled', function () { - var renderer = new CanvasRenderer(200, 200, { - autoResize: false - }); - - expect(renderer.view.style.width).to.equal(''); - }); - - it('Should not automatically resize view if not specified', function () { - var renderer = new CanvasRenderer(200, 200, { - resolution: 2 - }); - - expect(renderer.view.style.width).to.equal(''); - }); - }); -}); diff --git a/test/unit/pixi/renderers/webgl/WebGLGraphics.js b/test/unit/pixi/renderers/webgl/WebGLGraphics.js deleted file mode 100644 index 5867b28..0000000 --- a/test/unit/pixi/renderers/webgl/WebGLGraphics.js +++ /dev/null @@ -1,20 +0,0 @@ -describe('renderers/wegbl/WebGLGraphics', function () { - 'use strict'; - - var expect = chai.expect; - var WebGLGraphics = PIXI.WebGLGraphics; - - it('Module exists', function () { - expect(WebGLGraphics).to.be.a('function'); - }); - - it('Members exist', function () { - expect(WebGLGraphics).itself.to.respondTo('renderGraphics'); - expect(WebGLGraphics).itself.to.respondTo('updateGraphics'); - expect(WebGLGraphics).itself.to.respondTo('buildRectangle'); - expect(WebGLGraphics).itself.to.respondTo('buildRoundedRectangle'); - expect(WebGLGraphics).itself.to.respondTo('buildCircle'); - expect(WebGLGraphics).itself.to.respondTo('buildLine'); - expect(WebGLGraphics).itself.to.respondTo('buildPoly'); - }); -}); diff --git a/test/unit/pixi-v2/InteractionManager.js b/test/unit/pixi-v2/InteractionManager.js new file mode 100644 index 0000000..ed3001f --- /dev/null +++ b/test/unit/pixi-v2/InteractionManager.js @@ -0,0 +1,10 @@ +describe('pixi/InteractionManager', function () { + 'use strict'; + + var expect = chai.expect; + var InteractionManager = PIXI.InteractionManager; + + it('Module exists', function () { + expect(InteractionManager).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/Pixi.js b/test/unit/pixi-v2/Pixi.js new file mode 100644 index 0000000..27debc1 --- /dev/null +++ b/test/unit/pixi-v2/Pixi.js @@ -0,0 +1,9 @@ +describe('pixi/Pixi', function () { + 'use strict'; + + var expect = chai.expect; + + it('Module exists', function () { + expect(global).to.have.property('PIXI').and.to.be.an('object'); + }); +}); diff --git a/test/unit/pixi-v2/core/Circle.js b/test/unit/pixi-v2/core/Circle.js new file mode 100644 index 0000000..fbcfa17 --- /dev/null +++ b/test/unit/pixi-v2/core/Circle.js @@ -0,0 +1,21 @@ +describe('pixi/core/Circle', function () { + 'use strict'; + + var expect = chai.expect; + var Circle = PIXI.Circle; + + it('Module exists', function () { + expect(Circle).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Circle(); + pixi_core_Circle_confirmNewCircle(obj); + }); + + it("getBounds should return Rectangle that bounds the circle", function() { + var obj = new Circle(100, 250, 50); + var bounds = obj.getBounds(); + pixi_core_Circle_isBoundedByRectangle(obj, bounds); + }); +}); diff --git a/test/unit/pixi-v2/core/Ellipse.js b/test/unit/pixi-v2/core/Ellipse.js new file mode 100644 index 0000000..026b56f --- /dev/null +++ b/test/unit/pixi-v2/core/Ellipse.js @@ -0,0 +1,24 @@ +describe('pixi/core/Ellipse', function () { + 'use strict'; + + var expect = chai.expect; + var Ellipse = PIXI.Ellipse; + + it('Module exists', function () { + expect(Ellipse).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Ellipse(); + + expect(obj).to.be.an.instanceof(Ellipse); + expect(obj).to.respondTo('clone'); + expect(obj).to.respondTo('contains'); + expect(obj).to.respondTo('getBounds'); + + expect(obj).to.have.property('x', 0); + expect(obj).to.have.property('y', 0); + expect(obj).to.have.property('width', 0); + expect(obj).to.have.property('height', 0); + }); +}); diff --git a/test/unit/pixi-v2/core/Matrix.js b/test/unit/pixi-v2/core/Matrix.js new file mode 100644 index 0000000..da75e2e --- /dev/null +++ b/test/unit/pixi-v2/core/Matrix.js @@ -0,0 +1,14 @@ +describe('pixi/core/Matrix', function () { + 'use strict'; + + var expect = chai.expect; + + it('Matrix exists', function () { + expect(PIXI.Matrix).to.be.an('function'); + }); + + it('Confirm new Matrix', function () { + var matrix = new PIXI.Matrix(); + pixi_core_Matrix_confirmNewMatrix(matrix); + }); +}); diff --git a/test/unit/pixi-v2/core/Point.js b/test/unit/pixi-v2/core/Point.js new file mode 100644 index 0000000..c4d5163 --- /dev/null +++ b/test/unit/pixi-v2/core/Point.js @@ -0,0 +1,15 @@ +describe('pixi/core/Point', function () { + 'use strict'; + + var expect = chai.expect; + var Point = PIXI.Point; + + it('Module exists', function () { + expect(Point).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Point(); + pixi_core_Point_confirm(obj, 0, 0); + }); +}); diff --git a/test/unit/pixi-v2/core/Polygon.js b/test/unit/pixi-v2/core/Polygon.js new file mode 100644 index 0000000..dc8c918 --- /dev/null +++ b/test/unit/pixi-v2/core/Polygon.js @@ -0,0 +1,20 @@ +describe('pixi/core/Polygon', function () { + 'use strict'; + + var expect = chai.expect; + var Polygon = PIXI.Polygon; + + it('Module exists', function () { + expect(Polygon).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Polygon(); + + expect(obj).to.be.an.instanceof(Polygon); + expect(obj).to.respondTo('clone'); + expect(obj).to.respondTo('contains'); + + expect(obj).to.have.deep.property('points.length', 0); + }); +}); diff --git a/test/unit/pixi-v2/core/Rectangle.js b/test/unit/pixi-v2/core/Rectangle.js new file mode 100644 index 0000000..d43316e --- /dev/null +++ b/test/unit/pixi-v2/core/Rectangle.js @@ -0,0 +1,15 @@ +describe('pixi/core/Rectangle', function () { + 'use strict'; + + var expect = chai.expect; + var Rectangle = PIXI.Rectangle; + + it('Module exists', function () { + expect(Rectangle).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var rect = new Rectangle(); + pixi_core_Rectangle_confirm(rect, 0, 0, 0, 0); + }); +}); diff --git a/test/unit/pixi-v2/display/DisplayObject.js b/test/unit/pixi-v2/display/DisplayObject.js new file mode 100644 index 0000000..044acf8 --- /dev/null +++ b/test/unit/pixi-v2/display/DisplayObject.js @@ -0,0 +1,21 @@ +describe('pixi/display/DisplayObject', function () { + 'use strict'; + + var expect = chai.expect; + var DisplayObject = PIXI.DisplayObject; + + it('Module exists', function () { + expect(DisplayObject).to.be.a('function'); + // expect(PIXI).to.have.property('visibleCount', 0); + }); + + it('Confirm new instance', function () { + var obj = new DisplayObject(); + + pixi_display_DisplayObject_confirmNew(obj); + expect(obj).to.have.property('hitArea', null); + expect(obj).to.have.property('interactive', false); + expect(obj).to.have.property('renderable', false); + expect(obj).to.have.property('stage', null); + }); +}); diff --git a/test/unit/pixi-v2/display/DisplayObjectContainer.js b/test/unit/pixi-v2/display/DisplayObjectContainer.js new file mode 100644 index 0000000..15a3376 --- /dev/null +++ b/test/unit/pixi-v2/display/DisplayObjectContainer.js @@ -0,0 +1,67 @@ +describe('pixi/display/DisplayObjectContainer', function () { + 'use strict'; + + var expect = chai.expect; + var DisplayObjectContainer = PIXI.DisplayObjectContainer; + + it('Module exists', function () { + expect(DisplayObjectContainer).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new DisplayObjectContainer(); + + pixi_display_DisplayObjectContainer_confirmNew(obj); + expect(obj).to.have.property('hitArea', null); + expect(obj).to.have.property('interactive', false); + expect(obj).to.have.property('renderable', false); + expect(obj).to.have.property('stage', null); + }); + + it('Gets child index', function() { + var container = new PIXI.DisplayObjectContainer(); + var children = []; + for (var i = 0; i < 10; i++) { + var child = new PIXI.DisplayObject(); + children.push(child); + container.addChild(child); + } + + for (i = 0; i < children.length; i++) { + expect(i).to.eql(container.getChildIndex(children[i])); + } + }); + + it('throws error when trying to get index of not a child', function() { + var container = new PIXI.DisplayObjectContainer(); + var child = new PIXI.DisplayObject(); + + expect(function() { container.getChildIndex(child); }).to.throw(); + }); + + it('Sets child index', function() { + var container = new PIXI.DisplayObjectContainer(); + var children = []; + + for (var i = 0; i < 10; i++) { + var child = new PIXI.DisplayObject(); + children.push(child); + container.addChild(child); + } + children.reverse(); + + for (i = 0; i < children.length; i++) { + container.setChildIndex(children[i], i); + expect(i).to.eql(container.getChildIndex(children[i])); + } + }); + + it('throws error when trying to set incorect index', function() { + var container = new PIXI.DisplayObjectContainer(); + var child = new PIXI.DisplayObject(); + container.addChild(child); + + expect(function() { container.setChildIndex(child, -1); }).to.throw(); + expect(function() { container.setChildIndex(child, 1); }).to.throw(); + }); +}); diff --git a/test/unit/pixi-v2/display/MovieClip.js b/test/unit/pixi-v2/display/MovieClip.js new file mode 100644 index 0000000..f3c6c6a --- /dev/null +++ b/test/unit/pixi-v2/display/MovieClip.js @@ -0,0 +1,33 @@ +describe('pixi/display/MovieClip', function () { + 'use strict'; + + var expect = chai.expect; + var MovieClip = PIXI.MovieClip; + var Texture = PIXI.Texture; + + it('Module exists', function () { + expect(MovieClip).to.be.a('function'); + }); + + it('Confirm new instance', function (done) { + var texture = Texture.fromImage('/base/test/textures/SpriteSheet-Explosion.png'); + var obj = new MovieClip([texture]); + + pixi_display_Sprite_confirmNew(obj, done); + + expect(obj).to.be.an.instanceof(MovieClip); + expect(obj).to.respondTo('stop'); + expect(obj).to.respondTo('play'); + expect(obj).to.respondTo('gotoAndStop'); + expect(obj).to.respondTo('gotoAndPlay'); + expect(obj).to.respondTo('updateTransform'); + + expect(obj).to.have.deep.property('textures.length', 1); + expect(obj).to.have.deep.property('textures[0]', texture); + expect(obj).to.have.property('animationSpeed', 1); + expect(obj).to.have.property('loop', true); + expect(obj).to.have.property('onComplete', null); + expect(obj).to.have.property('currentFrame', 0); + expect(obj).to.have.property('playing', false); + }); +}); diff --git a/test/unit/pixi-v2/display/Sprite.js b/test/unit/pixi-v2/display/Sprite.js new file mode 100644 index 0000000..30c8076 --- /dev/null +++ b/test/unit/pixi-v2/display/Sprite.js @@ -0,0 +1,28 @@ +describe('pixi/display/Sprite', function () { + 'use strict'; + + var expect = chai.expect; + var Sprite = PIXI.Sprite; + var Texture = PIXI.Texture; + + it('Module exists', function () { + expect(Sprite).to.be.a('function'); + expect(PIXI).to.have.deep.property('blendModes.NORMAL', 0); + expect(PIXI).to.have.deep.property('blendModes.ADD', 1); + expect(PIXI).to.have.deep.property('blendModes.MULTIPLY', 2); + expect(PIXI).to.have.deep.property('blendModes.SCREEN', 3); + }); + + + it('Members exist', function () { + expect(Sprite).itself.to.respondTo('fromImage'); + expect(Sprite).itself.to.respondTo('fromFrame'); + }); + + it('Confirm new instance', function (done) { + var texture = Texture.fromImage('/base/test/textures/SpriteSheet-Aliens.png'); + var obj = new Sprite(texture); + + pixi_display_Sprite_confirmNew(obj, done); + }); +}); diff --git a/test/unit/pixi-v2/display/Stage.js b/test/unit/pixi-v2/display/Stage.js new file mode 100644 index 0000000..6974c2e --- /dev/null +++ b/test/unit/pixi-v2/display/Stage.js @@ -0,0 +1,49 @@ +describe('pixi/display/Stage', function () { + 'use strict'; + + var expect = chai.expect; + var Stage = PIXI.Stage; + var InteractionManager = PIXI.InteractionManager; + var Rectangle = PIXI.Rectangle; + + it('Module exists', function () { + expect(Stage).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Stage(null, true); + + pixi_display_DisplayObjectContainer_confirmNew(obj); + + expect(obj).to.be.an.instanceof(Stage); + expect(obj).to.respondTo('updateTransform'); + expect(obj).to.respondTo('setBackgroundColor'); + expect(obj).to.respondTo('getMousePosition'); + // FIXME: duplicate member in DisplayObject + pixi_core_Matrix_confirmNewMatrix(obj.worldTransform); + // FIXME: convert arg to bool in constructor + expect(obj).to.have.property('interactive', true); + + expect(obj).to.have.property('interactionManager') + .and.to.be.an.instanceof(InteractionManager) + .and.to.have.property('stage', obj); + + expect(obj).to.have.property('dirty', true); + + expect(obj).to.have.property('stage', obj); + + expect(obj).to.have.property('hitArea') + .and.to.be.an.instanceof(Rectangle); + pixi_core_Rectangle_confirm(obj.hitArea, 0, 0, 100000, 100000); + + expect(obj).to.have.property('backgroundColor', 0x000000); + expect(obj).to.have.deep.property('backgroundColorSplit.length', 3); + expect(obj).to.have.deep.property('backgroundColorSplit[0]', 0); + expect(obj).to.have.deep.property('backgroundColorSplit[1]', 0); + expect(obj).to.have.deep.property('backgroundColorSplit[2]', 0); + expect(obj).to.have.property('backgroundColorString', '#000000'); + + + expect(obj).to.have.property('worldVisible', true); + }); +}); diff --git a/test/unit/pixi-v2/extras/Rope.js b/test/unit/pixi-v2/extras/Rope.js new file mode 100644 index 0000000..05885ac --- /dev/null +++ b/test/unit/pixi-v2/extras/Rope.js @@ -0,0 +1,31 @@ +describe('pixi/extras/Rope', function () { + 'use strict'; + + var expect = chai.expect; + var Rope = PIXI.Rope; + var Texture = PIXI.Texture; + var Point = PIXI.Point; + + it('Module exists', function () { + expect(Rope).to.be.a('function'); + }); + + it('Confirm new instance', function () { + + var texture = Texture.fromImage('/base/test/textures/bunny.png'); + + // TODO-Alvin + // Same as Strip + + // var obj = new Rope(texture, [new Point(), new Point(5, 10), new Point(10, 20)]); + + // pixi_extras_Strip_confirmNew(obj); + + // expect(obj).to.be.an.instanceof(Rope); + // expect(obj).to.respondTo('refresh'); + // expect(obj).to.respondTo('updateTransform'); + // expect(obj).to.respondTo('setTexture'); + + // TODO: Test properties + }); +}); diff --git a/test/unit/pixi-v2/extras/Spine.js b/test/unit/pixi-v2/extras/Spine.js new file mode 100644 index 0000000..0708bc0 --- /dev/null +++ b/test/unit/pixi-v2/extras/Spine.js @@ -0,0 +1,10 @@ +describe('pixi/extras/Spine', function () { + 'use strict'; + + var expect = chai.expect; + var Spine = PIXI.Spine; + + it('Module exists', function () { + expect(Spine).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/extras/Strip.js b/test/unit/pixi-v2/extras/Strip.js new file mode 100644 index 0000000..230af90 --- /dev/null +++ b/test/unit/pixi-v2/extras/Strip.js @@ -0,0 +1,26 @@ +describe('pixi/extras/Strip', function () { + 'use strict'; + + var expect = chai.expect; + var Strip = PIXI.Strip; + var Texture = PIXI.Texture; + + it('Module exists', function () { + expect(Strip).to.be.a('function'); + }); + + it('Confirm new instance', function () { + + + // TODO-Alvin + // We tweaked it to make it pass the tests, but the whole strip class needs + // to be re-coded + + var texture = Texture.fromImage('/base/test/textures/bunny.png'); + + // var obj = new Strip(texture, 20, 10000); + + + // pixi_extras_Strip_confirmNew(obj); + }); +}); diff --git a/test/unit/pixi-v2/extras/TilingSprite.js b/test/unit/pixi-v2/extras/TilingSprite.js new file mode 100644 index 0000000..56aea14 --- /dev/null +++ b/test/unit/pixi-v2/extras/TilingSprite.js @@ -0,0 +1,24 @@ +describe('pixi/extras/TilingSprite', function () { + 'use strict'; + + var expect = chai.expect; + var TilingSprite = PIXI.TilingSprite; + var Texture = PIXI.Texture; + + it('Module exists', function () { + expect(TilingSprite).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var texture = Texture.fromImage('/base/test/textures/bunny.png'); + var obj = new TilingSprite(texture, 6000, 12000); + + pixi_display_DisplayObjectContainer_confirmNew(obj); + + expect(obj).to.be.an.instanceof(TilingSprite); + expect(obj).to.respondTo('setTexture'); + expect(obj).to.respondTo('onTextureUpdate'); + + // TODO: Test properties + }); +}); diff --git a/test/unit/pixi-v2/filters/FilterBlock.js b/test/unit/pixi-v2/filters/FilterBlock.js new file mode 100644 index 0000000..870cec0 --- /dev/null +++ b/test/unit/pixi-v2/filters/FilterBlock.js @@ -0,0 +1,10 @@ +describe('pixi/filters/FilterBlock', function () { + 'use strict'; + + var expect = chai.expect; + var FilterBlock = PIXI.FilterBlock; + + it('Module exists', function () { + expect(FilterBlock).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/AssetLoader.js b/test/unit/pixi-v2/loaders/AssetLoader.js new file mode 100644 index 0000000..a0aa0b5 --- /dev/null +++ b/test/unit/pixi-v2/loaders/AssetLoader.js @@ -0,0 +1,10 @@ +describe('pixi/loaders/AssetLoader', function () { + 'use strict'; + + var expect = chai.expect; + var AssetLoader = PIXI.AssetLoader; + + it('Module exists', function () { + expect(AssetLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/BitmapFontLoader.js b/test/unit/pixi-v2/loaders/BitmapFontLoader.js new file mode 100644 index 0000000..046f018 --- /dev/null +++ b/test/unit/pixi-v2/loaders/BitmapFontLoader.js @@ -0,0 +1,9 @@ +describe('pixi/loaders/BitmapFontLoader', function () { + 'use strict'; + + var expect = chai.expect; + + it('Module exists', function () { + expect(PIXI.BitmapFontLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/ImageLoader.js b/test/unit/pixi-v2/loaders/ImageLoader.js new file mode 100644 index 0000000..8b1f556 --- /dev/null +++ b/test/unit/pixi-v2/loaders/ImageLoader.js @@ -0,0 +1,10 @@ +describe('pixi/loaders/ImageLoader', function () { + 'use strict'; + + var expect = chai.expect; + var ImageLoader = PIXI.ImageLoader; + + it('Module exists', function () { + expect(ImageLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/JsonLoader.js b/test/unit/pixi-v2/loaders/JsonLoader.js new file mode 100644 index 0000000..c577e83 --- /dev/null +++ b/test/unit/pixi-v2/loaders/JsonLoader.js @@ -0,0 +1,10 @@ +describe('pixi/loaders/JsonLoader', function () { + 'use strict'; + + var expect = chai.expect; + var JsonLoader = PIXI.JsonLoader; + + it('Module exists', function () { + expect(JsonLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/SpineLoader.js b/test/unit/pixi-v2/loaders/SpineLoader.js new file mode 100644 index 0000000..fdcc0b8 --- /dev/null +++ b/test/unit/pixi-v2/loaders/SpineLoader.js @@ -0,0 +1,10 @@ +describe('pixi/loaders/SpineLoader', function () { + 'use strict'; + + var expect = chai.expect; + var SpineLoader = PIXI.SpineLoader; + + it('Module exists', function () { + expect(SpineLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/SpriteSheetLoader.js b/test/unit/pixi-v2/loaders/SpriteSheetLoader.js new file mode 100644 index 0000000..57beb27 --- /dev/null +++ b/test/unit/pixi-v2/loaders/SpriteSheetLoader.js @@ -0,0 +1,10 @@ +describe('pixi/loaders/SpriteSheetLoader', function () { + 'use strict'; + + var expect = chai.expect; + var SpriteSheetLoader = PIXI.SpriteSheetLoader; + + it('Module exists', function () { + expect(SpriteSheetLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/primitives/Graphics.js b/test/unit/pixi-v2/primitives/Graphics.js new file mode 100644 index 0000000..f3849eb --- /dev/null +++ b/test/unit/pixi-v2/primitives/Graphics.js @@ -0,0 +1,44 @@ +describe('pixi/primitives/Graphics', function () { + 'use strict'; + + var expect = chai.expect; + var Graphics = PIXI.Graphics; + + it('Module exists', function () { + expect(Graphics).to.be.a('function'); + + expect(Graphics).itself.to.have.property('POLY', 0); + expect(Graphics).itself.to.have.property('RECT', 1); + expect(Graphics).itself.to.have.property('CIRC', 2); + expect(Graphics).itself.to.have.property('ELIP', 3); + expect(Graphics).itself.to.have.property('RREC', 4); + }); + + it('Confirm new instance', function () { + var obj = new Graphics(); + + pixi_display_DisplayObjectContainer_confirmNew(obj); + + expect(obj).to.be.an.instanceof(Graphics); + expect(obj).to.respondTo('lineStyle'); + expect(obj).to.respondTo('lineStyle'); + expect(obj).to.respondTo('moveTo'); + expect(obj).to.respondTo('lineTo'); + expect(obj).to.respondTo('beginFill'); + expect(obj).to.respondTo('endFill'); + expect(obj).to.respondTo('drawRect'); + // expect(obj).to.respondTo('drawRoundedRect'); + expect(obj).to.respondTo('drawCircle'); + expect(obj).to.respondTo('drawEllipse'); + expect(obj).to.respondTo('clear'); + + expect(obj).to.have.property('renderable', true); + expect(obj).to.have.property('fillAlpha', 1); + expect(obj).to.have.property('lineWidth', 0); + expect(obj).to.have.property('width', 0); + expect(obj).to.have.property('height', 0); + expect(obj).to.have.property('lineColor', 0); + expect(obj).to.have.deep.property('graphicsData.length', 0); + // expect(obj).to.have.deep.property('currentPath.points.length', 0); + }); +}); diff --git a/test/unit/pixi-v2/renderers/canvas/CanvasGraphics.js b/test/unit/pixi-v2/renderers/canvas/CanvasGraphics.js new file mode 100644 index 0000000..8f44472 --- /dev/null +++ b/test/unit/pixi-v2/renderers/canvas/CanvasGraphics.js @@ -0,0 +1,15 @@ +describe('renders/canvas/CanvasGraphics', function () { + 'use strict'; + + var expect = chai.expect; + var CanvasGraphics = PIXI.CanvasGraphics; + + it('Module exists', function () { + expect(CanvasGraphics).to.be.a('function'); + }); + + it('Members exist', function () { + expect(CanvasGraphics).itself.to.respondTo('renderGraphics'); + expect(CanvasGraphics).itself.to.respondTo('renderGraphicsMask'); + }); +}); diff --git a/test/unit/pixi-v2/renderers/canvas/CanvasRenderer.js b/test/unit/pixi-v2/renderers/canvas/CanvasRenderer.js new file mode 100644 index 0000000..1646444 --- /dev/null +++ b/test/unit/pixi-v2/renderers/canvas/CanvasRenderer.js @@ -0,0 +1,36 @@ +describe('renderers/canvas/CanvasRenderer', function () { + 'use strict'; + + var expect = chai.expect; + var CanvasRenderer = PIXI.CanvasRenderer; + + it('Module exists', function () { + expect(CanvasRenderer).to.be.a('function'); + }); + + describe('.autoResize', function () { + it('Should automatically resize view if enabled', function () { + var renderer = new CanvasRenderer(200, 200, { + autoResize: true + }); + + expect(renderer.view.style.width).to.equal('200px'); + }); + + it('Should not automatically resize view if disabled', function () { + var renderer = new CanvasRenderer(200, 200, { + autoResize: false + }); + + expect(renderer.view.style.width).to.equal(''); + }); + + it('Should not automatically resize view if not specified', function () { + var renderer = new CanvasRenderer(200, 200, { + resolution: 2 + }); + + expect(renderer.view.style.width).to.equal(''); + }); + }); +}); diff --git a/test/unit/pixi-v2/renderers/webgl/WebGLGraphics.js b/test/unit/pixi-v2/renderers/webgl/WebGLGraphics.js new file mode 100644 index 0000000..5867b28 --- /dev/null +++ b/test/unit/pixi-v2/renderers/webgl/WebGLGraphics.js @@ -0,0 +1,20 @@ +describe('renderers/wegbl/WebGLGraphics', function () { + 'use strict'; + + var expect = chai.expect; + var WebGLGraphics = PIXI.WebGLGraphics; + + it('Module exists', function () { + expect(WebGLGraphics).to.be.a('function'); + }); + + it('Members exist', function () { + expect(WebGLGraphics).itself.to.respondTo('renderGraphics'); + expect(WebGLGraphics).itself.to.respondTo('updateGraphics'); + expect(WebGLGraphics).itself.to.respondTo('buildRectangle'); + expect(WebGLGraphics).itself.to.respondTo('buildRoundedRectangle'); + expect(WebGLGraphics).itself.to.respondTo('buildCircle'); + expect(WebGLGraphics).itself.to.respondTo('buildLine'); + expect(WebGLGraphics).itself.to.respondTo('buildPoly'); + }); +}); diff --git a/test/unit/pixi-v2/renderers/webgl/WebGLRenderer.js b/test/unit/pixi-v2/renderers/webgl/WebGLRenderer.js new file mode 100644 index 0000000..1680a80 --- /dev/null +++ b/test/unit/pixi-v2/renderers/webgl/WebGLRenderer.js @@ -0,0 +1,49 @@ +describe('renderers/webgl/WebGLRenderer', function () { + 'use strict'; + + var expect = chai.expect; + var WebGLRenderer = PIXI.WebGLRenderer; + + it('Module exists', function () { + expect(WebGLRenderer).to.be.a('function'); + }); + + // Skip tests if WebGL is not available (WebGL not supported in Travis CI) + try { + var renderer = new WebGLRenderer(400, 300, {}); + renderer.destroy(); + } catch (error) { + return; + } + + it('Destroy renderer', function () { + var renderer = new WebGLRenderer(400, 300, {}); + renderer.destroy(); + }); + + describe('.autoResize', function () { + it('Should automatically resize view if enabled', function () { + var renderer = new WebGLRenderer(200, 200, { + autoResize: true + }); + + expect(renderer.view.style.width).to.equal('200px'); + }); + + it('Should not automatically resize view if disabled', function () { + var renderer = new WebGLRenderer(200, 200, { + autoResize: false + }); + + expect(renderer.view.style.width).to.equal(''); + }); + + it('Should not automatically resize view if not specified', function () { + var renderer = new WebGLRenderer(200, 200, { + resolution: 2 + }); + + expect(renderer.view.style.width).to.equal(''); + }); + }); +}); diff --git a/test/unit/pixi-v2/renderers/webgl/WebGLShaders.js b/test/unit/pixi-v2/renderers/webgl/WebGLShaders.js new file mode 100644 index 0000000..6e33e4f --- /dev/null +++ b/test/unit/pixi-v2/renderers/webgl/WebGLShaders.js @@ -0,0 +1,13 @@ +describe('renderers/webgl/WebGLShaders', function () { + 'use strict'; + + var expect = chai.expect; + + it('Module members exist', function () { + + expect(PIXI).to.respondTo('CompileVertexShader'); + expect(PIXI).to.respondTo('CompileFragmentShader'); + expect(PIXI).to.respondTo('_CompileShader'); + expect(PIXI).to.respondTo('compileProgram'); + }); +}); diff --git a/test/unit/pixi-v2/renderers/webgl/WebGLSpriteBatch.js b/test/unit/pixi-v2/renderers/webgl/WebGLSpriteBatch.js new file mode 100644 index 0000000..e662b63 --- /dev/null +++ b/test/unit/pixi-v2/renderers/webgl/WebGLSpriteBatch.js @@ -0,0 +1,10 @@ +describe('renderers/webgl/utils/WebGLSpriteBatch', function () { + 'use strict'; + + var expect = chai.expect; + var WebGLSpriteBatch = PIXI.WebGLSpriteBatch; + + it('Module exists', function () { + expect(WebGLSpriteBatch).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/text/BitmapText.js b/test/unit/pixi-v2/text/BitmapText.js new file mode 100644 index 0000000..9388e3d --- /dev/null +++ b/test/unit/pixi-v2/text/BitmapText.js @@ -0,0 +1,10 @@ +describe('pixi/text/BitmapText', function () { + 'use strict'; + + var expect = chai.expect; + var BitmapText = PIXI.BitmapText; + + it('Module exists', function () { + expect(BitmapText).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/text/Text.js b/test/unit/pixi-v2/text/Text.js new file mode 100644 index 0000000..9bc9ac5 --- /dev/null +++ b/test/unit/pixi-v2/text/Text.js @@ -0,0 +1,10 @@ +describe('pixi/text/Text', function () { + 'use strict'; + + var expect = chai.expect; + var Text = PIXI.Text; + + it('Module exists', function () { + expect(Text).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/textures/BaseTexture.js b/test/unit/pixi-v2/textures/BaseTexture.js new file mode 100644 index 0000000..502b724 --- /dev/null +++ b/test/unit/pixi-v2/textures/BaseTexture.js @@ -0,0 +1,11 @@ +describe('pixi/textures/BaseTexture', function () { + 'use strict'; + + var expect = chai.expect; + var BaseTexture = PIXI.BaseTexture; + + it('Module exists', function () { + expect(BaseTexture).to.be.a('function'); + expect(PIXI).to.have.property('BaseTextureCache').and.to.be.an('object'); + }); +}); diff --git a/test/unit/pixi-v2/textures/RenderTexture.js b/test/unit/pixi-v2/textures/RenderTexture.js new file mode 100644 index 0000000..96acdb4 --- /dev/null +++ b/test/unit/pixi-v2/textures/RenderTexture.js @@ -0,0 +1,15 @@ +describe('pixi/textures/RenderTexture', function () { + 'use strict'; + + var expect = chai.expect; + var RenderTexture = PIXI.RenderTexture; + + it('Module exists', function () { + expect(RenderTexture).to.be.a('function'); + }); + + it('Confirm new instance', function (done) { + var texture = new RenderTexture(100, 100, new PIXI.CanvasRenderer()); + pixi_textures_RenderTexture_confirmNew(texture, done); + }); +}); diff --git a/test/unit/pixi-v2/textures/Texture.js b/test/unit/pixi-v2/textures/Texture.js new file mode 100644 index 0000000..090f64d --- /dev/null +++ b/test/unit/pixi-v2/textures/Texture.js @@ -0,0 +1,26 @@ +describe('pixi/textures/Texture', function () { + 'use strict'; + + var expect = chai.expect; + var Texture = PIXI.Texture; + + it('Module exists', function () { + expect(Texture).to.be.a('function'); + expect(PIXI).to.have.property('TextureCache').and.to.be.an('object'); + }); + + it('Members exist', function () { + expect(Texture).itself.to.respondTo('fromImage'); + expect(Texture).itself.to.respondTo('fromFrame'); + expect(Texture).itself.to.respondTo('fromCanvas'); + expect(Texture).itself.to.respondTo('addTextureToCache'); + expect(Texture).itself.to.respondTo('removeTextureFromCache'); + + // expect(Texture).itself.to.have.deep.property('frameUpdates.length', 0); + }); + + it('Confirm new instance', function (done) { + var texture = Texture.fromImage('/base/test/textures/bunny.png'); + pixi_textures_Texture_confirmNew(texture, done); + }); +}); diff --git a/test/unit/pixi-v2/utils/Detector.js b/test/unit/pixi-v2/utils/Detector.js new file mode 100644 index 0000000..4cf6008 --- /dev/null +++ b/test/unit/pixi-v2/utils/Detector.js @@ -0,0 +1,10 @@ +describe('pixi/utils/Detector', function () { + 'use strict'; + + var expect = chai.expect; + var autoDetectRenderer = PIXI.autoDetectRenderer; + + it('Module exists', function () { + expect(autoDetectRenderer).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/utils/EventTarget.js b/test/unit/pixi-v2/utils/EventTarget.js new file mode 100644 index 0000000..1cfc3a4 --- /dev/null +++ b/test/unit/pixi-v2/utils/EventTarget.js @@ -0,0 +1,361 @@ +describe('pixi/utils/EventTarget', function () { + 'use strict'; + + var expect = chai.expect; + + var Clazz, PClazz, obj, pobj, obj2; + beforeEach(function () { + Clazz = function () {}; + PClazz = function () {}; + + PIXI.EventTarget.mixin(Clazz.prototype); + PIXI.EventTarget.mixin(PClazz.prototype); + + obj = new Clazz(); + obj2 = new Clazz(); + pobj = new PClazz(); + + obj.parent = pobj; + obj2.parent = obj; + }); + + it('Module exists', function () { + expect(PIXI.EventTarget).to.be.an('object'); + }); + + it('Confirm new instance', function () { + pixi_utils_EventTarget_confirm(obj); + }); + + it('simple on/emit case works', function () { + var myData = {}; + + obj.on('myevent', function (event) { + pixi_utils_EventTarget_Event_confirm(event, obj, myData); + }); + + obj.emit('myevent', myData); + }); + + it('simple once case works', function () { + var called = 0; + + obj.once('myevent', function() { called++; }); + + obj.emit('myevent'); + obj.emit('myevent'); + obj.emit('myevent'); + obj.emit('myevent'); + obj.emit('myevent'); + + expect(called).to.equal(1); + }); + + it('simple off case works', function (done) { + function onMyEvent() { + done(new Error('Event listener should not have been called')); + } + + obj.on('myevent', onMyEvent); + obj.off('myevent', onMyEvent); + obj.emit('myevent'); + + done(); + }); + + it('simple propagation case works', function (done) { + var myData = {}; + + pobj.on('myevent', function () { + done(); + }); + + obj.emit('myevent'); + }); + + it('simple stopPropagation case works', function (done) { + var myData = {}; + + pobj.on('myevent', function () { + done(new Error('Event listener should not have been called on the parent element')); + }); + + obj.on('myevent', function (evt) { + evt.stopPropagation(); + }); + + obj.emit('myevent'); + + done(); + }); + + it('simple stopImmediatePropagation case works', function (done) { + var myData = {}; + + pobj.on('myevent', function () { + done(new Error('Event listener should not have been called on the parent')); + }); + + obj.on('myevent', function (evt) { + evt.stopImmediatePropagation(); + }); + + obj.on('myevent', function () { + done(new Error('Event listener should not have been called on the second')); + }); + + obj.emit('myevent'); + + done(); + }); + + it('multiple dispatches work properly', function () { + var called = 0; + + function onMyEvent() { + called++; + } + + obj.on('myevent', onMyEvent); + obj.emit('myevent'); + obj.emit('myevent'); + obj.emit('myevent'); + obj.emit('myevent'); + + expect(called).to.equal(4); + }); + + it('multiple events work properly', function () { + var called = 0; + + function onMyEvent() { + called++; + } + + obj.on('myevent1', onMyEvent); + obj.on('myevent2', onMyEvent); + obj.on('myevent3', onMyEvent); + obj.emit('myevent1'); + obj.emit('myevent2'); + obj.emit('myevent3'); + + expect(called).to.equal(3); + }); + + it('multiple events one removed works properly', function () { + var called = 0; + + function onMyEvent() { + called++; + } + + obj.on('myevent1', onMyEvent); + obj.on('myevent2', onMyEvent); + obj.on('myevent3', onMyEvent); + + obj.emit('myevent1'); + obj.emit('myevent2'); + obj.emit('myevent3'); + + obj.off('myevent2', onMyEvent); + + obj.emit('myevent1'); + obj.emit('myevent2'); + obj.emit('myevent3'); + + expect(called).to.equal(5); + }); + + it('multiple handlers for one event with some removed', function () { + var called = 0; + + var onMyEvent = function () { + called++; + }, + onMyEvent2 = function () { + called++; + }; + + // add 2 handlers and confirm they both get called + obj.on('myevent', onMyEvent); + obj.on('myevent', onMyEvent); + obj.on('myevent', onMyEvent2); + obj.on('myevent', onMyEvent2); + + obj.emit('myevent'); + + expect(called).to.equal(4); + + // remove one of the handlers, emit again, then ensure 1 more call is made + obj.off('myevent', onMyEvent); + + obj.emit('myevent'); + + expect(called).to.equal(6); + }); + + it('calls to off without a handler do nothing', function () { + var called = 0; + + var onMyEvent = function () { + called++; + }; + + obj.on('myevent', onMyEvent); + obj.on('myevent', onMyEvent); + + obj.emit('myevent'); + + expect(called).to.equal(2); + + obj.off('myevent'); + + obj.emit('myevent'); + + expect(called).to.equal(4); + + obj.off('myevent', onMyEvent); + + obj.emit('myevent'); + + expect(called).to.equal(4); + }); + + it('handles multiple instances with the same prototype', function () { + var called = 0; + + function onMyEvent(e) { + called++; + } + + obj.on('myevent1', onMyEvent); + obj.on('myevent2', onMyEvent); + + obj2.istwo = true; + obj2.on('myevent1', onMyEvent); + obj2.on('myevent2', onMyEvent); + + obj.emit('myevent1'); + obj.emit('myevent2'); + obj2.emit('myevent1'); + obj2.emit('myevent2'); + + //we emit 4 times, but since obj2 is a child of obj the event should bubble + //up to obj and show up there as well. So the obj2.emit() calls each increment + //the counter twice. + expect(called).to.equal(6); + }); + + it('is backwards compatible with older .dispatchEvent({})', function () { + var called = 0, + data = { + some: 'thing', + hello: true + }; + + function onMyEvent(event) { + pixi_utils_EventTarget_Event_confirm(event, obj, data); + + called++; + } + + obj.on('myevent1', onMyEvent); + obj.on('myevent2', onMyEvent); + obj.on('myevent3', onMyEvent); + + data.type = 'myevent1'; + obj.emit(data); + + data.type = 'myevent2'; + obj.emit(data); + + data.type = 'myevent3'; + obj.emit(data); + + obj.off('myevent2', onMyEvent); + + data.type = 'myevent1'; + obj.emit(data); + + data.type = 'myevent2'; + obj.emit(data); + + data.type = 'myevent3'; + obj.emit(data); + + expect(called).to.equal(5); + }); + + it('is backwards compatible with older .call(this)', function () { + var Fn = function() { + PIXI.EventTarget.call(this); + }, + o = new Fn(); + + pixi_utils_EventTarget_confirm(o); + }); + + it('is backwards compatible with older .addEventListener("")', function () { + var called = 0, + data = { + some: 'thing', + hello: true + }; + + function onMyEvent(event) { + pixi_utils_EventTarget_Event_confirm(event, obj, data); + + called++; + } + + obj.addEventListener('myevent1', onMyEvent); + obj.addEventListener('myevent2', onMyEvent); + obj.addEventListener('myevent3', onMyEvent); + + data.type = 'myevent1'; + obj.emit(data); + + data.type = 'myevent2'; + obj.emit(data); + + data.type = 'myevent3'; + obj.emit(data); + + obj.off('myevent2', onMyEvent); + + data.type = 'myevent1'; + obj.emit(data); + + data.type = 'myevent2'; + obj.emit(data); + + data.type = 'myevent3'; + obj.emit(data); + + expect(called).to.equal(5); + }); + + it('event remove during emit call properly', function () { + var called = 0; + + function cb1() { + called++; + obj.off('myevent', cb1); + } + function cb2() { + called++; + obj.off('myevent', cb2); + } + function cb3() { + called++; + obj.off('myevent', cb3); + } + + obj.on('myevent', cb1); + obj.on('myevent', cb2); + obj.on('myevent', cb3); + obj.emit('myevent', ''); + + expect(called).to.equal(3); + }); +}); diff --git a/test/unit/pixi-v2/utils/Polyk.js b/test/unit/pixi-v2/utils/Polyk.js new file mode 100644 index 0000000..dfc7128 --- /dev/null +++ b/test/unit/pixi-v2/utils/Polyk.js @@ -0,0 +1,14 @@ +describe('pixi/utils/Polyk', function () { + 'use strict'; + + var expect = chai.expect; + var PolyK = PIXI.PolyK; + + it('Module exists', function () { + expect(PolyK).to.be.an('object'); + }); + + it('Members exist', function () { + expect(PolyK).to.respondTo('Triangulate'); + }); +}); diff --git a/test/unit/pixi-v2/utils/Utils.js b/test/unit/pixi-v2/utils/Utils.js new file mode 100644 index 0000000..c97b3c6 --- /dev/null +++ b/test/unit/pixi-v2/utils/Utils.js @@ -0,0 +1,17 @@ +describe('Utils', function () { + 'use strict'; + + var expect = chai.expect; + + it('requestAnimationFrame exists', function () { + expect(global).to.respondTo('requestAnimationFrame'); + }); + + it('cancelAnimationFrame exists', function () { + expect(global).to.respondTo('cancelAnimationFrame'); + }); + + it('requestAnimFrame exists', function () { + expect(global).to.respondTo('requestAnimFrame'); + }); +}); diff --git a/test/unit/pixi/InteractionManager.js b/test/unit/pixi/InteractionManager.js deleted file mode 100644 index ed3001f..0000000 --- a/test/unit/pixi/InteractionManager.js +++ /dev/null @@ -1,10 +0,0 @@ -describe('pixi/InteractionManager', function () { - 'use strict'; - - var expect = chai.expect; - var InteractionManager = PIXI.InteractionManager; - - it('Module exists', function () { - expect(InteractionManager).to.be.a('function'); - }); -}); diff --git a/test/unit/pixi/Pixi.js b/test/unit/pixi/Pixi.js deleted file mode 100644 index 27debc1..0000000 --- a/test/unit/pixi/Pixi.js +++ /dev/null @@ -1,9 +0,0 @@ -describe('pixi/Pixi', function () { - 'use strict'; - - var expect = chai.expect; - - it('Module exists', function () { - expect(global).to.have.property('PIXI').and.to.be.an('object'); - }); -}); diff --git a/test/unit/pixi/core/Circle.js b/test/unit/pixi/core/Circle.js deleted file mode 100644 index fbcfa17..0000000 --- a/test/unit/pixi/core/Circle.js +++ /dev/null @@ -1,21 +0,0 @@ -describe('pixi/core/Circle', function () { - 'use strict'; - - var expect = chai.expect; - var Circle = PIXI.Circle; - - it('Module exists', function () { - expect(Circle).to.be.a('function'); - }); - - it('Confirm new instance', function () { - var obj = new Circle(); - pixi_core_Circle_confirmNewCircle(obj); - }); - - it("getBounds should return Rectangle that bounds the circle", function() { - var obj = new Circle(100, 250, 50); - var bounds = obj.getBounds(); - pixi_core_Circle_isBoundedByRectangle(obj, bounds); - }); -}); diff --git a/test/unit/pixi/core/Ellipse.js b/test/unit/pixi/core/Ellipse.js deleted file mode 100644 index 026b56f..0000000 --- a/test/unit/pixi/core/Ellipse.js +++ /dev/null @@ -1,24 +0,0 @@ -describe('pixi/core/Ellipse', function () { - 'use strict'; - - var expect = chai.expect; - var Ellipse = PIXI.Ellipse; - - it('Module exists', function () { - expect(Ellipse).to.be.a('function'); - }); - - it('Confirm new instance', function () { - var obj = new Ellipse(); - - expect(obj).to.be.an.instanceof(Ellipse); - expect(obj).to.respondTo('clone'); - expect(obj).to.respondTo('contains'); - expect(obj).to.respondTo('getBounds'); - - expect(obj).to.have.property('x', 0); - expect(obj).to.have.property('y', 0); - expect(obj).to.have.property('width', 0); - expect(obj).to.have.property('height', 0); - }); -}); diff --git a/test/unit/pixi/core/Matrix.js b/test/unit/pixi/core/Matrix.js deleted file mode 100644 index da75e2e..0000000 --- a/test/unit/pixi/core/Matrix.js +++ /dev/null @@ -1,14 +0,0 @@ -describe('pixi/core/Matrix', function () { - 'use strict'; - - var expect = chai.expect; - - it('Matrix exists', function () { - expect(PIXI.Matrix).to.be.an('function'); - }); - - it('Confirm new Matrix', function () { - var matrix = new PIXI.Matrix(); - pixi_core_Matrix_confirmNewMatrix(matrix); - }); -}); diff --git a/test/unit/pixi/core/Point.js b/test/unit/pixi/core/Point.js deleted file mode 100644 index c4d5163..0000000 --- a/test/unit/pixi/core/Point.js +++ /dev/null @@ -1,15 +0,0 @@ -describe('pixi/core/Point', function () { - 'use strict'; - - var expect = chai.expect; - var Point = PIXI.Point; - - it('Module exists', function () { - expect(Point).to.be.a('function'); - }); - - it('Confirm new instance', function () { - var obj = new Point(); - pixi_core_Point_confirm(obj, 0, 0); - }); -}); diff --git a/test/unit/pixi/core/Polygon.js b/test/unit/pixi/core/Polygon.js deleted file mode 100644 index dc8c918..0000000 --- a/test/unit/pixi/core/Polygon.js +++ /dev/null @@ -1,20 +0,0 @@ -describe('pixi/core/Polygon', function () { - 'use strict'; - - var expect = chai.expect; - var Polygon = PIXI.Polygon; - - it('Module exists', function () { - expect(Polygon).to.be.a('function'); - }); - - it('Confirm new instance', function () { - var obj = new Polygon(); - - expect(obj).to.be.an.instanceof(Polygon); - expect(obj).to.respondTo('clone'); - expect(obj).to.respondTo('contains'); - - expect(obj).to.have.deep.property('points.length', 0); - }); -}); diff --git a/test/unit/pixi/core/Rectangle.js b/test/unit/pixi/core/Rectangle.js deleted file mode 100644 index d43316e..0000000 --- a/test/unit/pixi/core/Rectangle.js +++ /dev/null @@ -1,15 +0,0 @@ -describe('pixi/core/Rectangle', function () { - 'use strict'; - - var expect = chai.expect; - var Rectangle = PIXI.Rectangle; - - it('Module exists', function () { - expect(Rectangle).to.be.a('function'); - }); - - it('Confirm new instance', function () { - var rect = new Rectangle(); - pixi_core_Rectangle_confirm(rect, 0, 0, 0, 0); - }); -}); diff --git a/test/unit/pixi/display/DisplayObject.js b/test/unit/pixi/display/DisplayObject.js deleted file mode 100644 index 044acf8..0000000 --- a/test/unit/pixi/display/DisplayObject.js +++ /dev/null @@ -1,21 +0,0 @@ -describe('pixi/display/DisplayObject', function () { - 'use strict'; - - var expect = chai.expect; - var DisplayObject = PIXI.DisplayObject; - - it('Module exists', function () { - expect(DisplayObject).to.be.a('function'); - // expect(PIXI).to.have.property('visibleCount', 0); - }); - - it('Confirm new instance', function () { - var obj = new DisplayObject(); - - pixi_display_DisplayObject_confirmNew(obj); - expect(obj).to.have.property('hitArea', null); - expect(obj).to.have.property('interactive', false); - expect(obj).to.have.property('renderable', false); - expect(obj).to.have.property('stage', null); - }); -}); diff --git a/test/unit/pixi/display/DisplayObjectContainer.js b/test/unit/pixi/display/DisplayObjectContainer.js deleted file mode 100644 index 15a3376..0000000 --- a/test/unit/pixi/display/DisplayObjectContainer.js +++ /dev/null @@ -1,67 +0,0 @@ -describe('pixi/display/DisplayObjectContainer', function () { - 'use strict'; - - var expect = chai.expect; - var DisplayObjectContainer = PIXI.DisplayObjectContainer; - - it('Module exists', function () { - expect(DisplayObjectContainer).to.be.a('function'); - }); - - it('Confirm new instance', function () { - var obj = new DisplayObjectContainer(); - - pixi_display_DisplayObjectContainer_confirmNew(obj); - expect(obj).to.have.property('hitArea', null); - expect(obj).to.have.property('interactive', false); - expect(obj).to.have.property('renderable', false); - expect(obj).to.have.property('stage', null); - }); - - it('Gets child index', function() { - var container = new PIXI.DisplayObjectContainer(); - var children = []; - for (var i = 0; i < 10; i++) { - var child = new PIXI.DisplayObject(); - children.push(child); - container.addChild(child); - } - - for (i = 0; i < children.length; i++) { - expect(i).to.eql(container.getChildIndex(children[i])); - } - }); - - it('throws error when trying to get index of not a child', function() { - var container = new PIXI.DisplayObjectContainer(); - var child = new PIXI.DisplayObject(); - - expect(function() { container.getChildIndex(child); }).to.throw(); - }); - - it('Sets child index', function() { - var container = new PIXI.DisplayObjectContainer(); - var children = []; - - for (var i = 0; i < 10; i++) { - var child = new PIXI.DisplayObject(); - children.push(child); - container.addChild(child); - } - children.reverse(); - - for (i = 0; i < children.length; i++) { - container.setChildIndex(children[i], i); - expect(i).to.eql(container.getChildIndex(children[i])); - } - }); - - it('throws error when trying to set incorect index', function() { - var container = new PIXI.DisplayObjectContainer(); - var child = new PIXI.DisplayObject(); - container.addChild(child); - - expect(function() { container.setChildIndex(child, -1); }).to.throw(); - expect(function() { container.setChildIndex(child, 1); }).to.throw(); - }); -}); diff --git a/test/unit/pixi/display/MovieClip.js b/test/unit/pixi/display/MovieClip.js deleted file mode 100644 index f3c6c6a..0000000 --- a/test/unit/pixi/display/MovieClip.js +++ /dev/null @@ -1,33 +0,0 @@ -describe('pixi/display/MovieClip', function () { - 'use strict'; - - var expect = chai.expect; - var MovieClip = PIXI.MovieClip; - var Texture = PIXI.Texture; - - it('Module exists', function () { - expect(MovieClip).to.be.a('function'); - }); - - it('Confirm new instance', function (done) { - var texture = Texture.fromImage('/base/test/textures/SpriteSheet-Explosion.png'); - var obj = new MovieClip([texture]); - - pixi_display_Sprite_confirmNew(obj, done); - - expect(obj).to.be.an.instanceof(MovieClip); - expect(obj).to.respondTo('stop'); - expect(obj).to.respondTo('play'); - expect(obj).to.respondTo('gotoAndStop'); - expect(obj).to.respondTo('gotoAndPlay'); - expect(obj).to.respondTo('updateTransform'); - - expect(obj).to.have.deep.property('textures.length', 1); - expect(obj).to.have.deep.property('textures[0]', texture); - expect(obj).to.have.property('animationSpeed', 1); - expect(obj).to.have.property('loop', true); - expect(obj).to.have.property('onComplete', null); - expect(obj).to.have.property('currentFrame', 0); - expect(obj).to.have.property('playing', false); - }); -}); diff --git a/test/unit/pixi/display/Sprite.js b/test/unit/pixi/display/Sprite.js deleted file mode 100644 index 30c8076..0000000 --- a/test/unit/pixi/display/Sprite.js +++ /dev/null @@ -1,28 +0,0 @@ -describe('pixi/display/Sprite', function () { - 'use strict'; - - var expect = chai.expect; - var Sprite = PIXI.Sprite; - var Texture = PIXI.Texture; - - it('Module exists', function () { - expect(Sprite).to.be.a('function'); - expect(PIXI).to.have.deep.property('blendModes.NORMAL', 0); - expect(PIXI).to.have.deep.property('blendModes.ADD', 1); - expect(PIXI).to.have.deep.property('blendModes.MULTIPLY', 2); - expect(PIXI).to.have.deep.property('blendModes.SCREEN', 3); - }); - - - it('Members exist', function () { - expect(Sprite).itself.to.respondTo('fromImage'); - expect(Sprite).itself.to.respondTo('fromFrame'); - }); - - it('Confirm new instance', function (done) { - var texture = Texture.fromImage('/base/test/textures/SpriteSheet-Aliens.png'); - var obj = new Sprite(texture); - - pixi_display_Sprite_confirmNew(obj, done); - }); -}); diff --git a/test/unit/pixi/display/Stage.js b/test/unit/pixi/display/Stage.js deleted file mode 100644 index 6974c2e..0000000 --- a/test/unit/pixi/display/Stage.js +++ /dev/null @@ -1,49 +0,0 @@ -describe('pixi/display/Stage', function () { - 'use strict'; - - var expect = chai.expect; - var Stage = PIXI.Stage; - var InteractionManager = PIXI.InteractionManager; - var Rectangle = PIXI.Rectangle; - - it('Module exists', function () { - expect(Stage).to.be.a('function'); - }); - - it('Confirm new instance', function () { - var obj = new Stage(null, true); - - pixi_display_DisplayObjectContainer_confirmNew(obj); - - expect(obj).to.be.an.instanceof(Stage); - expect(obj).to.respondTo('updateTransform'); - expect(obj).to.respondTo('setBackgroundColor'); - expect(obj).to.respondTo('getMousePosition'); - // FIXME: duplicate member in DisplayObject - pixi_core_Matrix_confirmNewMatrix(obj.worldTransform); - // FIXME: convert arg to bool in constructor - expect(obj).to.have.property('interactive', true); - - expect(obj).to.have.property('interactionManager') - .and.to.be.an.instanceof(InteractionManager) - .and.to.have.property('stage', obj); - - expect(obj).to.have.property('dirty', true); - - expect(obj).to.have.property('stage', obj); - - expect(obj).to.have.property('hitArea') - .and.to.be.an.instanceof(Rectangle); - pixi_core_Rectangle_confirm(obj.hitArea, 0, 0, 100000, 100000); - - expect(obj).to.have.property('backgroundColor', 0x000000); - expect(obj).to.have.deep.property('backgroundColorSplit.length', 3); - expect(obj).to.have.deep.property('backgroundColorSplit[0]', 0); - expect(obj).to.have.deep.property('backgroundColorSplit[1]', 0); - expect(obj).to.have.deep.property('backgroundColorSplit[2]', 0); - expect(obj).to.have.property('backgroundColorString', '#000000'); - - - expect(obj).to.have.property('worldVisible', true); - }); -}); diff --git a/test/unit/pixi/extras/Rope.js b/test/unit/pixi/extras/Rope.js deleted file mode 100644 index 05885ac..0000000 --- a/test/unit/pixi/extras/Rope.js +++ /dev/null @@ -1,31 +0,0 @@ -describe('pixi/extras/Rope', function () { - 'use strict'; - - var expect = chai.expect; - var Rope = PIXI.Rope; - var Texture = PIXI.Texture; - var Point = PIXI.Point; - - it('Module exists', function () { - expect(Rope).to.be.a('function'); - }); - - it('Confirm new instance', function () { - - var texture = Texture.fromImage('/base/test/textures/bunny.png'); - - // TODO-Alvin - // Same as Strip - - // var obj = new Rope(texture, [new Point(), new Point(5, 10), new Point(10, 20)]); - - // pixi_extras_Strip_confirmNew(obj); - - // expect(obj).to.be.an.instanceof(Rope); - // expect(obj).to.respondTo('refresh'); - // expect(obj).to.respondTo('updateTransform'); - // expect(obj).to.respondTo('setTexture'); - - // TODO: Test properties - }); -}); diff --git a/test/unit/pixi/extras/Spine.js b/test/unit/pixi/extras/Spine.js deleted file mode 100644 index 0708bc0..0000000 --- a/test/unit/pixi/extras/Spine.js +++ /dev/null @@ -1,10 +0,0 @@ -describe('pixi/extras/Spine', function () { - 'use strict'; - - var expect = chai.expect; - var Spine = PIXI.Spine; - - it('Module exists', function () { - expect(Spine).to.be.a('function'); - }); -}); diff --git a/test/unit/pixi/extras/Strip.js b/test/unit/pixi/extras/Strip.js deleted file mode 100644 index 230af90..0000000 --- a/test/unit/pixi/extras/Strip.js +++ /dev/null @@ -1,26 +0,0 @@ -describe('pixi/extras/Strip', function () { - 'use strict'; - - var expect = chai.expect; - var Strip = PIXI.Strip; - var Texture = PIXI.Texture; - - it('Module exists', function () { - expect(Strip).to.be.a('function'); - }); - - it('Confirm new instance', function () { - - - // TODO-Alvin - // We tweaked it to make it pass the tests, but the whole strip class needs - // to be re-coded - - var texture = Texture.fromImage('/base/test/textures/bunny.png'); - - // var obj = new Strip(texture, 20, 10000); - - - // pixi_extras_Strip_confirmNew(obj); - }); -}); diff --git a/test/unit/pixi/extras/TilingSprite.js b/test/unit/pixi/extras/TilingSprite.js deleted file mode 100644 index 56aea14..0000000 --- a/test/unit/pixi/extras/TilingSprite.js +++ /dev/null @@ -1,24 +0,0 @@ -describe('pixi/extras/TilingSprite', function () { - 'use strict'; - - var expect = chai.expect; - var TilingSprite = PIXI.TilingSprite; - var Texture = PIXI.Texture; - - it('Module exists', function () { - expect(TilingSprite).to.be.a('function'); - }); - - it('Confirm new instance', function () { - var texture = Texture.fromImage('/base/test/textures/bunny.png'); - var obj = new TilingSprite(texture, 6000, 12000); - - pixi_display_DisplayObjectContainer_confirmNew(obj); - - expect(obj).to.be.an.instanceof(TilingSprite); - expect(obj).to.respondTo('setTexture'); - expect(obj).to.respondTo('onTextureUpdate'); - - // TODO: Test properties - }); -}); diff --git a/test/unit/pixi/filters/FilterBlock.js b/test/unit/pixi/filters/FilterBlock.js deleted file mode 100644 index 870cec0..0000000 --- a/test/unit/pixi/filters/FilterBlock.js +++ /dev/null @@ -1,10 +0,0 @@ -describe('pixi/filters/FilterBlock', function () { - 'use strict'; - - var expect = chai.expect; - var FilterBlock = PIXI.FilterBlock; - - it('Module exists', function () { - expect(FilterBlock).to.be.a('function'); - }); -}); diff --git a/test/unit/pixi/loaders/AssetLoader.js b/test/unit/pixi/loaders/AssetLoader.js deleted file mode 100644 index a0aa0b5..0000000 --- a/test/unit/pixi/loaders/AssetLoader.js +++ /dev/null @@ -1,10 +0,0 @@ -describe('pixi/loaders/AssetLoader', function () { - 'use strict'; - - var expect = chai.expect; - var AssetLoader = PIXI.AssetLoader; - - it('Module exists', function () { - expect(AssetLoader).to.be.a('function'); - }); -}); diff --git a/test/unit/pixi/loaders/BitmapFontLoader.js b/test/unit/pixi/loaders/BitmapFontLoader.js deleted file mode 100644 index 046f018..0000000 --- a/test/unit/pixi/loaders/BitmapFontLoader.js +++ /dev/null @@ -1,9 +0,0 @@ -describe('pixi/loaders/BitmapFontLoader', function () { - 'use strict'; - - var expect = chai.expect; - - it('Module exists', function () { - expect(PIXI.BitmapFontLoader).to.be.a('function'); - }); -}); diff --git a/test/unit/pixi/loaders/ImageLoader.js b/test/unit/pixi/loaders/ImageLoader.js deleted file mode 100644 index 8b1f556..0000000 --- a/test/unit/pixi/loaders/ImageLoader.js +++ /dev/null @@ -1,10 +0,0 @@ -describe('pixi/loaders/ImageLoader', function () { - 'use strict'; - - var expect = chai.expect; - var ImageLoader = PIXI.ImageLoader; - - it('Module exists', function () { - expect(ImageLoader).to.be.a('function'); - }); -}); diff --git a/test/unit/pixi/loaders/JsonLoader.js b/test/unit/pixi/loaders/JsonLoader.js deleted file mode 100644 index c577e83..0000000 --- a/test/unit/pixi/loaders/JsonLoader.js +++ /dev/null @@ -1,10 +0,0 @@ -describe('pixi/loaders/JsonLoader', function () { - 'use strict'; - - var expect = chai.expect; - var JsonLoader = PIXI.JsonLoader; - - it('Module exists', function () { - expect(JsonLoader).to.be.a('function'); - }); -}); diff --git a/test/unit/pixi/loaders/SpineLoader.js b/test/unit/pixi/loaders/SpineLoader.js deleted file mode 100644 index fdcc0b8..0000000 --- a/test/unit/pixi/loaders/SpineLoader.js +++ /dev/null @@ -1,10 +0,0 @@ -describe('pixi/loaders/SpineLoader', function () { - 'use strict'; - - var expect = chai.expect; - var SpineLoader = PIXI.SpineLoader; - - it('Module exists', function () { - expect(SpineLoader).to.be.a('function'); - }); -}); diff --git a/test/unit/pixi/loaders/SpriteSheetLoader.js b/test/unit/pixi/loaders/SpriteSheetLoader.js deleted file mode 100644 index 57beb27..0000000 --- a/test/unit/pixi/loaders/SpriteSheetLoader.js +++ /dev/null @@ -1,10 +0,0 @@ -describe('pixi/loaders/SpriteSheetLoader', function () { - 'use strict'; - - var expect = chai.expect; - var SpriteSheetLoader = PIXI.SpriteSheetLoader; - - it('Module exists', function () { - expect(SpriteSheetLoader).to.be.a('function'); - }); -}); diff --git a/test/unit/pixi/primitives/Graphics.js b/test/unit/pixi/primitives/Graphics.js deleted file mode 100644 index f3849eb..0000000 --- a/test/unit/pixi/primitives/Graphics.js +++ /dev/null @@ -1,44 +0,0 @@ -describe('pixi/primitives/Graphics', function () { - 'use strict'; - - var expect = chai.expect; - var Graphics = PIXI.Graphics; - - it('Module exists', function () { - expect(Graphics).to.be.a('function'); - - expect(Graphics).itself.to.have.property('POLY', 0); - expect(Graphics).itself.to.have.property('RECT', 1); - expect(Graphics).itself.to.have.property('CIRC', 2); - expect(Graphics).itself.to.have.property('ELIP', 3); - expect(Graphics).itself.to.have.property('RREC', 4); - }); - - it('Confirm new instance', function () { - var obj = new Graphics(); - - pixi_display_DisplayObjectContainer_confirmNew(obj); - - expect(obj).to.be.an.instanceof(Graphics); - expect(obj).to.respondTo('lineStyle'); - expect(obj).to.respondTo('lineStyle'); - expect(obj).to.respondTo('moveTo'); - expect(obj).to.respondTo('lineTo'); - expect(obj).to.respondTo('beginFill'); - expect(obj).to.respondTo('endFill'); - expect(obj).to.respondTo('drawRect'); - // expect(obj).to.respondTo('drawRoundedRect'); - expect(obj).to.respondTo('drawCircle'); - expect(obj).to.respondTo('drawEllipse'); - expect(obj).to.respondTo('clear'); - - expect(obj).to.have.property('renderable', true); - expect(obj).to.have.property('fillAlpha', 1); - expect(obj).to.have.property('lineWidth', 0); - expect(obj).to.have.property('width', 0); - expect(obj).to.have.property('height', 0); - expect(obj).to.have.property('lineColor', 0); - expect(obj).to.have.deep.property('graphicsData.length', 0); - // expect(obj).to.have.deep.property('currentPath.points.length', 0); - }); -}); diff --git a/test/unit/pixi/renderers/canvas/CanvasGraphics.js b/test/unit/pixi/renderers/canvas/CanvasGraphics.js deleted file mode 100644 index 8f44472..0000000 --- a/test/unit/pixi/renderers/canvas/CanvasGraphics.js +++ /dev/null @@ -1,15 +0,0 @@ -describe('renders/canvas/CanvasGraphics', function () { - 'use strict'; - - var expect = chai.expect; - var CanvasGraphics = PIXI.CanvasGraphics; - - it('Module exists', function () { - expect(CanvasGraphics).to.be.a('function'); - }); - - it('Members exist', function () { - expect(CanvasGraphics).itself.to.respondTo('renderGraphics'); - expect(CanvasGraphics).itself.to.respondTo('renderGraphicsMask'); - }); -}); diff --git a/test/unit/pixi/renderers/canvas/CanvasRenderer.js b/test/unit/pixi/renderers/canvas/CanvasRenderer.js deleted file mode 100644 index 1646444..0000000 --- a/test/unit/pixi/renderers/canvas/CanvasRenderer.js +++ /dev/null @@ -1,36 +0,0 @@ -describe('renderers/canvas/CanvasRenderer', function () { - 'use strict'; - - var expect = chai.expect; - var CanvasRenderer = PIXI.CanvasRenderer; - - it('Module exists', function () { - expect(CanvasRenderer).to.be.a('function'); - }); - - describe('.autoResize', function () { - it('Should automatically resize view if enabled', function () { - var renderer = new CanvasRenderer(200, 200, { - autoResize: true - }); - - expect(renderer.view.style.width).to.equal('200px'); - }); - - it('Should not automatically resize view if disabled', function () { - var renderer = new CanvasRenderer(200, 200, { - autoResize: false - }); - - expect(renderer.view.style.width).to.equal(''); - }); - - it('Should not automatically resize view if not specified', function () { - var renderer = new CanvasRenderer(200, 200, { - resolution: 2 - }); - - expect(renderer.view.style.width).to.equal(''); - }); - }); -}); diff --git a/test/unit/pixi/renderers/webgl/WebGLGraphics.js b/test/unit/pixi/renderers/webgl/WebGLGraphics.js deleted file mode 100644 index 5867b28..0000000 --- a/test/unit/pixi/renderers/webgl/WebGLGraphics.js +++ /dev/null @@ -1,20 +0,0 @@ -describe('renderers/wegbl/WebGLGraphics', function () { - 'use strict'; - - var expect = chai.expect; - var WebGLGraphics = PIXI.WebGLGraphics; - - it('Module exists', function () { - expect(WebGLGraphics).to.be.a('function'); - }); - - it('Members exist', function () { - expect(WebGLGraphics).itself.to.respondTo('renderGraphics'); - expect(WebGLGraphics).itself.to.respondTo('updateGraphics'); - expect(WebGLGraphics).itself.to.respondTo('buildRectangle'); - expect(WebGLGraphics).itself.to.respondTo('buildRoundedRectangle'); - expect(WebGLGraphics).itself.to.respondTo('buildCircle'); - expect(WebGLGraphics).itself.to.respondTo('buildLine'); - expect(WebGLGraphics).itself.to.respondTo('buildPoly'); - }); -}); diff --git a/test/unit/pixi/renderers/webgl/WebGLRenderer.js b/test/unit/pixi/renderers/webgl/WebGLRenderer.js deleted file mode 100644 index 1680a80..0000000 --- a/test/unit/pixi/renderers/webgl/WebGLRenderer.js +++ /dev/null @@ -1,49 +0,0 @@ -describe('renderers/webgl/WebGLRenderer', function () { - 'use strict'; - - var expect = chai.expect; - var WebGLRenderer = PIXI.WebGLRenderer; - - it('Module exists', function () { - expect(WebGLRenderer).to.be.a('function'); - }); - - // Skip tests if WebGL is not available (WebGL not supported in Travis CI) - try { - var renderer = new WebGLRenderer(400, 300, {}); - renderer.destroy(); - } catch (error) { - return; - } - - it('Destroy renderer', function () { - var renderer = new WebGLRenderer(400, 300, {}); - renderer.destroy(); - }); - - describe('.autoResize', function () { - it('Should automatically resize view if enabled', function () { - var renderer = new WebGLRenderer(200, 200, { - autoResize: true - }); - - expect(renderer.view.style.width).to.equal('200px'); - }); - - it('Should not automatically resize view if disabled', function () { - var renderer = new WebGLRenderer(200, 200, { - autoResize: false - }); - - expect(renderer.view.style.width).to.equal(''); - }); - - it('Should not automatically resize view if not specified', function () { - var renderer = new WebGLRenderer(200, 200, { - resolution: 2 - }); - - expect(renderer.view.style.width).to.equal(''); - }); - }); -}); diff --git a/test/unit/pixi-v2/InteractionManager.js b/test/unit/pixi-v2/InteractionManager.js new file mode 100644 index 0000000..ed3001f --- /dev/null +++ b/test/unit/pixi-v2/InteractionManager.js @@ -0,0 +1,10 @@ +describe('pixi/InteractionManager', function () { + 'use strict'; + + var expect = chai.expect; + var InteractionManager = PIXI.InteractionManager; + + it('Module exists', function () { + expect(InteractionManager).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/Pixi.js b/test/unit/pixi-v2/Pixi.js new file mode 100644 index 0000000..27debc1 --- /dev/null +++ b/test/unit/pixi-v2/Pixi.js @@ -0,0 +1,9 @@ +describe('pixi/Pixi', function () { + 'use strict'; + + var expect = chai.expect; + + it('Module exists', function () { + expect(global).to.have.property('PIXI').and.to.be.an('object'); + }); +}); diff --git a/test/unit/pixi-v2/core/Circle.js b/test/unit/pixi-v2/core/Circle.js new file mode 100644 index 0000000..fbcfa17 --- /dev/null +++ b/test/unit/pixi-v2/core/Circle.js @@ -0,0 +1,21 @@ +describe('pixi/core/Circle', function () { + 'use strict'; + + var expect = chai.expect; + var Circle = PIXI.Circle; + + it('Module exists', function () { + expect(Circle).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Circle(); + pixi_core_Circle_confirmNewCircle(obj); + }); + + it("getBounds should return Rectangle that bounds the circle", function() { + var obj = new Circle(100, 250, 50); + var bounds = obj.getBounds(); + pixi_core_Circle_isBoundedByRectangle(obj, bounds); + }); +}); diff --git a/test/unit/pixi-v2/core/Ellipse.js b/test/unit/pixi-v2/core/Ellipse.js new file mode 100644 index 0000000..026b56f --- /dev/null +++ b/test/unit/pixi-v2/core/Ellipse.js @@ -0,0 +1,24 @@ +describe('pixi/core/Ellipse', function () { + 'use strict'; + + var expect = chai.expect; + var Ellipse = PIXI.Ellipse; + + it('Module exists', function () { + expect(Ellipse).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Ellipse(); + + expect(obj).to.be.an.instanceof(Ellipse); + expect(obj).to.respondTo('clone'); + expect(obj).to.respondTo('contains'); + expect(obj).to.respondTo('getBounds'); + + expect(obj).to.have.property('x', 0); + expect(obj).to.have.property('y', 0); + expect(obj).to.have.property('width', 0); + expect(obj).to.have.property('height', 0); + }); +}); diff --git a/test/unit/pixi-v2/core/Matrix.js b/test/unit/pixi-v2/core/Matrix.js new file mode 100644 index 0000000..da75e2e --- /dev/null +++ b/test/unit/pixi-v2/core/Matrix.js @@ -0,0 +1,14 @@ +describe('pixi/core/Matrix', function () { + 'use strict'; + + var expect = chai.expect; + + it('Matrix exists', function () { + expect(PIXI.Matrix).to.be.an('function'); + }); + + it('Confirm new Matrix', function () { + var matrix = new PIXI.Matrix(); + pixi_core_Matrix_confirmNewMatrix(matrix); + }); +}); diff --git a/test/unit/pixi-v2/core/Point.js b/test/unit/pixi-v2/core/Point.js new file mode 100644 index 0000000..c4d5163 --- /dev/null +++ b/test/unit/pixi-v2/core/Point.js @@ -0,0 +1,15 @@ +describe('pixi/core/Point', function () { + 'use strict'; + + var expect = chai.expect; + var Point = PIXI.Point; + + it('Module exists', function () { + expect(Point).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Point(); + pixi_core_Point_confirm(obj, 0, 0); + }); +}); diff --git a/test/unit/pixi-v2/core/Polygon.js b/test/unit/pixi-v2/core/Polygon.js new file mode 100644 index 0000000..dc8c918 --- /dev/null +++ b/test/unit/pixi-v2/core/Polygon.js @@ -0,0 +1,20 @@ +describe('pixi/core/Polygon', function () { + 'use strict'; + + var expect = chai.expect; + var Polygon = PIXI.Polygon; + + it('Module exists', function () { + expect(Polygon).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Polygon(); + + expect(obj).to.be.an.instanceof(Polygon); + expect(obj).to.respondTo('clone'); + expect(obj).to.respondTo('contains'); + + expect(obj).to.have.deep.property('points.length', 0); + }); +}); diff --git a/test/unit/pixi-v2/core/Rectangle.js b/test/unit/pixi-v2/core/Rectangle.js new file mode 100644 index 0000000..d43316e --- /dev/null +++ b/test/unit/pixi-v2/core/Rectangle.js @@ -0,0 +1,15 @@ +describe('pixi/core/Rectangle', function () { + 'use strict'; + + var expect = chai.expect; + var Rectangle = PIXI.Rectangle; + + it('Module exists', function () { + expect(Rectangle).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var rect = new Rectangle(); + pixi_core_Rectangle_confirm(rect, 0, 0, 0, 0); + }); +}); diff --git a/test/unit/pixi-v2/display/DisplayObject.js b/test/unit/pixi-v2/display/DisplayObject.js new file mode 100644 index 0000000..044acf8 --- /dev/null +++ b/test/unit/pixi-v2/display/DisplayObject.js @@ -0,0 +1,21 @@ +describe('pixi/display/DisplayObject', function () { + 'use strict'; + + var expect = chai.expect; + var DisplayObject = PIXI.DisplayObject; + + it('Module exists', function () { + expect(DisplayObject).to.be.a('function'); + // expect(PIXI).to.have.property('visibleCount', 0); + }); + + it('Confirm new instance', function () { + var obj = new DisplayObject(); + + pixi_display_DisplayObject_confirmNew(obj); + expect(obj).to.have.property('hitArea', null); + expect(obj).to.have.property('interactive', false); + expect(obj).to.have.property('renderable', false); + expect(obj).to.have.property('stage', null); + }); +}); diff --git a/test/unit/pixi-v2/display/DisplayObjectContainer.js b/test/unit/pixi-v2/display/DisplayObjectContainer.js new file mode 100644 index 0000000..15a3376 --- /dev/null +++ b/test/unit/pixi-v2/display/DisplayObjectContainer.js @@ -0,0 +1,67 @@ +describe('pixi/display/DisplayObjectContainer', function () { + 'use strict'; + + var expect = chai.expect; + var DisplayObjectContainer = PIXI.DisplayObjectContainer; + + it('Module exists', function () { + expect(DisplayObjectContainer).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new DisplayObjectContainer(); + + pixi_display_DisplayObjectContainer_confirmNew(obj); + expect(obj).to.have.property('hitArea', null); + expect(obj).to.have.property('interactive', false); + expect(obj).to.have.property('renderable', false); + expect(obj).to.have.property('stage', null); + }); + + it('Gets child index', function() { + var container = new PIXI.DisplayObjectContainer(); + var children = []; + for (var i = 0; i < 10; i++) { + var child = new PIXI.DisplayObject(); + children.push(child); + container.addChild(child); + } + + for (i = 0; i < children.length; i++) { + expect(i).to.eql(container.getChildIndex(children[i])); + } + }); + + it('throws error when trying to get index of not a child', function() { + var container = new PIXI.DisplayObjectContainer(); + var child = new PIXI.DisplayObject(); + + expect(function() { container.getChildIndex(child); }).to.throw(); + }); + + it('Sets child index', function() { + var container = new PIXI.DisplayObjectContainer(); + var children = []; + + for (var i = 0; i < 10; i++) { + var child = new PIXI.DisplayObject(); + children.push(child); + container.addChild(child); + } + children.reverse(); + + for (i = 0; i < children.length; i++) { + container.setChildIndex(children[i], i); + expect(i).to.eql(container.getChildIndex(children[i])); + } + }); + + it('throws error when trying to set incorect index', function() { + var container = new PIXI.DisplayObjectContainer(); + var child = new PIXI.DisplayObject(); + container.addChild(child); + + expect(function() { container.setChildIndex(child, -1); }).to.throw(); + expect(function() { container.setChildIndex(child, 1); }).to.throw(); + }); +}); diff --git a/test/unit/pixi-v2/display/MovieClip.js b/test/unit/pixi-v2/display/MovieClip.js new file mode 100644 index 0000000..f3c6c6a --- /dev/null +++ b/test/unit/pixi-v2/display/MovieClip.js @@ -0,0 +1,33 @@ +describe('pixi/display/MovieClip', function () { + 'use strict'; + + var expect = chai.expect; + var MovieClip = PIXI.MovieClip; + var Texture = PIXI.Texture; + + it('Module exists', function () { + expect(MovieClip).to.be.a('function'); + }); + + it('Confirm new instance', function (done) { + var texture = Texture.fromImage('/base/test/textures/SpriteSheet-Explosion.png'); + var obj = new MovieClip([texture]); + + pixi_display_Sprite_confirmNew(obj, done); + + expect(obj).to.be.an.instanceof(MovieClip); + expect(obj).to.respondTo('stop'); + expect(obj).to.respondTo('play'); + expect(obj).to.respondTo('gotoAndStop'); + expect(obj).to.respondTo('gotoAndPlay'); + expect(obj).to.respondTo('updateTransform'); + + expect(obj).to.have.deep.property('textures.length', 1); + expect(obj).to.have.deep.property('textures[0]', texture); + expect(obj).to.have.property('animationSpeed', 1); + expect(obj).to.have.property('loop', true); + expect(obj).to.have.property('onComplete', null); + expect(obj).to.have.property('currentFrame', 0); + expect(obj).to.have.property('playing', false); + }); +}); diff --git a/test/unit/pixi-v2/display/Sprite.js b/test/unit/pixi-v2/display/Sprite.js new file mode 100644 index 0000000..30c8076 --- /dev/null +++ b/test/unit/pixi-v2/display/Sprite.js @@ -0,0 +1,28 @@ +describe('pixi/display/Sprite', function () { + 'use strict'; + + var expect = chai.expect; + var Sprite = PIXI.Sprite; + var Texture = PIXI.Texture; + + it('Module exists', function () { + expect(Sprite).to.be.a('function'); + expect(PIXI).to.have.deep.property('blendModes.NORMAL', 0); + expect(PIXI).to.have.deep.property('blendModes.ADD', 1); + expect(PIXI).to.have.deep.property('blendModes.MULTIPLY', 2); + expect(PIXI).to.have.deep.property('blendModes.SCREEN', 3); + }); + + + it('Members exist', function () { + expect(Sprite).itself.to.respondTo('fromImage'); + expect(Sprite).itself.to.respondTo('fromFrame'); + }); + + it('Confirm new instance', function (done) { + var texture = Texture.fromImage('/base/test/textures/SpriteSheet-Aliens.png'); + var obj = new Sprite(texture); + + pixi_display_Sprite_confirmNew(obj, done); + }); +}); diff --git a/test/unit/pixi-v2/display/Stage.js b/test/unit/pixi-v2/display/Stage.js new file mode 100644 index 0000000..6974c2e --- /dev/null +++ b/test/unit/pixi-v2/display/Stage.js @@ -0,0 +1,49 @@ +describe('pixi/display/Stage', function () { + 'use strict'; + + var expect = chai.expect; + var Stage = PIXI.Stage; + var InteractionManager = PIXI.InteractionManager; + var Rectangle = PIXI.Rectangle; + + it('Module exists', function () { + expect(Stage).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Stage(null, true); + + pixi_display_DisplayObjectContainer_confirmNew(obj); + + expect(obj).to.be.an.instanceof(Stage); + expect(obj).to.respondTo('updateTransform'); + expect(obj).to.respondTo('setBackgroundColor'); + expect(obj).to.respondTo('getMousePosition'); + // FIXME: duplicate member in DisplayObject + pixi_core_Matrix_confirmNewMatrix(obj.worldTransform); + // FIXME: convert arg to bool in constructor + expect(obj).to.have.property('interactive', true); + + expect(obj).to.have.property('interactionManager') + .and.to.be.an.instanceof(InteractionManager) + .and.to.have.property('stage', obj); + + expect(obj).to.have.property('dirty', true); + + expect(obj).to.have.property('stage', obj); + + expect(obj).to.have.property('hitArea') + .and.to.be.an.instanceof(Rectangle); + pixi_core_Rectangle_confirm(obj.hitArea, 0, 0, 100000, 100000); + + expect(obj).to.have.property('backgroundColor', 0x000000); + expect(obj).to.have.deep.property('backgroundColorSplit.length', 3); + expect(obj).to.have.deep.property('backgroundColorSplit[0]', 0); + expect(obj).to.have.deep.property('backgroundColorSplit[1]', 0); + expect(obj).to.have.deep.property('backgroundColorSplit[2]', 0); + expect(obj).to.have.property('backgroundColorString', '#000000'); + + + expect(obj).to.have.property('worldVisible', true); + }); +}); diff --git a/test/unit/pixi-v2/extras/Rope.js b/test/unit/pixi-v2/extras/Rope.js new file mode 100644 index 0000000..05885ac --- /dev/null +++ b/test/unit/pixi-v2/extras/Rope.js @@ -0,0 +1,31 @@ +describe('pixi/extras/Rope', function () { + 'use strict'; + + var expect = chai.expect; + var Rope = PIXI.Rope; + var Texture = PIXI.Texture; + var Point = PIXI.Point; + + it('Module exists', function () { + expect(Rope).to.be.a('function'); + }); + + it('Confirm new instance', function () { + + var texture = Texture.fromImage('/base/test/textures/bunny.png'); + + // TODO-Alvin + // Same as Strip + + // var obj = new Rope(texture, [new Point(), new Point(5, 10), new Point(10, 20)]); + + // pixi_extras_Strip_confirmNew(obj); + + // expect(obj).to.be.an.instanceof(Rope); + // expect(obj).to.respondTo('refresh'); + // expect(obj).to.respondTo('updateTransform'); + // expect(obj).to.respondTo('setTexture'); + + // TODO: Test properties + }); +}); diff --git a/test/unit/pixi-v2/extras/Spine.js b/test/unit/pixi-v2/extras/Spine.js new file mode 100644 index 0000000..0708bc0 --- /dev/null +++ b/test/unit/pixi-v2/extras/Spine.js @@ -0,0 +1,10 @@ +describe('pixi/extras/Spine', function () { + 'use strict'; + + var expect = chai.expect; + var Spine = PIXI.Spine; + + it('Module exists', function () { + expect(Spine).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/extras/Strip.js b/test/unit/pixi-v2/extras/Strip.js new file mode 100644 index 0000000..230af90 --- /dev/null +++ b/test/unit/pixi-v2/extras/Strip.js @@ -0,0 +1,26 @@ +describe('pixi/extras/Strip', function () { + 'use strict'; + + var expect = chai.expect; + var Strip = PIXI.Strip; + var Texture = PIXI.Texture; + + it('Module exists', function () { + expect(Strip).to.be.a('function'); + }); + + it('Confirm new instance', function () { + + + // TODO-Alvin + // We tweaked it to make it pass the tests, but the whole strip class needs + // to be re-coded + + var texture = Texture.fromImage('/base/test/textures/bunny.png'); + + // var obj = new Strip(texture, 20, 10000); + + + // pixi_extras_Strip_confirmNew(obj); + }); +}); diff --git a/test/unit/pixi-v2/extras/TilingSprite.js b/test/unit/pixi-v2/extras/TilingSprite.js new file mode 100644 index 0000000..56aea14 --- /dev/null +++ b/test/unit/pixi-v2/extras/TilingSprite.js @@ -0,0 +1,24 @@ +describe('pixi/extras/TilingSprite', function () { + 'use strict'; + + var expect = chai.expect; + var TilingSprite = PIXI.TilingSprite; + var Texture = PIXI.Texture; + + it('Module exists', function () { + expect(TilingSprite).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var texture = Texture.fromImage('/base/test/textures/bunny.png'); + var obj = new TilingSprite(texture, 6000, 12000); + + pixi_display_DisplayObjectContainer_confirmNew(obj); + + expect(obj).to.be.an.instanceof(TilingSprite); + expect(obj).to.respondTo('setTexture'); + expect(obj).to.respondTo('onTextureUpdate'); + + // TODO: Test properties + }); +}); diff --git a/test/unit/pixi-v2/filters/FilterBlock.js b/test/unit/pixi-v2/filters/FilterBlock.js new file mode 100644 index 0000000..870cec0 --- /dev/null +++ b/test/unit/pixi-v2/filters/FilterBlock.js @@ -0,0 +1,10 @@ +describe('pixi/filters/FilterBlock', function () { + 'use strict'; + + var expect = chai.expect; + var FilterBlock = PIXI.FilterBlock; + + it('Module exists', function () { + expect(FilterBlock).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/AssetLoader.js b/test/unit/pixi-v2/loaders/AssetLoader.js new file mode 100644 index 0000000..a0aa0b5 --- /dev/null +++ b/test/unit/pixi-v2/loaders/AssetLoader.js @@ -0,0 +1,10 @@ +describe('pixi/loaders/AssetLoader', function () { + 'use strict'; + + var expect = chai.expect; + var AssetLoader = PIXI.AssetLoader; + + it('Module exists', function () { + expect(AssetLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/BitmapFontLoader.js b/test/unit/pixi-v2/loaders/BitmapFontLoader.js new file mode 100644 index 0000000..046f018 --- /dev/null +++ b/test/unit/pixi-v2/loaders/BitmapFontLoader.js @@ -0,0 +1,9 @@ +describe('pixi/loaders/BitmapFontLoader', function () { + 'use strict'; + + var expect = chai.expect; + + it('Module exists', function () { + expect(PIXI.BitmapFontLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/ImageLoader.js b/test/unit/pixi-v2/loaders/ImageLoader.js new file mode 100644 index 0000000..8b1f556 --- /dev/null +++ b/test/unit/pixi-v2/loaders/ImageLoader.js @@ -0,0 +1,10 @@ +describe('pixi/loaders/ImageLoader', function () { + 'use strict'; + + var expect = chai.expect; + var ImageLoader = PIXI.ImageLoader; + + it('Module exists', function () { + expect(ImageLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/JsonLoader.js b/test/unit/pixi-v2/loaders/JsonLoader.js new file mode 100644 index 0000000..c577e83 --- /dev/null +++ b/test/unit/pixi-v2/loaders/JsonLoader.js @@ -0,0 +1,10 @@ +describe('pixi/loaders/JsonLoader', function () { + 'use strict'; + + var expect = chai.expect; + var JsonLoader = PIXI.JsonLoader; + + it('Module exists', function () { + expect(JsonLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/SpineLoader.js b/test/unit/pixi-v2/loaders/SpineLoader.js new file mode 100644 index 0000000..fdcc0b8 --- /dev/null +++ b/test/unit/pixi-v2/loaders/SpineLoader.js @@ -0,0 +1,10 @@ +describe('pixi/loaders/SpineLoader', function () { + 'use strict'; + + var expect = chai.expect; + var SpineLoader = PIXI.SpineLoader; + + it('Module exists', function () { + expect(SpineLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/SpriteSheetLoader.js b/test/unit/pixi-v2/loaders/SpriteSheetLoader.js new file mode 100644 index 0000000..57beb27 --- /dev/null +++ b/test/unit/pixi-v2/loaders/SpriteSheetLoader.js @@ -0,0 +1,10 @@ +describe('pixi/loaders/SpriteSheetLoader', function () { + 'use strict'; + + var expect = chai.expect; + var SpriteSheetLoader = PIXI.SpriteSheetLoader; + + it('Module exists', function () { + expect(SpriteSheetLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/primitives/Graphics.js b/test/unit/pixi-v2/primitives/Graphics.js new file mode 100644 index 0000000..f3849eb --- /dev/null +++ b/test/unit/pixi-v2/primitives/Graphics.js @@ -0,0 +1,44 @@ +describe('pixi/primitives/Graphics', function () { + 'use strict'; + + var expect = chai.expect; + var Graphics = PIXI.Graphics; + + it('Module exists', function () { + expect(Graphics).to.be.a('function'); + + expect(Graphics).itself.to.have.property('POLY', 0); + expect(Graphics).itself.to.have.property('RECT', 1); + expect(Graphics).itself.to.have.property('CIRC', 2); + expect(Graphics).itself.to.have.property('ELIP', 3); + expect(Graphics).itself.to.have.property('RREC', 4); + }); + + it('Confirm new instance', function () { + var obj = new Graphics(); + + pixi_display_DisplayObjectContainer_confirmNew(obj); + + expect(obj).to.be.an.instanceof(Graphics); + expect(obj).to.respondTo('lineStyle'); + expect(obj).to.respondTo('lineStyle'); + expect(obj).to.respondTo('moveTo'); + expect(obj).to.respondTo('lineTo'); + expect(obj).to.respondTo('beginFill'); + expect(obj).to.respondTo('endFill'); + expect(obj).to.respondTo('drawRect'); + // expect(obj).to.respondTo('drawRoundedRect'); + expect(obj).to.respondTo('drawCircle'); + expect(obj).to.respondTo('drawEllipse'); + expect(obj).to.respondTo('clear'); + + expect(obj).to.have.property('renderable', true); + expect(obj).to.have.property('fillAlpha', 1); + expect(obj).to.have.property('lineWidth', 0); + expect(obj).to.have.property('width', 0); + expect(obj).to.have.property('height', 0); + expect(obj).to.have.property('lineColor', 0); + expect(obj).to.have.deep.property('graphicsData.length', 0); + // expect(obj).to.have.deep.property('currentPath.points.length', 0); + }); +}); diff --git a/test/unit/pixi-v2/renderers/canvas/CanvasGraphics.js b/test/unit/pixi-v2/renderers/canvas/CanvasGraphics.js new file mode 100644 index 0000000..8f44472 --- /dev/null +++ b/test/unit/pixi-v2/renderers/canvas/CanvasGraphics.js @@ -0,0 +1,15 @@ +describe('renders/canvas/CanvasGraphics', function () { + 'use strict'; + + var expect = chai.expect; + var CanvasGraphics = PIXI.CanvasGraphics; + + it('Module exists', function () { + expect(CanvasGraphics).to.be.a('function'); + }); + + it('Members exist', function () { + expect(CanvasGraphics).itself.to.respondTo('renderGraphics'); + expect(CanvasGraphics).itself.to.respondTo('renderGraphicsMask'); + }); +}); diff --git a/test/unit/pixi-v2/renderers/canvas/CanvasRenderer.js b/test/unit/pixi-v2/renderers/canvas/CanvasRenderer.js new file mode 100644 index 0000000..1646444 --- /dev/null +++ b/test/unit/pixi-v2/renderers/canvas/CanvasRenderer.js @@ -0,0 +1,36 @@ +describe('renderers/canvas/CanvasRenderer', function () { + 'use strict'; + + var expect = chai.expect; + var CanvasRenderer = PIXI.CanvasRenderer; + + it('Module exists', function () { + expect(CanvasRenderer).to.be.a('function'); + }); + + describe('.autoResize', function () { + it('Should automatically resize view if enabled', function () { + var renderer = new CanvasRenderer(200, 200, { + autoResize: true + }); + + expect(renderer.view.style.width).to.equal('200px'); + }); + + it('Should not automatically resize view if disabled', function () { + var renderer = new CanvasRenderer(200, 200, { + autoResize: false + }); + + expect(renderer.view.style.width).to.equal(''); + }); + + it('Should not automatically resize view if not specified', function () { + var renderer = new CanvasRenderer(200, 200, { + resolution: 2 + }); + + expect(renderer.view.style.width).to.equal(''); + }); + }); +}); diff --git a/test/unit/pixi-v2/renderers/webgl/WebGLGraphics.js b/test/unit/pixi-v2/renderers/webgl/WebGLGraphics.js new file mode 100644 index 0000000..5867b28 --- /dev/null +++ b/test/unit/pixi-v2/renderers/webgl/WebGLGraphics.js @@ -0,0 +1,20 @@ +describe('renderers/wegbl/WebGLGraphics', function () { + 'use strict'; + + var expect = chai.expect; + var WebGLGraphics = PIXI.WebGLGraphics; + + it('Module exists', function () { + expect(WebGLGraphics).to.be.a('function'); + }); + + it('Members exist', function () { + expect(WebGLGraphics).itself.to.respondTo('renderGraphics'); + expect(WebGLGraphics).itself.to.respondTo('updateGraphics'); + expect(WebGLGraphics).itself.to.respondTo('buildRectangle'); + expect(WebGLGraphics).itself.to.respondTo('buildRoundedRectangle'); + expect(WebGLGraphics).itself.to.respondTo('buildCircle'); + expect(WebGLGraphics).itself.to.respondTo('buildLine'); + expect(WebGLGraphics).itself.to.respondTo('buildPoly'); + }); +}); diff --git a/test/unit/pixi-v2/renderers/webgl/WebGLRenderer.js b/test/unit/pixi-v2/renderers/webgl/WebGLRenderer.js new file mode 100644 index 0000000..1680a80 --- /dev/null +++ b/test/unit/pixi-v2/renderers/webgl/WebGLRenderer.js @@ -0,0 +1,49 @@ +describe('renderers/webgl/WebGLRenderer', function () { + 'use strict'; + + var expect = chai.expect; + var WebGLRenderer = PIXI.WebGLRenderer; + + it('Module exists', function () { + expect(WebGLRenderer).to.be.a('function'); + }); + + // Skip tests if WebGL is not available (WebGL not supported in Travis CI) + try { + var renderer = new WebGLRenderer(400, 300, {}); + renderer.destroy(); + } catch (error) { + return; + } + + it('Destroy renderer', function () { + var renderer = new WebGLRenderer(400, 300, {}); + renderer.destroy(); + }); + + describe('.autoResize', function () { + it('Should automatically resize view if enabled', function () { + var renderer = new WebGLRenderer(200, 200, { + autoResize: true + }); + + expect(renderer.view.style.width).to.equal('200px'); + }); + + it('Should not automatically resize view if disabled', function () { + var renderer = new WebGLRenderer(200, 200, { + autoResize: false + }); + + expect(renderer.view.style.width).to.equal(''); + }); + + it('Should not automatically resize view if not specified', function () { + var renderer = new WebGLRenderer(200, 200, { + resolution: 2 + }); + + expect(renderer.view.style.width).to.equal(''); + }); + }); +}); diff --git a/test/unit/pixi-v2/renderers/webgl/WebGLShaders.js b/test/unit/pixi-v2/renderers/webgl/WebGLShaders.js new file mode 100644 index 0000000..6e33e4f --- /dev/null +++ b/test/unit/pixi-v2/renderers/webgl/WebGLShaders.js @@ -0,0 +1,13 @@ +describe('renderers/webgl/WebGLShaders', function () { + 'use strict'; + + var expect = chai.expect; + + it('Module members exist', function () { + + expect(PIXI).to.respondTo('CompileVertexShader'); + expect(PIXI).to.respondTo('CompileFragmentShader'); + expect(PIXI).to.respondTo('_CompileShader'); + expect(PIXI).to.respondTo('compileProgram'); + }); +}); diff --git a/test/unit/pixi-v2/renderers/webgl/WebGLSpriteBatch.js b/test/unit/pixi-v2/renderers/webgl/WebGLSpriteBatch.js new file mode 100644 index 0000000..e662b63 --- /dev/null +++ b/test/unit/pixi-v2/renderers/webgl/WebGLSpriteBatch.js @@ -0,0 +1,10 @@ +describe('renderers/webgl/utils/WebGLSpriteBatch', function () { + 'use strict'; + + var expect = chai.expect; + var WebGLSpriteBatch = PIXI.WebGLSpriteBatch; + + it('Module exists', function () { + expect(WebGLSpriteBatch).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/text/BitmapText.js b/test/unit/pixi-v2/text/BitmapText.js new file mode 100644 index 0000000..9388e3d --- /dev/null +++ b/test/unit/pixi-v2/text/BitmapText.js @@ -0,0 +1,10 @@ +describe('pixi/text/BitmapText', function () { + 'use strict'; + + var expect = chai.expect; + var BitmapText = PIXI.BitmapText; + + it('Module exists', function () { + expect(BitmapText).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/text/Text.js b/test/unit/pixi-v2/text/Text.js new file mode 100644 index 0000000..9bc9ac5 --- /dev/null +++ b/test/unit/pixi-v2/text/Text.js @@ -0,0 +1,10 @@ +describe('pixi/text/Text', function () { + 'use strict'; + + var expect = chai.expect; + var Text = PIXI.Text; + + it('Module exists', function () { + expect(Text).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/textures/BaseTexture.js b/test/unit/pixi-v2/textures/BaseTexture.js new file mode 100644 index 0000000..502b724 --- /dev/null +++ b/test/unit/pixi-v2/textures/BaseTexture.js @@ -0,0 +1,11 @@ +describe('pixi/textures/BaseTexture', function () { + 'use strict'; + + var expect = chai.expect; + var BaseTexture = PIXI.BaseTexture; + + it('Module exists', function () { + expect(BaseTexture).to.be.a('function'); + expect(PIXI).to.have.property('BaseTextureCache').and.to.be.an('object'); + }); +}); diff --git a/test/unit/pixi-v2/textures/RenderTexture.js b/test/unit/pixi-v2/textures/RenderTexture.js new file mode 100644 index 0000000..96acdb4 --- /dev/null +++ b/test/unit/pixi-v2/textures/RenderTexture.js @@ -0,0 +1,15 @@ +describe('pixi/textures/RenderTexture', function () { + 'use strict'; + + var expect = chai.expect; + var RenderTexture = PIXI.RenderTexture; + + it('Module exists', function () { + expect(RenderTexture).to.be.a('function'); + }); + + it('Confirm new instance', function (done) { + var texture = new RenderTexture(100, 100, new PIXI.CanvasRenderer()); + pixi_textures_RenderTexture_confirmNew(texture, done); + }); +}); diff --git a/test/unit/pixi-v2/textures/Texture.js b/test/unit/pixi-v2/textures/Texture.js new file mode 100644 index 0000000..090f64d --- /dev/null +++ b/test/unit/pixi-v2/textures/Texture.js @@ -0,0 +1,26 @@ +describe('pixi/textures/Texture', function () { + 'use strict'; + + var expect = chai.expect; + var Texture = PIXI.Texture; + + it('Module exists', function () { + expect(Texture).to.be.a('function'); + expect(PIXI).to.have.property('TextureCache').and.to.be.an('object'); + }); + + it('Members exist', function () { + expect(Texture).itself.to.respondTo('fromImage'); + expect(Texture).itself.to.respondTo('fromFrame'); + expect(Texture).itself.to.respondTo('fromCanvas'); + expect(Texture).itself.to.respondTo('addTextureToCache'); + expect(Texture).itself.to.respondTo('removeTextureFromCache'); + + // expect(Texture).itself.to.have.deep.property('frameUpdates.length', 0); + }); + + it('Confirm new instance', function (done) { + var texture = Texture.fromImage('/base/test/textures/bunny.png'); + pixi_textures_Texture_confirmNew(texture, done); + }); +}); diff --git a/test/unit/pixi-v2/utils/Detector.js b/test/unit/pixi-v2/utils/Detector.js new file mode 100644 index 0000000..4cf6008 --- /dev/null +++ b/test/unit/pixi-v2/utils/Detector.js @@ -0,0 +1,10 @@ +describe('pixi/utils/Detector', function () { + 'use strict'; + + var expect = chai.expect; + var autoDetectRenderer = PIXI.autoDetectRenderer; + + it('Module exists', function () { + expect(autoDetectRenderer).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/utils/EventTarget.js b/test/unit/pixi-v2/utils/EventTarget.js new file mode 100644 index 0000000..1cfc3a4 --- /dev/null +++ b/test/unit/pixi-v2/utils/EventTarget.js @@ -0,0 +1,361 @@ +describe('pixi/utils/EventTarget', function () { + 'use strict'; + + var expect = chai.expect; + + var Clazz, PClazz, obj, pobj, obj2; + beforeEach(function () { + Clazz = function () {}; + PClazz = function () {}; + + PIXI.EventTarget.mixin(Clazz.prototype); + PIXI.EventTarget.mixin(PClazz.prototype); + + obj = new Clazz(); + obj2 = new Clazz(); + pobj = new PClazz(); + + obj.parent = pobj; + obj2.parent = obj; + }); + + it('Module exists', function () { + expect(PIXI.EventTarget).to.be.an('object'); + }); + + it('Confirm new instance', function () { + pixi_utils_EventTarget_confirm(obj); + }); + + it('simple on/emit case works', function () { + var myData = {}; + + obj.on('myevent', function (event) { + pixi_utils_EventTarget_Event_confirm(event, obj, myData); + }); + + obj.emit('myevent', myData); + }); + + it('simple once case works', function () { + var called = 0; + + obj.once('myevent', function() { called++; }); + + obj.emit('myevent'); + obj.emit('myevent'); + obj.emit('myevent'); + obj.emit('myevent'); + obj.emit('myevent'); + + expect(called).to.equal(1); + }); + + it('simple off case works', function (done) { + function onMyEvent() { + done(new Error('Event listener should not have been called')); + } + + obj.on('myevent', onMyEvent); + obj.off('myevent', onMyEvent); + obj.emit('myevent'); + + done(); + }); + + it('simple propagation case works', function (done) { + var myData = {}; + + pobj.on('myevent', function () { + done(); + }); + + obj.emit('myevent'); + }); + + it('simple stopPropagation case works', function (done) { + var myData = {}; + + pobj.on('myevent', function () { + done(new Error('Event listener should not have been called on the parent element')); + }); + + obj.on('myevent', function (evt) { + evt.stopPropagation(); + }); + + obj.emit('myevent'); + + done(); + }); + + it('simple stopImmediatePropagation case works', function (done) { + var myData = {}; + + pobj.on('myevent', function () { + done(new Error('Event listener should not have been called on the parent')); + }); + + obj.on('myevent', function (evt) { + evt.stopImmediatePropagation(); + }); + + obj.on('myevent', function () { + done(new Error('Event listener should not have been called on the second')); + }); + + obj.emit('myevent'); + + done(); + }); + + it('multiple dispatches work properly', function () { + var called = 0; + + function onMyEvent() { + called++; + } + + obj.on('myevent', onMyEvent); + obj.emit('myevent'); + obj.emit('myevent'); + obj.emit('myevent'); + obj.emit('myevent'); + + expect(called).to.equal(4); + }); + + it('multiple events work properly', function () { + var called = 0; + + function onMyEvent() { + called++; + } + + obj.on('myevent1', onMyEvent); + obj.on('myevent2', onMyEvent); + obj.on('myevent3', onMyEvent); + obj.emit('myevent1'); + obj.emit('myevent2'); + obj.emit('myevent3'); + + expect(called).to.equal(3); + }); + + it('multiple events one removed works properly', function () { + var called = 0; + + function onMyEvent() { + called++; + } + + obj.on('myevent1', onMyEvent); + obj.on('myevent2', onMyEvent); + obj.on('myevent3', onMyEvent); + + obj.emit('myevent1'); + obj.emit('myevent2'); + obj.emit('myevent3'); + + obj.off('myevent2', onMyEvent); + + obj.emit('myevent1'); + obj.emit('myevent2'); + obj.emit('myevent3'); + + expect(called).to.equal(5); + }); + + it('multiple handlers for one event with some removed', function () { + var called = 0; + + var onMyEvent = function () { + called++; + }, + onMyEvent2 = function () { + called++; + }; + + // add 2 handlers and confirm they both get called + obj.on('myevent', onMyEvent); + obj.on('myevent', onMyEvent); + obj.on('myevent', onMyEvent2); + obj.on('myevent', onMyEvent2); + + obj.emit('myevent'); + + expect(called).to.equal(4); + + // remove one of the handlers, emit again, then ensure 1 more call is made + obj.off('myevent', onMyEvent); + + obj.emit('myevent'); + + expect(called).to.equal(6); + }); + + it('calls to off without a handler do nothing', function () { + var called = 0; + + var onMyEvent = function () { + called++; + }; + + obj.on('myevent', onMyEvent); + obj.on('myevent', onMyEvent); + + obj.emit('myevent'); + + expect(called).to.equal(2); + + obj.off('myevent'); + + obj.emit('myevent'); + + expect(called).to.equal(4); + + obj.off('myevent', onMyEvent); + + obj.emit('myevent'); + + expect(called).to.equal(4); + }); + + it('handles multiple instances with the same prototype', function () { + var called = 0; + + function onMyEvent(e) { + called++; + } + + obj.on('myevent1', onMyEvent); + obj.on('myevent2', onMyEvent); + + obj2.istwo = true; + obj2.on('myevent1', onMyEvent); + obj2.on('myevent2', onMyEvent); + + obj.emit('myevent1'); + obj.emit('myevent2'); + obj2.emit('myevent1'); + obj2.emit('myevent2'); + + //we emit 4 times, but since obj2 is a child of obj the event should bubble + //up to obj and show up there as well. So the obj2.emit() calls each increment + //the counter twice. + expect(called).to.equal(6); + }); + + it('is backwards compatible with older .dispatchEvent({})', function () { + var called = 0, + data = { + some: 'thing', + hello: true + }; + + function onMyEvent(event) { + pixi_utils_EventTarget_Event_confirm(event, obj, data); + + called++; + } + + obj.on('myevent1', onMyEvent); + obj.on('myevent2', onMyEvent); + obj.on('myevent3', onMyEvent); + + data.type = 'myevent1'; + obj.emit(data); + + data.type = 'myevent2'; + obj.emit(data); + + data.type = 'myevent3'; + obj.emit(data); + + obj.off('myevent2', onMyEvent); + + data.type = 'myevent1'; + obj.emit(data); + + data.type = 'myevent2'; + obj.emit(data); + + data.type = 'myevent3'; + obj.emit(data); + + expect(called).to.equal(5); + }); + + it('is backwards compatible with older .call(this)', function () { + var Fn = function() { + PIXI.EventTarget.call(this); + }, + o = new Fn(); + + pixi_utils_EventTarget_confirm(o); + }); + + it('is backwards compatible with older .addEventListener("")', function () { + var called = 0, + data = { + some: 'thing', + hello: true + }; + + function onMyEvent(event) { + pixi_utils_EventTarget_Event_confirm(event, obj, data); + + called++; + } + + obj.addEventListener('myevent1', onMyEvent); + obj.addEventListener('myevent2', onMyEvent); + obj.addEventListener('myevent3', onMyEvent); + + data.type = 'myevent1'; + obj.emit(data); + + data.type = 'myevent2'; + obj.emit(data); + + data.type = 'myevent3'; + obj.emit(data); + + obj.off('myevent2', onMyEvent); + + data.type = 'myevent1'; + obj.emit(data); + + data.type = 'myevent2'; + obj.emit(data); + + data.type = 'myevent3'; + obj.emit(data); + + expect(called).to.equal(5); + }); + + it('event remove during emit call properly', function () { + var called = 0; + + function cb1() { + called++; + obj.off('myevent', cb1); + } + function cb2() { + called++; + obj.off('myevent', cb2); + } + function cb3() { + called++; + obj.off('myevent', cb3); + } + + obj.on('myevent', cb1); + obj.on('myevent', cb2); + obj.on('myevent', cb3); + obj.emit('myevent', ''); + + expect(called).to.equal(3); + }); +}); diff --git a/test/unit/pixi-v2/utils/Polyk.js b/test/unit/pixi-v2/utils/Polyk.js new file mode 100644 index 0000000..dfc7128 --- /dev/null +++ b/test/unit/pixi-v2/utils/Polyk.js @@ -0,0 +1,14 @@ +describe('pixi/utils/Polyk', function () { + 'use strict'; + + var expect = chai.expect; + var PolyK = PIXI.PolyK; + + it('Module exists', function () { + expect(PolyK).to.be.an('object'); + }); + + it('Members exist', function () { + expect(PolyK).to.respondTo('Triangulate'); + }); +}); diff --git a/test/unit/pixi-v2/utils/Utils.js b/test/unit/pixi-v2/utils/Utils.js new file mode 100644 index 0000000..c97b3c6 --- /dev/null +++ b/test/unit/pixi-v2/utils/Utils.js @@ -0,0 +1,17 @@ +describe('Utils', function () { + 'use strict'; + + var expect = chai.expect; + + it('requestAnimationFrame exists', function () { + expect(global).to.respondTo('requestAnimationFrame'); + }); + + it('cancelAnimationFrame exists', function () { + expect(global).to.respondTo('cancelAnimationFrame'); + }); + + it('requestAnimFrame exists', function () { + expect(global).to.respondTo('requestAnimFrame'); + }); +}); diff --git a/test/unit/pixi/InteractionManager.js b/test/unit/pixi/InteractionManager.js deleted file mode 100644 index ed3001f..0000000 --- a/test/unit/pixi/InteractionManager.js +++ /dev/null @@ -1,10 +0,0 @@ -describe('pixi/InteractionManager', function () { - 'use strict'; - - var expect = chai.expect; - var InteractionManager = PIXI.InteractionManager; - - it('Module exists', function () { - expect(InteractionManager).to.be.a('function'); - }); -}); diff --git a/test/unit/pixi/Pixi.js b/test/unit/pixi/Pixi.js deleted file mode 100644 index 27debc1..0000000 --- a/test/unit/pixi/Pixi.js +++ /dev/null @@ -1,9 +0,0 @@ -describe('pixi/Pixi', function () { - 'use strict'; - - var expect = chai.expect; - - it('Module exists', function () { - expect(global).to.have.property('PIXI').and.to.be.an('object'); - }); -}); diff --git a/test/unit/pixi/core/Circle.js b/test/unit/pixi/core/Circle.js deleted file mode 100644 index fbcfa17..0000000 --- a/test/unit/pixi/core/Circle.js +++ /dev/null @@ -1,21 +0,0 @@ -describe('pixi/core/Circle', function () { - 'use strict'; - - var expect = chai.expect; - var Circle = PIXI.Circle; - - it('Module exists', function () { - expect(Circle).to.be.a('function'); - }); - - it('Confirm new instance', function () { - var obj = new Circle(); - pixi_core_Circle_confirmNewCircle(obj); - }); - - it("getBounds should return Rectangle that bounds the circle", function() { - var obj = new Circle(100, 250, 50); - var bounds = obj.getBounds(); - pixi_core_Circle_isBoundedByRectangle(obj, bounds); - }); -}); diff --git a/test/unit/pixi/core/Ellipse.js b/test/unit/pixi/core/Ellipse.js deleted file mode 100644 index 026b56f..0000000 --- a/test/unit/pixi/core/Ellipse.js +++ /dev/null @@ -1,24 +0,0 @@ -describe('pixi/core/Ellipse', function () { - 'use strict'; - - var expect = chai.expect; - var Ellipse = PIXI.Ellipse; - - it('Module exists', function () { - expect(Ellipse).to.be.a('function'); - }); - - it('Confirm new instance', function () { - var obj = new Ellipse(); - - expect(obj).to.be.an.instanceof(Ellipse); - expect(obj).to.respondTo('clone'); - expect(obj).to.respondTo('contains'); - expect(obj).to.respondTo('getBounds'); - - expect(obj).to.have.property('x', 0); - expect(obj).to.have.property('y', 0); - expect(obj).to.have.property('width', 0); - expect(obj).to.have.property('height', 0); - }); -}); diff --git a/test/unit/pixi/core/Matrix.js b/test/unit/pixi/core/Matrix.js deleted file mode 100644 index da75e2e..0000000 --- a/test/unit/pixi/core/Matrix.js +++ /dev/null @@ -1,14 +0,0 @@ -describe('pixi/core/Matrix', function () { - 'use strict'; - - var expect = chai.expect; - - it('Matrix exists', function () { - expect(PIXI.Matrix).to.be.an('function'); - }); - - it('Confirm new Matrix', function () { - var matrix = new PIXI.Matrix(); - pixi_core_Matrix_confirmNewMatrix(matrix); - }); -}); diff --git a/test/unit/pixi/core/Point.js b/test/unit/pixi/core/Point.js deleted file mode 100644 index c4d5163..0000000 --- a/test/unit/pixi/core/Point.js +++ /dev/null @@ -1,15 +0,0 @@ -describe('pixi/core/Point', function () { - 'use strict'; - - var expect = chai.expect; - var Point = PIXI.Point; - - it('Module exists', function () { - expect(Point).to.be.a('function'); - }); - - it('Confirm new instance', function () { - var obj = new Point(); - pixi_core_Point_confirm(obj, 0, 0); - }); -}); diff --git a/test/unit/pixi/core/Polygon.js b/test/unit/pixi/core/Polygon.js deleted file mode 100644 index dc8c918..0000000 --- a/test/unit/pixi/core/Polygon.js +++ /dev/null @@ -1,20 +0,0 @@ -describe('pixi/core/Polygon', function () { - 'use strict'; - - var expect = chai.expect; - var Polygon = PIXI.Polygon; - - it('Module exists', function () { - expect(Polygon).to.be.a('function'); - }); - - it('Confirm new instance', function () { - var obj = new Polygon(); - - expect(obj).to.be.an.instanceof(Polygon); - expect(obj).to.respondTo('clone'); - expect(obj).to.respondTo('contains'); - - expect(obj).to.have.deep.property('points.length', 0); - }); -}); diff --git a/test/unit/pixi/core/Rectangle.js b/test/unit/pixi/core/Rectangle.js deleted file mode 100644 index d43316e..0000000 --- a/test/unit/pixi/core/Rectangle.js +++ /dev/null @@ -1,15 +0,0 @@ -describe('pixi/core/Rectangle', function () { - 'use strict'; - - var expect = chai.expect; - var Rectangle = PIXI.Rectangle; - - it('Module exists', function () { - expect(Rectangle).to.be.a('function'); - }); - - it('Confirm new instance', function () { - var rect = new Rectangle(); - pixi_core_Rectangle_confirm(rect, 0, 0, 0, 0); - }); -}); diff --git a/test/unit/pixi/display/DisplayObject.js b/test/unit/pixi/display/DisplayObject.js deleted file mode 100644 index 044acf8..0000000 --- a/test/unit/pixi/display/DisplayObject.js +++ /dev/null @@ -1,21 +0,0 @@ -describe('pixi/display/DisplayObject', function () { - 'use strict'; - - var expect = chai.expect; - var DisplayObject = PIXI.DisplayObject; - - it('Module exists', function () { - expect(DisplayObject).to.be.a('function'); - // expect(PIXI).to.have.property('visibleCount', 0); - }); - - it('Confirm new instance', function () { - var obj = new DisplayObject(); - - pixi_display_DisplayObject_confirmNew(obj); - expect(obj).to.have.property('hitArea', null); - expect(obj).to.have.property('interactive', false); - expect(obj).to.have.property('renderable', false); - expect(obj).to.have.property('stage', null); - }); -}); diff --git a/test/unit/pixi/display/DisplayObjectContainer.js b/test/unit/pixi/display/DisplayObjectContainer.js deleted file mode 100644 index 15a3376..0000000 --- a/test/unit/pixi/display/DisplayObjectContainer.js +++ /dev/null @@ -1,67 +0,0 @@ -describe('pixi/display/DisplayObjectContainer', function () { - 'use strict'; - - var expect = chai.expect; - var DisplayObjectContainer = PIXI.DisplayObjectContainer; - - it('Module exists', function () { - expect(DisplayObjectContainer).to.be.a('function'); - }); - - it('Confirm new instance', function () { - var obj = new DisplayObjectContainer(); - - pixi_display_DisplayObjectContainer_confirmNew(obj); - expect(obj).to.have.property('hitArea', null); - expect(obj).to.have.property('interactive', false); - expect(obj).to.have.property('renderable', false); - expect(obj).to.have.property('stage', null); - }); - - it('Gets child index', function() { - var container = new PIXI.DisplayObjectContainer(); - var children = []; - for (var i = 0; i < 10; i++) { - var child = new PIXI.DisplayObject(); - children.push(child); - container.addChild(child); - } - - for (i = 0; i < children.length; i++) { - expect(i).to.eql(container.getChildIndex(children[i])); - } - }); - - it('throws error when trying to get index of not a child', function() { - var container = new PIXI.DisplayObjectContainer(); - var child = new PIXI.DisplayObject(); - - expect(function() { container.getChildIndex(child); }).to.throw(); - }); - - it('Sets child index', function() { - var container = new PIXI.DisplayObjectContainer(); - var children = []; - - for (var i = 0; i < 10; i++) { - var child = new PIXI.DisplayObject(); - children.push(child); - container.addChild(child); - } - children.reverse(); - - for (i = 0; i < children.length; i++) { - container.setChildIndex(children[i], i); - expect(i).to.eql(container.getChildIndex(children[i])); - } - }); - - it('throws error when trying to set incorect index', function() { - var container = new PIXI.DisplayObjectContainer(); - var child = new PIXI.DisplayObject(); - container.addChild(child); - - expect(function() { container.setChildIndex(child, -1); }).to.throw(); - expect(function() { container.setChildIndex(child, 1); }).to.throw(); - }); -}); diff --git a/test/unit/pixi/display/MovieClip.js b/test/unit/pixi/display/MovieClip.js deleted file mode 100644 index f3c6c6a..0000000 --- a/test/unit/pixi/display/MovieClip.js +++ /dev/null @@ -1,33 +0,0 @@ -describe('pixi/display/MovieClip', function () { - 'use strict'; - - var expect = chai.expect; - var MovieClip = PIXI.MovieClip; - var Texture = PIXI.Texture; - - it('Module exists', function () { - expect(MovieClip).to.be.a('function'); - }); - - it('Confirm new instance', function (done) { - var texture = Texture.fromImage('/base/test/textures/SpriteSheet-Explosion.png'); - var obj = new MovieClip([texture]); - - pixi_display_Sprite_confirmNew(obj, done); - - expect(obj).to.be.an.instanceof(MovieClip); - expect(obj).to.respondTo('stop'); - expect(obj).to.respondTo('play'); - expect(obj).to.respondTo('gotoAndStop'); - expect(obj).to.respondTo('gotoAndPlay'); - expect(obj).to.respondTo('updateTransform'); - - expect(obj).to.have.deep.property('textures.length', 1); - expect(obj).to.have.deep.property('textures[0]', texture); - expect(obj).to.have.property('animationSpeed', 1); - expect(obj).to.have.property('loop', true); - expect(obj).to.have.property('onComplete', null); - expect(obj).to.have.property('currentFrame', 0); - expect(obj).to.have.property('playing', false); - }); -}); diff --git a/test/unit/pixi/display/Sprite.js b/test/unit/pixi/display/Sprite.js deleted file mode 100644 index 30c8076..0000000 --- a/test/unit/pixi/display/Sprite.js +++ /dev/null @@ -1,28 +0,0 @@ -describe('pixi/display/Sprite', function () { - 'use strict'; - - var expect = chai.expect; - var Sprite = PIXI.Sprite; - var Texture = PIXI.Texture; - - it('Module exists', function () { - expect(Sprite).to.be.a('function'); - expect(PIXI).to.have.deep.property('blendModes.NORMAL', 0); - expect(PIXI).to.have.deep.property('blendModes.ADD', 1); - expect(PIXI).to.have.deep.property('blendModes.MULTIPLY', 2); - expect(PIXI).to.have.deep.property('blendModes.SCREEN', 3); - }); - - - it('Members exist', function () { - expect(Sprite).itself.to.respondTo('fromImage'); - expect(Sprite).itself.to.respondTo('fromFrame'); - }); - - it('Confirm new instance', function (done) { - var texture = Texture.fromImage('/base/test/textures/SpriteSheet-Aliens.png'); - var obj = new Sprite(texture); - - pixi_display_Sprite_confirmNew(obj, done); - }); -}); diff --git a/test/unit/pixi/display/Stage.js b/test/unit/pixi/display/Stage.js deleted file mode 100644 index 6974c2e..0000000 --- a/test/unit/pixi/display/Stage.js +++ /dev/null @@ -1,49 +0,0 @@ -describe('pixi/display/Stage', function () { - 'use strict'; - - var expect = chai.expect; - var Stage = PIXI.Stage; - var InteractionManager = PIXI.InteractionManager; - var Rectangle = PIXI.Rectangle; - - it('Module exists', function () { - expect(Stage).to.be.a('function'); - }); - - it('Confirm new instance', function () { - var obj = new Stage(null, true); - - pixi_display_DisplayObjectContainer_confirmNew(obj); - - expect(obj).to.be.an.instanceof(Stage); - expect(obj).to.respondTo('updateTransform'); - expect(obj).to.respondTo('setBackgroundColor'); - expect(obj).to.respondTo('getMousePosition'); - // FIXME: duplicate member in DisplayObject - pixi_core_Matrix_confirmNewMatrix(obj.worldTransform); - // FIXME: convert arg to bool in constructor - expect(obj).to.have.property('interactive', true); - - expect(obj).to.have.property('interactionManager') - .and.to.be.an.instanceof(InteractionManager) - .and.to.have.property('stage', obj); - - expect(obj).to.have.property('dirty', true); - - expect(obj).to.have.property('stage', obj); - - expect(obj).to.have.property('hitArea') - .and.to.be.an.instanceof(Rectangle); - pixi_core_Rectangle_confirm(obj.hitArea, 0, 0, 100000, 100000); - - expect(obj).to.have.property('backgroundColor', 0x000000); - expect(obj).to.have.deep.property('backgroundColorSplit.length', 3); - expect(obj).to.have.deep.property('backgroundColorSplit[0]', 0); - expect(obj).to.have.deep.property('backgroundColorSplit[1]', 0); - expect(obj).to.have.deep.property('backgroundColorSplit[2]', 0); - expect(obj).to.have.property('backgroundColorString', '#000000'); - - - expect(obj).to.have.property('worldVisible', true); - }); -}); diff --git a/test/unit/pixi/extras/Rope.js b/test/unit/pixi/extras/Rope.js deleted file mode 100644 index 05885ac..0000000 --- a/test/unit/pixi/extras/Rope.js +++ /dev/null @@ -1,31 +0,0 @@ -describe('pixi/extras/Rope', function () { - 'use strict'; - - var expect = chai.expect; - var Rope = PIXI.Rope; - var Texture = PIXI.Texture; - var Point = PIXI.Point; - - it('Module exists', function () { - expect(Rope).to.be.a('function'); - }); - - it('Confirm new instance', function () { - - var texture = Texture.fromImage('/base/test/textures/bunny.png'); - - // TODO-Alvin - // Same as Strip - - // var obj = new Rope(texture, [new Point(), new Point(5, 10), new Point(10, 20)]); - - // pixi_extras_Strip_confirmNew(obj); - - // expect(obj).to.be.an.instanceof(Rope); - // expect(obj).to.respondTo('refresh'); - // expect(obj).to.respondTo('updateTransform'); - // expect(obj).to.respondTo('setTexture'); - - // TODO: Test properties - }); -}); diff --git a/test/unit/pixi/extras/Spine.js b/test/unit/pixi/extras/Spine.js deleted file mode 100644 index 0708bc0..0000000 --- a/test/unit/pixi/extras/Spine.js +++ /dev/null @@ -1,10 +0,0 @@ -describe('pixi/extras/Spine', function () { - 'use strict'; - - var expect = chai.expect; - var Spine = PIXI.Spine; - - it('Module exists', function () { - expect(Spine).to.be.a('function'); - }); -}); diff --git a/test/unit/pixi/extras/Strip.js b/test/unit/pixi/extras/Strip.js deleted file mode 100644 index 230af90..0000000 --- a/test/unit/pixi/extras/Strip.js +++ /dev/null @@ -1,26 +0,0 @@ -describe('pixi/extras/Strip', function () { - 'use strict'; - - var expect = chai.expect; - var Strip = PIXI.Strip; - var Texture = PIXI.Texture; - - it('Module exists', function () { - expect(Strip).to.be.a('function'); - }); - - it('Confirm new instance', function () { - - - // TODO-Alvin - // We tweaked it to make it pass the tests, but the whole strip class needs - // to be re-coded - - var texture = Texture.fromImage('/base/test/textures/bunny.png'); - - // var obj = new Strip(texture, 20, 10000); - - - // pixi_extras_Strip_confirmNew(obj); - }); -}); diff --git a/test/unit/pixi/extras/TilingSprite.js b/test/unit/pixi/extras/TilingSprite.js deleted file mode 100644 index 56aea14..0000000 --- a/test/unit/pixi/extras/TilingSprite.js +++ /dev/null @@ -1,24 +0,0 @@ -describe('pixi/extras/TilingSprite', function () { - 'use strict'; - - var expect = chai.expect; - var TilingSprite = PIXI.TilingSprite; - var Texture = PIXI.Texture; - - it('Module exists', function () { - expect(TilingSprite).to.be.a('function'); - }); - - it('Confirm new instance', function () { - var texture = Texture.fromImage('/base/test/textures/bunny.png'); - var obj = new TilingSprite(texture, 6000, 12000); - - pixi_display_DisplayObjectContainer_confirmNew(obj); - - expect(obj).to.be.an.instanceof(TilingSprite); - expect(obj).to.respondTo('setTexture'); - expect(obj).to.respondTo('onTextureUpdate'); - - // TODO: Test properties - }); -}); diff --git a/test/unit/pixi/filters/FilterBlock.js b/test/unit/pixi/filters/FilterBlock.js deleted file mode 100644 index 870cec0..0000000 --- a/test/unit/pixi/filters/FilterBlock.js +++ /dev/null @@ -1,10 +0,0 @@ -describe('pixi/filters/FilterBlock', function () { - 'use strict'; - - var expect = chai.expect; - var FilterBlock = PIXI.FilterBlock; - - it('Module exists', function () { - expect(FilterBlock).to.be.a('function'); - }); -}); diff --git a/test/unit/pixi/loaders/AssetLoader.js b/test/unit/pixi/loaders/AssetLoader.js deleted file mode 100644 index a0aa0b5..0000000 --- a/test/unit/pixi/loaders/AssetLoader.js +++ /dev/null @@ -1,10 +0,0 @@ -describe('pixi/loaders/AssetLoader', function () { - 'use strict'; - - var expect = chai.expect; - var AssetLoader = PIXI.AssetLoader; - - it('Module exists', function () { - expect(AssetLoader).to.be.a('function'); - }); -}); diff --git a/test/unit/pixi/loaders/BitmapFontLoader.js b/test/unit/pixi/loaders/BitmapFontLoader.js deleted file mode 100644 index 046f018..0000000 --- a/test/unit/pixi/loaders/BitmapFontLoader.js +++ /dev/null @@ -1,9 +0,0 @@ -describe('pixi/loaders/BitmapFontLoader', function () { - 'use strict'; - - var expect = chai.expect; - - it('Module exists', function () { - expect(PIXI.BitmapFontLoader).to.be.a('function'); - }); -}); diff --git a/test/unit/pixi/loaders/ImageLoader.js b/test/unit/pixi/loaders/ImageLoader.js deleted file mode 100644 index 8b1f556..0000000 --- a/test/unit/pixi/loaders/ImageLoader.js +++ /dev/null @@ -1,10 +0,0 @@ -describe('pixi/loaders/ImageLoader', function () { - 'use strict'; - - var expect = chai.expect; - var ImageLoader = PIXI.ImageLoader; - - it('Module exists', function () { - expect(ImageLoader).to.be.a('function'); - }); -}); diff --git a/test/unit/pixi/loaders/JsonLoader.js b/test/unit/pixi/loaders/JsonLoader.js deleted file mode 100644 index c577e83..0000000 --- a/test/unit/pixi/loaders/JsonLoader.js +++ /dev/null @@ -1,10 +0,0 @@ -describe('pixi/loaders/JsonLoader', function () { - 'use strict'; - - var expect = chai.expect; - var JsonLoader = PIXI.JsonLoader; - - it('Module exists', function () { - expect(JsonLoader).to.be.a('function'); - }); -}); diff --git a/test/unit/pixi/loaders/SpineLoader.js b/test/unit/pixi/loaders/SpineLoader.js deleted file mode 100644 index fdcc0b8..0000000 --- a/test/unit/pixi/loaders/SpineLoader.js +++ /dev/null @@ -1,10 +0,0 @@ -describe('pixi/loaders/SpineLoader', function () { - 'use strict'; - - var expect = chai.expect; - var SpineLoader = PIXI.SpineLoader; - - it('Module exists', function () { - expect(SpineLoader).to.be.a('function'); - }); -}); diff --git a/test/unit/pixi/loaders/SpriteSheetLoader.js b/test/unit/pixi/loaders/SpriteSheetLoader.js deleted file mode 100644 index 57beb27..0000000 --- a/test/unit/pixi/loaders/SpriteSheetLoader.js +++ /dev/null @@ -1,10 +0,0 @@ -describe('pixi/loaders/SpriteSheetLoader', function () { - 'use strict'; - - var expect = chai.expect; - var SpriteSheetLoader = PIXI.SpriteSheetLoader; - - it('Module exists', function () { - expect(SpriteSheetLoader).to.be.a('function'); - }); -}); diff --git a/test/unit/pixi/primitives/Graphics.js b/test/unit/pixi/primitives/Graphics.js deleted file mode 100644 index f3849eb..0000000 --- a/test/unit/pixi/primitives/Graphics.js +++ /dev/null @@ -1,44 +0,0 @@ -describe('pixi/primitives/Graphics', function () { - 'use strict'; - - var expect = chai.expect; - var Graphics = PIXI.Graphics; - - it('Module exists', function () { - expect(Graphics).to.be.a('function'); - - expect(Graphics).itself.to.have.property('POLY', 0); - expect(Graphics).itself.to.have.property('RECT', 1); - expect(Graphics).itself.to.have.property('CIRC', 2); - expect(Graphics).itself.to.have.property('ELIP', 3); - expect(Graphics).itself.to.have.property('RREC', 4); - }); - - it('Confirm new instance', function () { - var obj = new Graphics(); - - pixi_display_DisplayObjectContainer_confirmNew(obj); - - expect(obj).to.be.an.instanceof(Graphics); - expect(obj).to.respondTo('lineStyle'); - expect(obj).to.respondTo('lineStyle'); - expect(obj).to.respondTo('moveTo'); - expect(obj).to.respondTo('lineTo'); - expect(obj).to.respondTo('beginFill'); - expect(obj).to.respondTo('endFill'); - expect(obj).to.respondTo('drawRect'); - // expect(obj).to.respondTo('drawRoundedRect'); - expect(obj).to.respondTo('drawCircle'); - expect(obj).to.respondTo('drawEllipse'); - expect(obj).to.respondTo('clear'); - - expect(obj).to.have.property('renderable', true); - expect(obj).to.have.property('fillAlpha', 1); - expect(obj).to.have.property('lineWidth', 0); - expect(obj).to.have.property('width', 0); - expect(obj).to.have.property('height', 0); - expect(obj).to.have.property('lineColor', 0); - expect(obj).to.have.deep.property('graphicsData.length', 0); - // expect(obj).to.have.deep.property('currentPath.points.length', 0); - }); -}); diff --git a/test/unit/pixi/renderers/canvas/CanvasGraphics.js b/test/unit/pixi/renderers/canvas/CanvasGraphics.js deleted file mode 100644 index 8f44472..0000000 --- a/test/unit/pixi/renderers/canvas/CanvasGraphics.js +++ /dev/null @@ -1,15 +0,0 @@ -describe('renders/canvas/CanvasGraphics', function () { - 'use strict'; - - var expect = chai.expect; - var CanvasGraphics = PIXI.CanvasGraphics; - - it('Module exists', function () { - expect(CanvasGraphics).to.be.a('function'); - }); - - it('Members exist', function () { - expect(CanvasGraphics).itself.to.respondTo('renderGraphics'); - expect(CanvasGraphics).itself.to.respondTo('renderGraphicsMask'); - }); -}); diff --git a/test/unit/pixi/renderers/canvas/CanvasRenderer.js b/test/unit/pixi/renderers/canvas/CanvasRenderer.js deleted file mode 100644 index 1646444..0000000 --- a/test/unit/pixi/renderers/canvas/CanvasRenderer.js +++ /dev/null @@ -1,36 +0,0 @@ -describe('renderers/canvas/CanvasRenderer', function () { - 'use strict'; - - var expect = chai.expect; - var CanvasRenderer = PIXI.CanvasRenderer; - - it('Module exists', function () { - expect(CanvasRenderer).to.be.a('function'); - }); - - describe('.autoResize', function () { - it('Should automatically resize view if enabled', function () { - var renderer = new CanvasRenderer(200, 200, { - autoResize: true - }); - - expect(renderer.view.style.width).to.equal('200px'); - }); - - it('Should not automatically resize view if disabled', function () { - var renderer = new CanvasRenderer(200, 200, { - autoResize: false - }); - - expect(renderer.view.style.width).to.equal(''); - }); - - it('Should not automatically resize view if not specified', function () { - var renderer = new CanvasRenderer(200, 200, { - resolution: 2 - }); - - expect(renderer.view.style.width).to.equal(''); - }); - }); -}); diff --git a/test/unit/pixi/renderers/webgl/WebGLGraphics.js b/test/unit/pixi/renderers/webgl/WebGLGraphics.js deleted file mode 100644 index 5867b28..0000000 --- a/test/unit/pixi/renderers/webgl/WebGLGraphics.js +++ /dev/null @@ -1,20 +0,0 @@ -describe('renderers/wegbl/WebGLGraphics', function () { - 'use strict'; - - var expect = chai.expect; - var WebGLGraphics = PIXI.WebGLGraphics; - - it('Module exists', function () { - expect(WebGLGraphics).to.be.a('function'); - }); - - it('Members exist', function () { - expect(WebGLGraphics).itself.to.respondTo('renderGraphics'); - expect(WebGLGraphics).itself.to.respondTo('updateGraphics'); - expect(WebGLGraphics).itself.to.respondTo('buildRectangle'); - expect(WebGLGraphics).itself.to.respondTo('buildRoundedRectangle'); - expect(WebGLGraphics).itself.to.respondTo('buildCircle'); - expect(WebGLGraphics).itself.to.respondTo('buildLine'); - expect(WebGLGraphics).itself.to.respondTo('buildPoly'); - }); -}); diff --git a/test/unit/pixi/renderers/webgl/WebGLRenderer.js b/test/unit/pixi/renderers/webgl/WebGLRenderer.js deleted file mode 100644 index 1680a80..0000000 --- a/test/unit/pixi/renderers/webgl/WebGLRenderer.js +++ /dev/null @@ -1,49 +0,0 @@ -describe('renderers/webgl/WebGLRenderer', function () { - 'use strict'; - - var expect = chai.expect; - var WebGLRenderer = PIXI.WebGLRenderer; - - it('Module exists', function () { - expect(WebGLRenderer).to.be.a('function'); - }); - - // Skip tests if WebGL is not available (WebGL not supported in Travis CI) - try { - var renderer = new WebGLRenderer(400, 300, {}); - renderer.destroy(); - } catch (error) { - return; - } - - it('Destroy renderer', function () { - var renderer = new WebGLRenderer(400, 300, {}); - renderer.destroy(); - }); - - describe('.autoResize', function () { - it('Should automatically resize view if enabled', function () { - var renderer = new WebGLRenderer(200, 200, { - autoResize: true - }); - - expect(renderer.view.style.width).to.equal('200px'); - }); - - it('Should not automatically resize view if disabled', function () { - var renderer = new WebGLRenderer(200, 200, { - autoResize: false - }); - - expect(renderer.view.style.width).to.equal(''); - }); - - it('Should not automatically resize view if not specified', function () { - var renderer = new WebGLRenderer(200, 200, { - resolution: 2 - }); - - expect(renderer.view.style.width).to.equal(''); - }); - }); -}); diff --git a/test/unit/pixi/renderers/webgl/WebGLShaders.js b/test/unit/pixi/renderers/webgl/WebGLShaders.js deleted file mode 100644 index 6e33e4f..0000000 --- a/test/unit/pixi/renderers/webgl/WebGLShaders.js +++ /dev/null @@ -1,13 +0,0 @@ -describe('renderers/webgl/WebGLShaders', function () { - 'use strict'; - - var expect = chai.expect; - - it('Module members exist', function () { - - expect(PIXI).to.respondTo('CompileVertexShader'); - expect(PIXI).to.respondTo('CompileFragmentShader'); - expect(PIXI).to.respondTo('_CompileShader'); - expect(PIXI).to.respondTo('compileProgram'); - }); -}); diff --git a/test/unit/pixi-v2/InteractionManager.js b/test/unit/pixi-v2/InteractionManager.js new file mode 100644 index 0000000..ed3001f --- /dev/null +++ b/test/unit/pixi-v2/InteractionManager.js @@ -0,0 +1,10 @@ +describe('pixi/InteractionManager', function () { + 'use strict'; + + var expect = chai.expect; + var InteractionManager = PIXI.InteractionManager; + + it('Module exists', function () { + expect(InteractionManager).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/Pixi.js b/test/unit/pixi-v2/Pixi.js new file mode 100644 index 0000000..27debc1 --- /dev/null +++ b/test/unit/pixi-v2/Pixi.js @@ -0,0 +1,9 @@ +describe('pixi/Pixi', function () { + 'use strict'; + + var expect = chai.expect; + + it('Module exists', function () { + expect(global).to.have.property('PIXI').and.to.be.an('object'); + }); +}); diff --git a/test/unit/pixi-v2/core/Circle.js b/test/unit/pixi-v2/core/Circle.js new file mode 100644 index 0000000..fbcfa17 --- /dev/null +++ b/test/unit/pixi-v2/core/Circle.js @@ -0,0 +1,21 @@ +describe('pixi/core/Circle', function () { + 'use strict'; + + var expect = chai.expect; + var Circle = PIXI.Circle; + + it('Module exists', function () { + expect(Circle).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Circle(); + pixi_core_Circle_confirmNewCircle(obj); + }); + + it("getBounds should return Rectangle that bounds the circle", function() { + var obj = new Circle(100, 250, 50); + var bounds = obj.getBounds(); + pixi_core_Circle_isBoundedByRectangle(obj, bounds); + }); +}); diff --git a/test/unit/pixi-v2/core/Ellipse.js b/test/unit/pixi-v2/core/Ellipse.js new file mode 100644 index 0000000..026b56f --- /dev/null +++ b/test/unit/pixi-v2/core/Ellipse.js @@ -0,0 +1,24 @@ +describe('pixi/core/Ellipse', function () { + 'use strict'; + + var expect = chai.expect; + var Ellipse = PIXI.Ellipse; + + it('Module exists', function () { + expect(Ellipse).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Ellipse(); + + expect(obj).to.be.an.instanceof(Ellipse); + expect(obj).to.respondTo('clone'); + expect(obj).to.respondTo('contains'); + expect(obj).to.respondTo('getBounds'); + + expect(obj).to.have.property('x', 0); + expect(obj).to.have.property('y', 0); + expect(obj).to.have.property('width', 0); + expect(obj).to.have.property('height', 0); + }); +}); diff --git a/test/unit/pixi-v2/core/Matrix.js b/test/unit/pixi-v2/core/Matrix.js new file mode 100644 index 0000000..da75e2e --- /dev/null +++ b/test/unit/pixi-v2/core/Matrix.js @@ -0,0 +1,14 @@ +describe('pixi/core/Matrix', function () { + 'use strict'; + + var expect = chai.expect; + + it('Matrix exists', function () { + expect(PIXI.Matrix).to.be.an('function'); + }); + + it('Confirm new Matrix', function () { + var matrix = new PIXI.Matrix(); + pixi_core_Matrix_confirmNewMatrix(matrix); + }); +}); diff --git a/test/unit/pixi-v2/core/Point.js b/test/unit/pixi-v2/core/Point.js new file mode 100644 index 0000000..c4d5163 --- /dev/null +++ b/test/unit/pixi-v2/core/Point.js @@ -0,0 +1,15 @@ +describe('pixi/core/Point', function () { + 'use strict'; + + var expect = chai.expect; + var Point = PIXI.Point; + + it('Module exists', function () { + expect(Point).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Point(); + pixi_core_Point_confirm(obj, 0, 0); + }); +}); diff --git a/test/unit/pixi-v2/core/Polygon.js b/test/unit/pixi-v2/core/Polygon.js new file mode 100644 index 0000000..dc8c918 --- /dev/null +++ b/test/unit/pixi-v2/core/Polygon.js @@ -0,0 +1,20 @@ +describe('pixi/core/Polygon', function () { + 'use strict'; + + var expect = chai.expect; + var Polygon = PIXI.Polygon; + + it('Module exists', function () { + expect(Polygon).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Polygon(); + + expect(obj).to.be.an.instanceof(Polygon); + expect(obj).to.respondTo('clone'); + expect(obj).to.respondTo('contains'); + + expect(obj).to.have.deep.property('points.length', 0); + }); +}); diff --git a/test/unit/pixi-v2/core/Rectangle.js b/test/unit/pixi-v2/core/Rectangle.js new file mode 100644 index 0000000..d43316e --- /dev/null +++ b/test/unit/pixi-v2/core/Rectangle.js @@ -0,0 +1,15 @@ +describe('pixi/core/Rectangle', function () { + 'use strict'; + + var expect = chai.expect; + var Rectangle = PIXI.Rectangle; + + it('Module exists', function () { + expect(Rectangle).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var rect = new Rectangle(); + pixi_core_Rectangle_confirm(rect, 0, 0, 0, 0); + }); +}); diff --git a/test/unit/pixi-v2/display/DisplayObject.js b/test/unit/pixi-v2/display/DisplayObject.js new file mode 100644 index 0000000..044acf8 --- /dev/null +++ b/test/unit/pixi-v2/display/DisplayObject.js @@ -0,0 +1,21 @@ +describe('pixi/display/DisplayObject', function () { + 'use strict'; + + var expect = chai.expect; + var DisplayObject = PIXI.DisplayObject; + + it('Module exists', function () { + expect(DisplayObject).to.be.a('function'); + // expect(PIXI).to.have.property('visibleCount', 0); + }); + + it('Confirm new instance', function () { + var obj = new DisplayObject(); + + pixi_display_DisplayObject_confirmNew(obj); + expect(obj).to.have.property('hitArea', null); + expect(obj).to.have.property('interactive', false); + expect(obj).to.have.property('renderable', false); + expect(obj).to.have.property('stage', null); + }); +}); diff --git a/test/unit/pixi-v2/display/DisplayObjectContainer.js b/test/unit/pixi-v2/display/DisplayObjectContainer.js new file mode 100644 index 0000000..15a3376 --- /dev/null +++ b/test/unit/pixi-v2/display/DisplayObjectContainer.js @@ -0,0 +1,67 @@ +describe('pixi/display/DisplayObjectContainer', function () { + 'use strict'; + + var expect = chai.expect; + var DisplayObjectContainer = PIXI.DisplayObjectContainer; + + it('Module exists', function () { + expect(DisplayObjectContainer).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new DisplayObjectContainer(); + + pixi_display_DisplayObjectContainer_confirmNew(obj); + expect(obj).to.have.property('hitArea', null); + expect(obj).to.have.property('interactive', false); + expect(obj).to.have.property('renderable', false); + expect(obj).to.have.property('stage', null); + }); + + it('Gets child index', function() { + var container = new PIXI.DisplayObjectContainer(); + var children = []; + for (var i = 0; i < 10; i++) { + var child = new PIXI.DisplayObject(); + children.push(child); + container.addChild(child); + } + + for (i = 0; i < children.length; i++) { + expect(i).to.eql(container.getChildIndex(children[i])); + } + }); + + it('throws error when trying to get index of not a child', function() { + var container = new PIXI.DisplayObjectContainer(); + var child = new PIXI.DisplayObject(); + + expect(function() { container.getChildIndex(child); }).to.throw(); + }); + + it('Sets child index', function() { + var container = new PIXI.DisplayObjectContainer(); + var children = []; + + for (var i = 0; i < 10; i++) { + var child = new PIXI.DisplayObject(); + children.push(child); + container.addChild(child); + } + children.reverse(); + + for (i = 0; i < children.length; i++) { + container.setChildIndex(children[i], i); + expect(i).to.eql(container.getChildIndex(children[i])); + } + }); + + it('throws error when trying to set incorect index', function() { + var container = new PIXI.DisplayObjectContainer(); + var child = new PIXI.DisplayObject(); + container.addChild(child); + + expect(function() { container.setChildIndex(child, -1); }).to.throw(); + expect(function() { container.setChildIndex(child, 1); }).to.throw(); + }); +}); diff --git a/test/unit/pixi-v2/display/MovieClip.js b/test/unit/pixi-v2/display/MovieClip.js new file mode 100644 index 0000000..f3c6c6a --- /dev/null +++ b/test/unit/pixi-v2/display/MovieClip.js @@ -0,0 +1,33 @@ +describe('pixi/display/MovieClip', function () { + 'use strict'; + + var expect = chai.expect; + var MovieClip = PIXI.MovieClip; + var Texture = PIXI.Texture; + + it('Module exists', function () { + expect(MovieClip).to.be.a('function'); + }); + + it('Confirm new instance', function (done) { + var texture = Texture.fromImage('/base/test/textures/SpriteSheet-Explosion.png'); + var obj = new MovieClip([texture]); + + pixi_display_Sprite_confirmNew(obj, done); + + expect(obj).to.be.an.instanceof(MovieClip); + expect(obj).to.respondTo('stop'); + expect(obj).to.respondTo('play'); + expect(obj).to.respondTo('gotoAndStop'); + expect(obj).to.respondTo('gotoAndPlay'); + expect(obj).to.respondTo('updateTransform'); + + expect(obj).to.have.deep.property('textures.length', 1); + expect(obj).to.have.deep.property('textures[0]', texture); + expect(obj).to.have.property('animationSpeed', 1); + expect(obj).to.have.property('loop', true); + expect(obj).to.have.property('onComplete', null); + expect(obj).to.have.property('currentFrame', 0); + expect(obj).to.have.property('playing', false); + }); +}); diff --git a/test/unit/pixi-v2/display/Sprite.js b/test/unit/pixi-v2/display/Sprite.js new file mode 100644 index 0000000..30c8076 --- /dev/null +++ b/test/unit/pixi-v2/display/Sprite.js @@ -0,0 +1,28 @@ +describe('pixi/display/Sprite', function () { + 'use strict'; + + var expect = chai.expect; + var Sprite = PIXI.Sprite; + var Texture = PIXI.Texture; + + it('Module exists', function () { + expect(Sprite).to.be.a('function'); + expect(PIXI).to.have.deep.property('blendModes.NORMAL', 0); + expect(PIXI).to.have.deep.property('blendModes.ADD', 1); + expect(PIXI).to.have.deep.property('blendModes.MULTIPLY', 2); + expect(PIXI).to.have.deep.property('blendModes.SCREEN', 3); + }); + + + it('Members exist', function () { + expect(Sprite).itself.to.respondTo('fromImage'); + expect(Sprite).itself.to.respondTo('fromFrame'); + }); + + it('Confirm new instance', function (done) { + var texture = Texture.fromImage('/base/test/textures/SpriteSheet-Aliens.png'); + var obj = new Sprite(texture); + + pixi_display_Sprite_confirmNew(obj, done); + }); +}); diff --git a/test/unit/pixi-v2/display/Stage.js b/test/unit/pixi-v2/display/Stage.js new file mode 100644 index 0000000..6974c2e --- /dev/null +++ b/test/unit/pixi-v2/display/Stage.js @@ -0,0 +1,49 @@ +describe('pixi/display/Stage', function () { + 'use strict'; + + var expect = chai.expect; + var Stage = PIXI.Stage; + var InteractionManager = PIXI.InteractionManager; + var Rectangle = PIXI.Rectangle; + + it('Module exists', function () { + expect(Stage).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Stage(null, true); + + pixi_display_DisplayObjectContainer_confirmNew(obj); + + expect(obj).to.be.an.instanceof(Stage); + expect(obj).to.respondTo('updateTransform'); + expect(obj).to.respondTo('setBackgroundColor'); + expect(obj).to.respondTo('getMousePosition'); + // FIXME: duplicate member in DisplayObject + pixi_core_Matrix_confirmNewMatrix(obj.worldTransform); + // FIXME: convert arg to bool in constructor + expect(obj).to.have.property('interactive', true); + + expect(obj).to.have.property('interactionManager') + .and.to.be.an.instanceof(InteractionManager) + .and.to.have.property('stage', obj); + + expect(obj).to.have.property('dirty', true); + + expect(obj).to.have.property('stage', obj); + + expect(obj).to.have.property('hitArea') + .and.to.be.an.instanceof(Rectangle); + pixi_core_Rectangle_confirm(obj.hitArea, 0, 0, 100000, 100000); + + expect(obj).to.have.property('backgroundColor', 0x000000); + expect(obj).to.have.deep.property('backgroundColorSplit.length', 3); + expect(obj).to.have.deep.property('backgroundColorSplit[0]', 0); + expect(obj).to.have.deep.property('backgroundColorSplit[1]', 0); + expect(obj).to.have.deep.property('backgroundColorSplit[2]', 0); + expect(obj).to.have.property('backgroundColorString', '#000000'); + + + expect(obj).to.have.property('worldVisible', true); + }); +}); diff --git a/test/unit/pixi-v2/extras/Rope.js b/test/unit/pixi-v2/extras/Rope.js new file mode 100644 index 0000000..05885ac --- /dev/null +++ b/test/unit/pixi-v2/extras/Rope.js @@ -0,0 +1,31 @@ +describe('pixi/extras/Rope', function () { + 'use strict'; + + var expect = chai.expect; + var Rope = PIXI.Rope; + var Texture = PIXI.Texture; + var Point = PIXI.Point; + + it('Module exists', function () { + expect(Rope).to.be.a('function'); + }); + + it('Confirm new instance', function () { + + var texture = Texture.fromImage('/base/test/textures/bunny.png'); + + // TODO-Alvin + // Same as Strip + + // var obj = new Rope(texture, [new Point(), new Point(5, 10), new Point(10, 20)]); + + // pixi_extras_Strip_confirmNew(obj); + + // expect(obj).to.be.an.instanceof(Rope); + // expect(obj).to.respondTo('refresh'); + // expect(obj).to.respondTo('updateTransform'); + // expect(obj).to.respondTo('setTexture'); + + // TODO: Test properties + }); +}); diff --git a/test/unit/pixi-v2/extras/Spine.js b/test/unit/pixi-v2/extras/Spine.js new file mode 100644 index 0000000..0708bc0 --- /dev/null +++ b/test/unit/pixi-v2/extras/Spine.js @@ -0,0 +1,10 @@ +describe('pixi/extras/Spine', function () { + 'use strict'; + + var expect = chai.expect; + var Spine = PIXI.Spine; + + it('Module exists', function () { + expect(Spine).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/extras/Strip.js b/test/unit/pixi-v2/extras/Strip.js new file mode 100644 index 0000000..230af90 --- /dev/null +++ b/test/unit/pixi-v2/extras/Strip.js @@ -0,0 +1,26 @@ +describe('pixi/extras/Strip', function () { + 'use strict'; + + var expect = chai.expect; + var Strip = PIXI.Strip; + var Texture = PIXI.Texture; + + it('Module exists', function () { + expect(Strip).to.be.a('function'); + }); + + it('Confirm new instance', function () { + + + // TODO-Alvin + // We tweaked it to make it pass the tests, but the whole strip class needs + // to be re-coded + + var texture = Texture.fromImage('/base/test/textures/bunny.png'); + + // var obj = new Strip(texture, 20, 10000); + + + // pixi_extras_Strip_confirmNew(obj); + }); +}); diff --git a/test/unit/pixi-v2/extras/TilingSprite.js b/test/unit/pixi-v2/extras/TilingSprite.js new file mode 100644 index 0000000..56aea14 --- /dev/null +++ b/test/unit/pixi-v2/extras/TilingSprite.js @@ -0,0 +1,24 @@ +describe('pixi/extras/TilingSprite', function () { + 'use strict'; + + var expect = chai.expect; + var TilingSprite = PIXI.TilingSprite; + var Texture = PIXI.Texture; + + it('Module exists', function () { + expect(TilingSprite).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var texture = Texture.fromImage('/base/test/textures/bunny.png'); + var obj = new TilingSprite(texture, 6000, 12000); + + pixi_display_DisplayObjectContainer_confirmNew(obj); + + expect(obj).to.be.an.instanceof(TilingSprite); + expect(obj).to.respondTo('setTexture'); + expect(obj).to.respondTo('onTextureUpdate'); + + // TODO: Test properties + }); +}); diff --git a/test/unit/pixi-v2/filters/FilterBlock.js b/test/unit/pixi-v2/filters/FilterBlock.js new file mode 100644 index 0000000..870cec0 --- /dev/null +++ b/test/unit/pixi-v2/filters/FilterBlock.js @@ -0,0 +1,10 @@ +describe('pixi/filters/FilterBlock', function () { + 'use strict'; + + var expect = chai.expect; + var FilterBlock = PIXI.FilterBlock; + + it('Module exists', function () { + expect(FilterBlock).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/AssetLoader.js b/test/unit/pixi-v2/loaders/AssetLoader.js new file mode 100644 index 0000000..a0aa0b5 --- /dev/null +++ b/test/unit/pixi-v2/loaders/AssetLoader.js @@ -0,0 +1,10 @@ +describe('pixi/loaders/AssetLoader', function () { + 'use strict'; + + var expect = chai.expect; + var AssetLoader = PIXI.AssetLoader; + + it('Module exists', function () { + expect(AssetLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/BitmapFontLoader.js b/test/unit/pixi-v2/loaders/BitmapFontLoader.js new file mode 100644 index 0000000..046f018 --- /dev/null +++ b/test/unit/pixi-v2/loaders/BitmapFontLoader.js @@ -0,0 +1,9 @@ +describe('pixi/loaders/BitmapFontLoader', function () { + 'use strict'; + + var expect = chai.expect; + + it('Module exists', function () { + expect(PIXI.BitmapFontLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/ImageLoader.js b/test/unit/pixi-v2/loaders/ImageLoader.js new file mode 100644 index 0000000..8b1f556 --- /dev/null +++ b/test/unit/pixi-v2/loaders/ImageLoader.js @@ -0,0 +1,10 @@ +describe('pixi/loaders/ImageLoader', function () { + 'use strict'; + + var expect = chai.expect; + var ImageLoader = PIXI.ImageLoader; + + it('Module exists', function () { + expect(ImageLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/JsonLoader.js b/test/unit/pixi-v2/loaders/JsonLoader.js new file mode 100644 index 0000000..c577e83 --- /dev/null +++ b/test/unit/pixi-v2/loaders/JsonLoader.js @@ -0,0 +1,10 @@ +describe('pixi/loaders/JsonLoader', function () { + 'use strict'; + + var expect = chai.expect; + var JsonLoader = PIXI.JsonLoader; + + it('Module exists', function () { + expect(JsonLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/SpineLoader.js b/test/unit/pixi-v2/loaders/SpineLoader.js new file mode 100644 index 0000000..fdcc0b8 --- /dev/null +++ b/test/unit/pixi-v2/loaders/SpineLoader.js @@ -0,0 +1,10 @@ +describe('pixi/loaders/SpineLoader', function () { + 'use strict'; + + var expect = chai.expect; + var SpineLoader = PIXI.SpineLoader; + + it('Module exists', function () { + expect(SpineLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/SpriteSheetLoader.js b/test/unit/pixi-v2/loaders/SpriteSheetLoader.js new file mode 100644 index 0000000..57beb27 --- /dev/null +++ b/test/unit/pixi-v2/loaders/SpriteSheetLoader.js @@ -0,0 +1,10 @@ +describe('pixi/loaders/SpriteSheetLoader', function () { + 'use strict'; + + var expect = chai.expect; + var SpriteSheetLoader = PIXI.SpriteSheetLoader; + + it('Module exists', function () { + expect(SpriteSheetLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/primitives/Graphics.js b/test/unit/pixi-v2/primitives/Graphics.js new file mode 100644 index 0000000..f3849eb --- /dev/null +++ b/test/unit/pixi-v2/primitives/Graphics.js @@ -0,0 +1,44 @@ +describe('pixi/primitives/Graphics', function () { + 'use strict'; + + var expect = chai.expect; + var Graphics = PIXI.Graphics; + + it('Module exists', function () { + expect(Graphics).to.be.a('function'); + + expect(Graphics).itself.to.have.property('POLY', 0); + expect(Graphics).itself.to.have.property('RECT', 1); + expect(Graphics).itself.to.have.property('CIRC', 2); + expect(Graphics).itself.to.have.property('ELIP', 3); + expect(Graphics).itself.to.have.property('RREC', 4); + }); + + it('Confirm new instance', function () { + var obj = new Graphics(); + + pixi_display_DisplayObjectContainer_confirmNew(obj); + + expect(obj).to.be.an.instanceof(Graphics); + expect(obj).to.respondTo('lineStyle'); + expect(obj).to.respondTo('lineStyle'); + expect(obj).to.respondTo('moveTo'); + expect(obj).to.respondTo('lineTo'); + expect(obj).to.respondTo('beginFill'); + expect(obj).to.respondTo('endFill'); + expect(obj).to.respondTo('drawRect'); + // expect(obj).to.respondTo('drawRoundedRect'); + expect(obj).to.respondTo('drawCircle'); + expect(obj).to.respondTo('drawEllipse'); + expect(obj).to.respondTo('clear'); + + expect(obj).to.have.property('renderable', true); + expect(obj).to.have.property('fillAlpha', 1); + expect(obj).to.have.property('lineWidth', 0); + expect(obj).to.have.property('width', 0); + expect(obj).to.have.property('height', 0); + expect(obj).to.have.property('lineColor', 0); + expect(obj).to.have.deep.property('graphicsData.length', 0); + // expect(obj).to.have.deep.property('currentPath.points.length', 0); + }); +}); diff --git a/test/unit/pixi-v2/renderers/canvas/CanvasGraphics.js b/test/unit/pixi-v2/renderers/canvas/CanvasGraphics.js new file mode 100644 index 0000000..8f44472 --- /dev/null +++ b/test/unit/pixi-v2/renderers/canvas/CanvasGraphics.js @@ -0,0 +1,15 @@ +describe('renders/canvas/CanvasGraphics', function () { + 'use strict'; + + var expect = chai.expect; + var CanvasGraphics = PIXI.CanvasGraphics; + + it('Module exists', function () { + expect(CanvasGraphics).to.be.a('function'); + }); + + it('Members exist', function () { + expect(CanvasGraphics).itself.to.respondTo('renderGraphics'); + expect(CanvasGraphics).itself.to.respondTo('renderGraphicsMask'); + }); +}); diff --git a/test/unit/pixi-v2/renderers/canvas/CanvasRenderer.js b/test/unit/pixi-v2/renderers/canvas/CanvasRenderer.js new file mode 100644 index 0000000..1646444 --- /dev/null +++ b/test/unit/pixi-v2/renderers/canvas/CanvasRenderer.js @@ -0,0 +1,36 @@ +describe('renderers/canvas/CanvasRenderer', function () { + 'use strict'; + + var expect = chai.expect; + var CanvasRenderer = PIXI.CanvasRenderer; + + it('Module exists', function () { + expect(CanvasRenderer).to.be.a('function'); + }); + + describe('.autoResize', function () { + it('Should automatically resize view if enabled', function () { + var renderer = new CanvasRenderer(200, 200, { + autoResize: true + }); + + expect(renderer.view.style.width).to.equal('200px'); + }); + + it('Should not automatically resize view if disabled', function () { + var renderer = new CanvasRenderer(200, 200, { + autoResize: false + }); + + expect(renderer.view.style.width).to.equal(''); + }); + + it('Should not automatically resize view if not specified', function () { + var renderer = new CanvasRenderer(200, 200, { + resolution: 2 + }); + + expect(renderer.view.style.width).to.equal(''); + }); + }); +}); diff --git a/test/unit/pixi-v2/renderers/webgl/WebGLGraphics.js b/test/unit/pixi-v2/renderers/webgl/WebGLGraphics.js new file mode 100644 index 0000000..5867b28 --- /dev/null +++ b/test/unit/pixi-v2/renderers/webgl/WebGLGraphics.js @@ -0,0 +1,20 @@ +describe('renderers/wegbl/WebGLGraphics', function () { + 'use strict'; + + var expect = chai.expect; + var WebGLGraphics = PIXI.WebGLGraphics; + + it('Module exists', function () { + expect(WebGLGraphics).to.be.a('function'); + }); + + it('Members exist', function () { + expect(WebGLGraphics).itself.to.respondTo('renderGraphics'); + expect(WebGLGraphics).itself.to.respondTo('updateGraphics'); + expect(WebGLGraphics).itself.to.respondTo('buildRectangle'); + expect(WebGLGraphics).itself.to.respondTo('buildRoundedRectangle'); + expect(WebGLGraphics).itself.to.respondTo('buildCircle'); + expect(WebGLGraphics).itself.to.respondTo('buildLine'); + expect(WebGLGraphics).itself.to.respondTo('buildPoly'); + }); +}); diff --git a/test/unit/pixi-v2/renderers/webgl/WebGLRenderer.js b/test/unit/pixi-v2/renderers/webgl/WebGLRenderer.js new file mode 100644 index 0000000..1680a80 --- /dev/null +++ b/test/unit/pixi-v2/renderers/webgl/WebGLRenderer.js @@ -0,0 +1,49 @@ +describe('renderers/webgl/WebGLRenderer', function () { + 'use strict'; + + var expect = chai.expect; + var WebGLRenderer = PIXI.WebGLRenderer; + + it('Module exists', function () { + expect(WebGLRenderer).to.be.a('function'); + }); + + // Skip tests if WebGL is not available (WebGL not supported in Travis CI) + try { + var renderer = new WebGLRenderer(400, 300, {}); + renderer.destroy(); + } catch (error) { + return; + } + + it('Destroy renderer', function () { + var renderer = new WebGLRenderer(400, 300, {}); + renderer.destroy(); + }); + + describe('.autoResize', function () { + it('Should automatically resize view if enabled', function () { + var renderer = new WebGLRenderer(200, 200, { + autoResize: true + }); + + expect(renderer.view.style.width).to.equal('200px'); + }); + + it('Should not automatically resize view if disabled', function () { + var renderer = new WebGLRenderer(200, 200, { + autoResize: false + }); + + expect(renderer.view.style.width).to.equal(''); + }); + + it('Should not automatically resize view if not specified', function () { + var renderer = new WebGLRenderer(200, 200, { + resolution: 2 + }); + + expect(renderer.view.style.width).to.equal(''); + }); + }); +}); diff --git a/test/unit/pixi-v2/renderers/webgl/WebGLShaders.js b/test/unit/pixi-v2/renderers/webgl/WebGLShaders.js new file mode 100644 index 0000000..6e33e4f --- /dev/null +++ b/test/unit/pixi-v2/renderers/webgl/WebGLShaders.js @@ -0,0 +1,13 @@ +describe('renderers/webgl/WebGLShaders', function () { + 'use strict'; + + var expect = chai.expect; + + it('Module members exist', function () { + + expect(PIXI).to.respondTo('CompileVertexShader'); + expect(PIXI).to.respondTo('CompileFragmentShader'); + expect(PIXI).to.respondTo('_CompileShader'); + expect(PIXI).to.respondTo('compileProgram'); + }); +}); diff --git a/test/unit/pixi-v2/renderers/webgl/WebGLSpriteBatch.js b/test/unit/pixi-v2/renderers/webgl/WebGLSpriteBatch.js new file mode 100644 index 0000000..e662b63 --- /dev/null +++ b/test/unit/pixi-v2/renderers/webgl/WebGLSpriteBatch.js @@ -0,0 +1,10 @@ +describe('renderers/webgl/utils/WebGLSpriteBatch', function () { + 'use strict'; + + var expect = chai.expect; + var WebGLSpriteBatch = PIXI.WebGLSpriteBatch; + + it('Module exists', function () { + expect(WebGLSpriteBatch).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/text/BitmapText.js b/test/unit/pixi-v2/text/BitmapText.js new file mode 100644 index 0000000..9388e3d --- /dev/null +++ b/test/unit/pixi-v2/text/BitmapText.js @@ -0,0 +1,10 @@ +describe('pixi/text/BitmapText', function () { + 'use strict'; + + var expect = chai.expect; + var BitmapText = PIXI.BitmapText; + + it('Module exists', function () { + expect(BitmapText).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/text/Text.js b/test/unit/pixi-v2/text/Text.js new file mode 100644 index 0000000..9bc9ac5 --- /dev/null +++ b/test/unit/pixi-v2/text/Text.js @@ -0,0 +1,10 @@ +describe('pixi/text/Text', function () { + 'use strict'; + + var expect = chai.expect; + var Text = PIXI.Text; + + it('Module exists', function () { + expect(Text).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/textures/BaseTexture.js b/test/unit/pixi-v2/textures/BaseTexture.js new file mode 100644 index 0000000..502b724 --- /dev/null +++ b/test/unit/pixi-v2/textures/BaseTexture.js @@ -0,0 +1,11 @@ +describe('pixi/textures/BaseTexture', function () { + 'use strict'; + + var expect = chai.expect; + var BaseTexture = PIXI.BaseTexture; + + it('Module exists', function () { + expect(BaseTexture).to.be.a('function'); + expect(PIXI).to.have.property('BaseTextureCache').and.to.be.an('object'); + }); +}); diff --git a/test/unit/pixi-v2/textures/RenderTexture.js b/test/unit/pixi-v2/textures/RenderTexture.js new file mode 100644 index 0000000..96acdb4 --- /dev/null +++ b/test/unit/pixi-v2/textures/RenderTexture.js @@ -0,0 +1,15 @@ +describe('pixi/textures/RenderTexture', function () { + 'use strict'; + + var expect = chai.expect; + var RenderTexture = PIXI.RenderTexture; + + it('Module exists', function () { + expect(RenderTexture).to.be.a('function'); + }); + + it('Confirm new instance', function (done) { + var texture = new RenderTexture(100, 100, new PIXI.CanvasRenderer()); + pixi_textures_RenderTexture_confirmNew(texture, done); + }); +}); diff --git a/test/unit/pixi-v2/textures/Texture.js b/test/unit/pixi-v2/textures/Texture.js new file mode 100644 index 0000000..090f64d --- /dev/null +++ b/test/unit/pixi-v2/textures/Texture.js @@ -0,0 +1,26 @@ +describe('pixi/textures/Texture', function () { + 'use strict'; + + var expect = chai.expect; + var Texture = PIXI.Texture; + + it('Module exists', function () { + expect(Texture).to.be.a('function'); + expect(PIXI).to.have.property('TextureCache').and.to.be.an('object'); + }); + + it('Members exist', function () { + expect(Texture).itself.to.respondTo('fromImage'); + expect(Texture).itself.to.respondTo('fromFrame'); + expect(Texture).itself.to.respondTo('fromCanvas'); + expect(Texture).itself.to.respondTo('addTextureToCache'); + expect(Texture).itself.to.respondTo('removeTextureFromCache'); + + // expect(Texture).itself.to.have.deep.property('frameUpdates.length', 0); + }); + + it('Confirm new instance', function (done) { + var texture = Texture.fromImage('/base/test/textures/bunny.png'); + pixi_textures_Texture_confirmNew(texture, done); + }); +}); diff --git a/test/unit/pixi-v2/utils/Detector.js b/test/unit/pixi-v2/utils/Detector.js new file mode 100644 index 0000000..4cf6008 --- /dev/null +++ b/test/unit/pixi-v2/utils/Detector.js @@ -0,0 +1,10 @@ +describe('pixi/utils/Detector', function () { + 'use strict'; + + var expect = chai.expect; + var autoDetectRenderer = PIXI.autoDetectRenderer; + + it('Module exists', function () { + expect(autoDetectRenderer).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/utils/EventTarget.js b/test/unit/pixi-v2/utils/EventTarget.js new file mode 100644 index 0000000..1cfc3a4 --- /dev/null +++ b/test/unit/pixi-v2/utils/EventTarget.js @@ -0,0 +1,361 @@ +describe('pixi/utils/EventTarget', function () { + 'use strict'; + + var expect = chai.expect; + + var Clazz, PClazz, obj, pobj, obj2; + beforeEach(function () { + Clazz = function () {}; + PClazz = function () {}; + + PIXI.EventTarget.mixin(Clazz.prototype); + PIXI.EventTarget.mixin(PClazz.prototype); + + obj = new Clazz(); + obj2 = new Clazz(); + pobj = new PClazz(); + + obj.parent = pobj; + obj2.parent = obj; + }); + + it('Module exists', function () { + expect(PIXI.EventTarget).to.be.an('object'); + }); + + it('Confirm new instance', function () { + pixi_utils_EventTarget_confirm(obj); + }); + + it('simple on/emit case works', function () { + var myData = {}; + + obj.on('myevent', function (event) { + pixi_utils_EventTarget_Event_confirm(event, obj, myData); + }); + + obj.emit('myevent', myData); + }); + + it('simple once case works', function () { + var called = 0; + + obj.once('myevent', function() { called++; }); + + obj.emit('myevent'); + obj.emit('myevent'); + obj.emit('myevent'); + obj.emit('myevent'); + obj.emit('myevent'); + + expect(called).to.equal(1); + }); + + it('simple off case works', function (done) { + function onMyEvent() { + done(new Error('Event listener should not have been called')); + } + + obj.on('myevent', onMyEvent); + obj.off('myevent', onMyEvent); + obj.emit('myevent'); + + done(); + }); + + it('simple propagation case works', function (done) { + var myData = {}; + + pobj.on('myevent', function () { + done(); + }); + + obj.emit('myevent'); + }); + + it('simple stopPropagation case works', function (done) { + var myData = {}; + + pobj.on('myevent', function () { + done(new Error('Event listener should not have been called on the parent element')); + }); + + obj.on('myevent', function (evt) { + evt.stopPropagation(); + }); + + obj.emit('myevent'); + + done(); + }); + + it('simple stopImmediatePropagation case works', function (done) { + var myData = {}; + + pobj.on('myevent', function () { + done(new Error('Event listener should not have been called on the parent')); + }); + + obj.on('myevent', function (evt) { + evt.stopImmediatePropagation(); + }); + + obj.on('myevent', function () { + done(new Error('Event listener should not have been called on the second')); + }); + + obj.emit('myevent'); + + done(); + }); + + it('multiple dispatches work properly', function () { + var called = 0; + + function onMyEvent() { + called++; + } + + obj.on('myevent', onMyEvent); + obj.emit('myevent'); + obj.emit('myevent'); + obj.emit('myevent'); + obj.emit('myevent'); + + expect(called).to.equal(4); + }); + + it('multiple events work properly', function () { + var called = 0; + + function onMyEvent() { + called++; + } + + obj.on('myevent1', onMyEvent); + obj.on('myevent2', onMyEvent); + obj.on('myevent3', onMyEvent); + obj.emit('myevent1'); + obj.emit('myevent2'); + obj.emit('myevent3'); + + expect(called).to.equal(3); + }); + + it('multiple events one removed works properly', function () { + var called = 0; + + function onMyEvent() { + called++; + } + + obj.on('myevent1', onMyEvent); + obj.on('myevent2', onMyEvent); + obj.on('myevent3', onMyEvent); + + obj.emit('myevent1'); + obj.emit('myevent2'); + obj.emit('myevent3'); + + obj.off('myevent2', onMyEvent); + + obj.emit('myevent1'); + obj.emit('myevent2'); + obj.emit('myevent3'); + + expect(called).to.equal(5); + }); + + it('multiple handlers for one event with some removed', function () { + var called = 0; + + var onMyEvent = function () { + called++; + }, + onMyEvent2 = function () { + called++; + }; + + // add 2 handlers and confirm they both get called + obj.on('myevent', onMyEvent); + obj.on('myevent', onMyEvent); + obj.on('myevent', onMyEvent2); + obj.on('myevent', onMyEvent2); + + obj.emit('myevent'); + + expect(called).to.equal(4); + + // remove one of the handlers, emit again, then ensure 1 more call is made + obj.off('myevent', onMyEvent); + + obj.emit('myevent'); + + expect(called).to.equal(6); + }); + + it('calls to off without a handler do nothing', function () { + var called = 0; + + var onMyEvent = function () { + called++; + }; + + obj.on('myevent', onMyEvent); + obj.on('myevent', onMyEvent); + + obj.emit('myevent'); + + expect(called).to.equal(2); + + obj.off('myevent'); + + obj.emit('myevent'); + + expect(called).to.equal(4); + + obj.off('myevent', onMyEvent); + + obj.emit('myevent'); + + expect(called).to.equal(4); + }); + + it('handles multiple instances with the same prototype', function () { + var called = 0; + + function onMyEvent(e) { + called++; + } + + obj.on('myevent1', onMyEvent); + obj.on('myevent2', onMyEvent); + + obj2.istwo = true; + obj2.on('myevent1', onMyEvent); + obj2.on('myevent2', onMyEvent); + + obj.emit('myevent1'); + obj.emit('myevent2'); + obj2.emit('myevent1'); + obj2.emit('myevent2'); + + //we emit 4 times, but since obj2 is a child of obj the event should bubble + //up to obj and show up there as well. So the obj2.emit() calls each increment + //the counter twice. + expect(called).to.equal(6); + }); + + it('is backwards compatible with older .dispatchEvent({})', function () { + var called = 0, + data = { + some: 'thing', + hello: true + }; + + function onMyEvent(event) { + pixi_utils_EventTarget_Event_confirm(event, obj, data); + + called++; + } + + obj.on('myevent1', onMyEvent); + obj.on('myevent2', onMyEvent); + obj.on('myevent3', onMyEvent); + + data.type = 'myevent1'; + obj.emit(data); + + data.type = 'myevent2'; + obj.emit(data); + + data.type = 'myevent3'; + obj.emit(data); + + obj.off('myevent2', onMyEvent); + + data.type = 'myevent1'; + obj.emit(data); + + data.type = 'myevent2'; + obj.emit(data); + + data.type = 'myevent3'; + obj.emit(data); + + expect(called).to.equal(5); + }); + + it('is backwards compatible with older .call(this)', function () { + var Fn = function() { + PIXI.EventTarget.call(this); + }, + o = new Fn(); + + pixi_utils_EventTarget_confirm(o); + }); + + it('is backwards compatible with older .addEventListener("")', function () { + var called = 0, + data = { + some: 'thing', + hello: true + }; + + function onMyEvent(event) { + pixi_utils_EventTarget_Event_confirm(event, obj, data); + + called++; + } + + obj.addEventListener('myevent1', onMyEvent); + obj.addEventListener('myevent2', onMyEvent); + obj.addEventListener('myevent3', onMyEvent); + + data.type = 'myevent1'; + obj.emit(data); + + data.type = 'myevent2'; + obj.emit(data); + + data.type = 'myevent3'; + obj.emit(data); + + obj.off('myevent2', onMyEvent); + + data.type = 'myevent1'; + obj.emit(data); + + data.type = 'myevent2'; + obj.emit(data); + + data.type = 'myevent3'; + obj.emit(data); + + expect(called).to.equal(5); + }); + + it('event remove during emit call properly', function () { + var called = 0; + + function cb1() { + called++; + obj.off('myevent', cb1); + } + function cb2() { + called++; + obj.off('myevent', cb2); + } + function cb3() { + called++; + obj.off('myevent', cb3); + } + + obj.on('myevent', cb1); + obj.on('myevent', cb2); + obj.on('myevent', cb3); + obj.emit('myevent', ''); + + expect(called).to.equal(3); + }); +}); diff --git a/test/unit/pixi-v2/utils/Polyk.js b/test/unit/pixi-v2/utils/Polyk.js new file mode 100644 index 0000000..dfc7128 --- /dev/null +++ b/test/unit/pixi-v2/utils/Polyk.js @@ -0,0 +1,14 @@ +describe('pixi/utils/Polyk', function () { + 'use strict'; + + var expect = chai.expect; + var PolyK = PIXI.PolyK; + + it('Module exists', function () { + expect(PolyK).to.be.an('object'); + }); + + it('Members exist', function () { + expect(PolyK).to.respondTo('Triangulate'); + }); +}); diff --git a/test/unit/pixi-v2/utils/Utils.js b/test/unit/pixi-v2/utils/Utils.js new file mode 100644 index 0000000..c97b3c6 --- /dev/null +++ b/test/unit/pixi-v2/utils/Utils.js @@ -0,0 +1,17 @@ +describe('Utils', function () { + 'use strict'; + + var expect = chai.expect; + + it('requestAnimationFrame exists', function () { + expect(global).to.respondTo('requestAnimationFrame'); + }); + + it('cancelAnimationFrame exists', function () { + expect(global).to.respondTo('cancelAnimationFrame'); + }); + + it('requestAnimFrame exists', function () { + expect(global).to.respondTo('requestAnimFrame'); + }); +}); diff --git a/test/unit/pixi/InteractionManager.js b/test/unit/pixi/InteractionManager.js deleted file mode 100644 index ed3001f..0000000 --- a/test/unit/pixi/InteractionManager.js +++ /dev/null @@ -1,10 +0,0 @@ -describe('pixi/InteractionManager', function () { - 'use strict'; - - var expect = chai.expect; - var InteractionManager = PIXI.InteractionManager; - - it('Module exists', function () { - expect(InteractionManager).to.be.a('function'); - }); -}); diff --git a/test/unit/pixi/Pixi.js b/test/unit/pixi/Pixi.js deleted file mode 100644 index 27debc1..0000000 --- a/test/unit/pixi/Pixi.js +++ /dev/null @@ -1,9 +0,0 @@ -describe('pixi/Pixi', function () { - 'use strict'; - - var expect = chai.expect; - - it('Module exists', function () { - expect(global).to.have.property('PIXI').and.to.be.an('object'); - }); -}); diff --git a/test/unit/pixi/core/Circle.js b/test/unit/pixi/core/Circle.js deleted file mode 100644 index fbcfa17..0000000 --- a/test/unit/pixi/core/Circle.js +++ /dev/null @@ -1,21 +0,0 @@ -describe('pixi/core/Circle', function () { - 'use strict'; - - var expect = chai.expect; - var Circle = PIXI.Circle; - - it('Module exists', function () { - expect(Circle).to.be.a('function'); - }); - - it('Confirm new instance', function () { - var obj = new Circle(); - pixi_core_Circle_confirmNewCircle(obj); - }); - - it("getBounds should return Rectangle that bounds the circle", function() { - var obj = new Circle(100, 250, 50); - var bounds = obj.getBounds(); - pixi_core_Circle_isBoundedByRectangle(obj, bounds); - }); -}); diff --git a/test/unit/pixi/core/Ellipse.js b/test/unit/pixi/core/Ellipse.js deleted file mode 100644 index 026b56f..0000000 --- a/test/unit/pixi/core/Ellipse.js +++ /dev/null @@ -1,24 +0,0 @@ -describe('pixi/core/Ellipse', function () { - 'use strict'; - - var expect = chai.expect; - var Ellipse = PIXI.Ellipse; - - it('Module exists', function () { - expect(Ellipse).to.be.a('function'); - }); - - it('Confirm new instance', function () { - var obj = new Ellipse(); - - expect(obj).to.be.an.instanceof(Ellipse); - expect(obj).to.respondTo('clone'); - expect(obj).to.respondTo('contains'); - expect(obj).to.respondTo('getBounds'); - - expect(obj).to.have.property('x', 0); - expect(obj).to.have.property('y', 0); - expect(obj).to.have.property('width', 0); - expect(obj).to.have.property('height', 0); - }); -}); diff --git a/test/unit/pixi/core/Matrix.js b/test/unit/pixi/core/Matrix.js deleted file mode 100644 index da75e2e..0000000 --- a/test/unit/pixi/core/Matrix.js +++ /dev/null @@ -1,14 +0,0 @@ -describe('pixi/core/Matrix', function () { - 'use strict'; - - var expect = chai.expect; - - it('Matrix exists', function () { - expect(PIXI.Matrix).to.be.an('function'); - }); - - it('Confirm new Matrix', function () { - var matrix = new PIXI.Matrix(); - pixi_core_Matrix_confirmNewMatrix(matrix); - }); -}); diff --git a/test/unit/pixi/core/Point.js b/test/unit/pixi/core/Point.js deleted file mode 100644 index c4d5163..0000000 --- a/test/unit/pixi/core/Point.js +++ /dev/null @@ -1,15 +0,0 @@ -describe('pixi/core/Point', function () { - 'use strict'; - - var expect = chai.expect; - var Point = PIXI.Point; - - it('Module exists', function () { - expect(Point).to.be.a('function'); - }); - - it('Confirm new instance', function () { - var obj = new Point(); - pixi_core_Point_confirm(obj, 0, 0); - }); -}); diff --git a/test/unit/pixi/core/Polygon.js b/test/unit/pixi/core/Polygon.js deleted file mode 100644 index dc8c918..0000000 --- a/test/unit/pixi/core/Polygon.js +++ /dev/null @@ -1,20 +0,0 @@ -describe('pixi/core/Polygon', function () { - 'use strict'; - - var expect = chai.expect; - var Polygon = PIXI.Polygon; - - it('Module exists', function () { - expect(Polygon).to.be.a('function'); - }); - - it('Confirm new instance', function () { - var obj = new Polygon(); - - expect(obj).to.be.an.instanceof(Polygon); - expect(obj).to.respondTo('clone'); - expect(obj).to.respondTo('contains'); - - expect(obj).to.have.deep.property('points.length', 0); - }); -}); diff --git a/test/unit/pixi/core/Rectangle.js b/test/unit/pixi/core/Rectangle.js deleted file mode 100644 index d43316e..0000000 --- a/test/unit/pixi/core/Rectangle.js +++ /dev/null @@ -1,15 +0,0 @@ -describe('pixi/core/Rectangle', function () { - 'use strict'; - - var expect = chai.expect; - var Rectangle = PIXI.Rectangle; - - it('Module exists', function () { - expect(Rectangle).to.be.a('function'); - }); - - it('Confirm new instance', function () { - var rect = new Rectangle(); - pixi_core_Rectangle_confirm(rect, 0, 0, 0, 0); - }); -}); diff --git a/test/unit/pixi/display/DisplayObject.js b/test/unit/pixi/display/DisplayObject.js deleted file mode 100644 index 044acf8..0000000 --- a/test/unit/pixi/display/DisplayObject.js +++ /dev/null @@ -1,21 +0,0 @@ -describe('pixi/display/DisplayObject', function () { - 'use strict'; - - var expect = chai.expect; - var DisplayObject = PIXI.DisplayObject; - - it('Module exists', function () { - expect(DisplayObject).to.be.a('function'); - // expect(PIXI).to.have.property('visibleCount', 0); - }); - - it('Confirm new instance', function () { - var obj = new DisplayObject(); - - pixi_display_DisplayObject_confirmNew(obj); - expect(obj).to.have.property('hitArea', null); - expect(obj).to.have.property('interactive', false); - expect(obj).to.have.property('renderable', false); - expect(obj).to.have.property('stage', null); - }); -}); diff --git a/test/unit/pixi/display/DisplayObjectContainer.js b/test/unit/pixi/display/DisplayObjectContainer.js deleted file mode 100644 index 15a3376..0000000 --- a/test/unit/pixi/display/DisplayObjectContainer.js +++ /dev/null @@ -1,67 +0,0 @@ -describe('pixi/display/DisplayObjectContainer', function () { - 'use strict'; - - var expect = chai.expect; - var DisplayObjectContainer = PIXI.DisplayObjectContainer; - - it('Module exists', function () { - expect(DisplayObjectContainer).to.be.a('function'); - }); - - it('Confirm new instance', function () { - var obj = new DisplayObjectContainer(); - - pixi_display_DisplayObjectContainer_confirmNew(obj); - expect(obj).to.have.property('hitArea', null); - expect(obj).to.have.property('interactive', false); - expect(obj).to.have.property('renderable', false); - expect(obj).to.have.property('stage', null); - }); - - it('Gets child index', function() { - var container = new PIXI.DisplayObjectContainer(); - var children = []; - for (var i = 0; i < 10; i++) { - var child = new PIXI.DisplayObject(); - children.push(child); - container.addChild(child); - } - - for (i = 0; i < children.length; i++) { - expect(i).to.eql(container.getChildIndex(children[i])); - } - }); - - it('throws error when trying to get index of not a child', function() { - var container = new PIXI.DisplayObjectContainer(); - var child = new PIXI.DisplayObject(); - - expect(function() { container.getChildIndex(child); }).to.throw(); - }); - - it('Sets child index', function() { - var container = new PIXI.DisplayObjectContainer(); - var children = []; - - for (var i = 0; i < 10; i++) { - var child = new PIXI.DisplayObject(); - children.push(child); - container.addChild(child); - } - children.reverse(); - - for (i = 0; i < children.length; i++) { - container.setChildIndex(children[i], i); - expect(i).to.eql(container.getChildIndex(children[i])); - } - }); - - it('throws error when trying to set incorect index', function() { - var container = new PIXI.DisplayObjectContainer(); - var child = new PIXI.DisplayObject(); - container.addChild(child); - - expect(function() { container.setChildIndex(child, -1); }).to.throw(); - expect(function() { container.setChildIndex(child, 1); }).to.throw(); - }); -}); diff --git a/test/unit/pixi/display/MovieClip.js b/test/unit/pixi/display/MovieClip.js deleted file mode 100644 index f3c6c6a..0000000 --- a/test/unit/pixi/display/MovieClip.js +++ /dev/null @@ -1,33 +0,0 @@ -describe('pixi/display/MovieClip', function () { - 'use strict'; - - var expect = chai.expect; - var MovieClip = PIXI.MovieClip; - var Texture = PIXI.Texture; - - it('Module exists', function () { - expect(MovieClip).to.be.a('function'); - }); - - it('Confirm new instance', function (done) { - var texture = Texture.fromImage('/base/test/textures/SpriteSheet-Explosion.png'); - var obj = new MovieClip([texture]); - - pixi_display_Sprite_confirmNew(obj, done); - - expect(obj).to.be.an.instanceof(MovieClip); - expect(obj).to.respondTo('stop'); - expect(obj).to.respondTo('play'); - expect(obj).to.respondTo('gotoAndStop'); - expect(obj).to.respondTo('gotoAndPlay'); - expect(obj).to.respondTo('updateTransform'); - - expect(obj).to.have.deep.property('textures.length', 1); - expect(obj).to.have.deep.property('textures[0]', texture); - expect(obj).to.have.property('animationSpeed', 1); - expect(obj).to.have.property('loop', true); - expect(obj).to.have.property('onComplete', null); - expect(obj).to.have.property('currentFrame', 0); - expect(obj).to.have.property('playing', false); - }); -}); diff --git a/test/unit/pixi/display/Sprite.js b/test/unit/pixi/display/Sprite.js deleted file mode 100644 index 30c8076..0000000 --- a/test/unit/pixi/display/Sprite.js +++ /dev/null @@ -1,28 +0,0 @@ -describe('pixi/display/Sprite', function () { - 'use strict'; - - var expect = chai.expect; - var Sprite = PIXI.Sprite; - var Texture = PIXI.Texture; - - it('Module exists', function () { - expect(Sprite).to.be.a('function'); - expect(PIXI).to.have.deep.property('blendModes.NORMAL', 0); - expect(PIXI).to.have.deep.property('blendModes.ADD', 1); - expect(PIXI).to.have.deep.property('blendModes.MULTIPLY', 2); - expect(PIXI).to.have.deep.property('blendModes.SCREEN', 3); - }); - - - it('Members exist', function () { - expect(Sprite).itself.to.respondTo('fromImage'); - expect(Sprite).itself.to.respondTo('fromFrame'); - }); - - it('Confirm new instance', function (done) { - var texture = Texture.fromImage('/base/test/textures/SpriteSheet-Aliens.png'); - var obj = new Sprite(texture); - - pixi_display_Sprite_confirmNew(obj, done); - }); -}); diff --git a/test/unit/pixi/display/Stage.js b/test/unit/pixi/display/Stage.js deleted file mode 100644 index 6974c2e..0000000 --- a/test/unit/pixi/display/Stage.js +++ /dev/null @@ -1,49 +0,0 @@ -describe('pixi/display/Stage', function () { - 'use strict'; - - var expect = chai.expect; - var Stage = PIXI.Stage; - var InteractionManager = PIXI.InteractionManager; - var Rectangle = PIXI.Rectangle; - - it('Module exists', function () { - expect(Stage).to.be.a('function'); - }); - - it('Confirm new instance', function () { - var obj = new Stage(null, true); - - pixi_display_DisplayObjectContainer_confirmNew(obj); - - expect(obj).to.be.an.instanceof(Stage); - expect(obj).to.respondTo('updateTransform'); - expect(obj).to.respondTo('setBackgroundColor'); - expect(obj).to.respondTo('getMousePosition'); - // FIXME: duplicate member in DisplayObject - pixi_core_Matrix_confirmNewMatrix(obj.worldTransform); - // FIXME: convert arg to bool in constructor - expect(obj).to.have.property('interactive', true); - - expect(obj).to.have.property('interactionManager') - .and.to.be.an.instanceof(InteractionManager) - .and.to.have.property('stage', obj); - - expect(obj).to.have.property('dirty', true); - - expect(obj).to.have.property('stage', obj); - - expect(obj).to.have.property('hitArea') - .and.to.be.an.instanceof(Rectangle); - pixi_core_Rectangle_confirm(obj.hitArea, 0, 0, 100000, 100000); - - expect(obj).to.have.property('backgroundColor', 0x000000); - expect(obj).to.have.deep.property('backgroundColorSplit.length', 3); - expect(obj).to.have.deep.property('backgroundColorSplit[0]', 0); - expect(obj).to.have.deep.property('backgroundColorSplit[1]', 0); - expect(obj).to.have.deep.property('backgroundColorSplit[2]', 0); - expect(obj).to.have.property('backgroundColorString', '#000000'); - - - expect(obj).to.have.property('worldVisible', true); - }); -}); diff --git a/test/unit/pixi/extras/Rope.js b/test/unit/pixi/extras/Rope.js deleted file mode 100644 index 05885ac..0000000 --- a/test/unit/pixi/extras/Rope.js +++ /dev/null @@ -1,31 +0,0 @@ -describe('pixi/extras/Rope', function () { - 'use strict'; - - var expect = chai.expect; - var Rope = PIXI.Rope; - var Texture = PIXI.Texture; - var Point = PIXI.Point; - - it('Module exists', function () { - expect(Rope).to.be.a('function'); - }); - - it('Confirm new instance', function () { - - var texture = Texture.fromImage('/base/test/textures/bunny.png'); - - // TODO-Alvin - // Same as Strip - - // var obj = new Rope(texture, [new Point(), new Point(5, 10), new Point(10, 20)]); - - // pixi_extras_Strip_confirmNew(obj); - - // expect(obj).to.be.an.instanceof(Rope); - // expect(obj).to.respondTo('refresh'); - // expect(obj).to.respondTo('updateTransform'); - // expect(obj).to.respondTo('setTexture'); - - // TODO: Test properties - }); -}); diff --git a/test/unit/pixi/extras/Spine.js b/test/unit/pixi/extras/Spine.js deleted file mode 100644 index 0708bc0..0000000 --- a/test/unit/pixi/extras/Spine.js +++ /dev/null @@ -1,10 +0,0 @@ -describe('pixi/extras/Spine', function () { - 'use strict'; - - var expect = chai.expect; - var Spine = PIXI.Spine; - - it('Module exists', function () { - expect(Spine).to.be.a('function'); - }); -}); diff --git a/test/unit/pixi/extras/Strip.js b/test/unit/pixi/extras/Strip.js deleted file mode 100644 index 230af90..0000000 --- a/test/unit/pixi/extras/Strip.js +++ /dev/null @@ -1,26 +0,0 @@ -describe('pixi/extras/Strip', function () { - 'use strict'; - - var expect = chai.expect; - var Strip = PIXI.Strip; - var Texture = PIXI.Texture; - - it('Module exists', function () { - expect(Strip).to.be.a('function'); - }); - - it('Confirm new instance', function () { - - - // TODO-Alvin - // We tweaked it to make it pass the tests, but the whole strip class needs - // to be re-coded - - var texture = Texture.fromImage('/base/test/textures/bunny.png'); - - // var obj = new Strip(texture, 20, 10000); - - - // pixi_extras_Strip_confirmNew(obj); - }); -}); diff --git a/test/unit/pixi/extras/TilingSprite.js b/test/unit/pixi/extras/TilingSprite.js deleted file mode 100644 index 56aea14..0000000 --- a/test/unit/pixi/extras/TilingSprite.js +++ /dev/null @@ -1,24 +0,0 @@ -describe('pixi/extras/TilingSprite', function () { - 'use strict'; - - var expect = chai.expect; - var TilingSprite = PIXI.TilingSprite; - var Texture = PIXI.Texture; - - it('Module exists', function () { - expect(TilingSprite).to.be.a('function'); - }); - - it('Confirm new instance', function () { - var texture = Texture.fromImage('/base/test/textures/bunny.png'); - var obj = new TilingSprite(texture, 6000, 12000); - - pixi_display_DisplayObjectContainer_confirmNew(obj); - - expect(obj).to.be.an.instanceof(TilingSprite); - expect(obj).to.respondTo('setTexture'); - expect(obj).to.respondTo('onTextureUpdate'); - - // TODO: Test properties - }); -}); diff --git a/test/unit/pixi/filters/FilterBlock.js b/test/unit/pixi/filters/FilterBlock.js deleted file mode 100644 index 870cec0..0000000 --- a/test/unit/pixi/filters/FilterBlock.js +++ /dev/null @@ -1,10 +0,0 @@ -describe('pixi/filters/FilterBlock', function () { - 'use strict'; - - var expect = chai.expect; - var FilterBlock = PIXI.FilterBlock; - - it('Module exists', function () { - expect(FilterBlock).to.be.a('function'); - }); -}); diff --git a/test/unit/pixi/loaders/AssetLoader.js b/test/unit/pixi/loaders/AssetLoader.js deleted file mode 100644 index a0aa0b5..0000000 --- a/test/unit/pixi/loaders/AssetLoader.js +++ /dev/null @@ -1,10 +0,0 @@ -describe('pixi/loaders/AssetLoader', function () { - 'use strict'; - - var expect = chai.expect; - var AssetLoader = PIXI.AssetLoader; - - it('Module exists', function () { - expect(AssetLoader).to.be.a('function'); - }); -}); diff --git a/test/unit/pixi/loaders/BitmapFontLoader.js b/test/unit/pixi/loaders/BitmapFontLoader.js deleted file mode 100644 index 046f018..0000000 --- a/test/unit/pixi/loaders/BitmapFontLoader.js +++ /dev/null @@ -1,9 +0,0 @@ -describe('pixi/loaders/BitmapFontLoader', function () { - 'use strict'; - - var expect = chai.expect; - - it('Module exists', function () { - expect(PIXI.BitmapFontLoader).to.be.a('function'); - }); -}); diff --git a/test/unit/pixi/loaders/ImageLoader.js b/test/unit/pixi/loaders/ImageLoader.js deleted file mode 100644 index 8b1f556..0000000 --- a/test/unit/pixi/loaders/ImageLoader.js +++ /dev/null @@ -1,10 +0,0 @@ -describe('pixi/loaders/ImageLoader', function () { - 'use strict'; - - var expect = chai.expect; - var ImageLoader = PIXI.ImageLoader; - - it('Module exists', function () { - expect(ImageLoader).to.be.a('function'); - }); -}); diff --git a/test/unit/pixi/loaders/JsonLoader.js b/test/unit/pixi/loaders/JsonLoader.js deleted file mode 100644 index c577e83..0000000 --- a/test/unit/pixi/loaders/JsonLoader.js +++ /dev/null @@ -1,10 +0,0 @@ -describe('pixi/loaders/JsonLoader', function () { - 'use strict'; - - var expect = chai.expect; - var JsonLoader = PIXI.JsonLoader; - - it('Module exists', function () { - expect(JsonLoader).to.be.a('function'); - }); -}); diff --git a/test/unit/pixi/loaders/SpineLoader.js b/test/unit/pixi/loaders/SpineLoader.js deleted file mode 100644 index fdcc0b8..0000000 --- a/test/unit/pixi/loaders/SpineLoader.js +++ /dev/null @@ -1,10 +0,0 @@ -describe('pixi/loaders/SpineLoader', function () { - 'use strict'; - - var expect = chai.expect; - var SpineLoader = PIXI.SpineLoader; - - it('Module exists', function () { - expect(SpineLoader).to.be.a('function'); - }); -}); diff --git a/test/unit/pixi/loaders/SpriteSheetLoader.js b/test/unit/pixi/loaders/SpriteSheetLoader.js deleted file mode 100644 index 57beb27..0000000 --- a/test/unit/pixi/loaders/SpriteSheetLoader.js +++ /dev/null @@ -1,10 +0,0 @@ -describe('pixi/loaders/SpriteSheetLoader', function () { - 'use strict'; - - var expect = chai.expect; - var SpriteSheetLoader = PIXI.SpriteSheetLoader; - - it('Module exists', function () { - expect(SpriteSheetLoader).to.be.a('function'); - }); -}); diff --git a/test/unit/pixi/primitives/Graphics.js b/test/unit/pixi/primitives/Graphics.js deleted file mode 100644 index f3849eb..0000000 --- a/test/unit/pixi/primitives/Graphics.js +++ /dev/null @@ -1,44 +0,0 @@ -describe('pixi/primitives/Graphics', function () { - 'use strict'; - - var expect = chai.expect; - var Graphics = PIXI.Graphics; - - it('Module exists', function () { - expect(Graphics).to.be.a('function'); - - expect(Graphics).itself.to.have.property('POLY', 0); - expect(Graphics).itself.to.have.property('RECT', 1); - expect(Graphics).itself.to.have.property('CIRC', 2); - expect(Graphics).itself.to.have.property('ELIP', 3); - expect(Graphics).itself.to.have.property('RREC', 4); - }); - - it('Confirm new instance', function () { - var obj = new Graphics(); - - pixi_display_DisplayObjectContainer_confirmNew(obj); - - expect(obj).to.be.an.instanceof(Graphics); - expect(obj).to.respondTo('lineStyle'); - expect(obj).to.respondTo('lineStyle'); - expect(obj).to.respondTo('moveTo'); - expect(obj).to.respondTo('lineTo'); - expect(obj).to.respondTo('beginFill'); - expect(obj).to.respondTo('endFill'); - expect(obj).to.respondTo('drawRect'); - // expect(obj).to.respondTo('drawRoundedRect'); - expect(obj).to.respondTo('drawCircle'); - expect(obj).to.respondTo('drawEllipse'); - expect(obj).to.respondTo('clear'); - - expect(obj).to.have.property('renderable', true); - expect(obj).to.have.property('fillAlpha', 1); - expect(obj).to.have.property('lineWidth', 0); - expect(obj).to.have.property('width', 0); - expect(obj).to.have.property('height', 0); - expect(obj).to.have.property('lineColor', 0); - expect(obj).to.have.deep.property('graphicsData.length', 0); - // expect(obj).to.have.deep.property('currentPath.points.length', 0); - }); -}); diff --git a/test/unit/pixi/renderers/canvas/CanvasGraphics.js b/test/unit/pixi/renderers/canvas/CanvasGraphics.js deleted file mode 100644 index 8f44472..0000000 --- a/test/unit/pixi/renderers/canvas/CanvasGraphics.js +++ /dev/null @@ -1,15 +0,0 @@ -describe('renders/canvas/CanvasGraphics', function () { - 'use strict'; - - var expect = chai.expect; - var CanvasGraphics = PIXI.CanvasGraphics; - - it('Module exists', function () { - expect(CanvasGraphics).to.be.a('function'); - }); - - it('Members exist', function () { - expect(CanvasGraphics).itself.to.respondTo('renderGraphics'); - expect(CanvasGraphics).itself.to.respondTo('renderGraphicsMask'); - }); -}); diff --git a/test/unit/pixi/renderers/canvas/CanvasRenderer.js b/test/unit/pixi/renderers/canvas/CanvasRenderer.js deleted file mode 100644 index 1646444..0000000 --- a/test/unit/pixi/renderers/canvas/CanvasRenderer.js +++ /dev/null @@ -1,36 +0,0 @@ -describe('renderers/canvas/CanvasRenderer', function () { - 'use strict'; - - var expect = chai.expect; - var CanvasRenderer = PIXI.CanvasRenderer; - - it('Module exists', function () { - expect(CanvasRenderer).to.be.a('function'); - }); - - describe('.autoResize', function () { - it('Should automatically resize view if enabled', function () { - var renderer = new CanvasRenderer(200, 200, { - autoResize: true - }); - - expect(renderer.view.style.width).to.equal('200px'); - }); - - it('Should not automatically resize view if disabled', function () { - var renderer = new CanvasRenderer(200, 200, { - autoResize: false - }); - - expect(renderer.view.style.width).to.equal(''); - }); - - it('Should not automatically resize view if not specified', function () { - var renderer = new CanvasRenderer(200, 200, { - resolution: 2 - }); - - expect(renderer.view.style.width).to.equal(''); - }); - }); -}); diff --git a/test/unit/pixi/renderers/webgl/WebGLGraphics.js b/test/unit/pixi/renderers/webgl/WebGLGraphics.js deleted file mode 100644 index 5867b28..0000000 --- a/test/unit/pixi/renderers/webgl/WebGLGraphics.js +++ /dev/null @@ -1,20 +0,0 @@ -describe('renderers/wegbl/WebGLGraphics', function () { - 'use strict'; - - var expect = chai.expect; - var WebGLGraphics = PIXI.WebGLGraphics; - - it('Module exists', function () { - expect(WebGLGraphics).to.be.a('function'); - }); - - it('Members exist', function () { - expect(WebGLGraphics).itself.to.respondTo('renderGraphics'); - expect(WebGLGraphics).itself.to.respondTo('updateGraphics'); - expect(WebGLGraphics).itself.to.respondTo('buildRectangle'); - expect(WebGLGraphics).itself.to.respondTo('buildRoundedRectangle'); - expect(WebGLGraphics).itself.to.respondTo('buildCircle'); - expect(WebGLGraphics).itself.to.respondTo('buildLine'); - expect(WebGLGraphics).itself.to.respondTo('buildPoly'); - }); -}); diff --git a/test/unit/pixi/renderers/webgl/WebGLRenderer.js b/test/unit/pixi/renderers/webgl/WebGLRenderer.js deleted file mode 100644 index 1680a80..0000000 --- a/test/unit/pixi/renderers/webgl/WebGLRenderer.js +++ /dev/null @@ -1,49 +0,0 @@ -describe('renderers/webgl/WebGLRenderer', function () { - 'use strict'; - - var expect = chai.expect; - var WebGLRenderer = PIXI.WebGLRenderer; - - it('Module exists', function () { - expect(WebGLRenderer).to.be.a('function'); - }); - - // Skip tests if WebGL is not available (WebGL not supported in Travis CI) - try { - var renderer = new WebGLRenderer(400, 300, {}); - renderer.destroy(); - } catch (error) { - return; - } - - it('Destroy renderer', function () { - var renderer = new WebGLRenderer(400, 300, {}); - renderer.destroy(); - }); - - describe('.autoResize', function () { - it('Should automatically resize view if enabled', function () { - var renderer = new WebGLRenderer(200, 200, { - autoResize: true - }); - - expect(renderer.view.style.width).to.equal('200px'); - }); - - it('Should not automatically resize view if disabled', function () { - var renderer = new WebGLRenderer(200, 200, { - autoResize: false - }); - - expect(renderer.view.style.width).to.equal(''); - }); - - it('Should not automatically resize view if not specified', function () { - var renderer = new WebGLRenderer(200, 200, { - resolution: 2 - }); - - expect(renderer.view.style.width).to.equal(''); - }); - }); -}); diff --git a/test/unit/pixi/renderers/webgl/WebGLShaders.js b/test/unit/pixi/renderers/webgl/WebGLShaders.js deleted file mode 100644 index 6e33e4f..0000000 --- a/test/unit/pixi/renderers/webgl/WebGLShaders.js +++ /dev/null @@ -1,13 +0,0 @@ -describe('renderers/webgl/WebGLShaders', function () { - 'use strict'; - - var expect = chai.expect; - - it('Module members exist', function () { - - expect(PIXI).to.respondTo('CompileVertexShader'); - expect(PIXI).to.respondTo('CompileFragmentShader'); - expect(PIXI).to.respondTo('_CompileShader'); - expect(PIXI).to.respondTo('compileProgram'); - }); -}); diff --git a/test/unit/pixi/renderers/webgl/WebGLSpriteBatch.js b/test/unit/pixi/renderers/webgl/WebGLSpriteBatch.js deleted file mode 100644 index e662b63..0000000 --- a/test/unit/pixi/renderers/webgl/WebGLSpriteBatch.js +++ /dev/null @@ -1,10 +0,0 @@ -describe('renderers/webgl/utils/WebGLSpriteBatch', function () { - 'use strict'; - - var expect = chai.expect; - var WebGLSpriteBatch = PIXI.WebGLSpriteBatch; - - it('Module exists', function () { - expect(WebGLSpriteBatch).to.be.a('function'); - }); -}); diff --git a/test/unit/pixi-v2/InteractionManager.js b/test/unit/pixi-v2/InteractionManager.js new file mode 100644 index 0000000..ed3001f --- /dev/null +++ b/test/unit/pixi-v2/InteractionManager.js @@ -0,0 +1,10 @@ +describe('pixi/InteractionManager', function () { + 'use strict'; + + var expect = chai.expect; + var InteractionManager = PIXI.InteractionManager; + + it('Module exists', function () { + expect(InteractionManager).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/Pixi.js b/test/unit/pixi-v2/Pixi.js new file mode 100644 index 0000000..27debc1 --- /dev/null +++ b/test/unit/pixi-v2/Pixi.js @@ -0,0 +1,9 @@ +describe('pixi/Pixi', function () { + 'use strict'; + + var expect = chai.expect; + + it('Module exists', function () { + expect(global).to.have.property('PIXI').and.to.be.an('object'); + }); +}); diff --git a/test/unit/pixi-v2/core/Circle.js b/test/unit/pixi-v2/core/Circle.js new file mode 100644 index 0000000..fbcfa17 --- /dev/null +++ b/test/unit/pixi-v2/core/Circle.js @@ -0,0 +1,21 @@ +describe('pixi/core/Circle', function () { + 'use strict'; + + var expect = chai.expect; + var Circle = PIXI.Circle; + + it('Module exists', function () { + expect(Circle).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Circle(); + pixi_core_Circle_confirmNewCircle(obj); + }); + + it("getBounds should return Rectangle that bounds the circle", function() { + var obj = new Circle(100, 250, 50); + var bounds = obj.getBounds(); + pixi_core_Circle_isBoundedByRectangle(obj, bounds); + }); +}); diff --git a/test/unit/pixi-v2/core/Ellipse.js b/test/unit/pixi-v2/core/Ellipse.js new file mode 100644 index 0000000..026b56f --- /dev/null +++ b/test/unit/pixi-v2/core/Ellipse.js @@ -0,0 +1,24 @@ +describe('pixi/core/Ellipse', function () { + 'use strict'; + + var expect = chai.expect; + var Ellipse = PIXI.Ellipse; + + it('Module exists', function () { + expect(Ellipse).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Ellipse(); + + expect(obj).to.be.an.instanceof(Ellipse); + expect(obj).to.respondTo('clone'); + expect(obj).to.respondTo('contains'); + expect(obj).to.respondTo('getBounds'); + + expect(obj).to.have.property('x', 0); + expect(obj).to.have.property('y', 0); + expect(obj).to.have.property('width', 0); + expect(obj).to.have.property('height', 0); + }); +}); diff --git a/test/unit/pixi-v2/core/Matrix.js b/test/unit/pixi-v2/core/Matrix.js new file mode 100644 index 0000000..da75e2e --- /dev/null +++ b/test/unit/pixi-v2/core/Matrix.js @@ -0,0 +1,14 @@ +describe('pixi/core/Matrix', function () { + 'use strict'; + + var expect = chai.expect; + + it('Matrix exists', function () { + expect(PIXI.Matrix).to.be.an('function'); + }); + + it('Confirm new Matrix', function () { + var matrix = new PIXI.Matrix(); + pixi_core_Matrix_confirmNewMatrix(matrix); + }); +}); diff --git a/test/unit/pixi-v2/core/Point.js b/test/unit/pixi-v2/core/Point.js new file mode 100644 index 0000000..c4d5163 --- /dev/null +++ b/test/unit/pixi-v2/core/Point.js @@ -0,0 +1,15 @@ +describe('pixi/core/Point', function () { + 'use strict'; + + var expect = chai.expect; + var Point = PIXI.Point; + + it('Module exists', function () { + expect(Point).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Point(); + pixi_core_Point_confirm(obj, 0, 0); + }); +}); diff --git a/test/unit/pixi-v2/core/Polygon.js b/test/unit/pixi-v2/core/Polygon.js new file mode 100644 index 0000000..dc8c918 --- /dev/null +++ b/test/unit/pixi-v2/core/Polygon.js @@ -0,0 +1,20 @@ +describe('pixi/core/Polygon', function () { + 'use strict'; + + var expect = chai.expect; + var Polygon = PIXI.Polygon; + + it('Module exists', function () { + expect(Polygon).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Polygon(); + + expect(obj).to.be.an.instanceof(Polygon); + expect(obj).to.respondTo('clone'); + expect(obj).to.respondTo('contains'); + + expect(obj).to.have.deep.property('points.length', 0); + }); +}); diff --git a/test/unit/pixi-v2/core/Rectangle.js b/test/unit/pixi-v2/core/Rectangle.js new file mode 100644 index 0000000..d43316e --- /dev/null +++ b/test/unit/pixi-v2/core/Rectangle.js @@ -0,0 +1,15 @@ +describe('pixi/core/Rectangle', function () { + 'use strict'; + + var expect = chai.expect; + var Rectangle = PIXI.Rectangle; + + it('Module exists', function () { + expect(Rectangle).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var rect = new Rectangle(); + pixi_core_Rectangle_confirm(rect, 0, 0, 0, 0); + }); +}); diff --git a/test/unit/pixi-v2/display/DisplayObject.js b/test/unit/pixi-v2/display/DisplayObject.js new file mode 100644 index 0000000..044acf8 --- /dev/null +++ b/test/unit/pixi-v2/display/DisplayObject.js @@ -0,0 +1,21 @@ +describe('pixi/display/DisplayObject', function () { + 'use strict'; + + var expect = chai.expect; + var DisplayObject = PIXI.DisplayObject; + + it('Module exists', function () { + expect(DisplayObject).to.be.a('function'); + // expect(PIXI).to.have.property('visibleCount', 0); + }); + + it('Confirm new instance', function () { + var obj = new DisplayObject(); + + pixi_display_DisplayObject_confirmNew(obj); + expect(obj).to.have.property('hitArea', null); + expect(obj).to.have.property('interactive', false); + expect(obj).to.have.property('renderable', false); + expect(obj).to.have.property('stage', null); + }); +}); diff --git a/test/unit/pixi-v2/display/DisplayObjectContainer.js b/test/unit/pixi-v2/display/DisplayObjectContainer.js new file mode 100644 index 0000000..15a3376 --- /dev/null +++ b/test/unit/pixi-v2/display/DisplayObjectContainer.js @@ -0,0 +1,67 @@ +describe('pixi/display/DisplayObjectContainer', function () { + 'use strict'; + + var expect = chai.expect; + var DisplayObjectContainer = PIXI.DisplayObjectContainer; + + it('Module exists', function () { + expect(DisplayObjectContainer).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new DisplayObjectContainer(); + + pixi_display_DisplayObjectContainer_confirmNew(obj); + expect(obj).to.have.property('hitArea', null); + expect(obj).to.have.property('interactive', false); + expect(obj).to.have.property('renderable', false); + expect(obj).to.have.property('stage', null); + }); + + it('Gets child index', function() { + var container = new PIXI.DisplayObjectContainer(); + var children = []; + for (var i = 0; i < 10; i++) { + var child = new PIXI.DisplayObject(); + children.push(child); + container.addChild(child); + } + + for (i = 0; i < children.length; i++) { + expect(i).to.eql(container.getChildIndex(children[i])); + } + }); + + it('throws error when trying to get index of not a child', function() { + var container = new PIXI.DisplayObjectContainer(); + var child = new PIXI.DisplayObject(); + + expect(function() { container.getChildIndex(child); }).to.throw(); + }); + + it('Sets child index', function() { + var container = new PIXI.DisplayObjectContainer(); + var children = []; + + for (var i = 0; i < 10; i++) { + var child = new PIXI.DisplayObject(); + children.push(child); + container.addChild(child); + } + children.reverse(); + + for (i = 0; i < children.length; i++) { + container.setChildIndex(children[i], i); + expect(i).to.eql(container.getChildIndex(children[i])); + } + }); + + it('throws error when trying to set incorect index', function() { + var container = new PIXI.DisplayObjectContainer(); + var child = new PIXI.DisplayObject(); + container.addChild(child); + + expect(function() { container.setChildIndex(child, -1); }).to.throw(); + expect(function() { container.setChildIndex(child, 1); }).to.throw(); + }); +}); diff --git a/test/unit/pixi-v2/display/MovieClip.js b/test/unit/pixi-v2/display/MovieClip.js new file mode 100644 index 0000000..f3c6c6a --- /dev/null +++ b/test/unit/pixi-v2/display/MovieClip.js @@ -0,0 +1,33 @@ +describe('pixi/display/MovieClip', function () { + 'use strict'; + + var expect = chai.expect; + var MovieClip = PIXI.MovieClip; + var Texture = PIXI.Texture; + + it('Module exists', function () { + expect(MovieClip).to.be.a('function'); + }); + + it('Confirm new instance', function (done) { + var texture = Texture.fromImage('/base/test/textures/SpriteSheet-Explosion.png'); + var obj = new MovieClip([texture]); + + pixi_display_Sprite_confirmNew(obj, done); + + expect(obj).to.be.an.instanceof(MovieClip); + expect(obj).to.respondTo('stop'); + expect(obj).to.respondTo('play'); + expect(obj).to.respondTo('gotoAndStop'); + expect(obj).to.respondTo('gotoAndPlay'); + expect(obj).to.respondTo('updateTransform'); + + expect(obj).to.have.deep.property('textures.length', 1); + expect(obj).to.have.deep.property('textures[0]', texture); + expect(obj).to.have.property('animationSpeed', 1); + expect(obj).to.have.property('loop', true); + expect(obj).to.have.property('onComplete', null); + expect(obj).to.have.property('currentFrame', 0); + expect(obj).to.have.property('playing', false); + }); +}); diff --git a/test/unit/pixi-v2/display/Sprite.js b/test/unit/pixi-v2/display/Sprite.js new file mode 100644 index 0000000..30c8076 --- /dev/null +++ b/test/unit/pixi-v2/display/Sprite.js @@ -0,0 +1,28 @@ +describe('pixi/display/Sprite', function () { + 'use strict'; + + var expect = chai.expect; + var Sprite = PIXI.Sprite; + var Texture = PIXI.Texture; + + it('Module exists', function () { + expect(Sprite).to.be.a('function'); + expect(PIXI).to.have.deep.property('blendModes.NORMAL', 0); + expect(PIXI).to.have.deep.property('blendModes.ADD', 1); + expect(PIXI).to.have.deep.property('blendModes.MULTIPLY', 2); + expect(PIXI).to.have.deep.property('blendModes.SCREEN', 3); + }); + + + it('Members exist', function () { + expect(Sprite).itself.to.respondTo('fromImage'); + expect(Sprite).itself.to.respondTo('fromFrame'); + }); + + it('Confirm new instance', function (done) { + var texture = Texture.fromImage('/base/test/textures/SpriteSheet-Aliens.png'); + var obj = new Sprite(texture); + + pixi_display_Sprite_confirmNew(obj, done); + }); +}); diff --git a/test/unit/pixi-v2/display/Stage.js b/test/unit/pixi-v2/display/Stage.js new file mode 100644 index 0000000..6974c2e --- /dev/null +++ b/test/unit/pixi-v2/display/Stage.js @@ -0,0 +1,49 @@ +describe('pixi/display/Stage', function () { + 'use strict'; + + var expect = chai.expect; + var Stage = PIXI.Stage; + var InteractionManager = PIXI.InteractionManager; + var Rectangle = PIXI.Rectangle; + + it('Module exists', function () { + expect(Stage).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Stage(null, true); + + pixi_display_DisplayObjectContainer_confirmNew(obj); + + expect(obj).to.be.an.instanceof(Stage); + expect(obj).to.respondTo('updateTransform'); + expect(obj).to.respondTo('setBackgroundColor'); + expect(obj).to.respondTo('getMousePosition'); + // FIXME: duplicate member in DisplayObject + pixi_core_Matrix_confirmNewMatrix(obj.worldTransform); + // FIXME: convert arg to bool in constructor + expect(obj).to.have.property('interactive', true); + + expect(obj).to.have.property('interactionManager') + .and.to.be.an.instanceof(InteractionManager) + .and.to.have.property('stage', obj); + + expect(obj).to.have.property('dirty', true); + + expect(obj).to.have.property('stage', obj); + + expect(obj).to.have.property('hitArea') + .and.to.be.an.instanceof(Rectangle); + pixi_core_Rectangle_confirm(obj.hitArea, 0, 0, 100000, 100000); + + expect(obj).to.have.property('backgroundColor', 0x000000); + expect(obj).to.have.deep.property('backgroundColorSplit.length', 3); + expect(obj).to.have.deep.property('backgroundColorSplit[0]', 0); + expect(obj).to.have.deep.property('backgroundColorSplit[1]', 0); + expect(obj).to.have.deep.property('backgroundColorSplit[2]', 0); + expect(obj).to.have.property('backgroundColorString', '#000000'); + + + expect(obj).to.have.property('worldVisible', true); + }); +}); diff --git a/test/unit/pixi-v2/extras/Rope.js b/test/unit/pixi-v2/extras/Rope.js new file mode 100644 index 0000000..05885ac --- /dev/null +++ b/test/unit/pixi-v2/extras/Rope.js @@ -0,0 +1,31 @@ +describe('pixi/extras/Rope', function () { + 'use strict'; + + var expect = chai.expect; + var Rope = PIXI.Rope; + var Texture = PIXI.Texture; + var Point = PIXI.Point; + + it('Module exists', function () { + expect(Rope).to.be.a('function'); + }); + + it('Confirm new instance', function () { + + var texture = Texture.fromImage('/base/test/textures/bunny.png'); + + // TODO-Alvin + // Same as Strip + + // var obj = new Rope(texture, [new Point(), new Point(5, 10), new Point(10, 20)]); + + // pixi_extras_Strip_confirmNew(obj); + + // expect(obj).to.be.an.instanceof(Rope); + // expect(obj).to.respondTo('refresh'); + // expect(obj).to.respondTo('updateTransform'); + // expect(obj).to.respondTo('setTexture'); + + // TODO: Test properties + }); +}); diff --git a/test/unit/pixi-v2/extras/Spine.js b/test/unit/pixi-v2/extras/Spine.js new file mode 100644 index 0000000..0708bc0 --- /dev/null +++ b/test/unit/pixi-v2/extras/Spine.js @@ -0,0 +1,10 @@ +describe('pixi/extras/Spine', function () { + 'use strict'; + + var expect = chai.expect; + var Spine = PIXI.Spine; + + it('Module exists', function () { + expect(Spine).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/extras/Strip.js b/test/unit/pixi-v2/extras/Strip.js new file mode 100644 index 0000000..230af90 --- /dev/null +++ b/test/unit/pixi-v2/extras/Strip.js @@ -0,0 +1,26 @@ +describe('pixi/extras/Strip', function () { + 'use strict'; + + var expect = chai.expect; + var Strip = PIXI.Strip; + var Texture = PIXI.Texture; + + it('Module exists', function () { + expect(Strip).to.be.a('function'); + }); + + it('Confirm new instance', function () { + + + // TODO-Alvin + // We tweaked it to make it pass the tests, but the whole strip class needs + // to be re-coded + + var texture = Texture.fromImage('/base/test/textures/bunny.png'); + + // var obj = new Strip(texture, 20, 10000); + + + // pixi_extras_Strip_confirmNew(obj); + }); +}); diff --git a/test/unit/pixi-v2/extras/TilingSprite.js b/test/unit/pixi-v2/extras/TilingSprite.js new file mode 100644 index 0000000..56aea14 --- /dev/null +++ b/test/unit/pixi-v2/extras/TilingSprite.js @@ -0,0 +1,24 @@ +describe('pixi/extras/TilingSprite', function () { + 'use strict'; + + var expect = chai.expect; + var TilingSprite = PIXI.TilingSprite; + var Texture = PIXI.Texture; + + it('Module exists', function () { + expect(TilingSprite).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var texture = Texture.fromImage('/base/test/textures/bunny.png'); + var obj = new TilingSprite(texture, 6000, 12000); + + pixi_display_DisplayObjectContainer_confirmNew(obj); + + expect(obj).to.be.an.instanceof(TilingSprite); + expect(obj).to.respondTo('setTexture'); + expect(obj).to.respondTo('onTextureUpdate'); + + // TODO: Test properties + }); +}); diff --git a/test/unit/pixi-v2/filters/FilterBlock.js b/test/unit/pixi-v2/filters/FilterBlock.js new file mode 100644 index 0000000..870cec0 --- /dev/null +++ b/test/unit/pixi-v2/filters/FilterBlock.js @@ -0,0 +1,10 @@ +describe('pixi/filters/FilterBlock', function () { + 'use strict'; + + var expect = chai.expect; + var FilterBlock = PIXI.FilterBlock; + + it('Module exists', function () { + expect(FilterBlock).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/AssetLoader.js b/test/unit/pixi-v2/loaders/AssetLoader.js new file mode 100644 index 0000000..a0aa0b5 --- /dev/null +++ b/test/unit/pixi-v2/loaders/AssetLoader.js @@ -0,0 +1,10 @@ +describe('pixi/loaders/AssetLoader', function () { + 'use strict'; + + var expect = chai.expect; + var AssetLoader = PIXI.AssetLoader; + + it('Module exists', function () { + expect(AssetLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/BitmapFontLoader.js b/test/unit/pixi-v2/loaders/BitmapFontLoader.js new file mode 100644 index 0000000..046f018 --- /dev/null +++ b/test/unit/pixi-v2/loaders/BitmapFontLoader.js @@ -0,0 +1,9 @@ +describe('pixi/loaders/BitmapFontLoader', function () { + 'use strict'; + + var expect = chai.expect; + + it('Module exists', function () { + expect(PIXI.BitmapFontLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/ImageLoader.js b/test/unit/pixi-v2/loaders/ImageLoader.js new file mode 100644 index 0000000..8b1f556 --- /dev/null +++ b/test/unit/pixi-v2/loaders/ImageLoader.js @@ -0,0 +1,10 @@ +describe('pixi/loaders/ImageLoader', function () { + 'use strict'; + + var expect = chai.expect; + var ImageLoader = PIXI.ImageLoader; + + it('Module exists', function () { + expect(ImageLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/JsonLoader.js b/test/unit/pixi-v2/loaders/JsonLoader.js new file mode 100644 index 0000000..c577e83 --- /dev/null +++ b/test/unit/pixi-v2/loaders/JsonLoader.js @@ -0,0 +1,10 @@ +describe('pixi/loaders/JsonLoader', function () { + 'use strict'; + + var expect = chai.expect; + var JsonLoader = PIXI.JsonLoader; + + it('Module exists', function () { + expect(JsonLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/SpineLoader.js b/test/unit/pixi-v2/loaders/SpineLoader.js new file mode 100644 index 0000000..fdcc0b8 --- /dev/null +++ b/test/unit/pixi-v2/loaders/SpineLoader.js @@ -0,0 +1,10 @@ +describe('pixi/loaders/SpineLoader', function () { + 'use strict'; + + var expect = chai.expect; + var SpineLoader = PIXI.SpineLoader; + + it('Module exists', function () { + expect(SpineLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/SpriteSheetLoader.js b/test/unit/pixi-v2/loaders/SpriteSheetLoader.js new file mode 100644 index 0000000..57beb27 --- /dev/null +++ b/test/unit/pixi-v2/loaders/SpriteSheetLoader.js @@ -0,0 +1,10 @@ +describe('pixi/loaders/SpriteSheetLoader', function () { + 'use strict'; + + var expect = chai.expect; + var SpriteSheetLoader = PIXI.SpriteSheetLoader; + + it('Module exists', function () { + expect(SpriteSheetLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/primitives/Graphics.js b/test/unit/pixi-v2/primitives/Graphics.js new file mode 100644 index 0000000..f3849eb --- /dev/null +++ b/test/unit/pixi-v2/primitives/Graphics.js @@ -0,0 +1,44 @@ +describe('pixi/primitives/Graphics', function () { + 'use strict'; + + var expect = chai.expect; + var Graphics = PIXI.Graphics; + + it('Module exists', function () { + expect(Graphics).to.be.a('function'); + + expect(Graphics).itself.to.have.property('POLY', 0); + expect(Graphics).itself.to.have.property('RECT', 1); + expect(Graphics).itself.to.have.property('CIRC', 2); + expect(Graphics).itself.to.have.property('ELIP', 3); + expect(Graphics).itself.to.have.property('RREC', 4); + }); + + it('Confirm new instance', function () { + var obj = new Graphics(); + + pixi_display_DisplayObjectContainer_confirmNew(obj); + + expect(obj).to.be.an.instanceof(Graphics); + expect(obj).to.respondTo('lineStyle'); + expect(obj).to.respondTo('lineStyle'); + expect(obj).to.respondTo('moveTo'); + expect(obj).to.respondTo('lineTo'); + expect(obj).to.respondTo('beginFill'); + expect(obj).to.respondTo('endFill'); + expect(obj).to.respondTo('drawRect'); + // expect(obj).to.respondTo('drawRoundedRect'); + expect(obj).to.respondTo('drawCircle'); + expect(obj).to.respondTo('drawEllipse'); + expect(obj).to.respondTo('clear'); + + expect(obj).to.have.property('renderable', true); + expect(obj).to.have.property('fillAlpha', 1); + expect(obj).to.have.property('lineWidth', 0); + expect(obj).to.have.property('width', 0); + expect(obj).to.have.property('height', 0); + expect(obj).to.have.property('lineColor', 0); + expect(obj).to.have.deep.property('graphicsData.length', 0); + // expect(obj).to.have.deep.property('currentPath.points.length', 0); + }); +}); diff --git a/test/unit/pixi-v2/renderers/canvas/CanvasGraphics.js b/test/unit/pixi-v2/renderers/canvas/CanvasGraphics.js new file mode 100644 index 0000000..8f44472 --- /dev/null +++ b/test/unit/pixi-v2/renderers/canvas/CanvasGraphics.js @@ -0,0 +1,15 @@ +describe('renders/canvas/CanvasGraphics', function () { + 'use strict'; + + var expect = chai.expect; + var CanvasGraphics = PIXI.CanvasGraphics; + + it('Module exists', function () { + expect(CanvasGraphics).to.be.a('function'); + }); + + it('Members exist', function () { + expect(CanvasGraphics).itself.to.respondTo('renderGraphics'); + expect(CanvasGraphics).itself.to.respondTo('renderGraphicsMask'); + }); +}); diff --git a/test/unit/pixi-v2/renderers/canvas/CanvasRenderer.js b/test/unit/pixi-v2/renderers/canvas/CanvasRenderer.js new file mode 100644 index 0000000..1646444 --- /dev/null +++ b/test/unit/pixi-v2/renderers/canvas/CanvasRenderer.js @@ -0,0 +1,36 @@ +describe('renderers/canvas/CanvasRenderer', function () { + 'use strict'; + + var expect = chai.expect; + var CanvasRenderer = PIXI.CanvasRenderer; + + it('Module exists', function () { + expect(CanvasRenderer).to.be.a('function'); + }); + + describe('.autoResize', function () { + it('Should automatically resize view if enabled', function () { + var renderer = new CanvasRenderer(200, 200, { + autoResize: true + }); + + expect(renderer.view.style.width).to.equal('200px'); + }); + + it('Should not automatically resize view if disabled', function () { + var renderer = new CanvasRenderer(200, 200, { + autoResize: false + }); + + expect(renderer.view.style.width).to.equal(''); + }); + + it('Should not automatically resize view if not specified', function () { + var renderer = new CanvasRenderer(200, 200, { + resolution: 2 + }); + + expect(renderer.view.style.width).to.equal(''); + }); + }); +}); diff --git a/test/unit/pixi-v2/renderers/webgl/WebGLGraphics.js b/test/unit/pixi-v2/renderers/webgl/WebGLGraphics.js new file mode 100644 index 0000000..5867b28 --- /dev/null +++ b/test/unit/pixi-v2/renderers/webgl/WebGLGraphics.js @@ -0,0 +1,20 @@ +describe('renderers/wegbl/WebGLGraphics', function () { + 'use strict'; + + var expect = chai.expect; + var WebGLGraphics = PIXI.WebGLGraphics; + + it('Module exists', function () { + expect(WebGLGraphics).to.be.a('function'); + }); + + it('Members exist', function () { + expect(WebGLGraphics).itself.to.respondTo('renderGraphics'); + expect(WebGLGraphics).itself.to.respondTo('updateGraphics'); + expect(WebGLGraphics).itself.to.respondTo('buildRectangle'); + expect(WebGLGraphics).itself.to.respondTo('buildRoundedRectangle'); + expect(WebGLGraphics).itself.to.respondTo('buildCircle'); + expect(WebGLGraphics).itself.to.respondTo('buildLine'); + expect(WebGLGraphics).itself.to.respondTo('buildPoly'); + }); +}); diff --git a/test/unit/pixi-v2/renderers/webgl/WebGLRenderer.js b/test/unit/pixi-v2/renderers/webgl/WebGLRenderer.js new file mode 100644 index 0000000..1680a80 --- /dev/null +++ b/test/unit/pixi-v2/renderers/webgl/WebGLRenderer.js @@ -0,0 +1,49 @@ +describe('renderers/webgl/WebGLRenderer', function () { + 'use strict'; + + var expect = chai.expect; + var WebGLRenderer = PIXI.WebGLRenderer; + + it('Module exists', function () { + expect(WebGLRenderer).to.be.a('function'); + }); + + // Skip tests if WebGL is not available (WebGL not supported in Travis CI) + try { + var renderer = new WebGLRenderer(400, 300, {}); + renderer.destroy(); + } catch (error) { + return; + } + + it('Destroy renderer', function () { + var renderer = new WebGLRenderer(400, 300, {}); + renderer.destroy(); + }); + + describe('.autoResize', function () { + it('Should automatically resize view if enabled', function () { + var renderer = new WebGLRenderer(200, 200, { + autoResize: true + }); + + expect(renderer.view.style.width).to.equal('200px'); + }); + + it('Should not automatically resize view if disabled', function () { + var renderer = new WebGLRenderer(200, 200, { + autoResize: false + }); + + expect(renderer.view.style.width).to.equal(''); + }); + + it('Should not automatically resize view if not specified', function () { + var renderer = new WebGLRenderer(200, 200, { + resolution: 2 + }); + + expect(renderer.view.style.width).to.equal(''); + }); + }); +}); diff --git a/test/unit/pixi-v2/renderers/webgl/WebGLShaders.js b/test/unit/pixi-v2/renderers/webgl/WebGLShaders.js new file mode 100644 index 0000000..6e33e4f --- /dev/null +++ b/test/unit/pixi-v2/renderers/webgl/WebGLShaders.js @@ -0,0 +1,13 @@ +describe('renderers/webgl/WebGLShaders', function () { + 'use strict'; + + var expect = chai.expect; + + it('Module members exist', function () { + + expect(PIXI).to.respondTo('CompileVertexShader'); + expect(PIXI).to.respondTo('CompileFragmentShader'); + expect(PIXI).to.respondTo('_CompileShader'); + expect(PIXI).to.respondTo('compileProgram'); + }); +}); diff --git a/test/unit/pixi-v2/renderers/webgl/WebGLSpriteBatch.js b/test/unit/pixi-v2/renderers/webgl/WebGLSpriteBatch.js new file mode 100644 index 0000000..e662b63 --- /dev/null +++ b/test/unit/pixi-v2/renderers/webgl/WebGLSpriteBatch.js @@ -0,0 +1,10 @@ +describe('renderers/webgl/utils/WebGLSpriteBatch', function () { + 'use strict'; + + var expect = chai.expect; + var WebGLSpriteBatch = PIXI.WebGLSpriteBatch; + + it('Module exists', function () { + expect(WebGLSpriteBatch).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/text/BitmapText.js b/test/unit/pixi-v2/text/BitmapText.js new file mode 100644 index 0000000..9388e3d --- /dev/null +++ b/test/unit/pixi-v2/text/BitmapText.js @@ -0,0 +1,10 @@ +describe('pixi/text/BitmapText', function () { + 'use strict'; + + var expect = chai.expect; + var BitmapText = PIXI.BitmapText; + + it('Module exists', function () { + expect(BitmapText).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/text/Text.js b/test/unit/pixi-v2/text/Text.js new file mode 100644 index 0000000..9bc9ac5 --- /dev/null +++ b/test/unit/pixi-v2/text/Text.js @@ -0,0 +1,10 @@ +describe('pixi/text/Text', function () { + 'use strict'; + + var expect = chai.expect; + var Text = PIXI.Text; + + it('Module exists', function () { + expect(Text).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/textures/BaseTexture.js b/test/unit/pixi-v2/textures/BaseTexture.js new file mode 100644 index 0000000..502b724 --- /dev/null +++ b/test/unit/pixi-v2/textures/BaseTexture.js @@ -0,0 +1,11 @@ +describe('pixi/textures/BaseTexture', function () { + 'use strict'; + + var expect = chai.expect; + var BaseTexture = PIXI.BaseTexture; + + it('Module exists', function () { + expect(BaseTexture).to.be.a('function'); + expect(PIXI).to.have.property('BaseTextureCache').and.to.be.an('object'); + }); +}); diff --git a/test/unit/pixi-v2/textures/RenderTexture.js b/test/unit/pixi-v2/textures/RenderTexture.js new file mode 100644 index 0000000..96acdb4 --- /dev/null +++ b/test/unit/pixi-v2/textures/RenderTexture.js @@ -0,0 +1,15 @@ +describe('pixi/textures/RenderTexture', function () { + 'use strict'; + + var expect = chai.expect; + var RenderTexture = PIXI.RenderTexture; + + it('Module exists', function () { + expect(RenderTexture).to.be.a('function'); + }); + + it('Confirm new instance', function (done) { + var texture = new RenderTexture(100, 100, new PIXI.CanvasRenderer()); + pixi_textures_RenderTexture_confirmNew(texture, done); + }); +}); diff --git a/test/unit/pixi-v2/textures/Texture.js b/test/unit/pixi-v2/textures/Texture.js new file mode 100644 index 0000000..090f64d --- /dev/null +++ b/test/unit/pixi-v2/textures/Texture.js @@ -0,0 +1,26 @@ +describe('pixi/textures/Texture', function () { + 'use strict'; + + var expect = chai.expect; + var Texture = PIXI.Texture; + + it('Module exists', function () { + expect(Texture).to.be.a('function'); + expect(PIXI).to.have.property('TextureCache').and.to.be.an('object'); + }); + + it('Members exist', function () { + expect(Texture).itself.to.respondTo('fromImage'); + expect(Texture).itself.to.respondTo('fromFrame'); + expect(Texture).itself.to.respondTo('fromCanvas'); + expect(Texture).itself.to.respondTo('addTextureToCache'); + expect(Texture).itself.to.respondTo('removeTextureFromCache'); + + // expect(Texture).itself.to.have.deep.property('frameUpdates.length', 0); + }); + + it('Confirm new instance', function (done) { + var texture = Texture.fromImage('/base/test/textures/bunny.png'); + pixi_textures_Texture_confirmNew(texture, done); + }); +}); diff --git a/test/unit/pixi-v2/utils/Detector.js b/test/unit/pixi-v2/utils/Detector.js new file mode 100644 index 0000000..4cf6008 --- /dev/null +++ b/test/unit/pixi-v2/utils/Detector.js @@ -0,0 +1,10 @@ +describe('pixi/utils/Detector', function () { + 'use strict'; + + var expect = chai.expect; + var autoDetectRenderer = PIXI.autoDetectRenderer; + + it('Module exists', function () { + expect(autoDetectRenderer).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/utils/EventTarget.js b/test/unit/pixi-v2/utils/EventTarget.js new file mode 100644 index 0000000..1cfc3a4 --- /dev/null +++ b/test/unit/pixi-v2/utils/EventTarget.js @@ -0,0 +1,361 @@ +describe('pixi/utils/EventTarget', function () { + 'use strict'; + + var expect = chai.expect; + + var Clazz, PClazz, obj, pobj, obj2; + beforeEach(function () { + Clazz = function () {}; + PClazz = function () {}; + + PIXI.EventTarget.mixin(Clazz.prototype); + PIXI.EventTarget.mixin(PClazz.prototype); + + obj = new Clazz(); + obj2 = new Clazz(); + pobj = new PClazz(); + + obj.parent = pobj; + obj2.parent = obj; + }); + + it('Module exists', function () { + expect(PIXI.EventTarget).to.be.an('object'); + }); + + it('Confirm new instance', function () { + pixi_utils_EventTarget_confirm(obj); + }); + + it('simple on/emit case works', function () { + var myData = {}; + + obj.on('myevent', function (event) { + pixi_utils_EventTarget_Event_confirm(event, obj, myData); + }); + + obj.emit('myevent', myData); + }); + + it('simple once case works', function () { + var called = 0; + + obj.once('myevent', function() { called++; }); + + obj.emit('myevent'); + obj.emit('myevent'); + obj.emit('myevent'); + obj.emit('myevent'); + obj.emit('myevent'); + + expect(called).to.equal(1); + }); + + it('simple off case works', function (done) { + function onMyEvent() { + done(new Error('Event listener should not have been called')); + } + + obj.on('myevent', onMyEvent); + obj.off('myevent', onMyEvent); + obj.emit('myevent'); + + done(); + }); + + it('simple propagation case works', function (done) { + var myData = {}; + + pobj.on('myevent', function () { + done(); + }); + + obj.emit('myevent'); + }); + + it('simple stopPropagation case works', function (done) { + var myData = {}; + + pobj.on('myevent', function () { + done(new Error('Event listener should not have been called on the parent element')); + }); + + obj.on('myevent', function (evt) { + evt.stopPropagation(); + }); + + obj.emit('myevent'); + + done(); + }); + + it('simple stopImmediatePropagation case works', function (done) { + var myData = {}; + + pobj.on('myevent', function () { + done(new Error('Event listener should not have been called on the parent')); + }); + + obj.on('myevent', function (evt) { + evt.stopImmediatePropagation(); + }); + + obj.on('myevent', function () { + done(new Error('Event listener should not have been called on the second')); + }); + + obj.emit('myevent'); + + done(); + }); + + it('multiple dispatches work properly', function () { + var called = 0; + + function onMyEvent() { + called++; + } + + obj.on('myevent', onMyEvent); + obj.emit('myevent'); + obj.emit('myevent'); + obj.emit('myevent'); + obj.emit('myevent'); + + expect(called).to.equal(4); + }); + + it('multiple events work properly', function () { + var called = 0; + + function onMyEvent() { + called++; + } + + obj.on('myevent1', onMyEvent); + obj.on('myevent2', onMyEvent); + obj.on('myevent3', onMyEvent); + obj.emit('myevent1'); + obj.emit('myevent2'); + obj.emit('myevent3'); + + expect(called).to.equal(3); + }); + + it('multiple events one removed works properly', function () { + var called = 0; + + function onMyEvent() { + called++; + } + + obj.on('myevent1', onMyEvent); + obj.on('myevent2', onMyEvent); + obj.on('myevent3', onMyEvent); + + obj.emit('myevent1'); + obj.emit('myevent2'); + obj.emit('myevent3'); + + obj.off('myevent2', onMyEvent); + + obj.emit('myevent1'); + obj.emit('myevent2'); + obj.emit('myevent3'); + + expect(called).to.equal(5); + }); + + it('multiple handlers for one event with some removed', function () { + var called = 0; + + var onMyEvent = function () { + called++; + }, + onMyEvent2 = function () { + called++; + }; + + // add 2 handlers and confirm they both get called + obj.on('myevent', onMyEvent); + obj.on('myevent', onMyEvent); + obj.on('myevent', onMyEvent2); + obj.on('myevent', onMyEvent2); + + obj.emit('myevent'); + + expect(called).to.equal(4); + + // remove one of the handlers, emit again, then ensure 1 more call is made + obj.off('myevent', onMyEvent); + + obj.emit('myevent'); + + expect(called).to.equal(6); + }); + + it('calls to off without a handler do nothing', function () { + var called = 0; + + var onMyEvent = function () { + called++; + }; + + obj.on('myevent', onMyEvent); + obj.on('myevent', onMyEvent); + + obj.emit('myevent'); + + expect(called).to.equal(2); + + obj.off('myevent'); + + obj.emit('myevent'); + + expect(called).to.equal(4); + + obj.off('myevent', onMyEvent); + + obj.emit('myevent'); + + expect(called).to.equal(4); + }); + + it('handles multiple instances with the same prototype', function () { + var called = 0; + + function onMyEvent(e) { + called++; + } + + obj.on('myevent1', onMyEvent); + obj.on('myevent2', onMyEvent); + + obj2.istwo = true; + obj2.on('myevent1', onMyEvent); + obj2.on('myevent2', onMyEvent); + + obj.emit('myevent1'); + obj.emit('myevent2'); + obj2.emit('myevent1'); + obj2.emit('myevent2'); + + //we emit 4 times, but since obj2 is a child of obj the event should bubble + //up to obj and show up there as well. So the obj2.emit() calls each increment + //the counter twice. + expect(called).to.equal(6); + }); + + it('is backwards compatible with older .dispatchEvent({})', function () { + var called = 0, + data = { + some: 'thing', + hello: true + }; + + function onMyEvent(event) { + pixi_utils_EventTarget_Event_confirm(event, obj, data); + + called++; + } + + obj.on('myevent1', onMyEvent); + obj.on('myevent2', onMyEvent); + obj.on('myevent3', onMyEvent); + + data.type = 'myevent1'; + obj.emit(data); + + data.type = 'myevent2'; + obj.emit(data); + + data.type = 'myevent3'; + obj.emit(data); + + obj.off('myevent2', onMyEvent); + + data.type = 'myevent1'; + obj.emit(data); + + data.type = 'myevent2'; + obj.emit(data); + + data.type = 'myevent3'; + obj.emit(data); + + expect(called).to.equal(5); + }); + + it('is backwards compatible with older .call(this)', function () { + var Fn = function() { + PIXI.EventTarget.call(this); + }, + o = new Fn(); + + pixi_utils_EventTarget_confirm(o); + }); + + it('is backwards compatible with older .addEventListener("")', function () { + var called = 0, + data = { + some: 'thing', + hello: true + }; + + function onMyEvent(event) { + pixi_utils_EventTarget_Event_confirm(event, obj, data); + + called++; + } + + obj.addEventListener('myevent1', onMyEvent); + obj.addEventListener('myevent2', onMyEvent); + obj.addEventListener('myevent3', onMyEvent); + + data.type = 'myevent1'; + obj.emit(data); + + data.type = 'myevent2'; + obj.emit(data); + + data.type = 'myevent3'; + obj.emit(data); + + obj.off('myevent2', onMyEvent); + + data.type = 'myevent1'; + obj.emit(data); + + data.type = 'myevent2'; + obj.emit(data); + + data.type = 'myevent3'; + obj.emit(data); + + expect(called).to.equal(5); + }); + + it('event remove during emit call properly', function () { + var called = 0; + + function cb1() { + called++; + obj.off('myevent', cb1); + } + function cb2() { + called++; + obj.off('myevent', cb2); + } + function cb3() { + called++; + obj.off('myevent', cb3); + } + + obj.on('myevent', cb1); + obj.on('myevent', cb2); + obj.on('myevent', cb3); + obj.emit('myevent', ''); + + expect(called).to.equal(3); + }); +}); diff --git a/test/unit/pixi-v2/utils/Polyk.js b/test/unit/pixi-v2/utils/Polyk.js new file mode 100644 index 0000000..dfc7128 --- /dev/null +++ b/test/unit/pixi-v2/utils/Polyk.js @@ -0,0 +1,14 @@ +describe('pixi/utils/Polyk', function () { + 'use strict'; + + var expect = chai.expect; + var PolyK = PIXI.PolyK; + + it('Module exists', function () { + expect(PolyK).to.be.an('object'); + }); + + it('Members exist', function () { + expect(PolyK).to.respondTo('Triangulate'); + }); +}); diff --git a/test/unit/pixi-v2/utils/Utils.js b/test/unit/pixi-v2/utils/Utils.js new file mode 100644 index 0000000..c97b3c6 --- /dev/null +++ b/test/unit/pixi-v2/utils/Utils.js @@ -0,0 +1,17 @@ +describe('Utils', function () { + 'use strict'; + + var expect = chai.expect; + + it('requestAnimationFrame exists', function () { + expect(global).to.respondTo('requestAnimationFrame'); + }); + + it('cancelAnimationFrame exists', function () { + expect(global).to.respondTo('cancelAnimationFrame'); + }); + + it('requestAnimFrame exists', function () { + expect(global).to.respondTo('requestAnimFrame'); + }); +}); diff --git a/test/unit/pixi/InteractionManager.js b/test/unit/pixi/InteractionManager.js deleted file mode 100644 index ed3001f..0000000 --- a/test/unit/pixi/InteractionManager.js +++ /dev/null @@ -1,10 +0,0 @@ -describe('pixi/InteractionManager', function () { - 'use strict'; - - var expect = chai.expect; - var InteractionManager = PIXI.InteractionManager; - - it('Module exists', function () { - expect(InteractionManager).to.be.a('function'); - }); -}); diff --git a/test/unit/pixi/Pixi.js b/test/unit/pixi/Pixi.js deleted file mode 100644 index 27debc1..0000000 --- a/test/unit/pixi/Pixi.js +++ /dev/null @@ -1,9 +0,0 @@ -describe('pixi/Pixi', function () { - 'use strict'; - - var expect = chai.expect; - - it('Module exists', function () { - expect(global).to.have.property('PIXI').and.to.be.an('object'); - }); -}); diff --git a/test/unit/pixi/core/Circle.js b/test/unit/pixi/core/Circle.js deleted file mode 100644 index fbcfa17..0000000 --- a/test/unit/pixi/core/Circle.js +++ /dev/null @@ -1,21 +0,0 @@ -describe('pixi/core/Circle', function () { - 'use strict'; - - var expect = chai.expect; - var Circle = PIXI.Circle; - - it('Module exists', function () { - expect(Circle).to.be.a('function'); - }); - - it('Confirm new instance', function () { - var obj = new Circle(); - pixi_core_Circle_confirmNewCircle(obj); - }); - - it("getBounds should return Rectangle that bounds the circle", function() { - var obj = new Circle(100, 250, 50); - var bounds = obj.getBounds(); - pixi_core_Circle_isBoundedByRectangle(obj, bounds); - }); -}); diff --git a/test/unit/pixi/core/Ellipse.js b/test/unit/pixi/core/Ellipse.js deleted file mode 100644 index 026b56f..0000000 --- a/test/unit/pixi/core/Ellipse.js +++ /dev/null @@ -1,24 +0,0 @@ -describe('pixi/core/Ellipse', function () { - 'use strict'; - - var expect = chai.expect; - var Ellipse = PIXI.Ellipse; - - it('Module exists', function () { - expect(Ellipse).to.be.a('function'); - }); - - it('Confirm new instance', function () { - var obj = new Ellipse(); - - expect(obj).to.be.an.instanceof(Ellipse); - expect(obj).to.respondTo('clone'); - expect(obj).to.respondTo('contains'); - expect(obj).to.respondTo('getBounds'); - - expect(obj).to.have.property('x', 0); - expect(obj).to.have.property('y', 0); - expect(obj).to.have.property('width', 0); - expect(obj).to.have.property('height', 0); - }); -}); diff --git a/test/unit/pixi/core/Matrix.js b/test/unit/pixi/core/Matrix.js deleted file mode 100644 index da75e2e..0000000 --- a/test/unit/pixi/core/Matrix.js +++ /dev/null @@ -1,14 +0,0 @@ -describe('pixi/core/Matrix', function () { - 'use strict'; - - var expect = chai.expect; - - it('Matrix exists', function () { - expect(PIXI.Matrix).to.be.an('function'); - }); - - it('Confirm new Matrix', function () { - var matrix = new PIXI.Matrix(); - pixi_core_Matrix_confirmNewMatrix(matrix); - }); -}); diff --git a/test/unit/pixi/core/Point.js b/test/unit/pixi/core/Point.js deleted file mode 100644 index c4d5163..0000000 --- a/test/unit/pixi/core/Point.js +++ /dev/null @@ -1,15 +0,0 @@ -describe('pixi/core/Point', function () { - 'use strict'; - - var expect = chai.expect; - var Point = PIXI.Point; - - it('Module exists', function () { - expect(Point).to.be.a('function'); - }); - - it('Confirm new instance', function () { - var obj = new Point(); - pixi_core_Point_confirm(obj, 0, 0); - }); -}); diff --git a/test/unit/pixi/core/Polygon.js b/test/unit/pixi/core/Polygon.js deleted file mode 100644 index dc8c918..0000000 --- a/test/unit/pixi/core/Polygon.js +++ /dev/null @@ -1,20 +0,0 @@ -describe('pixi/core/Polygon', function () { - 'use strict'; - - var expect = chai.expect; - var Polygon = PIXI.Polygon; - - it('Module exists', function () { - expect(Polygon).to.be.a('function'); - }); - - it('Confirm new instance', function () { - var obj = new Polygon(); - - expect(obj).to.be.an.instanceof(Polygon); - expect(obj).to.respondTo('clone'); - expect(obj).to.respondTo('contains'); - - expect(obj).to.have.deep.property('points.length', 0); - }); -}); diff --git a/test/unit/pixi/core/Rectangle.js b/test/unit/pixi/core/Rectangle.js deleted file mode 100644 index d43316e..0000000 --- a/test/unit/pixi/core/Rectangle.js +++ /dev/null @@ -1,15 +0,0 @@ -describe('pixi/core/Rectangle', function () { - 'use strict'; - - var expect = chai.expect; - var Rectangle = PIXI.Rectangle; - - it('Module exists', function () { - expect(Rectangle).to.be.a('function'); - }); - - it('Confirm new instance', function () { - var rect = new Rectangle(); - pixi_core_Rectangle_confirm(rect, 0, 0, 0, 0); - }); -}); diff --git a/test/unit/pixi/display/DisplayObject.js b/test/unit/pixi/display/DisplayObject.js deleted file mode 100644 index 044acf8..0000000 --- a/test/unit/pixi/display/DisplayObject.js +++ /dev/null @@ -1,21 +0,0 @@ -describe('pixi/display/DisplayObject', function () { - 'use strict'; - - var expect = chai.expect; - var DisplayObject = PIXI.DisplayObject; - - it('Module exists', function () { - expect(DisplayObject).to.be.a('function'); - // expect(PIXI).to.have.property('visibleCount', 0); - }); - - it('Confirm new instance', function () { - var obj = new DisplayObject(); - - pixi_display_DisplayObject_confirmNew(obj); - expect(obj).to.have.property('hitArea', null); - expect(obj).to.have.property('interactive', false); - expect(obj).to.have.property('renderable', false); - expect(obj).to.have.property('stage', null); - }); -}); diff --git a/test/unit/pixi/display/DisplayObjectContainer.js b/test/unit/pixi/display/DisplayObjectContainer.js deleted file mode 100644 index 15a3376..0000000 --- a/test/unit/pixi/display/DisplayObjectContainer.js +++ /dev/null @@ -1,67 +0,0 @@ -describe('pixi/display/DisplayObjectContainer', function () { - 'use strict'; - - var expect = chai.expect; - var DisplayObjectContainer = PIXI.DisplayObjectContainer; - - it('Module exists', function () { - expect(DisplayObjectContainer).to.be.a('function'); - }); - - it('Confirm new instance', function () { - var obj = new DisplayObjectContainer(); - - pixi_display_DisplayObjectContainer_confirmNew(obj); - expect(obj).to.have.property('hitArea', null); - expect(obj).to.have.property('interactive', false); - expect(obj).to.have.property('renderable', false); - expect(obj).to.have.property('stage', null); - }); - - it('Gets child index', function() { - var container = new PIXI.DisplayObjectContainer(); - var children = []; - for (var i = 0; i < 10; i++) { - var child = new PIXI.DisplayObject(); - children.push(child); - container.addChild(child); - } - - for (i = 0; i < children.length; i++) { - expect(i).to.eql(container.getChildIndex(children[i])); - } - }); - - it('throws error when trying to get index of not a child', function() { - var container = new PIXI.DisplayObjectContainer(); - var child = new PIXI.DisplayObject(); - - expect(function() { container.getChildIndex(child); }).to.throw(); - }); - - it('Sets child index', function() { - var container = new PIXI.DisplayObjectContainer(); - var children = []; - - for (var i = 0; i < 10; i++) { - var child = new PIXI.DisplayObject(); - children.push(child); - container.addChild(child); - } - children.reverse(); - - for (i = 0; i < children.length; i++) { - container.setChildIndex(children[i], i); - expect(i).to.eql(container.getChildIndex(children[i])); - } - }); - - it('throws error when trying to set incorect index', function() { - var container = new PIXI.DisplayObjectContainer(); - var child = new PIXI.DisplayObject(); - container.addChild(child); - - expect(function() { container.setChildIndex(child, -1); }).to.throw(); - expect(function() { container.setChildIndex(child, 1); }).to.throw(); - }); -}); diff --git a/test/unit/pixi/display/MovieClip.js b/test/unit/pixi/display/MovieClip.js deleted file mode 100644 index f3c6c6a..0000000 --- a/test/unit/pixi/display/MovieClip.js +++ /dev/null @@ -1,33 +0,0 @@ -describe('pixi/display/MovieClip', function () { - 'use strict'; - - var expect = chai.expect; - var MovieClip = PIXI.MovieClip; - var Texture = PIXI.Texture; - - it('Module exists', function () { - expect(MovieClip).to.be.a('function'); - }); - - it('Confirm new instance', function (done) { - var texture = Texture.fromImage('/base/test/textures/SpriteSheet-Explosion.png'); - var obj = new MovieClip([texture]); - - pixi_display_Sprite_confirmNew(obj, done); - - expect(obj).to.be.an.instanceof(MovieClip); - expect(obj).to.respondTo('stop'); - expect(obj).to.respondTo('play'); - expect(obj).to.respondTo('gotoAndStop'); - expect(obj).to.respondTo('gotoAndPlay'); - expect(obj).to.respondTo('updateTransform'); - - expect(obj).to.have.deep.property('textures.length', 1); - expect(obj).to.have.deep.property('textures[0]', texture); - expect(obj).to.have.property('animationSpeed', 1); - expect(obj).to.have.property('loop', true); - expect(obj).to.have.property('onComplete', null); - expect(obj).to.have.property('currentFrame', 0); - expect(obj).to.have.property('playing', false); - }); -}); diff --git a/test/unit/pixi/display/Sprite.js b/test/unit/pixi/display/Sprite.js deleted file mode 100644 index 30c8076..0000000 --- a/test/unit/pixi/display/Sprite.js +++ /dev/null @@ -1,28 +0,0 @@ -describe('pixi/display/Sprite', function () { - 'use strict'; - - var expect = chai.expect; - var Sprite = PIXI.Sprite; - var Texture = PIXI.Texture; - - it('Module exists', function () { - expect(Sprite).to.be.a('function'); - expect(PIXI).to.have.deep.property('blendModes.NORMAL', 0); - expect(PIXI).to.have.deep.property('blendModes.ADD', 1); - expect(PIXI).to.have.deep.property('blendModes.MULTIPLY', 2); - expect(PIXI).to.have.deep.property('blendModes.SCREEN', 3); - }); - - - it('Members exist', function () { - expect(Sprite).itself.to.respondTo('fromImage'); - expect(Sprite).itself.to.respondTo('fromFrame'); - }); - - it('Confirm new instance', function (done) { - var texture = Texture.fromImage('/base/test/textures/SpriteSheet-Aliens.png'); - var obj = new Sprite(texture); - - pixi_display_Sprite_confirmNew(obj, done); - }); -}); diff --git a/test/unit/pixi/display/Stage.js b/test/unit/pixi/display/Stage.js deleted file mode 100644 index 6974c2e..0000000 --- a/test/unit/pixi/display/Stage.js +++ /dev/null @@ -1,49 +0,0 @@ -describe('pixi/display/Stage', function () { - 'use strict'; - - var expect = chai.expect; - var Stage = PIXI.Stage; - var InteractionManager = PIXI.InteractionManager; - var Rectangle = PIXI.Rectangle; - - it('Module exists', function () { - expect(Stage).to.be.a('function'); - }); - - it('Confirm new instance', function () { - var obj = new Stage(null, true); - - pixi_display_DisplayObjectContainer_confirmNew(obj); - - expect(obj).to.be.an.instanceof(Stage); - expect(obj).to.respondTo('updateTransform'); - expect(obj).to.respondTo('setBackgroundColor'); - expect(obj).to.respondTo('getMousePosition'); - // FIXME: duplicate member in DisplayObject - pixi_core_Matrix_confirmNewMatrix(obj.worldTransform); - // FIXME: convert arg to bool in constructor - expect(obj).to.have.property('interactive', true); - - expect(obj).to.have.property('interactionManager') - .and.to.be.an.instanceof(InteractionManager) - .and.to.have.property('stage', obj); - - expect(obj).to.have.property('dirty', true); - - expect(obj).to.have.property('stage', obj); - - expect(obj).to.have.property('hitArea') - .and.to.be.an.instanceof(Rectangle); - pixi_core_Rectangle_confirm(obj.hitArea, 0, 0, 100000, 100000); - - expect(obj).to.have.property('backgroundColor', 0x000000); - expect(obj).to.have.deep.property('backgroundColorSplit.length', 3); - expect(obj).to.have.deep.property('backgroundColorSplit[0]', 0); - expect(obj).to.have.deep.property('backgroundColorSplit[1]', 0); - expect(obj).to.have.deep.property('backgroundColorSplit[2]', 0); - expect(obj).to.have.property('backgroundColorString', '#000000'); - - - expect(obj).to.have.property('worldVisible', true); - }); -}); diff --git a/test/unit/pixi/extras/Rope.js b/test/unit/pixi/extras/Rope.js deleted file mode 100644 index 05885ac..0000000 --- a/test/unit/pixi/extras/Rope.js +++ /dev/null @@ -1,31 +0,0 @@ -describe('pixi/extras/Rope', function () { - 'use strict'; - - var expect = chai.expect; - var Rope = PIXI.Rope; - var Texture = PIXI.Texture; - var Point = PIXI.Point; - - it('Module exists', function () { - expect(Rope).to.be.a('function'); - }); - - it('Confirm new instance', function () { - - var texture = Texture.fromImage('/base/test/textures/bunny.png'); - - // TODO-Alvin - // Same as Strip - - // var obj = new Rope(texture, [new Point(), new Point(5, 10), new Point(10, 20)]); - - // pixi_extras_Strip_confirmNew(obj); - - // expect(obj).to.be.an.instanceof(Rope); - // expect(obj).to.respondTo('refresh'); - // expect(obj).to.respondTo('updateTransform'); - // expect(obj).to.respondTo('setTexture'); - - // TODO: Test properties - }); -}); diff --git a/test/unit/pixi/extras/Spine.js b/test/unit/pixi/extras/Spine.js deleted file mode 100644 index 0708bc0..0000000 --- a/test/unit/pixi/extras/Spine.js +++ /dev/null @@ -1,10 +0,0 @@ -describe('pixi/extras/Spine', function () { - 'use strict'; - - var expect = chai.expect; - var Spine = PIXI.Spine; - - it('Module exists', function () { - expect(Spine).to.be.a('function'); - }); -}); diff --git a/test/unit/pixi/extras/Strip.js b/test/unit/pixi/extras/Strip.js deleted file mode 100644 index 230af90..0000000 --- a/test/unit/pixi/extras/Strip.js +++ /dev/null @@ -1,26 +0,0 @@ -describe('pixi/extras/Strip', function () { - 'use strict'; - - var expect = chai.expect; - var Strip = PIXI.Strip; - var Texture = PIXI.Texture; - - it('Module exists', function () { - expect(Strip).to.be.a('function'); - }); - - it('Confirm new instance', function () { - - - // TODO-Alvin - // We tweaked it to make it pass the tests, but the whole strip class needs - // to be re-coded - - var texture = Texture.fromImage('/base/test/textures/bunny.png'); - - // var obj = new Strip(texture, 20, 10000); - - - // pixi_extras_Strip_confirmNew(obj); - }); -}); diff --git a/test/unit/pixi/extras/TilingSprite.js b/test/unit/pixi/extras/TilingSprite.js deleted file mode 100644 index 56aea14..0000000 --- a/test/unit/pixi/extras/TilingSprite.js +++ /dev/null @@ -1,24 +0,0 @@ -describe('pixi/extras/TilingSprite', function () { - 'use strict'; - - var expect = chai.expect; - var TilingSprite = PIXI.TilingSprite; - var Texture = PIXI.Texture; - - it('Module exists', function () { - expect(TilingSprite).to.be.a('function'); - }); - - it('Confirm new instance', function () { - var texture = Texture.fromImage('/base/test/textures/bunny.png'); - var obj = new TilingSprite(texture, 6000, 12000); - - pixi_display_DisplayObjectContainer_confirmNew(obj); - - expect(obj).to.be.an.instanceof(TilingSprite); - expect(obj).to.respondTo('setTexture'); - expect(obj).to.respondTo('onTextureUpdate'); - - // TODO: Test properties - }); -}); diff --git a/test/unit/pixi/filters/FilterBlock.js b/test/unit/pixi/filters/FilterBlock.js deleted file mode 100644 index 870cec0..0000000 --- a/test/unit/pixi/filters/FilterBlock.js +++ /dev/null @@ -1,10 +0,0 @@ -describe('pixi/filters/FilterBlock', function () { - 'use strict'; - - var expect = chai.expect; - var FilterBlock = PIXI.FilterBlock; - - it('Module exists', function () { - expect(FilterBlock).to.be.a('function'); - }); -}); diff --git a/test/unit/pixi/loaders/AssetLoader.js b/test/unit/pixi/loaders/AssetLoader.js deleted file mode 100644 index a0aa0b5..0000000 --- a/test/unit/pixi/loaders/AssetLoader.js +++ /dev/null @@ -1,10 +0,0 @@ -describe('pixi/loaders/AssetLoader', function () { - 'use strict'; - - var expect = chai.expect; - var AssetLoader = PIXI.AssetLoader; - - it('Module exists', function () { - expect(AssetLoader).to.be.a('function'); - }); -}); diff --git a/test/unit/pixi/loaders/BitmapFontLoader.js b/test/unit/pixi/loaders/BitmapFontLoader.js deleted file mode 100644 index 046f018..0000000 --- a/test/unit/pixi/loaders/BitmapFontLoader.js +++ /dev/null @@ -1,9 +0,0 @@ -describe('pixi/loaders/BitmapFontLoader', function () { - 'use strict'; - - var expect = chai.expect; - - it('Module exists', function () { - expect(PIXI.BitmapFontLoader).to.be.a('function'); - }); -}); diff --git a/test/unit/pixi/loaders/ImageLoader.js b/test/unit/pixi/loaders/ImageLoader.js deleted file mode 100644 index 8b1f556..0000000 --- a/test/unit/pixi/loaders/ImageLoader.js +++ /dev/null @@ -1,10 +0,0 @@ -describe('pixi/loaders/ImageLoader', function () { - 'use strict'; - - var expect = chai.expect; - var ImageLoader = PIXI.ImageLoader; - - it('Module exists', function () { - expect(ImageLoader).to.be.a('function'); - }); -}); diff --git a/test/unit/pixi/loaders/JsonLoader.js b/test/unit/pixi/loaders/JsonLoader.js deleted file mode 100644 index c577e83..0000000 --- a/test/unit/pixi/loaders/JsonLoader.js +++ /dev/null @@ -1,10 +0,0 @@ -describe('pixi/loaders/JsonLoader', function () { - 'use strict'; - - var expect = chai.expect; - var JsonLoader = PIXI.JsonLoader; - - it('Module exists', function () { - expect(JsonLoader).to.be.a('function'); - }); -}); diff --git a/test/unit/pixi/loaders/SpineLoader.js b/test/unit/pixi/loaders/SpineLoader.js deleted file mode 100644 index fdcc0b8..0000000 --- a/test/unit/pixi/loaders/SpineLoader.js +++ /dev/null @@ -1,10 +0,0 @@ -describe('pixi/loaders/SpineLoader', function () { - 'use strict'; - - var expect = chai.expect; - var SpineLoader = PIXI.SpineLoader; - - it('Module exists', function () { - expect(SpineLoader).to.be.a('function'); - }); -}); diff --git a/test/unit/pixi/loaders/SpriteSheetLoader.js b/test/unit/pixi/loaders/SpriteSheetLoader.js deleted file mode 100644 index 57beb27..0000000 --- a/test/unit/pixi/loaders/SpriteSheetLoader.js +++ /dev/null @@ -1,10 +0,0 @@ -describe('pixi/loaders/SpriteSheetLoader', function () { - 'use strict'; - - var expect = chai.expect; - var SpriteSheetLoader = PIXI.SpriteSheetLoader; - - it('Module exists', function () { - expect(SpriteSheetLoader).to.be.a('function'); - }); -}); diff --git a/test/unit/pixi/primitives/Graphics.js b/test/unit/pixi/primitives/Graphics.js deleted file mode 100644 index f3849eb..0000000 --- a/test/unit/pixi/primitives/Graphics.js +++ /dev/null @@ -1,44 +0,0 @@ -describe('pixi/primitives/Graphics', function () { - 'use strict'; - - var expect = chai.expect; - var Graphics = PIXI.Graphics; - - it('Module exists', function () { - expect(Graphics).to.be.a('function'); - - expect(Graphics).itself.to.have.property('POLY', 0); - expect(Graphics).itself.to.have.property('RECT', 1); - expect(Graphics).itself.to.have.property('CIRC', 2); - expect(Graphics).itself.to.have.property('ELIP', 3); - expect(Graphics).itself.to.have.property('RREC', 4); - }); - - it('Confirm new instance', function () { - var obj = new Graphics(); - - pixi_display_DisplayObjectContainer_confirmNew(obj); - - expect(obj).to.be.an.instanceof(Graphics); - expect(obj).to.respondTo('lineStyle'); - expect(obj).to.respondTo('lineStyle'); - expect(obj).to.respondTo('moveTo'); - expect(obj).to.respondTo('lineTo'); - expect(obj).to.respondTo('beginFill'); - expect(obj).to.respondTo('endFill'); - expect(obj).to.respondTo('drawRect'); - // expect(obj).to.respondTo('drawRoundedRect'); - expect(obj).to.respondTo('drawCircle'); - expect(obj).to.respondTo('drawEllipse'); - expect(obj).to.respondTo('clear'); - - expect(obj).to.have.property('renderable', true); - expect(obj).to.have.property('fillAlpha', 1); - expect(obj).to.have.property('lineWidth', 0); - expect(obj).to.have.property('width', 0); - expect(obj).to.have.property('height', 0); - expect(obj).to.have.property('lineColor', 0); - expect(obj).to.have.deep.property('graphicsData.length', 0); - // expect(obj).to.have.deep.property('currentPath.points.length', 0); - }); -}); diff --git a/test/unit/pixi/renderers/canvas/CanvasGraphics.js b/test/unit/pixi/renderers/canvas/CanvasGraphics.js deleted file mode 100644 index 8f44472..0000000 --- a/test/unit/pixi/renderers/canvas/CanvasGraphics.js +++ /dev/null @@ -1,15 +0,0 @@ -describe('renders/canvas/CanvasGraphics', function () { - 'use strict'; - - var expect = chai.expect; - var CanvasGraphics = PIXI.CanvasGraphics; - - it('Module exists', function () { - expect(CanvasGraphics).to.be.a('function'); - }); - - it('Members exist', function () { - expect(CanvasGraphics).itself.to.respondTo('renderGraphics'); - expect(CanvasGraphics).itself.to.respondTo('renderGraphicsMask'); - }); -}); diff --git a/test/unit/pixi/renderers/canvas/CanvasRenderer.js b/test/unit/pixi/renderers/canvas/CanvasRenderer.js deleted file mode 100644 index 1646444..0000000 --- a/test/unit/pixi/renderers/canvas/CanvasRenderer.js +++ /dev/null @@ -1,36 +0,0 @@ -describe('renderers/canvas/CanvasRenderer', function () { - 'use strict'; - - var expect = chai.expect; - var CanvasRenderer = PIXI.CanvasRenderer; - - it('Module exists', function () { - expect(CanvasRenderer).to.be.a('function'); - }); - - describe('.autoResize', function () { - it('Should automatically resize view if enabled', function () { - var renderer = new CanvasRenderer(200, 200, { - autoResize: true - }); - - expect(renderer.view.style.width).to.equal('200px'); - }); - - it('Should not automatically resize view if disabled', function () { - var renderer = new CanvasRenderer(200, 200, { - autoResize: false - }); - - expect(renderer.view.style.width).to.equal(''); - }); - - it('Should not automatically resize view if not specified', function () { - var renderer = new CanvasRenderer(200, 200, { - resolution: 2 - }); - - expect(renderer.view.style.width).to.equal(''); - }); - }); -}); diff --git a/test/unit/pixi/renderers/webgl/WebGLGraphics.js b/test/unit/pixi/renderers/webgl/WebGLGraphics.js deleted file mode 100644 index 5867b28..0000000 --- a/test/unit/pixi/renderers/webgl/WebGLGraphics.js +++ /dev/null @@ -1,20 +0,0 @@ -describe('renderers/wegbl/WebGLGraphics', function () { - 'use strict'; - - var expect = chai.expect; - var WebGLGraphics = PIXI.WebGLGraphics; - - it('Module exists', function () { - expect(WebGLGraphics).to.be.a('function'); - }); - - it('Members exist', function () { - expect(WebGLGraphics).itself.to.respondTo('renderGraphics'); - expect(WebGLGraphics).itself.to.respondTo('updateGraphics'); - expect(WebGLGraphics).itself.to.respondTo('buildRectangle'); - expect(WebGLGraphics).itself.to.respondTo('buildRoundedRectangle'); - expect(WebGLGraphics).itself.to.respondTo('buildCircle'); - expect(WebGLGraphics).itself.to.respondTo('buildLine'); - expect(WebGLGraphics).itself.to.respondTo('buildPoly'); - }); -}); diff --git a/test/unit/pixi/renderers/webgl/WebGLRenderer.js b/test/unit/pixi/renderers/webgl/WebGLRenderer.js deleted file mode 100644 index 1680a80..0000000 --- a/test/unit/pixi/renderers/webgl/WebGLRenderer.js +++ /dev/null @@ -1,49 +0,0 @@ -describe('renderers/webgl/WebGLRenderer', function () { - 'use strict'; - - var expect = chai.expect; - var WebGLRenderer = PIXI.WebGLRenderer; - - it('Module exists', function () { - expect(WebGLRenderer).to.be.a('function'); - }); - - // Skip tests if WebGL is not available (WebGL not supported in Travis CI) - try { - var renderer = new WebGLRenderer(400, 300, {}); - renderer.destroy(); - } catch (error) { - return; - } - - it('Destroy renderer', function () { - var renderer = new WebGLRenderer(400, 300, {}); - renderer.destroy(); - }); - - describe('.autoResize', function () { - it('Should automatically resize view if enabled', function () { - var renderer = new WebGLRenderer(200, 200, { - autoResize: true - }); - - expect(renderer.view.style.width).to.equal('200px'); - }); - - it('Should not automatically resize view if disabled', function () { - var renderer = new WebGLRenderer(200, 200, { - autoResize: false - }); - - expect(renderer.view.style.width).to.equal(''); - }); - - it('Should not automatically resize view if not specified', function () { - var renderer = new WebGLRenderer(200, 200, { - resolution: 2 - }); - - expect(renderer.view.style.width).to.equal(''); - }); - }); -}); diff --git a/test/unit/pixi/renderers/webgl/WebGLShaders.js b/test/unit/pixi/renderers/webgl/WebGLShaders.js deleted file mode 100644 index 6e33e4f..0000000 --- a/test/unit/pixi/renderers/webgl/WebGLShaders.js +++ /dev/null @@ -1,13 +0,0 @@ -describe('renderers/webgl/WebGLShaders', function () { - 'use strict'; - - var expect = chai.expect; - - it('Module members exist', function () { - - expect(PIXI).to.respondTo('CompileVertexShader'); - expect(PIXI).to.respondTo('CompileFragmentShader'); - expect(PIXI).to.respondTo('_CompileShader'); - expect(PIXI).to.respondTo('compileProgram'); - }); -}); diff --git a/test/unit/pixi/renderers/webgl/WebGLSpriteBatch.js b/test/unit/pixi/renderers/webgl/WebGLSpriteBatch.js deleted file mode 100644 index e662b63..0000000 --- a/test/unit/pixi/renderers/webgl/WebGLSpriteBatch.js +++ /dev/null @@ -1,10 +0,0 @@ -describe('renderers/webgl/utils/WebGLSpriteBatch', function () { - 'use strict'; - - var expect = chai.expect; - var WebGLSpriteBatch = PIXI.WebGLSpriteBatch; - - it('Module exists', function () { - expect(WebGLSpriteBatch).to.be.a('function'); - }); -}); diff --git a/test/unit/pixi/text/BitmapText.js b/test/unit/pixi/text/BitmapText.js deleted file mode 100644 index 9388e3d..0000000 --- a/test/unit/pixi/text/BitmapText.js +++ /dev/null @@ -1,10 +0,0 @@ -describe('pixi/text/BitmapText', function () { - 'use strict'; - - var expect = chai.expect; - var BitmapText = PIXI.BitmapText; - - it('Module exists', function () { - expect(BitmapText).to.be.a('function'); - }); -}); diff --git a/test/unit/pixi-v2/InteractionManager.js b/test/unit/pixi-v2/InteractionManager.js new file mode 100644 index 0000000..ed3001f --- /dev/null +++ b/test/unit/pixi-v2/InteractionManager.js @@ -0,0 +1,10 @@ +describe('pixi/InteractionManager', function () { + 'use strict'; + + var expect = chai.expect; + var InteractionManager = PIXI.InteractionManager; + + it('Module exists', function () { + expect(InteractionManager).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/Pixi.js b/test/unit/pixi-v2/Pixi.js new file mode 100644 index 0000000..27debc1 --- /dev/null +++ b/test/unit/pixi-v2/Pixi.js @@ -0,0 +1,9 @@ +describe('pixi/Pixi', function () { + 'use strict'; + + var expect = chai.expect; + + it('Module exists', function () { + expect(global).to.have.property('PIXI').and.to.be.an('object'); + }); +}); diff --git a/test/unit/pixi-v2/core/Circle.js b/test/unit/pixi-v2/core/Circle.js new file mode 100644 index 0000000..fbcfa17 --- /dev/null +++ b/test/unit/pixi-v2/core/Circle.js @@ -0,0 +1,21 @@ +describe('pixi/core/Circle', function () { + 'use strict'; + + var expect = chai.expect; + var Circle = PIXI.Circle; + + it('Module exists', function () { + expect(Circle).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Circle(); + pixi_core_Circle_confirmNewCircle(obj); + }); + + it("getBounds should return Rectangle that bounds the circle", function() { + var obj = new Circle(100, 250, 50); + var bounds = obj.getBounds(); + pixi_core_Circle_isBoundedByRectangle(obj, bounds); + }); +}); diff --git a/test/unit/pixi-v2/core/Ellipse.js b/test/unit/pixi-v2/core/Ellipse.js new file mode 100644 index 0000000..026b56f --- /dev/null +++ b/test/unit/pixi-v2/core/Ellipse.js @@ -0,0 +1,24 @@ +describe('pixi/core/Ellipse', function () { + 'use strict'; + + var expect = chai.expect; + var Ellipse = PIXI.Ellipse; + + it('Module exists', function () { + expect(Ellipse).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Ellipse(); + + expect(obj).to.be.an.instanceof(Ellipse); + expect(obj).to.respondTo('clone'); + expect(obj).to.respondTo('contains'); + expect(obj).to.respondTo('getBounds'); + + expect(obj).to.have.property('x', 0); + expect(obj).to.have.property('y', 0); + expect(obj).to.have.property('width', 0); + expect(obj).to.have.property('height', 0); + }); +}); diff --git a/test/unit/pixi-v2/core/Matrix.js b/test/unit/pixi-v2/core/Matrix.js new file mode 100644 index 0000000..da75e2e --- /dev/null +++ b/test/unit/pixi-v2/core/Matrix.js @@ -0,0 +1,14 @@ +describe('pixi/core/Matrix', function () { + 'use strict'; + + var expect = chai.expect; + + it('Matrix exists', function () { + expect(PIXI.Matrix).to.be.an('function'); + }); + + it('Confirm new Matrix', function () { + var matrix = new PIXI.Matrix(); + pixi_core_Matrix_confirmNewMatrix(matrix); + }); +}); diff --git a/test/unit/pixi-v2/core/Point.js b/test/unit/pixi-v2/core/Point.js new file mode 100644 index 0000000..c4d5163 --- /dev/null +++ b/test/unit/pixi-v2/core/Point.js @@ -0,0 +1,15 @@ +describe('pixi/core/Point', function () { + 'use strict'; + + var expect = chai.expect; + var Point = PIXI.Point; + + it('Module exists', function () { + expect(Point).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Point(); + pixi_core_Point_confirm(obj, 0, 0); + }); +}); diff --git a/test/unit/pixi-v2/core/Polygon.js b/test/unit/pixi-v2/core/Polygon.js new file mode 100644 index 0000000..dc8c918 --- /dev/null +++ b/test/unit/pixi-v2/core/Polygon.js @@ -0,0 +1,20 @@ +describe('pixi/core/Polygon', function () { + 'use strict'; + + var expect = chai.expect; + var Polygon = PIXI.Polygon; + + it('Module exists', function () { + expect(Polygon).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Polygon(); + + expect(obj).to.be.an.instanceof(Polygon); + expect(obj).to.respondTo('clone'); + expect(obj).to.respondTo('contains'); + + expect(obj).to.have.deep.property('points.length', 0); + }); +}); diff --git a/test/unit/pixi-v2/core/Rectangle.js b/test/unit/pixi-v2/core/Rectangle.js new file mode 100644 index 0000000..d43316e --- /dev/null +++ b/test/unit/pixi-v2/core/Rectangle.js @@ -0,0 +1,15 @@ +describe('pixi/core/Rectangle', function () { + 'use strict'; + + var expect = chai.expect; + var Rectangle = PIXI.Rectangle; + + it('Module exists', function () { + expect(Rectangle).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var rect = new Rectangle(); + pixi_core_Rectangle_confirm(rect, 0, 0, 0, 0); + }); +}); diff --git a/test/unit/pixi-v2/display/DisplayObject.js b/test/unit/pixi-v2/display/DisplayObject.js new file mode 100644 index 0000000..044acf8 --- /dev/null +++ b/test/unit/pixi-v2/display/DisplayObject.js @@ -0,0 +1,21 @@ +describe('pixi/display/DisplayObject', function () { + 'use strict'; + + var expect = chai.expect; + var DisplayObject = PIXI.DisplayObject; + + it('Module exists', function () { + expect(DisplayObject).to.be.a('function'); + // expect(PIXI).to.have.property('visibleCount', 0); + }); + + it('Confirm new instance', function () { + var obj = new DisplayObject(); + + pixi_display_DisplayObject_confirmNew(obj); + expect(obj).to.have.property('hitArea', null); + expect(obj).to.have.property('interactive', false); + expect(obj).to.have.property('renderable', false); + expect(obj).to.have.property('stage', null); + }); +}); diff --git a/test/unit/pixi-v2/display/DisplayObjectContainer.js b/test/unit/pixi-v2/display/DisplayObjectContainer.js new file mode 100644 index 0000000..15a3376 --- /dev/null +++ b/test/unit/pixi-v2/display/DisplayObjectContainer.js @@ -0,0 +1,67 @@ +describe('pixi/display/DisplayObjectContainer', function () { + 'use strict'; + + var expect = chai.expect; + var DisplayObjectContainer = PIXI.DisplayObjectContainer; + + it('Module exists', function () { + expect(DisplayObjectContainer).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new DisplayObjectContainer(); + + pixi_display_DisplayObjectContainer_confirmNew(obj); + expect(obj).to.have.property('hitArea', null); + expect(obj).to.have.property('interactive', false); + expect(obj).to.have.property('renderable', false); + expect(obj).to.have.property('stage', null); + }); + + it('Gets child index', function() { + var container = new PIXI.DisplayObjectContainer(); + var children = []; + for (var i = 0; i < 10; i++) { + var child = new PIXI.DisplayObject(); + children.push(child); + container.addChild(child); + } + + for (i = 0; i < children.length; i++) { + expect(i).to.eql(container.getChildIndex(children[i])); + } + }); + + it('throws error when trying to get index of not a child', function() { + var container = new PIXI.DisplayObjectContainer(); + var child = new PIXI.DisplayObject(); + + expect(function() { container.getChildIndex(child); }).to.throw(); + }); + + it('Sets child index', function() { + var container = new PIXI.DisplayObjectContainer(); + var children = []; + + for (var i = 0; i < 10; i++) { + var child = new PIXI.DisplayObject(); + children.push(child); + container.addChild(child); + } + children.reverse(); + + for (i = 0; i < children.length; i++) { + container.setChildIndex(children[i], i); + expect(i).to.eql(container.getChildIndex(children[i])); + } + }); + + it('throws error when trying to set incorect index', function() { + var container = new PIXI.DisplayObjectContainer(); + var child = new PIXI.DisplayObject(); + container.addChild(child); + + expect(function() { container.setChildIndex(child, -1); }).to.throw(); + expect(function() { container.setChildIndex(child, 1); }).to.throw(); + }); +}); diff --git a/test/unit/pixi-v2/display/MovieClip.js b/test/unit/pixi-v2/display/MovieClip.js new file mode 100644 index 0000000..f3c6c6a --- /dev/null +++ b/test/unit/pixi-v2/display/MovieClip.js @@ -0,0 +1,33 @@ +describe('pixi/display/MovieClip', function () { + 'use strict'; + + var expect = chai.expect; + var MovieClip = PIXI.MovieClip; + var Texture = PIXI.Texture; + + it('Module exists', function () { + expect(MovieClip).to.be.a('function'); + }); + + it('Confirm new instance', function (done) { + var texture = Texture.fromImage('/base/test/textures/SpriteSheet-Explosion.png'); + var obj = new MovieClip([texture]); + + pixi_display_Sprite_confirmNew(obj, done); + + expect(obj).to.be.an.instanceof(MovieClip); + expect(obj).to.respondTo('stop'); + expect(obj).to.respondTo('play'); + expect(obj).to.respondTo('gotoAndStop'); + expect(obj).to.respondTo('gotoAndPlay'); + expect(obj).to.respondTo('updateTransform'); + + expect(obj).to.have.deep.property('textures.length', 1); + expect(obj).to.have.deep.property('textures[0]', texture); + expect(obj).to.have.property('animationSpeed', 1); + expect(obj).to.have.property('loop', true); + expect(obj).to.have.property('onComplete', null); + expect(obj).to.have.property('currentFrame', 0); + expect(obj).to.have.property('playing', false); + }); +}); diff --git a/test/unit/pixi-v2/display/Sprite.js b/test/unit/pixi-v2/display/Sprite.js new file mode 100644 index 0000000..30c8076 --- /dev/null +++ b/test/unit/pixi-v2/display/Sprite.js @@ -0,0 +1,28 @@ +describe('pixi/display/Sprite', function () { + 'use strict'; + + var expect = chai.expect; + var Sprite = PIXI.Sprite; + var Texture = PIXI.Texture; + + it('Module exists', function () { + expect(Sprite).to.be.a('function'); + expect(PIXI).to.have.deep.property('blendModes.NORMAL', 0); + expect(PIXI).to.have.deep.property('blendModes.ADD', 1); + expect(PIXI).to.have.deep.property('blendModes.MULTIPLY', 2); + expect(PIXI).to.have.deep.property('blendModes.SCREEN', 3); + }); + + + it('Members exist', function () { + expect(Sprite).itself.to.respondTo('fromImage'); + expect(Sprite).itself.to.respondTo('fromFrame'); + }); + + it('Confirm new instance', function (done) { + var texture = Texture.fromImage('/base/test/textures/SpriteSheet-Aliens.png'); + var obj = new Sprite(texture); + + pixi_display_Sprite_confirmNew(obj, done); + }); +}); diff --git a/test/unit/pixi-v2/display/Stage.js b/test/unit/pixi-v2/display/Stage.js new file mode 100644 index 0000000..6974c2e --- /dev/null +++ b/test/unit/pixi-v2/display/Stage.js @@ -0,0 +1,49 @@ +describe('pixi/display/Stage', function () { + 'use strict'; + + var expect = chai.expect; + var Stage = PIXI.Stage; + var InteractionManager = PIXI.InteractionManager; + var Rectangle = PIXI.Rectangle; + + it('Module exists', function () { + expect(Stage).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Stage(null, true); + + pixi_display_DisplayObjectContainer_confirmNew(obj); + + expect(obj).to.be.an.instanceof(Stage); + expect(obj).to.respondTo('updateTransform'); + expect(obj).to.respondTo('setBackgroundColor'); + expect(obj).to.respondTo('getMousePosition'); + // FIXME: duplicate member in DisplayObject + pixi_core_Matrix_confirmNewMatrix(obj.worldTransform); + // FIXME: convert arg to bool in constructor + expect(obj).to.have.property('interactive', true); + + expect(obj).to.have.property('interactionManager') + .and.to.be.an.instanceof(InteractionManager) + .and.to.have.property('stage', obj); + + expect(obj).to.have.property('dirty', true); + + expect(obj).to.have.property('stage', obj); + + expect(obj).to.have.property('hitArea') + .and.to.be.an.instanceof(Rectangle); + pixi_core_Rectangle_confirm(obj.hitArea, 0, 0, 100000, 100000); + + expect(obj).to.have.property('backgroundColor', 0x000000); + expect(obj).to.have.deep.property('backgroundColorSplit.length', 3); + expect(obj).to.have.deep.property('backgroundColorSplit[0]', 0); + expect(obj).to.have.deep.property('backgroundColorSplit[1]', 0); + expect(obj).to.have.deep.property('backgroundColorSplit[2]', 0); + expect(obj).to.have.property('backgroundColorString', '#000000'); + + + expect(obj).to.have.property('worldVisible', true); + }); +}); diff --git a/test/unit/pixi-v2/extras/Rope.js b/test/unit/pixi-v2/extras/Rope.js new file mode 100644 index 0000000..05885ac --- /dev/null +++ b/test/unit/pixi-v2/extras/Rope.js @@ -0,0 +1,31 @@ +describe('pixi/extras/Rope', function () { + 'use strict'; + + var expect = chai.expect; + var Rope = PIXI.Rope; + var Texture = PIXI.Texture; + var Point = PIXI.Point; + + it('Module exists', function () { + expect(Rope).to.be.a('function'); + }); + + it('Confirm new instance', function () { + + var texture = Texture.fromImage('/base/test/textures/bunny.png'); + + // TODO-Alvin + // Same as Strip + + // var obj = new Rope(texture, [new Point(), new Point(5, 10), new Point(10, 20)]); + + // pixi_extras_Strip_confirmNew(obj); + + // expect(obj).to.be.an.instanceof(Rope); + // expect(obj).to.respondTo('refresh'); + // expect(obj).to.respondTo('updateTransform'); + // expect(obj).to.respondTo('setTexture'); + + // TODO: Test properties + }); +}); diff --git a/test/unit/pixi-v2/extras/Spine.js b/test/unit/pixi-v2/extras/Spine.js new file mode 100644 index 0000000..0708bc0 --- /dev/null +++ b/test/unit/pixi-v2/extras/Spine.js @@ -0,0 +1,10 @@ +describe('pixi/extras/Spine', function () { + 'use strict'; + + var expect = chai.expect; + var Spine = PIXI.Spine; + + it('Module exists', function () { + expect(Spine).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/extras/Strip.js b/test/unit/pixi-v2/extras/Strip.js new file mode 100644 index 0000000..230af90 --- /dev/null +++ b/test/unit/pixi-v2/extras/Strip.js @@ -0,0 +1,26 @@ +describe('pixi/extras/Strip', function () { + 'use strict'; + + var expect = chai.expect; + var Strip = PIXI.Strip; + var Texture = PIXI.Texture; + + it('Module exists', function () { + expect(Strip).to.be.a('function'); + }); + + it('Confirm new instance', function () { + + + // TODO-Alvin + // We tweaked it to make it pass the tests, but the whole strip class needs + // to be re-coded + + var texture = Texture.fromImage('/base/test/textures/bunny.png'); + + // var obj = new Strip(texture, 20, 10000); + + + // pixi_extras_Strip_confirmNew(obj); + }); +}); diff --git a/test/unit/pixi-v2/extras/TilingSprite.js b/test/unit/pixi-v2/extras/TilingSprite.js new file mode 100644 index 0000000..56aea14 --- /dev/null +++ b/test/unit/pixi-v2/extras/TilingSprite.js @@ -0,0 +1,24 @@ +describe('pixi/extras/TilingSprite', function () { + 'use strict'; + + var expect = chai.expect; + var TilingSprite = PIXI.TilingSprite; + var Texture = PIXI.Texture; + + it('Module exists', function () { + expect(TilingSprite).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var texture = Texture.fromImage('/base/test/textures/bunny.png'); + var obj = new TilingSprite(texture, 6000, 12000); + + pixi_display_DisplayObjectContainer_confirmNew(obj); + + expect(obj).to.be.an.instanceof(TilingSprite); + expect(obj).to.respondTo('setTexture'); + expect(obj).to.respondTo('onTextureUpdate'); + + // TODO: Test properties + }); +}); diff --git a/test/unit/pixi-v2/filters/FilterBlock.js b/test/unit/pixi-v2/filters/FilterBlock.js new file mode 100644 index 0000000..870cec0 --- /dev/null +++ b/test/unit/pixi-v2/filters/FilterBlock.js @@ -0,0 +1,10 @@ +describe('pixi/filters/FilterBlock', function () { + 'use strict'; + + var expect = chai.expect; + var FilterBlock = PIXI.FilterBlock; + + it('Module exists', function () { + expect(FilterBlock).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/AssetLoader.js b/test/unit/pixi-v2/loaders/AssetLoader.js new file mode 100644 index 0000000..a0aa0b5 --- /dev/null +++ b/test/unit/pixi-v2/loaders/AssetLoader.js @@ -0,0 +1,10 @@ +describe('pixi/loaders/AssetLoader', function () { + 'use strict'; + + var expect = chai.expect; + var AssetLoader = PIXI.AssetLoader; + + it('Module exists', function () { + expect(AssetLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/BitmapFontLoader.js b/test/unit/pixi-v2/loaders/BitmapFontLoader.js new file mode 100644 index 0000000..046f018 --- /dev/null +++ b/test/unit/pixi-v2/loaders/BitmapFontLoader.js @@ -0,0 +1,9 @@ +describe('pixi/loaders/BitmapFontLoader', function () { + 'use strict'; + + var expect = chai.expect; + + it('Module exists', function () { + expect(PIXI.BitmapFontLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/ImageLoader.js b/test/unit/pixi-v2/loaders/ImageLoader.js new file mode 100644 index 0000000..8b1f556 --- /dev/null +++ b/test/unit/pixi-v2/loaders/ImageLoader.js @@ -0,0 +1,10 @@ +describe('pixi/loaders/ImageLoader', function () { + 'use strict'; + + var expect = chai.expect; + var ImageLoader = PIXI.ImageLoader; + + it('Module exists', function () { + expect(ImageLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/JsonLoader.js b/test/unit/pixi-v2/loaders/JsonLoader.js new file mode 100644 index 0000000..c577e83 --- /dev/null +++ b/test/unit/pixi-v2/loaders/JsonLoader.js @@ -0,0 +1,10 @@ +describe('pixi/loaders/JsonLoader', function () { + 'use strict'; + + var expect = chai.expect; + var JsonLoader = PIXI.JsonLoader; + + it('Module exists', function () { + expect(JsonLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/SpineLoader.js b/test/unit/pixi-v2/loaders/SpineLoader.js new file mode 100644 index 0000000..fdcc0b8 --- /dev/null +++ b/test/unit/pixi-v2/loaders/SpineLoader.js @@ -0,0 +1,10 @@ +describe('pixi/loaders/SpineLoader', function () { + 'use strict'; + + var expect = chai.expect; + var SpineLoader = PIXI.SpineLoader; + + it('Module exists', function () { + expect(SpineLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/SpriteSheetLoader.js b/test/unit/pixi-v2/loaders/SpriteSheetLoader.js new file mode 100644 index 0000000..57beb27 --- /dev/null +++ b/test/unit/pixi-v2/loaders/SpriteSheetLoader.js @@ -0,0 +1,10 @@ +describe('pixi/loaders/SpriteSheetLoader', function () { + 'use strict'; + + var expect = chai.expect; + var SpriteSheetLoader = PIXI.SpriteSheetLoader; + + it('Module exists', function () { + expect(SpriteSheetLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/primitives/Graphics.js b/test/unit/pixi-v2/primitives/Graphics.js new file mode 100644 index 0000000..f3849eb --- /dev/null +++ b/test/unit/pixi-v2/primitives/Graphics.js @@ -0,0 +1,44 @@ +describe('pixi/primitives/Graphics', function () { + 'use strict'; + + var expect = chai.expect; + var Graphics = PIXI.Graphics; + + it('Module exists', function () { + expect(Graphics).to.be.a('function'); + + expect(Graphics).itself.to.have.property('POLY', 0); + expect(Graphics).itself.to.have.property('RECT', 1); + expect(Graphics).itself.to.have.property('CIRC', 2); + expect(Graphics).itself.to.have.property('ELIP', 3); + expect(Graphics).itself.to.have.property('RREC', 4); + }); + + it('Confirm new instance', function () { + var obj = new Graphics(); + + pixi_display_DisplayObjectContainer_confirmNew(obj); + + expect(obj).to.be.an.instanceof(Graphics); + expect(obj).to.respondTo('lineStyle'); + expect(obj).to.respondTo('lineStyle'); + expect(obj).to.respondTo('moveTo'); + expect(obj).to.respondTo('lineTo'); + expect(obj).to.respondTo('beginFill'); + expect(obj).to.respondTo('endFill'); + expect(obj).to.respondTo('drawRect'); + // expect(obj).to.respondTo('drawRoundedRect'); + expect(obj).to.respondTo('drawCircle'); + expect(obj).to.respondTo('drawEllipse'); + expect(obj).to.respondTo('clear'); + + expect(obj).to.have.property('renderable', true); + expect(obj).to.have.property('fillAlpha', 1); + expect(obj).to.have.property('lineWidth', 0); + expect(obj).to.have.property('width', 0); + expect(obj).to.have.property('height', 0); + expect(obj).to.have.property('lineColor', 0); + expect(obj).to.have.deep.property('graphicsData.length', 0); + // expect(obj).to.have.deep.property('currentPath.points.length', 0); + }); +}); diff --git a/test/unit/pixi-v2/renderers/canvas/CanvasGraphics.js b/test/unit/pixi-v2/renderers/canvas/CanvasGraphics.js new file mode 100644 index 0000000..8f44472 --- /dev/null +++ b/test/unit/pixi-v2/renderers/canvas/CanvasGraphics.js @@ -0,0 +1,15 @@ +describe('renders/canvas/CanvasGraphics', function () { + 'use strict'; + + var expect = chai.expect; + var CanvasGraphics = PIXI.CanvasGraphics; + + it('Module exists', function () { + expect(CanvasGraphics).to.be.a('function'); + }); + + it('Members exist', function () { + expect(CanvasGraphics).itself.to.respondTo('renderGraphics'); + expect(CanvasGraphics).itself.to.respondTo('renderGraphicsMask'); + }); +}); diff --git a/test/unit/pixi-v2/renderers/canvas/CanvasRenderer.js b/test/unit/pixi-v2/renderers/canvas/CanvasRenderer.js new file mode 100644 index 0000000..1646444 --- /dev/null +++ b/test/unit/pixi-v2/renderers/canvas/CanvasRenderer.js @@ -0,0 +1,36 @@ +describe('renderers/canvas/CanvasRenderer', function () { + 'use strict'; + + var expect = chai.expect; + var CanvasRenderer = PIXI.CanvasRenderer; + + it('Module exists', function () { + expect(CanvasRenderer).to.be.a('function'); + }); + + describe('.autoResize', function () { + it('Should automatically resize view if enabled', function () { + var renderer = new CanvasRenderer(200, 200, { + autoResize: true + }); + + expect(renderer.view.style.width).to.equal('200px'); + }); + + it('Should not automatically resize view if disabled', function () { + var renderer = new CanvasRenderer(200, 200, { + autoResize: false + }); + + expect(renderer.view.style.width).to.equal(''); + }); + + it('Should not automatically resize view if not specified', function () { + var renderer = new CanvasRenderer(200, 200, { + resolution: 2 + }); + + expect(renderer.view.style.width).to.equal(''); + }); + }); +}); diff --git a/test/unit/pixi-v2/renderers/webgl/WebGLGraphics.js b/test/unit/pixi-v2/renderers/webgl/WebGLGraphics.js new file mode 100644 index 0000000..5867b28 --- /dev/null +++ b/test/unit/pixi-v2/renderers/webgl/WebGLGraphics.js @@ -0,0 +1,20 @@ +describe('renderers/wegbl/WebGLGraphics', function () { + 'use strict'; + + var expect = chai.expect; + var WebGLGraphics = PIXI.WebGLGraphics; + + it('Module exists', function () { + expect(WebGLGraphics).to.be.a('function'); + }); + + it('Members exist', function () { + expect(WebGLGraphics).itself.to.respondTo('renderGraphics'); + expect(WebGLGraphics).itself.to.respondTo('updateGraphics'); + expect(WebGLGraphics).itself.to.respondTo('buildRectangle'); + expect(WebGLGraphics).itself.to.respondTo('buildRoundedRectangle'); + expect(WebGLGraphics).itself.to.respondTo('buildCircle'); + expect(WebGLGraphics).itself.to.respondTo('buildLine'); + expect(WebGLGraphics).itself.to.respondTo('buildPoly'); + }); +}); diff --git a/test/unit/pixi-v2/renderers/webgl/WebGLRenderer.js b/test/unit/pixi-v2/renderers/webgl/WebGLRenderer.js new file mode 100644 index 0000000..1680a80 --- /dev/null +++ b/test/unit/pixi-v2/renderers/webgl/WebGLRenderer.js @@ -0,0 +1,49 @@ +describe('renderers/webgl/WebGLRenderer', function () { + 'use strict'; + + var expect = chai.expect; + var WebGLRenderer = PIXI.WebGLRenderer; + + it('Module exists', function () { + expect(WebGLRenderer).to.be.a('function'); + }); + + // Skip tests if WebGL is not available (WebGL not supported in Travis CI) + try { + var renderer = new WebGLRenderer(400, 300, {}); + renderer.destroy(); + } catch (error) { + return; + } + + it('Destroy renderer', function () { + var renderer = new WebGLRenderer(400, 300, {}); + renderer.destroy(); + }); + + describe('.autoResize', function () { + it('Should automatically resize view if enabled', function () { + var renderer = new WebGLRenderer(200, 200, { + autoResize: true + }); + + expect(renderer.view.style.width).to.equal('200px'); + }); + + it('Should not automatically resize view if disabled', function () { + var renderer = new WebGLRenderer(200, 200, { + autoResize: false + }); + + expect(renderer.view.style.width).to.equal(''); + }); + + it('Should not automatically resize view if not specified', function () { + var renderer = new WebGLRenderer(200, 200, { + resolution: 2 + }); + + expect(renderer.view.style.width).to.equal(''); + }); + }); +}); diff --git a/test/unit/pixi-v2/renderers/webgl/WebGLShaders.js b/test/unit/pixi-v2/renderers/webgl/WebGLShaders.js new file mode 100644 index 0000000..6e33e4f --- /dev/null +++ b/test/unit/pixi-v2/renderers/webgl/WebGLShaders.js @@ -0,0 +1,13 @@ +describe('renderers/webgl/WebGLShaders', function () { + 'use strict'; + + var expect = chai.expect; + + it('Module members exist', function () { + + expect(PIXI).to.respondTo('CompileVertexShader'); + expect(PIXI).to.respondTo('CompileFragmentShader'); + expect(PIXI).to.respondTo('_CompileShader'); + expect(PIXI).to.respondTo('compileProgram'); + }); +}); diff --git a/test/unit/pixi-v2/renderers/webgl/WebGLSpriteBatch.js b/test/unit/pixi-v2/renderers/webgl/WebGLSpriteBatch.js new file mode 100644 index 0000000..e662b63 --- /dev/null +++ b/test/unit/pixi-v2/renderers/webgl/WebGLSpriteBatch.js @@ -0,0 +1,10 @@ +describe('renderers/webgl/utils/WebGLSpriteBatch', function () { + 'use strict'; + + var expect = chai.expect; + var WebGLSpriteBatch = PIXI.WebGLSpriteBatch; + + it('Module exists', function () { + expect(WebGLSpriteBatch).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/text/BitmapText.js b/test/unit/pixi-v2/text/BitmapText.js new file mode 100644 index 0000000..9388e3d --- /dev/null +++ b/test/unit/pixi-v2/text/BitmapText.js @@ -0,0 +1,10 @@ +describe('pixi/text/BitmapText', function () { + 'use strict'; + + var expect = chai.expect; + var BitmapText = PIXI.BitmapText; + + it('Module exists', function () { + expect(BitmapText).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/text/Text.js b/test/unit/pixi-v2/text/Text.js new file mode 100644 index 0000000..9bc9ac5 --- /dev/null +++ b/test/unit/pixi-v2/text/Text.js @@ -0,0 +1,10 @@ +describe('pixi/text/Text', function () { + 'use strict'; + + var expect = chai.expect; + var Text = PIXI.Text; + + it('Module exists', function () { + expect(Text).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/textures/BaseTexture.js b/test/unit/pixi-v2/textures/BaseTexture.js new file mode 100644 index 0000000..502b724 --- /dev/null +++ b/test/unit/pixi-v2/textures/BaseTexture.js @@ -0,0 +1,11 @@ +describe('pixi/textures/BaseTexture', function () { + 'use strict'; + + var expect = chai.expect; + var BaseTexture = PIXI.BaseTexture; + + it('Module exists', function () { + expect(BaseTexture).to.be.a('function'); + expect(PIXI).to.have.property('BaseTextureCache').and.to.be.an('object'); + }); +}); diff --git a/test/unit/pixi-v2/textures/RenderTexture.js b/test/unit/pixi-v2/textures/RenderTexture.js new file mode 100644 index 0000000..96acdb4 --- /dev/null +++ b/test/unit/pixi-v2/textures/RenderTexture.js @@ -0,0 +1,15 @@ +describe('pixi/textures/RenderTexture', function () { + 'use strict'; + + var expect = chai.expect; + var RenderTexture = PIXI.RenderTexture; + + it('Module exists', function () { + expect(RenderTexture).to.be.a('function'); + }); + + it('Confirm new instance', function (done) { + var texture = new RenderTexture(100, 100, new PIXI.CanvasRenderer()); + pixi_textures_RenderTexture_confirmNew(texture, done); + }); +}); diff --git a/test/unit/pixi-v2/textures/Texture.js b/test/unit/pixi-v2/textures/Texture.js new file mode 100644 index 0000000..090f64d --- /dev/null +++ b/test/unit/pixi-v2/textures/Texture.js @@ -0,0 +1,26 @@ +describe('pixi/textures/Texture', function () { + 'use strict'; + + var expect = chai.expect; + var Texture = PIXI.Texture; + + it('Module exists', function () { + expect(Texture).to.be.a('function'); + expect(PIXI).to.have.property('TextureCache').and.to.be.an('object'); + }); + + it('Members exist', function () { + expect(Texture).itself.to.respondTo('fromImage'); + expect(Texture).itself.to.respondTo('fromFrame'); + expect(Texture).itself.to.respondTo('fromCanvas'); + expect(Texture).itself.to.respondTo('addTextureToCache'); + expect(Texture).itself.to.respondTo('removeTextureFromCache'); + + // expect(Texture).itself.to.have.deep.property('frameUpdates.length', 0); + }); + + it('Confirm new instance', function (done) { + var texture = Texture.fromImage('/base/test/textures/bunny.png'); + pixi_textures_Texture_confirmNew(texture, done); + }); +}); diff --git a/test/unit/pixi-v2/utils/Detector.js b/test/unit/pixi-v2/utils/Detector.js new file mode 100644 index 0000000..4cf6008 --- /dev/null +++ b/test/unit/pixi-v2/utils/Detector.js @@ -0,0 +1,10 @@ +describe('pixi/utils/Detector', function () { + 'use strict'; + + var expect = chai.expect; + var autoDetectRenderer = PIXI.autoDetectRenderer; + + it('Module exists', function () { + expect(autoDetectRenderer).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/utils/EventTarget.js b/test/unit/pixi-v2/utils/EventTarget.js new file mode 100644 index 0000000..1cfc3a4 --- /dev/null +++ b/test/unit/pixi-v2/utils/EventTarget.js @@ -0,0 +1,361 @@ +describe('pixi/utils/EventTarget', function () { + 'use strict'; + + var expect = chai.expect; + + var Clazz, PClazz, obj, pobj, obj2; + beforeEach(function () { + Clazz = function () {}; + PClazz = function () {}; + + PIXI.EventTarget.mixin(Clazz.prototype); + PIXI.EventTarget.mixin(PClazz.prototype); + + obj = new Clazz(); + obj2 = new Clazz(); + pobj = new PClazz(); + + obj.parent = pobj; + obj2.parent = obj; + }); + + it('Module exists', function () { + expect(PIXI.EventTarget).to.be.an('object'); + }); + + it('Confirm new instance', function () { + pixi_utils_EventTarget_confirm(obj); + }); + + it('simple on/emit case works', function () { + var myData = {}; + + obj.on('myevent', function (event) { + pixi_utils_EventTarget_Event_confirm(event, obj, myData); + }); + + obj.emit('myevent', myData); + }); + + it('simple once case works', function () { + var called = 0; + + obj.once('myevent', function() { called++; }); + + obj.emit('myevent'); + obj.emit('myevent'); + obj.emit('myevent'); + obj.emit('myevent'); + obj.emit('myevent'); + + expect(called).to.equal(1); + }); + + it('simple off case works', function (done) { + function onMyEvent() { + done(new Error('Event listener should not have been called')); + } + + obj.on('myevent', onMyEvent); + obj.off('myevent', onMyEvent); + obj.emit('myevent'); + + done(); + }); + + it('simple propagation case works', function (done) { + var myData = {}; + + pobj.on('myevent', function () { + done(); + }); + + obj.emit('myevent'); + }); + + it('simple stopPropagation case works', function (done) { + var myData = {}; + + pobj.on('myevent', function () { + done(new Error('Event listener should not have been called on the parent element')); + }); + + obj.on('myevent', function (evt) { + evt.stopPropagation(); + }); + + obj.emit('myevent'); + + done(); + }); + + it('simple stopImmediatePropagation case works', function (done) { + var myData = {}; + + pobj.on('myevent', function () { + done(new Error('Event listener should not have been called on the parent')); + }); + + obj.on('myevent', function (evt) { + evt.stopImmediatePropagation(); + }); + + obj.on('myevent', function () { + done(new Error('Event listener should not have been called on the second')); + }); + + obj.emit('myevent'); + + done(); + }); + + it('multiple dispatches work properly', function () { + var called = 0; + + function onMyEvent() { + called++; + } + + obj.on('myevent', onMyEvent); + obj.emit('myevent'); + obj.emit('myevent'); + obj.emit('myevent'); + obj.emit('myevent'); + + expect(called).to.equal(4); + }); + + it('multiple events work properly', function () { + var called = 0; + + function onMyEvent() { + called++; + } + + obj.on('myevent1', onMyEvent); + obj.on('myevent2', onMyEvent); + obj.on('myevent3', onMyEvent); + obj.emit('myevent1'); + obj.emit('myevent2'); + obj.emit('myevent3'); + + expect(called).to.equal(3); + }); + + it('multiple events one removed works properly', function () { + var called = 0; + + function onMyEvent() { + called++; + } + + obj.on('myevent1', onMyEvent); + obj.on('myevent2', onMyEvent); + obj.on('myevent3', onMyEvent); + + obj.emit('myevent1'); + obj.emit('myevent2'); + obj.emit('myevent3'); + + obj.off('myevent2', onMyEvent); + + obj.emit('myevent1'); + obj.emit('myevent2'); + obj.emit('myevent3'); + + expect(called).to.equal(5); + }); + + it('multiple handlers for one event with some removed', function () { + var called = 0; + + var onMyEvent = function () { + called++; + }, + onMyEvent2 = function () { + called++; + }; + + // add 2 handlers and confirm they both get called + obj.on('myevent', onMyEvent); + obj.on('myevent', onMyEvent); + obj.on('myevent', onMyEvent2); + obj.on('myevent', onMyEvent2); + + obj.emit('myevent'); + + expect(called).to.equal(4); + + // remove one of the handlers, emit again, then ensure 1 more call is made + obj.off('myevent', onMyEvent); + + obj.emit('myevent'); + + expect(called).to.equal(6); + }); + + it('calls to off without a handler do nothing', function () { + var called = 0; + + var onMyEvent = function () { + called++; + }; + + obj.on('myevent', onMyEvent); + obj.on('myevent', onMyEvent); + + obj.emit('myevent'); + + expect(called).to.equal(2); + + obj.off('myevent'); + + obj.emit('myevent'); + + expect(called).to.equal(4); + + obj.off('myevent', onMyEvent); + + obj.emit('myevent'); + + expect(called).to.equal(4); + }); + + it('handles multiple instances with the same prototype', function () { + var called = 0; + + function onMyEvent(e) { + called++; + } + + obj.on('myevent1', onMyEvent); + obj.on('myevent2', onMyEvent); + + obj2.istwo = true; + obj2.on('myevent1', onMyEvent); + obj2.on('myevent2', onMyEvent); + + obj.emit('myevent1'); + obj.emit('myevent2'); + obj2.emit('myevent1'); + obj2.emit('myevent2'); + + //we emit 4 times, but since obj2 is a child of obj the event should bubble + //up to obj and show up there as well. So the obj2.emit() calls each increment + //the counter twice. + expect(called).to.equal(6); + }); + + it('is backwards compatible with older .dispatchEvent({})', function () { + var called = 0, + data = { + some: 'thing', + hello: true + }; + + function onMyEvent(event) { + pixi_utils_EventTarget_Event_confirm(event, obj, data); + + called++; + } + + obj.on('myevent1', onMyEvent); + obj.on('myevent2', onMyEvent); + obj.on('myevent3', onMyEvent); + + data.type = 'myevent1'; + obj.emit(data); + + data.type = 'myevent2'; + obj.emit(data); + + data.type = 'myevent3'; + obj.emit(data); + + obj.off('myevent2', onMyEvent); + + data.type = 'myevent1'; + obj.emit(data); + + data.type = 'myevent2'; + obj.emit(data); + + data.type = 'myevent3'; + obj.emit(data); + + expect(called).to.equal(5); + }); + + it('is backwards compatible with older .call(this)', function () { + var Fn = function() { + PIXI.EventTarget.call(this); + }, + o = new Fn(); + + pixi_utils_EventTarget_confirm(o); + }); + + it('is backwards compatible with older .addEventListener("")', function () { + var called = 0, + data = { + some: 'thing', + hello: true + }; + + function onMyEvent(event) { + pixi_utils_EventTarget_Event_confirm(event, obj, data); + + called++; + } + + obj.addEventListener('myevent1', onMyEvent); + obj.addEventListener('myevent2', onMyEvent); + obj.addEventListener('myevent3', onMyEvent); + + data.type = 'myevent1'; + obj.emit(data); + + data.type = 'myevent2'; + obj.emit(data); + + data.type = 'myevent3'; + obj.emit(data); + + obj.off('myevent2', onMyEvent); + + data.type = 'myevent1'; + obj.emit(data); + + data.type = 'myevent2'; + obj.emit(data); + + data.type = 'myevent3'; + obj.emit(data); + + expect(called).to.equal(5); + }); + + it('event remove during emit call properly', function () { + var called = 0; + + function cb1() { + called++; + obj.off('myevent', cb1); + } + function cb2() { + called++; + obj.off('myevent', cb2); + } + function cb3() { + called++; + obj.off('myevent', cb3); + } + + obj.on('myevent', cb1); + obj.on('myevent', cb2); + obj.on('myevent', cb3); + obj.emit('myevent', ''); + + expect(called).to.equal(3); + }); +}); diff --git a/test/unit/pixi-v2/utils/Polyk.js b/test/unit/pixi-v2/utils/Polyk.js new file mode 100644 index 0000000..dfc7128 --- /dev/null +++ b/test/unit/pixi-v2/utils/Polyk.js @@ -0,0 +1,14 @@ +describe('pixi/utils/Polyk', function () { + 'use strict'; + + var expect = chai.expect; + var PolyK = PIXI.PolyK; + + it('Module exists', function () { + expect(PolyK).to.be.an('object'); + }); + + it('Members exist', function () { + expect(PolyK).to.respondTo('Triangulate'); + }); +}); diff --git a/test/unit/pixi-v2/utils/Utils.js b/test/unit/pixi-v2/utils/Utils.js new file mode 100644 index 0000000..c97b3c6 --- /dev/null +++ b/test/unit/pixi-v2/utils/Utils.js @@ -0,0 +1,17 @@ +describe('Utils', function () { + 'use strict'; + + var expect = chai.expect; + + it('requestAnimationFrame exists', function () { + expect(global).to.respondTo('requestAnimationFrame'); + }); + + it('cancelAnimationFrame exists', function () { + expect(global).to.respondTo('cancelAnimationFrame'); + }); + + it('requestAnimFrame exists', function () { + expect(global).to.respondTo('requestAnimFrame'); + }); +}); diff --git a/test/unit/pixi/InteractionManager.js b/test/unit/pixi/InteractionManager.js deleted file mode 100644 index ed3001f..0000000 --- a/test/unit/pixi/InteractionManager.js +++ /dev/null @@ -1,10 +0,0 @@ -describe('pixi/InteractionManager', function () { - 'use strict'; - - var expect = chai.expect; - var InteractionManager = PIXI.InteractionManager; - - it('Module exists', function () { - expect(InteractionManager).to.be.a('function'); - }); -}); diff --git a/test/unit/pixi/Pixi.js b/test/unit/pixi/Pixi.js deleted file mode 100644 index 27debc1..0000000 --- a/test/unit/pixi/Pixi.js +++ /dev/null @@ -1,9 +0,0 @@ -describe('pixi/Pixi', function () { - 'use strict'; - - var expect = chai.expect; - - it('Module exists', function () { - expect(global).to.have.property('PIXI').and.to.be.an('object'); - }); -}); diff --git a/test/unit/pixi/core/Circle.js b/test/unit/pixi/core/Circle.js deleted file mode 100644 index fbcfa17..0000000 --- a/test/unit/pixi/core/Circle.js +++ /dev/null @@ -1,21 +0,0 @@ -describe('pixi/core/Circle', function () { - 'use strict'; - - var expect = chai.expect; - var Circle = PIXI.Circle; - - it('Module exists', function () { - expect(Circle).to.be.a('function'); - }); - - it('Confirm new instance', function () { - var obj = new Circle(); - pixi_core_Circle_confirmNewCircle(obj); - }); - - it("getBounds should return Rectangle that bounds the circle", function() { - var obj = new Circle(100, 250, 50); - var bounds = obj.getBounds(); - pixi_core_Circle_isBoundedByRectangle(obj, bounds); - }); -}); diff --git a/test/unit/pixi/core/Ellipse.js b/test/unit/pixi/core/Ellipse.js deleted file mode 100644 index 026b56f..0000000 --- a/test/unit/pixi/core/Ellipse.js +++ /dev/null @@ -1,24 +0,0 @@ -describe('pixi/core/Ellipse', function () { - 'use strict'; - - var expect = chai.expect; - var Ellipse = PIXI.Ellipse; - - it('Module exists', function () { - expect(Ellipse).to.be.a('function'); - }); - - it('Confirm new instance', function () { - var obj = new Ellipse(); - - expect(obj).to.be.an.instanceof(Ellipse); - expect(obj).to.respondTo('clone'); - expect(obj).to.respondTo('contains'); - expect(obj).to.respondTo('getBounds'); - - expect(obj).to.have.property('x', 0); - expect(obj).to.have.property('y', 0); - expect(obj).to.have.property('width', 0); - expect(obj).to.have.property('height', 0); - }); -}); diff --git a/test/unit/pixi/core/Matrix.js b/test/unit/pixi/core/Matrix.js deleted file mode 100644 index da75e2e..0000000 --- a/test/unit/pixi/core/Matrix.js +++ /dev/null @@ -1,14 +0,0 @@ -describe('pixi/core/Matrix', function () { - 'use strict'; - - var expect = chai.expect; - - it('Matrix exists', function () { - expect(PIXI.Matrix).to.be.an('function'); - }); - - it('Confirm new Matrix', function () { - var matrix = new PIXI.Matrix(); - pixi_core_Matrix_confirmNewMatrix(matrix); - }); -}); diff --git a/test/unit/pixi/core/Point.js b/test/unit/pixi/core/Point.js deleted file mode 100644 index c4d5163..0000000 --- a/test/unit/pixi/core/Point.js +++ /dev/null @@ -1,15 +0,0 @@ -describe('pixi/core/Point', function () { - 'use strict'; - - var expect = chai.expect; - var Point = PIXI.Point; - - it('Module exists', function () { - expect(Point).to.be.a('function'); - }); - - it('Confirm new instance', function () { - var obj = new Point(); - pixi_core_Point_confirm(obj, 0, 0); - }); -}); diff --git a/test/unit/pixi/core/Polygon.js b/test/unit/pixi/core/Polygon.js deleted file mode 100644 index dc8c918..0000000 --- a/test/unit/pixi/core/Polygon.js +++ /dev/null @@ -1,20 +0,0 @@ -describe('pixi/core/Polygon', function () { - 'use strict'; - - var expect = chai.expect; - var Polygon = PIXI.Polygon; - - it('Module exists', function () { - expect(Polygon).to.be.a('function'); - }); - - it('Confirm new instance', function () { - var obj = new Polygon(); - - expect(obj).to.be.an.instanceof(Polygon); - expect(obj).to.respondTo('clone'); - expect(obj).to.respondTo('contains'); - - expect(obj).to.have.deep.property('points.length', 0); - }); -}); diff --git a/test/unit/pixi/core/Rectangle.js b/test/unit/pixi/core/Rectangle.js deleted file mode 100644 index d43316e..0000000 --- a/test/unit/pixi/core/Rectangle.js +++ /dev/null @@ -1,15 +0,0 @@ -describe('pixi/core/Rectangle', function () { - 'use strict'; - - var expect = chai.expect; - var Rectangle = PIXI.Rectangle; - - it('Module exists', function () { - expect(Rectangle).to.be.a('function'); - }); - - it('Confirm new instance', function () { - var rect = new Rectangle(); - pixi_core_Rectangle_confirm(rect, 0, 0, 0, 0); - }); -}); diff --git a/test/unit/pixi/display/DisplayObject.js b/test/unit/pixi/display/DisplayObject.js deleted file mode 100644 index 044acf8..0000000 --- a/test/unit/pixi/display/DisplayObject.js +++ /dev/null @@ -1,21 +0,0 @@ -describe('pixi/display/DisplayObject', function () { - 'use strict'; - - var expect = chai.expect; - var DisplayObject = PIXI.DisplayObject; - - it('Module exists', function () { - expect(DisplayObject).to.be.a('function'); - // expect(PIXI).to.have.property('visibleCount', 0); - }); - - it('Confirm new instance', function () { - var obj = new DisplayObject(); - - pixi_display_DisplayObject_confirmNew(obj); - expect(obj).to.have.property('hitArea', null); - expect(obj).to.have.property('interactive', false); - expect(obj).to.have.property('renderable', false); - expect(obj).to.have.property('stage', null); - }); -}); diff --git a/test/unit/pixi/display/DisplayObjectContainer.js b/test/unit/pixi/display/DisplayObjectContainer.js deleted file mode 100644 index 15a3376..0000000 --- a/test/unit/pixi/display/DisplayObjectContainer.js +++ /dev/null @@ -1,67 +0,0 @@ -describe('pixi/display/DisplayObjectContainer', function () { - 'use strict'; - - var expect = chai.expect; - var DisplayObjectContainer = PIXI.DisplayObjectContainer; - - it('Module exists', function () { - expect(DisplayObjectContainer).to.be.a('function'); - }); - - it('Confirm new instance', function () { - var obj = new DisplayObjectContainer(); - - pixi_display_DisplayObjectContainer_confirmNew(obj); - expect(obj).to.have.property('hitArea', null); - expect(obj).to.have.property('interactive', false); - expect(obj).to.have.property('renderable', false); - expect(obj).to.have.property('stage', null); - }); - - it('Gets child index', function() { - var container = new PIXI.DisplayObjectContainer(); - var children = []; - for (var i = 0; i < 10; i++) { - var child = new PIXI.DisplayObject(); - children.push(child); - container.addChild(child); - } - - for (i = 0; i < children.length; i++) { - expect(i).to.eql(container.getChildIndex(children[i])); - } - }); - - it('throws error when trying to get index of not a child', function() { - var container = new PIXI.DisplayObjectContainer(); - var child = new PIXI.DisplayObject(); - - expect(function() { container.getChildIndex(child); }).to.throw(); - }); - - it('Sets child index', function() { - var container = new PIXI.DisplayObjectContainer(); - var children = []; - - for (var i = 0; i < 10; i++) { - var child = new PIXI.DisplayObject(); - children.push(child); - container.addChild(child); - } - children.reverse(); - - for (i = 0; i < children.length; i++) { - container.setChildIndex(children[i], i); - expect(i).to.eql(container.getChildIndex(children[i])); - } - }); - - it('throws error when trying to set incorect index', function() { - var container = new PIXI.DisplayObjectContainer(); - var child = new PIXI.DisplayObject(); - container.addChild(child); - - expect(function() { container.setChildIndex(child, -1); }).to.throw(); - expect(function() { container.setChildIndex(child, 1); }).to.throw(); - }); -}); diff --git a/test/unit/pixi/display/MovieClip.js b/test/unit/pixi/display/MovieClip.js deleted file mode 100644 index f3c6c6a..0000000 --- a/test/unit/pixi/display/MovieClip.js +++ /dev/null @@ -1,33 +0,0 @@ -describe('pixi/display/MovieClip', function () { - 'use strict'; - - var expect = chai.expect; - var MovieClip = PIXI.MovieClip; - var Texture = PIXI.Texture; - - it('Module exists', function () { - expect(MovieClip).to.be.a('function'); - }); - - it('Confirm new instance', function (done) { - var texture = Texture.fromImage('/base/test/textures/SpriteSheet-Explosion.png'); - var obj = new MovieClip([texture]); - - pixi_display_Sprite_confirmNew(obj, done); - - expect(obj).to.be.an.instanceof(MovieClip); - expect(obj).to.respondTo('stop'); - expect(obj).to.respondTo('play'); - expect(obj).to.respondTo('gotoAndStop'); - expect(obj).to.respondTo('gotoAndPlay'); - expect(obj).to.respondTo('updateTransform'); - - expect(obj).to.have.deep.property('textures.length', 1); - expect(obj).to.have.deep.property('textures[0]', texture); - expect(obj).to.have.property('animationSpeed', 1); - expect(obj).to.have.property('loop', true); - expect(obj).to.have.property('onComplete', null); - expect(obj).to.have.property('currentFrame', 0); - expect(obj).to.have.property('playing', false); - }); -}); diff --git a/test/unit/pixi/display/Sprite.js b/test/unit/pixi/display/Sprite.js deleted file mode 100644 index 30c8076..0000000 --- a/test/unit/pixi/display/Sprite.js +++ /dev/null @@ -1,28 +0,0 @@ -describe('pixi/display/Sprite', function () { - 'use strict'; - - var expect = chai.expect; - var Sprite = PIXI.Sprite; - var Texture = PIXI.Texture; - - it('Module exists', function () { - expect(Sprite).to.be.a('function'); - expect(PIXI).to.have.deep.property('blendModes.NORMAL', 0); - expect(PIXI).to.have.deep.property('blendModes.ADD', 1); - expect(PIXI).to.have.deep.property('blendModes.MULTIPLY', 2); - expect(PIXI).to.have.deep.property('blendModes.SCREEN', 3); - }); - - - it('Members exist', function () { - expect(Sprite).itself.to.respondTo('fromImage'); - expect(Sprite).itself.to.respondTo('fromFrame'); - }); - - it('Confirm new instance', function (done) { - var texture = Texture.fromImage('/base/test/textures/SpriteSheet-Aliens.png'); - var obj = new Sprite(texture); - - pixi_display_Sprite_confirmNew(obj, done); - }); -}); diff --git a/test/unit/pixi/display/Stage.js b/test/unit/pixi/display/Stage.js deleted file mode 100644 index 6974c2e..0000000 --- a/test/unit/pixi/display/Stage.js +++ /dev/null @@ -1,49 +0,0 @@ -describe('pixi/display/Stage', function () { - 'use strict'; - - var expect = chai.expect; - var Stage = PIXI.Stage; - var InteractionManager = PIXI.InteractionManager; - var Rectangle = PIXI.Rectangle; - - it('Module exists', function () { - expect(Stage).to.be.a('function'); - }); - - it('Confirm new instance', function () { - var obj = new Stage(null, true); - - pixi_display_DisplayObjectContainer_confirmNew(obj); - - expect(obj).to.be.an.instanceof(Stage); - expect(obj).to.respondTo('updateTransform'); - expect(obj).to.respondTo('setBackgroundColor'); - expect(obj).to.respondTo('getMousePosition'); - // FIXME: duplicate member in DisplayObject - pixi_core_Matrix_confirmNewMatrix(obj.worldTransform); - // FIXME: convert arg to bool in constructor - expect(obj).to.have.property('interactive', true); - - expect(obj).to.have.property('interactionManager') - .and.to.be.an.instanceof(InteractionManager) - .and.to.have.property('stage', obj); - - expect(obj).to.have.property('dirty', true); - - expect(obj).to.have.property('stage', obj); - - expect(obj).to.have.property('hitArea') - .and.to.be.an.instanceof(Rectangle); - pixi_core_Rectangle_confirm(obj.hitArea, 0, 0, 100000, 100000); - - expect(obj).to.have.property('backgroundColor', 0x000000); - expect(obj).to.have.deep.property('backgroundColorSplit.length', 3); - expect(obj).to.have.deep.property('backgroundColorSplit[0]', 0); - expect(obj).to.have.deep.property('backgroundColorSplit[1]', 0); - expect(obj).to.have.deep.property('backgroundColorSplit[2]', 0); - expect(obj).to.have.property('backgroundColorString', '#000000'); - - - expect(obj).to.have.property('worldVisible', true); - }); -}); diff --git a/test/unit/pixi/extras/Rope.js b/test/unit/pixi/extras/Rope.js deleted file mode 100644 index 05885ac..0000000 --- a/test/unit/pixi/extras/Rope.js +++ /dev/null @@ -1,31 +0,0 @@ -describe('pixi/extras/Rope', function () { - 'use strict'; - - var expect = chai.expect; - var Rope = PIXI.Rope; - var Texture = PIXI.Texture; - var Point = PIXI.Point; - - it('Module exists', function () { - expect(Rope).to.be.a('function'); - }); - - it('Confirm new instance', function () { - - var texture = Texture.fromImage('/base/test/textures/bunny.png'); - - // TODO-Alvin - // Same as Strip - - // var obj = new Rope(texture, [new Point(), new Point(5, 10), new Point(10, 20)]); - - // pixi_extras_Strip_confirmNew(obj); - - // expect(obj).to.be.an.instanceof(Rope); - // expect(obj).to.respondTo('refresh'); - // expect(obj).to.respondTo('updateTransform'); - // expect(obj).to.respondTo('setTexture'); - - // TODO: Test properties - }); -}); diff --git a/test/unit/pixi/extras/Spine.js b/test/unit/pixi/extras/Spine.js deleted file mode 100644 index 0708bc0..0000000 --- a/test/unit/pixi/extras/Spine.js +++ /dev/null @@ -1,10 +0,0 @@ -describe('pixi/extras/Spine', function () { - 'use strict'; - - var expect = chai.expect; - var Spine = PIXI.Spine; - - it('Module exists', function () { - expect(Spine).to.be.a('function'); - }); -}); diff --git a/test/unit/pixi/extras/Strip.js b/test/unit/pixi/extras/Strip.js deleted file mode 100644 index 230af90..0000000 --- a/test/unit/pixi/extras/Strip.js +++ /dev/null @@ -1,26 +0,0 @@ -describe('pixi/extras/Strip', function () { - 'use strict'; - - var expect = chai.expect; - var Strip = PIXI.Strip; - var Texture = PIXI.Texture; - - it('Module exists', function () { - expect(Strip).to.be.a('function'); - }); - - it('Confirm new instance', function () { - - - // TODO-Alvin - // We tweaked it to make it pass the tests, but the whole strip class needs - // to be re-coded - - var texture = Texture.fromImage('/base/test/textures/bunny.png'); - - // var obj = new Strip(texture, 20, 10000); - - - // pixi_extras_Strip_confirmNew(obj); - }); -}); diff --git a/test/unit/pixi/extras/TilingSprite.js b/test/unit/pixi/extras/TilingSprite.js deleted file mode 100644 index 56aea14..0000000 --- a/test/unit/pixi/extras/TilingSprite.js +++ /dev/null @@ -1,24 +0,0 @@ -describe('pixi/extras/TilingSprite', function () { - 'use strict'; - - var expect = chai.expect; - var TilingSprite = PIXI.TilingSprite; - var Texture = PIXI.Texture; - - it('Module exists', function () { - expect(TilingSprite).to.be.a('function'); - }); - - it('Confirm new instance', function () { - var texture = Texture.fromImage('/base/test/textures/bunny.png'); - var obj = new TilingSprite(texture, 6000, 12000); - - pixi_display_DisplayObjectContainer_confirmNew(obj); - - expect(obj).to.be.an.instanceof(TilingSprite); - expect(obj).to.respondTo('setTexture'); - expect(obj).to.respondTo('onTextureUpdate'); - - // TODO: Test properties - }); -}); diff --git a/test/unit/pixi/filters/FilterBlock.js b/test/unit/pixi/filters/FilterBlock.js deleted file mode 100644 index 870cec0..0000000 --- a/test/unit/pixi/filters/FilterBlock.js +++ /dev/null @@ -1,10 +0,0 @@ -describe('pixi/filters/FilterBlock', function () { - 'use strict'; - - var expect = chai.expect; - var FilterBlock = PIXI.FilterBlock; - - it('Module exists', function () { - expect(FilterBlock).to.be.a('function'); - }); -}); diff --git a/test/unit/pixi/loaders/AssetLoader.js b/test/unit/pixi/loaders/AssetLoader.js deleted file mode 100644 index a0aa0b5..0000000 --- a/test/unit/pixi/loaders/AssetLoader.js +++ /dev/null @@ -1,10 +0,0 @@ -describe('pixi/loaders/AssetLoader', function () { - 'use strict'; - - var expect = chai.expect; - var AssetLoader = PIXI.AssetLoader; - - it('Module exists', function () { - expect(AssetLoader).to.be.a('function'); - }); -}); diff --git a/test/unit/pixi/loaders/BitmapFontLoader.js b/test/unit/pixi/loaders/BitmapFontLoader.js deleted file mode 100644 index 046f018..0000000 --- a/test/unit/pixi/loaders/BitmapFontLoader.js +++ /dev/null @@ -1,9 +0,0 @@ -describe('pixi/loaders/BitmapFontLoader', function () { - 'use strict'; - - var expect = chai.expect; - - it('Module exists', function () { - expect(PIXI.BitmapFontLoader).to.be.a('function'); - }); -}); diff --git a/test/unit/pixi/loaders/ImageLoader.js b/test/unit/pixi/loaders/ImageLoader.js deleted file mode 100644 index 8b1f556..0000000 --- a/test/unit/pixi/loaders/ImageLoader.js +++ /dev/null @@ -1,10 +0,0 @@ -describe('pixi/loaders/ImageLoader', function () { - 'use strict'; - - var expect = chai.expect; - var ImageLoader = PIXI.ImageLoader; - - it('Module exists', function () { - expect(ImageLoader).to.be.a('function'); - }); -}); diff --git a/test/unit/pixi/loaders/JsonLoader.js b/test/unit/pixi/loaders/JsonLoader.js deleted file mode 100644 index c577e83..0000000 --- a/test/unit/pixi/loaders/JsonLoader.js +++ /dev/null @@ -1,10 +0,0 @@ -describe('pixi/loaders/JsonLoader', function () { - 'use strict'; - - var expect = chai.expect; - var JsonLoader = PIXI.JsonLoader; - - it('Module exists', function () { - expect(JsonLoader).to.be.a('function'); - }); -}); diff --git a/test/unit/pixi/loaders/SpineLoader.js b/test/unit/pixi/loaders/SpineLoader.js deleted file mode 100644 index fdcc0b8..0000000 --- a/test/unit/pixi/loaders/SpineLoader.js +++ /dev/null @@ -1,10 +0,0 @@ -describe('pixi/loaders/SpineLoader', function () { - 'use strict'; - - var expect = chai.expect; - var SpineLoader = PIXI.SpineLoader; - - it('Module exists', function () { - expect(SpineLoader).to.be.a('function'); - }); -}); diff --git a/test/unit/pixi/loaders/SpriteSheetLoader.js b/test/unit/pixi/loaders/SpriteSheetLoader.js deleted file mode 100644 index 57beb27..0000000 --- a/test/unit/pixi/loaders/SpriteSheetLoader.js +++ /dev/null @@ -1,10 +0,0 @@ -describe('pixi/loaders/SpriteSheetLoader', function () { - 'use strict'; - - var expect = chai.expect; - var SpriteSheetLoader = PIXI.SpriteSheetLoader; - - it('Module exists', function () { - expect(SpriteSheetLoader).to.be.a('function'); - }); -}); diff --git a/test/unit/pixi/primitives/Graphics.js b/test/unit/pixi/primitives/Graphics.js deleted file mode 100644 index f3849eb..0000000 --- a/test/unit/pixi/primitives/Graphics.js +++ /dev/null @@ -1,44 +0,0 @@ -describe('pixi/primitives/Graphics', function () { - 'use strict'; - - var expect = chai.expect; - var Graphics = PIXI.Graphics; - - it('Module exists', function () { - expect(Graphics).to.be.a('function'); - - expect(Graphics).itself.to.have.property('POLY', 0); - expect(Graphics).itself.to.have.property('RECT', 1); - expect(Graphics).itself.to.have.property('CIRC', 2); - expect(Graphics).itself.to.have.property('ELIP', 3); - expect(Graphics).itself.to.have.property('RREC', 4); - }); - - it('Confirm new instance', function () { - var obj = new Graphics(); - - pixi_display_DisplayObjectContainer_confirmNew(obj); - - expect(obj).to.be.an.instanceof(Graphics); - expect(obj).to.respondTo('lineStyle'); - expect(obj).to.respondTo('lineStyle'); - expect(obj).to.respondTo('moveTo'); - expect(obj).to.respondTo('lineTo'); - expect(obj).to.respondTo('beginFill'); - expect(obj).to.respondTo('endFill'); - expect(obj).to.respondTo('drawRect'); - // expect(obj).to.respondTo('drawRoundedRect'); - expect(obj).to.respondTo('drawCircle'); - expect(obj).to.respondTo('drawEllipse'); - expect(obj).to.respondTo('clear'); - - expect(obj).to.have.property('renderable', true); - expect(obj).to.have.property('fillAlpha', 1); - expect(obj).to.have.property('lineWidth', 0); - expect(obj).to.have.property('width', 0); - expect(obj).to.have.property('height', 0); - expect(obj).to.have.property('lineColor', 0); - expect(obj).to.have.deep.property('graphicsData.length', 0); - // expect(obj).to.have.deep.property('currentPath.points.length', 0); - }); -}); diff --git a/test/unit/pixi/renderers/canvas/CanvasGraphics.js b/test/unit/pixi/renderers/canvas/CanvasGraphics.js deleted file mode 100644 index 8f44472..0000000 --- a/test/unit/pixi/renderers/canvas/CanvasGraphics.js +++ /dev/null @@ -1,15 +0,0 @@ -describe('renders/canvas/CanvasGraphics', function () { - 'use strict'; - - var expect = chai.expect; - var CanvasGraphics = PIXI.CanvasGraphics; - - it('Module exists', function () { - expect(CanvasGraphics).to.be.a('function'); - }); - - it('Members exist', function () { - expect(CanvasGraphics).itself.to.respondTo('renderGraphics'); - expect(CanvasGraphics).itself.to.respondTo('renderGraphicsMask'); - }); -}); diff --git a/test/unit/pixi/renderers/canvas/CanvasRenderer.js b/test/unit/pixi/renderers/canvas/CanvasRenderer.js deleted file mode 100644 index 1646444..0000000 --- a/test/unit/pixi/renderers/canvas/CanvasRenderer.js +++ /dev/null @@ -1,36 +0,0 @@ -describe('renderers/canvas/CanvasRenderer', function () { - 'use strict'; - - var expect = chai.expect; - var CanvasRenderer = PIXI.CanvasRenderer; - - it('Module exists', function () { - expect(CanvasRenderer).to.be.a('function'); - }); - - describe('.autoResize', function () { - it('Should automatically resize view if enabled', function () { - var renderer = new CanvasRenderer(200, 200, { - autoResize: true - }); - - expect(renderer.view.style.width).to.equal('200px'); - }); - - it('Should not automatically resize view if disabled', function () { - var renderer = new CanvasRenderer(200, 200, { - autoResize: false - }); - - expect(renderer.view.style.width).to.equal(''); - }); - - it('Should not automatically resize view if not specified', function () { - var renderer = new CanvasRenderer(200, 200, { - resolution: 2 - }); - - expect(renderer.view.style.width).to.equal(''); - }); - }); -}); diff --git a/test/unit/pixi/renderers/webgl/WebGLGraphics.js b/test/unit/pixi/renderers/webgl/WebGLGraphics.js deleted file mode 100644 index 5867b28..0000000 --- a/test/unit/pixi/renderers/webgl/WebGLGraphics.js +++ /dev/null @@ -1,20 +0,0 @@ -describe('renderers/wegbl/WebGLGraphics', function () { - 'use strict'; - - var expect = chai.expect; - var WebGLGraphics = PIXI.WebGLGraphics; - - it('Module exists', function () { - expect(WebGLGraphics).to.be.a('function'); - }); - - it('Members exist', function () { - expect(WebGLGraphics).itself.to.respondTo('renderGraphics'); - expect(WebGLGraphics).itself.to.respondTo('updateGraphics'); - expect(WebGLGraphics).itself.to.respondTo('buildRectangle'); - expect(WebGLGraphics).itself.to.respondTo('buildRoundedRectangle'); - expect(WebGLGraphics).itself.to.respondTo('buildCircle'); - expect(WebGLGraphics).itself.to.respondTo('buildLine'); - expect(WebGLGraphics).itself.to.respondTo('buildPoly'); - }); -}); diff --git a/test/unit/pixi/renderers/webgl/WebGLRenderer.js b/test/unit/pixi/renderers/webgl/WebGLRenderer.js deleted file mode 100644 index 1680a80..0000000 --- a/test/unit/pixi/renderers/webgl/WebGLRenderer.js +++ /dev/null @@ -1,49 +0,0 @@ -describe('renderers/webgl/WebGLRenderer', function () { - 'use strict'; - - var expect = chai.expect; - var WebGLRenderer = PIXI.WebGLRenderer; - - it('Module exists', function () { - expect(WebGLRenderer).to.be.a('function'); - }); - - // Skip tests if WebGL is not available (WebGL not supported in Travis CI) - try { - var renderer = new WebGLRenderer(400, 300, {}); - renderer.destroy(); - } catch (error) { - return; - } - - it('Destroy renderer', function () { - var renderer = new WebGLRenderer(400, 300, {}); - renderer.destroy(); - }); - - describe('.autoResize', function () { - it('Should automatically resize view if enabled', function () { - var renderer = new WebGLRenderer(200, 200, { - autoResize: true - }); - - expect(renderer.view.style.width).to.equal('200px'); - }); - - it('Should not automatically resize view if disabled', function () { - var renderer = new WebGLRenderer(200, 200, { - autoResize: false - }); - - expect(renderer.view.style.width).to.equal(''); - }); - - it('Should not automatically resize view if not specified', function () { - var renderer = new WebGLRenderer(200, 200, { - resolution: 2 - }); - - expect(renderer.view.style.width).to.equal(''); - }); - }); -}); diff --git a/test/unit/pixi/renderers/webgl/WebGLShaders.js b/test/unit/pixi/renderers/webgl/WebGLShaders.js deleted file mode 100644 index 6e33e4f..0000000 --- a/test/unit/pixi/renderers/webgl/WebGLShaders.js +++ /dev/null @@ -1,13 +0,0 @@ -describe('renderers/webgl/WebGLShaders', function () { - 'use strict'; - - var expect = chai.expect; - - it('Module members exist', function () { - - expect(PIXI).to.respondTo('CompileVertexShader'); - expect(PIXI).to.respondTo('CompileFragmentShader'); - expect(PIXI).to.respondTo('_CompileShader'); - expect(PIXI).to.respondTo('compileProgram'); - }); -}); diff --git a/test/unit/pixi/renderers/webgl/WebGLSpriteBatch.js b/test/unit/pixi/renderers/webgl/WebGLSpriteBatch.js deleted file mode 100644 index e662b63..0000000 --- a/test/unit/pixi/renderers/webgl/WebGLSpriteBatch.js +++ /dev/null @@ -1,10 +0,0 @@ -describe('renderers/webgl/utils/WebGLSpriteBatch', function () { - 'use strict'; - - var expect = chai.expect; - var WebGLSpriteBatch = PIXI.WebGLSpriteBatch; - - it('Module exists', function () { - expect(WebGLSpriteBatch).to.be.a('function'); - }); -}); diff --git a/test/unit/pixi/text/BitmapText.js b/test/unit/pixi/text/BitmapText.js deleted file mode 100644 index 9388e3d..0000000 --- a/test/unit/pixi/text/BitmapText.js +++ /dev/null @@ -1,10 +0,0 @@ -describe('pixi/text/BitmapText', function () { - 'use strict'; - - var expect = chai.expect; - var BitmapText = PIXI.BitmapText; - - it('Module exists', function () { - expect(BitmapText).to.be.a('function'); - }); -}); diff --git a/test/unit/pixi/text/Text.js b/test/unit/pixi/text/Text.js deleted file mode 100644 index 9bc9ac5..0000000 --- a/test/unit/pixi/text/Text.js +++ /dev/null @@ -1,10 +0,0 @@ -describe('pixi/text/Text', function () { - 'use strict'; - - var expect = chai.expect; - var Text = PIXI.Text; - - it('Module exists', function () { - expect(Text).to.be.a('function'); - }); -}); diff --git a/test/unit/pixi-v2/InteractionManager.js b/test/unit/pixi-v2/InteractionManager.js new file mode 100644 index 0000000..ed3001f --- /dev/null +++ b/test/unit/pixi-v2/InteractionManager.js @@ -0,0 +1,10 @@ +describe('pixi/InteractionManager', function () { + 'use strict'; + + var expect = chai.expect; + var InteractionManager = PIXI.InteractionManager; + + it('Module exists', function () { + expect(InteractionManager).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/Pixi.js b/test/unit/pixi-v2/Pixi.js new file mode 100644 index 0000000..27debc1 --- /dev/null +++ b/test/unit/pixi-v2/Pixi.js @@ -0,0 +1,9 @@ +describe('pixi/Pixi', function () { + 'use strict'; + + var expect = chai.expect; + + it('Module exists', function () { + expect(global).to.have.property('PIXI').and.to.be.an('object'); + }); +}); diff --git a/test/unit/pixi-v2/core/Circle.js b/test/unit/pixi-v2/core/Circle.js new file mode 100644 index 0000000..fbcfa17 --- /dev/null +++ b/test/unit/pixi-v2/core/Circle.js @@ -0,0 +1,21 @@ +describe('pixi/core/Circle', function () { + 'use strict'; + + var expect = chai.expect; + var Circle = PIXI.Circle; + + it('Module exists', function () { + expect(Circle).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Circle(); + pixi_core_Circle_confirmNewCircle(obj); + }); + + it("getBounds should return Rectangle that bounds the circle", function() { + var obj = new Circle(100, 250, 50); + var bounds = obj.getBounds(); + pixi_core_Circle_isBoundedByRectangle(obj, bounds); + }); +}); diff --git a/test/unit/pixi-v2/core/Ellipse.js b/test/unit/pixi-v2/core/Ellipse.js new file mode 100644 index 0000000..026b56f --- /dev/null +++ b/test/unit/pixi-v2/core/Ellipse.js @@ -0,0 +1,24 @@ +describe('pixi/core/Ellipse', function () { + 'use strict'; + + var expect = chai.expect; + var Ellipse = PIXI.Ellipse; + + it('Module exists', function () { + expect(Ellipse).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Ellipse(); + + expect(obj).to.be.an.instanceof(Ellipse); + expect(obj).to.respondTo('clone'); + expect(obj).to.respondTo('contains'); + expect(obj).to.respondTo('getBounds'); + + expect(obj).to.have.property('x', 0); + expect(obj).to.have.property('y', 0); + expect(obj).to.have.property('width', 0); + expect(obj).to.have.property('height', 0); + }); +}); diff --git a/test/unit/pixi-v2/core/Matrix.js b/test/unit/pixi-v2/core/Matrix.js new file mode 100644 index 0000000..da75e2e --- /dev/null +++ b/test/unit/pixi-v2/core/Matrix.js @@ -0,0 +1,14 @@ +describe('pixi/core/Matrix', function () { + 'use strict'; + + var expect = chai.expect; + + it('Matrix exists', function () { + expect(PIXI.Matrix).to.be.an('function'); + }); + + it('Confirm new Matrix', function () { + var matrix = new PIXI.Matrix(); + pixi_core_Matrix_confirmNewMatrix(matrix); + }); +}); diff --git a/test/unit/pixi-v2/core/Point.js b/test/unit/pixi-v2/core/Point.js new file mode 100644 index 0000000..c4d5163 --- /dev/null +++ b/test/unit/pixi-v2/core/Point.js @@ -0,0 +1,15 @@ +describe('pixi/core/Point', function () { + 'use strict'; + + var expect = chai.expect; + var Point = PIXI.Point; + + it('Module exists', function () { + expect(Point).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Point(); + pixi_core_Point_confirm(obj, 0, 0); + }); +}); diff --git a/test/unit/pixi-v2/core/Polygon.js b/test/unit/pixi-v2/core/Polygon.js new file mode 100644 index 0000000..dc8c918 --- /dev/null +++ b/test/unit/pixi-v2/core/Polygon.js @@ -0,0 +1,20 @@ +describe('pixi/core/Polygon', function () { + 'use strict'; + + var expect = chai.expect; + var Polygon = PIXI.Polygon; + + it('Module exists', function () { + expect(Polygon).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Polygon(); + + expect(obj).to.be.an.instanceof(Polygon); + expect(obj).to.respondTo('clone'); + expect(obj).to.respondTo('contains'); + + expect(obj).to.have.deep.property('points.length', 0); + }); +}); diff --git a/test/unit/pixi-v2/core/Rectangle.js b/test/unit/pixi-v2/core/Rectangle.js new file mode 100644 index 0000000..d43316e --- /dev/null +++ b/test/unit/pixi-v2/core/Rectangle.js @@ -0,0 +1,15 @@ +describe('pixi/core/Rectangle', function () { + 'use strict'; + + var expect = chai.expect; + var Rectangle = PIXI.Rectangle; + + it('Module exists', function () { + expect(Rectangle).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var rect = new Rectangle(); + pixi_core_Rectangle_confirm(rect, 0, 0, 0, 0); + }); +}); diff --git a/test/unit/pixi-v2/display/DisplayObject.js b/test/unit/pixi-v2/display/DisplayObject.js new file mode 100644 index 0000000..044acf8 --- /dev/null +++ b/test/unit/pixi-v2/display/DisplayObject.js @@ -0,0 +1,21 @@ +describe('pixi/display/DisplayObject', function () { + 'use strict'; + + var expect = chai.expect; + var DisplayObject = PIXI.DisplayObject; + + it('Module exists', function () { + expect(DisplayObject).to.be.a('function'); + // expect(PIXI).to.have.property('visibleCount', 0); + }); + + it('Confirm new instance', function () { + var obj = new DisplayObject(); + + pixi_display_DisplayObject_confirmNew(obj); + expect(obj).to.have.property('hitArea', null); + expect(obj).to.have.property('interactive', false); + expect(obj).to.have.property('renderable', false); + expect(obj).to.have.property('stage', null); + }); +}); diff --git a/test/unit/pixi-v2/display/DisplayObjectContainer.js b/test/unit/pixi-v2/display/DisplayObjectContainer.js new file mode 100644 index 0000000..15a3376 --- /dev/null +++ b/test/unit/pixi-v2/display/DisplayObjectContainer.js @@ -0,0 +1,67 @@ +describe('pixi/display/DisplayObjectContainer', function () { + 'use strict'; + + var expect = chai.expect; + var DisplayObjectContainer = PIXI.DisplayObjectContainer; + + it('Module exists', function () { + expect(DisplayObjectContainer).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new DisplayObjectContainer(); + + pixi_display_DisplayObjectContainer_confirmNew(obj); + expect(obj).to.have.property('hitArea', null); + expect(obj).to.have.property('interactive', false); + expect(obj).to.have.property('renderable', false); + expect(obj).to.have.property('stage', null); + }); + + it('Gets child index', function() { + var container = new PIXI.DisplayObjectContainer(); + var children = []; + for (var i = 0; i < 10; i++) { + var child = new PIXI.DisplayObject(); + children.push(child); + container.addChild(child); + } + + for (i = 0; i < children.length; i++) { + expect(i).to.eql(container.getChildIndex(children[i])); + } + }); + + it('throws error when trying to get index of not a child', function() { + var container = new PIXI.DisplayObjectContainer(); + var child = new PIXI.DisplayObject(); + + expect(function() { container.getChildIndex(child); }).to.throw(); + }); + + it('Sets child index', function() { + var container = new PIXI.DisplayObjectContainer(); + var children = []; + + for (var i = 0; i < 10; i++) { + var child = new PIXI.DisplayObject(); + children.push(child); + container.addChild(child); + } + children.reverse(); + + for (i = 0; i < children.length; i++) { + container.setChildIndex(children[i], i); + expect(i).to.eql(container.getChildIndex(children[i])); + } + }); + + it('throws error when trying to set incorect index', function() { + var container = new PIXI.DisplayObjectContainer(); + var child = new PIXI.DisplayObject(); + container.addChild(child); + + expect(function() { container.setChildIndex(child, -1); }).to.throw(); + expect(function() { container.setChildIndex(child, 1); }).to.throw(); + }); +}); diff --git a/test/unit/pixi-v2/display/MovieClip.js b/test/unit/pixi-v2/display/MovieClip.js new file mode 100644 index 0000000..f3c6c6a --- /dev/null +++ b/test/unit/pixi-v2/display/MovieClip.js @@ -0,0 +1,33 @@ +describe('pixi/display/MovieClip', function () { + 'use strict'; + + var expect = chai.expect; + var MovieClip = PIXI.MovieClip; + var Texture = PIXI.Texture; + + it('Module exists', function () { + expect(MovieClip).to.be.a('function'); + }); + + it('Confirm new instance', function (done) { + var texture = Texture.fromImage('/base/test/textures/SpriteSheet-Explosion.png'); + var obj = new MovieClip([texture]); + + pixi_display_Sprite_confirmNew(obj, done); + + expect(obj).to.be.an.instanceof(MovieClip); + expect(obj).to.respondTo('stop'); + expect(obj).to.respondTo('play'); + expect(obj).to.respondTo('gotoAndStop'); + expect(obj).to.respondTo('gotoAndPlay'); + expect(obj).to.respondTo('updateTransform'); + + expect(obj).to.have.deep.property('textures.length', 1); + expect(obj).to.have.deep.property('textures[0]', texture); + expect(obj).to.have.property('animationSpeed', 1); + expect(obj).to.have.property('loop', true); + expect(obj).to.have.property('onComplete', null); + expect(obj).to.have.property('currentFrame', 0); + expect(obj).to.have.property('playing', false); + }); +}); diff --git a/test/unit/pixi-v2/display/Sprite.js b/test/unit/pixi-v2/display/Sprite.js new file mode 100644 index 0000000..30c8076 --- /dev/null +++ b/test/unit/pixi-v2/display/Sprite.js @@ -0,0 +1,28 @@ +describe('pixi/display/Sprite', function () { + 'use strict'; + + var expect = chai.expect; + var Sprite = PIXI.Sprite; + var Texture = PIXI.Texture; + + it('Module exists', function () { + expect(Sprite).to.be.a('function'); + expect(PIXI).to.have.deep.property('blendModes.NORMAL', 0); + expect(PIXI).to.have.deep.property('blendModes.ADD', 1); + expect(PIXI).to.have.deep.property('blendModes.MULTIPLY', 2); + expect(PIXI).to.have.deep.property('blendModes.SCREEN', 3); + }); + + + it('Members exist', function () { + expect(Sprite).itself.to.respondTo('fromImage'); + expect(Sprite).itself.to.respondTo('fromFrame'); + }); + + it('Confirm new instance', function (done) { + var texture = Texture.fromImage('/base/test/textures/SpriteSheet-Aliens.png'); + var obj = new Sprite(texture); + + pixi_display_Sprite_confirmNew(obj, done); + }); +}); diff --git a/test/unit/pixi-v2/display/Stage.js b/test/unit/pixi-v2/display/Stage.js new file mode 100644 index 0000000..6974c2e --- /dev/null +++ b/test/unit/pixi-v2/display/Stage.js @@ -0,0 +1,49 @@ +describe('pixi/display/Stage', function () { + 'use strict'; + + var expect = chai.expect; + var Stage = PIXI.Stage; + var InteractionManager = PIXI.InteractionManager; + var Rectangle = PIXI.Rectangle; + + it('Module exists', function () { + expect(Stage).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Stage(null, true); + + pixi_display_DisplayObjectContainer_confirmNew(obj); + + expect(obj).to.be.an.instanceof(Stage); + expect(obj).to.respondTo('updateTransform'); + expect(obj).to.respondTo('setBackgroundColor'); + expect(obj).to.respondTo('getMousePosition'); + // FIXME: duplicate member in DisplayObject + pixi_core_Matrix_confirmNewMatrix(obj.worldTransform); + // FIXME: convert arg to bool in constructor + expect(obj).to.have.property('interactive', true); + + expect(obj).to.have.property('interactionManager') + .and.to.be.an.instanceof(InteractionManager) + .and.to.have.property('stage', obj); + + expect(obj).to.have.property('dirty', true); + + expect(obj).to.have.property('stage', obj); + + expect(obj).to.have.property('hitArea') + .and.to.be.an.instanceof(Rectangle); + pixi_core_Rectangle_confirm(obj.hitArea, 0, 0, 100000, 100000); + + expect(obj).to.have.property('backgroundColor', 0x000000); + expect(obj).to.have.deep.property('backgroundColorSplit.length', 3); + expect(obj).to.have.deep.property('backgroundColorSplit[0]', 0); + expect(obj).to.have.deep.property('backgroundColorSplit[1]', 0); + expect(obj).to.have.deep.property('backgroundColorSplit[2]', 0); + expect(obj).to.have.property('backgroundColorString', '#000000'); + + + expect(obj).to.have.property('worldVisible', true); + }); +}); diff --git a/test/unit/pixi-v2/extras/Rope.js b/test/unit/pixi-v2/extras/Rope.js new file mode 100644 index 0000000..05885ac --- /dev/null +++ b/test/unit/pixi-v2/extras/Rope.js @@ -0,0 +1,31 @@ +describe('pixi/extras/Rope', function () { + 'use strict'; + + var expect = chai.expect; + var Rope = PIXI.Rope; + var Texture = PIXI.Texture; + var Point = PIXI.Point; + + it('Module exists', function () { + expect(Rope).to.be.a('function'); + }); + + it('Confirm new instance', function () { + + var texture = Texture.fromImage('/base/test/textures/bunny.png'); + + // TODO-Alvin + // Same as Strip + + // var obj = new Rope(texture, [new Point(), new Point(5, 10), new Point(10, 20)]); + + // pixi_extras_Strip_confirmNew(obj); + + // expect(obj).to.be.an.instanceof(Rope); + // expect(obj).to.respondTo('refresh'); + // expect(obj).to.respondTo('updateTransform'); + // expect(obj).to.respondTo('setTexture'); + + // TODO: Test properties + }); +}); diff --git a/test/unit/pixi-v2/extras/Spine.js b/test/unit/pixi-v2/extras/Spine.js new file mode 100644 index 0000000..0708bc0 --- /dev/null +++ b/test/unit/pixi-v2/extras/Spine.js @@ -0,0 +1,10 @@ +describe('pixi/extras/Spine', function () { + 'use strict'; + + var expect = chai.expect; + var Spine = PIXI.Spine; + + it('Module exists', function () { + expect(Spine).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/extras/Strip.js b/test/unit/pixi-v2/extras/Strip.js new file mode 100644 index 0000000..230af90 --- /dev/null +++ b/test/unit/pixi-v2/extras/Strip.js @@ -0,0 +1,26 @@ +describe('pixi/extras/Strip', function () { + 'use strict'; + + var expect = chai.expect; + var Strip = PIXI.Strip; + var Texture = PIXI.Texture; + + it('Module exists', function () { + expect(Strip).to.be.a('function'); + }); + + it('Confirm new instance', function () { + + + // TODO-Alvin + // We tweaked it to make it pass the tests, but the whole strip class needs + // to be re-coded + + var texture = Texture.fromImage('/base/test/textures/bunny.png'); + + // var obj = new Strip(texture, 20, 10000); + + + // pixi_extras_Strip_confirmNew(obj); + }); +}); diff --git a/test/unit/pixi-v2/extras/TilingSprite.js b/test/unit/pixi-v2/extras/TilingSprite.js new file mode 100644 index 0000000..56aea14 --- /dev/null +++ b/test/unit/pixi-v2/extras/TilingSprite.js @@ -0,0 +1,24 @@ +describe('pixi/extras/TilingSprite', function () { + 'use strict'; + + var expect = chai.expect; + var TilingSprite = PIXI.TilingSprite; + var Texture = PIXI.Texture; + + it('Module exists', function () { + expect(TilingSprite).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var texture = Texture.fromImage('/base/test/textures/bunny.png'); + var obj = new TilingSprite(texture, 6000, 12000); + + pixi_display_DisplayObjectContainer_confirmNew(obj); + + expect(obj).to.be.an.instanceof(TilingSprite); + expect(obj).to.respondTo('setTexture'); + expect(obj).to.respondTo('onTextureUpdate'); + + // TODO: Test properties + }); +}); diff --git a/test/unit/pixi-v2/filters/FilterBlock.js b/test/unit/pixi-v2/filters/FilterBlock.js new file mode 100644 index 0000000..870cec0 --- /dev/null +++ b/test/unit/pixi-v2/filters/FilterBlock.js @@ -0,0 +1,10 @@ +describe('pixi/filters/FilterBlock', function () { + 'use strict'; + + var expect = chai.expect; + var FilterBlock = PIXI.FilterBlock; + + it('Module exists', function () { + expect(FilterBlock).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/AssetLoader.js b/test/unit/pixi-v2/loaders/AssetLoader.js new file mode 100644 index 0000000..a0aa0b5 --- /dev/null +++ b/test/unit/pixi-v2/loaders/AssetLoader.js @@ -0,0 +1,10 @@ +describe('pixi/loaders/AssetLoader', function () { + 'use strict'; + + var expect = chai.expect; + var AssetLoader = PIXI.AssetLoader; + + it('Module exists', function () { + expect(AssetLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/BitmapFontLoader.js b/test/unit/pixi-v2/loaders/BitmapFontLoader.js new file mode 100644 index 0000000..046f018 --- /dev/null +++ b/test/unit/pixi-v2/loaders/BitmapFontLoader.js @@ -0,0 +1,9 @@ +describe('pixi/loaders/BitmapFontLoader', function () { + 'use strict'; + + var expect = chai.expect; + + it('Module exists', function () { + expect(PIXI.BitmapFontLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/ImageLoader.js b/test/unit/pixi-v2/loaders/ImageLoader.js new file mode 100644 index 0000000..8b1f556 --- /dev/null +++ b/test/unit/pixi-v2/loaders/ImageLoader.js @@ -0,0 +1,10 @@ +describe('pixi/loaders/ImageLoader', function () { + 'use strict'; + + var expect = chai.expect; + var ImageLoader = PIXI.ImageLoader; + + it('Module exists', function () { + expect(ImageLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/JsonLoader.js b/test/unit/pixi-v2/loaders/JsonLoader.js new file mode 100644 index 0000000..c577e83 --- /dev/null +++ b/test/unit/pixi-v2/loaders/JsonLoader.js @@ -0,0 +1,10 @@ +describe('pixi/loaders/JsonLoader', function () { + 'use strict'; + + var expect = chai.expect; + var JsonLoader = PIXI.JsonLoader; + + it('Module exists', function () { + expect(JsonLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/SpineLoader.js b/test/unit/pixi-v2/loaders/SpineLoader.js new file mode 100644 index 0000000..fdcc0b8 --- /dev/null +++ b/test/unit/pixi-v2/loaders/SpineLoader.js @@ -0,0 +1,10 @@ +describe('pixi/loaders/SpineLoader', function () { + 'use strict'; + + var expect = chai.expect; + var SpineLoader = PIXI.SpineLoader; + + it('Module exists', function () { + expect(SpineLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/SpriteSheetLoader.js b/test/unit/pixi-v2/loaders/SpriteSheetLoader.js new file mode 100644 index 0000000..57beb27 --- /dev/null +++ b/test/unit/pixi-v2/loaders/SpriteSheetLoader.js @@ -0,0 +1,10 @@ +describe('pixi/loaders/SpriteSheetLoader', function () { + 'use strict'; + + var expect = chai.expect; + var SpriteSheetLoader = PIXI.SpriteSheetLoader; + + it('Module exists', function () { + expect(SpriteSheetLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/primitives/Graphics.js b/test/unit/pixi-v2/primitives/Graphics.js new file mode 100644 index 0000000..f3849eb --- /dev/null +++ b/test/unit/pixi-v2/primitives/Graphics.js @@ -0,0 +1,44 @@ +describe('pixi/primitives/Graphics', function () { + 'use strict'; + + var expect = chai.expect; + var Graphics = PIXI.Graphics; + + it('Module exists', function () { + expect(Graphics).to.be.a('function'); + + expect(Graphics).itself.to.have.property('POLY', 0); + expect(Graphics).itself.to.have.property('RECT', 1); + expect(Graphics).itself.to.have.property('CIRC', 2); + expect(Graphics).itself.to.have.property('ELIP', 3); + expect(Graphics).itself.to.have.property('RREC', 4); + }); + + it('Confirm new instance', function () { + var obj = new Graphics(); + + pixi_display_DisplayObjectContainer_confirmNew(obj); + + expect(obj).to.be.an.instanceof(Graphics); + expect(obj).to.respondTo('lineStyle'); + expect(obj).to.respondTo('lineStyle'); + expect(obj).to.respondTo('moveTo'); + expect(obj).to.respondTo('lineTo'); + expect(obj).to.respondTo('beginFill'); + expect(obj).to.respondTo('endFill'); + expect(obj).to.respondTo('drawRect'); + // expect(obj).to.respondTo('drawRoundedRect'); + expect(obj).to.respondTo('drawCircle'); + expect(obj).to.respondTo('drawEllipse'); + expect(obj).to.respondTo('clear'); + + expect(obj).to.have.property('renderable', true); + expect(obj).to.have.property('fillAlpha', 1); + expect(obj).to.have.property('lineWidth', 0); + expect(obj).to.have.property('width', 0); + expect(obj).to.have.property('height', 0); + expect(obj).to.have.property('lineColor', 0); + expect(obj).to.have.deep.property('graphicsData.length', 0); + // expect(obj).to.have.deep.property('currentPath.points.length', 0); + }); +}); diff --git a/test/unit/pixi-v2/renderers/canvas/CanvasGraphics.js b/test/unit/pixi-v2/renderers/canvas/CanvasGraphics.js new file mode 100644 index 0000000..8f44472 --- /dev/null +++ b/test/unit/pixi-v2/renderers/canvas/CanvasGraphics.js @@ -0,0 +1,15 @@ +describe('renders/canvas/CanvasGraphics', function () { + 'use strict'; + + var expect = chai.expect; + var CanvasGraphics = PIXI.CanvasGraphics; + + it('Module exists', function () { + expect(CanvasGraphics).to.be.a('function'); + }); + + it('Members exist', function () { + expect(CanvasGraphics).itself.to.respondTo('renderGraphics'); + expect(CanvasGraphics).itself.to.respondTo('renderGraphicsMask'); + }); +}); diff --git a/test/unit/pixi-v2/renderers/canvas/CanvasRenderer.js b/test/unit/pixi-v2/renderers/canvas/CanvasRenderer.js new file mode 100644 index 0000000..1646444 --- /dev/null +++ b/test/unit/pixi-v2/renderers/canvas/CanvasRenderer.js @@ -0,0 +1,36 @@ +describe('renderers/canvas/CanvasRenderer', function () { + 'use strict'; + + var expect = chai.expect; + var CanvasRenderer = PIXI.CanvasRenderer; + + it('Module exists', function () { + expect(CanvasRenderer).to.be.a('function'); + }); + + describe('.autoResize', function () { + it('Should automatically resize view if enabled', function () { + var renderer = new CanvasRenderer(200, 200, { + autoResize: true + }); + + expect(renderer.view.style.width).to.equal('200px'); + }); + + it('Should not automatically resize view if disabled', function () { + var renderer = new CanvasRenderer(200, 200, { + autoResize: false + }); + + expect(renderer.view.style.width).to.equal(''); + }); + + it('Should not automatically resize view if not specified', function () { + var renderer = new CanvasRenderer(200, 200, { + resolution: 2 + }); + + expect(renderer.view.style.width).to.equal(''); + }); + }); +}); diff --git a/test/unit/pixi-v2/renderers/webgl/WebGLGraphics.js b/test/unit/pixi-v2/renderers/webgl/WebGLGraphics.js new file mode 100644 index 0000000..5867b28 --- /dev/null +++ b/test/unit/pixi-v2/renderers/webgl/WebGLGraphics.js @@ -0,0 +1,20 @@ +describe('renderers/wegbl/WebGLGraphics', function () { + 'use strict'; + + var expect = chai.expect; + var WebGLGraphics = PIXI.WebGLGraphics; + + it('Module exists', function () { + expect(WebGLGraphics).to.be.a('function'); + }); + + it('Members exist', function () { + expect(WebGLGraphics).itself.to.respondTo('renderGraphics'); + expect(WebGLGraphics).itself.to.respondTo('updateGraphics'); + expect(WebGLGraphics).itself.to.respondTo('buildRectangle'); + expect(WebGLGraphics).itself.to.respondTo('buildRoundedRectangle'); + expect(WebGLGraphics).itself.to.respondTo('buildCircle'); + expect(WebGLGraphics).itself.to.respondTo('buildLine'); + expect(WebGLGraphics).itself.to.respondTo('buildPoly'); + }); +}); diff --git a/test/unit/pixi-v2/renderers/webgl/WebGLRenderer.js b/test/unit/pixi-v2/renderers/webgl/WebGLRenderer.js new file mode 100644 index 0000000..1680a80 --- /dev/null +++ b/test/unit/pixi-v2/renderers/webgl/WebGLRenderer.js @@ -0,0 +1,49 @@ +describe('renderers/webgl/WebGLRenderer', function () { + 'use strict'; + + var expect = chai.expect; + var WebGLRenderer = PIXI.WebGLRenderer; + + it('Module exists', function () { + expect(WebGLRenderer).to.be.a('function'); + }); + + // Skip tests if WebGL is not available (WebGL not supported in Travis CI) + try { + var renderer = new WebGLRenderer(400, 300, {}); + renderer.destroy(); + } catch (error) { + return; + } + + it('Destroy renderer', function () { + var renderer = new WebGLRenderer(400, 300, {}); + renderer.destroy(); + }); + + describe('.autoResize', function () { + it('Should automatically resize view if enabled', function () { + var renderer = new WebGLRenderer(200, 200, { + autoResize: true + }); + + expect(renderer.view.style.width).to.equal('200px'); + }); + + it('Should not automatically resize view if disabled', function () { + var renderer = new WebGLRenderer(200, 200, { + autoResize: false + }); + + expect(renderer.view.style.width).to.equal(''); + }); + + it('Should not automatically resize view if not specified', function () { + var renderer = new WebGLRenderer(200, 200, { + resolution: 2 + }); + + expect(renderer.view.style.width).to.equal(''); + }); + }); +}); diff --git a/test/unit/pixi-v2/renderers/webgl/WebGLShaders.js b/test/unit/pixi-v2/renderers/webgl/WebGLShaders.js new file mode 100644 index 0000000..6e33e4f --- /dev/null +++ b/test/unit/pixi-v2/renderers/webgl/WebGLShaders.js @@ -0,0 +1,13 @@ +describe('renderers/webgl/WebGLShaders', function () { + 'use strict'; + + var expect = chai.expect; + + it('Module members exist', function () { + + expect(PIXI).to.respondTo('CompileVertexShader'); + expect(PIXI).to.respondTo('CompileFragmentShader'); + expect(PIXI).to.respondTo('_CompileShader'); + expect(PIXI).to.respondTo('compileProgram'); + }); +}); diff --git a/test/unit/pixi-v2/renderers/webgl/WebGLSpriteBatch.js b/test/unit/pixi-v2/renderers/webgl/WebGLSpriteBatch.js new file mode 100644 index 0000000..e662b63 --- /dev/null +++ b/test/unit/pixi-v2/renderers/webgl/WebGLSpriteBatch.js @@ -0,0 +1,10 @@ +describe('renderers/webgl/utils/WebGLSpriteBatch', function () { + 'use strict'; + + var expect = chai.expect; + var WebGLSpriteBatch = PIXI.WebGLSpriteBatch; + + it('Module exists', function () { + expect(WebGLSpriteBatch).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/text/BitmapText.js b/test/unit/pixi-v2/text/BitmapText.js new file mode 100644 index 0000000..9388e3d --- /dev/null +++ b/test/unit/pixi-v2/text/BitmapText.js @@ -0,0 +1,10 @@ +describe('pixi/text/BitmapText', function () { + 'use strict'; + + var expect = chai.expect; + var BitmapText = PIXI.BitmapText; + + it('Module exists', function () { + expect(BitmapText).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/text/Text.js b/test/unit/pixi-v2/text/Text.js new file mode 100644 index 0000000..9bc9ac5 --- /dev/null +++ b/test/unit/pixi-v2/text/Text.js @@ -0,0 +1,10 @@ +describe('pixi/text/Text', function () { + 'use strict'; + + var expect = chai.expect; + var Text = PIXI.Text; + + it('Module exists', function () { + expect(Text).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/textures/BaseTexture.js b/test/unit/pixi-v2/textures/BaseTexture.js new file mode 100644 index 0000000..502b724 --- /dev/null +++ b/test/unit/pixi-v2/textures/BaseTexture.js @@ -0,0 +1,11 @@ +describe('pixi/textures/BaseTexture', function () { + 'use strict'; + + var expect = chai.expect; + var BaseTexture = PIXI.BaseTexture; + + it('Module exists', function () { + expect(BaseTexture).to.be.a('function'); + expect(PIXI).to.have.property('BaseTextureCache').and.to.be.an('object'); + }); +}); diff --git a/test/unit/pixi-v2/textures/RenderTexture.js b/test/unit/pixi-v2/textures/RenderTexture.js new file mode 100644 index 0000000..96acdb4 --- /dev/null +++ b/test/unit/pixi-v2/textures/RenderTexture.js @@ -0,0 +1,15 @@ +describe('pixi/textures/RenderTexture', function () { + 'use strict'; + + var expect = chai.expect; + var RenderTexture = PIXI.RenderTexture; + + it('Module exists', function () { + expect(RenderTexture).to.be.a('function'); + }); + + it('Confirm new instance', function (done) { + var texture = new RenderTexture(100, 100, new PIXI.CanvasRenderer()); + pixi_textures_RenderTexture_confirmNew(texture, done); + }); +}); diff --git a/test/unit/pixi-v2/textures/Texture.js b/test/unit/pixi-v2/textures/Texture.js new file mode 100644 index 0000000..090f64d --- /dev/null +++ b/test/unit/pixi-v2/textures/Texture.js @@ -0,0 +1,26 @@ +describe('pixi/textures/Texture', function () { + 'use strict'; + + var expect = chai.expect; + var Texture = PIXI.Texture; + + it('Module exists', function () { + expect(Texture).to.be.a('function'); + expect(PIXI).to.have.property('TextureCache').and.to.be.an('object'); + }); + + it('Members exist', function () { + expect(Texture).itself.to.respondTo('fromImage'); + expect(Texture).itself.to.respondTo('fromFrame'); + expect(Texture).itself.to.respondTo('fromCanvas'); + expect(Texture).itself.to.respondTo('addTextureToCache'); + expect(Texture).itself.to.respondTo('removeTextureFromCache'); + + // expect(Texture).itself.to.have.deep.property('frameUpdates.length', 0); + }); + + it('Confirm new instance', function (done) { + var texture = Texture.fromImage('/base/test/textures/bunny.png'); + pixi_textures_Texture_confirmNew(texture, done); + }); +}); diff --git a/test/unit/pixi-v2/utils/Detector.js b/test/unit/pixi-v2/utils/Detector.js new file mode 100644 index 0000000..4cf6008 --- /dev/null +++ b/test/unit/pixi-v2/utils/Detector.js @@ -0,0 +1,10 @@ +describe('pixi/utils/Detector', function () { + 'use strict'; + + var expect = chai.expect; + var autoDetectRenderer = PIXI.autoDetectRenderer; + + it('Module exists', function () { + expect(autoDetectRenderer).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/utils/EventTarget.js b/test/unit/pixi-v2/utils/EventTarget.js new file mode 100644 index 0000000..1cfc3a4 --- /dev/null +++ b/test/unit/pixi-v2/utils/EventTarget.js @@ -0,0 +1,361 @@ +describe('pixi/utils/EventTarget', function () { + 'use strict'; + + var expect = chai.expect; + + var Clazz, PClazz, obj, pobj, obj2; + beforeEach(function () { + Clazz = function () {}; + PClazz = function () {}; + + PIXI.EventTarget.mixin(Clazz.prototype); + PIXI.EventTarget.mixin(PClazz.prototype); + + obj = new Clazz(); + obj2 = new Clazz(); + pobj = new PClazz(); + + obj.parent = pobj; + obj2.parent = obj; + }); + + it('Module exists', function () { + expect(PIXI.EventTarget).to.be.an('object'); + }); + + it('Confirm new instance', function () { + pixi_utils_EventTarget_confirm(obj); + }); + + it('simple on/emit case works', function () { + var myData = {}; + + obj.on('myevent', function (event) { + pixi_utils_EventTarget_Event_confirm(event, obj, myData); + }); + + obj.emit('myevent', myData); + }); + + it('simple once case works', function () { + var called = 0; + + obj.once('myevent', function() { called++; }); + + obj.emit('myevent'); + obj.emit('myevent'); + obj.emit('myevent'); + obj.emit('myevent'); + obj.emit('myevent'); + + expect(called).to.equal(1); + }); + + it('simple off case works', function (done) { + function onMyEvent() { + done(new Error('Event listener should not have been called')); + } + + obj.on('myevent', onMyEvent); + obj.off('myevent', onMyEvent); + obj.emit('myevent'); + + done(); + }); + + it('simple propagation case works', function (done) { + var myData = {}; + + pobj.on('myevent', function () { + done(); + }); + + obj.emit('myevent'); + }); + + it('simple stopPropagation case works', function (done) { + var myData = {}; + + pobj.on('myevent', function () { + done(new Error('Event listener should not have been called on the parent element')); + }); + + obj.on('myevent', function (evt) { + evt.stopPropagation(); + }); + + obj.emit('myevent'); + + done(); + }); + + it('simple stopImmediatePropagation case works', function (done) { + var myData = {}; + + pobj.on('myevent', function () { + done(new Error('Event listener should not have been called on the parent')); + }); + + obj.on('myevent', function (evt) { + evt.stopImmediatePropagation(); + }); + + obj.on('myevent', function () { + done(new Error('Event listener should not have been called on the second')); + }); + + obj.emit('myevent'); + + done(); + }); + + it('multiple dispatches work properly', function () { + var called = 0; + + function onMyEvent() { + called++; + } + + obj.on('myevent', onMyEvent); + obj.emit('myevent'); + obj.emit('myevent'); + obj.emit('myevent'); + obj.emit('myevent'); + + expect(called).to.equal(4); + }); + + it('multiple events work properly', function () { + var called = 0; + + function onMyEvent() { + called++; + } + + obj.on('myevent1', onMyEvent); + obj.on('myevent2', onMyEvent); + obj.on('myevent3', onMyEvent); + obj.emit('myevent1'); + obj.emit('myevent2'); + obj.emit('myevent3'); + + expect(called).to.equal(3); + }); + + it('multiple events one removed works properly', function () { + var called = 0; + + function onMyEvent() { + called++; + } + + obj.on('myevent1', onMyEvent); + obj.on('myevent2', onMyEvent); + obj.on('myevent3', onMyEvent); + + obj.emit('myevent1'); + obj.emit('myevent2'); + obj.emit('myevent3'); + + obj.off('myevent2', onMyEvent); + + obj.emit('myevent1'); + obj.emit('myevent2'); + obj.emit('myevent3'); + + expect(called).to.equal(5); + }); + + it('multiple handlers for one event with some removed', function () { + var called = 0; + + var onMyEvent = function () { + called++; + }, + onMyEvent2 = function () { + called++; + }; + + // add 2 handlers and confirm they both get called + obj.on('myevent', onMyEvent); + obj.on('myevent', onMyEvent); + obj.on('myevent', onMyEvent2); + obj.on('myevent', onMyEvent2); + + obj.emit('myevent'); + + expect(called).to.equal(4); + + // remove one of the handlers, emit again, then ensure 1 more call is made + obj.off('myevent', onMyEvent); + + obj.emit('myevent'); + + expect(called).to.equal(6); + }); + + it('calls to off without a handler do nothing', function () { + var called = 0; + + var onMyEvent = function () { + called++; + }; + + obj.on('myevent', onMyEvent); + obj.on('myevent', onMyEvent); + + obj.emit('myevent'); + + expect(called).to.equal(2); + + obj.off('myevent'); + + obj.emit('myevent'); + + expect(called).to.equal(4); + + obj.off('myevent', onMyEvent); + + obj.emit('myevent'); + + expect(called).to.equal(4); + }); + + it('handles multiple instances with the same prototype', function () { + var called = 0; + + function onMyEvent(e) { + called++; + } + + obj.on('myevent1', onMyEvent); + obj.on('myevent2', onMyEvent); + + obj2.istwo = true; + obj2.on('myevent1', onMyEvent); + obj2.on('myevent2', onMyEvent); + + obj.emit('myevent1'); + obj.emit('myevent2'); + obj2.emit('myevent1'); + obj2.emit('myevent2'); + + //we emit 4 times, but since obj2 is a child of obj the event should bubble + //up to obj and show up there as well. So the obj2.emit() calls each increment + //the counter twice. + expect(called).to.equal(6); + }); + + it('is backwards compatible with older .dispatchEvent({})', function () { + var called = 0, + data = { + some: 'thing', + hello: true + }; + + function onMyEvent(event) { + pixi_utils_EventTarget_Event_confirm(event, obj, data); + + called++; + } + + obj.on('myevent1', onMyEvent); + obj.on('myevent2', onMyEvent); + obj.on('myevent3', onMyEvent); + + data.type = 'myevent1'; + obj.emit(data); + + data.type = 'myevent2'; + obj.emit(data); + + data.type = 'myevent3'; + obj.emit(data); + + obj.off('myevent2', onMyEvent); + + data.type = 'myevent1'; + obj.emit(data); + + data.type = 'myevent2'; + obj.emit(data); + + data.type = 'myevent3'; + obj.emit(data); + + expect(called).to.equal(5); + }); + + it('is backwards compatible with older .call(this)', function () { + var Fn = function() { + PIXI.EventTarget.call(this); + }, + o = new Fn(); + + pixi_utils_EventTarget_confirm(o); + }); + + it('is backwards compatible with older .addEventListener("")', function () { + var called = 0, + data = { + some: 'thing', + hello: true + }; + + function onMyEvent(event) { + pixi_utils_EventTarget_Event_confirm(event, obj, data); + + called++; + } + + obj.addEventListener('myevent1', onMyEvent); + obj.addEventListener('myevent2', onMyEvent); + obj.addEventListener('myevent3', onMyEvent); + + data.type = 'myevent1'; + obj.emit(data); + + data.type = 'myevent2'; + obj.emit(data); + + data.type = 'myevent3'; + obj.emit(data); + + obj.off('myevent2', onMyEvent); + + data.type = 'myevent1'; + obj.emit(data); + + data.type = 'myevent2'; + obj.emit(data); + + data.type = 'myevent3'; + obj.emit(data); + + expect(called).to.equal(5); + }); + + it('event remove during emit call properly', function () { + var called = 0; + + function cb1() { + called++; + obj.off('myevent', cb1); + } + function cb2() { + called++; + obj.off('myevent', cb2); + } + function cb3() { + called++; + obj.off('myevent', cb3); + } + + obj.on('myevent', cb1); + obj.on('myevent', cb2); + obj.on('myevent', cb3); + obj.emit('myevent', ''); + + expect(called).to.equal(3); + }); +}); diff --git a/test/unit/pixi-v2/utils/Polyk.js b/test/unit/pixi-v2/utils/Polyk.js new file mode 100644 index 0000000..dfc7128 --- /dev/null +++ b/test/unit/pixi-v2/utils/Polyk.js @@ -0,0 +1,14 @@ +describe('pixi/utils/Polyk', function () { + 'use strict'; + + var expect = chai.expect; + var PolyK = PIXI.PolyK; + + it('Module exists', function () { + expect(PolyK).to.be.an('object'); + }); + + it('Members exist', function () { + expect(PolyK).to.respondTo('Triangulate'); + }); +}); diff --git a/test/unit/pixi-v2/utils/Utils.js b/test/unit/pixi-v2/utils/Utils.js new file mode 100644 index 0000000..c97b3c6 --- /dev/null +++ b/test/unit/pixi-v2/utils/Utils.js @@ -0,0 +1,17 @@ +describe('Utils', function () { + 'use strict'; + + var expect = chai.expect; + + it('requestAnimationFrame exists', function () { + expect(global).to.respondTo('requestAnimationFrame'); + }); + + it('cancelAnimationFrame exists', function () { + expect(global).to.respondTo('cancelAnimationFrame'); + }); + + it('requestAnimFrame exists', function () { + expect(global).to.respondTo('requestAnimFrame'); + }); +}); diff --git a/test/unit/pixi/InteractionManager.js b/test/unit/pixi/InteractionManager.js deleted file mode 100644 index ed3001f..0000000 --- a/test/unit/pixi/InteractionManager.js +++ /dev/null @@ -1,10 +0,0 @@ -describe('pixi/InteractionManager', function () { - 'use strict'; - - var expect = chai.expect; - var InteractionManager = PIXI.InteractionManager; - - it('Module exists', function () { - expect(InteractionManager).to.be.a('function'); - }); -}); diff --git a/test/unit/pixi/Pixi.js b/test/unit/pixi/Pixi.js deleted file mode 100644 index 27debc1..0000000 --- a/test/unit/pixi/Pixi.js +++ /dev/null @@ -1,9 +0,0 @@ -describe('pixi/Pixi', function () { - 'use strict'; - - var expect = chai.expect; - - it('Module exists', function () { - expect(global).to.have.property('PIXI').and.to.be.an('object'); - }); -}); diff --git a/test/unit/pixi/core/Circle.js b/test/unit/pixi/core/Circle.js deleted file mode 100644 index fbcfa17..0000000 --- a/test/unit/pixi/core/Circle.js +++ /dev/null @@ -1,21 +0,0 @@ -describe('pixi/core/Circle', function () { - 'use strict'; - - var expect = chai.expect; - var Circle = PIXI.Circle; - - it('Module exists', function () { - expect(Circle).to.be.a('function'); - }); - - it('Confirm new instance', function () { - var obj = new Circle(); - pixi_core_Circle_confirmNewCircle(obj); - }); - - it("getBounds should return Rectangle that bounds the circle", function() { - var obj = new Circle(100, 250, 50); - var bounds = obj.getBounds(); - pixi_core_Circle_isBoundedByRectangle(obj, bounds); - }); -}); diff --git a/test/unit/pixi/core/Ellipse.js b/test/unit/pixi/core/Ellipse.js deleted file mode 100644 index 026b56f..0000000 --- a/test/unit/pixi/core/Ellipse.js +++ /dev/null @@ -1,24 +0,0 @@ -describe('pixi/core/Ellipse', function () { - 'use strict'; - - var expect = chai.expect; - var Ellipse = PIXI.Ellipse; - - it('Module exists', function () { - expect(Ellipse).to.be.a('function'); - }); - - it('Confirm new instance', function () { - var obj = new Ellipse(); - - expect(obj).to.be.an.instanceof(Ellipse); - expect(obj).to.respondTo('clone'); - expect(obj).to.respondTo('contains'); - expect(obj).to.respondTo('getBounds'); - - expect(obj).to.have.property('x', 0); - expect(obj).to.have.property('y', 0); - expect(obj).to.have.property('width', 0); - expect(obj).to.have.property('height', 0); - }); -}); diff --git a/test/unit/pixi/core/Matrix.js b/test/unit/pixi/core/Matrix.js deleted file mode 100644 index da75e2e..0000000 --- a/test/unit/pixi/core/Matrix.js +++ /dev/null @@ -1,14 +0,0 @@ -describe('pixi/core/Matrix', function () { - 'use strict'; - - var expect = chai.expect; - - it('Matrix exists', function () { - expect(PIXI.Matrix).to.be.an('function'); - }); - - it('Confirm new Matrix', function () { - var matrix = new PIXI.Matrix(); - pixi_core_Matrix_confirmNewMatrix(matrix); - }); -}); diff --git a/test/unit/pixi/core/Point.js b/test/unit/pixi/core/Point.js deleted file mode 100644 index c4d5163..0000000 --- a/test/unit/pixi/core/Point.js +++ /dev/null @@ -1,15 +0,0 @@ -describe('pixi/core/Point', function () { - 'use strict'; - - var expect = chai.expect; - var Point = PIXI.Point; - - it('Module exists', function () { - expect(Point).to.be.a('function'); - }); - - it('Confirm new instance', function () { - var obj = new Point(); - pixi_core_Point_confirm(obj, 0, 0); - }); -}); diff --git a/test/unit/pixi/core/Polygon.js b/test/unit/pixi/core/Polygon.js deleted file mode 100644 index dc8c918..0000000 --- a/test/unit/pixi/core/Polygon.js +++ /dev/null @@ -1,20 +0,0 @@ -describe('pixi/core/Polygon', function () { - 'use strict'; - - var expect = chai.expect; - var Polygon = PIXI.Polygon; - - it('Module exists', function () { - expect(Polygon).to.be.a('function'); - }); - - it('Confirm new instance', function () { - var obj = new Polygon(); - - expect(obj).to.be.an.instanceof(Polygon); - expect(obj).to.respondTo('clone'); - expect(obj).to.respondTo('contains'); - - expect(obj).to.have.deep.property('points.length', 0); - }); -}); diff --git a/test/unit/pixi/core/Rectangle.js b/test/unit/pixi/core/Rectangle.js deleted file mode 100644 index d43316e..0000000 --- a/test/unit/pixi/core/Rectangle.js +++ /dev/null @@ -1,15 +0,0 @@ -describe('pixi/core/Rectangle', function () { - 'use strict'; - - var expect = chai.expect; - var Rectangle = PIXI.Rectangle; - - it('Module exists', function () { - expect(Rectangle).to.be.a('function'); - }); - - it('Confirm new instance', function () { - var rect = new Rectangle(); - pixi_core_Rectangle_confirm(rect, 0, 0, 0, 0); - }); -}); diff --git a/test/unit/pixi/display/DisplayObject.js b/test/unit/pixi/display/DisplayObject.js deleted file mode 100644 index 044acf8..0000000 --- a/test/unit/pixi/display/DisplayObject.js +++ /dev/null @@ -1,21 +0,0 @@ -describe('pixi/display/DisplayObject', function () { - 'use strict'; - - var expect = chai.expect; - var DisplayObject = PIXI.DisplayObject; - - it('Module exists', function () { - expect(DisplayObject).to.be.a('function'); - // expect(PIXI).to.have.property('visibleCount', 0); - }); - - it('Confirm new instance', function () { - var obj = new DisplayObject(); - - pixi_display_DisplayObject_confirmNew(obj); - expect(obj).to.have.property('hitArea', null); - expect(obj).to.have.property('interactive', false); - expect(obj).to.have.property('renderable', false); - expect(obj).to.have.property('stage', null); - }); -}); diff --git a/test/unit/pixi/display/DisplayObjectContainer.js b/test/unit/pixi/display/DisplayObjectContainer.js deleted file mode 100644 index 15a3376..0000000 --- a/test/unit/pixi/display/DisplayObjectContainer.js +++ /dev/null @@ -1,67 +0,0 @@ -describe('pixi/display/DisplayObjectContainer', function () { - 'use strict'; - - var expect = chai.expect; - var DisplayObjectContainer = PIXI.DisplayObjectContainer; - - it('Module exists', function () { - expect(DisplayObjectContainer).to.be.a('function'); - }); - - it('Confirm new instance', function () { - var obj = new DisplayObjectContainer(); - - pixi_display_DisplayObjectContainer_confirmNew(obj); - expect(obj).to.have.property('hitArea', null); - expect(obj).to.have.property('interactive', false); - expect(obj).to.have.property('renderable', false); - expect(obj).to.have.property('stage', null); - }); - - it('Gets child index', function() { - var container = new PIXI.DisplayObjectContainer(); - var children = []; - for (var i = 0; i < 10; i++) { - var child = new PIXI.DisplayObject(); - children.push(child); - container.addChild(child); - } - - for (i = 0; i < children.length; i++) { - expect(i).to.eql(container.getChildIndex(children[i])); - } - }); - - it('throws error when trying to get index of not a child', function() { - var container = new PIXI.DisplayObjectContainer(); - var child = new PIXI.DisplayObject(); - - expect(function() { container.getChildIndex(child); }).to.throw(); - }); - - it('Sets child index', function() { - var container = new PIXI.DisplayObjectContainer(); - var children = []; - - for (var i = 0; i < 10; i++) { - var child = new PIXI.DisplayObject(); - children.push(child); - container.addChild(child); - } - children.reverse(); - - for (i = 0; i < children.length; i++) { - container.setChildIndex(children[i], i); - expect(i).to.eql(container.getChildIndex(children[i])); - } - }); - - it('throws error when trying to set incorect index', function() { - var container = new PIXI.DisplayObjectContainer(); - var child = new PIXI.DisplayObject(); - container.addChild(child); - - expect(function() { container.setChildIndex(child, -1); }).to.throw(); - expect(function() { container.setChildIndex(child, 1); }).to.throw(); - }); -}); diff --git a/test/unit/pixi/display/MovieClip.js b/test/unit/pixi/display/MovieClip.js deleted file mode 100644 index f3c6c6a..0000000 --- a/test/unit/pixi/display/MovieClip.js +++ /dev/null @@ -1,33 +0,0 @@ -describe('pixi/display/MovieClip', function () { - 'use strict'; - - var expect = chai.expect; - var MovieClip = PIXI.MovieClip; - var Texture = PIXI.Texture; - - it('Module exists', function () { - expect(MovieClip).to.be.a('function'); - }); - - it('Confirm new instance', function (done) { - var texture = Texture.fromImage('/base/test/textures/SpriteSheet-Explosion.png'); - var obj = new MovieClip([texture]); - - pixi_display_Sprite_confirmNew(obj, done); - - expect(obj).to.be.an.instanceof(MovieClip); - expect(obj).to.respondTo('stop'); - expect(obj).to.respondTo('play'); - expect(obj).to.respondTo('gotoAndStop'); - expect(obj).to.respondTo('gotoAndPlay'); - expect(obj).to.respondTo('updateTransform'); - - expect(obj).to.have.deep.property('textures.length', 1); - expect(obj).to.have.deep.property('textures[0]', texture); - expect(obj).to.have.property('animationSpeed', 1); - expect(obj).to.have.property('loop', true); - expect(obj).to.have.property('onComplete', null); - expect(obj).to.have.property('currentFrame', 0); - expect(obj).to.have.property('playing', false); - }); -}); diff --git a/test/unit/pixi/display/Sprite.js b/test/unit/pixi/display/Sprite.js deleted file mode 100644 index 30c8076..0000000 --- a/test/unit/pixi/display/Sprite.js +++ /dev/null @@ -1,28 +0,0 @@ -describe('pixi/display/Sprite', function () { - 'use strict'; - - var expect = chai.expect; - var Sprite = PIXI.Sprite; - var Texture = PIXI.Texture; - - it('Module exists', function () { - expect(Sprite).to.be.a('function'); - expect(PIXI).to.have.deep.property('blendModes.NORMAL', 0); - expect(PIXI).to.have.deep.property('blendModes.ADD', 1); - expect(PIXI).to.have.deep.property('blendModes.MULTIPLY', 2); - expect(PIXI).to.have.deep.property('blendModes.SCREEN', 3); - }); - - - it('Members exist', function () { - expect(Sprite).itself.to.respondTo('fromImage'); - expect(Sprite).itself.to.respondTo('fromFrame'); - }); - - it('Confirm new instance', function (done) { - var texture = Texture.fromImage('/base/test/textures/SpriteSheet-Aliens.png'); - var obj = new Sprite(texture); - - pixi_display_Sprite_confirmNew(obj, done); - }); -}); diff --git a/test/unit/pixi/display/Stage.js b/test/unit/pixi/display/Stage.js deleted file mode 100644 index 6974c2e..0000000 --- a/test/unit/pixi/display/Stage.js +++ /dev/null @@ -1,49 +0,0 @@ -describe('pixi/display/Stage', function () { - 'use strict'; - - var expect = chai.expect; - var Stage = PIXI.Stage; - var InteractionManager = PIXI.InteractionManager; - var Rectangle = PIXI.Rectangle; - - it('Module exists', function () { - expect(Stage).to.be.a('function'); - }); - - it('Confirm new instance', function () { - var obj = new Stage(null, true); - - pixi_display_DisplayObjectContainer_confirmNew(obj); - - expect(obj).to.be.an.instanceof(Stage); - expect(obj).to.respondTo('updateTransform'); - expect(obj).to.respondTo('setBackgroundColor'); - expect(obj).to.respondTo('getMousePosition'); - // FIXME: duplicate member in DisplayObject - pixi_core_Matrix_confirmNewMatrix(obj.worldTransform); - // FIXME: convert arg to bool in constructor - expect(obj).to.have.property('interactive', true); - - expect(obj).to.have.property('interactionManager') - .and.to.be.an.instanceof(InteractionManager) - .and.to.have.property('stage', obj); - - expect(obj).to.have.property('dirty', true); - - expect(obj).to.have.property('stage', obj); - - expect(obj).to.have.property('hitArea') - .and.to.be.an.instanceof(Rectangle); - pixi_core_Rectangle_confirm(obj.hitArea, 0, 0, 100000, 100000); - - expect(obj).to.have.property('backgroundColor', 0x000000); - expect(obj).to.have.deep.property('backgroundColorSplit.length', 3); - expect(obj).to.have.deep.property('backgroundColorSplit[0]', 0); - expect(obj).to.have.deep.property('backgroundColorSplit[1]', 0); - expect(obj).to.have.deep.property('backgroundColorSplit[2]', 0); - expect(obj).to.have.property('backgroundColorString', '#000000'); - - - expect(obj).to.have.property('worldVisible', true); - }); -}); diff --git a/test/unit/pixi/extras/Rope.js b/test/unit/pixi/extras/Rope.js deleted file mode 100644 index 05885ac..0000000 --- a/test/unit/pixi/extras/Rope.js +++ /dev/null @@ -1,31 +0,0 @@ -describe('pixi/extras/Rope', function () { - 'use strict'; - - var expect = chai.expect; - var Rope = PIXI.Rope; - var Texture = PIXI.Texture; - var Point = PIXI.Point; - - it('Module exists', function () { - expect(Rope).to.be.a('function'); - }); - - it('Confirm new instance', function () { - - var texture = Texture.fromImage('/base/test/textures/bunny.png'); - - // TODO-Alvin - // Same as Strip - - // var obj = new Rope(texture, [new Point(), new Point(5, 10), new Point(10, 20)]); - - // pixi_extras_Strip_confirmNew(obj); - - // expect(obj).to.be.an.instanceof(Rope); - // expect(obj).to.respondTo('refresh'); - // expect(obj).to.respondTo('updateTransform'); - // expect(obj).to.respondTo('setTexture'); - - // TODO: Test properties - }); -}); diff --git a/test/unit/pixi/extras/Spine.js b/test/unit/pixi/extras/Spine.js deleted file mode 100644 index 0708bc0..0000000 --- a/test/unit/pixi/extras/Spine.js +++ /dev/null @@ -1,10 +0,0 @@ -describe('pixi/extras/Spine', function () { - 'use strict'; - - var expect = chai.expect; - var Spine = PIXI.Spine; - - it('Module exists', function () { - expect(Spine).to.be.a('function'); - }); -}); diff --git a/test/unit/pixi/extras/Strip.js b/test/unit/pixi/extras/Strip.js deleted file mode 100644 index 230af90..0000000 --- a/test/unit/pixi/extras/Strip.js +++ /dev/null @@ -1,26 +0,0 @@ -describe('pixi/extras/Strip', function () { - 'use strict'; - - var expect = chai.expect; - var Strip = PIXI.Strip; - var Texture = PIXI.Texture; - - it('Module exists', function () { - expect(Strip).to.be.a('function'); - }); - - it('Confirm new instance', function () { - - - // TODO-Alvin - // We tweaked it to make it pass the tests, but the whole strip class needs - // to be re-coded - - var texture = Texture.fromImage('/base/test/textures/bunny.png'); - - // var obj = new Strip(texture, 20, 10000); - - - // pixi_extras_Strip_confirmNew(obj); - }); -}); diff --git a/test/unit/pixi/extras/TilingSprite.js b/test/unit/pixi/extras/TilingSprite.js deleted file mode 100644 index 56aea14..0000000 --- a/test/unit/pixi/extras/TilingSprite.js +++ /dev/null @@ -1,24 +0,0 @@ -describe('pixi/extras/TilingSprite', function () { - 'use strict'; - - var expect = chai.expect; - var TilingSprite = PIXI.TilingSprite; - var Texture = PIXI.Texture; - - it('Module exists', function () { - expect(TilingSprite).to.be.a('function'); - }); - - it('Confirm new instance', function () { - var texture = Texture.fromImage('/base/test/textures/bunny.png'); - var obj = new TilingSprite(texture, 6000, 12000); - - pixi_display_DisplayObjectContainer_confirmNew(obj); - - expect(obj).to.be.an.instanceof(TilingSprite); - expect(obj).to.respondTo('setTexture'); - expect(obj).to.respondTo('onTextureUpdate'); - - // TODO: Test properties - }); -}); diff --git a/test/unit/pixi/filters/FilterBlock.js b/test/unit/pixi/filters/FilterBlock.js deleted file mode 100644 index 870cec0..0000000 --- a/test/unit/pixi/filters/FilterBlock.js +++ /dev/null @@ -1,10 +0,0 @@ -describe('pixi/filters/FilterBlock', function () { - 'use strict'; - - var expect = chai.expect; - var FilterBlock = PIXI.FilterBlock; - - it('Module exists', function () { - expect(FilterBlock).to.be.a('function'); - }); -}); diff --git a/test/unit/pixi/loaders/AssetLoader.js b/test/unit/pixi/loaders/AssetLoader.js deleted file mode 100644 index a0aa0b5..0000000 --- a/test/unit/pixi/loaders/AssetLoader.js +++ /dev/null @@ -1,10 +0,0 @@ -describe('pixi/loaders/AssetLoader', function () { - 'use strict'; - - var expect = chai.expect; - var AssetLoader = PIXI.AssetLoader; - - it('Module exists', function () { - expect(AssetLoader).to.be.a('function'); - }); -}); diff --git a/test/unit/pixi/loaders/BitmapFontLoader.js b/test/unit/pixi/loaders/BitmapFontLoader.js deleted file mode 100644 index 046f018..0000000 --- a/test/unit/pixi/loaders/BitmapFontLoader.js +++ /dev/null @@ -1,9 +0,0 @@ -describe('pixi/loaders/BitmapFontLoader', function () { - 'use strict'; - - var expect = chai.expect; - - it('Module exists', function () { - expect(PIXI.BitmapFontLoader).to.be.a('function'); - }); -}); diff --git a/test/unit/pixi/loaders/ImageLoader.js b/test/unit/pixi/loaders/ImageLoader.js deleted file mode 100644 index 8b1f556..0000000 --- a/test/unit/pixi/loaders/ImageLoader.js +++ /dev/null @@ -1,10 +0,0 @@ -describe('pixi/loaders/ImageLoader', function () { - 'use strict'; - - var expect = chai.expect; - var ImageLoader = PIXI.ImageLoader; - - it('Module exists', function () { - expect(ImageLoader).to.be.a('function'); - }); -}); diff --git a/test/unit/pixi/loaders/JsonLoader.js b/test/unit/pixi/loaders/JsonLoader.js deleted file mode 100644 index c577e83..0000000 --- a/test/unit/pixi/loaders/JsonLoader.js +++ /dev/null @@ -1,10 +0,0 @@ -describe('pixi/loaders/JsonLoader', function () { - 'use strict'; - - var expect = chai.expect; - var JsonLoader = PIXI.JsonLoader; - - it('Module exists', function () { - expect(JsonLoader).to.be.a('function'); - }); -}); diff --git a/test/unit/pixi/loaders/SpineLoader.js b/test/unit/pixi/loaders/SpineLoader.js deleted file mode 100644 index fdcc0b8..0000000 --- a/test/unit/pixi/loaders/SpineLoader.js +++ /dev/null @@ -1,10 +0,0 @@ -describe('pixi/loaders/SpineLoader', function () { - 'use strict'; - - var expect = chai.expect; - var SpineLoader = PIXI.SpineLoader; - - it('Module exists', function () { - expect(SpineLoader).to.be.a('function'); - }); -}); diff --git a/test/unit/pixi/loaders/SpriteSheetLoader.js b/test/unit/pixi/loaders/SpriteSheetLoader.js deleted file mode 100644 index 57beb27..0000000 --- a/test/unit/pixi/loaders/SpriteSheetLoader.js +++ /dev/null @@ -1,10 +0,0 @@ -describe('pixi/loaders/SpriteSheetLoader', function () { - 'use strict'; - - var expect = chai.expect; - var SpriteSheetLoader = PIXI.SpriteSheetLoader; - - it('Module exists', function () { - expect(SpriteSheetLoader).to.be.a('function'); - }); -}); diff --git a/test/unit/pixi/primitives/Graphics.js b/test/unit/pixi/primitives/Graphics.js deleted file mode 100644 index f3849eb..0000000 --- a/test/unit/pixi/primitives/Graphics.js +++ /dev/null @@ -1,44 +0,0 @@ -describe('pixi/primitives/Graphics', function () { - 'use strict'; - - var expect = chai.expect; - var Graphics = PIXI.Graphics; - - it('Module exists', function () { - expect(Graphics).to.be.a('function'); - - expect(Graphics).itself.to.have.property('POLY', 0); - expect(Graphics).itself.to.have.property('RECT', 1); - expect(Graphics).itself.to.have.property('CIRC', 2); - expect(Graphics).itself.to.have.property('ELIP', 3); - expect(Graphics).itself.to.have.property('RREC', 4); - }); - - it('Confirm new instance', function () { - var obj = new Graphics(); - - pixi_display_DisplayObjectContainer_confirmNew(obj); - - expect(obj).to.be.an.instanceof(Graphics); - expect(obj).to.respondTo('lineStyle'); - expect(obj).to.respondTo('lineStyle'); - expect(obj).to.respondTo('moveTo'); - expect(obj).to.respondTo('lineTo'); - expect(obj).to.respondTo('beginFill'); - expect(obj).to.respondTo('endFill'); - expect(obj).to.respondTo('drawRect'); - // expect(obj).to.respondTo('drawRoundedRect'); - expect(obj).to.respondTo('drawCircle'); - expect(obj).to.respondTo('drawEllipse'); - expect(obj).to.respondTo('clear'); - - expect(obj).to.have.property('renderable', true); - expect(obj).to.have.property('fillAlpha', 1); - expect(obj).to.have.property('lineWidth', 0); - expect(obj).to.have.property('width', 0); - expect(obj).to.have.property('height', 0); - expect(obj).to.have.property('lineColor', 0); - expect(obj).to.have.deep.property('graphicsData.length', 0); - // expect(obj).to.have.deep.property('currentPath.points.length', 0); - }); -}); diff --git a/test/unit/pixi/renderers/canvas/CanvasGraphics.js b/test/unit/pixi/renderers/canvas/CanvasGraphics.js deleted file mode 100644 index 8f44472..0000000 --- a/test/unit/pixi/renderers/canvas/CanvasGraphics.js +++ /dev/null @@ -1,15 +0,0 @@ -describe('renders/canvas/CanvasGraphics', function () { - 'use strict'; - - var expect = chai.expect; - var CanvasGraphics = PIXI.CanvasGraphics; - - it('Module exists', function () { - expect(CanvasGraphics).to.be.a('function'); - }); - - it('Members exist', function () { - expect(CanvasGraphics).itself.to.respondTo('renderGraphics'); - expect(CanvasGraphics).itself.to.respondTo('renderGraphicsMask'); - }); -}); diff --git a/test/unit/pixi/renderers/canvas/CanvasRenderer.js b/test/unit/pixi/renderers/canvas/CanvasRenderer.js deleted file mode 100644 index 1646444..0000000 --- a/test/unit/pixi/renderers/canvas/CanvasRenderer.js +++ /dev/null @@ -1,36 +0,0 @@ -describe('renderers/canvas/CanvasRenderer', function () { - 'use strict'; - - var expect = chai.expect; - var CanvasRenderer = PIXI.CanvasRenderer; - - it('Module exists', function () { - expect(CanvasRenderer).to.be.a('function'); - }); - - describe('.autoResize', function () { - it('Should automatically resize view if enabled', function () { - var renderer = new CanvasRenderer(200, 200, { - autoResize: true - }); - - expect(renderer.view.style.width).to.equal('200px'); - }); - - it('Should not automatically resize view if disabled', function () { - var renderer = new CanvasRenderer(200, 200, { - autoResize: false - }); - - expect(renderer.view.style.width).to.equal(''); - }); - - it('Should not automatically resize view if not specified', function () { - var renderer = new CanvasRenderer(200, 200, { - resolution: 2 - }); - - expect(renderer.view.style.width).to.equal(''); - }); - }); -}); diff --git a/test/unit/pixi/renderers/webgl/WebGLGraphics.js b/test/unit/pixi/renderers/webgl/WebGLGraphics.js deleted file mode 100644 index 5867b28..0000000 --- a/test/unit/pixi/renderers/webgl/WebGLGraphics.js +++ /dev/null @@ -1,20 +0,0 @@ -describe('renderers/wegbl/WebGLGraphics', function () { - 'use strict'; - - var expect = chai.expect; - var WebGLGraphics = PIXI.WebGLGraphics; - - it('Module exists', function () { - expect(WebGLGraphics).to.be.a('function'); - }); - - it('Members exist', function () { - expect(WebGLGraphics).itself.to.respondTo('renderGraphics'); - expect(WebGLGraphics).itself.to.respondTo('updateGraphics'); - expect(WebGLGraphics).itself.to.respondTo('buildRectangle'); - expect(WebGLGraphics).itself.to.respondTo('buildRoundedRectangle'); - expect(WebGLGraphics).itself.to.respondTo('buildCircle'); - expect(WebGLGraphics).itself.to.respondTo('buildLine'); - expect(WebGLGraphics).itself.to.respondTo('buildPoly'); - }); -}); diff --git a/test/unit/pixi/renderers/webgl/WebGLRenderer.js b/test/unit/pixi/renderers/webgl/WebGLRenderer.js deleted file mode 100644 index 1680a80..0000000 --- a/test/unit/pixi/renderers/webgl/WebGLRenderer.js +++ /dev/null @@ -1,49 +0,0 @@ -describe('renderers/webgl/WebGLRenderer', function () { - 'use strict'; - - var expect = chai.expect; - var WebGLRenderer = PIXI.WebGLRenderer; - - it('Module exists', function () { - expect(WebGLRenderer).to.be.a('function'); - }); - - // Skip tests if WebGL is not available (WebGL not supported in Travis CI) - try { - var renderer = new WebGLRenderer(400, 300, {}); - renderer.destroy(); - } catch (error) { - return; - } - - it('Destroy renderer', function () { - var renderer = new WebGLRenderer(400, 300, {}); - renderer.destroy(); - }); - - describe('.autoResize', function () { - it('Should automatically resize view if enabled', function () { - var renderer = new WebGLRenderer(200, 200, { - autoResize: true - }); - - expect(renderer.view.style.width).to.equal('200px'); - }); - - it('Should not automatically resize view if disabled', function () { - var renderer = new WebGLRenderer(200, 200, { - autoResize: false - }); - - expect(renderer.view.style.width).to.equal(''); - }); - - it('Should not automatically resize view if not specified', function () { - var renderer = new WebGLRenderer(200, 200, { - resolution: 2 - }); - - expect(renderer.view.style.width).to.equal(''); - }); - }); -}); diff --git a/test/unit/pixi/renderers/webgl/WebGLShaders.js b/test/unit/pixi/renderers/webgl/WebGLShaders.js deleted file mode 100644 index 6e33e4f..0000000 --- a/test/unit/pixi/renderers/webgl/WebGLShaders.js +++ /dev/null @@ -1,13 +0,0 @@ -describe('renderers/webgl/WebGLShaders', function () { - 'use strict'; - - var expect = chai.expect; - - it('Module members exist', function () { - - expect(PIXI).to.respondTo('CompileVertexShader'); - expect(PIXI).to.respondTo('CompileFragmentShader'); - expect(PIXI).to.respondTo('_CompileShader'); - expect(PIXI).to.respondTo('compileProgram'); - }); -}); diff --git a/test/unit/pixi/renderers/webgl/WebGLSpriteBatch.js b/test/unit/pixi/renderers/webgl/WebGLSpriteBatch.js deleted file mode 100644 index e662b63..0000000 --- a/test/unit/pixi/renderers/webgl/WebGLSpriteBatch.js +++ /dev/null @@ -1,10 +0,0 @@ -describe('renderers/webgl/utils/WebGLSpriteBatch', function () { - 'use strict'; - - var expect = chai.expect; - var WebGLSpriteBatch = PIXI.WebGLSpriteBatch; - - it('Module exists', function () { - expect(WebGLSpriteBatch).to.be.a('function'); - }); -}); diff --git a/test/unit/pixi/text/BitmapText.js b/test/unit/pixi/text/BitmapText.js deleted file mode 100644 index 9388e3d..0000000 --- a/test/unit/pixi/text/BitmapText.js +++ /dev/null @@ -1,10 +0,0 @@ -describe('pixi/text/BitmapText', function () { - 'use strict'; - - var expect = chai.expect; - var BitmapText = PIXI.BitmapText; - - it('Module exists', function () { - expect(BitmapText).to.be.a('function'); - }); -}); diff --git a/test/unit/pixi/text/Text.js b/test/unit/pixi/text/Text.js deleted file mode 100644 index 9bc9ac5..0000000 --- a/test/unit/pixi/text/Text.js +++ /dev/null @@ -1,10 +0,0 @@ -describe('pixi/text/Text', function () { - 'use strict'; - - var expect = chai.expect; - var Text = PIXI.Text; - - it('Module exists', function () { - expect(Text).to.be.a('function'); - }); -}); diff --git a/test/unit/pixi/textures/BaseTexture.js b/test/unit/pixi/textures/BaseTexture.js deleted file mode 100644 index 502b724..0000000 --- a/test/unit/pixi/textures/BaseTexture.js +++ /dev/null @@ -1,11 +0,0 @@ -describe('pixi/textures/BaseTexture', function () { - 'use strict'; - - var expect = chai.expect; - var BaseTexture = PIXI.BaseTexture; - - it('Module exists', function () { - expect(BaseTexture).to.be.a('function'); - expect(PIXI).to.have.property('BaseTextureCache').and.to.be.an('object'); - }); -}); diff --git a/test/unit/pixi-v2/InteractionManager.js b/test/unit/pixi-v2/InteractionManager.js new file mode 100644 index 0000000..ed3001f --- /dev/null +++ b/test/unit/pixi-v2/InteractionManager.js @@ -0,0 +1,10 @@ +describe('pixi/InteractionManager', function () { + 'use strict'; + + var expect = chai.expect; + var InteractionManager = PIXI.InteractionManager; + + it('Module exists', function () { + expect(InteractionManager).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/Pixi.js b/test/unit/pixi-v2/Pixi.js new file mode 100644 index 0000000..27debc1 --- /dev/null +++ b/test/unit/pixi-v2/Pixi.js @@ -0,0 +1,9 @@ +describe('pixi/Pixi', function () { + 'use strict'; + + var expect = chai.expect; + + it('Module exists', function () { + expect(global).to.have.property('PIXI').and.to.be.an('object'); + }); +}); diff --git a/test/unit/pixi-v2/core/Circle.js b/test/unit/pixi-v2/core/Circle.js new file mode 100644 index 0000000..fbcfa17 --- /dev/null +++ b/test/unit/pixi-v2/core/Circle.js @@ -0,0 +1,21 @@ +describe('pixi/core/Circle', function () { + 'use strict'; + + var expect = chai.expect; + var Circle = PIXI.Circle; + + it('Module exists', function () { + expect(Circle).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Circle(); + pixi_core_Circle_confirmNewCircle(obj); + }); + + it("getBounds should return Rectangle that bounds the circle", function() { + var obj = new Circle(100, 250, 50); + var bounds = obj.getBounds(); + pixi_core_Circle_isBoundedByRectangle(obj, bounds); + }); +}); diff --git a/test/unit/pixi-v2/core/Ellipse.js b/test/unit/pixi-v2/core/Ellipse.js new file mode 100644 index 0000000..026b56f --- /dev/null +++ b/test/unit/pixi-v2/core/Ellipse.js @@ -0,0 +1,24 @@ +describe('pixi/core/Ellipse', function () { + 'use strict'; + + var expect = chai.expect; + var Ellipse = PIXI.Ellipse; + + it('Module exists', function () { + expect(Ellipse).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Ellipse(); + + expect(obj).to.be.an.instanceof(Ellipse); + expect(obj).to.respondTo('clone'); + expect(obj).to.respondTo('contains'); + expect(obj).to.respondTo('getBounds'); + + expect(obj).to.have.property('x', 0); + expect(obj).to.have.property('y', 0); + expect(obj).to.have.property('width', 0); + expect(obj).to.have.property('height', 0); + }); +}); diff --git a/test/unit/pixi-v2/core/Matrix.js b/test/unit/pixi-v2/core/Matrix.js new file mode 100644 index 0000000..da75e2e --- /dev/null +++ b/test/unit/pixi-v2/core/Matrix.js @@ -0,0 +1,14 @@ +describe('pixi/core/Matrix', function () { + 'use strict'; + + var expect = chai.expect; + + it('Matrix exists', function () { + expect(PIXI.Matrix).to.be.an('function'); + }); + + it('Confirm new Matrix', function () { + var matrix = new PIXI.Matrix(); + pixi_core_Matrix_confirmNewMatrix(matrix); + }); +}); diff --git a/test/unit/pixi-v2/core/Point.js b/test/unit/pixi-v2/core/Point.js new file mode 100644 index 0000000..c4d5163 --- /dev/null +++ b/test/unit/pixi-v2/core/Point.js @@ -0,0 +1,15 @@ +describe('pixi/core/Point', function () { + 'use strict'; + + var expect = chai.expect; + var Point = PIXI.Point; + + it('Module exists', function () { + expect(Point).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Point(); + pixi_core_Point_confirm(obj, 0, 0); + }); +}); diff --git a/test/unit/pixi-v2/core/Polygon.js b/test/unit/pixi-v2/core/Polygon.js new file mode 100644 index 0000000..dc8c918 --- /dev/null +++ b/test/unit/pixi-v2/core/Polygon.js @@ -0,0 +1,20 @@ +describe('pixi/core/Polygon', function () { + 'use strict'; + + var expect = chai.expect; + var Polygon = PIXI.Polygon; + + it('Module exists', function () { + expect(Polygon).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Polygon(); + + expect(obj).to.be.an.instanceof(Polygon); + expect(obj).to.respondTo('clone'); + expect(obj).to.respondTo('contains'); + + expect(obj).to.have.deep.property('points.length', 0); + }); +}); diff --git a/test/unit/pixi-v2/core/Rectangle.js b/test/unit/pixi-v2/core/Rectangle.js new file mode 100644 index 0000000..d43316e --- /dev/null +++ b/test/unit/pixi-v2/core/Rectangle.js @@ -0,0 +1,15 @@ +describe('pixi/core/Rectangle', function () { + 'use strict'; + + var expect = chai.expect; + var Rectangle = PIXI.Rectangle; + + it('Module exists', function () { + expect(Rectangle).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var rect = new Rectangle(); + pixi_core_Rectangle_confirm(rect, 0, 0, 0, 0); + }); +}); diff --git a/test/unit/pixi-v2/display/DisplayObject.js b/test/unit/pixi-v2/display/DisplayObject.js new file mode 100644 index 0000000..044acf8 --- /dev/null +++ b/test/unit/pixi-v2/display/DisplayObject.js @@ -0,0 +1,21 @@ +describe('pixi/display/DisplayObject', function () { + 'use strict'; + + var expect = chai.expect; + var DisplayObject = PIXI.DisplayObject; + + it('Module exists', function () { + expect(DisplayObject).to.be.a('function'); + // expect(PIXI).to.have.property('visibleCount', 0); + }); + + it('Confirm new instance', function () { + var obj = new DisplayObject(); + + pixi_display_DisplayObject_confirmNew(obj); + expect(obj).to.have.property('hitArea', null); + expect(obj).to.have.property('interactive', false); + expect(obj).to.have.property('renderable', false); + expect(obj).to.have.property('stage', null); + }); +}); diff --git a/test/unit/pixi-v2/display/DisplayObjectContainer.js b/test/unit/pixi-v2/display/DisplayObjectContainer.js new file mode 100644 index 0000000..15a3376 --- /dev/null +++ b/test/unit/pixi-v2/display/DisplayObjectContainer.js @@ -0,0 +1,67 @@ +describe('pixi/display/DisplayObjectContainer', function () { + 'use strict'; + + var expect = chai.expect; + var DisplayObjectContainer = PIXI.DisplayObjectContainer; + + it('Module exists', function () { + expect(DisplayObjectContainer).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new DisplayObjectContainer(); + + pixi_display_DisplayObjectContainer_confirmNew(obj); + expect(obj).to.have.property('hitArea', null); + expect(obj).to.have.property('interactive', false); + expect(obj).to.have.property('renderable', false); + expect(obj).to.have.property('stage', null); + }); + + it('Gets child index', function() { + var container = new PIXI.DisplayObjectContainer(); + var children = []; + for (var i = 0; i < 10; i++) { + var child = new PIXI.DisplayObject(); + children.push(child); + container.addChild(child); + } + + for (i = 0; i < children.length; i++) { + expect(i).to.eql(container.getChildIndex(children[i])); + } + }); + + it('throws error when trying to get index of not a child', function() { + var container = new PIXI.DisplayObjectContainer(); + var child = new PIXI.DisplayObject(); + + expect(function() { container.getChildIndex(child); }).to.throw(); + }); + + it('Sets child index', function() { + var container = new PIXI.DisplayObjectContainer(); + var children = []; + + for (var i = 0; i < 10; i++) { + var child = new PIXI.DisplayObject(); + children.push(child); + container.addChild(child); + } + children.reverse(); + + for (i = 0; i < children.length; i++) { + container.setChildIndex(children[i], i); + expect(i).to.eql(container.getChildIndex(children[i])); + } + }); + + it('throws error when trying to set incorect index', function() { + var container = new PIXI.DisplayObjectContainer(); + var child = new PIXI.DisplayObject(); + container.addChild(child); + + expect(function() { container.setChildIndex(child, -1); }).to.throw(); + expect(function() { container.setChildIndex(child, 1); }).to.throw(); + }); +}); diff --git a/test/unit/pixi-v2/display/MovieClip.js b/test/unit/pixi-v2/display/MovieClip.js new file mode 100644 index 0000000..f3c6c6a --- /dev/null +++ b/test/unit/pixi-v2/display/MovieClip.js @@ -0,0 +1,33 @@ +describe('pixi/display/MovieClip', function () { + 'use strict'; + + var expect = chai.expect; + var MovieClip = PIXI.MovieClip; + var Texture = PIXI.Texture; + + it('Module exists', function () { + expect(MovieClip).to.be.a('function'); + }); + + it('Confirm new instance', function (done) { + var texture = Texture.fromImage('/base/test/textures/SpriteSheet-Explosion.png'); + var obj = new MovieClip([texture]); + + pixi_display_Sprite_confirmNew(obj, done); + + expect(obj).to.be.an.instanceof(MovieClip); + expect(obj).to.respondTo('stop'); + expect(obj).to.respondTo('play'); + expect(obj).to.respondTo('gotoAndStop'); + expect(obj).to.respondTo('gotoAndPlay'); + expect(obj).to.respondTo('updateTransform'); + + expect(obj).to.have.deep.property('textures.length', 1); + expect(obj).to.have.deep.property('textures[0]', texture); + expect(obj).to.have.property('animationSpeed', 1); + expect(obj).to.have.property('loop', true); + expect(obj).to.have.property('onComplete', null); + expect(obj).to.have.property('currentFrame', 0); + expect(obj).to.have.property('playing', false); + }); +}); diff --git a/test/unit/pixi-v2/display/Sprite.js b/test/unit/pixi-v2/display/Sprite.js new file mode 100644 index 0000000..30c8076 --- /dev/null +++ b/test/unit/pixi-v2/display/Sprite.js @@ -0,0 +1,28 @@ +describe('pixi/display/Sprite', function () { + 'use strict'; + + var expect = chai.expect; + var Sprite = PIXI.Sprite; + var Texture = PIXI.Texture; + + it('Module exists', function () { + expect(Sprite).to.be.a('function'); + expect(PIXI).to.have.deep.property('blendModes.NORMAL', 0); + expect(PIXI).to.have.deep.property('blendModes.ADD', 1); + expect(PIXI).to.have.deep.property('blendModes.MULTIPLY', 2); + expect(PIXI).to.have.deep.property('blendModes.SCREEN', 3); + }); + + + it('Members exist', function () { + expect(Sprite).itself.to.respondTo('fromImage'); + expect(Sprite).itself.to.respondTo('fromFrame'); + }); + + it('Confirm new instance', function (done) { + var texture = Texture.fromImage('/base/test/textures/SpriteSheet-Aliens.png'); + var obj = new Sprite(texture); + + pixi_display_Sprite_confirmNew(obj, done); + }); +}); diff --git a/test/unit/pixi-v2/display/Stage.js b/test/unit/pixi-v2/display/Stage.js new file mode 100644 index 0000000..6974c2e --- /dev/null +++ b/test/unit/pixi-v2/display/Stage.js @@ -0,0 +1,49 @@ +describe('pixi/display/Stage', function () { + 'use strict'; + + var expect = chai.expect; + var Stage = PIXI.Stage; + var InteractionManager = PIXI.InteractionManager; + var Rectangle = PIXI.Rectangle; + + it('Module exists', function () { + expect(Stage).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Stage(null, true); + + pixi_display_DisplayObjectContainer_confirmNew(obj); + + expect(obj).to.be.an.instanceof(Stage); + expect(obj).to.respondTo('updateTransform'); + expect(obj).to.respondTo('setBackgroundColor'); + expect(obj).to.respondTo('getMousePosition'); + // FIXME: duplicate member in DisplayObject + pixi_core_Matrix_confirmNewMatrix(obj.worldTransform); + // FIXME: convert arg to bool in constructor + expect(obj).to.have.property('interactive', true); + + expect(obj).to.have.property('interactionManager') + .and.to.be.an.instanceof(InteractionManager) + .and.to.have.property('stage', obj); + + expect(obj).to.have.property('dirty', true); + + expect(obj).to.have.property('stage', obj); + + expect(obj).to.have.property('hitArea') + .and.to.be.an.instanceof(Rectangle); + pixi_core_Rectangle_confirm(obj.hitArea, 0, 0, 100000, 100000); + + expect(obj).to.have.property('backgroundColor', 0x000000); + expect(obj).to.have.deep.property('backgroundColorSplit.length', 3); + expect(obj).to.have.deep.property('backgroundColorSplit[0]', 0); + expect(obj).to.have.deep.property('backgroundColorSplit[1]', 0); + expect(obj).to.have.deep.property('backgroundColorSplit[2]', 0); + expect(obj).to.have.property('backgroundColorString', '#000000'); + + + expect(obj).to.have.property('worldVisible', true); + }); +}); diff --git a/test/unit/pixi-v2/extras/Rope.js b/test/unit/pixi-v2/extras/Rope.js new file mode 100644 index 0000000..05885ac --- /dev/null +++ b/test/unit/pixi-v2/extras/Rope.js @@ -0,0 +1,31 @@ +describe('pixi/extras/Rope', function () { + 'use strict'; + + var expect = chai.expect; + var Rope = PIXI.Rope; + var Texture = PIXI.Texture; + var Point = PIXI.Point; + + it('Module exists', function () { + expect(Rope).to.be.a('function'); + }); + + it('Confirm new instance', function () { + + var texture = Texture.fromImage('/base/test/textures/bunny.png'); + + // TODO-Alvin + // Same as Strip + + // var obj = new Rope(texture, [new Point(), new Point(5, 10), new Point(10, 20)]); + + // pixi_extras_Strip_confirmNew(obj); + + // expect(obj).to.be.an.instanceof(Rope); + // expect(obj).to.respondTo('refresh'); + // expect(obj).to.respondTo('updateTransform'); + // expect(obj).to.respondTo('setTexture'); + + // TODO: Test properties + }); +}); diff --git a/test/unit/pixi-v2/extras/Spine.js b/test/unit/pixi-v2/extras/Spine.js new file mode 100644 index 0000000..0708bc0 --- /dev/null +++ b/test/unit/pixi-v2/extras/Spine.js @@ -0,0 +1,10 @@ +describe('pixi/extras/Spine', function () { + 'use strict'; + + var expect = chai.expect; + var Spine = PIXI.Spine; + + it('Module exists', function () { + expect(Spine).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/extras/Strip.js b/test/unit/pixi-v2/extras/Strip.js new file mode 100644 index 0000000..230af90 --- /dev/null +++ b/test/unit/pixi-v2/extras/Strip.js @@ -0,0 +1,26 @@ +describe('pixi/extras/Strip', function () { + 'use strict'; + + var expect = chai.expect; + var Strip = PIXI.Strip; + var Texture = PIXI.Texture; + + it('Module exists', function () { + expect(Strip).to.be.a('function'); + }); + + it('Confirm new instance', function () { + + + // TODO-Alvin + // We tweaked it to make it pass the tests, but the whole strip class needs + // to be re-coded + + var texture = Texture.fromImage('/base/test/textures/bunny.png'); + + // var obj = new Strip(texture, 20, 10000); + + + // pixi_extras_Strip_confirmNew(obj); + }); +}); diff --git a/test/unit/pixi-v2/extras/TilingSprite.js b/test/unit/pixi-v2/extras/TilingSprite.js new file mode 100644 index 0000000..56aea14 --- /dev/null +++ b/test/unit/pixi-v2/extras/TilingSprite.js @@ -0,0 +1,24 @@ +describe('pixi/extras/TilingSprite', function () { + 'use strict'; + + var expect = chai.expect; + var TilingSprite = PIXI.TilingSprite; + var Texture = PIXI.Texture; + + it('Module exists', function () { + expect(TilingSprite).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var texture = Texture.fromImage('/base/test/textures/bunny.png'); + var obj = new TilingSprite(texture, 6000, 12000); + + pixi_display_DisplayObjectContainer_confirmNew(obj); + + expect(obj).to.be.an.instanceof(TilingSprite); + expect(obj).to.respondTo('setTexture'); + expect(obj).to.respondTo('onTextureUpdate'); + + // TODO: Test properties + }); +}); diff --git a/test/unit/pixi-v2/filters/FilterBlock.js b/test/unit/pixi-v2/filters/FilterBlock.js new file mode 100644 index 0000000..870cec0 --- /dev/null +++ b/test/unit/pixi-v2/filters/FilterBlock.js @@ -0,0 +1,10 @@ +describe('pixi/filters/FilterBlock', function () { + 'use strict'; + + var expect = chai.expect; + var FilterBlock = PIXI.FilterBlock; + + it('Module exists', function () { + expect(FilterBlock).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/AssetLoader.js b/test/unit/pixi-v2/loaders/AssetLoader.js new file mode 100644 index 0000000..a0aa0b5 --- /dev/null +++ b/test/unit/pixi-v2/loaders/AssetLoader.js @@ -0,0 +1,10 @@ +describe('pixi/loaders/AssetLoader', function () { + 'use strict'; + + var expect = chai.expect; + var AssetLoader = PIXI.AssetLoader; + + it('Module exists', function () { + expect(AssetLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/BitmapFontLoader.js b/test/unit/pixi-v2/loaders/BitmapFontLoader.js new file mode 100644 index 0000000..046f018 --- /dev/null +++ b/test/unit/pixi-v2/loaders/BitmapFontLoader.js @@ -0,0 +1,9 @@ +describe('pixi/loaders/BitmapFontLoader', function () { + 'use strict'; + + var expect = chai.expect; + + it('Module exists', function () { + expect(PIXI.BitmapFontLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/ImageLoader.js b/test/unit/pixi-v2/loaders/ImageLoader.js new file mode 100644 index 0000000..8b1f556 --- /dev/null +++ b/test/unit/pixi-v2/loaders/ImageLoader.js @@ -0,0 +1,10 @@ +describe('pixi/loaders/ImageLoader', function () { + 'use strict'; + + var expect = chai.expect; + var ImageLoader = PIXI.ImageLoader; + + it('Module exists', function () { + expect(ImageLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/JsonLoader.js b/test/unit/pixi-v2/loaders/JsonLoader.js new file mode 100644 index 0000000..c577e83 --- /dev/null +++ b/test/unit/pixi-v2/loaders/JsonLoader.js @@ -0,0 +1,10 @@ +describe('pixi/loaders/JsonLoader', function () { + 'use strict'; + + var expect = chai.expect; + var JsonLoader = PIXI.JsonLoader; + + it('Module exists', function () { + expect(JsonLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/SpineLoader.js b/test/unit/pixi-v2/loaders/SpineLoader.js new file mode 100644 index 0000000..fdcc0b8 --- /dev/null +++ b/test/unit/pixi-v2/loaders/SpineLoader.js @@ -0,0 +1,10 @@ +describe('pixi/loaders/SpineLoader', function () { + 'use strict'; + + var expect = chai.expect; + var SpineLoader = PIXI.SpineLoader; + + it('Module exists', function () { + expect(SpineLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/SpriteSheetLoader.js b/test/unit/pixi-v2/loaders/SpriteSheetLoader.js new file mode 100644 index 0000000..57beb27 --- /dev/null +++ b/test/unit/pixi-v2/loaders/SpriteSheetLoader.js @@ -0,0 +1,10 @@ +describe('pixi/loaders/SpriteSheetLoader', function () { + 'use strict'; + + var expect = chai.expect; + var SpriteSheetLoader = PIXI.SpriteSheetLoader; + + it('Module exists', function () { + expect(SpriteSheetLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/primitives/Graphics.js b/test/unit/pixi-v2/primitives/Graphics.js new file mode 100644 index 0000000..f3849eb --- /dev/null +++ b/test/unit/pixi-v2/primitives/Graphics.js @@ -0,0 +1,44 @@ +describe('pixi/primitives/Graphics', function () { + 'use strict'; + + var expect = chai.expect; + var Graphics = PIXI.Graphics; + + it('Module exists', function () { + expect(Graphics).to.be.a('function'); + + expect(Graphics).itself.to.have.property('POLY', 0); + expect(Graphics).itself.to.have.property('RECT', 1); + expect(Graphics).itself.to.have.property('CIRC', 2); + expect(Graphics).itself.to.have.property('ELIP', 3); + expect(Graphics).itself.to.have.property('RREC', 4); + }); + + it('Confirm new instance', function () { + var obj = new Graphics(); + + pixi_display_DisplayObjectContainer_confirmNew(obj); + + expect(obj).to.be.an.instanceof(Graphics); + expect(obj).to.respondTo('lineStyle'); + expect(obj).to.respondTo('lineStyle'); + expect(obj).to.respondTo('moveTo'); + expect(obj).to.respondTo('lineTo'); + expect(obj).to.respondTo('beginFill'); + expect(obj).to.respondTo('endFill'); + expect(obj).to.respondTo('drawRect'); + // expect(obj).to.respondTo('drawRoundedRect'); + expect(obj).to.respondTo('drawCircle'); + expect(obj).to.respondTo('drawEllipse'); + expect(obj).to.respondTo('clear'); + + expect(obj).to.have.property('renderable', true); + expect(obj).to.have.property('fillAlpha', 1); + expect(obj).to.have.property('lineWidth', 0); + expect(obj).to.have.property('width', 0); + expect(obj).to.have.property('height', 0); + expect(obj).to.have.property('lineColor', 0); + expect(obj).to.have.deep.property('graphicsData.length', 0); + // expect(obj).to.have.deep.property('currentPath.points.length', 0); + }); +}); diff --git a/test/unit/pixi-v2/renderers/canvas/CanvasGraphics.js b/test/unit/pixi-v2/renderers/canvas/CanvasGraphics.js new file mode 100644 index 0000000..8f44472 --- /dev/null +++ b/test/unit/pixi-v2/renderers/canvas/CanvasGraphics.js @@ -0,0 +1,15 @@ +describe('renders/canvas/CanvasGraphics', function () { + 'use strict'; + + var expect = chai.expect; + var CanvasGraphics = PIXI.CanvasGraphics; + + it('Module exists', function () { + expect(CanvasGraphics).to.be.a('function'); + }); + + it('Members exist', function () { + expect(CanvasGraphics).itself.to.respondTo('renderGraphics'); + expect(CanvasGraphics).itself.to.respondTo('renderGraphicsMask'); + }); +}); diff --git a/test/unit/pixi-v2/renderers/canvas/CanvasRenderer.js b/test/unit/pixi-v2/renderers/canvas/CanvasRenderer.js new file mode 100644 index 0000000..1646444 --- /dev/null +++ b/test/unit/pixi-v2/renderers/canvas/CanvasRenderer.js @@ -0,0 +1,36 @@ +describe('renderers/canvas/CanvasRenderer', function () { + 'use strict'; + + var expect = chai.expect; + var CanvasRenderer = PIXI.CanvasRenderer; + + it('Module exists', function () { + expect(CanvasRenderer).to.be.a('function'); + }); + + describe('.autoResize', function () { + it('Should automatically resize view if enabled', function () { + var renderer = new CanvasRenderer(200, 200, { + autoResize: true + }); + + expect(renderer.view.style.width).to.equal('200px'); + }); + + it('Should not automatically resize view if disabled', function () { + var renderer = new CanvasRenderer(200, 200, { + autoResize: false + }); + + expect(renderer.view.style.width).to.equal(''); + }); + + it('Should not automatically resize view if not specified', function () { + var renderer = new CanvasRenderer(200, 200, { + resolution: 2 + }); + + expect(renderer.view.style.width).to.equal(''); + }); + }); +}); diff --git a/test/unit/pixi-v2/renderers/webgl/WebGLGraphics.js b/test/unit/pixi-v2/renderers/webgl/WebGLGraphics.js new file mode 100644 index 0000000..5867b28 --- /dev/null +++ b/test/unit/pixi-v2/renderers/webgl/WebGLGraphics.js @@ -0,0 +1,20 @@ +describe('renderers/wegbl/WebGLGraphics', function () { + 'use strict'; + + var expect = chai.expect; + var WebGLGraphics = PIXI.WebGLGraphics; + + it('Module exists', function () { + expect(WebGLGraphics).to.be.a('function'); + }); + + it('Members exist', function () { + expect(WebGLGraphics).itself.to.respondTo('renderGraphics'); + expect(WebGLGraphics).itself.to.respondTo('updateGraphics'); + expect(WebGLGraphics).itself.to.respondTo('buildRectangle'); + expect(WebGLGraphics).itself.to.respondTo('buildRoundedRectangle'); + expect(WebGLGraphics).itself.to.respondTo('buildCircle'); + expect(WebGLGraphics).itself.to.respondTo('buildLine'); + expect(WebGLGraphics).itself.to.respondTo('buildPoly'); + }); +}); diff --git a/test/unit/pixi-v2/renderers/webgl/WebGLRenderer.js b/test/unit/pixi-v2/renderers/webgl/WebGLRenderer.js new file mode 100644 index 0000000..1680a80 --- /dev/null +++ b/test/unit/pixi-v2/renderers/webgl/WebGLRenderer.js @@ -0,0 +1,49 @@ +describe('renderers/webgl/WebGLRenderer', function () { + 'use strict'; + + var expect = chai.expect; + var WebGLRenderer = PIXI.WebGLRenderer; + + it('Module exists', function () { + expect(WebGLRenderer).to.be.a('function'); + }); + + // Skip tests if WebGL is not available (WebGL not supported in Travis CI) + try { + var renderer = new WebGLRenderer(400, 300, {}); + renderer.destroy(); + } catch (error) { + return; + } + + it('Destroy renderer', function () { + var renderer = new WebGLRenderer(400, 300, {}); + renderer.destroy(); + }); + + describe('.autoResize', function () { + it('Should automatically resize view if enabled', function () { + var renderer = new WebGLRenderer(200, 200, { + autoResize: true + }); + + expect(renderer.view.style.width).to.equal('200px'); + }); + + it('Should not automatically resize view if disabled', function () { + var renderer = new WebGLRenderer(200, 200, { + autoResize: false + }); + + expect(renderer.view.style.width).to.equal(''); + }); + + it('Should not automatically resize view if not specified', function () { + var renderer = new WebGLRenderer(200, 200, { + resolution: 2 + }); + + expect(renderer.view.style.width).to.equal(''); + }); + }); +}); diff --git a/test/unit/pixi-v2/renderers/webgl/WebGLShaders.js b/test/unit/pixi-v2/renderers/webgl/WebGLShaders.js new file mode 100644 index 0000000..6e33e4f --- /dev/null +++ b/test/unit/pixi-v2/renderers/webgl/WebGLShaders.js @@ -0,0 +1,13 @@ +describe('renderers/webgl/WebGLShaders', function () { + 'use strict'; + + var expect = chai.expect; + + it('Module members exist', function () { + + expect(PIXI).to.respondTo('CompileVertexShader'); + expect(PIXI).to.respondTo('CompileFragmentShader'); + expect(PIXI).to.respondTo('_CompileShader'); + expect(PIXI).to.respondTo('compileProgram'); + }); +}); diff --git a/test/unit/pixi-v2/renderers/webgl/WebGLSpriteBatch.js b/test/unit/pixi-v2/renderers/webgl/WebGLSpriteBatch.js new file mode 100644 index 0000000..e662b63 --- /dev/null +++ b/test/unit/pixi-v2/renderers/webgl/WebGLSpriteBatch.js @@ -0,0 +1,10 @@ +describe('renderers/webgl/utils/WebGLSpriteBatch', function () { + 'use strict'; + + var expect = chai.expect; + var WebGLSpriteBatch = PIXI.WebGLSpriteBatch; + + it('Module exists', function () { + expect(WebGLSpriteBatch).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/text/BitmapText.js b/test/unit/pixi-v2/text/BitmapText.js new file mode 100644 index 0000000..9388e3d --- /dev/null +++ b/test/unit/pixi-v2/text/BitmapText.js @@ -0,0 +1,10 @@ +describe('pixi/text/BitmapText', function () { + 'use strict'; + + var expect = chai.expect; + var BitmapText = PIXI.BitmapText; + + it('Module exists', function () { + expect(BitmapText).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/text/Text.js b/test/unit/pixi-v2/text/Text.js new file mode 100644 index 0000000..9bc9ac5 --- /dev/null +++ b/test/unit/pixi-v2/text/Text.js @@ -0,0 +1,10 @@ +describe('pixi/text/Text', function () { + 'use strict'; + + var expect = chai.expect; + var Text = PIXI.Text; + + it('Module exists', function () { + expect(Text).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/textures/BaseTexture.js b/test/unit/pixi-v2/textures/BaseTexture.js new file mode 100644 index 0000000..502b724 --- /dev/null +++ b/test/unit/pixi-v2/textures/BaseTexture.js @@ -0,0 +1,11 @@ +describe('pixi/textures/BaseTexture', function () { + 'use strict'; + + var expect = chai.expect; + var BaseTexture = PIXI.BaseTexture; + + it('Module exists', function () { + expect(BaseTexture).to.be.a('function'); + expect(PIXI).to.have.property('BaseTextureCache').and.to.be.an('object'); + }); +}); diff --git a/test/unit/pixi-v2/textures/RenderTexture.js b/test/unit/pixi-v2/textures/RenderTexture.js new file mode 100644 index 0000000..96acdb4 --- /dev/null +++ b/test/unit/pixi-v2/textures/RenderTexture.js @@ -0,0 +1,15 @@ +describe('pixi/textures/RenderTexture', function () { + 'use strict'; + + var expect = chai.expect; + var RenderTexture = PIXI.RenderTexture; + + it('Module exists', function () { + expect(RenderTexture).to.be.a('function'); + }); + + it('Confirm new instance', function (done) { + var texture = new RenderTexture(100, 100, new PIXI.CanvasRenderer()); + pixi_textures_RenderTexture_confirmNew(texture, done); + }); +}); diff --git a/test/unit/pixi-v2/textures/Texture.js b/test/unit/pixi-v2/textures/Texture.js new file mode 100644 index 0000000..090f64d --- /dev/null +++ b/test/unit/pixi-v2/textures/Texture.js @@ -0,0 +1,26 @@ +describe('pixi/textures/Texture', function () { + 'use strict'; + + var expect = chai.expect; + var Texture = PIXI.Texture; + + it('Module exists', function () { + expect(Texture).to.be.a('function'); + expect(PIXI).to.have.property('TextureCache').and.to.be.an('object'); + }); + + it('Members exist', function () { + expect(Texture).itself.to.respondTo('fromImage'); + expect(Texture).itself.to.respondTo('fromFrame'); + expect(Texture).itself.to.respondTo('fromCanvas'); + expect(Texture).itself.to.respondTo('addTextureToCache'); + expect(Texture).itself.to.respondTo('removeTextureFromCache'); + + // expect(Texture).itself.to.have.deep.property('frameUpdates.length', 0); + }); + + it('Confirm new instance', function (done) { + var texture = Texture.fromImage('/base/test/textures/bunny.png'); + pixi_textures_Texture_confirmNew(texture, done); + }); +}); diff --git a/test/unit/pixi-v2/utils/Detector.js b/test/unit/pixi-v2/utils/Detector.js new file mode 100644 index 0000000..4cf6008 --- /dev/null +++ b/test/unit/pixi-v2/utils/Detector.js @@ -0,0 +1,10 @@ +describe('pixi/utils/Detector', function () { + 'use strict'; + + var expect = chai.expect; + var autoDetectRenderer = PIXI.autoDetectRenderer; + + it('Module exists', function () { + expect(autoDetectRenderer).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/utils/EventTarget.js b/test/unit/pixi-v2/utils/EventTarget.js new file mode 100644 index 0000000..1cfc3a4 --- /dev/null +++ b/test/unit/pixi-v2/utils/EventTarget.js @@ -0,0 +1,361 @@ +describe('pixi/utils/EventTarget', function () { + 'use strict'; + + var expect = chai.expect; + + var Clazz, PClazz, obj, pobj, obj2; + beforeEach(function () { + Clazz = function () {}; + PClazz = function () {}; + + PIXI.EventTarget.mixin(Clazz.prototype); + PIXI.EventTarget.mixin(PClazz.prototype); + + obj = new Clazz(); + obj2 = new Clazz(); + pobj = new PClazz(); + + obj.parent = pobj; + obj2.parent = obj; + }); + + it('Module exists', function () { + expect(PIXI.EventTarget).to.be.an('object'); + }); + + it('Confirm new instance', function () { + pixi_utils_EventTarget_confirm(obj); + }); + + it('simple on/emit case works', function () { + var myData = {}; + + obj.on('myevent', function (event) { + pixi_utils_EventTarget_Event_confirm(event, obj, myData); + }); + + obj.emit('myevent', myData); + }); + + it('simple once case works', function () { + var called = 0; + + obj.once('myevent', function() { called++; }); + + obj.emit('myevent'); + obj.emit('myevent'); + obj.emit('myevent'); + obj.emit('myevent'); + obj.emit('myevent'); + + expect(called).to.equal(1); + }); + + it('simple off case works', function (done) { + function onMyEvent() { + done(new Error('Event listener should not have been called')); + } + + obj.on('myevent', onMyEvent); + obj.off('myevent', onMyEvent); + obj.emit('myevent'); + + done(); + }); + + it('simple propagation case works', function (done) { + var myData = {}; + + pobj.on('myevent', function () { + done(); + }); + + obj.emit('myevent'); + }); + + it('simple stopPropagation case works', function (done) { + var myData = {}; + + pobj.on('myevent', function () { + done(new Error('Event listener should not have been called on the parent element')); + }); + + obj.on('myevent', function (evt) { + evt.stopPropagation(); + }); + + obj.emit('myevent'); + + done(); + }); + + it('simple stopImmediatePropagation case works', function (done) { + var myData = {}; + + pobj.on('myevent', function () { + done(new Error('Event listener should not have been called on the parent')); + }); + + obj.on('myevent', function (evt) { + evt.stopImmediatePropagation(); + }); + + obj.on('myevent', function () { + done(new Error('Event listener should not have been called on the second')); + }); + + obj.emit('myevent'); + + done(); + }); + + it('multiple dispatches work properly', function () { + var called = 0; + + function onMyEvent() { + called++; + } + + obj.on('myevent', onMyEvent); + obj.emit('myevent'); + obj.emit('myevent'); + obj.emit('myevent'); + obj.emit('myevent'); + + expect(called).to.equal(4); + }); + + it('multiple events work properly', function () { + var called = 0; + + function onMyEvent() { + called++; + } + + obj.on('myevent1', onMyEvent); + obj.on('myevent2', onMyEvent); + obj.on('myevent3', onMyEvent); + obj.emit('myevent1'); + obj.emit('myevent2'); + obj.emit('myevent3'); + + expect(called).to.equal(3); + }); + + it('multiple events one removed works properly', function () { + var called = 0; + + function onMyEvent() { + called++; + } + + obj.on('myevent1', onMyEvent); + obj.on('myevent2', onMyEvent); + obj.on('myevent3', onMyEvent); + + obj.emit('myevent1'); + obj.emit('myevent2'); + obj.emit('myevent3'); + + obj.off('myevent2', onMyEvent); + + obj.emit('myevent1'); + obj.emit('myevent2'); + obj.emit('myevent3'); + + expect(called).to.equal(5); + }); + + it('multiple handlers for one event with some removed', function () { + var called = 0; + + var onMyEvent = function () { + called++; + }, + onMyEvent2 = function () { + called++; + }; + + // add 2 handlers and confirm they both get called + obj.on('myevent', onMyEvent); + obj.on('myevent', onMyEvent); + obj.on('myevent', onMyEvent2); + obj.on('myevent', onMyEvent2); + + obj.emit('myevent'); + + expect(called).to.equal(4); + + // remove one of the handlers, emit again, then ensure 1 more call is made + obj.off('myevent', onMyEvent); + + obj.emit('myevent'); + + expect(called).to.equal(6); + }); + + it('calls to off without a handler do nothing', function () { + var called = 0; + + var onMyEvent = function () { + called++; + }; + + obj.on('myevent', onMyEvent); + obj.on('myevent', onMyEvent); + + obj.emit('myevent'); + + expect(called).to.equal(2); + + obj.off('myevent'); + + obj.emit('myevent'); + + expect(called).to.equal(4); + + obj.off('myevent', onMyEvent); + + obj.emit('myevent'); + + expect(called).to.equal(4); + }); + + it('handles multiple instances with the same prototype', function () { + var called = 0; + + function onMyEvent(e) { + called++; + } + + obj.on('myevent1', onMyEvent); + obj.on('myevent2', onMyEvent); + + obj2.istwo = true; + obj2.on('myevent1', onMyEvent); + obj2.on('myevent2', onMyEvent); + + obj.emit('myevent1'); + obj.emit('myevent2'); + obj2.emit('myevent1'); + obj2.emit('myevent2'); + + //we emit 4 times, but since obj2 is a child of obj the event should bubble + //up to obj and show up there as well. So the obj2.emit() calls each increment + //the counter twice. + expect(called).to.equal(6); + }); + + it('is backwards compatible with older .dispatchEvent({})', function () { + var called = 0, + data = { + some: 'thing', + hello: true + }; + + function onMyEvent(event) { + pixi_utils_EventTarget_Event_confirm(event, obj, data); + + called++; + } + + obj.on('myevent1', onMyEvent); + obj.on('myevent2', onMyEvent); + obj.on('myevent3', onMyEvent); + + data.type = 'myevent1'; + obj.emit(data); + + data.type = 'myevent2'; + obj.emit(data); + + data.type = 'myevent3'; + obj.emit(data); + + obj.off('myevent2', onMyEvent); + + data.type = 'myevent1'; + obj.emit(data); + + data.type = 'myevent2'; + obj.emit(data); + + data.type = 'myevent3'; + obj.emit(data); + + expect(called).to.equal(5); + }); + + it('is backwards compatible with older .call(this)', function () { + var Fn = function() { + PIXI.EventTarget.call(this); + }, + o = new Fn(); + + pixi_utils_EventTarget_confirm(o); + }); + + it('is backwards compatible with older .addEventListener("")', function () { + var called = 0, + data = { + some: 'thing', + hello: true + }; + + function onMyEvent(event) { + pixi_utils_EventTarget_Event_confirm(event, obj, data); + + called++; + } + + obj.addEventListener('myevent1', onMyEvent); + obj.addEventListener('myevent2', onMyEvent); + obj.addEventListener('myevent3', onMyEvent); + + data.type = 'myevent1'; + obj.emit(data); + + data.type = 'myevent2'; + obj.emit(data); + + data.type = 'myevent3'; + obj.emit(data); + + obj.off('myevent2', onMyEvent); + + data.type = 'myevent1'; + obj.emit(data); + + data.type = 'myevent2'; + obj.emit(data); + + data.type = 'myevent3'; + obj.emit(data); + + expect(called).to.equal(5); + }); + + it('event remove during emit call properly', function () { + var called = 0; + + function cb1() { + called++; + obj.off('myevent', cb1); + } + function cb2() { + called++; + obj.off('myevent', cb2); + } + function cb3() { + called++; + obj.off('myevent', cb3); + } + + obj.on('myevent', cb1); + obj.on('myevent', cb2); + obj.on('myevent', cb3); + obj.emit('myevent', ''); + + expect(called).to.equal(3); + }); +}); diff --git a/test/unit/pixi-v2/utils/Polyk.js b/test/unit/pixi-v2/utils/Polyk.js new file mode 100644 index 0000000..dfc7128 --- /dev/null +++ b/test/unit/pixi-v2/utils/Polyk.js @@ -0,0 +1,14 @@ +describe('pixi/utils/Polyk', function () { + 'use strict'; + + var expect = chai.expect; + var PolyK = PIXI.PolyK; + + it('Module exists', function () { + expect(PolyK).to.be.an('object'); + }); + + it('Members exist', function () { + expect(PolyK).to.respondTo('Triangulate'); + }); +}); diff --git a/test/unit/pixi-v2/utils/Utils.js b/test/unit/pixi-v2/utils/Utils.js new file mode 100644 index 0000000..c97b3c6 --- /dev/null +++ b/test/unit/pixi-v2/utils/Utils.js @@ -0,0 +1,17 @@ +describe('Utils', function () { + 'use strict'; + + var expect = chai.expect; + + it('requestAnimationFrame exists', function () { + expect(global).to.respondTo('requestAnimationFrame'); + }); + + it('cancelAnimationFrame exists', function () { + expect(global).to.respondTo('cancelAnimationFrame'); + }); + + it('requestAnimFrame exists', function () { + expect(global).to.respondTo('requestAnimFrame'); + }); +}); diff --git a/test/unit/pixi/InteractionManager.js b/test/unit/pixi/InteractionManager.js deleted file mode 100644 index ed3001f..0000000 --- a/test/unit/pixi/InteractionManager.js +++ /dev/null @@ -1,10 +0,0 @@ -describe('pixi/InteractionManager', function () { - 'use strict'; - - var expect = chai.expect; - var InteractionManager = PIXI.InteractionManager; - - it('Module exists', function () { - expect(InteractionManager).to.be.a('function'); - }); -}); diff --git a/test/unit/pixi/Pixi.js b/test/unit/pixi/Pixi.js deleted file mode 100644 index 27debc1..0000000 --- a/test/unit/pixi/Pixi.js +++ /dev/null @@ -1,9 +0,0 @@ -describe('pixi/Pixi', function () { - 'use strict'; - - var expect = chai.expect; - - it('Module exists', function () { - expect(global).to.have.property('PIXI').and.to.be.an('object'); - }); -}); diff --git a/test/unit/pixi/core/Circle.js b/test/unit/pixi/core/Circle.js deleted file mode 100644 index fbcfa17..0000000 --- a/test/unit/pixi/core/Circle.js +++ /dev/null @@ -1,21 +0,0 @@ -describe('pixi/core/Circle', function () { - 'use strict'; - - var expect = chai.expect; - var Circle = PIXI.Circle; - - it('Module exists', function () { - expect(Circle).to.be.a('function'); - }); - - it('Confirm new instance', function () { - var obj = new Circle(); - pixi_core_Circle_confirmNewCircle(obj); - }); - - it("getBounds should return Rectangle that bounds the circle", function() { - var obj = new Circle(100, 250, 50); - var bounds = obj.getBounds(); - pixi_core_Circle_isBoundedByRectangle(obj, bounds); - }); -}); diff --git a/test/unit/pixi/core/Ellipse.js b/test/unit/pixi/core/Ellipse.js deleted file mode 100644 index 026b56f..0000000 --- a/test/unit/pixi/core/Ellipse.js +++ /dev/null @@ -1,24 +0,0 @@ -describe('pixi/core/Ellipse', function () { - 'use strict'; - - var expect = chai.expect; - var Ellipse = PIXI.Ellipse; - - it('Module exists', function () { - expect(Ellipse).to.be.a('function'); - }); - - it('Confirm new instance', function () { - var obj = new Ellipse(); - - expect(obj).to.be.an.instanceof(Ellipse); - expect(obj).to.respondTo('clone'); - expect(obj).to.respondTo('contains'); - expect(obj).to.respondTo('getBounds'); - - expect(obj).to.have.property('x', 0); - expect(obj).to.have.property('y', 0); - expect(obj).to.have.property('width', 0); - expect(obj).to.have.property('height', 0); - }); -}); diff --git a/test/unit/pixi/core/Matrix.js b/test/unit/pixi/core/Matrix.js deleted file mode 100644 index da75e2e..0000000 --- a/test/unit/pixi/core/Matrix.js +++ /dev/null @@ -1,14 +0,0 @@ -describe('pixi/core/Matrix', function () { - 'use strict'; - - var expect = chai.expect; - - it('Matrix exists', function () { - expect(PIXI.Matrix).to.be.an('function'); - }); - - it('Confirm new Matrix', function () { - var matrix = new PIXI.Matrix(); - pixi_core_Matrix_confirmNewMatrix(matrix); - }); -}); diff --git a/test/unit/pixi/core/Point.js b/test/unit/pixi/core/Point.js deleted file mode 100644 index c4d5163..0000000 --- a/test/unit/pixi/core/Point.js +++ /dev/null @@ -1,15 +0,0 @@ -describe('pixi/core/Point', function () { - 'use strict'; - - var expect = chai.expect; - var Point = PIXI.Point; - - it('Module exists', function () { - expect(Point).to.be.a('function'); - }); - - it('Confirm new instance', function () { - var obj = new Point(); - pixi_core_Point_confirm(obj, 0, 0); - }); -}); diff --git a/test/unit/pixi/core/Polygon.js b/test/unit/pixi/core/Polygon.js deleted file mode 100644 index dc8c918..0000000 --- a/test/unit/pixi/core/Polygon.js +++ /dev/null @@ -1,20 +0,0 @@ -describe('pixi/core/Polygon', function () { - 'use strict'; - - var expect = chai.expect; - var Polygon = PIXI.Polygon; - - it('Module exists', function () { - expect(Polygon).to.be.a('function'); - }); - - it('Confirm new instance', function () { - var obj = new Polygon(); - - expect(obj).to.be.an.instanceof(Polygon); - expect(obj).to.respondTo('clone'); - expect(obj).to.respondTo('contains'); - - expect(obj).to.have.deep.property('points.length', 0); - }); -}); diff --git a/test/unit/pixi/core/Rectangle.js b/test/unit/pixi/core/Rectangle.js deleted file mode 100644 index d43316e..0000000 --- a/test/unit/pixi/core/Rectangle.js +++ /dev/null @@ -1,15 +0,0 @@ -describe('pixi/core/Rectangle', function () { - 'use strict'; - - var expect = chai.expect; - var Rectangle = PIXI.Rectangle; - - it('Module exists', function () { - expect(Rectangle).to.be.a('function'); - }); - - it('Confirm new instance', function () { - var rect = new Rectangle(); - pixi_core_Rectangle_confirm(rect, 0, 0, 0, 0); - }); -}); diff --git a/test/unit/pixi/display/DisplayObject.js b/test/unit/pixi/display/DisplayObject.js deleted file mode 100644 index 044acf8..0000000 --- a/test/unit/pixi/display/DisplayObject.js +++ /dev/null @@ -1,21 +0,0 @@ -describe('pixi/display/DisplayObject', function () { - 'use strict'; - - var expect = chai.expect; - var DisplayObject = PIXI.DisplayObject; - - it('Module exists', function () { - expect(DisplayObject).to.be.a('function'); - // expect(PIXI).to.have.property('visibleCount', 0); - }); - - it('Confirm new instance', function () { - var obj = new DisplayObject(); - - pixi_display_DisplayObject_confirmNew(obj); - expect(obj).to.have.property('hitArea', null); - expect(obj).to.have.property('interactive', false); - expect(obj).to.have.property('renderable', false); - expect(obj).to.have.property('stage', null); - }); -}); diff --git a/test/unit/pixi/display/DisplayObjectContainer.js b/test/unit/pixi/display/DisplayObjectContainer.js deleted file mode 100644 index 15a3376..0000000 --- a/test/unit/pixi/display/DisplayObjectContainer.js +++ /dev/null @@ -1,67 +0,0 @@ -describe('pixi/display/DisplayObjectContainer', function () { - 'use strict'; - - var expect = chai.expect; - var DisplayObjectContainer = PIXI.DisplayObjectContainer; - - it('Module exists', function () { - expect(DisplayObjectContainer).to.be.a('function'); - }); - - it('Confirm new instance', function () { - var obj = new DisplayObjectContainer(); - - pixi_display_DisplayObjectContainer_confirmNew(obj); - expect(obj).to.have.property('hitArea', null); - expect(obj).to.have.property('interactive', false); - expect(obj).to.have.property('renderable', false); - expect(obj).to.have.property('stage', null); - }); - - it('Gets child index', function() { - var container = new PIXI.DisplayObjectContainer(); - var children = []; - for (var i = 0; i < 10; i++) { - var child = new PIXI.DisplayObject(); - children.push(child); - container.addChild(child); - } - - for (i = 0; i < children.length; i++) { - expect(i).to.eql(container.getChildIndex(children[i])); - } - }); - - it('throws error when trying to get index of not a child', function() { - var container = new PIXI.DisplayObjectContainer(); - var child = new PIXI.DisplayObject(); - - expect(function() { container.getChildIndex(child); }).to.throw(); - }); - - it('Sets child index', function() { - var container = new PIXI.DisplayObjectContainer(); - var children = []; - - for (var i = 0; i < 10; i++) { - var child = new PIXI.DisplayObject(); - children.push(child); - container.addChild(child); - } - children.reverse(); - - for (i = 0; i < children.length; i++) { - container.setChildIndex(children[i], i); - expect(i).to.eql(container.getChildIndex(children[i])); - } - }); - - it('throws error when trying to set incorect index', function() { - var container = new PIXI.DisplayObjectContainer(); - var child = new PIXI.DisplayObject(); - container.addChild(child); - - expect(function() { container.setChildIndex(child, -1); }).to.throw(); - expect(function() { container.setChildIndex(child, 1); }).to.throw(); - }); -}); diff --git a/test/unit/pixi/display/MovieClip.js b/test/unit/pixi/display/MovieClip.js deleted file mode 100644 index f3c6c6a..0000000 --- a/test/unit/pixi/display/MovieClip.js +++ /dev/null @@ -1,33 +0,0 @@ -describe('pixi/display/MovieClip', function () { - 'use strict'; - - var expect = chai.expect; - var MovieClip = PIXI.MovieClip; - var Texture = PIXI.Texture; - - it('Module exists', function () { - expect(MovieClip).to.be.a('function'); - }); - - it('Confirm new instance', function (done) { - var texture = Texture.fromImage('/base/test/textures/SpriteSheet-Explosion.png'); - var obj = new MovieClip([texture]); - - pixi_display_Sprite_confirmNew(obj, done); - - expect(obj).to.be.an.instanceof(MovieClip); - expect(obj).to.respondTo('stop'); - expect(obj).to.respondTo('play'); - expect(obj).to.respondTo('gotoAndStop'); - expect(obj).to.respondTo('gotoAndPlay'); - expect(obj).to.respondTo('updateTransform'); - - expect(obj).to.have.deep.property('textures.length', 1); - expect(obj).to.have.deep.property('textures[0]', texture); - expect(obj).to.have.property('animationSpeed', 1); - expect(obj).to.have.property('loop', true); - expect(obj).to.have.property('onComplete', null); - expect(obj).to.have.property('currentFrame', 0); - expect(obj).to.have.property('playing', false); - }); -}); diff --git a/test/unit/pixi/display/Sprite.js b/test/unit/pixi/display/Sprite.js deleted file mode 100644 index 30c8076..0000000 --- a/test/unit/pixi/display/Sprite.js +++ /dev/null @@ -1,28 +0,0 @@ -describe('pixi/display/Sprite', function () { - 'use strict'; - - var expect = chai.expect; - var Sprite = PIXI.Sprite; - var Texture = PIXI.Texture; - - it('Module exists', function () { - expect(Sprite).to.be.a('function'); - expect(PIXI).to.have.deep.property('blendModes.NORMAL', 0); - expect(PIXI).to.have.deep.property('blendModes.ADD', 1); - expect(PIXI).to.have.deep.property('blendModes.MULTIPLY', 2); - expect(PIXI).to.have.deep.property('blendModes.SCREEN', 3); - }); - - - it('Members exist', function () { - expect(Sprite).itself.to.respondTo('fromImage'); - expect(Sprite).itself.to.respondTo('fromFrame'); - }); - - it('Confirm new instance', function (done) { - var texture = Texture.fromImage('/base/test/textures/SpriteSheet-Aliens.png'); - var obj = new Sprite(texture); - - pixi_display_Sprite_confirmNew(obj, done); - }); -}); diff --git a/test/unit/pixi/display/Stage.js b/test/unit/pixi/display/Stage.js deleted file mode 100644 index 6974c2e..0000000 --- a/test/unit/pixi/display/Stage.js +++ /dev/null @@ -1,49 +0,0 @@ -describe('pixi/display/Stage', function () { - 'use strict'; - - var expect = chai.expect; - var Stage = PIXI.Stage; - var InteractionManager = PIXI.InteractionManager; - var Rectangle = PIXI.Rectangle; - - it('Module exists', function () { - expect(Stage).to.be.a('function'); - }); - - it('Confirm new instance', function () { - var obj = new Stage(null, true); - - pixi_display_DisplayObjectContainer_confirmNew(obj); - - expect(obj).to.be.an.instanceof(Stage); - expect(obj).to.respondTo('updateTransform'); - expect(obj).to.respondTo('setBackgroundColor'); - expect(obj).to.respondTo('getMousePosition'); - // FIXME: duplicate member in DisplayObject - pixi_core_Matrix_confirmNewMatrix(obj.worldTransform); - // FIXME: convert arg to bool in constructor - expect(obj).to.have.property('interactive', true); - - expect(obj).to.have.property('interactionManager') - .and.to.be.an.instanceof(InteractionManager) - .and.to.have.property('stage', obj); - - expect(obj).to.have.property('dirty', true); - - expect(obj).to.have.property('stage', obj); - - expect(obj).to.have.property('hitArea') - .and.to.be.an.instanceof(Rectangle); - pixi_core_Rectangle_confirm(obj.hitArea, 0, 0, 100000, 100000); - - expect(obj).to.have.property('backgroundColor', 0x000000); - expect(obj).to.have.deep.property('backgroundColorSplit.length', 3); - expect(obj).to.have.deep.property('backgroundColorSplit[0]', 0); - expect(obj).to.have.deep.property('backgroundColorSplit[1]', 0); - expect(obj).to.have.deep.property('backgroundColorSplit[2]', 0); - expect(obj).to.have.property('backgroundColorString', '#000000'); - - - expect(obj).to.have.property('worldVisible', true); - }); -}); diff --git a/test/unit/pixi/extras/Rope.js b/test/unit/pixi/extras/Rope.js deleted file mode 100644 index 05885ac..0000000 --- a/test/unit/pixi/extras/Rope.js +++ /dev/null @@ -1,31 +0,0 @@ -describe('pixi/extras/Rope', function () { - 'use strict'; - - var expect = chai.expect; - var Rope = PIXI.Rope; - var Texture = PIXI.Texture; - var Point = PIXI.Point; - - it('Module exists', function () { - expect(Rope).to.be.a('function'); - }); - - it('Confirm new instance', function () { - - var texture = Texture.fromImage('/base/test/textures/bunny.png'); - - // TODO-Alvin - // Same as Strip - - // var obj = new Rope(texture, [new Point(), new Point(5, 10), new Point(10, 20)]); - - // pixi_extras_Strip_confirmNew(obj); - - // expect(obj).to.be.an.instanceof(Rope); - // expect(obj).to.respondTo('refresh'); - // expect(obj).to.respondTo('updateTransform'); - // expect(obj).to.respondTo('setTexture'); - - // TODO: Test properties - }); -}); diff --git a/test/unit/pixi/extras/Spine.js b/test/unit/pixi/extras/Spine.js deleted file mode 100644 index 0708bc0..0000000 --- a/test/unit/pixi/extras/Spine.js +++ /dev/null @@ -1,10 +0,0 @@ -describe('pixi/extras/Spine', function () { - 'use strict'; - - var expect = chai.expect; - var Spine = PIXI.Spine; - - it('Module exists', function () { - expect(Spine).to.be.a('function'); - }); -}); diff --git a/test/unit/pixi/extras/Strip.js b/test/unit/pixi/extras/Strip.js deleted file mode 100644 index 230af90..0000000 --- a/test/unit/pixi/extras/Strip.js +++ /dev/null @@ -1,26 +0,0 @@ -describe('pixi/extras/Strip', function () { - 'use strict'; - - var expect = chai.expect; - var Strip = PIXI.Strip; - var Texture = PIXI.Texture; - - it('Module exists', function () { - expect(Strip).to.be.a('function'); - }); - - it('Confirm new instance', function () { - - - // TODO-Alvin - // We tweaked it to make it pass the tests, but the whole strip class needs - // to be re-coded - - var texture = Texture.fromImage('/base/test/textures/bunny.png'); - - // var obj = new Strip(texture, 20, 10000); - - - // pixi_extras_Strip_confirmNew(obj); - }); -}); diff --git a/test/unit/pixi/extras/TilingSprite.js b/test/unit/pixi/extras/TilingSprite.js deleted file mode 100644 index 56aea14..0000000 --- a/test/unit/pixi/extras/TilingSprite.js +++ /dev/null @@ -1,24 +0,0 @@ -describe('pixi/extras/TilingSprite', function () { - 'use strict'; - - var expect = chai.expect; - var TilingSprite = PIXI.TilingSprite; - var Texture = PIXI.Texture; - - it('Module exists', function () { - expect(TilingSprite).to.be.a('function'); - }); - - it('Confirm new instance', function () { - var texture = Texture.fromImage('/base/test/textures/bunny.png'); - var obj = new TilingSprite(texture, 6000, 12000); - - pixi_display_DisplayObjectContainer_confirmNew(obj); - - expect(obj).to.be.an.instanceof(TilingSprite); - expect(obj).to.respondTo('setTexture'); - expect(obj).to.respondTo('onTextureUpdate'); - - // TODO: Test properties - }); -}); diff --git a/test/unit/pixi/filters/FilterBlock.js b/test/unit/pixi/filters/FilterBlock.js deleted file mode 100644 index 870cec0..0000000 --- a/test/unit/pixi/filters/FilterBlock.js +++ /dev/null @@ -1,10 +0,0 @@ -describe('pixi/filters/FilterBlock', function () { - 'use strict'; - - var expect = chai.expect; - var FilterBlock = PIXI.FilterBlock; - - it('Module exists', function () { - expect(FilterBlock).to.be.a('function'); - }); -}); diff --git a/test/unit/pixi/loaders/AssetLoader.js b/test/unit/pixi/loaders/AssetLoader.js deleted file mode 100644 index a0aa0b5..0000000 --- a/test/unit/pixi/loaders/AssetLoader.js +++ /dev/null @@ -1,10 +0,0 @@ -describe('pixi/loaders/AssetLoader', function () { - 'use strict'; - - var expect = chai.expect; - var AssetLoader = PIXI.AssetLoader; - - it('Module exists', function () { - expect(AssetLoader).to.be.a('function'); - }); -}); diff --git a/test/unit/pixi/loaders/BitmapFontLoader.js b/test/unit/pixi/loaders/BitmapFontLoader.js deleted file mode 100644 index 046f018..0000000 --- a/test/unit/pixi/loaders/BitmapFontLoader.js +++ /dev/null @@ -1,9 +0,0 @@ -describe('pixi/loaders/BitmapFontLoader', function () { - 'use strict'; - - var expect = chai.expect; - - it('Module exists', function () { - expect(PIXI.BitmapFontLoader).to.be.a('function'); - }); -}); diff --git a/test/unit/pixi/loaders/ImageLoader.js b/test/unit/pixi/loaders/ImageLoader.js deleted file mode 100644 index 8b1f556..0000000 --- a/test/unit/pixi/loaders/ImageLoader.js +++ /dev/null @@ -1,10 +0,0 @@ -describe('pixi/loaders/ImageLoader', function () { - 'use strict'; - - var expect = chai.expect; - var ImageLoader = PIXI.ImageLoader; - - it('Module exists', function () { - expect(ImageLoader).to.be.a('function'); - }); -}); diff --git a/test/unit/pixi/loaders/JsonLoader.js b/test/unit/pixi/loaders/JsonLoader.js deleted file mode 100644 index c577e83..0000000 --- a/test/unit/pixi/loaders/JsonLoader.js +++ /dev/null @@ -1,10 +0,0 @@ -describe('pixi/loaders/JsonLoader', function () { - 'use strict'; - - var expect = chai.expect; - var JsonLoader = PIXI.JsonLoader; - - it('Module exists', function () { - expect(JsonLoader).to.be.a('function'); - }); -}); diff --git a/test/unit/pixi/loaders/SpineLoader.js b/test/unit/pixi/loaders/SpineLoader.js deleted file mode 100644 index fdcc0b8..0000000 --- a/test/unit/pixi/loaders/SpineLoader.js +++ /dev/null @@ -1,10 +0,0 @@ -describe('pixi/loaders/SpineLoader', function () { - 'use strict'; - - var expect = chai.expect; - var SpineLoader = PIXI.SpineLoader; - - it('Module exists', function () { - expect(SpineLoader).to.be.a('function'); - }); -}); diff --git a/test/unit/pixi/loaders/SpriteSheetLoader.js b/test/unit/pixi/loaders/SpriteSheetLoader.js deleted file mode 100644 index 57beb27..0000000 --- a/test/unit/pixi/loaders/SpriteSheetLoader.js +++ /dev/null @@ -1,10 +0,0 @@ -describe('pixi/loaders/SpriteSheetLoader', function () { - 'use strict'; - - var expect = chai.expect; - var SpriteSheetLoader = PIXI.SpriteSheetLoader; - - it('Module exists', function () { - expect(SpriteSheetLoader).to.be.a('function'); - }); -}); diff --git a/test/unit/pixi/primitives/Graphics.js b/test/unit/pixi/primitives/Graphics.js deleted file mode 100644 index f3849eb..0000000 --- a/test/unit/pixi/primitives/Graphics.js +++ /dev/null @@ -1,44 +0,0 @@ -describe('pixi/primitives/Graphics', function () { - 'use strict'; - - var expect = chai.expect; - var Graphics = PIXI.Graphics; - - it('Module exists', function () { - expect(Graphics).to.be.a('function'); - - expect(Graphics).itself.to.have.property('POLY', 0); - expect(Graphics).itself.to.have.property('RECT', 1); - expect(Graphics).itself.to.have.property('CIRC', 2); - expect(Graphics).itself.to.have.property('ELIP', 3); - expect(Graphics).itself.to.have.property('RREC', 4); - }); - - it('Confirm new instance', function () { - var obj = new Graphics(); - - pixi_display_DisplayObjectContainer_confirmNew(obj); - - expect(obj).to.be.an.instanceof(Graphics); - expect(obj).to.respondTo('lineStyle'); - expect(obj).to.respondTo('lineStyle'); - expect(obj).to.respondTo('moveTo'); - expect(obj).to.respondTo('lineTo'); - expect(obj).to.respondTo('beginFill'); - expect(obj).to.respondTo('endFill'); - expect(obj).to.respondTo('drawRect'); - // expect(obj).to.respondTo('drawRoundedRect'); - expect(obj).to.respondTo('drawCircle'); - expect(obj).to.respondTo('drawEllipse'); - expect(obj).to.respondTo('clear'); - - expect(obj).to.have.property('renderable', true); - expect(obj).to.have.property('fillAlpha', 1); - expect(obj).to.have.property('lineWidth', 0); - expect(obj).to.have.property('width', 0); - expect(obj).to.have.property('height', 0); - expect(obj).to.have.property('lineColor', 0); - expect(obj).to.have.deep.property('graphicsData.length', 0); - // expect(obj).to.have.deep.property('currentPath.points.length', 0); - }); -}); diff --git a/test/unit/pixi/renderers/canvas/CanvasGraphics.js b/test/unit/pixi/renderers/canvas/CanvasGraphics.js deleted file mode 100644 index 8f44472..0000000 --- a/test/unit/pixi/renderers/canvas/CanvasGraphics.js +++ /dev/null @@ -1,15 +0,0 @@ -describe('renders/canvas/CanvasGraphics', function () { - 'use strict'; - - var expect = chai.expect; - var CanvasGraphics = PIXI.CanvasGraphics; - - it('Module exists', function () { - expect(CanvasGraphics).to.be.a('function'); - }); - - it('Members exist', function () { - expect(CanvasGraphics).itself.to.respondTo('renderGraphics'); - expect(CanvasGraphics).itself.to.respondTo('renderGraphicsMask'); - }); -}); diff --git a/test/unit/pixi/renderers/canvas/CanvasRenderer.js b/test/unit/pixi/renderers/canvas/CanvasRenderer.js deleted file mode 100644 index 1646444..0000000 --- a/test/unit/pixi/renderers/canvas/CanvasRenderer.js +++ /dev/null @@ -1,36 +0,0 @@ -describe('renderers/canvas/CanvasRenderer', function () { - 'use strict'; - - var expect = chai.expect; - var CanvasRenderer = PIXI.CanvasRenderer; - - it('Module exists', function () { - expect(CanvasRenderer).to.be.a('function'); - }); - - describe('.autoResize', function () { - it('Should automatically resize view if enabled', function () { - var renderer = new CanvasRenderer(200, 200, { - autoResize: true - }); - - expect(renderer.view.style.width).to.equal('200px'); - }); - - it('Should not automatically resize view if disabled', function () { - var renderer = new CanvasRenderer(200, 200, { - autoResize: false - }); - - expect(renderer.view.style.width).to.equal(''); - }); - - it('Should not automatically resize view if not specified', function () { - var renderer = new CanvasRenderer(200, 200, { - resolution: 2 - }); - - expect(renderer.view.style.width).to.equal(''); - }); - }); -}); diff --git a/test/unit/pixi/renderers/webgl/WebGLGraphics.js b/test/unit/pixi/renderers/webgl/WebGLGraphics.js deleted file mode 100644 index 5867b28..0000000 --- a/test/unit/pixi/renderers/webgl/WebGLGraphics.js +++ /dev/null @@ -1,20 +0,0 @@ -describe('renderers/wegbl/WebGLGraphics', function () { - 'use strict'; - - var expect = chai.expect; - var WebGLGraphics = PIXI.WebGLGraphics; - - it('Module exists', function () { - expect(WebGLGraphics).to.be.a('function'); - }); - - it('Members exist', function () { - expect(WebGLGraphics).itself.to.respondTo('renderGraphics'); - expect(WebGLGraphics).itself.to.respondTo('updateGraphics'); - expect(WebGLGraphics).itself.to.respondTo('buildRectangle'); - expect(WebGLGraphics).itself.to.respondTo('buildRoundedRectangle'); - expect(WebGLGraphics).itself.to.respondTo('buildCircle'); - expect(WebGLGraphics).itself.to.respondTo('buildLine'); - expect(WebGLGraphics).itself.to.respondTo('buildPoly'); - }); -}); diff --git a/test/unit/pixi/renderers/webgl/WebGLRenderer.js b/test/unit/pixi/renderers/webgl/WebGLRenderer.js deleted file mode 100644 index 1680a80..0000000 --- a/test/unit/pixi/renderers/webgl/WebGLRenderer.js +++ /dev/null @@ -1,49 +0,0 @@ -describe('renderers/webgl/WebGLRenderer', function () { - 'use strict'; - - var expect = chai.expect; - var WebGLRenderer = PIXI.WebGLRenderer; - - it('Module exists', function () { - expect(WebGLRenderer).to.be.a('function'); - }); - - // Skip tests if WebGL is not available (WebGL not supported in Travis CI) - try { - var renderer = new WebGLRenderer(400, 300, {}); - renderer.destroy(); - } catch (error) { - return; - } - - it('Destroy renderer', function () { - var renderer = new WebGLRenderer(400, 300, {}); - renderer.destroy(); - }); - - describe('.autoResize', function () { - it('Should automatically resize view if enabled', function () { - var renderer = new WebGLRenderer(200, 200, { - autoResize: true - }); - - expect(renderer.view.style.width).to.equal('200px'); - }); - - it('Should not automatically resize view if disabled', function () { - var renderer = new WebGLRenderer(200, 200, { - autoResize: false - }); - - expect(renderer.view.style.width).to.equal(''); - }); - - it('Should not automatically resize view if not specified', function () { - var renderer = new WebGLRenderer(200, 200, { - resolution: 2 - }); - - expect(renderer.view.style.width).to.equal(''); - }); - }); -}); diff --git a/test/unit/pixi/renderers/webgl/WebGLShaders.js b/test/unit/pixi/renderers/webgl/WebGLShaders.js deleted file mode 100644 index 6e33e4f..0000000 --- a/test/unit/pixi/renderers/webgl/WebGLShaders.js +++ /dev/null @@ -1,13 +0,0 @@ -describe('renderers/webgl/WebGLShaders', function () { - 'use strict'; - - var expect = chai.expect; - - it('Module members exist', function () { - - expect(PIXI).to.respondTo('CompileVertexShader'); - expect(PIXI).to.respondTo('CompileFragmentShader'); - expect(PIXI).to.respondTo('_CompileShader'); - expect(PIXI).to.respondTo('compileProgram'); - }); -}); diff --git a/test/unit/pixi/renderers/webgl/WebGLSpriteBatch.js b/test/unit/pixi/renderers/webgl/WebGLSpriteBatch.js deleted file mode 100644 index e662b63..0000000 --- a/test/unit/pixi/renderers/webgl/WebGLSpriteBatch.js +++ /dev/null @@ -1,10 +0,0 @@ -describe('renderers/webgl/utils/WebGLSpriteBatch', function () { - 'use strict'; - - var expect = chai.expect; - var WebGLSpriteBatch = PIXI.WebGLSpriteBatch; - - it('Module exists', function () { - expect(WebGLSpriteBatch).to.be.a('function'); - }); -}); diff --git a/test/unit/pixi/text/BitmapText.js b/test/unit/pixi/text/BitmapText.js deleted file mode 100644 index 9388e3d..0000000 --- a/test/unit/pixi/text/BitmapText.js +++ /dev/null @@ -1,10 +0,0 @@ -describe('pixi/text/BitmapText', function () { - 'use strict'; - - var expect = chai.expect; - var BitmapText = PIXI.BitmapText; - - it('Module exists', function () { - expect(BitmapText).to.be.a('function'); - }); -}); diff --git a/test/unit/pixi/text/Text.js b/test/unit/pixi/text/Text.js deleted file mode 100644 index 9bc9ac5..0000000 --- a/test/unit/pixi/text/Text.js +++ /dev/null @@ -1,10 +0,0 @@ -describe('pixi/text/Text', function () { - 'use strict'; - - var expect = chai.expect; - var Text = PIXI.Text; - - it('Module exists', function () { - expect(Text).to.be.a('function'); - }); -}); diff --git a/test/unit/pixi/textures/BaseTexture.js b/test/unit/pixi/textures/BaseTexture.js deleted file mode 100644 index 502b724..0000000 --- a/test/unit/pixi/textures/BaseTexture.js +++ /dev/null @@ -1,11 +0,0 @@ -describe('pixi/textures/BaseTexture', function () { - 'use strict'; - - var expect = chai.expect; - var BaseTexture = PIXI.BaseTexture; - - it('Module exists', function () { - expect(BaseTexture).to.be.a('function'); - expect(PIXI).to.have.property('BaseTextureCache').and.to.be.an('object'); - }); -}); diff --git a/test/unit/pixi/textures/RenderTexture.js b/test/unit/pixi/textures/RenderTexture.js deleted file mode 100644 index 96acdb4..0000000 --- a/test/unit/pixi/textures/RenderTexture.js +++ /dev/null @@ -1,15 +0,0 @@ -describe('pixi/textures/RenderTexture', function () { - 'use strict'; - - var expect = chai.expect; - var RenderTexture = PIXI.RenderTexture; - - it('Module exists', function () { - expect(RenderTexture).to.be.a('function'); - }); - - it('Confirm new instance', function (done) { - var texture = new RenderTexture(100, 100, new PIXI.CanvasRenderer()); - pixi_textures_RenderTexture_confirmNew(texture, done); - }); -}); diff --git a/test/unit/pixi-v2/InteractionManager.js b/test/unit/pixi-v2/InteractionManager.js new file mode 100644 index 0000000..ed3001f --- /dev/null +++ b/test/unit/pixi-v2/InteractionManager.js @@ -0,0 +1,10 @@ +describe('pixi/InteractionManager', function () { + 'use strict'; + + var expect = chai.expect; + var InteractionManager = PIXI.InteractionManager; + + it('Module exists', function () { + expect(InteractionManager).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/Pixi.js b/test/unit/pixi-v2/Pixi.js new file mode 100644 index 0000000..27debc1 --- /dev/null +++ b/test/unit/pixi-v2/Pixi.js @@ -0,0 +1,9 @@ +describe('pixi/Pixi', function () { + 'use strict'; + + var expect = chai.expect; + + it('Module exists', function () { + expect(global).to.have.property('PIXI').and.to.be.an('object'); + }); +}); diff --git a/test/unit/pixi-v2/core/Circle.js b/test/unit/pixi-v2/core/Circle.js new file mode 100644 index 0000000..fbcfa17 --- /dev/null +++ b/test/unit/pixi-v2/core/Circle.js @@ -0,0 +1,21 @@ +describe('pixi/core/Circle', function () { + 'use strict'; + + var expect = chai.expect; + var Circle = PIXI.Circle; + + it('Module exists', function () { + expect(Circle).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Circle(); + pixi_core_Circle_confirmNewCircle(obj); + }); + + it("getBounds should return Rectangle that bounds the circle", function() { + var obj = new Circle(100, 250, 50); + var bounds = obj.getBounds(); + pixi_core_Circle_isBoundedByRectangle(obj, bounds); + }); +}); diff --git a/test/unit/pixi-v2/core/Ellipse.js b/test/unit/pixi-v2/core/Ellipse.js new file mode 100644 index 0000000..026b56f --- /dev/null +++ b/test/unit/pixi-v2/core/Ellipse.js @@ -0,0 +1,24 @@ +describe('pixi/core/Ellipse', function () { + 'use strict'; + + var expect = chai.expect; + var Ellipse = PIXI.Ellipse; + + it('Module exists', function () { + expect(Ellipse).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Ellipse(); + + expect(obj).to.be.an.instanceof(Ellipse); + expect(obj).to.respondTo('clone'); + expect(obj).to.respondTo('contains'); + expect(obj).to.respondTo('getBounds'); + + expect(obj).to.have.property('x', 0); + expect(obj).to.have.property('y', 0); + expect(obj).to.have.property('width', 0); + expect(obj).to.have.property('height', 0); + }); +}); diff --git a/test/unit/pixi-v2/core/Matrix.js b/test/unit/pixi-v2/core/Matrix.js new file mode 100644 index 0000000..da75e2e --- /dev/null +++ b/test/unit/pixi-v2/core/Matrix.js @@ -0,0 +1,14 @@ +describe('pixi/core/Matrix', function () { + 'use strict'; + + var expect = chai.expect; + + it('Matrix exists', function () { + expect(PIXI.Matrix).to.be.an('function'); + }); + + it('Confirm new Matrix', function () { + var matrix = new PIXI.Matrix(); + pixi_core_Matrix_confirmNewMatrix(matrix); + }); +}); diff --git a/test/unit/pixi-v2/core/Point.js b/test/unit/pixi-v2/core/Point.js new file mode 100644 index 0000000..c4d5163 --- /dev/null +++ b/test/unit/pixi-v2/core/Point.js @@ -0,0 +1,15 @@ +describe('pixi/core/Point', function () { + 'use strict'; + + var expect = chai.expect; + var Point = PIXI.Point; + + it('Module exists', function () { + expect(Point).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Point(); + pixi_core_Point_confirm(obj, 0, 0); + }); +}); diff --git a/test/unit/pixi-v2/core/Polygon.js b/test/unit/pixi-v2/core/Polygon.js new file mode 100644 index 0000000..dc8c918 --- /dev/null +++ b/test/unit/pixi-v2/core/Polygon.js @@ -0,0 +1,20 @@ +describe('pixi/core/Polygon', function () { + 'use strict'; + + var expect = chai.expect; + var Polygon = PIXI.Polygon; + + it('Module exists', function () { + expect(Polygon).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Polygon(); + + expect(obj).to.be.an.instanceof(Polygon); + expect(obj).to.respondTo('clone'); + expect(obj).to.respondTo('contains'); + + expect(obj).to.have.deep.property('points.length', 0); + }); +}); diff --git a/test/unit/pixi-v2/core/Rectangle.js b/test/unit/pixi-v2/core/Rectangle.js new file mode 100644 index 0000000..d43316e --- /dev/null +++ b/test/unit/pixi-v2/core/Rectangle.js @@ -0,0 +1,15 @@ +describe('pixi/core/Rectangle', function () { + 'use strict'; + + var expect = chai.expect; + var Rectangle = PIXI.Rectangle; + + it('Module exists', function () { + expect(Rectangle).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var rect = new Rectangle(); + pixi_core_Rectangle_confirm(rect, 0, 0, 0, 0); + }); +}); diff --git a/test/unit/pixi-v2/display/DisplayObject.js b/test/unit/pixi-v2/display/DisplayObject.js new file mode 100644 index 0000000..044acf8 --- /dev/null +++ b/test/unit/pixi-v2/display/DisplayObject.js @@ -0,0 +1,21 @@ +describe('pixi/display/DisplayObject', function () { + 'use strict'; + + var expect = chai.expect; + var DisplayObject = PIXI.DisplayObject; + + it('Module exists', function () { + expect(DisplayObject).to.be.a('function'); + // expect(PIXI).to.have.property('visibleCount', 0); + }); + + it('Confirm new instance', function () { + var obj = new DisplayObject(); + + pixi_display_DisplayObject_confirmNew(obj); + expect(obj).to.have.property('hitArea', null); + expect(obj).to.have.property('interactive', false); + expect(obj).to.have.property('renderable', false); + expect(obj).to.have.property('stage', null); + }); +}); diff --git a/test/unit/pixi-v2/display/DisplayObjectContainer.js b/test/unit/pixi-v2/display/DisplayObjectContainer.js new file mode 100644 index 0000000..15a3376 --- /dev/null +++ b/test/unit/pixi-v2/display/DisplayObjectContainer.js @@ -0,0 +1,67 @@ +describe('pixi/display/DisplayObjectContainer', function () { + 'use strict'; + + var expect = chai.expect; + var DisplayObjectContainer = PIXI.DisplayObjectContainer; + + it('Module exists', function () { + expect(DisplayObjectContainer).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new DisplayObjectContainer(); + + pixi_display_DisplayObjectContainer_confirmNew(obj); + expect(obj).to.have.property('hitArea', null); + expect(obj).to.have.property('interactive', false); + expect(obj).to.have.property('renderable', false); + expect(obj).to.have.property('stage', null); + }); + + it('Gets child index', function() { + var container = new PIXI.DisplayObjectContainer(); + var children = []; + for (var i = 0; i < 10; i++) { + var child = new PIXI.DisplayObject(); + children.push(child); + container.addChild(child); + } + + for (i = 0; i < children.length; i++) { + expect(i).to.eql(container.getChildIndex(children[i])); + } + }); + + it('throws error when trying to get index of not a child', function() { + var container = new PIXI.DisplayObjectContainer(); + var child = new PIXI.DisplayObject(); + + expect(function() { container.getChildIndex(child); }).to.throw(); + }); + + it('Sets child index', function() { + var container = new PIXI.DisplayObjectContainer(); + var children = []; + + for (var i = 0; i < 10; i++) { + var child = new PIXI.DisplayObject(); + children.push(child); + container.addChild(child); + } + children.reverse(); + + for (i = 0; i < children.length; i++) { + container.setChildIndex(children[i], i); + expect(i).to.eql(container.getChildIndex(children[i])); + } + }); + + it('throws error when trying to set incorect index', function() { + var container = new PIXI.DisplayObjectContainer(); + var child = new PIXI.DisplayObject(); + container.addChild(child); + + expect(function() { container.setChildIndex(child, -1); }).to.throw(); + expect(function() { container.setChildIndex(child, 1); }).to.throw(); + }); +}); diff --git a/test/unit/pixi-v2/display/MovieClip.js b/test/unit/pixi-v2/display/MovieClip.js new file mode 100644 index 0000000..f3c6c6a --- /dev/null +++ b/test/unit/pixi-v2/display/MovieClip.js @@ -0,0 +1,33 @@ +describe('pixi/display/MovieClip', function () { + 'use strict'; + + var expect = chai.expect; + var MovieClip = PIXI.MovieClip; + var Texture = PIXI.Texture; + + it('Module exists', function () { + expect(MovieClip).to.be.a('function'); + }); + + it('Confirm new instance', function (done) { + var texture = Texture.fromImage('/base/test/textures/SpriteSheet-Explosion.png'); + var obj = new MovieClip([texture]); + + pixi_display_Sprite_confirmNew(obj, done); + + expect(obj).to.be.an.instanceof(MovieClip); + expect(obj).to.respondTo('stop'); + expect(obj).to.respondTo('play'); + expect(obj).to.respondTo('gotoAndStop'); + expect(obj).to.respondTo('gotoAndPlay'); + expect(obj).to.respondTo('updateTransform'); + + expect(obj).to.have.deep.property('textures.length', 1); + expect(obj).to.have.deep.property('textures[0]', texture); + expect(obj).to.have.property('animationSpeed', 1); + expect(obj).to.have.property('loop', true); + expect(obj).to.have.property('onComplete', null); + expect(obj).to.have.property('currentFrame', 0); + expect(obj).to.have.property('playing', false); + }); +}); diff --git a/test/unit/pixi-v2/display/Sprite.js b/test/unit/pixi-v2/display/Sprite.js new file mode 100644 index 0000000..30c8076 --- /dev/null +++ b/test/unit/pixi-v2/display/Sprite.js @@ -0,0 +1,28 @@ +describe('pixi/display/Sprite', function () { + 'use strict'; + + var expect = chai.expect; + var Sprite = PIXI.Sprite; + var Texture = PIXI.Texture; + + it('Module exists', function () { + expect(Sprite).to.be.a('function'); + expect(PIXI).to.have.deep.property('blendModes.NORMAL', 0); + expect(PIXI).to.have.deep.property('blendModes.ADD', 1); + expect(PIXI).to.have.deep.property('blendModes.MULTIPLY', 2); + expect(PIXI).to.have.deep.property('blendModes.SCREEN', 3); + }); + + + it('Members exist', function () { + expect(Sprite).itself.to.respondTo('fromImage'); + expect(Sprite).itself.to.respondTo('fromFrame'); + }); + + it('Confirm new instance', function (done) { + var texture = Texture.fromImage('/base/test/textures/SpriteSheet-Aliens.png'); + var obj = new Sprite(texture); + + pixi_display_Sprite_confirmNew(obj, done); + }); +}); diff --git a/test/unit/pixi-v2/display/Stage.js b/test/unit/pixi-v2/display/Stage.js new file mode 100644 index 0000000..6974c2e --- /dev/null +++ b/test/unit/pixi-v2/display/Stage.js @@ -0,0 +1,49 @@ +describe('pixi/display/Stage', function () { + 'use strict'; + + var expect = chai.expect; + var Stage = PIXI.Stage; + var InteractionManager = PIXI.InteractionManager; + var Rectangle = PIXI.Rectangle; + + it('Module exists', function () { + expect(Stage).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Stage(null, true); + + pixi_display_DisplayObjectContainer_confirmNew(obj); + + expect(obj).to.be.an.instanceof(Stage); + expect(obj).to.respondTo('updateTransform'); + expect(obj).to.respondTo('setBackgroundColor'); + expect(obj).to.respondTo('getMousePosition'); + // FIXME: duplicate member in DisplayObject + pixi_core_Matrix_confirmNewMatrix(obj.worldTransform); + // FIXME: convert arg to bool in constructor + expect(obj).to.have.property('interactive', true); + + expect(obj).to.have.property('interactionManager') + .and.to.be.an.instanceof(InteractionManager) + .and.to.have.property('stage', obj); + + expect(obj).to.have.property('dirty', true); + + expect(obj).to.have.property('stage', obj); + + expect(obj).to.have.property('hitArea') + .and.to.be.an.instanceof(Rectangle); + pixi_core_Rectangle_confirm(obj.hitArea, 0, 0, 100000, 100000); + + expect(obj).to.have.property('backgroundColor', 0x000000); + expect(obj).to.have.deep.property('backgroundColorSplit.length', 3); + expect(obj).to.have.deep.property('backgroundColorSplit[0]', 0); + expect(obj).to.have.deep.property('backgroundColorSplit[1]', 0); + expect(obj).to.have.deep.property('backgroundColorSplit[2]', 0); + expect(obj).to.have.property('backgroundColorString', '#000000'); + + + expect(obj).to.have.property('worldVisible', true); + }); +}); diff --git a/test/unit/pixi-v2/extras/Rope.js b/test/unit/pixi-v2/extras/Rope.js new file mode 100644 index 0000000..05885ac --- /dev/null +++ b/test/unit/pixi-v2/extras/Rope.js @@ -0,0 +1,31 @@ +describe('pixi/extras/Rope', function () { + 'use strict'; + + var expect = chai.expect; + var Rope = PIXI.Rope; + var Texture = PIXI.Texture; + var Point = PIXI.Point; + + it('Module exists', function () { + expect(Rope).to.be.a('function'); + }); + + it('Confirm new instance', function () { + + var texture = Texture.fromImage('/base/test/textures/bunny.png'); + + // TODO-Alvin + // Same as Strip + + // var obj = new Rope(texture, [new Point(), new Point(5, 10), new Point(10, 20)]); + + // pixi_extras_Strip_confirmNew(obj); + + // expect(obj).to.be.an.instanceof(Rope); + // expect(obj).to.respondTo('refresh'); + // expect(obj).to.respondTo('updateTransform'); + // expect(obj).to.respondTo('setTexture'); + + // TODO: Test properties + }); +}); diff --git a/test/unit/pixi-v2/extras/Spine.js b/test/unit/pixi-v2/extras/Spine.js new file mode 100644 index 0000000..0708bc0 --- /dev/null +++ b/test/unit/pixi-v2/extras/Spine.js @@ -0,0 +1,10 @@ +describe('pixi/extras/Spine', function () { + 'use strict'; + + var expect = chai.expect; + var Spine = PIXI.Spine; + + it('Module exists', function () { + expect(Spine).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/extras/Strip.js b/test/unit/pixi-v2/extras/Strip.js new file mode 100644 index 0000000..230af90 --- /dev/null +++ b/test/unit/pixi-v2/extras/Strip.js @@ -0,0 +1,26 @@ +describe('pixi/extras/Strip', function () { + 'use strict'; + + var expect = chai.expect; + var Strip = PIXI.Strip; + var Texture = PIXI.Texture; + + it('Module exists', function () { + expect(Strip).to.be.a('function'); + }); + + it('Confirm new instance', function () { + + + // TODO-Alvin + // We tweaked it to make it pass the tests, but the whole strip class needs + // to be re-coded + + var texture = Texture.fromImage('/base/test/textures/bunny.png'); + + // var obj = new Strip(texture, 20, 10000); + + + // pixi_extras_Strip_confirmNew(obj); + }); +}); diff --git a/test/unit/pixi-v2/extras/TilingSprite.js b/test/unit/pixi-v2/extras/TilingSprite.js new file mode 100644 index 0000000..56aea14 --- /dev/null +++ b/test/unit/pixi-v2/extras/TilingSprite.js @@ -0,0 +1,24 @@ +describe('pixi/extras/TilingSprite', function () { + 'use strict'; + + var expect = chai.expect; + var TilingSprite = PIXI.TilingSprite; + var Texture = PIXI.Texture; + + it('Module exists', function () { + expect(TilingSprite).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var texture = Texture.fromImage('/base/test/textures/bunny.png'); + var obj = new TilingSprite(texture, 6000, 12000); + + pixi_display_DisplayObjectContainer_confirmNew(obj); + + expect(obj).to.be.an.instanceof(TilingSprite); + expect(obj).to.respondTo('setTexture'); + expect(obj).to.respondTo('onTextureUpdate'); + + // TODO: Test properties + }); +}); diff --git a/test/unit/pixi-v2/filters/FilterBlock.js b/test/unit/pixi-v2/filters/FilterBlock.js new file mode 100644 index 0000000..870cec0 --- /dev/null +++ b/test/unit/pixi-v2/filters/FilterBlock.js @@ -0,0 +1,10 @@ +describe('pixi/filters/FilterBlock', function () { + 'use strict'; + + var expect = chai.expect; + var FilterBlock = PIXI.FilterBlock; + + it('Module exists', function () { + expect(FilterBlock).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/AssetLoader.js b/test/unit/pixi-v2/loaders/AssetLoader.js new file mode 100644 index 0000000..a0aa0b5 --- /dev/null +++ b/test/unit/pixi-v2/loaders/AssetLoader.js @@ -0,0 +1,10 @@ +describe('pixi/loaders/AssetLoader', function () { + 'use strict'; + + var expect = chai.expect; + var AssetLoader = PIXI.AssetLoader; + + it('Module exists', function () { + expect(AssetLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/BitmapFontLoader.js b/test/unit/pixi-v2/loaders/BitmapFontLoader.js new file mode 100644 index 0000000..046f018 --- /dev/null +++ b/test/unit/pixi-v2/loaders/BitmapFontLoader.js @@ -0,0 +1,9 @@ +describe('pixi/loaders/BitmapFontLoader', function () { + 'use strict'; + + var expect = chai.expect; + + it('Module exists', function () { + expect(PIXI.BitmapFontLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/ImageLoader.js b/test/unit/pixi-v2/loaders/ImageLoader.js new file mode 100644 index 0000000..8b1f556 --- /dev/null +++ b/test/unit/pixi-v2/loaders/ImageLoader.js @@ -0,0 +1,10 @@ +describe('pixi/loaders/ImageLoader', function () { + 'use strict'; + + var expect = chai.expect; + var ImageLoader = PIXI.ImageLoader; + + it('Module exists', function () { + expect(ImageLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/JsonLoader.js b/test/unit/pixi-v2/loaders/JsonLoader.js new file mode 100644 index 0000000..c577e83 --- /dev/null +++ b/test/unit/pixi-v2/loaders/JsonLoader.js @@ -0,0 +1,10 @@ +describe('pixi/loaders/JsonLoader', function () { + 'use strict'; + + var expect = chai.expect; + var JsonLoader = PIXI.JsonLoader; + + it('Module exists', function () { + expect(JsonLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/SpineLoader.js b/test/unit/pixi-v2/loaders/SpineLoader.js new file mode 100644 index 0000000..fdcc0b8 --- /dev/null +++ b/test/unit/pixi-v2/loaders/SpineLoader.js @@ -0,0 +1,10 @@ +describe('pixi/loaders/SpineLoader', function () { + 'use strict'; + + var expect = chai.expect; + var SpineLoader = PIXI.SpineLoader; + + it('Module exists', function () { + expect(SpineLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/SpriteSheetLoader.js b/test/unit/pixi-v2/loaders/SpriteSheetLoader.js new file mode 100644 index 0000000..57beb27 --- /dev/null +++ b/test/unit/pixi-v2/loaders/SpriteSheetLoader.js @@ -0,0 +1,10 @@ +describe('pixi/loaders/SpriteSheetLoader', function () { + 'use strict'; + + var expect = chai.expect; + var SpriteSheetLoader = PIXI.SpriteSheetLoader; + + it('Module exists', function () { + expect(SpriteSheetLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/primitives/Graphics.js b/test/unit/pixi-v2/primitives/Graphics.js new file mode 100644 index 0000000..f3849eb --- /dev/null +++ b/test/unit/pixi-v2/primitives/Graphics.js @@ -0,0 +1,44 @@ +describe('pixi/primitives/Graphics', function () { + 'use strict'; + + var expect = chai.expect; + var Graphics = PIXI.Graphics; + + it('Module exists', function () { + expect(Graphics).to.be.a('function'); + + expect(Graphics).itself.to.have.property('POLY', 0); + expect(Graphics).itself.to.have.property('RECT', 1); + expect(Graphics).itself.to.have.property('CIRC', 2); + expect(Graphics).itself.to.have.property('ELIP', 3); + expect(Graphics).itself.to.have.property('RREC', 4); + }); + + it('Confirm new instance', function () { + var obj = new Graphics(); + + pixi_display_DisplayObjectContainer_confirmNew(obj); + + expect(obj).to.be.an.instanceof(Graphics); + expect(obj).to.respondTo('lineStyle'); + expect(obj).to.respondTo('lineStyle'); + expect(obj).to.respondTo('moveTo'); + expect(obj).to.respondTo('lineTo'); + expect(obj).to.respondTo('beginFill'); + expect(obj).to.respondTo('endFill'); + expect(obj).to.respondTo('drawRect'); + // expect(obj).to.respondTo('drawRoundedRect'); + expect(obj).to.respondTo('drawCircle'); + expect(obj).to.respondTo('drawEllipse'); + expect(obj).to.respondTo('clear'); + + expect(obj).to.have.property('renderable', true); + expect(obj).to.have.property('fillAlpha', 1); + expect(obj).to.have.property('lineWidth', 0); + expect(obj).to.have.property('width', 0); + expect(obj).to.have.property('height', 0); + expect(obj).to.have.property('lineColor', 0); + expect(obj).to.have.deep.property('graphicsData.length', 0); + // expect(obj).to.have.deep.property('currentPath.points.length', 0); + }); +}); diff --git a/test/unit/pixi-v2/renderers/canvas/CanvasGraphics.js b/test/unit/pixi-v2/renderers/canvas/CanvasGraphics.js new file mode 100644 index 0000000..8f44472 --- /dev/null +++ b/test/unit/pixi-v2/renderers/canvas/CanvasGraphics.js @@ -0,0 +1,15 @@ +describe('renders/canvas/CanvasGraphics', function () { + 'use strict'; + + var expect = chai.expect; + var CanvasGraphics = PIXI.CanvasGraphics; + + it('Module exists', function () { + expect(CanvasGraphics).to.be.a('function'); + }); + + it('Members exist', function () { + expect(CanvasGraphics).itself.to.respondTo('renderGraphics'); + expect(CanvasGraphics).itself.to.respondTo('renderGraphicsMask'); + }); +}); diff --git a/test/unit/pixi-v2/renderers/canvas/CanvasRenderer.js b/test/unit/pixi-v2/renderers/canvas/CanvasRenderer.js new file mode 100644 index 0000000..1646444 --- /dev/null +++ b/test/unit/pixi-v2/renderers/canvas/CanvasRenderer.js @@ -0,0 +1,36 @@ +describe('renderers/canvas/CanvasRenderer', function () { + 'use strict'; + + var expect = chai.expect; + var CanvasRenderer = PIXI.CanvasRenderer; + + it('Module exists', function () { + expect(CanvasRenderer).to.be.a('function'); + }); + + describe('.autoResize', function () { + it('Should automatically resize view if enabled', function () { + var renderer = new CanvasRenderer(200, 200, { + autoResize: true + }); + + expect(renderer.view.style.width).to.equal('200px'); + }); + + it('Should not automatically resize view if disabled', function () { + var renderer = new CanvasRenderer(200, 200, { + autoResize: false + }); + + expect(renderer.view.style.width).to.equal(''); + }); + + it('Should not automatically resize view if not specified', function () { + var renderer = new CanvasRenderer(200, 200, { + resolution: 2 + }); + + expect(renderer.view.style.width).to.equal(''); + }); + }); +}); diff --git a/test/unit/pixi-v2/renderers/webgl/WebGLGraphics.js b/test/unit/pixi-v2/renderers/webgl/WebGLGraphics.js new file mode 100644 index 0000000..5867b28 --- /dev/null +++ b/test/unit/pixi-v2/renderers/webgl/WebGLGraphics.js @@ -0,0 +1,20 @@ +describe('renderers/wegbl/WebGLGraphics', function () { + 'use strict'; + + var expect = chai.expect; + var WebGLGraphics = PIXI.WebGLGraphics; + + it('Module exists', function () { + expect(WebGLGraphics).to.be.a('function'); + }); + + it('Members exist', function () { + expect(WebGLGraphics).itself.to.respondTo('renderGraphics'); + expect(WebGLGraphics).itself.to.respondTo('updateGraphics'); + expect(WebGLGraphics).itself.to.respondTo('buildRectangle'); + expect(WebGLGraphics).itself.to.respondTo('buildRoundedRectangle'); + expect(WebGLGraphics).itself.to.respondTo('buildCircle'); + expect(WebGLGraphics).itself.to.respondTo('buildLine'); + expect(WebGLGraphics).itself.to.respondTo('buildPoly'); + }); +}); diff --git a/test/unit/pixi-v2/renderers/webgl/WebGLRenderer.js b/test/unit/pixi-v2/renderers/webgl/WebGLRenderer.js new file mode 100644 index 0000000..1680a80 --- /dev/null +++ b/test/unit/pixi-v2/renderers/webgl/WebGLRenderer.js @@ -0,0 +1,49 @@ +describe('renderers/webgl/WebGLRenderer', function () { + 'use strict'; + + var expect = chai.expect; + var WebGLRenderer = PIXI.WebGLRenderer; + + it('Module exists', function () { + expect(WebGLRenderer).to.be.a('function'); + }); + + // Skip tests if WebGL is not available (WebGL not supported in Travis CI) + try { + var renderer = new WebGLRenderer(400, 300, {}); + renderer.destroy(); + } catch (error) { + return; + } + + it('Destroy renderer', function () { + var renderer = new WebGLRenderer(400, 300, {}); + renderer.destroy(); + }); + + describe('.autoResize', function () { + it('Should automatically resize view if enabled', function () { + var renderer = new WebGLRenderer(200, 200, { + autoResize: true + }); + + expect(renderer.view.style.width).to.equal('200px'); + }); + + it('Should not automatically resize view if disabled', function () { + var renderer = new WebGLRenderer(200, 200, { + autoResize: false + }); + + expect(renderer.view.style.width).to.equal(''); + }); + + it('Should not automatically resize view if not specified', function () { + var renderer = new WebGLRenderer(200, 200, { + resolution: 2 + }); + + expect(renderer.view.style.width).to.equal(''); + }); + }); +}); diff --git a/test/unit/pixi-v2/renderers/webgl/WebGLShaders.js b/test/unit/pixi-v2/renderers/webgl/WebGLShaders.js new file mode 100644 index 0000000..6e33e4f --- /dev/null +++ b/test/unit/pixi-v2/renderers/webgl/WebGLShaders.js @@ -0,0 +1,13 @@ +describe('renderers/webgl/WebGLShaders', function () { + 'use strict'; + + var expect = chai.expect; + + it('Module members exist', function () { + + expect(PIXI).to.respondTo('CompileVertexShader'); + expect(PIXI).to.respondTo('CompileFragmentShader'); + expect(PIXI).to.respondTo('_CompileShader'); + expect(PIXI).to.respondTo('compileProgram'); + }); +}); diff --git a/test/unit/pixi-v2/renderers/webgl/WebGLSpriteBatch.js b/test/unit/pixi-v2/renderers/webgl/WebGLSpriteBatch.js new file mode 100644 index 0000000..e662b63 --- /dev/null +++ b/test/unit/pixi-v2/renderers/webgl/WebGLSpriteBatch.js @@ -0,0 +1,10 @@ +describe('renderers/webgl/utils/WebGLSpriteBatch', function () { + 'use strict'; + + var expect = chai.expect; + var WebGLSpriteBatch = PIXI.WebGLSpriteBatch; + + it('Module exists', function () { + expect(WebGLSpriteBatch).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/text/BitmapText.js b/test/unit/pixi-v2/text/BitmapText.js new file mode 100644 index 0000000..9388e3d --- /dev/null +++ b/test/unit/pixi-v2/text/BitmapText.js @@ -0,0 +1,10 @@ +describe('pixi/text/BitmapText', function () { + 'use strict'; + + var expect = chai.expect; + var BitmapText = PIXI.BitmapText; + + it('Module exists', function () { + expect(BitmapText).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/text/Text.js b/test/unit/pixi-v2/text/Text.js new file mode 100644 index 0000000..9bc9ac5 --- /dev/null +++ b/test/unit/pixi-v2/text/Text.js @@ -0,0 +1,10 @@ +describe('pixi/text/Text', function () { + 'use strict'; + + var expect = chai.expect; + var Text = PIXI.Text; + + it('Module exists', function () { + expect(Text).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/textures/BaseTexture.js b/test/unit/pixi-v2/textures/BaseTexture.js new file mode 100644 index 0000000..502b724 --- /dev/null +++ b/test/unit/pixi-v2/textures/BaseTexture.js @@ -0,0 +1,11 @@ +describe('pixi/textures/BaseTexture', function () { + 'use strict'; + + var expect = chai.expect; + var BaseTexture = PIXI.BaseTexture; + + it('Module exists', function () { + expect(BaseTexture).to.be.a('function'); + expect(PIXI).to.have.property('BaseTextureCache').and.to.be.an('object'); + }); +}); diff --git a/test/unit/pixi-v2/textures/RenderTexture.js b/test/unit/pixi-v2/textures/RenderTexture.js new file mode 100644 index 0000000..96acdb4 --- /dev/null +++ b/test/unit/pixi-v2/textures/RenderTexture.js @@ -0,0 +1,15 @@ +describe('pixi/textures/RenderTexture', function () { + 'use strict'; + + var expect = chai.expect; + var RenderTexture = PIXI.RenderTexture; + + it('Module exists', function () { + expect(RenderTexture).to.be.a('function'); + }); + + it('Confirm new instance', function (done) { + var texture = new RenderTexture(100, 100, new PIXI.CanvasRenderer()); + pixi_textures_RenderTexture_confirmNew(texture, done); + }); +}); diff --git a/test/unit/pixi-v2/textures/Texture.js b/test/unit/pixi-v2/textures/Texture.js new file mode 100644 index 0000000..090f64d --- /dev/null +++ b/test/unit/pixi-v2/textures/Texture.js @@ -0,0 +1,26 @@ +describe('pixi/textures/Texture', function () { + 'use strict'; + + var expect = chai.expect; + var Texture = PIXI.Texture; + + it('Module exists', function () { + expect(Texture).to.be.a('function'); + expect(PIXI).to.have.property('TextureCache').and.to.be.an('object'); + }); + + it('Members exist', function () { + expect(Texture).itself.to.respondTo('fromImage'); + expect(Texture).itself.to.respondTo('fromFrame'); + expect(Texture).itself.to.respondTo('fromCanvas'); + expect(Texture).itself.to.respondTo('addTextureToCache'); + expect(Texture).itself.to.respondTo('removeTextureFromCache'); + + // expect(Texture).itself.to.have.deep.property('frameUpdates.length', 0); + }); + + it('Confirm new instance', function (done) { + var texture = Texture.fromImage('/base/test/textures/bunny.png'); + pixi_textures_Texture_confirmNew(texture, done); + }); +}); diff --git a/test/unit/pixi-v2/utils/Detector.js b/test/unit/pixi-v2/utils/Detector.js new file mode 100644 index 0000000..4cf6008 --- /dev/null +++ b/test/unit/pixi-v2/utils/Detector.js @@ -0,0 +1,10 @@ +describe('pixi/utils/Detector', function () { + 'use strict'; + + var expect = chai.expect; + var autoDetectRenderer = PIXI.autoDetectRenderer; + + it('Module exists', function () { + expect(autoDetectRenderer).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/utils/EventTarget.js b/test/unit/pixi-v2/utils/EventTarget.js new file mode 100644 index 0000000..1cfc3a4 --- /dev/null +++ b/test/unit/pixi-v2/utils/EventTarget.js @@ -0,0 +1,361 @@ +describe('pixi/utils/EventTarget', function () { + 'use strict'; + + var expect = chai.expect; + + var Clazz, PClazz, obj, pobj, obj2; + beforeEach(function () { + Clazz = function () {}; + PClazz = function () {}; + + PIXI.EventTarget.mixin(Clazz.prototype); + PIXI.EventTarget.mixin(PClazz.prototype); + + obj = new Clazz(); + obj2 = new Clazz(); + pobj = new PClazz(); + + obj.parent = pobj; + obj2.parent = obj; + }); + + it('Module exists', function () { + expect(PIXI.EventTarget).to.be.an('object'); + }); + + it('Confirm new instance', function () { + pixi_utils_EventTarget_confirm(obj); + }); + + it('simple on/emit case works', function () { + var myData = {}; + + obj.on('myevent', function (event) { + pixi_utils_EventTarget_Event_confirm(event, obj, myData); + }); + + obj.emit('myevent', myData); + }); + + it('simple once case works', function () { + var called = 0; + + obj.once('myevent', function() { called++; }); + + obj.emit('myevent'); + obj.emit('myevent'); + obj.emit('myevent'); + obj.emit('myevent'); + obj.emit('myevent'); + + expect(called).to.equal(1); + }); + + it('simple off case works', function (done) { + function onMyEvent() { + done(new Error('Event listener should not have been called')); + } + + obj.on('myevent', onMyEvent); + obj.off('myevent', onMyEvent); + obj.emit('myevent'); + + done(); + }); + + it('simple propagation case works', function (done) { + var myData = {}; + + pobj.on('myevent', function () { + done(); + }); + + obj.emit('myevent'); + }); + + it('simple stopPropagation case works', function (done) { + var myData = {}; + + pobj.on('myevent', function () { + done(new Error('Event listener should not have been called on the parent element')); + }); + + obj.on('myevent', function (evt) { + evt.stopPropagation(); + }); + + obj.emit('myevent'); + + done(); + }); + + it('simple stopImmediatePropagation case works', function (done) { + var myData = {}; + + pobj.on('myevent', function () { + done(new Error('Event listener should not have been called on the parent')); + }); + + obj.on('myevent', function (evt) { + evt.stopImmediatePropagation(); + }); + + obj.on('myevent', function () { + done(new Error('Event listener should not have been called on the second')); + }); + + obj.emit('myevent'); + + done(); + }); + + it('multiple dispatches work properly', function () { + var called = 0; + + function onMyEvent() { + called++; + } + + obj.on('myevent', onMyEvent); + obj.emit('myevent'); + obj.emit('myevent'); + obj.emit('myevent'); + obj.emit('myevent'); + + expect(called).to.equal(4); + }); + + it('multiple events work properly', function () { + var called = 0; + + function onMyEvent() { + called++; + } + + obj.on('myevent1', onMyEvent); + obj.on('myevent2', onMyEvent); + obj.on('myevent3', onMyEvent); + obj.emit('myevent1'); + obj.emit('myevent2'); + obj.emit('myevent3'); + + expect(called).to.equal(3); + }); + + it('multiple events one removed works properly', function () { + var called = 0; + + function onMyEvent() { + called++; + } + + obj.on('myevent1', onMyEvent); + obj.on('myevent2', onMyEvent); + obj.on('myevent3', onMyEvent); + + obj.emit('myevent1'); + obj.emit('myevent2'); + obj.emit('myevent3'); + + obj.off('myevent2', onMyEvent); + + obj.emit('myevent1'); + obj.emit('myevent2'); + obj.emit('myevent3'); + + expect(called).to.equal(5); + }); + + it('multiple handlers for one event with some removed', function () { + var called = 0; + + var onMyEvent = function () { + called++; + }, + onMyEvent2 = function () { + called++; + }; + + // add 2 handlers and confirm they both get called + obj.on('myevent', onMyEvent); + obj.on('myevent', onMyEvent); + obj.on('myevent', onMyEvent2); + obj.on('myevent', onMyEvent2); + + obj.emit('myevent'); + + expect(called).to.equal(4); + + // remove one of the handlers, emit again, then ensure 1 more call is made + obj.off('myevent', onMyEvent); + + obj.emit('myevent'); + + expect(called).to.equal(6); + }); + + it('calls to off without a handler do nothing', function () { + var called = 0; + + var onMyEvent = function () { + called++; + }; + + obj.on('myevent', onMyEvent); + obj.on('myevent', onMyEvent); + + obj.emit('myevent'); + + expect(called).to.equal(2); + + obj.off('myevent'); + + obj.emit('myevent'); + + expect(called).to.equal(4); + + obj.off('myevent', onMyEvent); + + obj.emit('myevent'); + + expect(called).to.equal(4); + }); + + it('handles multiple instances with the same prototype', function () { + var called = 0; + + function onMyEvent(e) { + called++; + } + + obj.on('myevent1', onMyEvent); + obj.on('myevent2', onMyEvent); + + obj2.istwo = true; + obj2.on('myevent1', onMyEvent); + obj2.on('myevent2', onMyEvent); + + obj.emit('myevent1'); + obj.emit('myevent2'); + obj2.emit('myevent1'); + obj2.emit('myevent2'); + + //we emit 4 times, but since obj2 is a child of obj the event should bubble + //up to obj and show up there as well. So the obj2.emit() calls each increment + //the counter twice. + expect(called).to.equal(6); + }); + + it('is backwards compatible with older .dispatchEvent({})', function () { + var called = 0, + data = { + some: 'thing', + hello: true + }; + + function onMyEvent(event) { + pixi_utils_EventTarget_Event_confirm(event, obj, data); + + called++; + } + + obj.on('myevent1', onMyEvent); + obj.on('myevent2', onMyEvent); + obj.on('myevent3', onMyEvent); + + data.type = 'myevent1'; + obj.emit(data); + + data.type = 'myevent2'; + obj.emit(data); + + data.type = 'myevent3'; + obj.emit(data); + + obj.off('myevent2', onMyEvent); + + data.type = 'myevent1'; + obj.emit(data); + + data.type = 'myevent2'; + obj.emit(data); + + data.type = 'myevent3'; + obj.emit(data); + + expect(called).to.equal(5); + }); + + it('is backwards compatible with older .call(this)', function () { + var Fn = function() { + PIXI.EventTarget.call(this); + }, + o = new Fn(); + + pixi_utils_EventTarget_confirm(o); + }); + + it('is backwards compatible with older .addEventListener("")', function () { + var called = 0, + data = { + some: 'thing', + hello: true + }; + + function onMyEvent(event) { + pixi_utils_EventTarget_Event_confirm(event, obj, data); + + called++; + } + + obj.addEventListener('myevent1', onMyEvent); + obj.addEventListener('myevent2', onMyEvent); + obj.addEventListener('myevent3', onMyEvent); + + data.type = 'myevent1'; + obj.emit(data); + + data.type = 'myevent2'; + obj.emit(data); + + data.type = 'myevent3'; + obj.emit(data); + + obj.off('myevent2', onMyEvent); + + data.type = 'myevent1'; + obj.emit(data); + + data.type = 'myevent2'; + obj.emit(data); + + data.type = 'myevent3'; + obj.emit(data); + + expect(called).to.equal(5); + }); + + it('event remove during emit call properly', function () { + var called = 0; + + function cb1() { + called++; + obj.off('myevent', cb1); + } + function cb2() { + called++; + obj.off('myevent', cb2); + } + function cb3() { + called++; + obj.off('myevent', cb3); + } + + obj.on('myevent', cb1); + obj.on('myevent', cb2); + obj.on('myevent', cb3); + obj.emit('myevent', ''); + + expect(called).to.equal(3); + }); +}); diff --git a/test/unit/pixi-v2/utils/Polyk.js b/test/unit/pixi-v2/utils/Polyk.js new file mode 100644 index 0000000..dfc7128 --- /dev/null +++ b/test/unit/pixi-v2/utils/Polyk.js @@ -0,0 +1,14 @@ +describe('pixi/utils/Polyk', function () { + 'use strict'; + + var expect = chai.expect; + var PolyK = PIXI.PolyK; + + it('Module exists', function () { + expect(PolyK).to.be.an('object'); + }); + + it('Members exist', function () { + expect(PolyK).to.respondTo('Triangulate'); + }); +}); diff --git a/test/unit/pixi-v2/utils/Utils.js b/test/unit/pixi-v2/utils/Utils.js new file mode 100644 index 0000000..c97b3c6 --- /dev/null +++ b/test/unit/pixi-v2/utils/Utils.js @@ -0,0 +1,17 @@ +describe('Utils', function () { + 'use strict'; + + var expect = chai.expect; + + it('requestAnimationFrame exists', function () { + expect(global).to.respondTo('requestAnimationFrame'); + }); + + it('cancelAnimationFrame exists', function () { + expect(global).to.respondTo('cancelAnimationFrame'); + }); + + it('requestAnimFrame exists', function () { + expect(global).to.respondTo('requestAnimFrame'); + }); +}); diff --git a/test/unit/pixi/InteractionManager.js b/test/unit/pixi/InteractionManager.js deleted file mode 100644 index ed3001f..0000000 --- a/test/unit/pixi/InteractionManager.js +++ /dev/null @@ -1,10 +0,0 @@ -describe('pixi/InteractionManager', function () { - 'use strict'; - - var expect = chai.expect; - var InteractionManager = PIXI.InteractionManager; - - it('Module exists', function () { - expect(InteractionManager).to.be.a('function'); - }); -}); diff --git a/test/unit/pixi/Pixi.js b/test/unit/pixi/Pixi.js deleted file mode 100644 index 27debc1..0000000 --- a/test/unit/pixi/Pixi.js +++ /dev/null @@ -1,9 +0,0 @@ -describe('pixi/Pixi', function () { - 'use strict'; - - var expect = chai.expect; - - it('Module exists', function () { - expect(global).to.have.property('PIXI').and.to.be.an('object'); - }); -}); diff --git a/test/unit/pixi/core/Circle.js b/test/unit/pixi/core/Circle.js deleted file mode 100644 index fbcfa17..0000000 --- a/test/unit/pixi/core/Circle.js +++ /dev/null @@ -1,21 +0,0 @@ -describe('pixi/core/Circle', function () { - 'use strict'; - - var expect = chai.expect; - var Circle = PIXI.Circle; - - it('Module exists', function () { - expect(Circle).to.be.a('function'); - }); - - it('Confirm new instance', function () { - var obj = new Circle(); - pixi_core_Circle_confirmNewCircle(obj); - }); - - it("getBounds should return Rectangle that bounds the circle", function() { - var obj = new Circle(100, 250, 50); - var bounds = obj.getBounds(); - pixi_core_Circle_isBoundedByRectangle(obj, bounds); - }); -}); diff --git a/test/unit/pixi/core/Ellipse.js b/test/unit/pixi/core/Ellipse.js deleted file mode 100644 index 026b56f..0000000 --- a/test/unit/pixi/core/Ellipse.js +++ /dev/null @@ -1,24 +0,0 @@ -describe('pixi/core/Ellipse', function () { - 'use strict'; - - var expect = chai.expect; - var Ellipse = PIXI.Ellipse; - - it('Module exists', function () { - expect(Ellipse).to.be.a('function'); - }); - - it('Confirm new instance', function () { - var obj = new Ellipse(); - - expect(obj).to.be.an.instanceof(Ellipse); - expect(obj).to.respondTo('clone'); - expect(obj).to.respondTo('contains'); - expect(obj).to.respondTo('getBounds'); - - expect(obj).to.have.property('x', 0); - expect(obj).to.have.property('y', 0); - expect(obj).to.have.property('width', 0); - expect(obj).to.have.property('height', 0); - }); -}); diff --git a/test/unit/pixi/core/Matrix.js b/test/unit/pixi/core/Matrix.js deleted file mode 100644 index da75e2e..0000000 --- a/test/unit/pixi/core/Matrix.js +++ /dev/null @@ -1,14 +0,0 @@ -describe('pixi/core/Matrix', function () { - 'use strict'; - - var expect = chai.expect; - - it('Matrix exists', function () { - expect(PIXI.Matrix).to.be.an('function'); - }); - - it('Confirm new Matrix', function () { - var matrix = new PIXI.Matrix(); - pixi_core_Matrix_confirmNewMatrix(matrix); - }); -}); diff --git a/test/unit/pixi/core/Point.js b/test/unit/pixi/core/Point.js deleted file mode 100644 index c4d5163..0000000 --- a/test/unit/pixi/core/Point.js +++ /dev/null @@ -1,15 +0,0 @@ -describe('pixi/core/Point', function () { - 'use strict'; - - var expect = chai.expect; - var Point = PIXI.Point; - - it('Module exists', function () { - expect(Point).to.be.a('function'); - }); - - it('Confirm new instance', function () { - var obj = new Point(); - pixi_core_Point_confirm(obj, 0, 0); - }); -}); diff --git a/test/unit/pixi/core/Polygon.js b/test/unit/pixi/core/Polygon.js deleted file mode 100644 index dc8c918..0000000 --- a/test/unit/pixi/core/Polygon.js +++ /dev/null @@ -1,20 +0,0 @@ -describe('pixi/core/Polygon', function () { - 'use strict'; - - var expect = chai.expect; - var Polygon = PIXI.Polygon; - - it('Module exists', function () { - expect(Polygon).to.be.a('function'); - }); - - it('Confirm new instance', function () { - var obj = new Polygon(); - - expect(obj).to.be.an.instanceof(Polygon); - expect(obj).to.respondTo('clone'); - expect(obj).to.respondTo('contains'); - - expect(obj).to.have.deep.property('points.length', 0); - }); -}); diff --git a/test/unit/pixi/core/Rectangle.js b/test/unit/pixi/core/Rectangle.js deleted file mode 100644 index d43316e..0000000 --- a/test/unit/pixi/core/Rectangle.js +++ /dev/null @@ -1,15 +0,0 @@ -describe('pixi/core/Rectangle', function () { - 'use strict'; - - var expect = chai.expect; - var Rectangle = PIXI.Rectangle; - - it('Module exists', function () { - expect(Rectangle).to.be.a('function'); - }); - - it('Confirm new instance', function () { - var rect = new Rectangle(); - pixi_core_Rectangle_confirm(rect, 0, 0, 0, 0); - }); -}); diff --git a/test/unit/pixi/display/DisplayObject.js b/test/unit/pixi/display/DisplayObject.js deleted file mode 100644 index 044acf8..0000000 --- a/test/unit/pixi/display/DisplayObject.js +++ /dev/null @@ -1,21 +0,0 @@ -describe('pixi/display/DisplayObject', function () { - 'use strict'; - - var expect = chai.expect; - var DisplayObject = PIXI.DisplayObject; - - it('Module exists', function () { - expect(DisplayObject).to.be.a('function'); - // expect(PIXI).to.have.property('visibleCount', 0); - }); - - it('Confirm new instance', function () { - var obj = new DisplayObject(); - - pixi_display_DisplayObject_confirmNew(obj); - expect(obj).to.have.property('hitArea', null); - expect(obj).to.have.property('interactive', false); - expect(obj).to.have.property('renderable', false); - expect(obj).to.have.property('stage', null); - }); -}); diff --git a/test/unit/pixi/display/DisplayObjectContainer.js b/test/unit/pixi/display/DisplayObjectContainer.js deleted file mode 100644 index 15a3376..0000000 --- a/test/unit/pixi/display/DisplayObjectContainer.js +++ /dev/null @@ -1,67 +0,0 @@ -describe('pixi/display/DisplayObjectContainer', function () { - 'use strict'; - - var expect = chai.expect; - var DisplayObjectContainer = PIXI.DisplayObjectContainer; - - it('Module exists', function () { - expect(DisplayObjectContainer).to.be.a('function'); - }); - - it('Confirm new instance', function () { - var obj = new DisplayObjectContainer(); - - pixi_display_DisplayObjectContainer_confirmNew(obj); - expect(obj).to.have.property('hitArea', null); - expect(obj).to.have.property('interactive', false); - expect(obj).to.have.property('renderable', false); - expect(obj).to.have.property('stage', null); - }); - - it('Gets child index', function() { - var container = new PIXI.DisplayObjectContainer(); - var children = []; - for (var i = 0; i < 10; i++) { - var child = new PIXI.DisplayObject(); - children.push(child); - container.addChild(child); - } - - for (i = 0; i < children.length; i++) { - expect(i).to.eql(container.getChildIndex(children[i])); - } - }); - - it('throws error when trying to get index of not a child', function() { - var container = new PIXI.DisplayObjectContainer(); - var child = new PIXI.DisplayObject(); - - expect(function() { container.getChildIndex(child); }).to.throw(); - }); - - it('Sets child index', function() { - var container = new PIXI.DisplayObjectContainer(); - var children = []; - - for (var i = 0; i < 10; i++) { - var child = new PIXI.DisplayObject(); - children.push(child); - container.addChild(child); - } - children.reverse(); - - for (i = 0; i < children.length; i++) { - container.setChildIndex(children[i], i); - expect(i).to.eql(container.getChildIndex(children[i])); - } - }); - - it('throws error when trying to set incorect index', function() { - var container = new PIXI.DisplayObjectContainer(); - var child = new PIXI.DisplayObject(); - container.addChild(child); - - expect(function() { container.setChildIndex(child, -1); }).to.throw(); - expect(function() { container.setChildIndex(child, 1); }).to.throw(); - }); -}); diff --git a/test/unit/pixi/display/MovieClip.js b/test/unit/pixi/display/MovieClip.js deleted file mode 100644 index f3c6c6a..0000000 --- a/test/unit/pixi/display/MovieClip.js +++ /dev/null @@ -1,33 +0,0 @@ -describe('pixi/display/MovieClip', function () { - 'use strict'; - - var expect = chai.expect; - var MovieClip = PIXI.MovieClip; - var Texture = PIXI.Texture; - - it('Module exists', function () { - expect(MovieClip).to.be.a('function'); - }); - - it('Confirm new instance', function (done) { - var texture = Texture.fromImage('/base/test/textures/SpriteSheet-Explosion.png'); - var obj = new MovieClip([texture]); - - pixi_display_Sprite_confirmNew(obj, done); - - expect(obj).to.be.an.instanceof(MovieClip); - expect(obj).to.respondTo('stop'); - expect(obj).to.respondTo('play'); - expect(obj).to.respondTo('gotoAndStop'); - expect(obj).to.respondTo('gotoAndPlay'); - expect(obj).to.respondTo('updateTransform'); - - expect(obj).to.have.deep.property('textures.length', 1); - expect(obj).to.have.deep.property('textures[0]', texture); - expect(obj).to.have.property('animationSpeed', 1); - expect(obj).to.have.property('loop', true); - expect(obj).to.have.property('onComplete', null); - expect(obj).to.have.property('currentFrame', 0); - expect(obj).to.have.property('playing', false); - }); -}); diff --git a/test/unit/pixi/display/Sprite.js b/test/unit/pixi/display/Sprite.js deleted file mode 100644 index 30c8076..0000000 --- a/test/unit/pixi/display/Sprite.js +++ /dev/null @@ -1,28 +0,0 @@ -describe('pixi/display/Sprite', function () { - 'use strict'; - - var expect = chai.expect; - var Sprite = PIXI.Sprite; - var Texture = PIXI.Texture; - - it('Module exists', function () { - expect(Sprite).to.be.a('function'); - expect(PIXI).to.have.deep.property('blendModes.NORMAL', 0); - expect(PIXI).to.have.deep.property('blendModes.ADD', 1); - expect(PIXI).to.have.deep.property('blendModes.MULTIPLY', 2); - expect(PIXI).to.have.deep.property('blendModes.SCREEN', 3); - }); - - - it('Members exist', function () { - expect(Sprite).itself.to.respondTo('fromImage'); - expect(Sprite).itself.to.respondTo('fromFrame'); - }); - - it('Confirm new instance', function (done) { - var texture = Texture.fromImage('/base/test/textures/SpriteSheet-Aliens.png'); - var obj = new Sprite(texture); - - pixi_display_Sprite_confirmNew(obj, done); - }); -}); diff --git a/test/unit/pixi/display/Stage.js b/test/unit/pixi/display/Stage.js deleted file mode 100644 index 6974c2e..0000000 --- a/test/unit/pixi/display/Stage.js +++ /dev/null @@ -1,49 +0,0 @@ -describe('pixi/display/Stage', function () { - 'use strict'; - - var expect = chai.expect; - var Stage = PIXI.Stage; - var InteractionManager = PIXI.InteractionManager; - var Rectangle = PIXI.Rectangle; - - it('Module exists', function () { - expect(Stage).to.be.a('function'); - }); - - it('Confirm new instance', function () { - var obj = new Stage(null, true); - - pixi_display_DisplayObjectContainer_confirmNew(obj); - - expect(obj).to.be.an.instanceof(Stage); - expect(obj).to.respondTo('updateTransform'); - expect(obj).to.respondTo('setBackgroundColor'); - expect(obj).to.respondTo('getMousePosition'); - // FIXME: duplicate member in DisplayObject - pixi_core_Matrix_confirmNewMatrix(obj.worldTransform); - // FIXME: convert arg to bool in constructor - expect(obj).to.have.property('interactive', true); - - expect(obj).to.have.property('interactionManager') - .and.to.be.an.instanceof(InteractionManager) - .and.to.have.property('stage', obj); - - expect(obj).to.have.property('dirty', true); - - expect(obj).to.have.property('stage', obj); - - expect(obj).to.have.property('hitArea') - .and.to.be.an.instanceof(Rectangle); - pixi_core_Rectangle_confirm(obj.hitArea, 0, 0, 100000, 100000); - - expect(obj).to.have.property('backgroundColor', 0x000000); - expect(obj).to.have.deep.property('backgroundColorSplit.length', 3); - expect(obj).to.have.deep.property('backgroundColorSplit[0]', 0); - expect(obj).to.have.deep.property('backgroundColorSplit[1]', 0); - expect(obj).to.have.deep.property('backgroundColorSplit[2]', 0); - expect(obj).to.have.property('backgroundColorString', '#000000'); - - - expect(obj).to.have.property('worldVisible', true); - }); -}); diff --git a/test/unit/pixi/extras/Rope.js b/test/unit/pixi/extras/Rope.js deleted file mode 100644 index 05885ac..0000000 --- a/test/unit/pixi/extras/Rope.js +++ /dev/null @@ -1,31 +0,0 @@ -describe('pixi/extras/Rope', function () { - 'use strict'; - - var expect = chai.expect; - var Rope = PIXI.Rope; - var Texture = PIXI.Texture; - var Point = PIXI.Point; - - it('Module exists', function () { - expect(Rope).to.be.a('function'); - }); - - it('Confirm new instance', function () { - - var texture = Texture.fromImage('/base/test/textures/bunny.png'); - - // TODO-Alvin - // Same as Strip - - // var obj = new Rope(texture, [new Point(), new Point(5, 10), new Point(10, 20)]); - - // pixi_extras_Strip_confirmNew(obj); - - // expect(obj).to.be.an.instanceof(Rope); - // expect(obj).to.respondTo('refresh'); - // expect(obj).to.respondTo('updateTransform'); - // expect(obj).to.respondTo('setTexture'); - - // TODO: Test properties - }); -}); diff --git a/test/unit/pixi/extras/Spine.js b/test/unit/pixi/extras/Spine.js deleted file mode 100644 index 0708bc0..0000000 --- a/test/unit/pixi/extras/Spine.js +++ /dev/null @@ -1,10 +0,0 @@ -describe('pixi/extras/Spine', function () { - 'use strict'; - - var expect = chai.expect; - var Spine = PIXI.Spine; - - it('Module exists', function () { - expect(Spine).to.be.a('function'); - }); -}); diff --git a/test/unit/pixi/extras/Strip.js b/test/unit/pixi/extras/Strip.js deleted file mode 100644 index 230af90..0000000 --- a/test/unit/pixi/extras/Strip.js +++ /dev/null @@ -1,26 +0,0 @@ -describe('pixi/extras/Strip', function () { - 'use strict'; - - var expect = chai.expect; - var Strip = PIXI.Strip; - var Texture = PIXI.Texture; - - it('Module exists', function () { - expect(Strip).to.be.a('function'); - }); - - it('Confirm new instance', function () { - - - // TODO-Alvin - // We tweaked it to make it pass the tests, but the whole strip class needs - // to be re-coded - - var texture = Texture.fromImage('/base/test/textures/bunny.png'); - - // var obj = new Strip(texture, 20, 10000); - - - // pixi_extras_Strip_confirmNew(obj); - }); -}); diff --git a/test/unit/pixi/extras/TilingSprite.js b/test/unit/pixi/extras/TilingSprite.js deleted file mode 100644 index 56aea14..0000000 --- a/test/unit/pixi/extras/TilingSprite.js +++ /dev/null @@ -1,24 +0,0 @@ -describe('pixi/extras/TilingSprite', function () { - 'use strict'; - - var expect = chai.expect; - var TilingSprite = PIXI.TilingSprite; - var Texture = PIXI.Texture; - - it('Module exists', function () { - expect(TilingSprite).to.be.a('function'); - }); - - it('Confirm new instance', function () { - var texture = Texture.fromImage('/base/test/textures/bunny.png'); - var obj = new TilingSprite(texture, 6000, 12000); - - pixi_display_DisplayObjectContainer_confirmNew(obj); - - expect(obj).to.be.an.instanceof(TilingSprite); - expect(obj).to.respondTo('setTexture'); - expect(obj).to.respondTo('onTextureUpdate'); - - // TODO: Test properties - }); -}); diff --git a/test/unit/pixi/filters/FilterBlock.js b/test/unit/pixi/filters/FilterBlock.js deleted file mode 100644 index 870cec0..0000000 --- a/test/unit/pixi/filters/FilterBlock.js +++ /dev/null @@ -1,10 +0,0 @@ -describe('pixi/filters/FilterBlock', function () { - 'use strict'; - - var expect = chai.expect; - var FilterBlock = PIXI.FilterBlock; - - it('Module exists', function () { - expect(FilterBlock).to.be.a('function'); - }); -}); diff --git a/test/unit/pixi/loaders/AssetLoader.js b/test/unit/pixi/loaders/AssetLoader.js deleted file mode 100644 index a0aa0b5..0000000 --- a/test/unit/pixi/loaders/AssetLoader.js +++ /dev/null @@ -1,10 +0,0 @@ -describe('pixi/loaders/AssetLoader', function () { - 'use strict'; - - var expect = chai.expect; - var AssetLoader = PIXI.AssetLoader; - - it('Module exists', function () { - expect(AssetLoader).to.be.a('function'); - }); -}); diff --git a/test/unit/pixi/loaders/BitmapFontLoader.js b/test/unit/pixi/loaders/BitmapFontLoader.js deleted file mode 100644 index 046f018..0000000 --- a/test/unit/pixi/loaders/BitmapFontLoader.js +++ /dev/null @@ -1,9 +0,0 @@ -describe('pixi/loaders/BitmapFontLoader', function () { - 'use strict'; - - var expect = chai.expect; - - it('Module exists', function () { - expect(PIXI.BitmapFontLoader).to.be.a('function'); - }); -}); diff --git a/test/unit/pixi/loaders/ImageLoader.js b/test/unit/pixi/loaders/ImageLoader.js deleted file mode 100644 index 8b1f556..0000000 --- a/test/unit/pixi/loaders/ImageLoader.js +++ /dev/null @@ -1,10 +0,0 @@ -describe('pixi/loaders/ImageLoader', function () { - 'use strict'; - - var expect = chai.expect; - var ImageLoader = PIXI.ImageLoader; - - it('Module exists', function () { - expect(ImageLoader).to.be.a('function'); - }); -}); diff --git a/test/unit/pixi/loaders/JsonLoader.js b/test/unit/pixi/loaders/JsonLoader.js deleted file mode 100644 index c577e83..0000000 --- a/test/unit/pixi/loaders/JsonLoader.js +++ /dev/null @@ -1,10 +0,0 @@ -describe('pixi/loaders/JsonLoader', function () { - 'use strict'; - - var expect = chai.expect; - var JsonLoader = PIXI.JsonLoader; - - it('Module exists', function () { - expect(JsonLoader).to.be.a('function'); - }); -}); diff --git a/test/unit/pixi/loaders/SpineLoader.js b/test/unit/pixi/loaders/SpineLoader.js deleted file mode 100644 index fdcc0b8..0000000 --- a/test/unit/pixi/loaders/SpineLoader.js +++ /dev/null @@ -1,10 +0,0 @@ -describe('pixi/loaders/SpineLoader', function () { - 'use strict'; - - var expect = chai.expect; - var SpineLoader = PIXI.SpineLoader; - - it('Module exists', function () { - expect(SpineLoader).to.be.a('function'); - }); -}); diff --git a/test/unit/pixi/loaders/SpriteSheetLoader.js b/test/unit/pixi/loaders/SpriteSheetLoader.js deleted file mode 100644 index 57beb27..0000000 --- a/test/unit/pixi/loaders/SpriteSheetLoader.js +++ /dev/null @@ -1,10 +0,0 @@ -describe('pixi/loaders/SpriteSheetLoader', function () { - 'use strict'; - - var expect = chai.expect; - var SpriteSheetLoader = PIXI.SpriteSheetLoader; - - it('Module exists', function () { - expect(SpriteSheetLoader).to.be.a('function'); - }); -}); diff --git a/test/unit/pixi/primitives/Graphics.js b/test/unit/pixi/primitives/Graphics.js deleted file mode 100644 index f3849eb..0000000 --- a/test/unit/pixi/primitives/Graphics.js +++ /dev/null @@ -1,44 +0,0 @@ -describe('pixi/primitives/Graphics', function () { - 'use strict'; - - var expect = chai.expect; - var Graphics = PIXI.Graphics; - - it('Module exists', function () { - expect(Graphics).to.be.a('function'); - - expect(Graphics).itself.to.have.property('POLY', 0); - expect(Graphics).itself.to.have.property('RECT', 1); - expect(Graphics).itself.to.have.property('CIRC', 2); - expect(Graphics).itself.to.have.property('ELIP', 3); - expect(Graphics).itself.to.have.property('RREC', 4); - }); - - it('Confirm new instance', function () { - var obj = new Graphics(); - - pixi_display_DisplayObjectContainer_confirmNew(obj); - - expect(obj).to.be.an.instanceof(Graphics); - expect(obj).to.respondTo('lineStyle'); - expect(obj).to.respondTo('lineStyle'); - expect(obj).to.respondTo('moveTo'); - expect(obj).to.respondTo('lineTo'); - expect(obj).to.respondTo('beginFill'); - expect(obj).to.respondTo('endFill'); - expect(obj).to.respondTo('drawRect'); - // expect(obj).to.respondTo('drawRoundedRect'); - expect(obj).to.respondTo('drawCircle'); - expect(obj).to.respondTo('drawEllipse'); - expect(obj).to.respondTo('clear'); - - expect(obj).to.have.property('renderable', true); - expect(obj).to.have.property('fillAlpha', 1); - expect(obj).to.have.property('lineWidth', 0); - expect(obj).to.have.property('width', 0); - expect(obj).to.have.property('height', 0); - expect(obj).to.have.property('lineColor', 0); - expect(obj).to.have.deep.property('graphicsData.length', 0); - // expect(obj).to.have.deep.property('currentPath.points.length', 0); - }); -}); diff --git a/test/unit/pixi/renderers/canvas/CanvasGraphics.js b/test/unit/pixi/renderers/canvas/CanvasGraphics.js deleted file mode 100644 index 8f44472..0000000 --- a/test/unit/pixi/renderers/canvas/CanvasGraphics.js +++ /dev/null @@ -1,15 +0,0 @@ -describe('renders/canvas/CanvasGraphics', function () { - 'use strict'; - - var expect = chai.expect; - var CanvasGraphics = PIXI.CanvasGraphics; - - it('Module exists', function () { - expect(CanvasGraphics).to.be.a('function'); - }); - - it('Members exist', function () { - expect(CanvasGraphics).itself.to.respondTo('renderGraphics'); - expect(CanvasGraphics).itself.to.respondTo('renderGraphicsMask'); - }); -}); diff --git a/test/unit/pixi/renderers/canvas/CanvasRenderer.js b/test/unit/pixi/renderers/canvas/CanvasRenderer.js deleted file mode 100644 index 1646444..0000000 --- a/test/unit/pixi/renderers/canvas/CanvasRenderer.js +++ /dev/null @@ -1,36 +0,0 @@ -describe('renderers/canvas/CanvasRenderer', function () { - 'use strict'; - - var expect = chai.expect; - var CanvasRenderer = PIXI.CanvasRenderer; - - it('Module exists', function () { - expect(CanvasRenderer).to.be.a('function'); - }); - - describe('.autoResize', function () { - it('Should automatically resize view if enabled', function () { - var renderer = new CanvasRenderer(200, 200, { - autoResize: true - }); - - expect(renderer.view.style.width).to.equal('200px'); - }); - - it('Should not automatically resize view if disabled', function () { - var renderer = new CanvasRenderer(200, 200, { - autoResize: false - }); - - expect(renderer.view.style.width).to.equal(''); - }); - - it('Should not automatically resize view if not specified', function () { - var renderer = new CanvasRenderer(200, 200, { - resolution: 2 - }); - - expect(renderer.view.style.width).to.equal(''); - }); - }); -}); diff --git a/test/unit/pixi/renderers/webgl/WebGLGraphics.js b/test/unit/pixi/renderers/webgl/WebGLGraphics.js deleted file mode 100644 index 5867b28..0000000 --- a/test/unit/pixi/renderers/webgl/WebGLGraphics.js +++ /dev/null @@ -1,20 +0,0 @@ -describe('renderers/wegbl/WebGLGraphics', function () { - 'use strict'; - - var expect = chai.expect; - var WebGLGraphics = PIXI.WebGLGraphics; - - it('Module exists', function () { - expect(WebGLGraphics).to.be.a('function'); - }); - - it('Members exist', function () { - expect(WebGLGraphics).itself.to.respondTo('renderGraphics'); - expect(WebGLGraphics).itself.to.respondTo('updateGraphics'); - expect(WebGLGraphics).itself.to.respondTo('buildRectangle'); - expect(WebGLGraphics).itself.to.respondTo('buildRoundedRectangle'); - expect(WebGLGraphics).itself.to.respondTo('buildCircle'); - expect(WebGLGraphics).itself.to.respondTo('buildLine'); - expect(WebGLGraphics).itself.to.respondTo('buildPoly'); - }); -}); diff --git a/test/unit/pixi/renderers/webgl/WebGLRenderer.js b/test/unit/pixi/renderers/webgl/WebGLRenderer.js deleted file mode 100644 index 1680a80..0000000 --- a/test/unit/pixi/renderers/webgl/WebGLRenderer.js +++ /dev/null @@ -1,49 +0,0 @@ -describe('renderers/webgl/WebGLRenderer', function () { - 'use strict'; - - var expect = chai.expect; - var WebGLRenderer = PIXI.WebGLRenderer; - - it('Module exists', function () { - expect(WebGLRenderer).to.be.a('function'); - }); - - // Skip tests if WebGL is not available (WebGL not supported in Travis CI) - try { - var renderer = new WebGLRenderer(400, 300, {}); - renderer.destroy(); - } catch (error) { - return; - } - - it('Destroy renderer', function () { - var renderer = new WebGLRenderer(400, 300, {}); - renderer.destroy(); - }); - - describe('.autoResize', function () { - it('Should automatically resize view if enabled', function () { - var renderer = new WebGLRenderer(200, 200, { - autoResize: true - }); - - expect(renderer.view.style.width).to.equal('200px'); - }); - - it('Should not automatically resize view if disabled', function () { - var renderer = new WebGLRenderer(200, 200, { - autoResize: false - }); - - expect(renderer.view.style.width).to.equal(''); - }); - - it('Should not automatically resize view if not specified', function () { - var renderer = new WebGLRenderer(200, 200, { - resolution: 2 - }); - - expect(renderer.view.style.width).to.equal(''); - }); - }); -}); diff --git a/test/unit/pixi/renderers/webgl/WebGLShaders.js b/test/unit/pixi/renderers/webgl/WebGLShaders.js deleted file mode 100644 index 6e33e4f..0000000 --- a/test/unit/pixi/renderers/webgl/WebGLShaders.js +++ /dev/null @@ -1,13 +0,0 @@ -describe('renderers/webgl/WebGLShaders', function () { - 'use strict'; - - var expect = chai.expect; - - it('Module members exist', function () { - - expect(PIXI).to.respondTo('CompileVertexShader'); - expect(PIXI).to.respondTo('CompileFragmentShader'); - expect(PIXI).to.respondTo('_CompileShader'); - expect(PIXI).to.respondTo('compileProgram'); - }); -}); diff --git a/test/unit/pixi/renderers/webgl/WebGLSpriteBatch.js b/test/unit/pixi/renderers/webgl/WebGLSpriteBatch.js deleted file mode 100644 index e662b63..0000000 --- a/test/unit/pixi/renderers/webgl/WebGLSpriteBatch.js +++ /dev/null @@ -1,10 +0,0 @@ -describe('renderers/webgl/utils/WebGLSpriteBatch', function () { - 'use strict'; - - var expect = chai.expect; - var WebGLSpriteBatch = PIXI.WebGLSpriteBatch; - - it('Module exists', function () { - expect(WebGLSpriteBatch).to.be.a('function'); - }); -}); diff --git a/test/unit/pixi/text/BitmapText.js b/test/unit/pixi/text/BitmapText.js deleted file mode 100644 index 9388e3d..0000000 --- a/test/unit/pixi/text/BitmapText.js +++ /dev/null @@ -1,10 +0,0 @@ -describe('pixi/text/BitmapText', function () { - 'use strict'; - - var expect = chai.expect; - var BitmapText = PIXI.BitmapText; - - it('Module exists', function () { - expect(BitmapText).to.be.a('function'); - }); -}); diff --git a/test/unit/pixi/text/Text.js b/test/unit/pixi/text/Text.js deleted file mode 100644 index 9bc9ac5..0000000 --- a/test/unit/pixi/text/Text.js +++ /dev/null @@ -1,10 +0,0 @@ -describe('pixi/text/Text', function () { - 'use strict'; - - var expect = chai.expect; - var Text = PIXI.Text; - - it('Module exists', function () { - expect(Text).to.be.a('function'); - }); -}); diff --git a/test/unit/pixi/textures/BaseTexture.js b/test/unit/pixi/textures/BaseTexture.js deleted file mode 100644 index 502b724..0000000 --- a/test/unit/pixi/textures/BaseTexture.js +++ /dev/null @@ -1,11 +0,0 @@ -describe('pixi/textures/BaseTexture', function () { - 'use strict'; - - var expect = chai.expect; - var BaseTexture = PIXI.BaseTexture; - - it('Module exists', function () { - expect(BaseTexture).to.be.a('function'); - expect(PIXI).to.have.property('BaseTextureCache').and.to.be.an('object'); - }); -}); diff --git a/test/unit/pixi/textures/RenderTexture.js b/test/unit/pixi/textures/RenderTexture.js deleted file mode 100644 index 96acdb4..0000000 --- a/test/unit/pixi/textures/RenderTexture.js +++ /dev/null @@ -1,15 +0,0 @@ -describe('pixi/textures/RenderTexture', function () { - 'use strict'; - - var expect = chai.expect; - var RenderTexture = PIXI.RenderTexture; - - it('Module exists', function () { - expect(RenderTexture).to.be.a('function'); - }); - - it('Confirm new instance', function (done) { - var texture = new RenderTexture(100, 100, new PIXI.CanvasRenderer()); - pixi_textures_RenderTexture_confirmNew(texture, done); - }); -}); diff --git a/test/unit/pixi/textures/Texture.js b/test/unit/pixi/textures/Texture.js deleted file mode 100644 index 090f64d..0000000 --- a/test/unit/pixi/textures/Texture.js +++ /dev/null @@ -1,26 +0,0 @@ -describe('pixi/textures/Texture', function () { - 'use strict'; - - var expect = chai.expect; - var Texture = PIXI.Texture; - - it('Module exists', function () { - expect(Texture).to.be.a('function'); - expect(PIXI).to.have.property('TextureCache').and.to.be.an('object'); - }); - - it('Members exist', function () { - expect(Texture).itself.to.respondTo('fromImage'); - expect(Texture).itself.to.respondTo('fromFrame'); - expect(Texture).itself.to.respondTo('fromCanvas'); - expect(Texture).itself.to.respondTo('addTextureToCache'); - expect(Texture).itself.to.respondTo('removeTextureFromCache'); - - // expect(Texture).itself.to.have.deep.property('frameUpdates.length', 0); - }); - - it('Confirm new instance', function (done) { - var texture = Texture.fromImage('/base/test/textures/bunny.png'); - pixi_textures_Texture_confirmNew(texture, done); - }); -}); diff --git a/test/unit/pixi-v2/InteractionManager.js b/test/unit/pixi-v2/InteractionManager.js new file mode 100644 index 0000000..ed3001f --- /dev/null +++ b/test/unit/pixi-v2/InteractionManager.js @@ -0,0 +1,10 @@ +describe('pixi/InteractionManager', function () { + 'use strict'; + + var expect = chai.expect; + var InteractionManager = PIXI.InteractionManager; + + it('Module exists', function () { + expect(InteractionManager).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/Pixi.js b/test/unit/pixi-v2/Pixi.js new file mode 100644 index 0000000..27debc1 --- /dev/null +++ b/test/unit/pixi-v2/Pixi.js @@ -0,0 +1,9 @@ +describe('pixi/Pixi', function () { + 'use strict'; + + var expect = chai.expect; + + it('Module exists', function () { + expect(global).to.have.property('PIXI').and.to.be.an('object'); + }); +}); diff --git a/test/unit/pixi-v2/core/Circle.js b/test/unit/pixi-v2/core/Circle.js new file mode 100644 index 0000000..fbcfa17 --- /dev/null +++ b/test/unit/pixi-v2/core/Circle.js @@ -0,0 +1,21 @@ +describe('pixi/core/Circle', function () { + 'use strict'; + + var expect = chai.expect; + var Circle = PIXI.Circle; + + it('Module exists', function () { + expect(Circle).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Circle(); + pixi_core_Circle_confirmNewCircle(obj); + }); + + it("getBounds should return Rectangle that bounds the circle", function() { + var obj = new Circle(100, 250, 50); + var bounds = obj.getBounds(); + pixi_core_Circle_isBoundedByRectangle(obj, bounds); + }); +}); diff --git a/test/unit/pixi-v2/core/Ellipse.js b/test/unit/pixi-v2/core/Ellipse.js new file mode 100644 index 0000000..026b56f --- /dev/null +++ b/test/unit/pixi-v2/core/Ellipse.js @@ -0,0 +1,24 @@ +describe('pixi/core/Ellipse', function () { + 'use strict'; + + var expect = chai.expect; + var Ellipse = PIXI.Ellipse; + + it('Module exists', function () { + expect(Ellipse).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Ellipse(); + + expect(obj).to.be.an.instanceof(Ellipse); + expect(obj).to.respondTo('clone'); + expect(obj).to.respondTo('contains'); + expect(obj).to.respondTo('getBounds'); + + expect(obj).to.have.property('x', 0); + expect(obj).to.have.property('y', 0); + expect(obj).to.have.property('width', 0); + expect(obj).to.have.property('height', 0); + }); +}); diff --git a/test/unit/pixi-v2/core/Matrix.js b/test/unit/pixi-v2/core/Matrix.js new file mode 100644 index 0000000..da75e2e --- /dev/null +++ b/test/unit/pixi-v2/core/Matrix.js @@ -0,0 +1,14 @@ +describe('pixi/core/Matrix', function () { + 'use strict'; + + var expect = chai.expect; + + it('Matrix exists', function () { + expect(PIXI.Matrix).to.be.an('function'); + }); + + it('Confirm new Matrix', function () { + var matrix = new PIXI.Matrix(); + pixi_core_Matrix_confirmNewMatrix(matrix); + }); +}); diff --git a/test/unit/pixi-v2/core/Point.js b/test/unit/pixi-v2/core/Point.js new file mode 100644 index 0000000..c4d5163 --- /dev/null +++ b/test/unit/pixi-v2/core/Point.js @@ -0,0 +1,15 @@ +describe('pixi/core/Point', function () { + 'use strict'; + + var expect = chai.expect; + var Point = PIXI.Point; + + it('Module exists', function () { + expect(Point).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Point(); + pixi_core_Point_confirm(obj, 0, 0); + }); +}); diff --git a/test/unit/pixi-v2/core/Polygon.js b/test/unit/pixi-v2/core/Polygon.js new file mode 100644 index 0000000..dc8c918 --- /dev/null +++ b/test/unit/pixi-v2/core/Polygon.js @@ -0,0 +1,20 @@ +describe('pixi/core/Polygon', function () { + 'use strict'; + + var expect = chai.expect; + var Polygon = PIXI.Polygon; + + it('Module exists', function () { + expect(Polygon).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Polygon(); + + expect(obj).to.be.an.instanceof(Polygon); + expect(obj).to.respondTo('clone'); + expect(obj).to.respondTo('contains'); + + expect(obj).to.have.deep.property('points.length', 0); + }); +}); diff --git a/test/unit/pixi-v2/core/Rectangle.js b/test/unit/pixi-v2/core/Rectangle.js new file mode 100644 index 0000000..d43316e --- /dev/null +++ b/test/unit/pixi-v2/core/Rectangle.js @@ -0,0 +1,15 @@ +describe('pixi/core/Rectangle', function () { + 'use strict'; + + var expect = chai.expect; + var Rectangle = PIXI.Rectangle; + + it('Module exists', function () { + expect(Rectangle).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var rect = new Rectangle(); + pixi_core_Rectangle_confirm(rect, 0, 0, 0, 0); + }); +}); diff --git a/test/unit/pixi-v2/display/DisplayObject.js b/test/unit/pixi-v2/display/DisplayObject.js new file mode 100644 index 0000000..044acf8 --- /dev/null +++ b/test/unit/pixi-v2/display/DisplayObject.js @@ -0,0 +1,21 @@ +describe('pixi/display/DisplayObject', function () { + 'use strict'; + + var expect = chai.expect; + var DisplayObject = PIXI.DisplayObject; + + it('Module exists', function () { + expect(DisplayObject).to.be.a('function'); + // expect(PIXI).to.have.property('visibleCount', 0); + }); + + it('Confirm new instance', function () { + var obj = new DisplayObject(); + + pixi_display_DisplayObject_confirmNew(obj); + expect(obj).to.have.property('hitArea', null); + expect(obj).to.have.property('interactive', false); + expect(obj).to.have.property('renderable', false); + expect(obj).to.have.property('stage', null); + }); +}); diff --git a/test/unit/pixi-v2/display/DisplayObjectContainer.js b/test/unit/pixi-v2/display/DisplayObjectContainer.js new file mode 100644 index 0000000..15a3376 --- /dev/null +++ b/test/unit/pixi-v2/display/DisplayObjectContainer.js @@ -0,0 +1,67 @@ +describe('pixi/display/DisplayObjectContainer', function () { + 'use strict'; + + var expect = chai.expect; + var DisplayObjectContainer = PIXI.DisplayObjectContainer; + + it('Module exists', function () { + expect(DisplayObjectContainer).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new DisplayObjectContainer(); + + pixi_display_DisplayObjectContainer_confirmNew(obj); + expect(obj).to.have.property('hitArea', null); + expect(obj).to.have.property('interactive', false); + expect(obj).to.have.property('renderable', false); + expect(obj).to.have.property('stage', null); + }); + + it('Gets child index', function() { + var container = new PIXI.DisplayObjectContainer(); + var children = []; + for (var i = 0; i < 10; i++) { + var child = new PIXI.DisplayObject(); + children.push(child); + container.addChild(child); + } + + for (i = 0; i < children.length; i++) { + expect(i).to.eql(container.getChildIndex(children[i])); + } + }); + + it('throws error when trying to get index of not a child', function() { + var container = new PIXI.DisplayObjectContainer(); + var child = new PIXI.DisplayObject(); + + expect(function() { container.getChildIndex(child); }).to.throw(); + }); + + it('Sets child index', function() { + var container = new PIXI.DisplayObjectContainer(); + var children = []; + + for (var i = 0; i < 10; i++) { + var child = new PIXI.DisplayObject(); + children.push(child); + container.addChild(child); + } + children.reverse(); + + for (i = 0; i < children.length; i++) { + container.setChildIndex(children[i], i); + expect(i).to.eql(container.getChildIndex(children[i])); + } + }); + + it('throws error when trying to set incorect index', function() { + var container = new PIXI.DisplayObjectContainer(); + var child = new PIXI.DisplayObject(); + container.addChild(child); + + expect(function() { container.setChildIndex(child, -1); }).to.throw(); + expect(function() { container.setChildIndex(child, 1); }).to.throw(); + }); +}); diff --git a/test/unit/pixi-v2/display/MovieClip.js b/test/unit/pixi-v2/display/MovieClip.js new file mode 100644 index 0000000..f3c6c6a --- /dev/null +++ b/test/unit/pixi-v2/display/MovieClip.js @@ -0,0 +1,33 @@ +describe('pixi/display/MovieClip', function () { + 'use strict'; + + var expect = chai.expect; + var MovieClip = PIXI.MovieClip; + var Texture = PIXI.Texture; + + it('Module exists', function () { + expect(MovieClip).to.be.a('function'); + }); + + it('Confirm new instance', function (done) { + var texture = Texture.fromImage('/base/test/textures/SpriteSheet-Explosion.png'); + var obj = new MovieClip([texture]); + + pixi_display_Sprite_confirmNew(obj, done); + + expect(obj).to.be.an.instanceof(MovieClip); + expect(obj).to.respondTo('stop'); + expect(obj).to.respondTo('play'); + expect(obj).to.respondTo('gotoAndStop'); + expect(obj).to.respondTo('gotoAndPlay'); + expect(obj).to.respondTo('updateTransform'); + + expect(obj).to.have.deep.property('textures.length', 1); + expect(obj).to.have.deep.property('textures[0]', texture); + expect(obj).to.have.property('animationSpeed', 1); + expect(obj).to.have.property('loop', true); + expect(obj).to.have.property('onComplete', null); + expect(obj).to.have.property('currentFrame', 0); + expect(obj).to.have.property('playing', false); + }); +}); diff --git a/test/unit/pixi-v2/display/Sprite.js b/test/unit/pixi-v2/display/Sprite.js new file mode 100644 index 0000000..30c8076 --- /dev/null +++ b/test/unit/pixi-v2/display/Sprite.js @@ -0,0 +1,28 @@ +describe('pixi/display/Sprite', function () { + 'use strict'; + + var expect = chai.expect; + var Sprite = PIXI.Sprite; + var Texture = PIXI.Texture; + + it('Module exists', function () { + expect(Sprite).to.be.a('function'); + expect(PIXI).to.have.deep.property('blendModes.NORMAL', 0); + expect(PIXI).to.have.deep.property('blendModes.ADD', 1); + expect(PIXI).to.have.deep.property('blendModes.MULTIPLY', 2); + expect(PIXI).to.have.deep.property('blendModes.SCREEN', 3); + }); + + + it('Members exist', function () { + expect(Sprite).itself.to.respondTo('fromImage'); + expect(Sprite).itself.to.respondTo('fromFrame'); + }); + + it('Confirm new instance', function (done) { + var texture = Texture.fromImage('/base/test/textures/SpriteSheet-Aliens.png'); + var obj = new Sprite(texture); + + pixi_display_Sprite_confirmNew(obj, done); + }); +}); diff --git a/test/unit/pixi-v2/display/Stage.js b/test/unit/pixi-v2/display/Stage.js new file mode 100644 index 0000000..6974c2e --- /dev/null +++ b/test/unit/pixi-v2/display/Stage.js @@ -0,0 +1,49 @@ +describe('pixi/display/Stage', function () { + 'use strict'; + + var expect = chai.expect; + var Stage = PIXI.Stage; + var InteractionManager = PIXI.InteractionManager; + var Rectangle = PIXI.Rectangle; + + it('Module exists', function () { + expect(Stage).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Stage(null, true); + + pixi_display_DisplayObjectContainer_confirmNew(obj); + + expect(obj).to.be.an.instanceof(Stage); + expect(obj).to.respondTo('updateTransform'); + expect(obj).to.respondTo('setBackgroundColor'); + expect(obj).to.respondTo('getMousePosition'); + // FIXME: duplicate member in DisplayObject + pixi_core_Matrix_confirmNewMatrix(obj.worldTransform); + // FIXME: convert arg to bool in constructor + expect(obj).to.have.property('interactive', true); + + expect(obj).to.have.property('interactionManager') + .and.to.be.an.instanceof(InteractionManager) + .and.to.have.property('stage', obj); + + expect(obj).to.have.property('dirty', true); + + expect(obj).to.have.property('stage', obj); + + expect(obj).to.have.property('hitArea') + .and.to.be.an.instanceof(Rectangle); + pixi_core_Rectangle_confirm(obj.hitArea, 0, 0, 100000, 100000); + + expect(obj).to.have.property('backgroundColor', 0x000000); + expect(obj).to.have.deep.property('backgroundColorSplit.length', 3); + expect(obj).to.have.deep.property('backgroundColorSplit[0]', 0); + expect(obj).to.have.deep.property('backgroundColorSplit[1]', 0); + expect(obj).to.have.deep.property('backgroundColorSplit[2]', 0); + expect(obj).to.have.property('backgroundColorString', '#000000'); + + + expect(obj).to.have.property('worldVisible', true); + }); +}); diff --git a/test/unit/pixi-v2/extras/Rope.js b/test/unit/pixi-v2/extras/Rope.js new file mode 100644 index 0000000..05885ac --- /dev/null +++ b/test/unit/pixi-v2/extras/Rope.js @@ -0,0 +1,31 @@ +describe('pixi/extras/Rope', function () { + 'use strict'; + + var expect = chai.expect; + var Rope = PIXI.Rope; + var Texture = PIXI.Texture; + var Point = PIXI.Point; + + it('Module exists', function () { + expect(Rope).to.be.a('function'); + }); + + it('Confirm new instance', function () { + + var texture = Texture.fromImage('/base/test/textures/bunny.png'); + + // TODO-Alvin + // Same as Strip + + // var obj = new Rope(texture, [new Point(), new Point(5, 10), new Point(10, 20)]); + + // pixi_extras_Strip_confirmNew(obj); + + // expect(obj).to.be.an.instanceof(Rope); + // expect(obj).to.respondTo('refresh'); + // expect(obj).to.respondTo('updateTransform'); + // expect(obj).to.respondTo('setTexture'); + + // TODO: Test properties + }); +}); diff --git a/test/unit/pixi-v2/extras/Spine.js b/test/unit/pixi-v2/extras/Spine.js new file mode 100644 index 0000000..0708bc0 --- /dev/null +++ b/test/unit/pixi-v2/extras/Spine.js @@ -0,0 +1,10 @@ +describe('pixi/extras/Spine', function () { + 'use strict'; + + var expect = chai.expect; + var Spine = PIXI.Spine; + + it('Module exists', function () { + expect(Spine).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/extras/Strip.js b/test/unit/pixi-v2/extras/Strip.js new file mode 100644 index 0000000..230af90 --- /dev/null +++ b/test/unit/pixi-v2/extras/Strip.js @@ -0,0 +1,26 @@ +describe('pixi/extras/Strip', function () { + 'use strict'; + + var expect = chai.expect; + var Strip = PIXI.Strip; + var Texture = PIXI.Texture; + + it('Module exists', function () { + expect(Strip).to.be.a('function'); + }); + + it('Confirm new instance', function () { + + + // TODO-Alvin + // We tweaked it to make it pass the tests, but the whole strip class needs + // to be re-coded + + var texture = Texture.fromImage('/base/test/textures/bunny.png'); + + // var obj = new Strip(texture, 20, 10000); + + + // pixi_extras_Strip_confirmNew(obj); + }); +}); diff --git a/test/unit/pixi-v2/extras/TilingSprite.js b/test/unit/pixi-v2/extras/TilingSprite.js new file mode 100644 index 0000000..56aea14 --- /dev/null +++ b/test/unit/pixi-v2/extras/TilingSprite.js @@ -0,0 +1,24 @@ +describe('pixi/extras/TilingSprite', function () { + 'use strict'; + + var expect = chai.expect; + var TilingSprite = PIXI.TilingSprite; + var Texture = PIXI.Texture; + + it('Module exists', function () { + expect(TilingSprite).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var texture = Texture.fromImage('/base/test/textures/bunny.png'); + var obj = new TilingSprite(texture, 6000, 12000); + + pixi_display_DisplayObjectContainer_confirmNew(obj); + + expect(obj).to.be.an.instanceof(TilingSprite); + expect(obj).to.respondTo('setTexture'); + expect(obj).to.respondTo('onTextureUpdate'); + + // TODO: Test properties + }); +}); diff --git a/test/unit/pixi-v2/filters/FilterBlock.js b/test/unit/pixi-v2/filters/FilterBlock.js new file mode 100644 index 0000000..870cec0 --- /dev/null +++ b/test/unit/pixi-v2/filters/FilterBlock.js @@ -0,0 +1,10 @@ +describe('pixi/filters/FilterBlock', function () { + 'use strict'; + + var expect = chai.expect; + var FilterBlock = PIXI.FilterBlock; + + it('Module exists', function () { + expect(FilterBlock).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/AssetLoader.js b/test/unit/pixi-v2/loaders/AssetLoader.js new file mode 100644 index 0000000..a0aa0b5 --- /dev/null +++ b/test/unit/pixi-v2/loaders/AssetLoader.js @@ -0,0 +1,10 @@ +describe('pixi/loaders/AssetLoader', function () { + 'use strict'; + + var expect = chai.expect; + var AssetLoader = PIXI.AssetLoader; + + it('Module exists', function () { + expect(AssetLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/BitmapFontLoader.js b/test/unit/pixi-v2/loaders/BitmapFontLoader.js new file mode 100644 index 0000000..046f018 --- /dev/null +++ b/test/unit/pixi-v2/loaders/BitmapFontLoader.js @@ -0,0 +1,9 @@ +describe('pixi/loaders/BitmapFontLoader', function () { + 'use strict'; + + var expect = chai.expect; + + it('Module exists', function () { + expect(PIXI.BitmapFontLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/ImageLoader.js b/test/unit/pixi-v2/loaders/ImageLoader.js new file mode 100644 index 0000000..8b1f556 --- /dev/null +++ b/test/unit/pixi-v2/loaders/ImageLoader.js @@ -0,0 +1,10 @@ +describe('pixi/loaders/ImageLoader', function () { + 'use strict'; + + var expect = chai.expect; + var ImageLoader = PIXI.ImageLoader; + + it('Module exists', function () { + expect(ImageLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/JsonLoader.js b/test/unit/pixi-v2/loaders/JsonLoader.js new file mode 100644 index 0000000..c577e83 --- /dev/null +++ b/test/unit/pixi-v2/loaders/JsonLoader.js @@ -0,0 +1,10 @@ +describe('pixi/loaders/JsonLoader', function () { + 'use strict'; + + var expect = chai.expect; + var JsonLoader = PIXI.JsonLoader; + + it('Module exists', function () { + expect(JsonLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/SpineLoader.js b/test/unit/pixi-v2/loaders/SpineLoader.js new file mode 100644 index 0000000..fdcc0b8 --- /dev/null +++ b/test/unit/pixi-v2/loaders/SpineLoader.js @@ -0,0 +1,10 @@ +describe('pixi/loaders/SpineLoader', function () { + 'use strict'; + + var expect = chai.expect; + var SpineLoader = PIXI.SpineLoader; + + it('Module exists', function () { + expect(SpineLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/SpriteSheetLoader.js b/test/unit/pixi-v2/loaders/SpriteSheetLoader.js new file mode 100644 index 0000000..57beb27 --- /dev/null +++ b/test/unit/pixi-v2/loaders/SpriteSheetLoader.js @@ -0,0 +1,10 @@ +describe('pixi/loaders/SpriteSheetLoader', function () { + 'use strict'; + + var expect = chai.expect; + var SpriteSheetLoader = PIXI.SpriteSheetLoader; + + it('Module exists', function () { + expect(SpriteSheetLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/primitives/Graphics.js b/test/unit/pixi-v2/primitives/Graphics.js new file mode 100644 index 0000000..f3849eb --- /dev/null +++ b/test/unit/pixi-v2/primitives/Graphics.js @@ -0,0 +1,44 @@ +describe('pixi/primitives/Graphics', function () { + 'use strict'; + + var expect = chai.expect; + var Graphics = PIXI.Graphics; + + it('Module exists', function () { + expect(Graphics).to.be.a('function'); + + expect(Graphics).itself.to.have.property('POLY', 0); + expect(Graphics).itself.to.have.property('RECT', 1); + expect(Graphics).itself.to.have.property('CIRC', 2); + expect(Graphics).itself.to.have.property('ELIP', 3); + expect(Graphics).itself.to.have.property('RREC', 4); + }); + + it('Confirm new instance', function () { + var obj = new Graphics(); + + pixi_display_DisplayObjectContainer_confirmNew(obj); + + expect(obj).to.be.an.instanceof(Graphics); + expect(obj).to.respondTo('lineStyle'); + expect(obj).to.respondTo('lineStyle'); + expect(obj).to.respondTo('moveTo'); + expect(obj).to.respondTo('lineTo'); + expect(obj).to.respondTo('beginFill'); + expect(obj).to.respondTo('endFill'); + expect(obj).to.respondTo('drawRect'); + // expect(obj).to.respondTo('drawRoundedRect'); + expect(obj).to.respondTo('drawCircle'); + expect(obj).to.respondTo('drawEllipse'); + expect(obj).to.respondTo('clear'); + + expect(obj).to.have.property('renderable', true); + expect(obj).to.have.property('fillAlpha', 1); + expect(obj).to.have.property('lineWidth', 0); + expect(obj).to.have.property('width', 0); + expect(obj).to.have.property('height', 0); + expect(obj).to.have.property('lineColor', 0); + expect(obj).to.have.deep.property('graphicsData.length', 0); + // expect(obj).to.have.deep.property('currentPath.points.length', 0); + }); +}); diff --git a/test/unit/pixi-v2/renderers/canvas/CanvasGraphics.js b/test/unit/pixi-v2/renderers/canvas/CanvasGraphics.js new file mode 100644 index 0000000..8f44472 --- /dev/null +++ b/test/unit/pixi-v2/renderers/canvas/CanvasGraphics.js @@ -0,0 +1,15 @@ +describe('renders/canvas/CanvasGraphics', function () { + 'use strict'; + + var expect = chai.expect; + var CanvasGraphics = PIXI.CanvasGraphics; + + it('Module exists', function () { + expect(CanvasGraphics).to.be.a('function'); + }); + + it('Members exist', function () { + expect(CanvasGraphics).itself.to.respondTo('renderGraphics'); + expect(CanvasGraphics).itself.to.respondTo('renderGraphicsMask'); + }); +}); diff --git a/test/unit/pixi-v2/renderers/canvas/CanvasRenderer.js b/test/unit/pixi-v2/renderers/canvas/CanvasRenderer.js new file mode 100644 index 0000000..1646444 --- /dev/null +++ b/test/unit/pixi-v2/renderers/canvas/CanvasRenderer.js @@ -0,0 +1,36 @@ +describe('renderers/canvas/CanvasRenderer', function () { + 'use strict'; + + var expect = chai.expect; + var CanvasRenderer = PIXI.CanvasRenderer; + + it('Module exists', function () { + expect(CanvasRenderer).to.be.a('function'); + }); + + describe('.autoResize', function () { + it('Should automatically resize view if enabled', function () { + var renderer = new CanvasRenderer(200, 200, { + autoResize: true + }); + + expect(renderer.view.style.width).to.equal('200px'); + }); + + it('Should not automatically resize view if disabled', function () { + var renderer = new CanvasRenderer(200, 200, { + autoResize: false + }); + + expect(renderer.view.style.width).to.equal(''); + }); + + it('Should not automatically resize view if not specified', function () { + var renderer = new CanvasRenderer(200, 200, { + resolution: 2 + }); + + expect(renderer.view.style.width).to.equal(''); + }); + }); +}); diff --git a/test/unit/pixi-v2/renderers/webgl/WebGLGraphics.js b/test/unit/pixi-v2/renderers/webgl/WebGLGraphics.js new file mode 100644 index 0000000..5867b28 --- /dev/null +++ b/test/unit/pixi-v2/renderers/webgl/WebGLGraphics.js @@ -0,0 +1,20 @@ +describe('renderers/wegbl/WebGLGraphics', function () { + 'use strict'; + + var expect = chai.expect; + var WebGLGraphics = PIXI.WebGLGraphics; + + it('Module exists', function () { + expect(WebGLGraphics).to.be.a('function'); + }); + + it('Members exist', function () { + expect(WebGLGraphics).itself.to.respondTo('renderGraphics'); + expect(WebGLGraphics).itself.to.respondTo('updateGraphics'); + expect(WebGLGraphics).itself.to.respondTo('buildRectangle'); + expect(WebGLGraphics).itself.to.respondTo('buildRoundedRectangle'); + expect(WebGLGraphics).itself.to.respondTo('buildCircle'); + expect(WebGLGraphics).itself.to.respondTo('buildLine'); + expect(WebGLGraphics).itself.to.respondTo('buildPoly'); + }); +}); diff --git a/test/unit/pixi-v2/renderers/webgl/WebGLRenderer.js b/test/unit/pixi-v2/renderers/webgl/WebGLRenderer.js new file mode 100644 index 0000000..1680a80 --- /dev/null +++ b/test/unit/pixi-v2/renderers/webgl/WebGLRenderer.js @@ -0,0 +1,49 @@ +describe('renderers/webgl/WebGLRenderer', function () { + 'use strict'; + + var expect = chai.expect; + var WebGLRenderer = PIXI.WebGLRenderer; + + it('Module exists', function () { + expect(WebGLRenderer).to.be.a('function'); + }); + + // Skip tests if WebGL is not available (WebGL not supported in Travis CI) + try { + var renderer = new WebGLRenderer(400, 300, {}); + renderer.destroy(); + } catch (error) { + return; + } + + it('Destroy renderer', function () { + var renderer = new WebGLRenderer(400, 300, {}); + renderer.destroy(); + }); + + describe('.autoResize', function () { + it('Should automatically resize view if enabled', function () { + var renderer = new WebGLRenderer(200, 200, { + autoResize: true + }); + + expect(renderer.view.style.width).to.equal('200px'); + }); + + it('Should not automatically resize view if disabled', function () { + var renderer = new WebGLRenderer(200, 200, { + autoResize: false + }); + + expect(renderer.view.style.width).to.equal(''); + }); + + it('Should not automatically resize view if not specified', function () { + var renderer = new WebGLRenderer(200, 200, { + resolution: 2 + }); + + expect(renderer.view.style.width).to.equal(''); + }); + }); +}); diff --git a/test/unit/pixi-v2/renderers/webgl/WebGLShaders.js b/test/unit/pixi-v2/renderers/webgl/WebGLShaders.js new file mode 100644 index 0000000..6e33e4f --- /dev/null +++ b/test/unit/pixi-v2/renderers/webgl/WebGLShaders.js @@ -0,0 +1,13 @@ +describe('renderers/webgl/WebGLShaders', function () { + 'use strict'; + + var expect = chai.expect; + + it('Module members exist', function () { + + expect(PIXI).to.respondTo('CompileVertexShader'); + expect(PIXI).to.respondTo('CompileFragmentShader'); + expect(PIXI).to.respondTo('_CompileShader'); + expect(PIXI).to.respondTo('compileProgram'); + }); +}); diff --git a/test/unit/pixi-v2/renderers/webgl/WebGLSpriteBatch.js b/test/unit/pixi-v2/renderers/webgl/WebGLSpriteBatch.js new file mode 100644 index 0000000..e662b63 --- /dev/null +++ b/test/unit/pixi-v2/renderers/webgl/WebGLSpriteBatch.js @@ -0,0 +1,10 @@ +describe('renderers/webgl/utils/WebGLSpriteBatch', function () { + 'use strict'; + + var expect = chai.expect; + var WebGLSpriteBatch = PIXI.WebGLSpriteBatch; + + it('Module exists', function () { + expect(WebGLSpriteBatch).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/text/BitmapText.js b/test/unit/pixi-v2/text/BitmapText.js new file mode 100644 index 0000000..9388e3d --- /dev/null +++ b/test/unit/pixi-v2/text/BitmapText.js @@ -0,0 +1,10 @@ +describe('pixi/text/BitmapText', function () { + 'use strict'; + + var expect = chai.expect; + var BitmapText = PIXI.BitmapText; + + it('Module exists', function () { + expect(BitmapText).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/text/Text.js b/test/unit/pixi-v2/text/Text.js new file mode 100644 index 0000000..9bc9ac5 --- /dev/null +++ b/test/unit/pixi-v2/text/Text.js @@ -0,0 +1,10 @@ +describe('pixi/text/Text', function () { + 'use strict'; + + var expect = chai.expect; + var Text = PIXI.Text; + + it('Module exists', function () { + expect(Text).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/textures/BaseTexture.js b/test/unit/pixi-v2/textures/BaseTexture.js new file mode 100644 index 0000000..502b724 --- /dev/null +++ b/test/unit/pixi-v2/textures/BaseTexture.js @@ -0,0 +1,11 @@ +describe('pixi/textures/BaseTexture', function () { + 'use strict'; + + var expect = chai.expect; + var BaseTexture = PIXI.BaseTexture; + + it('Module exists', function () { + expect(BaseTexture).to.be.a('function'); + expect(PIXI).to.have.property('BaseTextureCache').and.to.be.an('object'); + }); +}); diff --git a/test/unit/pixi-v2/textures/RenderTexture.js b/test/unit/pixi-v2/textures/RenderTexture.js new file mode 100644 index 0000000..96acdb4 --- /dev/null +++ b/test/unit/pixi-v2/textures/RenderTexture.js @@ -0,0 +1,15 @@ +describe('pixi/textures/RenderTexture', function () { + 'use strict'; + + var expect = chai.expect; + var RenderTexture = PIXI.RenderTexture; + + it('Module exists', function () { + expect(RenderTexture).to.be.a('function'); + }); + + it('Confirm new instance', function (done) { + var texture = new RenderTexture(100, 100, new PIXI.CanvasRenderer()); + pixi_textures_RenderTexture_confirmNew(texture, done); + }); +}); diff --git a/test/unit/pixi-v2/textures/Texture.js b/test/unit/pixi-v2/textures/Texture.js new file mode 100644 index 0000000..090f64d --- /dev/null +++ b/test/unit/pixi-v2/textures/Texture.js @@ -0,0 +1,26 @@ +describe('pixi/textures/Texture', function () { + 'use strict'; + + var expect = chai.expect; + var Texture = PIXI.Texture; + + it('Module exists', function () { + expect(Texture).to.be.a('function'); + expect(PIXI).to.have.property('TextureCache').and.to.be.an('object'); + }); + + it('Members exist', function () { + expect(Texture).itself.to.respondTo('fromImage'); + expect(Texture).itself.to.respondTo('fromFrame'); + expect(Texture).itself.to.respondTo('fromCanvas'); + expect(Texture).itself.to.respondTo('addTextureToCache'); + expect(Texture).itself.to.respondTo('removeTextureFromCache'); + + // expect(Texture).itself.to.have.deep.property('frameUpdates.length', 0); + }); + + it('Confirm new instance', function (done) { + var texture = Texture.fromImage('/base/test/textures/bunny.png'); + pixi_textures_Texture_confirmNew(texture, done); + }); +}); diff --git a/test/unit/pixi-v2/utils/Detector.js b/test/unit/pixi-v2/utils/Detector.js new file mode 100644 index 0000000..4cf6008 --- /dev/null +++ b/test/unit/pixi-v2/utils/Detector.js @@ -0,0 +1,10 @@ +describe('pixi/utils/Detector', function () { + 'use strict'; + + var expect = chai.expect; + var autoDetectRenderer = PIXI.autoDetectRenderer; + + it('Module exists', function () { + expect(autoDetectRenderer).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/utils/EventTarget.js b/test/unit/pixi-v2/utils/EventTarget.js new file mode 100644 index 0000000..1cfc3a4 --- /dev/null +++ b/test/unit/pixi-v2/utils/EventTarget.js @@ -0,0 +1,361 @@ +describe('pixi/utils/EventTarget', function () { + 'use strict'; + + var expect = chai.expect; + + var Clazz, PClazz, obj, pobj, obj2; + beforeEach(function () { + Clazz = function () {}; + PClazz = function () {}; + + PIXI.EventTarget.mixin(Clazz.prototype); + PIXI.EventTarget.mixin(PClazz.prototype); + + obj = new Clazz(); + obj2 = new Clazz(); + pobj = new PClazz(); + + obj.parent = pobj; + obj2.parent = obj; + }); + + it('Module exists', function () { + expect(PIXI.EventTarget).to.be.an('object'); + }); + + it('Confirm new instance', function () { + pixi_utils_EventTarget_confirm(obj); + }); + + it('simple on/emit case works', function () { + var myData = {}; + + obj.on('myevent', function (event) { + pixi_utils_EventTarget_Event_confirm(event, obj, myData); + }); + + obj.emit('myevent', myData); + }); + + it('simple once case works', function () { + var called = 0; + + obj.once('myevent', function() { called++; }); + + obj.emit('myevent'); + obj.emit('myevent'); + obj.emit('myevent'); + obj.emit('myevent'); + obj.emit('myevent'); + + expect(called).to.equal(1); + }); + + it('simple off case works', function (done) { + function onMyEvent() { + done(new Error('Event listener should not have been called')); + } + + obj.on('myevent', onMyEvent); + obj.off('myevent', onMyEvent); + obj.emit('myevent'); + + done(); + }); + + it('simple propagation case works', function (done) { + var myData = {}; + + pobj.on('myevent', function () { + done(); + }); + + obj.emit('myevent'); + }); + + it('simple stopPropagation case works', function (done) { + var myData = {}; + + pobj.on('myevent', function () { + done(new Error('Event listener should not have been called on the parent element')); + }); + + obj.on('myevent', function (evt) { + evt.stopPropagation(); + }); + + obj.emit('myevent'); + + done(); + }); + + it('simple stopImmediatePropagation case works', function (done) { + var myData = {}; + + pobj.on('myevent', function () { + done(new Error('Event listener should not have been called on the parent')); + }); + + obj.on('myevent', function (evt) { + evt.stopImmediatePropagation(); + }); + + obj.on('myevent', function () { + done(new Error('Event listener should not have been called on the second')); + }); + + obj.emit('myevent'); + + done(); + }); + + it('multiple dispatches work properly', function () { + var called = 0; + + function onMyEvent() { + called++; + } + + obj.on('myevent', onMyEvent); + obj.emit('myevent'); + obj.emit('myevent'); + obj.emit('myevent'); + obj.emit('myevent'); + + expect(called).to.equal(4); + }); + + it('multiple events work properly', function () { + var called = 0; + + function onMyEvent() { + called++; + } + + obj.on('myevent1', onMyEvent); + obj.on('myevent2', onMyEvent); + obj.on('myevent3', onMyEvent); + obj.emit('myevent1'); + obj.emit('myevent2'); + obj.emit('myevent3'); + + expect(called).to.equal(3); + }); + + it('multiple events one removed works properly', function () { + var called = 0; + + function onMyEvent() { + called++; + } + + obj.on('myevent1', onMyEvent); + obj.on('myevent2', onMyEvent); + obj.on('myevent3', onMyEvent); + + obj.emit('myevent1'); + obj.emit('myevent2'); + obj.emit('myevent3'); + + obj.off('myevent2', onMyEvent); + + obj.emit('myevent1'); + obj.emit('myevent2'); + obj.emit('myevent3'); + + expect(called).to.equal(5); + }); + + it('multiple handlers for one event with some removed', function () { + var called = 0; + + var onMyEvent = function () { + called++; + }, + onMyEvent2 = function () { + called++; + }; + + // add 2 handlers and confirm they both get called + obj.on('myevent', onMyEvent); + obj.on('myevent', onMyEvent); + obj.on('myevent', onMyEvent2); + obj.on('myevent', onMyEvent2); + + obj.emit('myevent'); + + expect(called).to.equal(4); + + // remove one of the handlers, emit again, then ensure 1 more call is made + obj.off('myevent', onMyEvent); + + obj.emit('myevent'); + + expect(called).to.equal(6); + }); + + it('calls to off without a handler do nothing', function () { + var called = 0; + + var onMyEvent = function () { + called++; + }; + + obj.on('myevent', onMyEvent); + obj.on('myevent', onMyEvent); + + obj.emit('myevent'); + + expect(called).to.equal(2); + + obj.off('myevent'); + + obj.emit('myevent'); + + expect(called).to.equal(4); + + obj.off('myevent', onMyEvent); + + obj.emit('myevent'); + + expect(called).to.equal(4); + }); + + it('handles multiple instances with the same prototype', function () { + var called = 0; + + function onMyEvent(e) { + called++; + } + + obj.on('myevent1', onMyEvent); + obj.on('myevent2', onMyEvent); + + obj2.istwo = true; + obj2.on('myevent1', onMyEvent); + obj2.on('myevent2', onMyEvent); + + obj.emit('myevent1'); + obj.emit('myevent2'); + obj2.emit('myevent1'); + obj2.emit('myevent2'); + + //we emit 4 times, but since obj2 is a child of obj the event should bubble + //up to obj and show up there as well. So the obj2.emit() calls each increment + //the counter twice. + expect(called).to.equal(6); + }); + + it('is backwards compatible with older .dispatchEvent({})', function () { + var called = 0, + data = { + some: 'thing', + hello: true + }; + + function onMyEvent(event) { + pixi_utils_EventTarget_Event_confirm(event, obj, data); + + called++; + } + + obj.on('myevent1', onMyEvent); + obj.on('myevent2', onMyEvent); + obj.on('myevent3', onMyEvent); + + data.type = 'myevent1'; + obj.emit(data); + + data.type = 'myevent2'; + obj.emit(data); + + data.type = 'myevent3'; + obj.emit(data); + + obj.off('myevent2', onMyEvent); + + data.type = 'myevent1'; + obj.emit(data); + + data.type = 'myevent2'; + obj.emit(data); + + data.type = 'myevent3'; + obj.emit(data); + + expect(called).to.equal(5); + }); + + it('is backwards compatible with older .call(this)', function () { + var Fn = function() { + PIXI.EventTarget.call(this); + }, + o = new Fn(); + + pixi_utils_EventTarget_confirm(o); + }); + + it('is backwards compatible with older .addEventListener("")', function () { + var called = 0, + data = { + some: 'thing', + hello: true + }; + + function onMyEvent(event) { + pixi_utils_EventTarget_Event_confirm(event, obj, data); + + called++; + } + + obj.addEventListener('myevent1', onMyEvent); + obj.addEventListener('myevent2', onMyEvent); + obj.addEventListener('myevent3', onMyEvent); + + data.type = 'myevent1'; + obj.emit(data); + + data.type = 'myevent2'; + obj.emit(data); + + data.type = 'myevent3'; + obj.emit(data); + + obj.off('myevent2', onMyEvent); + + data.type = 'myevent1'; + obj.emit(data); + + data.type = 'myevent2'; + obj.emit(data); + + data.type = 'myevent3'; + obj.emit(data); + + expect(called).to.equal(5); + }); + + it('event remove during emit call properly', function () { + var called = 0; + + function cb1() { + called++; + obj.off('myevent', cb1); + } + function cb2() { + called++; + obj.off('myevent', cb2); + } + function cb3() { + called++; + obj.off('myevent', cb3); + } + + obj.on('myevent', cb1); + obj.on('myevent', cb2); + obj.on('myevent', cb3); + obj.emit('myevent', ''); + + expect(called).to.equal(3); + }); +}); diff --git a/test/unit/pixi-v2/utils/Polyk.js b/test/unit/pixi-v2/utils/Polyk.js new file mode 100644 index 0000000..dfc7128 --- /dev/null +++ b/test/unit/pixi-v2/utils/Polyk.js @@ -0,0 +1,14 @@ +describe('pixi/utils/Polyk', function () { + 'use strict'; + + var expect = chai.expect; + var PolyK = PIXI.PolyK; + + it('Module exists', function () { + expect(PolyK).to.be.an('object'); + }); + + it('Members exist', function () { + expect(PolyK).to.respondTo('Triangulate'); + }); +}); diff --git a/test/unit/pixi-v2/utils/Utils.js b/test/unit/pixi-v2/utils/Utils.js new file mode 100644 index 0000000..c97b3c6 --- /dev/null +++ b/test/unit/pixi-v2/utils/Utils.js @@ -0,0 +1,17 @@ +describe('Utils', function () { + 'use strict'; + + var expect = chai.expect; + + it('requestAnimationFrame exists', function () { + expect(global).to.respondTo('requestAnimationFrame'); + }); + + it('cancelAnimationFrame exists', function () { + expect(global).to.respondTo('cancelAnimationFrame'); + }); + + it('requestAnimFrame exists', function () { + expect(global).to.respondTo('requestAnimFrame'); + }); +}); diff --git a/test/unit/pixi/InteractionManager.js b/test/unit/pixi/InteractionManager.js deleted file mode 100644 index ed3001f..0000000 --- a/test/unit/pixi/InteractionManager.js +++ /dev/null @@ -1,10 +0,0 @@ -describe('pixi/InteractionManager', function () { - 'use strict'; - - var expect = chai.expect; - var InteractionManager = PIXI.InteractionManager; - - it('Module exists', function () { - expect(InteractionManager).to.be.a('function'); - }); -}); diff --git a/test/unit/pixi/Pixi.js b/test/unit/pixi/Pixi.js deleted file mode 100644 index 27debc1..0000000 --- a/test/unit/pixi/Pixi.js +++ /dev/null @@ -1,9 +0,0 @@ -describe('pixi/Pixi', function () { - 'use strict'; - - var expect = chai.expect; - - it('Module exists', function () { - expect(global).to.have.property('PIXI').and.to.be.an('object'); - }); -}); diff --git a/test/unit/pixi/core/Circle.js b/test/unit/pixi/core/Circle.js deleted file mode 100644 index fbcfa17..0000000 --- a/test/unit/pixi/core/Circle.js +++ /dev/null @@ -1,21 +0,0 @@ -describe('pixi/core/Circle', function () { - 'use strict'; - - var expect = chai.expect; - var Circle = PIXI.Circle; - - it('Module exists', function () { - expect(Circle).to.be.a('function'); - }); - - it('Confirm new instance', function () { - var obj = new Circle(); - pixi_core_Circle_confirmNewCircle(obj); - }); - - it("getBounds should return Rectangle that bounds the circle", function() { - var obj = new Circle(100, 250, 50); - var bounds = obj.getBounds(); - pixi_core_Circle_isBoundedByRectangle(obj, bounds); - }); -}); diff --git a/test/unit/pixi/core/Ellipse.js b/test/unit/pixi/core/Ellipse.js deleted file mode 100644 index 026b56f..0000000 --- a/test/unit/pixi/core/Ellipse.js +++ /dev/null @@ -1,24 +0,0 @@ -describe('pixi/core/Ellipse', function () { - 'use strict'; - - var expect = chai.expect; - var Ellipse = PIXI.Ellipse; - - it('Module exists', function () { - expect(Ellipse).to.be.a('function'); - }); - - it('Confirm new instance', function () { - var obj = new Ellipse(); - - expect(obj).to.be.an.instanceof(Ellipse); - expect(obj).to.respondTo('clone'); - expect(obj).to.respondTo('contains'); - expect(obj).to.respondTo('getBounds'); - - expect(obj).to.have.property('x', 0); - expect(obj).to.have.property('y', 0); - expect(obj).to.have.property('width', 0); - expect(obj).to.have.property('height', 0); - }); -}); diff --git a/test/unit/pixi/core/Matrix.js b/test/unit/pixi/core/Matrix.js deleted file mode 100644 index da75e2e..0000000 --- a/test/unit/pixi/core/Matrix.js +++ /dev/null @@ -1,14 +0,0 @@ -describe('pixi/core/Matrix', function () { - 'use strict'; - - var expect = chai.expect; - - it('Matrix exists', function () { - expect(PIXI.Matrix).to.be.an('function'); - }); - - it('Confirm new Matrix', function () { - var matrix = new PIXI.Matrix(); - pixi_core_Matrix_confirmNewMatrix(matrix); - }); -}); diff --git a/test/unit/pixi/core/Point.js b/test/unit/pixi/core/Point.js deleted file mode 100644 index c4d5163..0000000 --- a/test/unit/pixi/core/Point.js +++ /dev/null @@ -1,15 +0,0 @@ -describe('pixi/core/Point', function () { - 'use strict'; - - var expect = chai.expect; - var Point = PIXI.Point; - - it('Module exists', function () { - expect(Point).to.be.a('function'); - }); - - it('Confirm new instance', function () { - var obj = new Point(); - pixi_core_Point_confirm(obj, 0, 0); - }); -}); diff --git a/test/unit/pixi/core/Polygon.js b/test/unit/pixi/core/Polygon.js deleted file mode 100644 index dc8c918..0000000 --- a/test/unit/pixi/core/Polygon.js +++ /dev/null @@ -1,20 +0,0 @@ -describe('pixi/core/Polygon', function () { - 'use strict'; - - var expect = chai.expect; - var Polygon = PIXI.Polygon; - - it('Module exists', function () { - expect(Polygon).to.be.a('function'); - }); - - it('Confirm new instance', function () { - var obj = new Polygon(); - - expect(obj).to.be.an.instanceof(Polygon); - expect(obj).to.respondTo('clone'); - expect(obj).to.respondTo('contains'); - - expect(obj).to.have.deep.property('points.length', 0); - }); -}); diff --git a/test/unit/pixi/core/Rectangle.js b/test/unit/pixi/core/Rectangle.js deleted file mode 100644 index d43316e..0000000 --- a/test/unit/pixi/core/Rectangle.js +++ /dev/null @@ -1,15 +0,0 @@ -describe('pixi/core/Rectangle', function () { - 'use strict'; - - var expect = chai.expect; - var Rectangle = PIXI.Rectangle; - - it('Module exists', function () { - expect(Rectangle).to.be.a('function'); - }); - - it('Confirm new instance', function () { - var rect = new Rectangle(); - pixi_core_Rectangle_confirm(rect, 0, 0, 0, 0); - }); -}); diff --git a/test/unit/pixi/display/DisplayObject.js b/test/unit/pixi/display/DisplayObject.js deleted file mode 100644 index 044acf8..0000000 --- a/test/unit/pixi/display/DisplayObject.js +++ /dev/null @@ -1,21 +0,0 @@ -describe('pixi/display/DisplayObject', function () { - 'use strict'; - - var expect = chai.expect; - var DisplayObject = PIXI.DisplayObject; - - it('Module exists', function () { - expect(DisplayObject).to.be.a('function'); - // expect(PIXI).to.have.property('visibleCount', 0); - }); - - it('Confirm new instance', function () { - var obj = new DisplayObject(); - - pixi_display_DisplayObject_confirmNew(obj); - expect(obj).to.have.property('hitArea', null); - expect(obj).to.have.property('interactive', false); - expect(obj).to.have.property('renderable', false); - expect(obj).to.have.property('stage', null); - }); -}); diff --git a/test/unit/pixi/display/DisplayObjectContainer.js b/test/unit/pixi/display/DisplayObjectContainer.js deleted file mode 100644 index 15a3376..0000000 --- a/test/unit/pixi/display/DisplayObjectContainer.js +++ /dev/null @@ -1,67 +0,0 @@ -describe('pixi/display/DisplayObjectContainer', function () { - 'use strict'; - - var expect = chai.expect; - var DisplayObjectContainer = PIXI.DisplayObjectContainer; - - it('Module exists', function () { - expect(DisplayObjectContainer).to.be.a('function'); - }); - - it('Confirm new instance', function () { - var obj = new DisplayObjectContainer(); - - pixi_display_DisplayObjectContainer_confirmNew(obj); - expect(obj).to.have.property('hitArea', null); - expect(obj).to.have.property('interactive', false); - expect(obj).to.have.property('renderable', false); - expect(obj).to.have.property('stage', null); - }); - - it('Gets child index', function() { - var container = new PIXI.DisplayObjectContainer(); - var children = []; - for (var i = 0; i < 10; i++) { - var child = new PIXI.DisplayObject(); - children.push(child); - container.addChild(child); - } - - for (i = 0; i < children.length; i++) { - expect(i).to.eql(container.getChildIndex(children[i])); - } - }); - - it('throws error when trying to get index of not a child', function() { - var container = new PIXI.DisplayObjectContainer(); - var child = new PIXI.DisplayObject(); - - expect(function() { container.getChildIndex(child); }).to.throw(); - }); - - it('Sets child index', function() { - var container = new PIXI.DisplayObjectContainer(); - var children = []; - - for (var i = 0; i < 10; i++) { - var child = new PIXI.DisplayObject(); - children.push(child); - container.addChild(child); - } - children.reverse(); - - for (i = 0; i < children.length; i++) { - container.setChildIndex(children[i], i); - expect(i).to.eql(container.getChildIndex(children[i])); - } - }); - - it('throws error when trying to set incorect index', function() { - var container = new PIXI.DisplayObjectContainer(); - var child = new PIXI.DisplayObject(); - container.addChild(child); - - expect(function() { container.setChildIndex(child, -1); }).to.throw(); - expect(function() { container.setChildIndex(child, 1); }).to.throw(); - }); -}); diff --git a/test/unit/pixi/display/MovieClip.js b/test/unit/pixi/display/MovieClip.js deleted file mode 100644 index f3c6c6a..0000000 --- a/test/unit/pixi/display/MovieClip.js +++ /dev/null @@ -1,33 +0,0 @@ -describe('pixi/display/MovieClip', function () { - 'use strict'; - - var expect = chai.expect; - var MovieClip = PIXI.MovieClip; - var Texture = PIXI.Texture; - - it('Module exists', function () { - expect(MovieClip).to.be.a('function'); - }); - - it('Confirm new instance', function (done) { - var texture = Texture.fromImage('/base/test/textures/SpriteSheet-Explosion.png'); - var obj = new MovieClip([texture]); - - pixi_display_Sprite_confirmNew(obj, done); - - expect(obj).to.be.an.instanceof(MovieClip); - expect(obj).to.respondTo('stop'); - expect(obj).to.respondTo('play'); - expect(obj).to.respondTo('gotoAndStop'); - expect(obj).to.respondTo('gotoAndPlay'); - expect(obj).to.respondTo('updateTransform'); - - expect(obj).to.have.deep.property('textures.length', 1); - expect(obj).to.have.deep.property('textures[0]', texture); - expect(obj).to.have.property('animationSpeed', 1); - expect(obj).to.have.property('loop', true); - expect(obj).to.have.property('onComplete', null); - expect(obj).to.have.property('currentFrame', 0); - expect(obj).to.have.property('playing', false); - }); -}); diff --git a/test/unit/pixi/display/Sprite.js b/test/unit/pixi/display/Sprite.js deleted file mode 100644 index 30c8076..0000000 --- a/test/unit/pixi/display/Sprite.js +++ /dev/null @@ -1,28 +0,0 @@ -describe('pixi/display/Sprite', function () { - 'use strict'; - - var expect = chai.expect; - var Sprite = PIXI.Sprite; - var Texture = PIXI.Texture; - - it('Module exists', function () { - expect(Sprite).to.be.a('function'); - expect(PIXI).to.have.deep.property('blendModes.NORMAL', 0); - expect(PIXI).to.have.deep.property('blendModes.ADD', 1); - expect(PIXI).to.have.deep.property('blendModes.MULTIPLY', 2); - expect(PIXI).to.have.deep.property('blendModes.SCREEN', 3); - }); - - - it('Members exist', function () { - expect(Sprite).itself.to.respondTo('fromImage'); - expect(Sprite).itself.to.respondTo('fromFrame'); - }); - - it('Confirm new instance', function (done) { - var texture = Texture.fromImage('/base/test/textures/SpriteSheet-Aliens.png'); - var obj = new Sprite(texture); - - pixi_display_Sprite_confirmNew(obj, done); - }); -}); diff --git a/test/unit/pixi/display/Stage.js b/test/unit/pixi/display/Stage.js deleted file mode 100644 index 6974c2e..0000000 --- a/test/unit/pixi/display/Stage.js +++ /dev/null @@ -1,49 +0,0 @@ -describe('pixi/display/Stage', function () { - 'use strict'; - - var expect = chai.expect; - var Stage = PIXI.Stage; - var InteractionManager = PIXI.InteractionManager; - var Rectangle = PIXI.Rectangle; - - it('Module exists', function () { - expect(Stage).to.be.a('function'); - }); - - it('Confirm new instance', function () { - var obj = new Stage(null, true); - - pixi_display_DisplayObjectContainer_confirmNew(obj); - - expect(obj).to.be.an.instanceof(Stage); - expect(obj).to.respondTo('updateTransform'); - expect(obj).to.respondTo('setBackgroundColor'); - expect(obj).to.respondTo('getMousePosition'); - // FIXME: duplicate member in DisplayObject - pixi_core_Matrix_confirmNewMatrix(obj.worldTransform); - // FIXME: convert arg to bool in constructor - expect(obj).to.have.property('interactive', true); - - expect(obj).to.have.property('interactionManager') - .and.to.be.an.instanceof(InteractionManager) - .and.to.have.property('stage', obj); - - expect(obj).to.have.property('dirty', true); - - expect(obj).to.have.property('stage', obj); - - expect(obj).to.have.property('hitArea') - .and.to.be.an.instanceof(Rectangle); - pixi_core_Rectangle_confirm(obj.hitArea, 0, 0, 100000, 100000); - - expect(obj).to.have.property('backgroundColor', 0x000000); - expect(obj).to.have.deep.property('backgroundColorSplit.length', 3); - expect(obj).to.have.deep.property('backgroundColorSplit[0]', 0); - expect(obj).to.have.deep.property('backgroundColorSplit[1]', 0); - expect(obj).to.have.deep.property('backgroundColorSplit[2]', 0); - expect(obj).to.have.property('backgroundColorString', '#000000'); - - - expect(obj).to.have.property('worldVisible', true); - }); -}); diff --git a/test/unit/pixi/extras/Rope.js b/test/unit/pixi/extras/Rope.js deleted file mode 100644 index 05885ac..0000000 --- a/test/unit/pixi/extras/Rope.js +++ /dev/null @@ -1,31 +0,0 @@ -describe('pixi/extras/Rope', function () { - 'use strict'; - - var expect = chai.expect; - var Rope = PIXI.Rope; - var Texture = PIXI.Texture; - var Point = PIXI.Point; - - it('Module exists', function () { - expect(Rope).to.be.a('function'); - }); - - it('Confirm new instance', function () { - - var texture = Texture.fromImage('/base/test/textures/bunny.png'); - - // TODO-Alvin - // Same as Strip - - // var obj = new Rope(texture, [new Point(), new Point(5, 10), new Point(10, 20)]); - - // pixi_extras_Strip_confirmNew(obj); - - // expect(obj).to.be.an.instanceof(Rope); - // expect(obj).to.respondTo('refresh'); - // expect(obj).to.respondTo('updateTransform'); - // expect(obj).to.respondTo('setTexture'); - - // TODO: Test properties - }); -}); diff --git a/test/unit/pixi/extras/Spine.js b/test/unit/pixi/extras/Spine.js deleted file mode 100644 index 0708bc0..0000000 --- a/test/unit/pixi/extras/Spine.js +++ /dev/null @@ -1,10 +0,0 @@ -describe('pixi/extras/Spine', function () { - 'use strict'; - - var expect = chai.expect; - var Spine = PIXI.Spine; - - it('Module exists', function () { - expect(Spine).to.be.a('function'); - }); -}); diff --git a/test/unit/pixi/extras/Strip.js b/test/unit/pixi/extras/Strip.js deleted file mode 100644 index 230af90..0000000 --- a/test/unit/pixi/extras/Strip.js +++ /dev/null @@ -1,26 +0,0 @@ -describe('pixi/extras/Strip', function () { - 'use strict'; - - var expect = chai.expect; - var Strip = PIXI.Strip; - var Texture = PIXI.Texture; - - it('Module exists', function () { - expect(Strip).to.be.a('function'); - }); - - it('Confirm new instance', function () { - - - // TODO-Alvin - // We tweaked it to make it pass the tests, but the whole strip class needs - // to be re-coded - - var texture = Texture.fromImage('/base/test/textures/bunny.png'); - - // var obj = new Strip(texture, 20, 10000); - - - // pixi_extras_Strip_confirmNew(obj); - }); -}); diff --git a/test/unit/pixi/extras/TilingSprite.js b/test/unit/pixi/extras/TilingSprite.js deleted file mode 100644 index 56aea14..0000000 --- a/test/unit/pixi/extras/TilingSprite.js +++ /dev/null @@ -1,24 +0,0 @@ -describe('pixi/extras/TilingSprite', function () { - 'use strict'; - - var expect = chai.expect; - var TilingSprite = PIXI.TilingSprite; - var Texture = PIXI.Texture; - - it('Module exists', function () { - expect(TilingSprite).to.be.a('function'); - }); - - it('Confirm new instance', function () { - var texture = Texture.fromImage('/base/test/textures/bunny.png'); - var obj = new TilingSprite(texture, 6000, 12000); - - pixi_display_DisplayObjectContainer_confirmNew(obj); - - expect(obj).to.be.an.instanceof(TilingSprite); - expect(obj).to.respondTo('setTexture'); - expect(obj).to.respondTo('onTextureUpdate'); - - // TODO: Test properties - }); -}); diff --git a/test/unit/pixi/filters/FilterBlock.js b/test/unit/pixi/filters/FilterBlock.js deleted file mode 100644 index 870cec0..0000000 --- a/test/unit/pixi/filters/FilterBlock.js +++ /dev/null @@ -1,10 +0,0 @@ -describe('pixi/filters/FilterBlock', function () { - 'use strict'; - - var expect = chai.expect; - var FilterBlock = PIXI.FilterBlock; - - it('Module exists', function () { - expect(FilterBlock).to.be.a('function'); - }); -}); diff --git a/test/unit/pixi/loaders/AssetLoader.js b/test/unit/pixi/loaders/AssetLoader.js deleted file mode 100644 index a0aa0b5..0000000 --- a/test/unit/pixi/loaders/AssetLoader.js +++ /dev/null @@ -1,10 +0,0 @@ -describe('pixi/loaders/AssetLoader', function () { - 'use strict'; - - var expect = chai.expect; - var AssetLoader = PIXI.AssetLoader; - - it('Module exists', function () { - expect(AssetLoader).to.be.a('function'); - }); -}); diff --git a/test/unit/pixi/loaders/BitmapFontLoader.js b/test/unit/pixi/loaders/BitmapFontLoader.js deleted file mode 100644 index 046f018..0000000 --- a/test/unit/pixi/loaders/BitmapFontLoader.js +++ /dev/null @@ -1,9 +0,0 @@ -describe('pixi/loaders/BitmapFontLoader', function () { - 'use strict'; - - var expect = chai.expect; - - it('Module exists', function () { - expect(PIXI.BitmapFontLoader).to.be.a('function'); - }); -}); diff --git a/test/unit/pixi/loaders/ImageLoader.js b/test/unit/pixi/loaders/ImageLoader.js deleted file mode 100644 index 8b1f556..0000000 --- a/test/unit/pixi/loaders/ImageLoader.js +++ /dev/null @@ -1,10 +0,0 @@ -describe('pixi/loaders/ImageLoader', function () { - 'use strict'; - - var expect = chai.expect; - var ImageLoader = PIXI.ImageLoader; - - it('Module exists', function () { - expect(ImageLoader).to.be.a('function'); - }); -}); diff --git a/test/unit/pixi/loaders/JsonLoader.js b/test/unit/pixi/loaders/JsonLoader.js deleted file mode 100644 index c577e83..0000000 --- a/test/unit/pixi/loaders/JsonLoader.js +++ /dev/null @@ -1,10 +0,0 @@ -describe('pixi/loaders/JsonLoader', function () { - 'use strict'; - - var expect = chai.expect; - var JsonLoader = PIXI.JsonLoader; - - it('Module exists', function () { - expect(JsonLoader).to.be.a('function'); - }); -}); diff --git a/test/unit/pixi/loaders/SpineLoader.js b/test/unit/pixi/loaders/SpineLoader.js deleted file mode 100644 index fdcc0b8..0000000 --- a/test/unit/pixi/loaders/SpineLoader.js +++ /dev/null @@ -1,10 +0,0 @@ -describe('pixi/loaders/SpineLoader', function () { - 'use strict'; - - var expect = chai.expect; - var SpineLoader = PIXI.SpineLoader; - - it('Module exists', function () { - expect(SpineLoader).to.be.a('function'); - }); -}); diff --git a/test/unit/pixi/loaders/SpriteSheetLoader.js b/test/unit/pixi/loaders/SpriteSheetLoader.js deleted file mode 100644 index 57beb27..0000000 --- a/test/unit/pixi/loaders/SpriteSheetLoader.js +++ /dev/null @@ -1,10 +0,0 @@ -describe('pixi/loaders/SpriteSheetLoader', function () { - 'use strict'; - - var expect = chai.expect; - var SpriteSheetLoader = PIXI.SpriteSheetLoader; - - it('Module exists', function () { - expect(SpriteSheetLoader).to.be.a('function'); - }); -}); diff --git a/test/unit/pixi/primitives/Graphics.js b/test/unit/pixi/primitives/Graphics.js deleted file mode 100644 index f3849eb..0000000 --- a/test/unit/pixi/primitives/Graphics.js +++ /dev/null @@ -1,44 +0,0 @@ -describe('pixi/primitives/Graphics', function () { - 'use strict'; - - var expect = chai.expect; - var Graphics = PIXI.Graphics; - - it('Module exists', function () { - expect(Graphics).to.be.a('function'); - - expect(Graphics).itself.to.have.property('POLY', 0); - expect(Graphics).itself.to.have.property('RECT', 1); - expect(Graphics).itself.to.have.property('CIRC', 2); - expect(Graphics).itself.to.have.property('ELIP', 3); - expect(Graphics).itself.to.have.property('RREC', 4); - }); - - it('Confirm new instance', function () { - var obj = new Graphics(); - - pixi_display_DisplayObjectContainer_confirmNew(obj); - - expect(obj).to.be.an.instanceof(Graphics); - expect(obj).to.respondTo('lineStyle'); - expect(obj).to.respondTo('lineStyle'); - expect(obj).to.respondTo('moveTo'); - expect(obj).to.respondTo('lineTo'); - expect(obj).to.respondTo('beginFill'); - expect(obj).to.respondTo('endFill'); - expect(obj).to.respondTo('drawRect'); - // expect(obj).to.respondTo('drawRoundedRect'); - expect(obj).to.respondTo('drawCircle'); - expect(obj).to.respondTo('drawEllipse'); - expect(obj).to.respondTo('clear'); - - expect(obj).to.have.property('renderable', true); - expect(obj).to.have.property('fillAlpha', 1); - expect(obj).to.have.property('lineWidth', 0); - expect(obj).to.have.property('width', 0); - expect(obj).to.have.property('height', 0); - expect(obj).to.have.property('lineColor', 0); - expect(obj).to.have.deep.property('graphicsData.length', 0); - // expect(obj).to.have.deep.property('currentPath.points.length', 0); - }); -}); diff --git a/test/unit/pixi/renderers/canvas/CanvasGraphics.js b/test/unit/pixi/renderers/canvas/CanvasGraphics.js deleted file mode 100644 index 8f44472..0000000 --- a/test/unit/pixi/renderers/canvas/CanvasGraphics.js +++ /dev/null @@ -1,15 +0,0 @@ -describe('renders/canvas/CanvasGraphics', function () { - 'use strict'; - - var expect = chai.expect; - var CanvasGraphics = PIXI.CanvasGraphics; - - it('Module exists', function () { - expect(CanvasGraphics).to.be.a('function'); - }); - - it('Members exist', function () { - expect(CanvasGraphics).itself.to.respondTo('renderGraphics'); - expect(CanvasGraphics).itself.to.respondTo('renderGraphicsMask'); - }); -}); diff --git a/test/unit/pixi/renderers/canvas/CanvasRenderer.js b/test/unit/pixi/renderers/canvas/CanvasRenderer.js deleted file mode 100644 index 1646444..0000000 --- a/test/unit/pixi/renderers/canvas/CanvasRenderer.js +++ /dev/null @@ -1,36 +0,0 @@ -describe('renderers/canvas/CanvasRenderer', function () { - 'use strict'; - - var expect = chai.expect; - var CanvasRenderer = PIXI.CanvasRenderer; - - it('Module exists', function () { - expect(CanvasRenderer).to.be.a('function'); - }); - - describe('.autoResize', function () { - it('Should automatically resize view if enabled', function () { - var renderer = new CanvasRenderer(200, 200, { - autoResize: true - }); - - expect(renderer.view.style.width).to.equal('200px'); - }); - - it('Should not automatically resize view if disabled', function () { - var renderer = new CanvasRenderer(200, 200, { - autoResize: false - }); - - expect(renderer.view.style.width).to.equal(''); - }); - - it('Should not automatically resize view if not specified', function () { - var renderer = new CanvasRenderer(200, 200, { - resolution: 2 - }); - - expect(renderer.view.style.width).to.equal(''); - }); - }); -}); diff --git a/test/unit/pixi/renderers/webgl/WebGLGraphics.js b/test/unit/pixi/renderers/webgl/WebGLGraphics.js deleted file mode 100644 index 5867b28..0000000 --- a/test/unit/pixi/renderers/webgl/WebGLGraphics.js +++ /dev/null @@ -1,20 +0,0 @@ -describe('renderers/wegbl/WebGLGraphics', function () { - 'use strict'; - - var expect = chai.expect; - var WebGLGraphics = PIXI.WebGLGraphics; - - it('Module exists', function () { - expect(WebGLGraphics).to.be.a('function'); - }); - - it('Members exist', function () { - expect(WebGLGraphics).itself.to.respondTo('renderGraphics'); - expect(WebGLGraphics).itself.to.respondTo('updateGraphics'); - expect(WebGLGraphics).itself.to.respondTo('buildRectangle'); - expect(WebGLGraphics).itself.to.respondTo('buildRoundedRectangle'); - expect(WebGLGraphics).itself.to.respondTo('buildCircle'); - expect(WebGLGraphics).itself.to.respondTo('buildLine'); - expect(WebGLGraphics).itself.to.respondTo('buildPoly'); - }); -}); diff --git a/test/unit/pixi/renderers/webgl/WebGLRenderer.js b/test/unit/pixi/renderers/webgl/WebGLRenderer.js deleted file mode 100644 index 1680a80..0000000 --- a/test/unit/pixi/renderers/webgl/WebGLRenderer.js +++ /dev/null @@ -1,49 +0,0 @@ -describe('renderers/webgl/WebGLRenderer', function () { - 'use strict'; - - var expect = chai.expect; - var WebGLRenderer = PIXI.WebGLRenderer; - - it('Module exists', function () { - expect(WebGLRenderer).to.be.a('function'); - }); - - // Skip tests if WebGL is not available (WebGL not supported in Travis CI) - try { - var renderer = new WebGLRenderer(400, 300, {}); - renderer.destroy(); - } catch (error) { - return; - } - - it('Destroy renderer', function () { - var renderer = new WebGLRenderer(400, 300, {}); - renderer.destroy(); - }); - - describe('.autoResize', function () { - it('Should automatically resize view if enabled', function () { - var renderer = new WebGLRenderer(200, 200, { - autoResize: true - }); - - expect(renderer.view.style.width).to.equal('200px'); - }); - - it('Should not automatically resize view if disabled', function () { - var renderer = new WebGLRenderer(200, 200, { - autoResize: false - }); - - expect(renderer.view.style.width).to.equal(''); - }); - - it('Should not automatically resize view if not specified', function () { - var renderer = new WebGLRenderer(200, 200, { - resolution: 2 - }); - - expect(renderer.view.style.width).to.equal(''); - }); - }); -}); diff --git a/test/unit/pixi/renderers/webgl/WebGLShaders.js b/test/unit/pixi/renderers/webgl/WebGLShaders.js deleted file mode 100644 index 6e33e4f..0000000 --- a/test/unit/pixi/renderers/webgl/WebGLShaders.js +++ /dev/null @@ -1,13 +0,0 @@ -describe('renderers/webgl/WebGLShaders', function () { - 'use strict'; - - var expect = chai.expect; - - it('Module members exist', function () { - - expect(PIXI).to.respondTo('CompileVertexShader'); - expect(PIXI).to.respondTo('CompileFragmentShader'); - expect(PIXI).to.respondTo('_CompileShader'); - expect(PIXI).to.respondTo('compileProgram'); - }); -}); diff --git a/test/unit/pixi/renderers/webgl/WebGLSpriteBatch.js b/test/unit/pixi/renderers/webgl/WebGLSpriteBatch.js deleted file mode 100644 index e662b63..0000000 --- a/test/unit/pixi/renderers/webgl/WebGLSpriteBatch.js +++ /dev/null @@ -1,10 +0,0 @@ -describe('renderers/webgl/utils/WebGLSpriteBatch', function () { - 'use strict'; - - var expect = chai.expect; - var WebGLSpriteBatch = PIXI.WebGLSpriteBatch; - - it('Module exists', function () { - expect(WebGLSpriteBatch).to.be.a('function'); - }); -}); diff --git a/test/unit/pixi/text/BitmapText.js b/test/unit/pixi/text/BitmapText.js deleted file mode 100644 index 9388e3d..0000000 --- a/test/unit/pixi/text/BitmapText.js +++ /dev/null @@ -1,10 +0,0 @@ -describe('pixi/text/BitmapText', function () { - 'use strict'; - - var expect = chai.expect; - var BitmapText = PIXI.BitmapText; - - it('Module exists', function () { - expect(BitmapText).to.be.a('function'); - }); -}); diff --git a/test/unit/pixi/text/Text.js b/test/unit/pixi/text/Text.js deleted file mode 100644 index 9bc9ac5..0000000 --- a/test/unit/pixi/text/Text.js +++ /dev/null @@ -1,10 +0,0 @@ -describe('pixi/text/Text', function () { - 'use strict'; - - var expect = chai.expect; - var Text = PIXI.Text; - - it('Module exists', function () { - expect(Text).to.be.a('function'); - }); -}); diff --git a/test/unit/pixi/textures/BaseTexture.js b/test/unit/pixi/textures/BaseTexture.js deleted file mode 100644 index 502b724..0000000 --- a/test/unit/pixi/textures/BaseTexture.js +++ /dev/null @@ -1,11 +0,0 @@ -describe('pixi/textures/BaseTexture', function () { - 'use strict'; - - var expect = chai.expect; - var BaseTexture = PIXI.BaseTexture; - - it('Module exists', function () { - expect(BaseTexture).to.be.a('function'); - expect(PIXI).to.have.property('BaseTextureCache').and.to.be.an('object'); - }); -}); diff --git a/test/unit/pixi/textures/RenderTexture.js b/test/unit/pixi/textures/RenderTexture.js deleted file mode 100644 index 96acdb4..0000000 --- a/test/unit/pixi/textures/RenderTexture.js +++ /dev/null @@ -1,15 +0,0 @@ -describe('pixi/textures/RenderTexture', function () { - 'use strict'; - - var expect = chai.expect; - var RenderTexture = PIXI.RenderTexture; - - it('Module exists', function () { - expect(RenderTexture).to.be.a('function'); - }); - - it('Confirm new instance', function (done) { - var texture = new RenderTexture(100, 100, new PIXI.CanvasRenderer()); - pixi_textures_RenderTexture_confirmNew(texture, done); - }); -}); diff --git a/test/unit/pixi/textures/Texture.js b/test/unit/pixi/textures/Texture.js deleted file mode 100644 index 090f64d..0000000 --- a/test/unit/pixi/textures/Texture.js +++ /dev/null @@ -1,26 +0,0 @@ -describe('pixi/textures/Texture', function () { - 'use strict'; - - var expect = chai.expect; - var Texture = PIXI.Texture; - - it('Module exists', function () { - expect(Texture).to.be.a('function'); - expect(PIXI).to.have.property('TextureCache').and.to.be.an('object'); - }); - - it('Members exist', function () { - expect(Texture).itself.to.respondTo('fromImage'); - expect(Texture).itself.to.respondTo('fromFrame'); - expect(Texture).itself.to.respondTo('fromCanvas'); - expect(Texture).itself.to.respondTo('addTextureToCache'); - expect(Texture).itself.to.respondTo('removeTextureFromCache'); - - // expect(Texture).itself.to.have.deep.property('frameUpdates.length', 0); - }); - - it('Confirm new instance', function (done) { - var texture = Texture.fromImage('/base/test/textures/bunny.png'); - pixi_textures_Texture_confirmNew(texture, done); - }); -}); diff --git a/test/unit/pixi/utils/Detector.js b/test/unit/pixi/utils/Detector.js deleted file mode 100644 index 4cf6008..0000000 --- a/test/unit/pixi/utils/Detector.js +++ /dev/null @@ -1,10 +0,0 @@ -describe('pixi/utils/Detector', function () { - 'use strict'; - - var expect = chai.expect; - var autoDetectRenderer = PIXI.autoDetectRenderer; - - it('Module exists', function () { - expect(autoDetectRenderer).to.be.a('function'); - }); -}); diff --git a/test/unit/pixi-v2/InteractionManager.js b/test/unit/pixi-v2/InteractionManager.js new file mode 100644 index 0000000..ed3001f --- /dev/null +++ b/test/unit/pixi-v2/InteractionManager.js @@ -0,0 +1,10 @@ +describe('pixi/InteractionManager', function () { + 'use strict'; + + var expect = chai.expect; + var InteractionManager = PIXI.InteractionManager; + + it('Module exists', function () { + expect(InteractionManager).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/Pixi.js b/test/unit/pixi-v2/Pixi.js new file mode 100644 index 0000000..27debc1 --- /dev/null +++ b/test/unit/pixi-v2/Pixi.js @@ -0,0 +1,9 @@ +describe('pixi/Pixi', function () { + 'use strict'; + + var expect = chai.expect; + + it('Module exists', function () { + expect(global).to.have.property('PIXI').and.to.be.an('object'); + }); +}); diff --git a/test/unit/pixi-v2/core/Circle.js b/test/unit/pixi-v2/core/Circle.js new file mode 100644 index 0000000..fbcfa17 --- /dev/null +++ b/test/unit/pixi-v2/core/Circle.js @@ -0,0 +1,21 @@ +describe('pixi/core/Circle', function () { + 'use strict'; + + var expect = chai.expect; + var Circle = PIXI.Circle; + + it('Module exists', function () { + expect(Circle).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Circle(); + pixi_core_Circle_confirmNewCircle(obj); + }); + + it("getBounds should return Rectangle that bounds the circle", function() { + var obj = new Circle(100, 250, 50); + var bounds = obj.getBounds(); + pixi_core_Circle_isBoundedByRectangle(obj, bounds); + }); +}); diff --git a/test/unit/pixi-v2/core/Ellipse.js b/test/unit/pixi-v2/core/Ellipse.js new file mode 100644 index 0000000..026b56f --- /dev/null +++ b/test/unit/pixi-v2/core/Ellipse.js @@ -0,0 +1,24 @@ +describe('pixi/core/Ellipse', function () { + 'use strict'; + + var expect = chai.expect; + var Ellipse = PIXI.Ellipse; + + it('Module exists', function () { + expect(Ellipse).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Ellipse(); + + expect(obj).to.be.an.instanceof(Ellipse); + expect(obj).to.respondTo('clone'); + expect(obj).to.respondTo('contains'); + expect(obj).to.respondTo('getBounds'); + + expect(obj).to.have.property('x', 0); + expect(obj).to.have.property('y', 0); + expect(obj).to.have.property('width', 0); + expect(obj).to.have.property('height', 0); + }); +}); diff --git a/test/unit/pixi-v2/core/Matrix.js b/test/unit/pixi-v2/core/Matrix.js new file mode 100644 index 0000000..da75e2e --- /dev/null +++ b/test/unit/pixi-v2/core/Matrix.js @@ -0,0 +1,14 @@ +describe('pixi/core/Matrix', function () { + 'use strict'; + + var expect = chai.expect; + + it('Matrix exists', function () { + expect(PIXI.Matrix).to.be.an('function'); + }); + + it('Confirm new Matrix', function () { + var matrix = new PIXI.Matrix(); + pixi_core_Matrix_confirmNewMatrix(matrix); + }); +}); diff --git a/test/unit/pixi-v2/core/Point.js b/test/unit/pixi-v2/core/Point.js new file mode 100644 index 0000000..c4d5163 --- /dev/null +++ b/test/unit/pixi-v2/core/Point.js @@ -0,0 +1,15 @@ +describe('pixi/core/Point', function () { + 'use strict'; + + var expect = chai.expect; + var Point = PIXI.Point; + + it('Module exists', function () { + expect(Point).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Point(); + pixi_core_Point_confirm(obj, 0, 0); + }); +}); diff --git a/test/unit/pixi-v2/core/Polygon.js b/test/unit/pixi-v2/core/Polygon.js new file mode 100644 index 0000000..dc8c918 --- /dev/null +++ b/test/unit/pixi-v2/core/Polygon.js @@ -0,0 +1,20 @@ +describe('pixi/core/Polygon', function () { + 'use strict'; + + var expect = chai.expect; + var Polygon = PIXI.Polygon; + + it('Module exists', function () { + expect(Polygon).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Polygon(); + + expect(obj).to.be.an.instanceof(Polygon); + expect(obj).to.respondTo('clone'); + expect(obj).to.respondTo('contains'); + + expect(obj).to.have.deep.property('points.length', 0); + }); +}); diff --git a/test/unit/pixi-v2/core/Rectangle.js b/test/unit/pixi-v2/core/Rectangle.js new file mode 100644 index 0000000..d43316e --- /dev/null +++ b/test/unit/pixi-v2/core/Rectangle.js @@ -0,0 +1,15 @@ +describe('pixi/core/Rectangle', function () { + 'use strict'; + + var expect = chai.expect; + var Rectangle = PIXI.Rectangle; + + it('Module exists', function () { + expect(Rectangle).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var rect = new Rectangle(); + pixi_core_Rectangle_confirm(rect, 0, 0, 0, 0); + }); +}); diff --git a/test/unit/pixi-v2/display/DisplayObject.js b/test/unit/pixi-v2/display/DisplayObject.js new file mode 100644 index 0000000..044acf8 --- /dev/null +++ b/test/unit/pixi-v2/display/DisplayObject.js @@ -0,0 +1,21 @@ +describe('pixi/display/DisplayObject', function () { + 'use strict'; + + var expect = chai.expect; + var DisplayObject = PIXI.DisplayObject; + + it('Module exists', function () { + expect(DisplayObject).to.be.a('function'); + // expect(PIXI).to.have.property('visibleCount', 0); + }); + + it('Confirm new instance', function () { + var obj = new DisplayObject(); + + pixi_display_DisplayObject_confirmNew(obj); + expect(obj).to.have.property('hitArea', null); + expect(obj).to.have.property('interactive', false); + expect(obj).to.have.property('renderable', false); + expect(obj).to.have.property('stage', null); + }); +}); diff --git a/test/unit/pixi-v2/display/DisplayObjectContainer.js b/test/unit/pixi-v2/display/DisplayObjectContainer.js new file mode 100644 index 0000000..15a3376 --- /dev/null +++ b/test/unit/pixi-v2/display/DisplayObjectContainer.js @@ -0,0 +1,67 @@ +describe('pixi/display/DisplayObjectContainer', function () { + 'use strict'; + + var expect = chai.expect; + var DisplayObjectContainer = PIXI.DisplayObjectContainer; + + it('Module exists', function () { + expect(DisplayObjectContainer).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new DisplayObjectContainer(); + + pixi_display_DisplayObjectContainer_confirmNew(obj); + expect(obj).to.have.property('hitArea', null); + expect(obj).to.have.property('interactive', false); + expect(obj).to.have.property('renderable', false); + expect(obj).to.have.property('stage', null); + }); + + it('Gets child index', function() { + var container = new PIXI.DisplayObjectContainer(); + var children = []; + for (var i = 0; i < 10; i++) { + var child = new PIXI.DisplayObject(); + children.push(child); + container.addChild(child); + } + + for (i = 0; i < children.length; i++) { + expect(i).to.eql(container.getChildIndex(children[i])); + } + }); + + it('throws error when trying to get index of not a child', function() { + var container = new PIXI.DisplayObjectContainer(); + var child = new PIXI.DisplayObject(); + + expect(function() { container.getChildIndex(child); }).to.throw(); + }); + + it('Sets child index', function() { + var container = new PIXI.DisplayObjectContainer(); + var children = []; + + for (var i = 0; i < 10; i++) { + var child = new PIXI.DisplayObject(); + children.push(child); + container.addChild(child); + } + children.reverse(); + + for (i = 0; i < children.length; i++) { + container.setChildIndex(children[i], i); + expect(i).to.eql(container.getChildIndex(children[i])); + } + }); + + it('throws error when trying to set incorect index', function() { + var container = new PIXI.DisplayObjectContainer(); + var child = new PIXI.DisplayObject(); + container.addChild(child); + + expect(function() { container.setChildIndex(child, -1); }).to.throw(); + expect(function() { container.setChildIndex(child, 1); }).to.throw(); + }); +}); diff --git a/test/unit/pixi-v2/display/MovieClip.js b/test/unit/pixi-v2/display/MovieClip.js new file mode 100644 index 0000000..f3c6c6a --- /dev/null +++ b/test/unit/pixi-v2/display/MovieClip.js @@ -0,0 +1,33 @@ +describe('pixi/display/MovieClip', function () { + 'use strict'; + + var expect = chai.expect; + var MovieClip = PIXI.MovieClip; + var Texture = PIXI.Texture; + + it('Module exists', function () { + expect(MovieClip).to.be.a('function'); + }); + + it('Confirm new instance', function (done) { + var texture = Texture.fromImage('/base/test/textures/SpriteSheet-Explosion.png'); + var obj = new MovieClip([texture]); + + pixi_display_Sprite_confirmNew(obj, done); + + expect(obj).to.be.an.instanceof(MovieClip); + expect(obj).to.respondTo('stop'); + expect(obj).to.respondTo('play'); + expect(obj).to.respondTo('gotoAndStop'); + expect(obj).to.respondTo('gotoAndPlay'); + expect(obj).to.respondTo('updateTransform'); + + expect(obj).to.have.deep.property('textures.length', 1); + expect(obj).to.have.deep.property('textures[0]', texture); + expect(obj).to.have.property('animationSpeed', 1); + expect(obj).to.have.property('loop', true); + expect(obj).to.have.property('onComplete', null); + expect(obj).to.have.property('currentFrame', 0); + expect(obj).to.have.property('playing', false); + }); +}); diff --git a/test/unit/pixi-v2/display/Sprite.js b/test/unit/pixi-v2/display/Sprite.js new file mode 100644 index 0000000..30c8076 --- /dev/null +++ b/test/unit/pixi-v2/display/Sprite.js @@ -0,0 +1,28 @@ +describe('pixi/display/Sprite', function () { + 'use strict'; + + var expect = chai.expect; + var Sprite = PIXI.Sprite; + var Texture = PIXI.Texture; + + it('Module exists', function () { + expect(Sprite).to.be.a('function'); + expect(PIXI).to.have.deep.property('blendModes.NORMAL', 0); + expect(PIXI).to.have.deep.property('blendModes.ADD', 1); + expect(PIXI).to.have.deep.property('blendModes.MULTIPLY', 2); + expect(PIXI).to.have.deep.property('blendModes.SCREEN', 3); + }); + + + it('Members exist', function () { + expect(Sprite).itself.to.respondTo('fromImage'); + expect(Sprite).itself.to.respondTo('fromFrame'); + }); + + it('Confirm new instance', function (done) { + var texture = Texture.fromImage('/base/test/textures/SpriteSheet-Aliens.png'); + var obj = new Sprite(texture); + + pixi_display_Sprite_confirmNew(obj, done); + }); +}); diff --git a/test/unit/pixi-v2/display/Stage.js b/test/unit/pixi-v2/display/Stage.js new file mode 100644 index 0000000..6974c2e --- /dev/null +++ b/test/unit/pixi-v2/display/Stage.js @@ -0,0 +1,49 @@ +describe('pixi/display/Stage', function () { + 'use strict'; + + var expect = chai.expect; + var Stage = PIXI.Stage; + var InteractionManager = PIXI.InteractionManager; + var Rectangle = PIXI.Rectangle; + + it('Module exists', function () { + expect(Stage).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Stage(null, true); + + pixi_display_DisplayObjectContainer_confirmNew(obj); + + expect(obj).to.be.an.instanceof(Stage); + expect(obj).to.respondTo('updateTransform'); + expect(obj).to.respondTo('setBackgroundColor'); + expect(obj).to.respondTo('getMousePosition'); + // FIXME: duplicate member in DisplayObject + pixi_core_Matrix_confirmNewMatrix(obj.worldTransform); + // FIXME: convert arg to bool in constructor + expect(obj).to.have.property('interactive', true); + + expect(obj).to.have.property('interactionManager') + .and.to.be.an.instanceof(InteractionManager) + .and.to.have.property('stage', obj); + + expect(obj).to.have.property('dirty', true); + + expect(obj).to.have.property('stage', obj); + + expect(obj).to.have.property('hitArea') + .and.to.be.an.instanceof(Rectangle); + pixi_core_Rectangle_confirm(obj.hitArea, 0, 0, 100000, 100000); + + expect(obj).to.have.property('backgroundColor', 0x000000); + expect(obj).to.have.deep.property('backgroundColorSplit.length', 3); + expect(obj).to.have.deep.property('backgroundColorSplit[0]', 0); + expect(obj).to.have.deep.property('backgroundColorSplit[1]', 0); + expect(obj).to.have.deep.property('backgroundColorSplit[2]', 0); + expect(obj).to.have.property('backgroundColorString', '#000000'); + + + expect(obj).to.have.property('worldVisible', true); + }); +}); diff --git a/test/unit/pixi-v2/extras/Rope.js b/test/unit/pixi-v2/extras/Rope.js new file mode 100644 index 0000000..05885ac --- /dev/null +++ b/test/unit/pixi-v2/extras/Rope.js @@ -0,0 +1,31 @@ +describe('pixi/extras/Rope', function () { + 'use strict'; + + var expect = chai.expect; + var Rope = PIXI.Rope; + var Texture = PIXI.Texture; + var Point = PIXI.Point; + + it('Module exists', function () { + expect(Rope).to.be.a('function'); + }); + + it('Confirm new instance', function () { + + var texture = Texture.fromImage('/base/test/textures/bunny.png'); + + // TODO-Alvin + // Same as Strip + + // var obj = new Rope(texture, [new Point(), new Point(5, 10), new Point(10, 20)]); + + // pixi_extras_Strip_confirmNew(obj); + + // expect(obj).to.be.an.instanceof(Rope); + // expect(obj).to.respondTo('refresh'); + // expect(obj).to.respondTo('updateTransform'); + // expect(obj).to.respondTo('setTexture'); + + // TODO: Test properties + }); +}); diff --git a/test/unit/pixi-v2/extras/Spine.js b/test/unit/pixi-v2/extras/Spine.js new file mode 100644 index 0000000..0708bc0 --- /dev/null +++ b/test/unit/pixi-v2/extras/Spine.js @@ -0,0 +1,10 @@ +describe('pixi/extras/Spine', function () { + 'use strict'; + + var expect = chai.expect; + var Spine = PIXI.Spine; + + it('Module exists', function () { + expect(Spine).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/extras/Strip.js b/test/unit/pixi-v2/extras/Strip.js new file mode 100644 index 0000000..230af90 --- /dev/null +++ b/test/unit/pixi-v2/extras/Strip.js @@ -0,0 +1,26 @@ +describe('pixi/extras/Strip', function () { + 'use strict'; + + var expect = chai.expect; + var Strip = PIXI.Strip; + var Texture = PIXI.Texture; + + it('Module exists', function () { + expect(Strip).to.be.a('function'); + }); + + it('Confirm new instance', function () { + + + // TODO-Alvin + // We tweaked it to make it pass the tests, but the whole strip class needs + // to be re-coded + + var texture = Texture.fromImage('/base/test/textures/bunny.png'); + + // var obj = new Strip(texture, 20, 10000); + + + // pixi_extras_Strip_confirmNew(obj); + }); +}); diff --git a/test/unit/pixi-v2/extras/TilingSprite.js b/test/unit/pixi-v2/extras/TilingSprite.js new file mode 100644 index 0000000..56aea14 --- /dev/null +++ b/test/unit/pixi-v2/extras/TilingSprite.js @@ -0,0 +1,24 @@ +describe('pixi/extras/TilingSprite', function () { + 'use strict'; + + var expect = chai.expect; + var TilingSprite = PIXI.TilingSprite; + var Texture = PIXI.Texture; + + it('Module exists', function () { + expect(TilingSprite).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var texture = Texture.fromImage('/base/test/textures/bunny.png'); + var obj = new TilingSprite(texture, 6000, 12000); + + pixi_display_DisplayObjectContainer_confirmNew(obj); + + expect(obj).to.be.an.instanceof(TilingSprite); + expect(obj).to.respondTo('setTexture'); + expect(obj).to.respondTo('onTextureUpdate'); + + // TODO: Test properties + }); +}); diff --git a/test/unit/pixi-v2/filters/FilterBlock.js b/test/unit/pixi-v2/filters/FilterBlock.js new file mode 100644 index 0000000..870cec0 --- /dev/null +++ b/test/unit/pixi-v2/filters/FilterBlock.js @@ -0,0 +1,10 @@ +describe('pixi/filters/FilterBlock', function () { + 'use strict'; + + var expect = chai.expect; + var FilterBlock = PIXI.FilterBlock; + + it('Module exists', function () { + expect(FilterBlock).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/AssetLoader.js b/test/unit/pixi-v2/loaders/AssetLoader.js new file mode 100644 index 0000000..a0aa0b5 --- /dev/null +++ b/test/unit/pixi-v2/loaders/AssetLoader.js @@ -0,0 +1,10 @@ +describe('pixi/loaders/AssetLoader', function () { + 'use strict'; + + var expect = chai.expect; + var AssetLoader = PIXI.AssetLoader; + + it('Module exists', function () { + expect(AssetLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/BitmapFontLoader.js b/test/unit/pixi-v2/loaders/BitmapFontLoader.js new file mode 100644 index 0000000..046f018 --- /dev/null +++ b/test/unit/pixi-v2/loaders/BitmapFontLoader.js @@ -0,0 +1,9 @@ +describe('pixi/loaders/BitmapFontLoader', function () { + 'use strict'; + + var expect = chai.expect; + + it('Module exists', function () { + expect(PIXI.BitmapFontLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/ImageLoader.js b/test/unit/pixi-v2/loaders/ImageLoader.js new file mode 100644 index 0000000..8b1f556 --- /dev/null +++ b/test/unit/pixi-v2/loaders/ImageLoader.js @@ -0,0 +1,10 @@ +describe('pixi/loaders/ImageLoader', function () { + 'use strict'; + + var expect = chai.expect; + var ImageLoader = PIXI.ImageLoader; + + it('Module exists', function () { + expect(ImageLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/JsonLoader.js b/test/unit/pixi-v2/loaders/JsonLoader.js new file mode 100644 index 0000000..c577e83 --- /dev/null +++ b/test/unit/pixi-v2/loaders/JsonLoader.js @@ -0,0 +1,10 @@ +describe('pixi/loaders/JsonLoader', function () { + 'use strict'; + + var expect = chai.expect; + var JsonLoader = PIXI.JsonLoader; + + it('Module exists', function () { + expect(JsonLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/SpineLoader.js b/test/unit/pixi-v2/loaders/SpineLoader.js new file mode 100644 index 0000000..fdcc0b8 --- /dev/null +++ b/test/unit/pixi-v2/loaders/SpineLoader.js @@ -0,0 +1,10 @@ +describe('pixi/loaders/SpineLoader', function () { + 'use strict'; + + var expect = chai.expect; + var SpineLoader = PIXI.SpineLoader; + + it('Module exists', function () { + expect(SpineLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/SpriteSheetLoader.js b/test/unit/pixi-v2/loaders/SpriteSheetLoader.js new file mode 100644 index 0000000..57beb27 --- /dev/null +++ b/test/unit/pixi-v2/loaders/SpriteSheetLoader.js @@ -0,0 +1,10 @@ +describe('pixi/loaders/SpriteSheetLoader', function () { + 'use strict'; + + var expect = chai.expect; + var SpriteSheetLoader = PIXI.SpriteSheetLoader; + + it('Module exists', function () { + expect(SpriteSheetLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/primitives/Graphics.js b/test/unit/pixi-v2/primitives/Graphics.js new file mode 100644 index 0000000..f3849eb --- /dev/null +++ b/test/unit/pixi-v2/primitives/Graphics.js @@ -0,0 +1,44 @@ +describe('pixi/primitives/Graphics', function () { + 'use strict'; + + var expect = chai.expect; + var Graphics = PIXI.Graphics; + + it('Module exists', function () { + expect(Graphics).to.be.a('function'); + + expect(Graphics).itself.to.have.property('POLY', 0); + expect(Graphics).itself.to.have.property('RECT', 1); + expect(Graphics).itself.to.have.property('CIRC', 2); + expect(Graphics).itself.to.have.property('ELIP', 3); + expect(Graphics).itself.to.have.property('RREC', 4); + }); + + it('Confirm new instance', function () { + var obj = new Graphics(); + + pixi_display_DisplayObjectContainer_confirmNew(obj); + + expect(obj).to.be.an.instanceof(Graphics); + expect(obj).to.respondTo('lineStyle'); + expect(obj).to.respondTo('lineStyle'); + expect(obj).to.respondTo('moveTo'); + expect(obj).to.respondTo('lineTo'); + expect(obj).to.respondTo('beginFill'); + expect(obj).to.respondTo('endFill'); + expect(obj).to.respondTo('drawRect'); + // expect(obj).to.respondTo('drawRoundedRect'); + expect(obj).to.respondTo('drawCircle'); + expect(obj).to.respondTo('drawEllipse'); + expect(obj).to.respondTo('clear'); + + expect(obj).to.have.property('renderable', true); + expect(obj).to.have.property('fillAlpha', 1); + expect(obj).to.have.property('lineWidth', 0); + expect(obj).to.have.property('width', 0); + expect(obj).to.have.property('height', 0); + expect(obj).to.have.property('lineColor', 0); + expect(obj).to.have.deep.property('graphicsData.length', 0); + // expect(obj).to.have.deep.property('currentPath.points.length', 0); + }); +}); diff --git a/test/unit/pixi-v2/renderers/canvas/CanvasGraphics.js b/test/unit/pixi-v2/renderers/canvas/CanvasGraphics.js new file mode 100644 index 0000000..8f44472 --- /dev/null +++ b/test/unit/pixi-v2/renderers/canvas/CanvasGraphics.js @@ -0,0 +1,15 @@ +describe('renders/canvas/CanvasGraphics', function () { + 'use strict'; + + var expect = chai.expect; + var CanvasGraphics = PIXI.CanvasGraphics; + + it('Module exists', function () { + expect(CanvasGraphics).to.be.a('function'); + }); + + it('Members exist', function () { + expect(CanvasGraphics).itself.to.respondTo('renderGraphics'); + expect(CanvasGraphics).itself.to.respondTo('renderGraphicsMask'); + }); +}); diff --git a/test/unit/pixi-v2/renderers/canvas/CanvasRenderer.js b/test/unit/pixi-v2/renderers/canvas/CanvasRenderer.js new file mode 100644 index 0000000..1646444 --- /dev/null +++ b/test/unit/pixi-v2/renderers/canvas/CanvasRenderer.js @@ -0,0 +1,36 @@ +describe('renderers/canvas/CanvasRenderer', function () { + 'use strict'; + + var expect = chai.expect; + var CanvasRenderer = PIXI.CanvasRenderer; + + it('Module exists', function () { + expect(CanvasRenderer).to.be.a('function'); + }); + + describe('.autoResize', function () { + it('Should automatically resize view if enabled', function () { + var renderer = new CanvasRenderer(200, 200, { + autoResize: true + }); + + expect(renderer.view.style.width).to.equal('200px'); + }); + + it('Should not automatically resize view if disabled', function () { + var renderer = new CanvasRenderer(200, 200, { + autoResize: false + }); + + expect(renderer.view.style.width).to.equal(''); + }); + + it('Should not automatically resize view if not specified', function () { + var renderer = new CanvasRenderer(200, 200, { + resolution: 2 + }); + + expect(renderer.view.style.width).to.equal(''); + }); + }); +}); diff --git a/test/unit/pixi-v2/renderers/webgl/WebGLGraphics.js b/test/unit/pixi-v2/renderers/webgl/WebGLGraphics.js new file mode 100644 index 0000000..5867b28 --- /dev/null +++ b/test/unit/pixi-v2/renderers/webgl/WebGLGraphics.js @@ -0,0 +1,20 @@ +describe('renderers/wegbl/WebGLGraphics', function () { + 'use strict'; + + var expect = chai.expect; + var WebGLGraphics = PIXI.WebGLGraphics; + + it('Module exists', function () { + expect(WebGLGraphics).to.be.a('function'); + }); + + it('Members exist', function () { + expect(WebGLGraphics).itself.to.respondTo('renderGraphics'); + expect(WebGLGraphics).itself.to.respondTo('updateGraphics'); + expect(WebGLGraphics).itself.to.respondTo('buildRectangle'); + expect(WebGLGraphics).itself.to.respondTo('buildRoundedRectangle'); + expect(WebGLGraphics).itself.to.respondTo('buildCircle'); + expect(WebGLGraphics).itself.to.respondTo('buildLine'); + expect(WebGLGraphics).itself.to.respondTo('buildPoly'); + }); +}); diff --git a/test/unit/pixi-v2/renderers/webgl/WebGLRenderer.js b/test/unit/pixi-v2/renderers/webgl/WebGLRenderer.js new file mode 100644 index 0000000..1680a80 --- /dev/null +++ b/test/unit/pixi-v2/renderers/webgl/WebGLRenderer.js @@ -0,0 +1,49 @@ +describe('renderers/webgl/WebGLRenderer', function () { + 'use strict'; + + var expect = chai.expect; + var WebGLRenderer = PIXI.WebGLRenderer; + + it('Module exists', function () { + expect(WebGLRenderer).to.be.a('function'); + }); + + // Skip tests if WebGL is not available (WebGL not supported in Travis CI) + try { + var renderer = new WebGLRenderer(400, 300, {}); + renderer.destroy(); + } catch (error) { + return; + } + + it('Destroy renderer', function () { + var renderer = new WebGLRenderer(400, 300, {}); + renderer.destroy(); + }); + + describe('.autoResize', function () { + it('Should automatically resize view if enabled', function () { + var renderer = new WebGLRenderer(200, 200, { + autoResize: true + }); + + expect(renderer.view.style.width).to.equal('200px'); + }); + + it('Should not automatically resize view if disabled', function () { + var renderer = new WebGLRenderer(200, 200, { + autoResize: false + }); + + expect(renderer.view.style.width).to.equal(''); + }); + + it('Should not automatically resize view if not specified', function () { + var renderer = new WebGLRenderer(200, 200, { + resolution: 2 + }); + + expect(renderer.view.style.width).to.equal(''); + }); + }); +}); diff --git a/test/unit/pixi-v2/renderers/webgl/WebGLShaders.js b/test/unit/pixi-v2/renderers/webgl/WebGLShaders.js new file mode 100644 index 0000000..6e33e4f --- /dev/null +++ b/test/unit/pixi-v2/renderers/webgl/WebGLShaders.js @@ -0,0 +1,13 @@ +describe('renderers/webgl/WebGLShaders', function () { + 'use strict'; + + var expect = chai.expect; + + it('Module members exist', function () { + + expect(PIXI).to.respondTo('CompileVertexShader'); + expect(PIXI).to.respondTo('CompileFragmentShader'); + expect(PIXI).to.respondTo('_CompileShader'); + expect(PIXI).to.respondTo('compileProgram'); + }); +}); diff --git a/test/unit/pixi-v2/renderers/webgl/WebGLSpriteBatch.js b/test/unit/pixi-v2/renderers/webgl/WebGLSpriteBatch.js new file mode 100644 index 0000000..e662b63 --- /dev/null +++ b/test/unit/pixi-v2/renderers/webgl/WebGLSpriteBatch.js @@ -0,0 +1,10 @@ +describe('renderers/webgl/utils/WebGLSpriteBatch', function () { + 'use strict'; + + var expect = chai.expect; + var WebGLSpriteBatch = PIXI.WebGLSpriteBatch; + + it('Module exists', function () { + expect(WebGLSpriteBatch).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/text/BitmapText.js b/test/unit/pixi-v2/text/BitmapText.js new file mode 100644 index 0000000..9388e3d --- /dev/null +++ b/test/unit/pixi-v2/text/BitmapText.js @@ -0,0 +1,10 @@ +describe('pixi/text/BitmapText', function () { + 'use strict'; + + var expect = chai.expect; + var BitmapText = PIXI.BitmapText; + + it('Module exists', function () { + expect(BitmapText).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/text/Text.js b/test/unit/pixi-v2/text/Text.js new file mode 100644 index 0000000..9bc9ac5 --- /dev/null +++ b/test/unit/pixi-v2/text/Text.js @@ -0,0 +1,10 @@ +describe('pixi/text/Text', function () { + 'use strict'; + + var expect = chai.expect; + var Text = PIXI.Text; + + it('Module exists', function () { + expect(Text).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/textures/BaseTexture.js b/test/unit/pixi-v2/textures/BaseTexture.js new file mode 100644 index 0000000..502b724 --- /dev/null +++ b/test/unit/pixi-v2/textures/BaseTexture.js @@ -0,0 +1,11 @@ +describe('pixi/textures/BaseTexture', function () { + 'use strict'; + + var expect = chai.expect; + var BaseTexture = PIXI.BaseTexture; + + it('Module exists', function () { + expect(BaseTexture).to.be.a('function'); + expect(PIXI).to.have.property('BaseTextureCache').and.to.be.an('object'); + }); +}); diff --git a/test/unit/pixi-v2/textures/RenderTexture.js b/test/unit/pixi-v2/textures/RenderTexture.js new file mode 100644 index 0000000..96acdb4 --- /dev/null +++ b/test/unit/pixi-v2/textures/RenderTexture.js @@ -0,0 +1,15 @@ +describe('pixi/textures/RenderTexture', function () { + 'use strict'; + + var expect = chai.expect; + var RenderTexture = PIXI.RenderTexture; + + it('Module exists', function () { + expect(RenderTexture).to.be.a('function'); + }); + + it('Confirm new instance', function (done) { + var texture = new RenderTexture(100, 100, new PIXI.CanvasRenderer()); + pixi_textures_RenderTexture_confirmNew(texture, done); + }); +}); diff --git a/test/unit/pixi-v2/textures/Texture.js b/test/unit/pixi-v2/textures/Texture.js new file mode 100644 index 0000000..090f64d --- /dev/null +++ b/test/unit/pixi-v2/textures/Texture.js @@ -0,0 +1,26 @@ +describe('pixi/textures/Texture', function () { + 'use strict'; + + var expect = chai.expect; + var Texture = PIXI.Texture; + + it('Module exists', function () { + expect(Texture).to.be.a('function'); + expect(PIXI).to.have.property('TextureCache').and.to.be.an('object'); + }); + + it('Members exist', function () { + expect(Texture).itself.to.respondTo('fromImage'); + expect(Texture).itself.to.respondTo('fromFrame'); + expect(Texture).itself.to.respondTo('fromCanvas'); + expect(Texture).itself.to.respondTo('addTextureToCache'); + expect(Texture).itself.to.respondTo('removeTextureFromCache'); + + // expect(Texture).itself.to.have.deep.property('frameUpdates.length', 0); + }); + + it('Confirm new instance', function (done) { + var texture = Texture.fromImage('/base/test/textures/bunny.png'); + pixi_textures_Texture_confirmNew(texture, done); + }); +}); diff --git a/test/unit/pixi-v2/utils/Detector.js b/test/unit/pixi-v2/utils/Detector.js new file mode 100644 index 0000000..4cf6008 --- /dev/null +++ b/test/unit/pixi-v2/utils/Detector.js @@ -0,0 +1,10 @@ +describe('pixi/utils/Detector', function () { + 'use strict'; + + var expect = chai.expect; + var autoDetectRenderer = PIXI.autoDetectRenderer; + + it('Module exists', function () { + expect(autoDetectRenderer).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/utils/EventTarget.js b/test/unit/pixi-v2/utils/EventTarget.js new file mode 100644 index 0000000..1cfc3a4 --- /dev/null +++ b/test/unit/pixi-v2/utils/EventTarget.js @@ -0,0 +1,361 @@ +describe('pixi/utils/EventTarget', function () { + 'use strict'; + + var expect = chai.expect; + + var Clazz, PClazz, obj, pobj, obj2; + beforeEach(function () { + Clazz = function () {}; + PClazz = function () {}; + + PIXI.EventTarget.mixin(Clazz.prototype); + PIXI.EventTarget.mixin(PClazz.prototype); + + obj = new Clazz(); + obj2 = new Clazz(); + pobj = new PClazz(); + + obj.parent = pobj; + obj2.parent = obj; + }); + + it('Module exists', function () { + expect(PIXI.EventTarget).to.be.an('object'); + }); + + it('Confirm new instance', function () { + pixi_utils_EventTarget_confirm(obj); + }); + + it('simple on/emit case works', function () { + var myData = {}; + + obj.on('myevent', function (event) { + pixi_utils_EventTarget_Event_confirm(event, obj, myData); + }); + + obj.emit('myevent', myData); + }); + + it('simple once case works', function () { + var called = 0; + + obj.once('myevent', function() { called++; }); + + obj.emit('myevent'); + obj.emit('myevent'); + obj.emit('myevent'); + obj.emit('myevent'); + obj.emit('myevent'); + + expect(called).to.equal(1); + }); + + it('simple off case works', function (done) { + function onMyEvent() { + done(new Error('Event listener should not have been called')); + } + + obj.on('myevent', onMyEvent); + obj.off('myevent', onMyEvent); + obj.emit('myevent'); + + done(); + }); + + it('simple propagation case works', function (done) { + var myData = {}; + + pobj.on('myevent', function () { + done(); + }); + + obj.emit('myevent'); + }); + + it('simple stopPropagation case works', function (done) { + var myData = {}; + + pobj.on('myevent', function () { + done(new Error('Event listener should not have been called on the parent element')); + }); + + obj.on('myevent', function (evt) { + evt.stopPropagation(); + }); + + obj.emit('myevent'); + + done(); + }); + + it('simple stopImmediatePropagation case works', function (done) { + var myData = {}; + + pobj.on('myevent', function () { + done(new Error('Event listener should not have been called on the parent')); + }); + + obj.on('myevent', function (evt) { + evt.stopImmediatePropagation(); + }); + + obj.on('myevent', function () { + done(new Error('Event listener should not have been called on the second')); + }); + + obj.emit('myevent'); + + done(); + }); + + it('multiple dispatches work properly', function () { + var called = 0; + + function onMyEvent() { + called++; + } + + obj.on('myevent', onMyEvent); + obj.emit('myevent'); + obj.emit('myevent'); + obj.emit('myevent'); + obj.emit('myevent'); + + expect(called).to.equal(4); + }); + + it('multiple events work properly', function () { + var called = 0; + + function onMyEvent() { + called++; + } + + obj.on('myevent1', onMyEvent); + obj.on('myevent2', onMyEvent); + obj.on('myevent3', onMyEvent); + obj.emit('myevent1'); + obj.emit('myevent2'); + obj.emit('myevent3'); + + expect(called).to.equal(3); + }); + + it('multiple events one removed works properly', function () { + var called = 0; + + function onMyEvent() { + called++; + } + + obj.on('myevent1', onMyEvent); + obj.on('myevent2', onMyEvent); + obj.on('myevent3', onMyEvent); + + obj.emit('myevent1'); + obj.emit('myevent2'); + obj.emit('myevent3'); + + obj.off('myevent2', onMyEvent); + + obj.emit('myevent1'); + obj.emit('myevent2'); + obj.emit('myevent3'); + + expect(called).to.equal(5); + }); + + it('multiple handlers for one event with some removed', function () { + var called = 0; + + var onMyEvent = function () { + called++; + }, + onMyEvent2 = function () { + called++; + }; + + // add 2 handlers and confirm they both get called + obj.on('myevent', onMyEvent); + obj.on('myevent', onMyEvent); + obj.on('myevent', onMyEvent2); + obj.on('myevent', onMyEvent2); + + obj.emit('myevent'); + + expect(called).to.equal(4); + + // remove one of the handlers, emit again, then ensure 1 more call is made + obj.off('myevent', onMyEvent); + + obj.emit('myevent'); + + expect(called).to.equal(6); + }); + + it('calls to off without a handler do nothing', function () { + var called = 0; + + var onMyEvent = function () { + called++; + }; + + obj.on('myevent', onMyEvent); + obj.on('myevent', onMyEvent); + + obj.emit('myevent'); + + expect(called).to.equal(2); + + obj.off('myevent'); + + obj.emit('myevent'); + + expect(called).to.equal(4); + + obj.off('myevent', onMyEvent); + + obj.emit('myevent'); + + expect(called).to.equal(4); + }); + + it('handles multiple instances with the same prototype', function () { + var called = 0; + + function onMyEvent(e) { + called++; + } + + obj.on('myevent1', onMyEvent); + obj.on('myevent2', onMyEvent); + + obj2.istwo = true; + obj2.on('myevent1', onMyEvent); + obj2.on('myevent2', onMyEvent); + + obj.emit('myevent1'); + obj.emit('myevent2'); + obj2.emit('myevent1'); + obj2.emit('myevent2'); + + //we emit 4 times, but since obj2 is a child of obj the event should bubble + //up to obj and show up there as well. So the obj2.emit() calls each increment + //the counter twice. + expect(called).to.equal(6); + }); + + it('is backwards compatible with older .dispatchEvent({})', function () { + var called = 0, + data = { + some: 'thing', + hello: true + }; + + function onMyEvent(event) { + pixi_utils_EventTarget_Event_confirm(event, obj, data); + + called++; + } + + obj.on('myevent1', onMyEvent); + obj.on('myevent2', onMyEvent); + obj.on('myevent3', onMyEvent); + + data.type = 'myevent1'; + obj.emit(data); + + data.type = 'myevent2'; + obj.emit(data); + + data.type = 'myevent3'; + obj.emit(data); + + obj.off('myevent2', onMyEvent); + + data.type = 'myevent1'; + obj.emit(data); + + data.type = 'myevent2'; + obj.emit(data); + + data.type = 'myevent3'; + obj.emit(data); + + expect(called).to.equal(5); + }); + + it('is backwards compatible with older .call(this)', function () { + var Fn = function() { + PIXI.EventTarget.call(this); + }, + o = new Fn(); + + pixi_utils_EventTarget_confirm(o); + }); + + it('is backwards compatible with older .addEventListener("")', function () { + var called = 0, + data = { + some: 'thing', + hello: true + }; + + function onMyEvent(event) { + pixi_utils_EventTarget_Event_confirm(event, obj, data); + + called++; + } + + obj.addEventListener('myevent1', onMyEvent); + obj.addEventListener('myevent2', onMyEvent); + obj.addEventListener('myevent3', onMyEvent); + + data.type = 'myevent1'; + obj.emit(data); + + data.type = 'myevent2'; + obj.emit(data); + + data.type = 'myevent3'; + obj.emit(data); + + obj.off('myevent2', onMyEvent); + + data.type = 'myevent1'; + obj.emit(data); + + data.type = 'myevent2'; + obj.emit(data); + + data.type = 'myevent3'; + obj.emit(data); + + expect(called).to.equal(5); + }); + + it('event remove during emit call properly', function () { + var called = 0; + + function cb1() { + called++; + obj.off('myevent', cb1); + } + function cb2() { + called++; + obj.off('myevent', cb2); + } + function cb3() { + called++; + obj.off('myevent', cb3); + } + + obj.on('myevent', cb1); + obj.on('myevent', cb2); + obj.on('myevent', cb3); + obj.emit('myevent', ''); + + expect(called).to.equal(3); + }); +}); diff --git a/test/unit/pixi-v2/utils/Polyk.js b/test/unit/pixi-v2/utils/Polyk.js new file mode 100644 index 0000000..dfc7128 --- /dev/null +++ b/test/unit/pixi-v2/utils/Polyk.js @@ -0,0 +1,14 @@ +describe('pixi/utils/Polyk', function () { + 'use strict'; + + var expect = chai.expect; + var PolyK = PIXI.PolyK; + + it('Module exists', function () { + expect(PolyK).to.be.an('object'); + }); + + it('Members exist', function () { + expect(PolyK).to.respondTo('Triangulate'); + }); +}); diff --git a/test/unit/pixi-v2/utils/Utils.js b/test/unit/pixi-v2/utils/Utils.js new file mode 100644 index 0000000..c97b3c6 --- /dev/null +++ b/test/unit/pixi-v2/utils/Utils.js @@ -0,0 +1,17 @@ +describe('Utils', function () { + 'use strict'; + + var expect = chai.expect; + + it('requestAnimationFrame exists', function () { + expect(global).to.respondTo('requestAnimationFrame'); + }); + + it('cancelAnimationFrame exists', function () { + expect(global).to.respondTo('cancelAnimationFrame'); + }); + + it('requestAnimFrame exists', function () { + expect(global).to.respondTo('requestAnimFrame'); + }); +}); diff --git a/test/unit/pixi/InteractionManager.js b/test/unit/pixi/InteractionManager.js deleted file mode 100644 index ed3001f..0000000 --- a/test/unit/pixi/InteractionManager.js +++ /dev/null @@ -1,10 +0,0 @@ -describe('pixi/InteractionManager', function () { - 'use strict'; - - var expect = chai.expect; - var InteractionManager = PIXI.InteractionManager; - - it('Module exists', function () { - expect(InteractionManager).to.be.a('function'); - }); -}); diff --git a/test/unit/pixi/Pixi.js b/test/unit/pixi/Pixi.js deleted file mode 100644 index 27debc1..0000000 --- a/test/unit/pixi/Pixi.js +++ /dev/null @@ -1,9 +0,0 @@ -describe('pixi/Pixi', function () { - 'use strict'; - - var expect = chai.expect; - - it('Module exists', function () { - expect(global).to.have.property('PIXI').and.to.be.an('object'); - }); -}); diff --git a/test/unit/pixi/core/Circle.js b/test/unit/pixi/core/Circle.js deleted file mode 100644 index fbcfa17..0000000 --- a/test/unit/pixi/core/Circle.js +++ /dev/null @@ -1,21 +0,0 @@ -describe('pixi/core/Circle', function () { - 'use strict'; - - var expect = chai.expect; - var Circle = PIXI.Circle; - - it('Module exists', function () { - expect(Circle).to.be.a('function'); - }); - - it('Confirm new instance', function () { - var obj = new Circle(); - pixi_core_Circle_confirmNewCircle(obj); - }); - - it("getBounds should return Rectangle that bounds the circle", function() { - var obj = new Circle(100, 250, 50); - var bounds = obj.getBounds(); - pixi_core_Circle_isBoundedByRectangle(obj, bounds); - }); -}); diff --git a/test/unit/pixi/core/Ellipse.js b/test/unit/pixi/core/Ellipse.js deleted file mode 100644 index 026b56f..0000000 --- a/test/unit/pixi/core/Ellipse.js +++ /dev/null @@ -1,24 +0,0 @@ -describe('pixi/core/Ellipse', function () { - 'use strict'; - - var expect = chai.expect; - var Ellipse = PIXI.Ellipse; - - it('Module exists', function () { - expect(Ellipse).to.be.a('function'); - }); - - it('Confirm new instance', function () { - var obj = new Ellipse(); - - expect(obj).to.be.an.instanceof(Ellipse); - expect(obj).to.respondTo('clone'); - expect(obj).to.respondTo('contains'); - expect(obj).to.respondTo('getBounds'); - - expect(obj).to.have.property('x', 0); - expect(obj).to.have.property('y', 0); - expect(obj).to.have.property('width', 0); - expect(obj).to.have.property('height', 0); - }); -}); diff --git a/test/unit/pixi/core/Matrix.js b/test/unit/pixi/core/Matrix.js deleted file mode 100644 index da75e2e..0000000 --- a/test/unit/pixi/core/Matrix.js +++ /dev/null @@ -1,14 +0,0 @@ -describe('pixi/core/Matrix', function () { - 'use strict'; - - var expect = chai.expect; - - it('Matrix exists', function () { - expect(PIXI.Matrix).to.be.an('function'); - }); - - it('Confirm new Matrix', function () { - var matrix = new PIXI.Matrix(); - pixi_core_Matrix_confirmNewMatrix(matrix); - }); -}); diff --git a/test/unit/pixi/core/Point.js b/test/unit/pixi/core/Point.js deleted file mode 100644 index c4d5163..0000000 --- a/test/unit/pixi/core/Point.js +++ /dev/null @@ -1,15 +0,0 @@ -describe('pixi/core/Point', function () { - 'use strict'; - - var expect = chai.expect; - var Point = PIXI.Point; - - it('Module exists', function () { - expect(Point).to.be.a('function'); - }); - - it('Confirm new instance', function () { - var obj = new Point(); - pixi_core_Point_confirm(obj, 0, 0); - }); -}); diff --git a/test/unit/pixi/core/Polygon.js b/test/unit/pixi/core/Polygon.js deleted file mode 100644 index dc8c918..0000000 --- a/test/unit/pixi/core/Polygon.js +++ /dev/null @@ -1,20 +0,0 @@ -describe('pixi/core/Polygon', function () { - 'use strict'; - - var expect = chai.expect; - var Polygon = PIXI.Polygon; - - it('Module exists', function () { - expect(Polygon).to.be.a('function'); - }); - - it('Confirm new instance', function () { - var obj = new Polygon(); - - expect(obj).to.be.an.instanceof(Polygon); - expect(obj).to.respondTo('clone'); - expect(obj).to.respondTo('contains'); - - expect(obj).to.have.deep.property('points.length', 0); - }); -}); diff --git a/test/unit/pixi/core/Rectangle.js b/test/unit/pixi/core/Rectangle.js deleted file mode 100644 index d43316e..0000000 --- a/test/unit/pixi/core/Rectangle.js +++ /dev/null @@ -1,15 +0,0 @@ -describe('pixi/core/Rectangle', function () { - 'use strict'; - - var expect = chai.expect; - var Rectangle = PIXI.Rectangle; - - it('Module exists', function () { - expect(Rectangle).to.be.a('function'); - }); - - it('Confirm new instance', function () { - var rect = new Rectangle(); - pixi_core_Rectangle_confirm(rect, 0, 0, 0, 0); - }); -}); diff --git a/test/unit/pixi/display/DisplayObject.js b/test/unit/pixi/display/DisplayObject.js deleted file mode 100644 index 044acf8..0000000 --- a/test/unit/pixi/display/DisplayObject.js +++ /dev/null @@ -1,21 +0,0 @@ -describe('pixi/display/DisplayObject', function () { - 'use strict'; - - var expect = chai.expect; - var DisplayObject = PIXI.DisplayObject; - - it('Module exists', function () { - expect(DisplayObject).to.be.a('function'); - // expect(PIXI).to.have.property('visibleCount', 0); - }); - - it('Confirm new instance', function () { - var obj = new DisplayObject(); - - pixi_display_DisplayObject_confirmNew(obj); - expect(obj).to.have.property('hitArea', null); - expect(obj).to.have.property('interactive', false); - expect(obj).to.have.property('renderable', false); - expect(obj).to.have.property('stage', null); - }); -}); diff --git a/test/unit/pixi/display/DisplayObjectContainer.js b/test/unit/pixi/display/DisplayObjectContainer.js deleted file mode 100644 index 15a3376..0000000 --- a/test/unit/pixi/display/DisplayObjectContainer.js +++ /dev/null @@ -1,67 +0,0 @@ -describe('pixi/display/DisplayObjectContainer', function () { - 'use strict'; - - var expect = chai.expect; - var DisplayObjectContainer = PIXI.DisplayObjectContainer; - - it('Module exists', function () { - expect(DisplayObjectContainer).to.be.a('function'); - }); - - it('Confirm new instance', function () { - var obj = new DisplayObjectContainer(); - - pixi_display_DisplayObjectContainer_confirmNew(obj); - expect(obj).to.have.property('hitArea', null); - expect(obj).to.have.property('interactive', false); - expect(obj).to.have.property('renderable', false); - expect(obj).to.have.property('stage', null); - }); - - it('Gets child index', function() { - var container = new PIXI.DisplayObjectContainer(); - var children = []; - for (var i = 0; i < 10; i++) { - var child = new PIXI.DisplayObject(); - children.push(child); - container.addChild(child); - } - - for (i = 0; i < children.length; i++) { - expect(i).to.eql(container.getChildIndex(children[i])); - } - }); - - it('throws error when trying to get index of not a child', function() { - var container = new PIXI.DisplayObjectContainer(); - var child = new PIXI.DisplayObject(); - - expect(function() { container.getChildIndex(child); }).to.throw(); - }); - - it('Sets child index', function() { - var container = new PIXI.DisplayObjectContainer(); - var children = []; - - for (var i = 0; i < 10; i++) { - var child = new PIXI.DisplayObject(); - children.push(child); - container.addChild(child); - } - children.reverse(); - - for (i = 0; i < children.length; i++) { - container.setChildIndex(children[i], i); - expect(i).to.eql(container.getChildIndex(children[i])); - } - }); - - it('throws error when trying to set incorect index', function() { - var container = new PIXI.DisplayObjectContainer(); - var child = new PIXI.DisplayObject(); - container.addChild(child); - - expect(function() { container.setChildIndex(child, -1); }).to.throw(); - expect(function() { container.setChildIndex(child, 1); }).to.throw(); - }); -}); diff --git a/test/unit/pixi/display/MovieClip.js b/test/unit/pixi/display/MovieClip.js deleted file mode 100644 index f3c6c6a..0000000 --- a/test/unit/pixi/display/MovieClip.js +++ /dev/null @@ -1,33 +0,0 @@ -describe('pixi/display/MovieClip', function () { - 'use strict'; - - var expect = chai.expect; - var MovieClip = PIXI.MovieClip; - var Texture = PIXI.Texture; - - it('Module exists', function () { - expect(MovieClip).to.be.a('function'); - }); - - it('Confirm new instance', function (done) { - var texture = Texture.fromImage('/base/test/textures/SpriteSheet-Explosion.png'); - var obj = new MovieClip([texture]); - - pixi_display_Sprite_confirmNew(obj, done); - - expect(obj).to.be.an.instanceof(MovieClip); - expect(obj).to.respondTo('stop'); - expect(obj).to.respondTo('play'); - expect(obj).to.respondTo('gotoAndStop'); - expect(obj).to.respondTo('gotoAndPlay'); - expect(obj).to.respondTo('updateTransform'); - - expect(obj).to.have.deep.property('textures.length', 1); - expect(obj).to.have.deep.property('textures[0]', texture); - expect(obj).to.have.property('animationSpeed', 1); - expect(obj).to.have.property('loop', true); - expect(obj).to.have.property('onComplete', null); - expect(obj).to.have.property('currentFrame', 0); - expect(obj).to.have.property('playing', false); - }); -}); diff --git a/test/unit/pixi/display/Sprite.js b/test/unit/pixi/display/Sprite.js deleted file mode 100644 index 30c8076..0000000 --- a/test/unit/pixi/display/Sprite.js +++ /dev/null @@ -1,28 +0,0 @@ -describe('pixi/display/Sprite', function () { - 'use strict'; - - var expect = chai.expect; - var Sprite = PIXI.Sprite; - var Texture = PIXI.Texture; - - it('Module exists', function () { - expect(Sprite).to.be.a('function'); - expect(PIXI).to.have.deep.property('blendModes.NORMAL', 0); - expect(PIXI).to.have.deep.property('blendModes.ADD', 1); - expect(PIXI).to.have.deep.property('blendModes.MULTIPLY', 2); - expect(PIXI).to.have.deep.property('blendModes.SCREEN', 3); - }); - - - it('Members exist', function () { - expect(Sprite).itself.to.respondTo('fromImage'); - expect(Sprite).itself.to.respondTo('fromFrame'); - }); - - it('Confirm new instance', function (done) { - var texture = Texture.fromImage('/base/test/textures/SpriteSheet-Aliens.png'); - var obj = new Sprite(texture); - - pixi_display_Sprite_confirmNew(obj, done); - }); -}); diff --git a/test/unit/pixi/display/Stage.js b/test/unit/pixi/display/Stage.js deleted file mode 100644 index 6974c2e..0000000 --- a/test/unit/pixi/display/Stage.js +++ /dev/null @@ -1,49 +0,0 @@ -describe('pixi/display/Stage', function () { - 'use strict'; - - var expect = chai.expect; - var Stage = PIXI.Stage; - var InteractionManager = PIXI.InteractionManager; - var Rectangle = PIXI.Rectangle; - - it('Module exists', function () { - expect(Stage).to.be.a('function'); - }); - - it('Confirm new instance', function () { - var obj = new Stage(null, true); - - pixi_display_DisplayObjectContainer_confirmNew(obj); - - expect(obj).to.be.an.instanceof(Stage); - expect(obj).to.respondTo('updateTransform'); - expect(obj).to.respondTo('setBackgroundColor'); - expect(obj).to.respondTo('getMousePosition'); - // FIXME: duplicate member in DisplayObject - pixi_core_Matrix_confirmNewMatrix(obj.worldTransform); - // FIXME: convert arg to bool in constructor - expect(obj).to.have.property('interactive', true); - - expect(obj).to.have.property('interactionManager') - .and.to.be.an.instanceof(InteractionManager) - .and.to.have.property('stage', obj); - - expect(obj).to.have.property('dirty', true); - - expect(obj).to.have.property('stage', obj); - - expect(obj).to.have.property('hitArea') - .and.to.be.an.instanceof(Rectangle); - pixi_core_Rectangle_confirm(obj.hitArea, 0, 0, 100000, 100000); - - expect(obj).to.have.property('backgroundColor', 0x000000); - expect(obj).to.have.deep.property('backgroundColorSplit.length', 3); - expect(obj).to.have.deep.property('backgroundColorSplit[0]', 0); - expect(obj).to.have.deep.property('backgroundColorSplit[1]', 0); - expect(obj).to.have.deep.property('backgroundColorSplit[2]', 0); - expect(obj).to.have.property('backgroundColorString', '#000000'); - - - expect(obj).to.have.property('worldVisible', true); - }); -}); diff --git a/test/unit/pixi/extras/Rope.js b/test/unit/pixi/extras/Rope.js deleted file mode 100644 index 05885ac..0000000 --- a/test/unit/pixi/extras/Rope.js +++ /dev/null @@ -1,31 +0,0 @@ -describe('pixi/extras/Rope', function () { - 'use strict'; - - var expect = chai.expect; - var Rope = PIXI.Rope; - var Texture = PIXI.Texture; - var Point = PIXI.Point; - - it('Module exists', function () { - expect(Rope).to.be.a('function'); - }); - - it('Confirm new instance', function () { - - var texture = Texture.fromImage('/base/test/textures/bunny.png'); - - // TODO-Alvin - // Same as Strip - - // var obj = new Rope(texture, [new Point(), new Point(5, 10), new Point(10, 20)]); - - // pixi_extras_Strip_confirmNew(obj); - - // expect(obj).to.be.an.instanceof(Rope); - // expect(obj).to.respondTo('refresh'); - // expect(obj).to.respondTo('updateTransform'); - // expect(obj).to.respondTo('setTexture'); - - // TODO: Test properties - }); -}); diff --git a/test/unit/pixi/extras/Spine.js b/test/unit/pixi/extras/Spine.js deleted file mode 100644 index 0708bc0..0000000 --- a/test/unit/pixi/extras/Spine.js +++ /dev/null @@ -1,10 +0,0 @@ -describe('pixi/extras/Spine', function () { - 'use strict'; - - var expect = chai.expect; - var Spine = PIXI.Spine; - - it('Module exists', function () { - expect(Spine).to.be.a('function'); - }); -}); diff --git a/test/unit/pixi/extras/Strip.js b/test/unit/pixi/extras/Strip.js deleted file mode 100644 index 230af90..0000000 --- a/test/unit/pixi/extras/Strip.js +++ /dev/null @@ -1,26 +0,0 @@ -describe('pixi/extras/Strip', function () { - 'use strict'; - - var expect = chai.expect; - var Strip = PIXI.Strip; - var Texture = PIXI.Texture; - - it('Module exists', function () { - expect(Strip).to.be.a('function'); - }); - - it('Confirm new instance', function () { - - - // TODO-Alvin - // We tweaked it to make it pass the tests, but the whole strip class needs - // to be re-coded - - var texture = Texture.fromImage('/base/test/textures/bunny.png'); - - // var obj = new Strip(texture, 20, 10000); - - - // pixi_extras_Strip_confirmNew(obj); - }); -}); diff --git a/test/unit/pixi/extras/TilingSprite.js b/test/unit/pixi/extras/TilingSprite.js deleted file mode 100644 index 56aea14..0000000 --- a/test/unit/pixi/extras/TilingSprite.js +++ /dev/null @@ -1,24 +0,0 @@ -describe('pixi/extras/TilingSprite', function () { - 'use strict'; - - var expect = chai.expect; - var TilingSprite = PIXI.TilingSprite; - var Texture = PIXI.Texture; - - it('Module exists', function () { - expect(TilingSprite).to.be.a('function'); - }); - - it('Confirm new instance', function () { - var texture = Texture.fromImage('/base/test/textures/bunny.png'); - var obj = new TilingSprite(texture, 6000, 12000); - - pixi_display_DisplayObjectContainer_confirmNew(obj); - - expect(obj).to.be.an.instanceof(TilingSprite); - expect(obj).to.respondTo('setTexture'); - expect(obj).to.respondTo('onTextureUpdate'); - - // TODO: Test properties - }); -}); diff --git a/test/unit/pixi/filters/FilterBlock.js b/test/unit/pixi/filters/FilterBlock.js deleted file mode 100644 index 870cec0..0000000 --- a/test/unit/pixi/filters/FilterBlock.js +++ /dev/null @@ -1,10 +0,0 @@ -describe('pixi/filters/FilterBlock', function () { - 'use strict'; - - var expect = chai.expect; - var FilterBlock = PIXI.FilterBlock; - - it('Module exists', function () { - expect(FilterBlock).to.be.a('function'); - }); -}); diff --git a/test/unit/pixi/loaders/AssetLoader.js b/test/unit/pixi/loaders/AssetLoader.js deleted file mode 100644 index a0aa0b5..0000000 --- a/test/unit/pixi/loaders/AssetLoader.js +++ /dev/null @@ -1,10 +0,0 @@ -describe('pixi/loaders/AssetLoader', function () { - 'use strict'; - - var expect = chai.expect; - var AssetLoader = PIXI.AssetLoader; - - it('Module exists', function () { - expect(AssetLoader).to.be.a('function'); - }); -}); diff --git a/test/unit/pixi/loaders/BitmapFontLoader.js b/test/unit/pixi/loaders/BitmapFontLoader.js deleted file mode 100644 index 046f018..0000000 --- a/test/unit/pixi/loaders/BitmapFontLoader.js +++ /dev/null @@ -1,9 +0,0 @@ -describe('pixi/loaders/BitmapFontLoader', function () { - 'use strict'; - - var expect = chai.expect; - - it('Module exists', function () { - expect(PIXI.BitmapFontLoader).to.be.a('function'); - }); -}); diff --git a/test/unit/pixi/loaders/ImageLoader.js b/test/unit/pixi/loaders/ImageLoader.js deleted file mode 100644 index 8b1f556..0000000 --- a/test/unit/pixi/loaders/ImageLoader.js +++ /dev/null @@ -1,10 +0,0 @@ -describe('pixi/loaders/ImageLoader', function () { - 'use strict'; - - var expect = chai.expect; - var ImageLoader = PIXI.ImageLoader; - - it('Module exists', function () { - expect(ImageLoader).to.be.a('function'); - }); -}); diff --git a/test/unit/pixi/loaders/JsonLoader.js b/test/unit/pixi/loaders/JsonLoader.js deleted file mode 100644 index c577e83..0000000 --- a/test/unit/pixi/loaders/JsonLoader.js +++ /dev/null @@ -1,10 +0,0 @@ -describe('pixi/loaders/JsonLoader', function () { - 'use strict'; - - var expect = chai.expect; - var JsonLoader = PIXI.JsonLoader; - - it('Module exists', function () { - expect(JsonLoader).to.be.a('function'); - }); -}); diff --git a/test/unit/pixi/loaders/SpineLoader.js b/test/unit/pixi/loaders/SpineLoader.js deleted file mode 100644 index fdcc0b8..0000000 --- a/test/unit/pixi/loaders/SpineLoader.js +++ /dev/null @@ -1,10 +0,0 @@ -describe('pixi/loaders/SpineLoader', function () { - 'use strict'; - - var expect = chai.expect; - var SpineLoader = PIXI.SpineLoader; - - it('Module exists', function () { - expect(SpineLoader).to.be.a('function'); - }); -}); diff --git a/test/unit/pixi/loaders/SpriteSheetLoader.js b/test/unit/pixi/loaders/SpriteSheetLoader.js deleted file mode 100644 index 57beb27..0000000 --- a/test/unit/pixi/loaders/SpriteSheetLoader.js +++ /dev/null @@ -1,10 +0,0 @@ -describe('pixi/loaders/SpriteSheetLoader', function () { - 'use strict'; - - var expect = chai.expect; - var SpriteSheetLoader = PIXI.SpriteSheetLoader; - - it('Module exists', function () { - expect(SpriteSheetLoader).to.be.a('function'); - }); -}); diff --git a/test/unit/pixi/primitives/Graphics.js b/test/unit/pixi/primitives/Graphics.js deleted file mode 100644 index f3849eb..0000000 --- a/test/unit/pixi/primitives/Graphics.js +++ /dev/null @@ -1,44 +0,0 @@ -describe('pixi/primitives/Graphics', function () { - 'use strict'; - - var expect = chai.expect; - var Graphics = PIXI.Graphics; - - it('Module exists', function () { - expect(Graphics).to.be.a('function'); - - expect(Graphics).itself.to.have.property('POLY', 0); - expect(Graphics).itself.to.have.property('RECT', 1); - expect(Graphics).itself.to.have.property('CIRC', 2); - expect(Graphics).itself.to.have.property('ELIP', 3); - expect(Graphics).itself.to.have.property('RREC', 4); - }); - - it('Confirm new instance', function () { - var obj = new Graphics(); - - pixi_display_DisplayObjectContainer_confirmNew(obj); - - expect(obj).to.be.an.instanceof(Graphics); - expect(obj).to.respondTo('lineStyle'); - expect(obj).to.respondTo('lineStyle'); - expect(obj).to.respondTo('moveTo'); - expect(obj).to.respondTo('lineTo'); - expect(obj).to.respondTo('beginFill'); - expect(obj).to.respondTo('endFill'); - expect(obj).to.respondTo('drawRect'); - // expect(obj).to.respondTo('drawRoundedRect'); - expect(obj).to.respondTo('drawCircle'); - expect(obj).to.respondTo('drawEllipse'); - expect(obj).to.respondTo('clear'); - - expect(obj).to.have.property('renderable', true); - expect(obj).to.have.property('fillAlpha', 1); - expect(obj).to.have.property('lineWidth', 0); - expect(obj).to.have.property('width', 0); - expect(obj).to.have.property('height', 0); - expect(obj).to.have.property('lineColor', 0); - expect(obj).to.have.deep.property('graphicsData.length', 0); - // expect(obj).to.have.deep.property('currentPath.points.length', 0); - }); -}); diff --git a/test/unit/pixi/renderers/canvas/CanvasGraphics.js b/test/unit/pixi/renderers/canvas/CanvasGraphics.js deleted file mode 100644 index 8f44472..0000000 --- a/test/unit/pixi/renderers/canvas/CanvasGraphics.js +++ /dev/null @@ -1,15 +0,0 @@ -describe('renders/canvas/CanvasGraphics', function () { - 'use strict'; - - var expect = chai.expect; - var CanvasGraphics = PIXI.CanvasGraphics; - - it('Module exists', function () { - expect(CanvasGraphics).to.be.a('function'); - }); - - it('Members exist', function () { - expect(CanvasGraphics).itself.to.respondTo('renderGraphics'); - expect(CanvasGraphics).itself.to.respondTo('renderGraphicsMask'); - }); -}); diff --git a/test/unit/pixi/renderers/canvas/CanvasRenderer.js b/test/unit/pixi/renderers/canvas/CanvasRenderer.js deleted file mode 100644 index 1646444..0000000 --- a/test/unit/pixi/renderers/canvas/CanvasRenderer.js +++ /dev/null @@ -1,36 +0,0 @@ -describe('renderers/canvas/CanvasRenderer', function () { - 'use strict'; - - var expect = chai.expect; - var CanvasRenderer = PIXI.CanvasRenderer; - - it('Module exists', function () { - expect(CanvasRenderer).to.be.a('function'); - }); - - describe('.autoResize', function () { - it('Should automatically resize view if enabled', function () { - var renderer = new CanvasRenderer(200, 200, { - autoResize: true - }); - - expect(renderer.view.style.width).to.equal('200px'); - }); - - it('Should not automatically resize view if disabled', function () { - var renderer = new CanvasRenderer(200, 200, { - autoResize: false - }); - - expect(renderer.view.style.width).to.equal(''); - }); - - it('Should not automatically resize view if not specified', function () { - var renderer = new CanvasRenderer(200, 200, { - resolution: 2 - }); - - expect(renderer.view.style.width).to.equal(''); - }); - }); -}); diff --git a/test/unit/pixi/renderers/webgl/WebGLGraphics.js b/test/unit/pixi/renderers/webgl/WebGLGraphics.js deleted file mode 100644 index 5867b28..0000000 --- a/test/unit/pixi/renderers/webgl/WebGLGraphics.js +++ /dev/null @@ -1,20 +0,0 @@ -describe('renderers/wegbl/WebGLGraphics', function () { - 'use strict'; - - var expect = chai.expect; - var WebGLGraphics = PIXI.WebGLGraphics; - - it('Module exists', function () { - expect(WebGLGraphics).to.be.a('function'); - }); - - it('Members exist', function () { - expect(WebGLGraphics).itself.to.respondTo('renderGraphics'); - expect(WebGLGraphics).itself.to.respondTo('updateGraphics'); - expect(WebGLGraphics).itself.to.respondTo('buildRectangle'); - expect(WebGLGraphics).itself.to.respondTo('buildRoundedRectangle'); - expect(WebGLGraphics).itself.to.respondTo('buildCircle'); - expect(WebGLGraphics).itself.to.respondTo('buildLine'); - expect(WebGLGraphics).itself.to.respondTo('buildPoly'); - }); -}); diff --git a/test/unit/pixi/renderers/webgl/WebGLRenderer.js b/test/unit/pixi/renderers/webgl/WebGLRenderer.js deleted file mode 100644 index 1680a80..0000000 --- a/test/unit/pixi/renderers/webgl/WebGLRenderer.js +++ /dev/null @@ -1,49 +0,0 @@ -describe('renderers/webgl/WebGLRenderer', function () { - 'use strict'; - - var expect = chai.expect; - var WebGLRenderer = PIXI.WebGLRenderer; - - it('Module exists', function () { - expect(WebGLRenderer).to.be.a('function'); - }); - - // Skip tests if WebGL is not available (WebGL not supported in Travis CI) - try { - var renderer = new WebGLRenderer(400, 300, {}); - renderer.destroy(); - } catch (error) { - return; - } - - it('Destroy renderer', function () { - var renderer = new WebGLRenderer(400, 300, {}); - renderer.destroy(); - }); - - describe('.autoResize', function () { - it('Should automatically resize view if enabled', function () { - var renderer = new WebGLRenderer(200, 200, { - autoResize: true - }); - - expect(renderer.view.style.width).to.equal('200px'); - }); - - it('Should not automatically resize view if disabled', function () { - var renderer = new WebGLRenderer(200, 200, { - autoResize: false - }); - - expect(renderer.view.style.width).to.equal(''); - }); - - it('Should not automatically resize view if not specified', function () { - var renderer = new WebGLRenderer(200, 200, { - resolution: 2 - }); - - expect(renderer.view.style.width).to.equal(''); - }); - }); -}); diff --git a/test/unit/pixi/renderers/webgl/WebGLShaders.js b/test/unit/pixi/renderers/webgl/WebGLShaders.js deleted file mode 100644 index 6e33e4f..0000000 --- a/test/unit/pixi/renderers/webgl/WebGLShaders.js +++ /dev/null @@ -1,13 +0,0 @@ -describe('renderers/webgl/WebGLShaders', function () { - 'use strict'; - - var expect = chai.expect; - - it('Module members exist', function () { - - expect(PIXI).to.respondTo('CompileVertexShader'); - expect(PIXI).to.respondTo('CompileFragmentShader'); - expect(PIXI).to.respondTo('_CompileShader'); - expect(PIXI).to.respondTo('compileProgram'); - }); -}); diff --git a/test/unit/pixi/renderers/webgl/WebGLSpriteBatch.js b/test/unit/pixi/renderers/webgl/WebGLSpriteBatch.js deleted file mode 100644 index e662b63..0000000 --- a/test/unit/pixi/renderers/webgl/WebGLSpriteBatch.js +++ /dev/null @@ -1,10 +0,0 @@ -describe('renderers/webgl/utils/WebGLSpriteBatch', function () { - 'use strict'; - - var expect = chai.expect; - var WebGLSpriteBatch = PIXI.WebGLSpriteBatch; - - it('Module exists', function () { - expect(WebGLSpriteBatch).to.be.a('function'); - }); -}); diff --git a/test/unit/pixi/text/BitmapText.js b/test/unit/pixi/text/BitmapText.js deleted file mode 100644 index 9388e3d..0000000 --- a/test/unit/pixi/text/BitmapText.js +++ /dev/null @@ -1,10 +0,0 @@ -describe('pixi/text/BitmapText', function () { - 'use strict'; - - var expect = chai.expect; - var BitmapText = PIXI.BitmapText; - - it('Module exists', function () { - expect(BitmapText).to.be.a('function'); - }); -}); diff --git a/test/unit/pixi/text/Text.js b/test/unit/pixi/text/Text.js deleted file mode 100644 index 9bc9ac5..0000000 --- a/test/unit/pixi/text/Text.js +++ /dev/null @@ -1,10 +0,0 @@ -describe('pixi/text/Text', function () { - 'use strict'; - - var expect = chai.expect; - var Text = PIXI.Text; - - it('Module exists', function () { - expect(Text).to.be.a('function'); - }); -}); diff --git a/test/unit/pixi/textures/BaseTexture.js b/test/unit/pixi/textures/BaseTexture.js deleted file mode 100644 index 502b724..0000000 --- a/test/unit/pixi/textures/BaseTexture.js +++ /dev/null @@ -1,11 +0,0 @@ -describe('pixi/textures/BaseTexture', function () { - 'use strict'; - - var expect = chai.expect; - var BaseTexture = PIXI.BaseTexture; - - it('Module exists', function () { - expect(BaseTexture).to.be.a('function'); - expect(PIXI).to.have.property('BaseTextureCache').and.to.be.an('object'); - }); -}); diff --git a/test/unit/pixi/textures/RenderTexture.js b/test/unit/pixi/textures/RenderTexture.js deleted file mode 100644 index 96acdb4..0000000 --- a/test/unit/pixi/textures/RenderTexture.js +++ /dev/null @@ -1,15 +0,0 @@ -describe('pixi/textures/RenderTexture', function () { - 'use strict'; - - var expect = chai.expect; - var RenderTexture = PIXI.RenderTexture; - - it('Module exists', function () { - expect(RenderTexture).to.be.a('function'); - }); - - it('Confirm new instance', function (done) { - var texture = new RenderTexture(100, 100, new PIXI.CanvasRenderer()); - pixi_textures_RenderTexture_confirmNew(texture, done); - }); -}); diff --git a/test/unit/pixi/textures/Texture.js b/test/unit/pixi/textures/Texture.js deleted file mode 100644 index 090f64d..0000000 --- a/test/unit/pixi/textures/Texture.js +++ /dev/null @@ -1,26 +0,0 @@ -describe('pixi/textures/Texture', function () { - 'use strict'; - - var expect = chai.expect; - var Texture = PIXI.Texture; - - it('Module exists', function () { - expect(Texture).to.be.a('function'); - expect(PIXI).to.have.property('TextureCache').and.to.be.an('object'); - }); - - it('Members exist', function () { - expect(Texture).itself.to.respondTo('fromImage'); - expect(Texture).itself.to.respondTo('fromFrame'); - expect(Texture).itself.to.respondTo('fromCanvas'); - expect(Texture).itself.to.respondTo('addTextureToCache'); - expect(Texture).itself.to.respondTo('removeTextureFromCache'); - - // expect(Texture).itself.to.have.deep.property('frameUpdates.length', 0); - }); - - it('Confirm new instance', function (done) { - var texture = Texture.fromImage('/base/test/textures/bunny.png'); - pixi_textures_Texture_confirmNew(texture, done); - }); -}); diff --git a/test/unit/pixi/utils/Detector.js b/test/unit/pixi/utils/Detector.js deleted file mode 100644 index 4cf6008..0000000 --- a/test/unit/pixi/utils/Detector.js +++ /dev/null @@ -1,10 +0,0 @@ -describe('pixi/utils/Detector', function () { - 'use strict'; - - var expect = chai.expect; - var autoDetectRenderer = PIXI.autoDetectRenderer; - - it('Module exists', function () { - expect(autoDetectRenderer).to.be.a('function'); - }); -}); diff --git a/test/unit/pixi/utils/EventTarget.js b/test/unit/pixi/utils/EventTarget.js deleted file mode 100644 index 1cfc3a4..0000000 --- a/test/unit/pixi/utils/EventTarget.js +++ /dev/null @@ -1,361 +0,0 @@ -describe('pixi/utils/EventTarget', function () { - 'use strict'; - - var expect = chai.expect; - - var Clazz, PClazz, obj, pobj, obj2; - beforeEach(function () { - Clazz = function () {}; - PClazz = function () {}; - - PIXI.EventTarget.mixin(Clazz.prototype); - PIXI.EventTarget.mixin(PClazz.prototype); - - obj = new Clazz(); - obj2 = new Clazz(); - pobj = new PClazz(); - - obj.parent = pobj; - obj2.parent = obj; - }); - - it('Module exists', function () { - expect(PIXI.EventTarget).to.be.an('object'); - }); - - it('Confirm new instance', function () { - pixi_utils_EventTarget_confirm(obj); - }); - - it('simple on/emit case works', function () { - var myData = {}; - - obj.on('myevent', function (event) { - pixi_utils_EventTarget_Event_confirm(event, obj, myData); - }); - - obj.emit('myevent', myData); - }); - - it('simple once case works', function () { - var called = 0; - - obj.once('myevent', function() { called++; }); - - obj.emit('myevent'); - obj.emit('myevent'); - obj.emit('myevent'); - obj.emit('myevent'); - obj.emit('myevent'); - - expect(called).to.equal(1); - }); - - it('simple off case works', function (done) { - function onMyEvent() { - done(new Error('Event listener should not have been called')); - } - - obj.on('myevent', onMyEvent); - obj.off('myevent', onMyEvent); - obj.emit('myevent'); - - done(); - }); - - it('simple propagation case works', function (done) { - var myData = {}; - - pobj.on('myevent', function () { - done(); - }); - - obj.emit('myevent'); - }); - - it('simple stopPropagation case works', function (done) { - var myData = {}; - - pobj.on('myevent', function () { - done(new Error('Event listener should not have been called on the parent element')); - }); - - obj.on('myevent', function (evt) { - evt.stopPropagation(); - }); - - obj.emit('myevent'); - - done(); - }); - - it('simple stopImmediatePropagation case works', function (done) { - var myData = {}; - - pobj.on('myevent', function () { - done(new Error('Event listener should not have been called on the parent')); - }); - - obj.on('myevent', function (evt) { - evt.stopImmediatePropagation(); - }); - - obj.on('myevent', function () { - done(new Error('Event listener should not have been called on the second')); - }); - - obj.emit('myevent'); - - done(); - }); - - it('multiple dispatches work properly', function () { - var called = 0; - - function onMyEvent() { - called++; - } - - obj.on('myevent', onMyEvent); - obj.emit('myevent'); - obj.emit('myevent'); - obj.emit('myevent'); - obj.emit('myevent'); - - expect(called).to.equal(4); - }); - - it('multiple events work properly', function () { - var called = 0; - - function onMyEvent() { - called++; - } - - obj.on('myevent1', onMyEvent); - obj.on('myevent2', onMyEvent); - obj.on('myevent3', onMyEvent); - obj.emit('myevent1'); - obj.emit('myevent2'); - obj.emit('myevent3'); - - expect(called).to.equal(3); - }); - - it('multiple events one removed works properly', function () { - var called = 0; - - function onMyEvent() { - called++; - } - - obj.on('myevent1', onMyEvent); - obj.on('myevent2', onMyEvent); - obj.on('myevent3', onMyEvent); - - obj.emit('myevent1'); - obj.emit('myevent2'); - obj.emit('myevent3'); - - obj.off('myevent2', onMyEvent); - - obj.emit('myevent1'); - obj.emit('myevent2'); - obj.emit('myevent3'); - - expect(called).to.equal(5); - }); - - it('multiple handlers for one event with some removed', function () { - var called = 0; - - var onMyEvent = function () { - called++; - }, - onMyEvent2 = function () { - called++; - }; - - // add 2 handlers and confirm they both get called - obj.on('myevent', onMyEvent); - obj.on('myevent', onMyEvent); - obj.on('myevent', onMyEvent2); - obj.on('myevent', onMyEvent2); - - obj.emit('myevent'); - - expect(called).to.equal(4); - - // remove one of the handlers, emit again, then ensure 1 more call is made - obj.off('myevent', onMyEvent); - - obj.emit('myevent'); - - expect(called).to.equal(6); - }); - - it('calls to off without a handler do nothing', function () { - var called = 0; - - var onMyEvent = function () { - called++; - }; - - obj.on('myevent', onMyEvent); - obj.on('myevent', onMyEvent); - - obj.emit('myevent'); - - expect(called).to.equal(2); - - obj.off('myevent'); - - obj.emit('myevent'); - - expect(called).to.equal(4); - - obj.off('myevent', onMyEvent); - - obj.emit('myevent'); - - expect(called).to.equal(4); - }); - - it('handles multiple instances with the same prototype', function () { - var called = 0; - - function onMyEvent(e) { - called++; - } - - obj.on('myevent1', onMyEvent); - obj.on('myevent2', onMyEvent); - - obj2.istwo = true; - obj2.on('myevent1', onMyEvent); - obj2.on('myevent2', onMyEvent); - - obj.emit('myevent1'); - obj.emit('myevent2'); - obj2.emit('myevent1'); - obj2.emit('myevent2'); - - //we emit 4 times, but since obj2 is a child of obj the event should bubble - //up to obj and show up there as well. So the obj2.emit() calls each increment - //the counter twice. - expect(called).to.equal(6); - }); - - it('is backwards compatible with older .dispatchEvent({})', function () { - var called = 0, - data = { - some: 'thing', - hello: true - }; - - function onMyEvent(event) { - pixi_utils_EventTarget_Event_confirm(event, obj, data); - - called++; - } - - obj.on('myevent1', onMyEvent); - obj.on('myevent2', onMyEvent); - obj.on('myevent3', onMyEvent); - - data.type = 'myevent1'; - obj.emit(data); - - data.type = 'myevent2'; - obj.emit(data); - - data.type = 'myevent3'; - obj.emit(data); - - obj.off('myevent2', onMyEvent); - - data.type = 'myevent1'; - obj.emit(data); - - data.type = 'myevent2'; - obj.emit(data); - - data.type = 'myevent3'; - obj.emit(data); - - expect(called).to.equal(5); - }); - - it('is backwards compatible with older .call(this)', function () { - var Fn = function() { - PIXI.EventTarget.call(this); - }, - o = new Fn(); - - pixi_utils_EventTarget_confirm(o); - }); - - it('is backwards compatible with older .addEventListener("")', function () { - var called = 0, - data = { - some: 'thing', - hello: true - }; - - function onMyEvent(event) { - pixi_utils_EventTarget_Event_confirm(event, obj, data); - - called++; - } - - obj.addEventListener('myevent1', onMyEvent); - obj.addEventListener('myevent2', onMyEvent); - obj.addEventListener('myevent3', onMyEvent); - - data.type = 'myevent1'; - obj.emit(data); - - data.type = 'myevent2'; - obj.emit(data); - - data.type = 'myevent3'; - obj.emit(data); - - obj.off('myevent2', onMyEvent); - - data.type = 'myevent1'; - obj.emit(data); - - data.type = 'myevent2'; - obj.emit(data); - - data.type = 'myevent3'; - obj.emit(data); - - expect(called).to.equal(5); - }); - - it('event remove during emit call properly', function () { - var called = 0; - - function cb1() { - called++; - obj.off('myevent', cb1); - } - function cb2() { - called++; - obj.off('myevent', cb2); - } - function cb3() { - called++; - obj.off('myevent', cb3); - } - - obj.on('myevent', cb1); - obj.on('myevent', cb2); - obj.on('myevent', cb3); - obj.emit('myevent', ''); - - expect(called).to.equal(3); - }); -}); diff --git a/test/unit/pixi-v2/InteractionManager.js b/test/unit/pixi-v2/InteractionManager.js new file mode 100644 index 0000000..ed3001f --- /dev/null +++ b/test/unit/pixi-v2/InteractionManager.js @@ -0,0 +1,10 @@ +describe('pixi/InteractionManager', function () { + 'use strict'; + + var expect = chai.expect; + var InteractionManager = PIXI.InteractionManager; + + it('Module exists', function () { + expect(InteractionManager).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/Pixi.js b/test/unit/pixi-v2/Pixi.js new file mode 100644 index 0000000..27debc1 --- /dev/null +++ b/test/unit/pixi-v2/Pixi.js @@ -0,0 +1,9 @@ +describe('pixi/Pixi', function () { + 'use strict'; + + var expect = chai.expect; + + it('Module exists', function () { + expect(global).to.have.property('PIXI').and.to.be.an('object'); + }); +}); diff --git a/test/unit/pixi-v2/core/Circle.js b/test/unit/pixi-v2/core/Circle.js new file mode 100644 index 0000000..fbcfa17 --- /dev/null +++ b/test/unit/pixi-v2/core/Circle.js @@ -0,0 +1,21 @@ +describe('pixi/core/Circle', function () { + 'use strict'; + + var expect = chai.expect; + var Circle = PIXI.Circle; + + it('Module exists', function () { + expect(Circle).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Circle(); + pixi_core_Circle_confirmNewCircle(obj); + }); + + it("getBounds should return Rectangle that bounds the circle", function() { + var obj = new Circle(100, 250, 50); + var bounds = obj.getBounds(); + pixi_core_Circle_isBoundedByRectangle(obj, bounds); + }); +}); diff --git a/test/unit/pixi-v2/core/Ellipse.js b/test/unit/pixi-v2/core/Ellipse.js new file mode 100644 index 0000000..026b56f --- /dev/null +++ b/test/unit/pixi-v2/core/Ellipse.js @@ -0,0 +1,24 @@ +describe('pixi/core/Ellipse', function () { + 'use strict'; + + var expect = chai.expect; + var Ellipse = PIXI.Ellipse; + + it('Module exists', function () { + expect(Ellipse).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Ellipse(); + + expect(obj).to.be.an.instanceof(Ellipse); + expect(obj).to.respondTo('clone'); + expect(obj).to.respondTo('contains'); + expect(obj).to.respondTo('getBounds'); + + expect(obj).to.have.property('x', 0); + expect(obj).to.have.property('y', 0); + expect(obj).to.have.property('width', 0); + expect(obj).to.have.property('height', 0); + }); +}); diff --git a/test/unit/pixi-v2/core/Matrix.js b/test/unit/pixi-v2/core/Matrix.js new file mode 100644 index 0000000..da75e2e --- /dev/null +++ b/test/unit/pixi-v2/core/Matrix.js @@ -0,0 +1,14 @@ +describe('pixi/core/Matrix', function () { + 'use strict'; + + var expect = chai.expect; + + it('Matrix exists', function () { + expect(PIXI.Matrix).to.be.an('function'); + }); + + it('Confirm new Matrix', function () { + var matrix = new PIXI.Matrix(); + pixi_core_Matrix_confirmNewMatrix(matrix); + }); +}); diff --git a/test/unit/pixi-v2/core/Point.js b/test/unit/pixi-v2/core/Point.js new file mode 100644 index 0000000..c4d5163 --- /dev/null +++ b/test/unit/pixi-v2/core/Point.js @@ -0,0 +1,15 @@ +describe('pixi/core/Point', function () { + 'use strict'; + + var expect = chai.expect; + var Point = PIXI.Point; + + it('Module exists', function () { + expect(Point).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Point(); + pixi_core_Point_confirm(obj, 0, 0); + }); +}); diff --git a/test/unit/pixi-v2/core/Polygon.js b/test/unit/pixi-v2/core/Polygon.js new file mode 100644 index 0000000..dc8c918 --- /dev/null +++ b/test/unit/pixi-v2/core/Polygon.js @@ -0,0 +1,20 @@ +describe('pixi/core/Polygon', function () { + 'use strict'; + + var expect = chai.expect; + var Polygon = PIXI.Polygon; + + it('Module exists', function () { + expect(Polygon).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Polygon(); + + expect(obj).to.be.an.instanceof(Polygon); + expect(obj).to.respondTo('clone'); + expect(obj).to.respondTo('contains'); + + expect(obj).to.have.deep.property('points.length', 0); + }); +}); diff --git a/test/unit/pixi-v2/core/Rectangle.js b/test/unit/pixi-v2/core/Rectangle.js new file mode 100644 index 0000000..d43316e --- /dev/null +++ b/test/unit/pixi-v2/core/Rectangle.js @@ -0,0 +1,15 @@ +describe('pixi/core/Rectangle', function () { + 'use strict'; + + var expect = chai.expect; + var Rectangle = PIXI.Rectangle; + + it('Module exists', function () { + expect(Rectangle).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var rect = new Rectangle(); + pixi_core_Rectangle_confirm(rect, 0, 0, 0, 0); + }); +}); diff --git a/test/unit/pixi-v2/display/DisplayObject.js b/test/unit/pixi-v2/display/DisplayObject.js new file mode 100644 index 0000000..044acf8 --- /dev/null +++ b/test/unit/pixi-v2/display/DisplayObject.js @@ -0,0 +1,21 @@ +describe('pixi/display/DisplayObject', function () { + 'use strict'; + + var expect = chai.expect; + var DisplayObject = PIXI.DisplayObject; + + it('Module exists', function () { + expect(DisplayObject).to.be.a('function'); + // expect(PIXI).to.have.property('visibleCount', 0); + }); + + it('Confirm new instance', function () { + var obj = new DisplayObject(); + + pixi_display_DisplayObject_confirmNew(obj); + expect(obj).to.have.property('hitArea', null); + expect(obj).to.have.property('interactive', false); + expect(obj).to.have.property('renderable', false); + expect(obj).to.have.property('stage', null); + }); +}); diff --git a/test/unit/pixi-v2/display/DisplayObjectContainer.js b/test/unit/pixi-v2/display/DisplayObjectContainer.js new file mode 100644 index 0000000..15a3376 --- /dev/null +++ b/test/unit/pixi-v2/display/DisplayObjectContainer.js @@ -0,0 +1,67 @@ +describe('pixi/display/DisplayObjectContainer', function () { + 'use strict'; + + var expect = chai.expect; + var DisplayObjectContainer = PIXI.DisplayObjectContainer; + + it('Module exists', function () { + expect(DisplayObjectContainer).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new DisplayObjectContainer(); + + pixi_display_DisplayObjectContainer_confirmNew(obj); + expect(obj).to.have.property('hitArea', null); + expect(obj).to.have.property('interactive', false); + expect(obj).to.have.property('renderable', false); + expect(obj).to.have.property('stage', null); + }); + + it('Gets child index', function() { + var container = new PIXI.DisplayObjectContainer(); + var children = []; + for (var i = 0; i < 10; i++) { + var child = new PIXI.DisplayObject(); + children.push(child); + container.addChild(child); + } + + for (i = 0; i < children.length; i++) { + expect(i).to.eql(container.getChildIndex(children[i])); + } + }); + + it('throws error when trying to get index of not a child', function() { + var container = new PIXI.DisplayObjectContainer(); + var child = new PIXI.DisplayObject(); + + expect(function() { container.getChildIndex(child); }).to.throw(); + }); + + it('Sets child index', function() { + var container = new PIXI.DisplayObjectContainer(); + var children = []; + + for (var i = 0; i < 10; i++) { + var child = new PIXI.DisplayObject(); + children.push(child); + container.addChild(child); + } + children.reverse(); + + for (i = 0; i < children.length; i++) { + container.setChildIndex(children[i], i); + expect(i).to.eql(container.getChildIndex(children[i])); + } + }); + + it('throws error when trying to set incorect index', function() { + var container = new PIXI.DisplayObjectContainer(); + var child = new PIXI.DisplayObject(); + container.addChild(child); + + expect(function() { container.setChildIndex(child, -1); }).to.throw(); + expect(function() { container.setChildIndex(child, 1); }).to.throw(); + }); +}); diff --git a/test/unit/pixi-v2/display/MovieClip.js b/test/unit/pixi-v2/display/MovieClip.js new file mode 100644 index 0000000..f3c6c6a --- /dev/null +++ b/test/unit/pixi-v2/display/MovieClip.js @@ -0,0 +1,33 @@ +describe('pixi/display/MovieClip', function () { + 'use strict'; + + var expect = chai.expect; + var MovieClip = PIXI.MovieClip; + var Texture = PIXI.Texture; + + it('Module exists', function () { + expect(MovieClip).to.be.a('function'); + }); + + it('Confirm new instance', function (done) { + var texture = Texture.fromImage('/base/test/textures/SpriteSheet-Explosion.png'); + var obj = new MovieClip([texture]); + + pixi_display_Sprite_confirmNew(obj, done); + + expect(obj).to.be.an.instanceof(MovieClip); + expect(obj).to.respondTo('stop'); + expect(obj).to.respondTo('play'); + expect(obj).to.respondTo('gotoAndStop'); + expect(obj).to.respondTo('gotoAndPlay'); + expect(obj).to.respondTo('updateTransform'); + + expect(obj).to.have.deep.property('textures.length', 1); + expect(obj).to.have.deep.property('textures[0]', texture); + expect(obj).to.have.property('animationSpeed', 1); + expect(obj).to.have.property('loop', true); + expect(obj).to.have.property('onComplete', null); + expect(obj).to.have.property('currentFrame', 0); + expect(obj).to.have.property('playing', false); + }); +}); diff --git a/test/unit/pixi-v2/display/Sprite.js b/test/unit/pixi-v2/display/Sprite.js new file mode 100644 index 0000000..30c8076 --- /dev/null +++ b/test/unit/pixi-v2/display/Sprite.js @@ -0,0 +1,28 @@ +describe('pixi/display/Sprite', function () { + 'use strict'; + + var expect = chai.expect; + var Sprite = PIXI.Sprite; + var Texture = PIXI.Texture; + + it('Module exists', function () { + expect(Sprite).to.be.a('function'); + expect(PIXI).to.have.deep.property('blendModes.NORMAL', 0); + expect(PIXI).to.have.deep.property('blendModes.ADD', 1); + expect(PIXI).to.have.deep.property('blendModes.MULTIPLY', 2); + expect(PIXI).to.have.deep.property('blendModes.SCREEN', 3); + }); + + + it('Members exist', function () { + expect(Sprite).itself.to.respondTo('fromImage'); + expect(Sprite).itself.to.respondTo('fromFrame'); + }); + + it('Confirm new instance', function (done) { + var texture = Texture.fromImage('/base/test/textures/SpriteSheet-Aliens.png'); + var obj = new Sprite(texture); + + pixi_display_Sprite_confirmNew(obj, done); + }); +}); diff --git a/test/unit/pixi-v2/display/Stage.js b/test/unit/pixi-v2/display/Stage.js new file mode 100644 index 0000000..6974c2e --- /dev/null +++ b/test/unit/pixi-v2/display/Stage.js @@ -0,0 +1,49 @@ +describe('pixi/display/Stage', function () { + 'use strict'; + + var expect = chai.expect; + var Stage = PIXI.Stage; + var InteractionManager = PIXI.InteractionManager; + var Rectangle = PIXI.Rectangle; + + it('Module exists', function () { + expect(Stage).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Stage(null, true); + + pixi_display_DisplayObjectContainer_confirmNew(obj); + + expect(obj).to.be.an.instanceof(Stage); + expect(obj).to.respondTo('updateTransform'); + expect(obj).to.respondTo('setBackgroundColor'); + expect(obj).to.respondTo('getMousePosition'); + // FIXME: duplicate member in DisplayObject + pixi_core_Matrix_confirmNewMatrix(obj.worldTransform); + // FIXME: convert arg to bool in constructor + expect(obj).to.have.property('interactive', true); + + expect(obj).to.have.property('interactionManager') + .and.to.be.an.instanceof(InteractionManager) + .and.to.have.property('stage', obj); + + expect(obj).to.have.property('dirty', true); + + expect(obj).to.have.property('stage', obj); + + expect(obj).to.have.property('hitArea') + .and.to.be.an.instanceof(Rectangle); + pixi_core_Rectangle_confirm(obj.hitArea, 0, 0, 100000, 100000); + + expect(obj).to.have.property('backgroundColor', 0x000000); + expect(obj).to.have.deep.property('backgroundColorSplit.length', 3); + expect(obj).to.have.deep.property('backgroundColorSplit[0]', 0); + expect(obj).to.have.deep.property('backgroundColorSplit[1]', 0); + expect(obj).to.have.deep.property('backgroundColorSplit[2]', 0); + expect(obj).to.have.property('backgroundColorString', '#000000'); + + + expect(obj).to.have.property('worldVisible', true); + }); +}); diff --git a/test/unit/pixi-v2/extras/Rope.js b/test/unit/pixi-v2/extras/Rope.js new file mode 100644 index 0000000..05885ac --- /dev/null +++ b/test/unit/pixi-v2/extras/Rope.js @@ -0,0 +1,31 @@ +describe('pixi/extras/Rope', function () { + 'use strict'; + + var expect = chai.expect; + var Rope = PIXI.Rope; + var Texture = PIXI.Texture; + var Point = PIXI.Point; + + it('Module exists', function () { + expect(Rope).to.be.a('function'); + }); + + it('Confirm new instance', function () { + + var texture = Texture.fromImage('/base/test/textures/bunny.png'); + + // TODO-Alvin + // Same as Strip + + // var obj = new Rope(texture, [new Point(), new Point(5, 10), new Point(10, 20)]); + + // pixi_extras_Strip_confirmNew(obj); + + // expect(obj).to.be.an.instanceof(Rope); + // expect(obj).to.respondTo('refresh'); + // expect(obj).to.respondTo('updateTransform'); + // expect(obj).to.respondTo('setTexture'); + + // TODO: Test properties + }); +}); diff --git a/test/unit/pixi-v2/extras/Spine.js b/test/unit/pixi-v2/extras/Spine.js new file mode 100644 index 0000000..0708bc0 --- /dev/null +++ b/test/unit/pixi-v2/extras/Spine.js @@ -0,0 +1,10 @@ +describe('pixi/extras/Spine', function () { + 'use strict'; + + var expect = chai.expect; + var Spine = PIXI.Spine; + + it('Module exists', function () { + expect(Spine).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/extras/Strip.js b/test/unit/pixi-v2/extras/Strip.js new file mode 100644 index 0000000..230af90 --- /dev/null +++ b/test/unit/pixi-v2/extras/Strip.js @@ -0,0 +1,26 @@ +describe('pixi/extras/Strip', function () { + 'use strict'; + + var expect = chai.expect; + var Strip = PIXI.Strip; + var Texture = PIXI.Texture; + + it('Module exists', function () { + expect(Strip).to.be.a('function'); + }); + + it('Confirm new instance', function () { + + + // TODO-Alvin + // We tweaked it to make it pass the tests, but the whole strip class needs + // to be re-coded + + var texture = Texture.fromImage('/base/test/textures/bunny.png'); + + // var obj = new Strip(texture, 20, 10000); + + + // pixi_extras_Strip_confirmNew(obj); + }); +}); diff --git a/test/unit/pixi-v2/extras/TilingSprite.js b/test/unit/pixi-v2/extras/TilingSprite.js new file mode 100644 index 0000000..56aea14 --- /dev/null +++ b/test/unit/pixi-v2/extras/TilingSprite.js @@ -0,0 +1,24 @@ +describe('pixi/extras/TilingSprite', function () { + 'use strict'; + + var expect = chai.expect; + var TilingSprite = PIXI.TilingSprite; + var Texture = PIXI.Texture; + + it('Module exists', function () { + expect(TilingSprite).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var texture = Texture.fromImage('/base/test/textures/bunny.png'); + var obj = new TilingSprite(texture, 6000, 12000); + + pixi_display_DisplayObjectContainer_confirmNew(obj); + + expect(obj).to.be.an.instanceof(TilingSprite); + expect(obj).to.respondTo('setTexture'); + expect(obj).to.respondTo('onTextureUpdate'); + + // TODO: Test properties + }); +}); diff --git a/test/unit/pixi-v2/filters/FilterBlock.js b/test/unit/pixi-v2/filters/FilterBlock.js new file mode 100644 index 0000000..870cec0 --- /dev/null +++ b/test/unit/pixi-v2/filters/FilterBlock.js @@ -0,0 +1,10 @@ +describe('pixi/filters/FilterBlock', function () { + 'use strict'; + + var expect = chai.expect; + var FilterBlock = PIXI.FilterBlock; + + it('Module exists', function () { + expect(FilterBlock).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/AssetLoader.js b/test/unit/pixi-v2/loaders/AssetLoader.js new file mode 100644 index 0000000..a0aa0b5 --- /dev/null +++ b/test/unit/pixi-v2/loaders/AssetLoader.js @@ -0,0 +1,10 @@ +describe('pixi/loaders/AssetLoader', function () { + 'use strict'; + + var expect = chai.expect; + var AssetLoader = PIXI.AssetLoader; + + it('Module exists', function () { + expect(AssetLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/BitmapFontLoader.js b/test/unit/pixi-v2/loaders/BitmapFontLoader.js new file mode 100644 index 0000000..046f018 --- /dev/null +++ b/test/unit/pixi-v2/loaders/BitmapFontLoader.js @@ -0,0 +1,9 @@ +describe('pixi/loaders/BitmapFontLoader', function () { + 'use strict'; + + var expect = chai.expect; + + it('Module exists', function () { + expect(PIXI.BitmapFontLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/ImageLoader.js b/test/unit/pixi-v2/loaders/ImageLoader.js new file mode 100644 index 0000000..8b1f556 --- /dev/null +++ b/test/unit/pixi-v2/loaders/ImageLoader.js @@ -0,0 +1,10 @@ +describe('pixi/loaders/ImageLoader', function () { + 'use strict'; + + var expect = chai.expect; + var ImageLoader = PIXI.ImageLoader; + + it('Module exists', function () { + expect(ImageLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/JsonLoader.js b/test/unit/pixi-v2/loaders/JsonLoader.js new file mode 100644 index 0000000..c577e83 --- /dev/null +++ b/test/unit/pixi-v2/loaders/JsonLoader.js @@ -0,0 +1,10 @@ +describe('pixi/loaders/JsonLoader', function () { + 'use strict'; + + var expect = chai.expect; + var JsonLoader = PIXI.JsonLoader; + + it('Module exists', function () { + expect(JsonLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/SpineLoader.js b/test/unit/pixi-v2/loaders/SpineLoader.js new file mode 100644 index 0000000..fdcc0b8 --- /dev/null +++ b/test/unit/pixi-v2/loaders/SpineLoader.js @@ -0,0 +1,10 @@ +describe('pixi/loaders/SpineLoader', function () { + 'use strict'; + + var expect = chai.expect; + var SpineLoader = PIXI.SpineLoader; + + it('Module exists', function () { + expect(SpineLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/SpriteSheetLoader.js b/test/unit/pixi-v2/loaders/SpriteSheetLoader.js new file mode 100644 index 0000000..57beb27 --- /dev/null +++ b/test/unit/pixi-v2/loaders/SpriteSheetLoader.js @@ -0,0 +1,10 @@ +describe('pixi/loaders/SpriteSheetLoader', function () { + 'use strict'; + + var expect = chai.expect; + var SpriteSheetLoader = PIXI.SpriteSheetLoader; + + it('Module exists', function () { + expect(SpriteSheetLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/primitives/Graphics.js b/test/unit/pixi-v2/primitives/Graphics.js new file mode 100644 index 0000000..f3849eb --- /dev/null +++ b/test/unit/pixi-v2/primitives/Graphics.js @@ -0,0 +1,44 @@ +describe('pixi/primitives/Graphics', function () { + 'use strict'; + + var expect = chai.expect; + var Graphics = PIXI.Graphics; + + it('Module exists', function () { + expect(Graphics).to.be.a('function'); + + expect(Graphics).itself.to.have.property('POLY', 0); + expect(Graphics).itself.to.have.property('RECT', 1); + expect(Graphics).itself.to.have.property('CIRC', 2); + expect(Graphics).itself.to.have.property('ELIP', 3); + expect(Graphics).itself.to.have.property('RREC', 4); + }); + + it('Confirm new instance', function () { + var obj = new Graphics(); + + pixi_display_DisplayObjectContainer_confirmNew(obj); + + expect(obj).to.be.an.instanceof(Graphics); + expect(obj).to.respondTo('lineStyle'); + expect(obj).to.respondTo('lineStyle'); + expect(obj).to.respondTo('moveTo'); + expect(obj).to.respondTo('lineTo'); + expect(obj).to.respondTo('beginFill'); + expect(obj).to.respondTo('endFill'); + expect(obj).to.respondTo('drawRect'); + // expect(obj).to.respondTo('drawRoundedRect'); + expect(obj).to.respondTo('drawCircle'); + expect(obj).to.respondTo('drawEllipse'); + expect(obj).to.respondTo('clear'); + + expect(obj).to.have.property('renderable', true); + expect(obj).to.have.property('fillAlpha', 1); + expect(obj).to.have.property('lineWidth', 0); + expect(obj).to.have.property('width', 0); + expect(obj).to.have.property('height', 0); + expect(obj).to.have.property('lineColor', 0); + expect(obj).to.have.deep.property('graphicsData.length', 0); + // expect(obj).to.have.deep.property('currentPath.points.length', 0); + }); +}); diff --git a/test/unit/pixi-v2/renderers/canvas/CanvasGraphics.js b/test/unit/pixi-v2/renderers/canvas/CanvasGraphics.js new file mode 100644 index 0000000..8f44472 --- /dev/null +++ b/test/unit/pixi-v2/renderers/canvas/CanvasGraphics.js @@ -0,0 +1,15 @@ +describe('renders/canvas/CanvasGraphics', function () { + 'use strict'; + + var expect = chai.expect; + var CanvasGraphics = PIXI.CanvasGraphics; + + it('Module exists', function () { + expect(CanvasGraphics).to.be.a('function'); + }); + + it('Members exist', function () { + expect(CanvasGraphics).itself.to.respondTo('renderGraphics'); + expect(CanvasGraphics).itself.to.respondTo('renderGraphicsMask'); + }); +}); diff --git a/test/unit/pixi-v2/renderers/canvas/CanvasRenderer.js b/test/unit/pixi-v2/renderers/canvas/CanvasRenderer.js new file mode 100644 index 0000000..1646444 --- /dev/null +++ b/test/unit/pixi-v2/renderers/canvas/CanvasRenderer.js @@ -0,0 +1,36 @@ +describe('renderers/canvas/CanvasRenderer', function () { + 'use strict'; + + var expect = chai.expect; + var CanvasRenderer = PIXI.CanvasRenderer; + + it('Module exists', function () { + expect(CanvasRenderer).to.be.a('function'); + }); + + describe('.autoResize', function () { + it('Should automatically resize view if enabled', function () { + var renderer = new CanvasRenderer(200, 200, { + autoResize: true + }); + + expect(renderer.view.style.width).to.equal('200px'); + }); + + it('Should not automatically resize view if disabled', function () { + var renderer = new CanvasRenderer(200, 200, { + autoResize: false + }); + + expect(renderer.view.style.width).to.equal(''); + }); + + it('Should not automatically resize view if not specified', function () { + var renderer = new CanvasRenderer(200, 200, { + resolution: 2 + }); + + expect(renderer.view.style.width).to.equal(''); + }); + }); +}); diff --git a/test/unit/pixi-v2/renderers/webgl/WebGLGraphics.js b/test/unit/pixi-v2/renderers/webgl/WebGLGraphics.js new file mode 100644 index 0000000..5867b28 --- /dev/null +++ b/test/unit/pixi-v2/renderers/webgl/WebGLGraphics.js @@ -0,0 +1,20 @@ +describe('renderers/wegbl/WebGLGraphics', function () { + 'use strict'; + + var expect = chai.expect; + var WebGLGraphics = PIXI.WebGLGraphics; + + it('Module exists', function () { + expect(WebGLGraphics).to.be.a('function'); + }); + + it('Members exist', function () { + expect(WebGLGraphics).itself.to.respondTo('renderGraphics'); + expect(WebGLGraphics).itself.to.respondTo('updateGraphics'); + expect(WebGLGraphics).itself.to.respondTo('buildRectangle'); + expect(WebGLGraphics).itself.to.respondTo('buildRoundedRectangle'); + expect(WebGLGraphics).itself.to.respondTo('buildCircle'); + expect(WebGLGraphics).itself.to.respondTo('buildLine'); + expect(WebGLGraphics).itself.to.respondTo('buildPoly'); + }); +}); diff --git a/test/unit/pixi-v2/renderers/webgl/WebGLRenderer.js b/test/unit/pixi-v2/renderers/webgl/WebGLRenderer.js new file mode 100644 index 0000000..1680a80 --- /dev/null +++ b/test/unit/pixi-v2/renderers/webgl/WebGLRenderer.js @@ -0,0 +1,49 @@ +describe('renderers/webgl/WebGLRenderer', function () { + 'use strict'; + + var expect = chai.expect; + var WebGLRenderer = PIXI.WebGLRenderer; + + it('Module exists', function () { + expect(WebGLRenderer).to.be.a('function'); + }); + + // Skip tests if WebGL is not available (WebGL not supported in Travis CI) + try { + var renderer = new WebGLRenderer(400, 300, {}); + renderer.destroy(); + } catch (error) { + return; + } + + it('Destroy renderer', function () { + var renderer = new WebGLRenderer(400, 300, {}); + renderer.destroy(); + }); + + describe('.autoResize', function () { + it('Should automatically resize view if enabled', function () { + var renderer = new WebGLRenderer(200, 200, { + autoResize: true + }); + + expect(renderer.view.style.width).to.equal('200px'); + }); + + it('Should not automatically resize view if disabled', function () { + var renderer = new WebGLRenderer(200, 200, { + autoResize: false + }); + + expect(renderer.view.style.width).to.equal(''); + }); + + it('Should not automatically resize view if not specified', function () { + var renderer = new WebGLRenderer(200, 200, { + resolution: 2 + }); + + expect(renderer.view.style.width).to.equal(''); + }); + }); +}); diff --git a/test/unit/pixi-v2/renderers/webgl/WebGLShaders.js b/test/unit/pixi-v2/renderers/webgl/WebGLShaders.js new file mode 100644 index 0000000..6e33e4f --- /dev/null +++ b/test/unit/pixi-v2/renderers/webgl/WebGLShaders.js @@ -0,0 +1,13 @@ +describe('renderers/webgl/WebGLShaders', function () { + 'use strict'; + + var expect = chai.expect; + + it('Module members exist', function () { + + expect(PIXI).to.respondTo('CompileVertexShader'); + expect(PIXI).to.respondTo('CompileFragmentShader'); + expect(PIXI).to.respondTo('_CompileShader'); + expect(PIXI).to.respondTo('compileProgram'); + }); +}); diff --git a/test/unit/pixi-v2/renderers/webgl/WebGLSpriteBatch.js b/test/unit/pixi-v2/renderers/webgl/WebGLSpriteBatch.js new file mode 100644 index 0000000..e662b63 --- /dev/null +++ b/test/unit/pixi-v2/renderers/webgl/WebGLSpriteBatch.js @@ -0,0 +1,10 @@ +describe('renderers/webgl/utils/WebGLSpriteBatch', function () { + 'use strict'; + + var expect = chai.expect; + var WebGLSpriteBatch = PIXI.WebGLSpriteBatch; + + it('Module exists', function () { + expect(WebGLSpriteBatch).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/text/BitmapText.js b/test/unit/pixi-v2/text/BitmapText.js new file mode 100644 index 0000000..9388e3d --- /dev/null +++ b/test/unit/pixi-v2/text/BitmapText.js @@ -0,0 +1,10 @@ +describe('pixi/text/BitmapText', function () { + 'use strict'; + + var expect = chai.expect; + var BitmapText = PIXI.BitmapText; + + it('Module exists', function () { + expect(BitmapText).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/text/Text.js b/test/unit/pixi-v2/text/Text.js new file mode 100644 index 0000000..9bc9ac5 --- /dev/null +++ b/test/unit/pixi-v2/text/Text.js @@ -0,0 +1,10 @@ +describe('pixi/text/Text', function () { + 'use strict'; + + var expect = chai.expect; + var Text = PIXI.Text; + + it('Module exists', function () { + expect(Text).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/textures/BaseTexture.js b/test/unit/pixi-v2/textures/BaseTexture.js new file mode 100644 index 0000000..502b724 --- /dev/null +++ b/test/unit/pixi-v2/textures/BaseTexture.js @@ -0,0 +1,11 @@ +describe('pixi/textures/BaseTexture', function () { + 'use strict'; + + var expect = chai.expect; + var BaseTexture = PIXI.BaseTexture; + + it('Module exists', function () { + expect(BaseTexture).to.be.a('function'); + expect(PIXI).to.have.property('BaseTextureCache').and.to.be.an('object'); + }); +}); diff --git a/test/unit/pixi-v2/textures/RenderTexture.js b/test/unit/pixi-v2/textures/RenderTexture.js new file mode 100644 index 0000000..96acdb4 --- /dev/null +++ b/test/unit/pixi-v2/textures/RenderTexture.js @@ -0,0 +1,15 @@ +describe('pixi/textures/RenderTexture', function () { + 'use strict'; + + var expect = chai.expect; + var RenderTexture = PIXI.RenderTexture; + + it('Module exists', function () { + expect(RenderTexture).to.be.a('function'); + }); + + it('Confirm new instance', function (done) { + var texture = new RenderTexture(100, 100, new PIXI.CanvasRenderer()); + pixi_textures_RenderTexture_confirmNew(texture, done); + }); +}); diff --git a/test/unit/pixi-v2/textures/Texture.js b/test/unit/pixi-v2/textures/Texture.js new file mode 100644 index 0000000..090f64d --- /dev/null +++ b/test/unit/pixi-v2/textures/Texture.js @@ -0,0 +1,26 @@ +describe('pixi/textures/Texture', function () { + 'use strict'; + + var expect = chai.expect; + var Texture = PIXI.Texture; + + it('Module exists', function () { + expect(Texture).to.be.a('function'); + expect(PIXI).to.have.property('TextureCache').and.to.be.an('object'); + }); + + it('Members exist', function () { + expect(Texture).itself.to.respondTo('fromImage'); + expect(Texture).itself.to.respondTo('fromFrame'); + expect(Texture).itself.to.respondTo('fromCanvas'); + expect(Texture).itself.to.respondTo('addTextureToCache'); + expect(Texture).itself.to.respondTo('removeTextureFromCache'); + + // expect(Texture).itself.to.have.deep.property('frameUpdates.length', 0); + }); + + it('Confirm new instance', function (done) { + var texture = Texture.fromImage('/base/test/textures/bunny.png'); + pixi_textures_Texture_confirmNew(texture, done); + }); +}); diff --git a/test/unit/pixi-v2/utils/Detector.js b/test/unit/pixi-v2/utils/Detector.js new file mode 100644 index 0000000..4cf6008 --- /dev/null +++ b/test/unit/pixi-v2/utils/Detector.js @@ -0,0 +1,10 @@ +describe('pixi/utils/Detector', function () { + 'use strict'; + + var expect = chai.expect; + var autoDetectRenderer = PIXI.autoDetectRenderer; + + it('Module exists', function () { + expect(autoDetectRenderer).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/utils/EventTarget.js b/test/unit/pixi-v2/utils/EventTarget.js new file mode 100644 index 0000000..1cfc3a4 --- /dev/null +++ b/test/unit/pixi-v2/utils/EventTarget.js @@ -0,0 +1,361 @@ +describe('pixi/utils/EventTarget', function () { + 'use strict'; + + var expect = chai.expect; + + var Clazz, PClazz, obj, pobj, obj2; + beforeEach(function () { + Clazz = function () {}; + PClazz = function () {}; + + PIXI.EventTarget.mixin(Clazz.prototype); + PIXI.EventTarget.mixin(PClazz.prototype); + + obj = new Clazz(); + obj2 = new Clazz(); + pobj = new PClazz(); + + obj.parent = pobj; + obj2.parent = obj; + }); + + it('Module exists', function () { + expect(PIXI.EventTarget).to.be.an('object'); + }); + + it('Confirm new instance', function () { + pixi_utils_EventTarget_confirm(obj); + }); + + it('simple on/emit case works', function () { + var myData = {}; + + obj.on('myevent', function (event) { + pixi_utils_EventTarget_Event_confirm(event, obj, myData); + }); + + obj.emit('myevent', myData); + }); + + it('simple once case works', function () { + var called = 0; + + obj.once('myevent', function() { called++; }); + + obj.emit('myevent'); + obj.emit('myevent'); + obj.emit('myevent'); + obj.emit('myevent'); + obj.emit('myevent'); + + expect(called).to.equal(1); + }); + + it('simple off case works', function (done) { + function onMyEvent() { + done(new Error('Event listener should not have been called')); + } + + obj.on('myevent', onMyEvent); + obj.off('myevent', onMyEvent); + obj.emit('myevent'); + + done(); + }); + + it('simple propagation case works', function (done) { + var myData = {}; + + pobj.on('myevent', function () { + done(); + }); + + obj.emit('myevent'); + }); + + it('simple stopPropagation case works', function (done) { + var myData = {}; + + pobj.on('myevent', function () { + done(new Error('Event listener should not have been called on the parent element')); + }); + + obj.on('myevent', function (evt) { + evt.stopPropagation(); + }); + + obj.emit('myevent'); + + done(); + }); + + it('simple stopImmediatePropagation case works', function (done) { + var myData = {}; + + pobj.on('myevent', function () { + done(new Error('Event listener should not have been called on the parent')); + }); + + obj.on('myevent', function (evt) { + evt.stopImmediatePropagation(); + }); + + obj.on('myevent', function () { + done(new Error('Event listener should not have been called on the second')); + }); + + obj.emit('myevent'); + + done(); + }); + + it('multiple dispatches work properly', function () { + var called = 0; + + function onMyEvent() { + called++; + } + + obj.on('myevent', onMyEvent); + obj.emit('myevent'); + obj.emit('myevent'); + obj.emit('myevent'); + obj.emit('myevent'); + + expect(called).to.equal(4); + }); + + it('multiple events work properly', function () { + var called = 0; + + function onMyEvent() { + called++; + } + + obj.on('myevent1', onMyEvent); + obj.on('myevent2', onMyEvent); + obj.on('myevent3', onMyEvent); + obj.emit('myevent1'); + obj.emit('myevent2'); + obj.emit('myevent3'); + + expect(called).to.equal(3); + }); + + it('multiple events one removed works properly', function () { + var called = 0; + + function onMyEvent() { + called++; + } + + obj.on('myevent1', onMyEvent); + obj.on('myevent2', onMyEvent); + obj.on('myevent3', onMyEvent); + + obj.emit('myevent1'); + obj.emit('myevent2'); + obj.emit('myevent3'); + + obj.off('myevent2', onMyEvent); + + obj.emit('myevent1'); + obj.emit('myevent2'); + obj.emit('myevent3'); + + expect(called).to.equal(5); + }); + + it('multiple handlers for one event with some removed', function () { + var called = 0; + + var onMyEvent = function () { + called++; + }, + onMyEvent2 = function () { + called++; + }; + + // add 2 handlers and confirm they both get called + obj.on('myevent', onMyEvent); + obj.on('myevent', onMyEvent); + obj.on('myevent', onMyEvent2); + obj.on('myevent', onMyEvent2); + + obj.emit('myevent'); + + expect(called).to.equal(4); + + // remove one of the handlers, emit again, then ensure 1 more call is made + obj.off('myevent', onMyEvent); + + obj.emit('myevent'); + + expect(called).to.equal(6); + }); + + it('calls to off without a handler do nothing', function () { + var called = 0; + + var onMyEvent = function () { + called++; + }; + + obj.on('myevent', onMyEvent); + obj.on('myevent', onMyEvent); + + obj.emit('myevent'); + + expect(called).to.equal(2); + + obj.off('myevent'); + + obj.emit('myevent'); + + expect(called).to.equal(4); + + obj.off('myevent', onMyEvent); + + obj.emit('myevent'); + + expect(called).to.equal(4); + }); + + it('handles multiple instances with the same prototype', function () { + var called = 0; + + function onMyEvent(e) { + called++; + } + + obj.on('myevent1', onMyEvent); + obj.on('myevent2', onMyEvent); + + obj2.istwo = true; + obj2.on('myevent1', onMyEvent); + obj2.on('myevent2', onMyEvent); + + obj.emit('myevent1'); + obj.emit('myevent2'); + obj2.emit('myevent1'); + obj2.emit('myevent2'); + + //we emit 4 times, but since obj2 is a child of obj the event should bubble + //up to obj and show up there as well. So the obj2.emit() calls each increment + //the counter twice. + expect(called).to.equal(6); + }); + + it('is backwards compatible with older .dispatchEvent({})', function () { + var called = 0, + data = { + some: 'thing', + hello: true + }; + + function onMyEvent(event) { + pixi_utils_EventTarget_Event_confirm(event, obj, data); + + called++; + } + + obj.on('myevent1', onMyEvent); + obj.on('myevent2', onMyEvent); + obj.on('myevent3', onMyEvent); + + data.type = 'myevent1'; + obj.emit(data); + + data.type = 'myevent2'; + obj.emit(data); + + data.type = 'myevent3'; + obj.emit(data); + + obj.off('myevent2', onMyEvent); + + data.type = 'myevent1'; + obj.emit(data); + + data.type = 'myevent2'; + obj.emit(data); + + data.type = 'myevent3'; + obj.emit(data); + + expect(called).to.equal(5); + }); + + it('is backwards compatible with older .call(this)', function () { + var Fn = function() { + PIXI.EventTarget.call(this); + }, + o = new Fn(); + + pixi_utils_EventTarget_confirm(o); + }); + + it('is backwards compatible with older .addEventListener("")', function () { + var called = 0, + data = { + some: 'thing', + hello: true + }; + + function onMyEvent(event) { + pixi_utils_EventTarget_Event_confirm(event, obj, data); + + called++; + } + + obj.addEventListener('myevent1', onMyEvent); + obj.addEventListener('myevent2', onMyEvent); + obj.addEventListener('myevent3', onMyEvent); + + data.type = 'myevent1'; + obj.emit(data); + + data.type = 'myevent2'; + obj.emit(data); + + data.type = 'myevent3'; + obj.emit(data); + + obj.off('myevent2', onMyEvent); + + data.type = 'myevent1'; + obj.emit(data); + + data.type = 'myevent2'; + obj.emit(data); + + data.type = 'myevent3'; + obj.emit(data); + + expect(called).to.equal(5); + }); + + it('event remove during emit call properly', function () { + var called = 0; + + function cb1() { + called++; + obj.off('myevent', cb1); + } + function cb2() { + called++; + obj.off('myevent', cb2); + } + function cb3() { + called++; + obj.off('myevent', cb3); + } + + obj.on('myevent', cb1); + obj.on('myevent', cb2); + obj.on('myevent', cb3); + obj.emit('myevent', ''); + + expect(called).to.equal(3); + }); +}); diff --git a/test/unit/pixi-v2/utils/Polyk.js b/test/unit/pixi-v2/utils/Polyk.js new file mode 100644 index 0000000..dfc7128 --- /dev/null +++ b/test/unit/pixi-v2/utils/Polyk.js @@ -0,0 +1,14 @@ +describe('pixi/utils/Polyk', function () { + 'use strict'; + + var expect = chai.expect; + var PolyK = PIXI.PolyK; + + it('Module exists', function () { + expect(PolyK).to.be.an('object'); + }); + + it('Members exist', function () { + expect(PolyK).to.respondTo('Triangulate'); + }); +}); diff --git a/test/unit/pixi-v2/utils/Utils.js b/test/unit/pixi-v2/utils/Utils.js new file mode 100644 index 0000000..c97b3c6 --- /dev/null +++ b/test/unit/pixi-v2/utils/Utils.js @@ -0,0 +1,17 @@ +describe('Utils', function () { + 'use strict'; + + var expect = chai.expect; + + it('requestAnimationFrame exists', function () { + expect(global).to.respondTo('requestAnimationFrame'); + }); + + it('cancelAnimationFrame exists', function () { + expect(global).to.respondTo('cancelAnimationFrame'); + }); + + it('requestAnimFrame exists', function () { + expect(global).to.respondTo('requestAnimFrame'); + }); +}); diff --git a/test/unit/pixi/InteractionManager.js b/test/unit/pixi/InteractionManager.js deleted file mode 100644 index ed3001f..0000000 --- a/test/unit/pixi/InteractionManager.js +++ /dev/null @@ -1,10 +0,0 @@ -describe('pixi/InteractionManager', function () { - 'use strict'; - - var expect = chai.expect; - var InteractionManager = PIXI.InteractionManager; - - it('Module exists', function () { - expect(InteractionManager).to.be.a('function'); - }); -}); diff --git a/test/unit/pixi/Pixi.js b/test/unit/pixi/Pixi.js deleted file mode 100644 index 27debc1..0000000 --- a/test/unit/pixi/Pixi.js +++ /dev/null @@ -1,9 +0,0 @@ -describe('pixi/Pixi', function () { - 'use strict'; - - var expect = chai.expect; - - it('Module exists', function () { - expect(global).to.have.property('PIXI').and.to.be.an('object'); - }); -}); diff --git a/test/unit/pixi/core/Circle.js b/test/unit/pixi/core/Circle.js deleted file mode 100644 index fbcfa17..0000000 --- a/test/unit/pixi/core/Circle.js +++ /dev/null @@ -1,21 +0,0 @@ -describe('pixi/core/Circle', function () { - 'use strict'; - - var expect = chai.expect; - var Circle = PIXI.Circle; - - it('Module exists', function () { - expect(Circle).to.be.a('function'); - }); - - it('Confirm new instance', function () { - var obj = new Circle(); - pixi_core_Circle_confirmNewCircle(obj); - }); - - it("getBounds should return Rectangle that bounds the circle", function() { - var obj = new Circle(100, 250, 50); - var bounds = obj.getBounds(); - pixi_core_Circle_isBoundedByRectangle(obj, bounds); - }); -}); diff --git a/test/unit/pixi/core/Ellipse.js b/test/unit/pixi/core/Ellipse.js deleted file mode 100644 index 026b56f..0000000 --- a/test/unit/pixi/core/Ellipse.js +++ /dev/null @@ -1,24 +0,0 @@ -describe('pixi/core/Ellipse', function () { - 'use strict'; - - var expect = chai.expect; - var Ellipse = PIXI.Ellipse; - - it('Module exists', function () { - expect(Ellipse).to.be.a('function'); - }); - - it('Confirm new instance', function () { - var obj = new Ellipse(); - - expect(obj).to.be.an.instanceof(Ellipse); - expect(obj).to.respondTo('clone'); - expect(obj).to.respondTo('contains'); - expect(obj).to.respondTo('getBounds'); - - expect(obj).to.have.property('x', 0); - expect(obj).to.have.property('y', 0); - expect(obj).to.have.property('width', 0); - expect(obj).to.have.property('height', 0); - }); -}); diff --git a/test/unit/pixi/core/Matrix.js b/test/unit/pixi/core/Matrix.js deleted file mode 100644 index da75e2e..0000000 --- a/test/unit/pixi/core/Matrix.js +++ /dev/null @@ -1,14 +0,0 @@ -describe('pixi/core/Matrix', function () { - 'use strict'; - - var expect = chai.expect; - - it('Matrix exists', function () { - expect(PIXI.Matrix).to.be.an('function'); - }); - - it('Confirm new Matrix', function () { - var matrix = new PIXI.Matrix(); - pixi_core_Matrix_confirmNewMatrix(matrix); - }); -}); diff --git a/test/unit/pixi/core/Point.js b/test/unit/pixi/core/Point.js deleted file mode 100644 index c4d5163..0000000 --- a/test/unit/pixi/core/Point.js +++ /dev/null @@ -1,15 +0,0 @@ -describe('pixi/core/Point', function () { - 'use strict'; - - var expect = chai.expect; - var Point = PIXI.Point; - - it('Module exists', function () { - expect(Point).to.be.a('function'); - }); - - it('Confirm new instance', function () { - var obj = new Point(); - pixi_core_Point_confirm(obj, 0, 0); - }); -}); diff --git a/test/unit/pixi/core/Polygon.js b/test/unit/pixi/core/Polygon.js deleted file mode 100644 index dc8c918..0000000 --- a/test/unit/pixi/core/Polygon.js +++ /dev/null @@ -1,20 +0,0 @@ -describe('pixi/core/Polygon', function () { - 'use strict'; - - var expect = chai.expect; - var Polygon = PIXI.Polygon; - - it('Module exists', function () { - expect(Polygon).to.be.a('function'); - }); - - it('Confirm new instance', function () { - var obj = new Polygon(); - - expect(obj).to.be.an.instanceof(Polygon); - expect(obj).to.respondTo('clone'); - expect(obj).to.respondTo('contains'); - - expect(obj).to.have.deep.property('points.length', 0); - }); -}); diff --git a/test/unit/pixi/core/Rectangle.js b/test/unit/pixi/core/Rectangle.js deleted file mode 100644 index d43316e..0000000 --- a/test/unit/pixi/core/Rectangle.js +++ /dev/null @@ -1,15 +0,0 @@ -describe('pixi/core/Rectangle', function () { - 'use strict'; - - var expect = chai.expect; - var Rectangle = PIXI.Rectangle; - - it('Module exists', function () { - expect(Rectangle).to.be.a('function'); - }); - - it('Confirm new instance', function () { - var rect = new Rectangle(); - pixi_core_Rectangle_confirm(rect, 0, 0, 0, 0); - }); -}); diff --git a/test/unit/pixi/display/DisplayObject.js b/test/unit/pixi/display/DisplayObject.js deleted file mode 100644 index 044acf8..0000000 --- a/test/unit/pixi/display/DisplayObject.js +++ /dev/null @@ -1,21 +0,0 @@ -describe('pixi/display/DisplayObject', function () { - 'use strict'; - - var expect = chai.expect; - var DisplayObject = PIXI.DisplayObject; - - it('Module exists', function () { - expect(DisplayObject).to.be.a('function'); - // expect(PIXI).to.have.property('visibleCount', 0); - }); - - it('Confirm new instance', function () { - var obj = new DisplayObject(); - - pixi_display_DisplayObject_confirmNew(obj); - expect(obj).to.have.property('hitArea', null); - expect(obj).to.have.property('interactive', false); - expect(obj).to.have.property('renderable', false); - expect(obj).to.have.property('stage', null); - }); -}); diff --git a/test/unit/pixi/display/DisplayObjectContainer.js b/test/unit/pixi/display/DisplayObjectContainer.js deleted file mode 100644 index 15a3376..0000000 --- a/test/unit/pixi/display/DisplayObjectContainer.js +++ /dev/null @@ -1,67 +0,0 @@ -describe('pixi/display/DisplayObjectContainer', function () { - 'use strict'; - - var expect = chai.expect; - var DisplayObjectContainer = PIXI.DisplayObjectContainer; - - it('Module exists', function () { - expect(DisplayObjectContainer).to.be.a('function'); - }); - - it('Confirm new instance', function () { - var obj = new DisplayObjectContainer(); - - pixi_display_DisplayObjectContainer_confirmNew(obj); - expect(obj).to.have.property('hitArea', null); - expect(obj).to.have.property('interactive', false); - expect(obj).to.have.property('renderable', false); - expect(obj).to.have.property('stage', null); - }); - - it('Gets child index', function() { - var container = new PIXI.DisplayObjectContainer(); - var children = []; - for (var i = 0; i < 10; i++) { - var child = new PIXI.DisplayObject(); - children.push(child); - container.addChild(child); - } - - for (i = 0; i < children.length; i++) { - expect(i).to.eql(container.getChildIndex(children[i])); - } - }); - - it('throws error when trying to get index of not a child', function() { - var container = new PIXI.DisplayObjectContainer(); - var child = new PIXI.DisplayObject(); - - expect(function() { container.getChildIndex(child); }).to.throw(); - }); - - it('Sets child index', function() { - var container = new PIXI.DisplayObjectContainer(); - var children = []; - - for (var i = 0; i < 10; i++) { - var child = new PIXI.DisplayObject(); - children.push(child); - container.addChild(child); - } - children.reverse(); - - for (i = 0; i < children.length; i++) { - container.setChildIndex(children[i], i); - expect(i).to.eql(container.getChildIndex(children[i])); - } - }); - - it('throws error when trying to set incorect index', function() { - var container = new PIXI.DisplayObjectContainer(); - var child = new PIXI.DisplayObject(); - container.addChild(child); - - expect(function() { container.setChildIndex(child, -1); }).to.throw(); - expect(function() { container.setChildIndex(child, 1); }).to.throw(); - }); -}); diff --git a/test/unit/pixi/display/MovieClip.js b/test/unit/pixi/display/MovieClip.js deleted file mode 100644 index f3c6c6a..0000000 --- a/test/unit/pixi/display/MovieClip.js +++ /dev/null @@ -1,33 +0,0 @@ -describe('pixi/display/MovieClip', function () { - 'use strict'; - - var expect = chai.expect; - var MovieClip = PIXI.MovieClip; - var Texture = PIXI.Texture; - - it('Module exists', function () { - expect(MovieClip).to.be.a('function'); - }); - - it('Confirm new instance', function (done) { - var texture = Texture.fromImage('/base/test/textures/SpriteSheet-Explosion.png'); - var obj = new MovieClip([texture]); - - pixi_display_Sprite_confirmNew(obj, done); - - expect(obj).to.be.an.instanceof(MovieClip); - expect(obj).to.respondTo('stop'); - expect(obj).to.respondTo('play'); - expect(obj).to.respondTo('gotoAndStop'); - expect(obj).to.respondTo('gotoAndPlay'); - expect(obj).to.respondTo('updateTransform'); - - expect(obj).to.have.deep.property('textures.length', 1); - expect(obj).to.have.deep.property('textures[0]', texture); - expect(obj).to.have.property('animationSpeed', 1); - expect(obj).to.have.property('loop', true); - expect(obj).to.have.property('onComplete', null); - expect(obj).to.have.property('currentFrame', 0); - expect(obj).to.have.property('playing', false); - }); -}); diff --git a/test/unit/pixi/display/Sprite.js b/test/unit/pixi/display/Sprite.js deleted file mode 100644 index 30c8076..0000000 --- a/test/unit/pixi/display/Sprite.js +++ /dev/null @@ -1,28 +0,0 @@ -describe('pixi/display/Sprite', function () { - 'use strict'; - - var expect = chai.expect; - var Sprite = PIXI.Sprite; - var Texture = PIXI.Texture; - - it('Module exists', function () { - expect(Sprite).to.be.a('function'); - expect(PIXI).to.have.deep.property('blendModes.NORMAL', 0); - expect(PIXI).to.have.deep.property('blendModes.ADD', 1); - expect(PIXI).to.have.deep.property('blendModes.MULTIPLY', 2); - expect(PIXI).to.have.deep.property('blendModes.SCREEN', 3); - }); - - - it('Members exist', function () { - expect(Sprite).itself.to.respondTo('fromImage'); - expect(Sprite).itself.to.respondTo('fromFrame'); - }); - - it('Confirm new instance', function (done) { - var texture = Texture.fromImage('/base/test/textures/SpriteSheet-Aliens.png'); - var obj = new Sprite(texture); - - pixi_display_Sprite_confirmNew(obj, done); - }); -}); diff --git a/test/unit/pixi/display/Stage.js b/test/unit/pixi/display/Stage.js deleted file mode 100644 index 6974c2e..0000000 --- a/test/unit/pixi/display/Stage.js +++ /dev/null @@ -1,49 +0,0 @@ -describe('pixi/display/Stage', function () { - 'use strict'; - - var expect = chai.expect; - var Stage = PIXI.Stage; - var InteractionManager = PIXI.InteractionManager; - var Rectangle = PIXI.Rectangle; - - it('Module exists', function () { - expect(Stage).to.be.a('function'); - }); - - it('Confirm new instance', function () { - var obj = new Stage(null, true); - - pixi_display_DisplayObjectContainer_confirmNew(obj); - - expect(obj).to.be.an.instanceof(Stage); - expect(obj).to.respondTo('updateTransform'); - expect(obj).to.respondTo('setBackgroundColor'); - expect(obj).to.respondTo('getMousePosition'); - // FIXME: duplicate member in DisplayObject - pixi_core_Matrix_confirmNewMatrix(obj.worldTransform); - // FIXME: convert arg to bool in constructor - expect(obj).to.have.property('interactive', true); - - expect(obj).to.have.property('interactionManager') - .and.to.be.an.instanceof(InteractionManager) - .and.to.have.property('stage', obj); - - expect(obj).to.have.property('dirty', true); - - expect(obj).to.have.property('stage', obj); - - expect(obj).to.have.property('hitArea') - .and.to.be.an.instanceof(Rectangle); - pixi_core_Rectangle_confirm(obj.hitArea, 0, 0, 100000, 100000); - - expect(obj).to.have.property('backgroundColor', 0x000000); - expect(obj).to.have.deep.property('backgroundColorSplit.length', 3); - expect(obj).to.have.deep.property('backgroundColorSplit[0]', 0); - expect(obj).to.have.deep.property('backgroundColorSplit[1]', 0); - expect(obj).to.have.deep.property('backgroundColorSplit[2]', 0); - expect(obj).to.have.property('backgroundColorString', '#000000'); - - - expect(obj).to.have.property('worldVisible', true); - }); -}); diff --git a/test/unit/pixi/extras/Rope.js b/test/unit/pixi/extras/Rope.js deleted file mode 100644 index 05885ac..0000000 --- a/test/unit/pixi/extras/Rope.js +++ /dev/null @@ -1,31 +0,0 @@ -describe('pixi/extras/Rope', function () { - 'use strict'; - - var expect = chai.expect; - var Rope = PIXI.Rope; - var Texture = PIXI.Texture; - var Point = PIXI.Point; - - it('Module exists', function () { - expect(Rope).to.be.a('function'); - }); - - it('Confirm new instance', function () { - - var texture = Texture.fromImage('/base/test/textures/bunny.png'); - - // TODO-Alvin - // Same as Strip - - // var obj = new Rope(texture, [new Point(), new Point(5, 10), new Point(10, 20)]); - - // pixi_extras_Strip_confirmNew(obj); - - // expect(obj).to.be.an.instanceof(Rope); - // expect(obj).to.respondTo('refresh'); - // expect(obj).to.respondTo('updateTransform'); - // expect(obj).to.respondTo('setTexture'); - - // TODO: Test properties - }); -}); diff --git a/test/unit/pixi/extras/Spine.js b/test/unit/pixi/extras/Spine.js deleted file mode 100644 index 0708bc0..0000000 --- a/test/unit/pixi/extras/Spine.js +++ /dev/null @@ -1,10 +0,0 @@ -describe('pixi/extras/Spine', function () { - 'use strict'; - - var expect = chai.expect; - var Spine = PIXI.Spine; - - it('Module exists', function () { - expect(Spine).to.be.a('function'); - }); -}); diff --git a/test/unit/pixi/extras/Strip.js b/test/unit/pixi/extras/Strip.js deleted file mode 100644 index 230af90..0000000 --- a/test/unit/pixi/extras/Strip.js +++ /dev/null @@ -1,26 +0,0 @@ -describe('pixi/extras/Strip', function () { - 'use strict'; - - var expect = chai.expect; - var Strip = PIXI.Strip; - var Texture = PIXI.Texture; - - it('Module exists', function () { - expect(Strip).to.be.a('function'); - }); - - it('Confirm new instance', function () { - - - // TODO-Alvin - // We tweaked it to make it pass the tests, but the whole strip class needs - // to be re-coded - - var texture = Texture.fromImage('/base/test/textures/bunny.png'); - - // var obj = new Strip(texture, 20, 10000); - - - // pixi_extras_Strip_confirmNew(obj); - }); -}); diff --git a/test/unit/pixi/extras/TilingSprite.js b/test/unit/pixi/extras/TilingSprite.js deleted file mode 100644 index 56aea14..0000000 --- a/test/unit/pixi/extras/TilingSprite.js +++ /dev/null @@ -1,24 +0,0 @@ -describe('pixi/extras/TilingSprite', function () { - 'use strict'; - - var expect = chai.expect; - var TilingSprite = PIXI.TilingSprite; - var Texture = PIXI.Texture; - - it('Module exists', function () { - expect(TilingSprite).to.be.a('function'); - }); - - it('Confirm new instance', function () { - var texture = Texture.fromImage('/base/test/textures/bunny.png'); - var obj = new TilingSprite(texture, 6000, 12000); - - pixi_display_DisplayObjectContainer_confirmNew(obj); - - expect(obj).to.be.an.instanceof(TilingSprite); - expect(obj).to.respondTo('setTexture'); - expect(obj).to.respondTo('onTextureUpdate'); - - // TODO: Test properties - }); -}); diff --git a/test/unit/pixi/filters/FilterBlock.js b/test/unit/pixi/filters/FilterBlock.js deleted file mode 100644 index 870cec0..0000000 --- a/test/unit/pixi/filters/FilterBlock.js +++ /dev/null @@ -1,10 +0,0 @@ -describe('pixi/filters/FilterBlock', function () { - 'use strict'; - - var expect = chai.expect; - var FilterBlock = PIXI.FilterBlock; - - it('Module exists', function () { - expect(FilterBlock).to.be.a('function'); - }); -}); diff --git a/test/unit/pixi/loaders/AssetLoader.js b/test/unit/pixi/loaders/AssetLoader.js deleted file mode 100644 index a0aa0b5..0000000 --- a/test/unit/pixi/loaders/AssetLoader.js +++ /dev/null @@ -1,10 +0,0 @@ -describe('pixi/loaders/AssetLoader', function () { - 'use strict'; - - var expect = chai.expect; - var AssetLoader = PIXI.AssetLoader; - - it('Module exists', function () { - expect(AssetLoader).to.be.a('function'); - }); -}); diff --git a/test/unit/pixi/loaders/BitmapFontLoader.js b/test/unit/pixi/loaders/BitmapFontLoader.js deleted file mode 100644 index 046f018..0000000 --- a/test/unit/pixi/loaders/BitmapFontLoader.js +++ /dev/null @@ -1,9 +0,0 @@ -describe('pixi/loaders/BitmapFontLoader', function () { - 'use strict'; - - var expect = chai.expect; - - it('Module exists', function () { - expect(PIXI.BitmapFontLoader).to.be.a('function'); - }); -}); diff --git a/test/unit/pixi/loaders/ImageLoader.js b/test/unit/pixi/loaders/ImageLoader.js deleted file mode 100644 index 8b1f556..0000000 --- a/test/unit/pixi/loaders/ImageLoader.js +++ /dev/null @@ -1,10 +0,0 @@ -describe('pixi/loaders/ImageLoader', function () { - 'use strict'; - - var expect = chai.expect; - var ImageLoader = PIXI.ImageLoader; - - it('Module exists', function () { - expect(ImageLoader).to.be.a('function'); - }); -}); diff --git a/test/unit/pixi/loaders/JsonLoader.js b/test/unit/pixi/loaders/JsonLoader.js deleted file mode 100644 index c577e83..0000000 --- a/test/unit/pixi/loaders/JsonLoader.js +++ /dev/null @@ -1,10 +0,0 @@ -describe('pixi/loaders/JsonLoader', function () { - 'use strict'; - - var expect = chai.expect; - var JsonLoader = PIXI.JsonLoader; - - it('Module exists', function () { - expect(JsonLoader).to.be.a('function'); - }); -}); diff --git a/test/unit/pixi/loaders/SpineLoader.js b/test/unit/pixi/loaders/SpineLoader.js deleted file mode 100644 index fdcc0b8..0000000 --- a/test/unit/pixi/loaders/SpineLoader.js +++ /dev/null @@ -1,10 +0,0 @@ -describe('pixi/loaders/SpineLoader', function () { - 'use strict'; - - var expect = chai.expect; - var SpineLoader = PIXI.SpineLoader; - - it('Module exists', function () { - expect(SpineLoader).to.be.a('function'); - }); -}); diff --git a/test/unit/pixi/loaders/SpriteSheetLoader.js b/test/unit/pixi/loaders/SpriteSheetLoader.js deleted file mode 100644 index 57beb27..0000000 --- a/test/unit/pixi/loaders/SpriteSheetLoader.js +++ /dev/null @@ -1,10 +0,0 @@ -describe('pixi/loaders/SpriteSheetLoader', function () { - 'use strict'; - - var expect = chai.expect; - var SpriteSheetLoader = PIXI.SpriteSheetLoader; - - it('Module exists', function () { - expect(SpriteSheetLoader).to.be.a('function'); - }); -}); diff --git a/test/unit/pixi/primitives/Graphics.js b/test/unit/pixi/primitives/Graphics.js deleted file mode 100644 index f3849eb..0000000 --- a/test/unit/pixi/primitives/Graphics.js +++ /dev/null @@ -1,44 +0,0 @@ -describe('pixi/primitives/Graphics', function () { - 'use strict'; - - var expect = chai.expect; - var Graphics = PIXI.Graphics; - - it('Module exists', function () { - expect(Graphics).to.be.a('function'); - - expect(Graphics).itself.to.have.property('POLY', 0); - expect(Graphics).itself.to.have.property('RECT', 1); - expect(Graphics).itself.to.have.property('CIRC', 2); - expect(Graphics).itself.to.have.property('ELIP', 3); - expect(Graphics).itself.to.have.property('RREC', 4); - }); - - it('Confirm new instance', function () { - var obj = new Graphics(); - - pixi_display_DisplayObjectContainer_confirmNew(obj); - - expect(obj).to.be.an.instanceof(Graphics); - expect(obj).to.respondTo('lineStyle'); - expect(obj).to.respondTo('lineStyle'); - expect(obj).to.respondTo('moveTo'); - expect(obj).to.respondTo('lineTo'); - expect(obj).to.respondTo('beginFill'); - expect(obj).to.respondTo('endFill'); - expect(obj).to.respondTo('drawRect'); - // expect(obj).to.respondTo('drawRoundedRect'); - expect(obj).to.respondTo('drawCircle'); - expect(obj).to.respondTo('drawEllipse'); - expect(obj).to.respondTo('clear'); - - expect(obj).to.have.property('renderable', true); - expect(obj).to.have.property('fillAlpha', 1); - expect(obj).to.have.property('lineWidth', 0); - expect(obj).to.have.property('width', 0); - expect(obj).to.have.property('height', 0); - expect(obj).to.have.property('lineColor', 0); - expect(obj).to.have.deep.property('graphicsData.length', 0); - // expect(obj).to.have.deep.property('currentPath.points.length', 0); - }); -}); diff --git a/test/unit/pixi/renderers/canvas/CanvasGraphics.js b/test/unit/pixi/renderers/canvas/CanvasGraphics.js deleted file mode 100644 index 8f44472..0000000 --- a/test/unit/pixi/renderers/canvas/CanvasGraphics.js +++ /dev/null @@ -1,15 +0,0 @@ -describe('renders/canvas/CanvasGraphics', function () { - 'use strict'; - - var expect = chai.expect; - var CanvasGraphics = PIXI.CanvasGraphics; - - it('Module exists', function () { - expect(CanvasGraphics).to.be.a('function'); - }); - - it('Members exist', function () { - expect(CanvasGraphics).itself.to.respondTo('renderGraphics'); - expect(CanvasGraphics).itself.to.respondTo('renderGraphicsMask'); - }); -}); diff --git a/test/unit/pixi/renderers/canvas/CanvasRenderer.js b/test/unit/pixi/renderers/canvas/CanvasRenderer.js deleted file mode 100644 index 1646444..0000000 --- a/test/unit/pixi/renderers/canvas/CanvasRenderer.js +++ /dev/null @@ -1,36 +0,0 @@ -describe('renderers/canvas/CanvasRenderer', function () { - 'use strict'; - - var expect = chai.expect; - var CanvasRenderer = PIXI.CanvasRenderer; - - it('Module exists', function () { - expect(CanvasRenderer).to.be.a('function'); - }); - - describe('.autoResize', function () { - it('Should automatically resize view if enabled', function () { - var renderer = new CanvasRenderer(200, 200, { - autoResize: true - }); - - expect(renderer.view.style.width).to.equal('200px'); - }); - - it('Should not automatically resize view if disabled', function () { - var renderer = new CanvasRenderer(200, 200, { - autoResize: false - }); - - expect(renderer.view.style.width).to.equal(''); - }); - - it('Should not automatically resize view if not specified', function () { - var renderer = new CanvasRenderer(200, 200, { - resolution: 2 - }); - - expect(renderer.view.style.width).to.equal(''); - }); - }); -}); diff --git a/test/unit/pixi/renderers/webgl/WebGLGraphics.js b/test/unit/pixi/renderers/webgl/WebGLGraphics.js deleted file mode 100644 index 5867b28..0000000 --- a/test/unit/pixi/renderers/webgl/WebGLGraphics.js +++ /dev/null @@ -1,20 +0,0 @@ -describe('renderers/wegbl/WebGLGraphics', function () { - 'use strict'; - - var expect = chai.expect; - var WebGLGraphics = PIXI.WebGLGraphics; - - it('Module exists', function () { - expect(WebGLGraphics).to.be.a('function'); - }); - - it('Members exist', function () { - expect(WebGLGraphics).itself.to.respondTo('renderGraphics'); - expect(WebGLGraphics).itself.to.respondTo('updateGraphics'); - expect(WebGLGraphics).itself.to.respondTo('buildRectangle'); - expect(WebGLGraphics).itself.to.respondTo('buildRoundedRectangle'); - expect(WebGLGraphics).itself.to.respondTo('buildCircle'); - expect(WebGLGraphics).itself.to.respondTo('buildLine'); - expect(WebGLGraphics).itself.to.respondTo('buildPoly'); - }); -}); diff --git a/test/unit/pixi/renderers/webgl/WebGLRenderer.js b/test/unit/pixi/renderers/webgl/WebGLRenderer.js deleted file mode 100644 index 1680a80..0000000 --- a/test/unit/pixi/renderers/webgl/WebGLRenderer.js +++ /dev/null @@ -1,49 +0,0 @@ -describe('renderers/webgl/WebGLRenderer', function () { - 'use strict'; - - var expect = chai.expect; - var WebGLRenderer = PIXI.WebGLRenderer; - - it('Module exists', function () { - expect(WebGLRenderer).to.be.a('function'); - }); - - // Skip tests if WebGL is not available (WebGL not supported in Travis CI) - try { - var renderer = new WebGLRenderer(400, 300, {}); - renderer.destroy(); - } catch (error) { - return; - } - - it('Destroy renderer', function () { - var renderer = new WebGLRenderer(400, 300, {}); - renderer.destroy(); - }); - - describe('.autoResize', function () { - it('Should automatically resize view if enabled', function () { - var renderer = new WebGLRenderer(200, 200, { - autoResize: true - }); - - expect(renderer.view.style.width).to.equal('200px'); - }); - - it('Should not automatically resize view if disabled', function () { - var renderer = new WebGLRenderer(200, 200, { - autoResize: false - }); - - expect(renderer.view.style.width).to.equal(''); - }); - - it('Should not automatically resize view if not specified', function () { - var renderer = new WebGLRenderer(200, 200, { - resolution: 2 - }); - - expect(renderer.view.style.width).to.equal(''); - }); - }); -}); diff --git a/test/unit/pixi/renderers/webgl/WebGLShaders.js b/test/unit/pixi/renderers/webgl/WebGLShaders.js deleted file mode 100644 index 6e33e4f..0000000 --- a/test/unit/pixi/renderers/webgl/WebGLShaders.js +++ /dev/null @@ -1,13 +0,0 @@ -describe('renderers/webgl/WebGLShaders', function () { - 'use strict'; - - var expect = chai.expect; - - it('Module members exist', function () { - - expect(PIXI).to.respondTo('CompileVertexShader'); - expect(PIXI).to.respondTo('CompileFragmentShader'); - expect(PIXI).to.respondTo('_CompileShader'); - expect(PIXI).to.respondTo('compileProgram'); - }); -}); diff --git a/test/unit/pixi/renderers/webgl/WebGLSpriteBatch.js b/test/unit/pixi/renderers/webgl/WebGLSpriteBatch.js deleted file mode 100644 index e662b63..0000000 --- a/test/unit/pixi/renderers/webgl/WebGLSpriteBatch.js +++ /dev/null @@ -1,10 +0,0 @@ -describe('renderers/webgl/utils/WebGLSpriteBatch', function () { - 'use strict'; - - var expect = chai.expect; - var WebGLSpriteBatch = PIXI.WebGLSpriteBatch; - - it('Module exists', function () { - expect(WebGLSpriteBatch).to.be.a('function'); - }); -}); diff --git a/test/unit/pixi/text/BitmapText.js b/test/unit/pixi/text/BitmapText.js deleted file mode 100644 index 9388e3d..0000000 --- a/test/unit/pixi/text/BitmapText.js +++ /dev/null @@ -1,10 +0,0 @@ -describe('pixi/text/BitmapText', function () { - 'use strict'; - - var expect = chai.expect; - var BitmapText = PIXI.BitmapText; - - it('Module exists', function () { - expect(BitmapText).to.be.a('function'); - }); -}); diff --git a/test/unit/pixi/text/Text.js b/test/unit/pixi/text/Text.js deleted file mode 100644 index 9bc9ac5..0000000 --- a/test/unit/pixi/text/Text.js +++ /dev/null @@ -1,10 +0,0 @@ -describe('pixi/text/Text', function () { - 'use strict'; - - var expect = chai.expect; - var Text = PIXI.Text; - - it('Module exists', function () { - expect(Text).to.be.a('function'); - }); -}); diff --git a/test/unit/pixi/textures/BaseTexture.js b/test/unit/pixi/textures/BaseTexture.js deleted file mode 100644 index 502b724..0000000 --- a/test/unit/pixi/textures/BaseTexture.js +++ /dev/null @@ -1,11 +0,0 @@ -describe('pixi/textures/BaseTexture', function () { - 'use strict'; - - var expect = chai.expect; - var BaseTexture = PIXI.BaseTexture; - - it('Module exists', function () { - expect(BaseTexture).to.be.a('function'); - expect(PIXI).to.have.property('BaseTextureCache').and.to.be.an('object'); - }); -}); diff --git a/test/unit/pixi/textures/RenderTexture.js b/test/unit/pixi/textures/RenderTexture.js deleted file mode 100644 index 96acdb4..0000000 --- a/test/unit/pixi/textures/RenderTexture.js +++ /dev/null @@ -1,15 +0,0 @@ -describe('pixi/textures/RenderTexture', function () { - 'use strict'; - - var expect = chai.expect; - var RenderTexture = PIXI.RenderTexture; - - it('Module exists', function () { - expect(RenderTexture).to.be.a('function'); - }); - - it('Confirm new instance', function (done) { - var texture = new RenderTexture(100, 100, new PIXI.CanvasRenderer()); - pixi_textures_RenderTexture_confirmNew(texture, done); - }); -}); diff --git a/test/unit/pixi/textures/Texture.js b/test/unit/pixi/textures/Texture.js deleted file mode 100644 index 090f64d..0000000 --- a/test/unit/pixi/textures/Texture.js +++ /dev/null @@ -1,26 +0,0 @@ -describe('pixi/textures/Texture', function () { - 'use strict'; - - var expect = chai.expect; - var Texture = PIXI.Texture; - - it('Module exists', function () { - expect(Texture).to.be.a('function'); - expect(PIXI).to.have.property('TextureCache').and.to.be.an('object'); - }); - - it('Members exist', function () { - expect(Texture).itself.to.respondTo('fromImage'); - expect(Texture).itself.to.respondTo('fromFrame'); - expect(Texture).itself.to.respondTo('fromCanvas'); - expect(Texture).itself.to.respondTo('addTextureToCache'); - expect(Texture).itself.to.respondTo('removeTextureFromCache'); - - // expect(Texture).itself.to.have.deep.property('frameUpdates.length', 0); - }); - - it('Confirm new instance', function (done) { - var texture = Texture.fromImage('/base/test/textures/bunny.png'); - pixi_textures_Texture_confirmNew(texture, done); - }); -}); diff --git a/test/unit/pixi/utils/Detector.js b/test/unit/pixi/utils/Detector.js deleted file mode 100644 index 4cf6008..0000000 --- a/test/unit/pixi/utils/Detector.js +++ /dev/null @@ -1,10 +0,0 @@ -describe('pixi/utils/Detector', function () { - 'use strict'; - - var expect = chai.expect; - var autoDetectRenderer = PIXI.autoDetectRenderer; - - it('Module exists', function () { - expect(autoDetectRenderer).to.be.a('function'); - }); -}); diff --git a/test/unit/pixi/utils/EventTarget.js b/test/unit/pixi/utils/EventTarget.js deleted file mode 100644 index 1cfc3a4..0000000 --- a/test/unit/pixi/utils/EventTarget.js +++ /dev/null @@ -1,361 +0,0 @@ -describe('pixi/utils/EventTarget', function () { - 'use strict'; - - var expect = chai.expect; - - var Clazz, PClazz, obj, pobj, obj2; - beforeEach(function () { - Clazz = function () {}; - PClazz = function () {}; - - PIXI.EventTarget.mixin(Clazz.prototype); - PIXI.EventTarget.mixin(PClazz.prototype); - - obj = new Clazz(); - obj2 = new Clazz(); - pobj = new PClazz(); - - obj.parent = pobj; - obj2.parent = obj; - }); - - it('Module exists', function () { - expect(PIXI.EventTarget).to.be.an('object'); - }); - - it('Confirm new instance', function () { - pixi_utils_EventTarget_confirm(obj); - }); - - it('simple on/emit case works', function () { - var myData = {}; - - obj.on('myevent', function (event) { - pixi_utils_EventTarget_Event_confirm(event, obj, myData); - }); - - obj.emit('myevent', myData); - }); - - it('simple once case works', function () { - var called = 0; - - obj.once('myevent', function() { called++; }); - - obj.emit('myevent'); - obj.emit('myevent'); - obj.emit('myevent'); - obj.emit('myevent'); - obj.emit('myevent'); - - expect(called).to.equal(1); - }); - - it('simple off case works', function (done) { - function onMyEvent() { - done(new Error('Event listener should not have been called')); - } - - obj.on('myevent', onMyEvent); - obj.off('myevent', onMyEvent); - obj.emit('myevent'); - - done(); - }); - - it('simple propagation case works', function (done) { - var myData = {}; - - pobj.on('myevent', function () { - done(); - }); - - obj.emit('myevent'); - }); - - it('simple stopPropagation case works', function (done) { - var myData = {}; - - pobj.on('myevent', function () { - done(new Error('Event listener should not have been called on the parent element')); - }); - - obj.on('myevent', function (evt) { - evt.stopPropagation(); - }); - - obj.emit('myevent'); - - done(); - }); - - it('simple stopImmediatePropagation case works', function (done) { - var myData = {}; - - pobj.on('myevent', function () { - done(new Error('Event listener should not have been called on the parent')); - }); - - obj.on('myevent', function (evt) { - evt.stopImmediatePropagation(); - }); - - obj.on('myevent', function () { - done(new Error('Event listener should not have been called on the second')); - }); - - obj.emit('myevent'); - - done(); - }); - - it('multiple dispatches work properly', function () { - var called = 0; - - function onMyEvent() { - called++; - } - - obj.on('myevent', onMyEvent); - obj.emit('myevent'); - obj.emit('myevent'); - obj.emit('myevent'); - obj.emit('myevent'); - - expect(called).to.equal(4); - }); - - it('multiple events work properly', function () { - var called = 0; - - function onMyEvent() { - called++; - } - - obj.on('myevent1', onMyEvent); - obj.on('myevent2', onMyEvent); - obj.on('myevent3', onMyEvent); - obj.emit('myevent1'); - obj.emit('myevent2'); - obj.emit('myevent3'); - - expect(called).to.equal(3); - }); - - it('multiple events one removed works properly', function () { - var called = 0; - - function onMyEvent() { - called++; - } - - obj.on('myevent1', onMyEvent); - obj.on('myevent2', onMyEvent); - obj.on('myevent3', onMyEvent); - - obj.emit('myevent1'); - obj.emit('myevent2'); - obj.emit('myevent3'); - - obj.off('myevent2', onMyEvent); - - obj.emit('myevent1'); - obj.emit('myevent2'); - obj.emit('myevent3'); - - expect(called).to.equal(5); - }); - - it('multiple handlers for one event with some removed', function () { - var called = 0; - - var onMyEvent = function () { - called++; - }, - onMyEvent2 = function () { - called++; - }; - - // add 2 handlers and confirm they both get called - obj.on('myevent', onMyEvent); - obj.on('myevent', onMyEvent); - obj.on('myevent', onMyEvent2); - obj.on('myevent', onMyEvent2); - - obj.emit('myevent'); - - expect(called).to.equal(4); - - // remove one of the handlers, emit again, then ensure 1 more call is made - obj.off('myevent', onMyEvent); - - obj.emit('myevent'); - - expect(called).to.equal(6); - }); - - it('calls to off without a handler do nothing', function () { - var called = 0; - - var onMyEvent = function () { - called++; - }; - - obj.on('myevent', onMyEvent); - obj.on('myevent', onMyEvent); - - obj.emit('myevent'); - - expect(called).to.equal(2); - - obj.off('myevent'); - - obj.emit('myevent'); - - expect(called).to.equal(4); - - obj.off('myevent', onMyEvent); - - obj.emit('myevent'); - - expect(called).to.equal(4); - }); - - it('handles multiple instances with the same prototype', function () { - var called = 0; - - function onMyEvent(e) { - called++; - } - - obj.on('myevent1', onMyEvent); - obj.on('myevent2', onMyEvent); - - obj2.istwo = true; - obj2.on('myevent1', onMyEvent); - obj2.on('myevent2', onMyEvent); - - obj.emit('myevent1'); - obj.emit('myevent2'); - obj2.emit('myevent1'); - obj2.emit('myevent2'); - - //we emit 4 times, but since obj2 is a child of obj the event should bubble - //up to obj and show up there as well. So the obj2.emit() calls each increment - //the counter twice. - expect(called).to.equal(6); - }); - - it('is backwards compatible with older .dispatchEvent({})', function () { - var called = 0, - data = { - some: 'thing', - hello: true - }; - - function onMyEvent(event) { - pixi_utils_EventTarget_Event_confirm(event, obj, data); - - called++; - } - - obj.on('myevent1', onMyEvent); - obj.on('myevent2', onMyEvent); - obj.on('myevent3', onMyEvent); - - data.type = 'myevent1'; - obj.emit(data); - - data.type = 'myevent2'; - obj.emit(data); - - data.type = 'myevent3'; - obj.emit(data); - - obj.off('myevent2', onMyEvent); - - data.type = 'myevent1'; - obj.emit(data); - - data.type = 'myevent2'; - obj.emit(data); - - data.type = 'myevent3'; - obj.emit(data); - - expect(called).to.equal(5); - }); - - it('is backwards compatible with older .call(this)', function () { - var Fn = function() { - PIXI.EventTarget.call(this); - }, - o = new Fn(); - - pixi_utils_EventTarget_confirm(o); - }); - - it('is backwards compatible with older .addEventListener("")', function () { - var called = 0, - data = { - some: 'thing', - hello: true - }; - - function onMyEvent(event) { - pixi_utils_EventTarget_Event_confirm(event, obj, data); - - called++; - } - - obj.addEventListener('myevent1', onMyEvent); - obj.addEventListener('myevent2', onMyEvent); - obj.addEventListener('myevent3', onMyEvent); - - data.type = 'myevent1'; - obj.emit(data); - - data.type = 'myevent2'; - obj.emit(data); - - data.type = 'myevent3'; - obj.emit(data); - - obj.off('myevent2', onMyEvent); - - data.type = 'myevent1'; - obj.emit(data); - - data.type = 'myevent2'; - obj.emit(data); - - data.type = 'myevent3'; - obj.emit(data); - - expect(called).to.equal(5); - }); - - it('event remove during emit call properly', function () { - var called = 0; - - function cb1() { - called++; - obj.off('myevent', cb1); - } - function cb2() { - called++; - obj.off('myevent', cb2); - } - function cb3() { - called++; - obj.off('myevent', cb3); - } - - obj.on('myevent', cb1); - obj.on('myevent', cb2); - obj.on('myevent', cb3); - obj.emit('myevent', ''); - - expect(called).to.equal(3); - }); -}); diff --git a/test/unit/pixi/utils/Polyk.js b/test/unit/pixi/utils/Polyk.js deleted file mode 100644 index dfc7128..0000000 --- a/test/unit/pixi/utils/Polyk.js +++ /dev/null @@ -1,14 +0,0 @@ -describe('pixi/utils/Polyk', function () { - 'use strict'; - - var expect = chai.expect; - var PolyK = PIXI.PolyK; - - it('Module exists', function () { - expect(PolyK).to.be.an('object'); - }); - - it('Members exist', function () { - expect(PolyK).to.respondTo('Triangulate'); - }); -}); diff --git a/test/unit/pixi-v2/InteractionManager.js b/test/unit/pixi-v2/InteractionManager.js new file mode 100644 index 0000000..ed3001f --- /dev/null +++ b/test/unit/pixi-v2/InteractionManager.js @@ -0,0 +1,10 @@ +describe('pixi/InteractionManager', function () { + 'use strict'; + + var expect = chai.expect; + var InteractionManager = PIXI.InteractionManager; + + it('Module exists', function () { + expect(InteractionManager).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/Pixi.js b/test/unit/pixi-v2/Pixi.js new file mode 100644 index 0000000..27debc1 --- /dev/null +++ b/test/unit/pixi-v2/Pixi.js @@ -0,0 +1,9 @@ +describe('pixi/Pixi', function () { + 'use strict'; + + var expect = chai.expect; + + it('Module exists', function () { + expect(global).to.have.property('PIXI').and.to.be.an('object'); + }); +}); diff --git a/test/unit/pixi-v2/core/Circle.js b/test/unit/pixi-v2/core/Circle.js new file mode 100644 index 0000000..fbcfa17 --- /dev/null +++ b/test/unit/pixi-v2/core/Circle.js @@ -0,0 +1,21 @@ +describe('pixi/core/Circle', function () { + 'use strict'; + + var expect = chai.expect; + var Circle = PIXI.Circle; + + it('Module exists', function () { + expect(Circle).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Circle(); + pixi_core_Circle_confirmNewCircle(obj); + }); + + it("getBounds should return Rectangle that bounds the circle", function() { + var obj = new Circle(100, 250, 50); + var bounds = obj.getBounds(); + pixi_core_Circle_isBoundedByRectangle(obj, bounds); + }); +}); diff --git a/test/unit/pixi-v2/core/Ellipse.js b/test/unit/pixi-v2/core/Ellipse.js new file mode 100644 index 0000000..026b56f --- /dev/null +++ b/test/unit/pixi-v2/core/Ellipse.js @@ -0,0 +1,24 @@ +describe('pixi/core/Ellipse', function () { + 'use strict'; + + var expect = chai.expect; + var Ellipse = PIXI.Ellipse; + + it('Module exists', function () { + expect(Ellipse).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Ellipse(); + + expect(obj).to.be.an.instanceof(Ellipse); + expect(obj).to.respondTo('clone'); + expect(obj).to.respondTo('contains'); + expect(obj).to.respondTo('getBounds'); + + expect(obj).to.have.property('x', 0); + expect(obj).to.have.property('y', 0); + expect(obj).to.have.property('width', 0); + expect(obj).to.have.property('height', 0); + }); +}); diff --git a/test/unit/pixi-v2/core/Matrix.js b/test/unit/pixi-v2/core/Matrix.js new file mode 100644 index 0000000..da75e2e --- /dev/null +++ b/test/unit/pixi-v2/core/Matrix.js @@ -0,0 +1,14 @@ +describe('pixi/core/Matrix', function () { + 'use strict'; + + var expect = chai.expect; + + it('Matrix exists', function () { + expect(PIXI.Matrix).to.be.an('function'); + }); + + it('Confirm new Matrix', function () { + var matrix = new PIXI.Matrix(); + pixi_core_Matrix_confirmNewMatrix(matrix); + }); +}); diff --git a/test/unit/pixi-v2/core/Point.js b/test/unit/pixi-v2/core/Point.js new file mode 100644 index 0000000..c4d5163 --- /dev/null +++ b/test/unit/pixi-v2/core/Point.js @@ -0,0 +1,15 @@ +describe('pixi/core/Point', function () { + 'use strict'; + + var expect = chai.expect; + var Point = PIXI.Point; + + it('Module exists', function () { + expect(Point).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Point(); + pixi_core_Point_confirm(obj, 0, 0); + }); +}); diff --git a/test/unit/pixi-v2/core/Polygon.js b/test/unit/pixi-v2/core/Polygon.js new file mode 100644 index 0000000..dc8c918 --- /dev/null +++ b/test/unit/pixi-v2/core/Polygon.js @@ -0,0 +1,20 @@ +describe('pixi/core/Polygon', function () { + 'use strict'; + + var expect = chai.expect; + var Polygon = PIXI.Polygon; + + it('Module exists', function () { + expect(Polygon).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Polygon(); + + expect(obj).to.be.an.instanceof(Polygon); + expect(obj).to.respondTo('clone'); + expect(obj).to.respondTo('contains'); + + expect(obj).to.have.deep.property('points.length', 0); + }); +}); diff --git a/test/unit/pixi-v2/core/Rectangle.js b/test/unit/pixi-v2/core/Rectangle.js new file mode 100644 index 0000000..d43316e --- /dev/null +++ b/test/unit/pixi-v2/core/Rectangle.js @@ -0,0 +1,15 @@ +describe('pixi/core/Rectangle', function () { + 'use strict'; + + var expect = chai.expect; + var Rectangle = PIXI.Rectangle; + + it('Module exists', function () { + expect(Rectangle).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var rect = new Rectangle(); + pixi_core_Rectangle_confirm(rect, 0, 0, 0, 0); + }); +}); diff --git a/test/unit/pixi-v2/display/DisplayObject.js b/test/unit/pixi-v2/display/DisplayObject.js new file mode 100644 index 0000000..044acf8 --- /dev/null +++ b/test/unit/pixi-v2/display/DisplayObject.js @@ -0,0 +1,21 @@ +describe('pixi/display/DisplayObject', function () { + 'use strict'; + + var expect = chai.expect; + var DisplayObject = PIXI.DisplayObject; + + it('Module exists', function () { + expect(DisplayObject).to.be.a('function'); + // expect(PIXI).to.have.property('visibleCount', 0); + }); + + it('Confirm new instance', function () { + var obj = new DisplayObject(); + + pixi_display_DisplayObject_confirmNew(obj); + expect(obj).to.have.property('hitArea', null); + expect(obj).to.have.property('interactive', false); + expect(obj).to.have.property('renderable', false); + expect(obj).to.have.property('stage', null); + }); +}); diff --git a/test/unit/pixi-v2/display/DisplayObjectContainer.js b/test/unit/pixi-v2/display/DisplayObjectContainer.js new file mode 100644 index 0000000..15a3376 --- /dev/null +++ b/test/unit/pixi-v2/display/DisplayObjectContainer.js @@ -0,0 +1,67 @@ +describe('pixi/display/DisplayObjectContainer', function () { + 'use strict'; + + var expect = chai.expect; + var DisplayObjectContainer = PIXI.DisplayObjectContainer; + + it('Module exists', function () { + expect(DisplayObjectContainer).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new DisplayObjectContainer(); + + pixi_display_DisplayObjectContainer_confirmNew(obj); + expect(obj).to.have.property('hitArea', null); + expect(obj).to.have.property('interactive', false); + expect(obj).to.have.property('renderable', false); + expect(obj).to.have.property('stage', null); + }); + + it('Gets child index', function() { + var container = new PIXI.DisplayObjectContainer(); + var children = []; + for (var i = 0; i < 10; i++) { + var child = new PIXI.DisplayObject(); + children.push(child); + container.addChild(child); + } + + for (i = 0; i < children.length; i++) { + expect(i).to.eql(container.getChildIndex(children[i])); + } + }); + + it('throws error when trying to get index of not a child', function() { + var container = new PIXI.DisplayObjectContainer(); + var child = new PIXI.DisplayObject(); + + expect(function() { container.getChildIndex(child); }).to.throw(); + }); + + it('Sets child index', function() { + var container = new PIXI.DisplayObjectContainer(); + var children = []; + + for (var i = 0; i < 10; i++) { + var child = new PIXI.DisplayObject(); + children.push(child); + container.addChild(child); + } + children.reverse(); + + for (i = 0; i < children.length; i++) { + container.setChildIndex(children[i], i); + expect(i).to.eql(container.getChildIndex(children[i])); + } + }); + + it('throws error when trying to set incorect index', function() { + var container = new PIXI.DisplayObjectContainer(); + var child = new PIXI.DisplayObject(); + container.addChild(child); + + expect(function() { container.setChildIndex(child, -1); }).to.throw(); + expect(function() { container.setChildIndex(child, 1); }).to.throw(); + }); +}); diff --git a/test/unit/pixi-v2/display/MovieClip.js b/test/unit/pixi-v2/display/MovieClip.js new file mode 100644 index 0000000..f3c6c6a --- /dev/null +++ b/test/unit/pixi-v2/display/MovieClip.js @@ -0,0 +1,33 @@ +describe('pixi/display/MovieClip', function () { + 'use strict'; + + var expect = chai.expect; + var MovieClip = PIXI.MovieClip; + var Texture = PIXI.Texture; + + it('Module exists', function () { + expect(MovieClip).to.be.a('function'); + }); + + it('Confirm new instance', function (done) { + var texture = Texture.fromImage('/base/test/textures/SpriteSheet-Explosion.png'); + var obj = new MovieClip([texture]); + + pixi_display_Sprite_confirmNew(obj, done); + + expect(obj).to.be.an.instanceof(MovieClip); + expect(obj).to.respondTo('stop'); + expect(obj).to.respondTo('play'); + expect(obj).to.respondTo('gotoAndStop'); + expect(obj).to.respondTo('gotoAndPlay'); + expect(obj).to.respondTo('updateTransform'); + + expect(obj).to.have.deep.property('textures.length', 1); + expect(obj).to.have.deep.property('textures[0]', texture); + expect(obj).to.have.property('animationSpeed', 1); + expect(obj).to.have.property('loop', true); + expect(obj).to.have.property('onComplete', null); + expect(obj).to.have.property('currentFrame', 0); + expect(obj).to.have.property('playing', false); + }); +}); diff --git a/test/unit/pixi-v2/display/Sprite.js b/test/unit/pixi-v2/display/Sprite.js new file mode 100644 index 0000000..30c8076 --- /dev/null +++ b/test/unit/pixi-v2/display/Sprite.js @@ -0,0 +1,28 @@ +describe('pixi/display/Sprite', function () { + 'use strict'; + + var expect = chai.expect; + var Sprite = PIXI.Sprite; + var Texture = PIXI.Texture; + + it('Module exists', function () { + expect(Sprite).to.be.a('function'); + expect(PIXI).to.have.deep.property('blendModes.NORMAL', 0); + expect(PIXI).to.have.deep.property('blendModes.ADD', 1); + expect(PIXI).to.have.deep.property('blendModes.MULTIPLY', 2); + expect(PIXI).to.have.deep.property('blendModes.SCREEN', 3); + }); + + + it('Members exist', function () { + expect(Sprite).itself.to.respondTo('fromImage'); + expect(Sprite).itself.to.respondTo('fromFrame'); + }); + + it('Confirm new instance', function (done) { + var texture = Texture.fromImage('/base/test/textures/SpriteSheet-Aliens.png'); + var obj = new Sprite(texture); + + pixi_display_Sprite_confirmNew(obj, done); + }); +}); diff --git a/test/unit/pixi-v2/display/Stage.js b/test/unit/pixi-v2/display/Stage.js new file mode 100644 index 0000000..6974c2e --- /dev/null +++ b/test/unit/pixi-v2/display/Stage.js @@ -0,0 +1,49 @@ +describe('pixi/display/Stage', function () { + 'use strict'; + + var expect = chai.expect; + var Stage = PIXI.Stage; + var InteractionManager = PIXI.InteractionManager; + var Rectangle = PIXI.Rectangle; + + it('Module exists', function () { + expect(Stage).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var obj = new Stage(null, true); + + pixi_display_DisplayObjectContainer_confirmNew(obj); + + expect(obj).to.be.an.instanceof(Stage); + expect(obj).to.respondTo('updateTransform'); + expect(obj).to.respondTo('setBackgroundColor'); + expect(obj).to.respondTo('getMousePosition'); + // FIXME: duplicate member in DisplayObject + pixi_core_Matrix_confirmNewMatrix(obj.worldTransform); + // FIXME: convert arg to bool in constructor + expect(obj).to.have.property('interactive', true); + + expect(obj).to.have.property('interactionManager') + .and.to.be.an.instanceof(InteractionManager) + .and.to.have.property('stage', obj); + + expect(obj).to.have.property('dirty', true); + + expect(obj).to.have.property('stage', obj); + + expect(obj).to.have.property('hitArea') + .and.to.be.an.instanceof(Rectangle); + pixi_core_Rectangle_confirm(obj.hitArea, 0, 0, 100000, 100000); + + expect(obj).to.have.property('backgroundColor', 0x000000); + expect(obj).to.have.deep.property('backgroundColorSplit.length', 3); + expect(obj).to.have.deep.property('backgroundColorSplit[0]', 0); + expect(obj).to.have.deep.property('backgroundColorSplit[1]', 0); + expect(obj).to.have.deep.property('backgroundColorSplit[2]', 0); + expect(obj).to.have.property('backgroundColorString', '#000000'); + + + expect(obj).to.have.property('worldVisible', true); + }); +}); diff --git a/test/unit/pixi-v2/extras/Rope.js b/test/unit/pixi-v2/extras/Rope.js new file mode 100644 index 0000000..05885ac --- /dev/null +++ b/test/unit/pixi-v2/extras/Rope.js @@ -0,0 +1,31 @@ +describe('pixi/extras/Rope', function () { + 'use strict'; + + var expect = chai.expect; + var Rope = PIXI.Rope; + var Texture = PIXI.Texture; + var Point = PIXI.Point; + + it('Module exists', function () { + expect(Rope).to.be.a('function'); + }); + + it('Confirm new instance', function () { + + var texture = Texture.fromImage('/base/test/textures/bunny.png'); + + // TODO-Alvin + // Same as Strip + + // var obj = new Rope(texture, [new Point(), new Point(5, 10), new Point(10, 20)]); + + // pixi_extras_Strip_confirmNew(obj); + + // expect(obj).to.be.an.instanceof(Rope); + // expect(obj).to.respondTo('refresh'); + // expect(obj).to.respondTo('updateTransform'); + // expect(obj).to.respondTo('setTexture'); + + // TODO: Test properties + }); +}); diff --git a/test/unit/pixi-v2/extras/Spine.js b/test/unit/pixi-v2/extras/Spine.js new file mode 100644 index 0000000..0708bc0 --- /dev/null +++ b/test/unit/pixi-v2/extras/Spine.js @@ -0,0 +1,10 @@ +describe('pixi/extras/Spine', function () { + 'use strict'; + + var expect = chai.expect; + var Spine = PIXI.Spine; + + it('Module exists', function () { + expect(Spine).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/extras/Strip.js b/test/unit/pixi-v2/extras/Strip.js new file mode 100644 index 0000000..230af90 --- /dev/null +++ b/test/unit/pixi-v2/extras/Strip.js @@ -0,0 +1,26 @@ +describe('pixi/extras/Strip', function () { + 'use strict'; + + var expect = chai.expect; + var Strip = PIXI.Strip; + var Texture = PIXI.Texture; + + it('Module exists', function () { + expect(Strip).to.be.a('function'); + }); + + it('Confirm new instance', function () { + + + // TODO-Alvin + // We tweaked it to make it pass the tests, but the whole strip class needs + // to be re-coded + + var texture = Texture.fromImage('/base/test/textures/bunny.png'); + + // var obj = new Strip(texture, 20, 10000); + + + // pixi_extras_Strip_confirmNew(obj); + }); +}); diff --git a/test/unit/pixi-v2/extras/TilingSprite.js b/test/unit/pixi-v2/extras/TilingSprite.js new file mode 100644 index 0000000..56aea14 --- /dev/null +++ b/test/unit/pixi-v2/extras/TilingSprite.js @@ -0,0 +1,24 @@ +describe('pixi/extras/TilingSprite', function () { + 'use strict'; + + var expect = chai.expect; + var TilingSprite = PIXI.TilingSprite; + var Texture = PIXI.Texture; + + it('Module exists', function () { + expect(TilingSprite).to.be.a('function'); + }); + + it('Confirm new instance', function () { + var texture = Texture.fromImage('/base/test/textures/bunny.png'); + var obj = new TilingSprite(texture, 6000, 12000); + + pixi_display_DisplayObjectContainer_confirmNew(obj); + + expect(obj).to.be.an.instanceof(TilingSprite); + expect(obj).to.respondTo('setTexture'); + expect(obj).to.respondTo('onTextureUpdate'); + + // TODO: Test properties + }); +}); diff --git a/test/unit/pixi-v2/filters/FilterBlock.js b/test/unit/pixi-v2/filters/FilterBlock.js new file mode 100644 index 0000000..870cec0 --- /dev/null +++ b/test/unit/pixi-v2/filters/FilterBlock.js @@ -0,0 +1,10 @@ +describe('pixi/filters/FilterBlock', function () { + 'use strict'; + + var expect = chai.expect; + var FilterBlock = PIXI.FilterBlock; + + it('Module exists', function () { + expect(FilterBlock).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/AssetLoader.js b/test/unit/pixi-v2/loaders/AssetLoader.js new file mode 100644 index 0000000..a0aa0b5 --- /dev/null +++ b/test/unit/pixi-v2/loaders/AssetLoader.js @@ -0,0 +1,10 @@ +describe('pixi/loaders/AssetLoader', function () { + 'use strict'; + + var expect = chai.expect; + var AssetLoader = PIXI.AssetLoader; + + it('Module exists', function () { + expect(AssetLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/BitmapFontLoader.js b/test/unit/pixi-v2/loaders/BitmapFontLoader.js new file mode 100644 index 0000000..046f018 --- /dev/null +++ b/test/unit/pixi-v2/loaders/BitmapFontLoader.js @@ -0,0 +1,9 @@ +describe('pixi/loaders/BitmapFontLoader', function () { + 'use strict'; + + var expect = chai.expect; + + it('Module exists', function () { + expect(PIXI.BitmapFontLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/ImageLoader.js b/test/unit/pixi-v2/loaders/ImageLoader.js new file mode 100644 index 0000000..8b1f556 --- /dev/null +++ b/test/unit/pixi-v2/loaders/ImageLoader.js @@ -0,0 +1,10 @@ +describe('pixi/loaders/ImageLoader', function () { + 'use strict'; + + var expect = chai.expect; + var ImageLoader = PIXI.ImageLoader; + + it('Module exists', function () { + expect(ImageLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/JsonLoader.js b/test/unit/pixi-v2/loaders/JsonLoader.js new file mode 100644 index 0000000..c577e83 --- /dev/null +++ b/test/unit/pixi-v2/loaders/JsonLoader.js @@ -0,0 +1,10 @@ +describe('pixi/loaders/JsonLoader', function () { + 'use strict'; + + var expect = chai.expect; + var JsonLoader = PIXI.JsonLoader; + + it('Module exists', function () { + expect(JsonLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/SpineLoader.js b/test/unit/pixi-v2/loaders/SpineLoader.js new file mode 100644 index 0000000..fdcc0b8 --- /dev/null +++ b/test/unit/pixi-v2/loaders/SpineLoader.js @@ -0,0 +1,10 @@ +describe('pixi/loaders/SpineLoader', function () { + 'use strict'; + + var expect = chai.expect; + var SpineLoader = PIXI.SpineLoader; + + it('Module exists', function () { + expect(SpineLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/loaders/SpriteSheetLoader.js b/test/unit/pixi-v2/loaders/SpriteSheetLoader.js new file mode 100644 index 0000000..57beb27 --- /dev/null +++ b/test/unit/pixi-v2/loaders/SpriteSheetLoader.js @@ -0,0 +1,10 @@ +describe('pixi/loaders/SpriteSheetLoader', function () { + 'use strict'; + + var expect = chai.expect; + var SpriteSheetLoader = PIXI.SpriteSheetLoader; + + it('Module exists', function () { + expect(SpriteSheetLoader).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/primitives/Graphics.js b/test/unit/pixi-v2/primitives/Graphics.js new file mode 100644 index 0000000..f3849eb --- /dev/null +++ b/test/unit/pixi-v2/primitives/Graphics.js @@ -0,0 +1,44 @@ +describe('pixi/primitives/Graphics', function () { + 'use strict'; + + var expect = chai.expect; + var Graphics = PIXI.Graphics; + + it('Module exists', function () { + expect(Graphics).to.be.a('function'); + + expect(Graphics).itself.to.have.property('POLY', 0); + expect(Graphics).itself.to.have.property('RECT', 1); + expect(Graphics).itself.to.have.property('CIRC', 2); + expect(Graphics).itself.to.have.property('ELIP', 3); + expect(Graphics).itself.to.have.property('RREC', 4); + }); + + it('Confirm new instance', function () { + var obj = new Graphics(); + + pixi_display_DisplayObjectContainer_confirmNew(obj); + + expect(obj).to.be.an.instanceof(Graphics); + expect(obj).to.respondTo('lineStyle'); + expect(obj).to.respondTo('lineStyle'); + expect(obj).to.respondTo('moveTo'); + expect(obj).to.respondTo('lineTo'); + expect(obj).to.respondTo('beginFill'); + expect(obj).to.respondTo('endFill'); + expect(obj).to.respondTo('drawRect'); + // expect(obj).to.respondTo('drawRoundedRect'); + expect(obj).to.respondTo('drawCircle'); + expect(obj).to.respondTo('drawEllipse'); + expect(obj).to.respondTo('clear'); + + expect(obj).to.have.property('renderable', true); + expect(obj).to.have.property('fillAlpha', 1); + expect(obj).to.have.property('lineWidth', 0); + expect(obj).to.have.property('width', 0); + expect(obj).to.have.property('height', 0); + expect(obj).to.have.property('lineColor', 0); + expect(obj).to.have.deep.property('graphicsData.length', 0); + // expect(obj).to.have.deep.property('currentPath.points.length', 0); + }); +}); diff --git a/test/unit/pixi-v2/renderers/canvas/CanvasGraphics.js b/test/unit/pixi-v2/renderers/canvas/CanvasGraphics.js new file mode 100644 index 0000000..8f44472 --- /dev/null +++ b/test/unit/pixi-v2/renderers/canvas/CanvasGraphics.js @@ -0,0 +1,15 @@ +describe('renders/canvas/CanvasGraphics', function () { + 'use strict'; + + var expect = chai.expect; + var CanvasGraphics = PIXI.CanvasGraphics; + + it('Module exists', function () { + expect(CanvasGraphics).to.be.a('function'); + }); + + it('Members exist', function () { + expect(CanvasGraphics).itself.to.respondTo('renderGraphics'); + expect(CanvasGraphics).itself.to.respondTo('renderGraphicsMask'); + }); +}); diff --git a/test/unit/pixi-v2/renderers/canvas/CanvasRenderer.js b/test/unit/pixi-v2/renderers/canvas/CanvasRenderer.js new file mode 100644 index 0000000..1646444 --- /dev/null +++ b/test/unit/pixi-v2/renderers/canvas/CanvasRenderer.js @@ -0,0 +1,36 @@ +describe('renderers/canvas/CanvasRenderer', function () { + 'use strict'; + + var expect = chai.expect; + var CanvasRenderer = PIXI.CanvasRenderer; + + it('Module exists', function () { + expect(CanvasRenderer).to.be.a('function'); + }); + + describe('.autoResize', function () { + it('Should automatically resize view if enabled', function () { + var renderer = new CanvasRenderer(200, 200, { + autoResize: true + }); + + expect(renderer.view.style.width).to.equal('200px'); + }); + + it('Should not automatically resize view if disabled', function () { + var renderer = new CanvasRenderer(200, 200, { + autoResize: false + }); + + expect(renderer.view.style.width).to.equal(''); + }); + + it('Should not automatically resize view if not specified', function () { + var renderer = new CanvasRenderer(200, 200, { + resolution: 2 + }); + + expect(renderer.view.style.width).to.equal(''); + }); + }); +}); diff --git a/test/unit/pixi-v2/renderers/webgl/WebGLGraphics.js b/test/unit/pixi-v2/renderers/webgl/WebGLGraphics.js new file mode 100644 index 0000000..5867b28 --- /dev/null +++ b/test/unit/pixi-v2/renderers/webgl/WebGLGraphics.js @@ -0,0 +1,20 @@ +describe('renderers/wegbl/WebGLGraphics', function () { + 'use strict'; + + var expect = chai.expect; + var WebGLGraphics = PIXI.WebGLGraphics; + + it('Module exists', function () { + expect(WebGLGraphics).to.be.a('function'); + }); + + it('Members exist', function () { + expect(WebGLGraphics).itself.to.respondTo('renderGraphics'); + expect(WebGLGraphics).itself.to.respondTo('updateGraphics'); + expect(WebGLGraphics).itself.to.respondTo('buildRectangle'); + expect(WebGLGraphics).itself.to.respondTo('buildRoundedRectangle'); + expect(WebGLGraphics).itself.to.respondTo('buildCircle'); + expect(WebGLGraphics).itself.to.respondTo('buildLine'); + expect(WebGLGraphics).itself.to.respondTo('buildPoly'); + }); +}); diff --git a/test/unit/pixi-v2/renderers/webgl/WebGLRenderer.js b/test/unit/pixi-v2/renderers/webgl/WebGLRenderer.js new file mode 100644 index 0000000..1680a80 --- /dev/null +++ b/test/unit/pixi-v2/renderers/webgl/WebGLRenderer.js @@ -0,0 +1,49 @@ +describe('renderers/webgl/WebGLRenderer', function () { + 'use strict'; + + var expect = chai.expect; + var WebGLRenderer = PIXI.WebGLRenderer; + + it('Module exists', function () { + expect(WebGLRenderer).to.be.a('function'); + }); + + // Skip tests if WebGL is not available (WebGL not supported in Travis CI) + try { + var renderer = new WebGLRenderer(400, 300, {}); + renderer.destroy(); + } catch (error) { + return; + } + + it('Destroy renderer', function () { + var renderer = new WebGLRenderer(400, 300, {}); + renderer.destroy(); + }); + + describe('.autoResize', function () { + it('Should automatically resize view if enabled', function () { + var renderer = new WebGLRenderer(200, 200, { + autoResize: true + }); + + expect(renderer.view.style.width).to.equal('200px'); + }); + + it('Should not automatically resize view if disabled', function () { + var renderer = new WebGLRenderer(200, 200, { + autoResize: false + }); + + expect(renderer.view.style.width).to.equal(''); + }); + + it('Should not automatically resize view if not specified', function () { + var renderer = new WebGLRenderer(200, 200, { + resolution: 2 + }); + + expect(renderer.view.style.width).to.equal(''); + }); + }); +}); diff --git a/test/unit/pixi-v2/renderers/webgl/WebGLShaders.js b/test/unit/pixi-v2/renderers/webgl/WebGLShaders.js new file mode 100644 index 0000000..6e33e4f --- /dev/null +++ b/test/unit/pixi-v2/renderers/webgl/WebGLShaders.js @@ -0,0 +1,13 @@ +describe('renderers/webgl/WebGLShaders', function () { + 'use strict'; + + var expect = chai.expect; + + it('Module members exist', function () { + + expect(PIXI).to.respondTo('CompileVertexShader'); + expect(PIXI).to.respondTo('CompileFragmentShader'); + expect(PIXI).to.respondTo('_CompileShader'); + expect(PIXI).to.respondTo('compileProgram'); + }); +}); diff --git a/test/unit/pixi-v2/renderers/webgl/WebGLSpriteBatch.js b/test/unit/pixi-v2/renderers/webgl/WebGLSpriteBatch.js new file mode 100644 index 0000000..e662b63 --- /dev/null +++ b/test/unit/pixi-v2/renderers/webgl/WebGLSpriteBatch.js @@ -0,0 +1,10 @@ +describe('renderers/webgl/utils/WebGLSpriteBatch', function () { + 'use strict'; + + var expect = chai.expect; + var WebGLSpriteBatch = PIXI.WebGLSpriteBatch; + + it('Module exists', function () { + expect(WebGLSpriteBatch).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/text/BitmapText.js b/test/unit/pixi-v2/text/BitmapText.js new file mode 100644 index 0000000..9388e3d --- /dev/null +++ b/test/unit/pixi-v2/text/BitmapText.js @@ -0,0 +1,10 @@ +describe('pixi/text/BitmapText', function () { + 'use strict'; + + var expect = chai.expect; + var BitmapText = PIXI.BitmapText; + + it('Module exists', function () { + expect(BitmapText).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/text/Text.js b/test/unit/pixi-v2/text/Text.js new file mode 100644 index 0000000..9bc9ac5 --- /dev/null +++ b/test/unit/pixi-v2/text/Text.js @@ -0,0 +1,10 @@ +describe('pixi/text/Text', function () { + 'use strict'; + + var expect = chai.expect; + var Text = PIXI.Text; + + it('Module exists', function () { + expect(Text).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/textures/BaseTexture.js b/test/unit/pixi-v2/textures/BaseTexture.js new file mode 100644 index 0000000..502b724 --- /dev/null +++ b/test/unit/pixi-v2/textures/BaseTexture.js @@ -0,0 +1,11 @@ +describe('pixi/textures/BaseTexture', function () { + 'use strict'; + + var expect = chai.expect; + var BaseTexture = PIXI.BaseTexture; + + it('Module exists', function () { + expect(BaseTexture).to.be.a('function'); + expect(PIXI).to.have.property('BaseTextureCache').and.to.be.an('object'); + }); +}); diff --git a/test/unit/pixi-v2/textures/RenderTexture.js b/test/unit/pixi-v2/textures/RenderTexture.js new file mode 100644 index 0000000..96acdb4 --- /dev/null +++ b/test/unit/pixi-v2/textures/RenderTexture.js @@ -0,0 +1,15 @@ +describe('pixi/textures/RenderTexture', function () { + 'use strict'; + + var expect = chai.expect; + var RenderTexture = PIXI.RenderTexture; + + it('Module exists', function () { + expect(RenderTexture).to.be.a('function'); + }); + + it('Confirm new instance', function (done) { + var texture = new RenderTexture(100, 100, new PIXI.CanvasRenderer()); + pixi_textures_RenderTexture_confirmNew(texture, done); + }); +}); diff --git a/test/unit/pixi-v2/textures/Texture.js b/test/unit/pixi-v2/textures/Texture.js new file mode 100644 index 0000000..090f64d --- /dev/null +++ b/test/unit/pixi-v2/textures/Texture.js @@ -0,0 +1,26 @@ +describe('pixi/textures/Texture', function () { + 'use strict'; + + var expect = chai.expect; + var Texture = PIXI.Texture; + + it('Module exists', function () { + expect(Texture).to.be.a('function'); + expect(PIXI).to.have.property('TextureCache').and.to.be.an('object'); + }); + + it('Members exist', function () { + expect(Texture).itself.to.respondTo('fromImage'); + expect(Texture).itself.to.respondTo('fromFrame'); + expect(Texture).itself.to.respondTo('fromCanvas'); + expect(Texture).itself.to.respondTo('addTextureToCache'); + expect(Texture).itself.to.respondTo('removeTextureFromCache'); + + // expect(Texture).itself.to.have.deep.property('frameUpdates.length', 0); + }); + + it('Confirm new instance', function (done) { + var texture = Texture.fromImage('/base/test/textures/bunny.png'); + pixi_textures_Texture_confirmNew(texture, done); + }); +}); diff --git a/test/unit/pixi-v2/utils/Detector.js b/test/unit/pixi-v2/utils/Detector.js new file mode 100644 index 0000000..4cf6008 --- /dev/null +++ b/test/unit/pixi-v2/utils/Detector.js @@ -0,0 +1,10 @@ +describe('pixi/utils/Detector', function () { + 'use strict'; + + var expect = chai.expect; + var autoDetectRenderer = PIXI.autoDetectRenderer; + + it('Module exists', function () { + expect(autoDetectRenderer).to.be.a('function'); + }); +}); diff --git a/test/unit/pixi-v2/utils/EventTarget.js b/test/unit/pixi-v2/utils/EventTarget.js new file mode 100644 index 0000000..1cfc3a4 --- /dev/null +++ b/test/unit/pixi-v2/utils/EventTarget.js @@ -0,0 +1,361 @@ +describe('pixi/utils/EventTarget', function () { + 'use strict'; + + var expect = chai.expect; + + var Clazz, PClazz, obj, pobj, obj2; + beforeEach(function () { + Clazz = function () {}; + PClazz = function () {}; + + PIXI.EventTarget.mixin(Clazz.prototype); + PIXI.EventTarget.mixin(PClazz.prototype); + + obj = new Clazz(); + obj2 = new Clazz(); + pobj = new PClazz(); + + obj.parent = pobj; + obj2.parent = obj; + }); + + it('Module exists', function () { + expect(PIXI.EventTarget).to.be.an('object'); + }); + + it('Confirm new instance', function () { + pixi_utils_EventTarget_confirm(obj); + }); + + it('simple on/emit case works', function () { + var myData = {}; + + obj.on('myevent', function (event) { + pixi_utils_EventTarget_Event_confirm(event, obj, myData); + }); + + obj.emit('myevent', myData); + }); + + it('simple once case works', function () { + var called = 0; + + obj.once('myevent', function() { called++; }); + + obj.emit('myevent'); + obj.emit('myevent'); + obj.emit('myevent'); + obj.emit('myevent'); + obj.emit('myevent'); + + expect(called).to.equal(1); + }); + + it('simple off case works', function (done) { + function onMyEvent() { + done(new Error('Event listener should not have been called')); + } + + obj.on('myevent', onMyEvent); + obj.off('myevent', onMyEvent); + obj.emit('myevent'); + + done(); + }); + + it('simple propagation case works', function (done) { + var myData = {}; + + pobj.on('myevent', function () { + done(); + }); + + obj.emit('myevent'); + }); + + it('simple stopPropagation case works', function (done) { + var myData = {}; + + pobj.on('myevent', function () { + done(new Error('Event listener should not have been called on the parent element')); + }); + + obj.on('myevent', function (evt) { + evt.stopPropagation(); + }); + + obj.emit('myevent'); + + done(); + }); + + it('simple stopImmediatePropagation case works', function (done) { + var myData = {}; + + pobj.on('myevent', function () { + done(new Error('Event listener should not have been called on the parent')); + }); + + obj.on('myevent', function (evt) { + evt.stopImmediatePropagation(); + }); + + obj.on('myevent', function () { + done(new Error('Event listener should not have been called on the second')); + }); + + obj.emit('myevent'); + + done(); + }); + + it('multiple dispatches work properly', function () { + var called = 0; + + function onMyEvent() { + called++; + } + + obj.on('myevent', onMyEvent); + obj.emit('myevent'); + obj.emit('myevent'); + obj.emit('myevent'); + obj.emit('myevent'); + + expect(called).to.equal(4); + }); + + it('multiple events work properly', function () { + var called = 0; + + function onMyEvent() { + called++; + } + + obj.on('myevent1', onMyEvent); + obj.on('myevent2', onMyEvent); + obj.on('myevent3', onMyEvent); + obj.emit('myevent1'); + obj.emit('myevent2'); + obj.emit('myevent3'); + + expect(called).to.equal(3); + }); + + it('multiple events one removed works properly', function () { + var called = 0; + + function onMyEvent() { + called++; + } + + obj.on('myevent1', onMyEvent); + obj.on('myevent2', onMyEvent); + obj.on('myevent3', onMyEvent); + + obj.emit('myevent1'); + obj.emit('myevent2'); + obj.emit('myevent3'); + + obj.off('myevent2', onMyEvent); + + obj.emit('myevent1'); + obj.emit('myevent2'); + obj.emit('myevent3'); + + expect(called).to.equal(5); + }); + + it('multiple handlers for one event with some removed', function () { + var called = 0; + + var onMyEvent = function () { + called++; + }, + onMyEvent2 = function () { + called++; + }; + + // add 2 handlers and confirm they both get called + obj.on('myevent', onMyEvent); + obj.on('myevent', onMyEvent); + obj.on('myevent', onMyEvent2); + obj.on('myevent', onMyEvent2); + + obj.emit('myevent'); + + expect(called).to.equal(4); + + // remove one of the handlers, emit again, then ensure 1 more call is made + obj.off('myevent', onMyEvent); + + obj.emit('myevent'); + + expect(called).to.equal(6); + }); + + it('calls to off without a handler do nothing', function () { + var called = 0; + + var onMyEvent = function () { + called++; + }; + + obj.on('myevent', onMyEvent); + obj.on('myevent', onMyEvent); + + obj.emit('myevent'); + + expect(called).to.equal(2); + + obj.off('myevent'); + + obj.emit('myevent'); + + expect(called).to.equal(4); + + obj.off('myevent', onMyEvent); + + obj.emit('myevent'); + + expect(called).to.equal(4); + }); + + it('handles multiple instances with the same prototype', function () { + var called = 0; + + function onMyEvent(e) { + called++; + } + + obj.on('myevent1', onMyEvent); + obj.on('myevent2', onMyEvent); + + obj2.istwo = true; + obj2.on('myevent1', onMyEvent); + obj2.on('myevent2', onMyEvent); + + obj.emit('myevent1'); + obj.emit('myevent2'); + obj2.emit('myevent1'); + obj2.emit('myevent2'); + + //we emit 4 times, but since obj2 is a child of obj the event should bubble + //up to obj and show up there as well. So the obj2.emit() calls each increment + //the counter twice. + expect(called).to.equal(6); + }); + + it('is backwards compatible with older .dispatchEvent({})', function () { + var called = 0, + data = { + some: 'thing', + hello: true + }; + + function onMyEvent(event) { + pixi_utils_EventTarget_Event_confirm(event, obj, data); + + called++; + } + + obj.on('myevent1', onMyEvent); + obj.on('myevent2', onMyEvent); + obj.on('myevent3', onMyEvent); + + data.type = 'myevent1'; + obj.emit(data); + + data.type = 'myevent2'; + obj.emit(data); + + data.type = 'myevent3'; + obj.emit(data); + + obj.off('myevent2', onMyEvent); + + data.type = 'myevent1'; + obj.emit(data); + + data.type = 'myevent2'; + obj.emit(data); + + data.type = 'myevent3'; + obj.emit(data); + + expect(called).to.equal(5); + }); + + it('is backwards compatible with older .call(this)', function () { + var Fn = function() { + PIXI.EventTarget.call(this); + }, + o = new Fn(); + + pixi_utils_EventTarget_confirm(o); + }); + + it('is backwards compatible with older .addEventListener("")', function () { + var called = 0, + data = { + some: 'thing', + hello: true + }; + + function onMyEvent(event) { + pixi_utils_EventTarget_Event_confirm(event, obj, data); + + called++; + } + + obj.addEventListener('myevent1', onMyEvent); + obj.addEventListener('myevent2', onMyEvent); + obj.addEventListener('myevent3', onMyEvent); + + data.type = 'myevent1'; + obj.emit(data); + + data.type = 'myevent2'; + obj.emit(data); + + data.type = 'myevent3'; + obj.emit(data); + + obj.off('myevent2', onMyEvent); + + data.type = 'myevent1'; + obj.emit(data); + + data.type = 'myevent2'; + obj.emit(data); + + data.type = 'myevent3'; + obj.emit(data); + + expect(called).to.equal(5); + }); + + it('event remove during emit call properly', function () { + var called = 0; + + function cb1() { + called++; + obj.off('myevent', cb1); + } + function cb2() { + called++; + obj.off('myevent', cb2); + } + function cb3() { + called++; + obj.off('myevent', cb3); + } + + obj.on('myevent', cb1); + obj.on('myevent', cb2); + obj.on('myevent', cb3); + obj.emit('myevent', ''); + + expect(called).to.equal(3); + }); +}); diff --git a/test/unit/pixi-v2/utils/Polyk.js b/test/unit/pixi-v2/utils/Polyk.js new file mode 100644 index 0000000..dfc7128 --- /dev/null +++ b/test/unit/pixi-v2/utils/Polyk.js @@ -0,0 +1,14 @@ +describe('pixi/utils/Polyk', function () { + 'use strict'; + + var expect = chai.expect; + var PolyK = PIXI.PolyK; + + it('Module exists', function () { + expect(PolyK).to.be.an('object'); + }); + + it('Members exist', function () { + expect(PolyK).to.respondTo('Triangulate'); + }); +}); diff --git a/test/unit/pixi-v2/utils/Utils.js b/test/unit/pixi-v2/utils/Utils.js new file mode 100644 index 0000000..c97b3c6 --- /dev/null +++ b/test/unit/pixi-v2/utils/Utils.js @@ -0,0 +1,17 @@ +describe('Utils', function () { + 'use strict'; + + var expect = chai.expect; + + it('requestAnimationFrame exists', function () { + expect(global).to.respondTo('requestAnimationFrame'); + }); + + it('cancelAnimationFrame exists', function () { + expect(global).to.respondTo('cancelAnimationFrame'); + }); + + it('requestAnimFrame exists', function () { + expect(global).to.respondTo('requestAnimFrame'); + }); +}); diff --git a/test/unit/pixi/InteractionManager.js b/test/unit/pixi/InteractionManager.js deleted file mode 100644 index ed3001f..0000000 --- a/test/unit/pixi/InteractionManager.js +++ /dev/null @@ -1,10 +0,0 @@ -describe('pixi/InteractionManager', function () { - 'use strict'; - - var expect = chai.expect; - var InteractionManager = PIXI.InteractionManager; - - it('Module exists', function () { - expect(InteractionManager).to.be.a('function'); - }); -}); diff --git a/test/unit/pixi/Pixi.js b/test/unit/pixi/Pixi.js deleted file mode 100644 index 27debc1..0000000 --- a/test/unit/pixi/Pixi.js +++ /dev/null @@ -1,9 +0,0 @@ -describe('pixi/Pixi', function () { - 'use strict'; - - var expect = chai.expect; - - it('Module exists', function () { - expect(global).to.have.property('PIXI').and.to.be.an('object'); - }); -}); diff --git a/test/unit/pixi/core/Circle.js b/test/unit/pixi/core/Circle.js deleted file mode 100644 index fbcfa17..0000000 --- a/test/unit/pixi/core/Circle.js +++ /dev/null @@ -1,21 +0,0 @@ -describe('pixi/core/Circle', function () { - 'use strict'; - - var expect = chai.expect; - var Circle = PIXI.Circle; - - it('Module exists', function () { - expect(Circle).to.be.a('function'); - }); - - it('Confirm new instance', function () { - var obj = new Circle(); - pixi_core_Circle_confirmNewCircle(obj); - }); - - it("getBounds should return Rectangle that bounds the circle", function() { - var obj = new Circle(100, 250, 50); - var bounds = obj.getBounds(); - pixi_core_Circle_isBoundedByRectangle(obj, bounds); - }); -}); diff --git a/test/unit/pixi/core/Ellipse.js b/test/unit/pixi/core/Ellipse.js deleted file mode 100644 index 026b56f..0000000 --- a/test/unit/pixi/core/Ellipse.js +++ /dev/null @@ -1,24 +0,0 @@ -describe('pixi/core/Ellipse', function () { - 'use strict'; - - var expect = chai.expect; - var Ellipse = PIXI.Ellipse; - - it('Module exists', function () { - expect(Ellipse).to.be.a('function'); - }); - - it('Confirm new instance', function () { - var obj = new Ellipse(); - - expect(obj).to.be.an.instanceof(Ellipse); - expect(obj).to.respondTo('clone'); - expect(obj).to.respondTo('contains'); - expect(obj).to.respondTo('getBounds'); - - expect(obj).to.have.property('x', 0); - expect(obj).to.have.property('y', 0); - expect(obj).to.have.property('width', 0); - expect(obj).to.have.property('height', 0); - }); -}); diff --git a/test/unit/pixi/core/Matrix.js b/test/unit/pixi/core/Matrix.js deleted file mode 100644 index da75e2e..0000000 --- a/test/unit/pixi/core/Matrix.js +++ /dev/null @@ -1,14 +0,0 @@ -describe('pixi/core/Matrix', function () { - 'use strict'; - - var expect = chai.expect; - - it('Matrix exists', function () { - expect(PIXI.Matrix).to.be.an('function'); - }); - - it('Confirm new Matrix', function () { - var matrix = new PIXI.Matrix(); - pixi_core_Matrix_confirmNewMatrix(matrix); - }); -}); diff --git a/test/unit/pixi/core/Point.js b/test/unit/pixi/core/Point.js deleted file mode 100644 index c4d5163..0000000 --- a/test/unit/pixi/core/Point.js +++ /dev/null @@ -1,15 +0,0 @@ -describe('pixi/core/Point', function () { - 'use strict'; - - var expect = chai.expect; - var Point = PIXI.Point; - - it('Module exists', function () { - expect(Point).to.be.a('function'); - }); - - it('Confirm new instance', function () { - var obj = new Point(); - pixi_core_Point_confirm(obj, 0, 0); - }); -}); diff --git a/test/unit/pixi/core/Polygon.js b/test/unit/pixi/core/Polygon.js deleted file mode 100644 index dc8c918..0000000 --- a/test/unit/pixi/core/Polygon.js +++ /dev/null @@ -1,20 +0,0 @@ -describe('pixi/core/Polygon', function () { - 'use strict'; - - var expect = chai.expect; - var Polygon = PIXI.Polygon; - - it('Module exists', function () { - expect(Polygon).to.be.a('function'); - }); - - it('Confirm new instance', function () { - var obj = new Polygon(); - - expect(obj).to.be.an.instanceof(Polygon); - expect(obj).to.respondTo('clone'); - expect(obj).to.respondTo('contains'); - - expect(obj).to.have.deep.property('points.length', 0); - }); -}); diff --git a/test/unit/pixi/core/Rectangle.js b/test/unit/pixi/core/Rectangle.js deleted file mode 100644 index d43316e..0000000 --- a/test/unit/pixi/core/Rectangle.js +++ /dev/null @@ -1,15 +0,0 @@ -describe('pixi/core/Rectangle', function () { - 'use strict'; - - var expect = chai.expect; - var Rectangle = PIXI.Rectangle; - - it('Module exists', function () { - expect(Rectangle).to.be.a('function'); - }); - - it('Confirm new instance', function () { - var rect = new Rectangle(); - pixi_core_Rectangle_confirm(rect, 0, 0, 0, 0); - }); -}); diff --git a/test/unit/pixi/display/DisplayObject.js b/test/unit/pixi/display/DisplayObject.js deleted file mode 100644 index 044acf8..0000000 --- a/test/unit/pixi/display/DisplayObject.js +++ /dev/null @@ -1,21 +0,0 @@ -describe('pixi/display/DisplayObject', function () { - 'use strict'; - - var expect = chai.expect; - var DisplayObject = PIXI.DisplayObject; - - it('Module exists', function () { - expect(DisplayObject).to.be.a('function'); - // expect(PIXI).to.have.property('visibleCount', 0); - }); - - it('Confirm new instance', function () { - var obj = new DisplayObject(); - - pixi_display_DisplayObject_confirmNew(obj); - expect(obj).to.have.property('hitArea', null); - expect(obj).to.have.property('interactive', false); - expect(obj).to.have.property('renderable', false); - expect(obj).to.have.property('stage', null); - }); -}); diff --git a/test/unit/pixi/display/DisplayObjectContainer.js b/test/unit/pixi/display/DisplayObjectContainer.js deleted file mode 100644 index 15a3376..0000000 --- a/test/unit/pixi/display/DisplayObjectContainer.js +++ /dev/null @@ -1,67 +0,0 @@ -describe('pixi/display/DisplayObjectContainer', function () { - 'use strict'; - - var expect = chai.expect; - var DisplayObjectContainer = PIXI.DisplayObjectContainer; - - it('Module exists', function () { - expect(DisplayObjectContainer).to.be.a('function'); - }); - - it('Confirm new instance', function () { - var obj = new DisplayObjectContainer(); - - pixi_display_DisplayObjectContainer_confirmNew(obj); - expect(obj).to.have.property('hitArea', null); - expect(obj).to.have.property('interactive', false); - expect(obj).to.have.property('renderable', false); - expect(obj).to.have.property('stage', null); - }); - - it('Gets child index', function() { - var container = new PIXI.DisplayObjectContainer(); - var children = []; - for (var i = 0; i < 10; i++) { - var child = new PIXI.DisplayObject(); - children.push(child); - container.addChild(child); - } - - for (i = 0; i < children.length; i++) { - expect(i).to.eql(container.getChildIndex(children[i])); - } - }); - - it('throws error when trying to get index of not a child', function() { - var container = new PIXI.DisplayObjectContainer(); - var child = new PIXI.DisplayObject(); - - expect(function() { container.getChildIndex(child); }).to.throw(); - }); - - it('Sets child index', function() { - var container = new PIXI.DisplayObjectContainer(); - var children = []; - - for (var i = 0; i < 10; i++) { - var child = new PIXI.DisplayObject(); - children.push(child); - container.addChild(child); - } - children.reverse(); - - for (i = 0; i < children.length; i++) { - container.setChildIndex(children[i], i); - expect(i).to.eql(container.getChildIndex(children[i])); - } - }); - - it('throws error when trying to set incorect index', function() { - var container = new PIXI.DisplayObjectContainer(); - var child = new PIXI.DisplayObject(); - container.addChild(child); - - expect(function() { container.setChildIndex(child, -1); }).to.throw(); - expect(function() { container.setChildIndex(child, 1); }).to.throw(); - }); -}); diff --git a/test/unit/pixi/display/MovieClip.js b/test/unit/pixi/display/MovieClip.js deleted file mode 100644 index f3c6c6a..0000000 --- a/test/unit/pixi/display/MovieClip.js +++ /dev/null @@ -1,33 +0,0 @@ -describe('pixi/display/MovieClip', function () { - 'use strict'; - - var expect = chai.expect; - var MovieClip = PIXI.MovieClip; - var Texture = PIXI.Texture; - - it('Module exists', function () { - expect(MovieClip).to.be.a('function'); - }); - - it('Confirm new instance', function (done) { - var texture = Texture.fromImage('/base/test/textures/SpriteSheet-Explosion.png'); - var obj = new MovieClip([texture]); - - pixi_display_Sprite_confirmNew(obj, done); - - expect(obj).to.be.an.instanceof(MovieClip); - expect(obj).to.respondTo('stop'); - expect(obj).to.respondTo('play'); - expect(obj).to.respondTo('gotoAndStop'); - expect(obj).to.respondTo('gotoAndPlay'); - expect(obj).to.respondTo('updateTransform'); - - expect(obj).to.have.deep.property('textures.length', 1); - expect(obj).to.have.deep.property('textures[0]', texture); - expect(obj).to.have.property('animationSpeed', 1); - expect(obj).to.have.property('loop', true); - expect(obj).to.have.property('onComplete', null); - expect(obj).to.have.property('currentFrame', 0); - expect(obj).to.have.property('playing', false); - }); -}); diff --git a/test/unit/pixi/display/Sprite.js b/test/unit/pixi/display/Sprite.js deleted file mode 100644 index 30c8076..0000000 --- a/test/unit/pixi/display/Sprite.js +++ /dev/null @@ -1,28 +0,0 @@ -describe('pixi/display/Sprite', function () { - 'use strict'; - - var expect = chai.expect; - var Sprite = PIXI.Sprite; - var Texture = PIXI.Texture; - - it('Module exists', function () { - expect(Sprite).to.be.a('function'); - expect(PIXI).to.have.deep.property('blendModes.NORMAL', 0); - expect(PIXI).to.have.deep.property('blendModes.ADD', 1); - expect(PIXI).to.have.deep.property('blendModes.MULTIPLY', 2); - expect(PIXI).to.have.deep.property('blendModes.SCREEN', 3); - }); - - - it('Members exist', function () { - expect(Sprite).itself.to.respondTo('fromImage'); - expect(Sprite).itself.to.respondTo('fromFrame'); - }); - - it('Confirm new instance', function (done) { - var texture = Texture.fromImage('/base/test/textures/SpriteSheet-Aliens.png'); - var obj = new Sprite(texture); - - pixi_display_Sprite_confirmNew(obj, done); - }); -}); diff --git a/test/unit/pixi/display/Stage.js b/test/unit/pixi/display/Stage.js deleted file mode 100644 index 6974c2e..0000000 --- a/test/unit/pixi/display/Stage.js +++ /dev/null @@ -1,49 +0,0 @@ -describe('pixi/display/Stage', function () { - 'use strict'; - - var expect = chai.expect; - var Stage = PIXI.Stage; - var InteractionManager = PIXI.InteractionManager; - var Rectangle = PIXI.Rectangle; - - it('Module exists', function () { - expect(Stage).to.be.a('function'); - }); - - it('Confirm new instance', function () { - var obj = new Stage(null, true); - - pixi_display_DisplayObjectContainer_confirmNew(obj); - - expect(obj).to.be.an.instanceof(Stage); - expect(obj).to.respondTo('updateTransform'); - expect(obj).to.respondTo('setBackgroundColor'); - expect(obj).to.respondTo('getMousePosition'); - // FIXME: duplicate member in DisplayObject - pixi_core_Matrix_confirmNewMatrix(obj.worldTransform); - // FIXME: convert arg to bool in constructor - expect(obj).to.have.property('interactive', true); - - expect(obj).to.have.property('interactionManager') - .and.to.be.an.instanceof(InteractionManager) - .and.to.have.property('stage', obj); - - expect(obj).to.have.property('dirty', true); - - expect(obj).to.have.property('stage', obj); - - expect(obj).to.have.property('hitArea') - .and.to.be.an.instanceof(Rectangle); - pixi_core_Rectangle_confirm(obj.hitArea, 0, 0, 100000, 100000); - - expect(obj).to.have.property('backgroundColor', 0x000000); - expect(obj).to.have.deep.property('backgroundColorSplit.length', 3); - expect(obj).to.have.deep.property('backgroundColorSplit[0]', 0); - expect(obj).to.have.deep.property('backgroundColorSplit[1]', 0); - expect(obj).to.have.deep.property('backgroundColorSplit[2]', 0); - expect(obj).to.have.property('backgroundColorString', '#000000'); - - - expect(obj).to.have.property('worldVisible', true); - }); -}); diff --git a/test/unit/pixi/extras/Rope.js b/test/unit/pixi/extras/Rope.js deleted file mode 100644 index 05885ac..0000000 --- a/test/unit/pixi/extras/Rope.js +++ /dev/null @@ -1,31 +0,0 @@ -describe('pixi/extras/Rope', function () { - 'use strict'; - - var expect = chai.expect; - var Rope = PIXI.Rope; - var Texture = PIXI.Texture; - var Point = PIXI.Point; - - it('Module exists', function () { - expect(Rope).to.be.a('function'); - }); - - it('Confirm new instance', function () { - - var texture = Texture.fromImage('/base/test/textures/bunny.png'); - - // TODO-Alvin - // Same as Strip - - // var obj = new Rope(texture, [new Point(), new Point(5, 10), new Point(10, 20)]); - - // pixi_extras_Strip_confirmNew(obj); - - // expect(obj).to.be.an.instanceof(Rope); - // expect(obj).to.respondTo('refresh'); - // expect(obj).to.respondTo('updateTransform'); - // expect(obj).to.respondTo('setTexture'); - - // TODO: Test properties - }); -}); diff --git a/test/unit/pixi/extras/Spine.js b/test/unit/pixi/extras/Spine.js deleted file mode 100644 index 0708bc0..0000000 --- a/test/unit/pixi/extras/Spine.js +++ /dev/null @@ -1,10 +0,0 @@ -describe('pixi/extras/Spine', function () { - 'use strict'; - - var expect = chai.expect; - var Spine = PIXI.Spine; - - it('Module exists', function () { - expect(Spine).to.be.a('function'); - }); -}); diff --git a/test/unit/pixi/extras/Strip.js b/test/unit/pixi/extras/Strip.js deleted file mode 100644 index 230af90..0000000 --- a/test/unit/pixi/extras/Strip.js +++ /dev/null @@ -1,26 +0,0 @@ -describe('pixi/extras/Strip', function () { - 'use strict'; - - var expect = chai.expect; - var Strip = PIXI.Strip; - var Texture = PIXI.Texture; - - it('Module exists', function () { - expect(Strip).to.be.a('function'); - }); - - it('Confirm new instance', function () { - - - // TODO-Alvin - // We tweaked it to make it pass the tests, but the whole strip class needs - // to be re-coded - - var texture = Texture.fromImage('/base/test/textures/bunny.png'); - - // var obj = new Strip(texture, 20, 10000); - - - // pixi_extras_Strip_confirmNew(obj); - }); -}); diff --git a/test/unit/pixi/extras/TilingSprite.js b/test/unit/pixi/extras/TilingSprite.js deleted file mode 100644 index 56aea14..0000000 --- a/test/unit/pixi/extras/TilingSprite.js +++ /dev/null @@ -1,24 +0,0 @@ -describe('pixi/extras/TilingSprite', function () { - 'use strict'; - - var expect = chai.expect; - var TilingSprite = PIXI.TilingSprite; - var Texture = PIXI.Texture; - - it('Module exists', function () { - expect(TilingSprite).to.be.a('function'); - }); - - it('Confirm new instance', function () { - var texture = Texture.fromImage('/base/test/textures/bunny.png'); - var obj = new TilingSprite(texture, 6000, 12000); - - pixi_display_DisplayObjectContainer_confirmNew(obj); - - expect(obj).to.be.an.instanceof(TilingSprite); - expect(obj).to.respondTo('setTexture'); - expect(obj).to.respondTo('onTextureUpdate'); - - // TODO: Test properties - }); -}); diff --git a/test/unit/pixi/filters/FilterBlock.js b/test/unit/pixi/filters/FilterBlock.js deleted file mode 100644 index 870cec0..0000000 --- a/test/unit/pixi/filters/FilterBlock.js +++ /dev/null @@ -1,10 +0,0 @@ -describe('pixi/filters/FilterBlock', function () { - 'use strict'; - - var expect = chai.expect; - var FilterBlock = PIXI.FilterBlock; - - it('Module exists', function () { - expect(FilterBlock).to.be.a('function'); - }); -}); diff --git a/test/unit/pixi/loaders/AssetLoader.js b/test/unit/pixi/loaders/AssetLoader.js deleted file mode 100644 index a0aa0b5..0000000 --- a/test/unit/pixi/loaders/AssetLoader.js +++ /dev/null @@ -1,10 +0,0 @@ -describe('pixi/loaders/AssetLoader', function () { - 'use strict'; - - var expect = chai.expect; - var AssetLoader = PIXI.AssetLoader; - - it('Module exists', function () { - expect(AssetLoader).to.be.a('function'); - }); -}); diff --git a/test/unit/pixi/loaders/BitmapFontLoader.js b/test/unit/pixi/loaders/BitmapFontLoader.js deleted file mode 100644 index 046f018..0000000 --- a/test/unit/pixi/loaders/BitmapFontLoader.js +++ /dev/null @@ -1,9 +0,0 @@ -describe('pixi/loaders/BitmapFontLoader', function () { - 'use strict'; - - var expect = chai.expect; - - it('Module exists', function () { - expect(PIXI.BitmapFontLoader).to.be.a('function'); - }); -}); diff --git a/test/unit/pixi/loaders/ImageLoader.js b/test/unit/pixi/loaders/ImageLoader.js deleted file mode 100644 index 8b1f556..0000000 --- a/test/unit/pixi/loaders/ImageLoader.js +++ /dev/null @@ -1,10 +0,0 @@ -describe('pixi/loaders/ImageLoader', function () { - 'use strict'; - - var expect = chai.expect; - var ImageLoader = PIXI.ImageLoader; - - it('Module exists', function () { - expect(ImageLoader).to.be.a('function'); - }); -}); diff --git a/test/unit/pixi/loaders/JsonLoader.js b/test/unit/pixi/loaders/JsonLoader.js deleted file mode 100644 index c577e83..0000000 --- a/test/unit/pixi/loaders/JsonLoader.js +++ /dev/null @@ -1,10 +0,0 @@ -describe('pixi/loaders/JsonLoader', function () { - 'use strict'; - - var expect = chai.expect; - var JsonLoader = PIXI.JsonLoader; - - it('Module exists', function () { - expect(JsonLoader).to.be.a('function'); - }); -}); diff --git a/test/unit/pixi/loaders/SpineLoader.js b/test/unit/pixi/loaders/SpineLoader.js deleted file mode 100644 index fdcc0b8..0000000 --- a/test/unit/pixi/loaders/SpineLoader.js +++ /dev/null @@ -1,10 +0,0 @@ -describe('pixi/loaders/SpineLoader', function () { - 'use strict'; - - var expect = chai.expect; - var SpineLoader = PIXI.SpineLoader; - - it('Module exists', function () { - expect(SpineLoader).to.be.a('function'); - }); -}); diff --git a/test/unit/pixi/loaders/SpriteSheetLoader.js b/test/unit/pixi/loaders/SpriteSheetLoader.js deleted file mode 100644 index 57beb27..0000000 --- a/test/unit/pixi/loaders/SpriteSheetLoader.js +++ /dev/null @@ -1,10 +0,0 @@ -describe('pixi/loaders/SpriteSheetLoader', function () { - 'use strict'; - - var expect = chai.expect; - var SpriteSheetLoader = PIXI.SpriteSheetLoader; - - it('Module exists', function () { - expect(SpriteSheetLoader).to.be.a('function'); - }); -}); diff --git a/test/unit/pixi/primitives/Graphics.js b/test/unit/pixi/primitives/Graphics.js deleted file mode 100644 index f3849eb..0000000 --- a/test/unit/pixi/primitives/Graphics.js +++ /dev/null @@ -1,44 +0,0 @@ -describe('pixi/primitives/Graphics', function () { - 'use strict'; - - var expect = chai.expect; - var Graphics = PIXI.Graphics; - - it('Module exists', function () { - expect(Graphics).to.be.a('function'); - - expect(Graphics).itself.to.have.property('POLY', 0); - expect(Graphics).itself.to.have.property('RECT', 1); - expect(Graphics).itself.to.have.property('CIRC', 2); - expect(Graphics).itself.to.have.property('ELIP', 3); - expect(Graphics).itself.to.have.property('RREC', 4); - }); - - it('Confirm new instance', function () { - var obj = new Graphics(); - - pixi_display_DisplayObjectContainer_confirmNew(obj); - - expect(obj).to.be.an.instanceof(Graphics); - expect(obj).to.respondTo('lineStyle'); - expect(obj).to.respondTo('lineStyle'); - expect(obj).to.respondTo('moveTo'); - expect(obj).to.respondTo('lineTo'); - expect(obj).to.respondTo('beginFill'); - expect(obj).to.respondTo('endFill'); - expect(obj).to.respondTo('drawRect'); - // expect(obj).to.respondTo('drawRoundedRect'); - expect(obj).to.respondTo('drawCircle'); - expect(obj).to.respondTo('drawEllipse'); - expect(obj).to.respondTo('clear'); - - expect(obj).to.have.property('renderable', true); - expect(obj).to.have.property('fillAlpha', 1); - expect(obj).to.have.property('lineWidth', 0); - expect(obj).to.have.property('width', 0); - expect(obj).to.have.property('height', 0); - expect(obj).to.have.property('lineColor', 0); - expect(obj).to.have.deep.property('graphicsData.length', 0); - // expect(obj).to.have.deep.property('currentPath.points.length', 0); - }); -}); diff --git a/test/unit/pixi/renderers/canvas/CanvasGraphics.js b/test/unit/pixi/renderers/canvas/CanvasGraphics.js deleted file mode 100644 index 8f44472..0000000 --- a/test/unit/pixi/renderers/canvas/CanvasGraphics.js +++ /dev/null @@ -1,15 +0,0 @@ -describe('renders/canvas/CanvasGraphics', function () { - 'use strict'; - - var expect = chai.expect; - var CanvasGraphics = PIXI.CanvasGraphics; - - it('Module exists', function () { - expect(CanvasGraphics).to.be.a('function'); - }); - - it('Members exist', function () { - expect(CanvasGraphics).itself.to.respondTo('renderGraphics'); - expect(CanvasGraphics).itself.to.respondTo('renderGraphicsMask'); - }); -}); diff --git a/test/unit/pixi/renderers/canvas/CanvasRenderer.js b/test/unit/pixi/renderers/canvas/CanvasRenderer.js deleted file mode 100644 index 1646444..0000000 --- a/test/unit/pixi/renderers/canvas/CanvasRenderer.js +++ /dev/null @@ -1,36 +0,0 @@ -describe('renderers/canvas/CanvasRenderer', function () { - 'use strict'; - - var expect = chai.expect; - var CanvasRenderer = PIXI.CanvasRenderer; - - it('Module exists', function () { - expect(CanvasRenderer).to.be.a('function'); - }); - - describe('.autoResize', function () { - it('Should automatically resize view if enabled', function () { - var renderer = new CanvasRenderer(200, 200, { - autoResize: true - }); - - expect(renderer.view.style.width).to.equal('200px'); - }); - - it('Should not automatically resize view if disabled', function () { - var renderer = new CanvasRenderer(200, 200, { - autoResize: false - }); - - expect(renderer.view.style.width).to.equal(''); - }); - - it('Should not automatically resize view if not specified', function () { - var renderer = new CanvasRenderer(200, 200, { - resolution: 2 - }); - - expect(renderer.view.style.width).to.equal(''); - }); - }); -}); diff --git a/test/unit/pixi/renderers/webgl/WebGLGraphics.js b/test/unit/pixi/renderers/webgl/WebGLGraphics.js deleted file mode 100644 index 5867b28..0000000 --- a/test/unit/pixi/renderers/webgl/WebGLGraphics.js +++ /dev/null @@ -1,20 +0,0 @@ -describe('renderers/wegbl/WebGLGraphics', function () { - 'use strict'; - - var expect = chai.expect; - var WebGLGraphics = PIXI.WebGLGraphics; - - it('Module exists', function () { - expect(WebGLGraphics).to.be.a('function'); - }); - - it('Members exist', function () { - expect(WebGLGraphics).itself.to.respondTo('renderGraphics'); - expect(WebGLGraphics).itself.to.respondTo('updateGraphics'); - expect(WebGLGraphics).itself.to.respondTo('buildRectangle'); - expect(WebGLGraphics).itself.to.respondTo('buildRoundedRectangle'); - expect(WebGLGraphics).itself.to.respondTo('buildCircle'); - expect(WebGLGraphics).itself.to.respondTo('buildLine'); - expect(WebGLGraphics).itself.to.respondTo('buildPoly'); - }); -}); diff --git a/test/unit/pixi/renderers/webgl/WebGLRenderer.js b/test/unit/pixi/renderers/webgl/WebGLRenderer.js deleted file mode 100644 index 1680a80..0000000 --- a/test/unit/pixi/renderers/webgl/WebGLRenderer.js +++ /dev/null @@ -1,49 +0,0 @@ -describe('renderers/webgl/WebGLRenderer', function () { - 'use strict'; - - var expect = chai.expect; - var WebGLRenderer = PIXI.WebGLRenderer; - - it('Module exists', function () { - expect(WebGLRenderer).to.be.a('function'); - }); - - // Skip tests if WebGL is not available (WebGL not supported in Travis CI) - try { - var renderer = new WebGLRenderer(400, 300, {}); - renderer.destroy(); - } catch (error) { - return; - } - - it('Destroy renderer', function () { - var renderer = new WebGLRenderer(400, 300, {}); - renderer.destroy(); - }); - - describe('.autoResize', function () { - it('Should automatically resize view if enabled', function () { - var renderer = new WebGLRenderer(200, 200, { - autoResize: true - }); - - expect(renderer.view.style.width).to.equal('200px'); - }); - - it('Should not automatically resize view if disabled', function () { - var renderer = new WebGLRenderer(200, 200, { - autoResize: false - }); - - expect(renderer.view.style.width).to.equal(''); - }); - - it('Should not automatically resize view if not specified', function () { - var renderer = new WebGLRenderer(200, 200, { - resolution: 2 - }); - - expect(renderer.view.style.width).to.equal(''); - }); - }); -}); diff --git a/test/unit/pixi/renderers/webgl/WebGLShaders.js b/test/unit/pixi/renderers/webgl/WebGLShaders.js deleted file mode 100644 index 6e33e4f..0000000 --- a/test/unit/pixi/renderers/webgl/WebGLShaders.js +++ /dev/null @@ -1,13 +0,0 @@ -describe('renderers/webgl/WebGLShaders', function () { - 'use strict'; - - var expect = chai.expect; - - it('Module members exist', function () { - - expect(PIXI).to.respondTo('CompileVertexShader'); - expect(PIXI).to.respondTo('CompileFragmentShader'); - expect(PIXI).to.respondTo('_CompileShader'); - expect(PIXI).to.respondTo('compileProgram'); - }); -}); diff --git a/test/unit/pixi/renderers/webgl/WebGLSpriteBatch.js b/test/unit/pixi/renderers/webgl/WebGLSpriteBatch.js deleted file mode 100644 index e662b63..0000000 --- a/test/unit/pixi/renderers/webgl/WebGLSpriteBatch.js +++ /dev/null @@ -1,10 +0,0 @@ -describe('renderers/webgl/utils/WebGLSpriteBatch', function () { - 'use strict'; - - var expect = chai.expect; - var WebGLSpriteBatch = PIXI.WebGLSpriteBatch; - - it('Module exists', function () { - expect(WebGLSpriteBatch).to.be.a('function'); - }); -}); diff --git a/test/unit/pixi/text/BitmapText.js b/test/unit/pixi/text/BitmapText.js deleted file mode 100644 index 9388e3d..0000000 --- a/test/unit/pixi/text/BitmapText.js +++ /dev/null @@ -1,10 +0,0 @@ -describe('pixi/text/BitmapText', function () { - 'use strict'; - - var expect = chai.expect; - var BitmapText = PIXI.BitmapText; - - it('Module exists', function () { - expect(BitmapText).to.be.a('function'); - }); -}); diff --git a/test/unit/pixi/text/Text.js b/test/unit/pixi/text/Text.js deleted file mode 100644 index 9bc9ac5..0000000 --- a/test/unit/pixi/text/Text.js +++ /dev/null @@ -1,10 +0,0 @@ -describe('pixi/text/Text', function () { - 'use strict'; - - var expect = chai.expect; - var Text = PIXI.Text; - - it('Module exists', function () { - expect(Text).to.be.a('function'); - }); -}); diff --git a/test/unit/pixi/textures/BaseTexture.js b/test/unit/pixi/textures/BaseTexture.js deleted file mode 100644 index 502b724..0000000 --- a/test/unit/pixi/textures/BaseTexture.js +++ /dev/null @@ -1,11 +0,0 @@ -describe('pixi/textures/BaseTexture', function () { - 'use strict'; - - var expect = chai.expect; - var BaseTexture = PIXI.BaseTexture; - - it('Module exists', function () { - expect(BaseTexture).to.be.a('function'); - expect(PIXI).to.have.property('BaseTextureCache').and.to.be.an('object'); - }); -}); diff --git a/test/unit/pixi/textures/RenderTexture.js b/test/unit/pixi/textures/RenderTexture.js deleted file mode 100644 index 96acdb4..0000000 --- a/test/unit/pixi/textures/RenderTexture.js +++ /dev/null @@ -1,15 +0,0 @@ -describe('pixi/textures/RenderTexture', function () { - 'use strict'; - - var expect = chai.expect; - var RenderTexture = PIXI.RenderTexture; - - it('Module exists', function () { - expect(RenderTexture).to.be.a('function'); - }); - - it('Confirm new instance', function (done) { - var texture = new RenderTexture(100, 100, new PIXI.CanvasRenderer()); - pixi_textures_RenderTexture_confirmNew(texture, done); - }); -}); diff --git a/test/unit/pixi/textures/Texture.js b/test/unit/pixi/textures/Texture.js deleted file mode 100644 index 090f64d..0000000 --- a/test/unit/pixi/textures/Texture.js +++ /dev/null @@ -1,26 +0,0 @@ -describe('pixi/textures/Texture', function () { - 'use strict'; - - var expect = chai.expect; - var Texture = PIXI.Texture; - - it('Module exists', function () { - expect(Texture).to.be.a('function'); - expect(PIXI).to.have.property('TextureCache').and.to.be.an('object'); - }); - - it('Members exist', function () { - expect(Texture).itself.to.respondTo('fromImage'); - expect(Texture).itself.to.respondTo('fromFrame'); - expect(Texture).itself.to.respondTo('fromCanvas'); - expect(Texture).itself.to.respondTo('addTextureToCache'); - expect(Texture).itself.to.respondTo('removeTextureFromCache'); - - // expect(Texture).itself.to.have.deep.property('frameUpdates.length', 0); - }); - - it('Confirm new instance', function (done) { - var texture = Texture.fromImage('/base/test/textures/bunny.png'); - pixi_textures_Texture_confirmNew(texture, done); - }); -}); diff --git a/test/unit/pixi/utils/Detector.js b/test/unit/pixi/utils/Detector.js deleted file mode 100644 index 4cf6008..0000000 --- a/test/unit/pixi/utils/Detector.js +++ /dev/null @@ -1,10 +0,0 @@ -describe('pixi/utils/Detector', function () { - 'use strict'; - - var expect = chai.expect; - var autoDetectRenderer = PIXI.autoDetectRenderer; - - it('Module exists', function () { - expect(autoDetectRenderer).to.be.a('function'); - }); -}); diff --git a/test/unit/pixi/utils/EventTarget.js b/test/unit/pixi/utils/EventTarget.js deleted file mode 100644 index 1cfc3a4..0000000 --- a/test/unit/pixi/utils/EventTarget.js +++ /dev/null @@ -1,361 +0,0 @@ -describe('pixi/utils/EventTarget', function () { - 'use strict'; - - var expect = chai.expect; - - var Clazz, PClazz, obj, pobj, obj2; - beforeEach(function () { - Clazz = function () {}; - PClazz = function () {}; - - PIXI.EventTarget.mixin(Clazz.prototype); - PIXI.EventTarget.mixin(PClazz.prototype); - - obj = new Clazz(); - obj2 = new Clazz(); - pobj = new PClazz(); - - obj.parent = pobj; - obj2.parent = obj; - }); - - it('Module exists', function () { - expect(PIXI.EventTarget).to.be.an('object'); - }); - - it('Confirm new instance', function () { - pixi_utils_EventTarget_confirm(obj); - }); - - it('simple on/emit case works', function () { - var myData = {}; - - obj.on('myevent', function (event) { - pixi_utils_EventTarget_Event_confirm(event, obj, myData); - }); - - obj.emit('myevent', myData); - }); - - it('simple once case works', function () { - var called = 0; - - obj.once('myevent', function() { called++; }); - - obj.emit('myevent'); - obj.emit('myevent'); - obj.emit('myevent'); - obj.emit('myevent'); - obj.emit('myevent'); - - expect(called).to.equal(1); - }); - - it('simple off case works', function (done) { - function onMyEvent() { - done(new Error('Event listener should not have been called')); - } - - obj.on('myevent', onMyEvent); - obj.off('myevent', onMyEvent); - obj.emit('myevent'); - - done(); - }); - - it('simple propagation case works', function (done) { - var myData = {}; - - pobj.on('myevent', function () { - done(); - }); - - obj.emit('myevent'); - }); - - it('simple stopPropagation case works', function (done) { - var myData = {}; - - pobj.on('myevent', function () { - done(new Error('Event listener should not have been called on the parent element')); - }); - - obj.on('myevent', function (evt) { - evt.stopPropagation(); - }); - - obj.emit('myevent'); - - done(); - }); - - it('simple stopImmediatePropagation case works', function (done) { - var myData = {}; - - pobj.on('myevent', function () { - done(new Error('Event listener should not have been called on the parent')); - }); - - obj.on('myevent', function (evt) { - evt.stopImmediatePropagation(); - }); - - obj.on('myevent', function () { - done(new Error('Event listener should not have been called on the second')); - }); - - obj.emit('myevent'); - - done(); - }); - - it('multiple dispatches work properly', function () { - var called = 0; - - function onMyEvent() { - called++; - } - - obj.on('myevent', onMyEvent); - obj.emit('myevent'); - obj.emit('myevent'); - obj.emit('myevent'); - obj.emit('myevent'); - - expect(called).to.equal(4); - }); - - it('multiple events work properly', function () { - var called = 0; - - function onMyEvent() { - called++; - } - - obj.on('myevent1', onMyEvent); - obj.on('myevent2', onMyEvent); - obj.on('myevent3', onMyEvent); - obj.emit('myevent1'); - obj.emit('myevent2'); - obj.emit('myevent3'); - - expect(called).to.equal(3); - }); - - it('multiple events one removed works properly', function () { - var called = 0; - - function onMyEvent() { - called++; - } - - obj.on('myevent1', onMyEvent); - obj.on('myevent2', onMyEvent); - obj.on('myevent3', onMyEvent); - - obj.emit('myevent1'); - obj.emit('myevent2'); - obj.emit('myevent3'); - - obj.off('myevent2', onMyEvent); - - obj.emit('myevent1'); - obj.emit('myevent2'); - obj.emit('myevent3'); - - expect(called).to.equal(5); - }); - - it('multiple handlers for one event with some removed', function () { - var called = 0; - - var onMyEvent = function () { - called++; - }, - onMyEvent2 = function () { - called++; - }; - - // add 2 handlers and confirm they both get called - obj.on('myevent', onMyEvent); - obj.on('myevent', onMyEvent); - obj.on('myevent', onMyEvent2); - obj.on('myevent', onMyEvent2); - - obj.emit('myevent'); - - expect(called).to.equal(4); - - // remove one of the handlers, emit again, then ensure 1 more call is made - obj.off('myevent', onMyEvent); - - obj.emit('myevent'); - - expect(called).to.equal(6); - }); - - it('calls to off without a handler do nothing', function () { - var called = 0; - - var onMyEvent = function () { - called++; - }; - - obj.on('myevent', onMyEvent); - obj.on('myevent', onMyEvent); - - obj.emit('myevent'); - - expect(called).to.equal(2); - - obj.off('myevent'); - - obj.emit('myevent'); - - expect(called).to.equal(4); - - obj.off('myevent', onMyEvent); - - obj.emit('myevent'); - - expect(called).to.equal(4); - }); - - it('handles multiple instances with the same prototype', function () { - var called = 0; - - function onMyEvent(e) { - called++; - } - - obj.on('myevent1', onMyEvent); - obj.on('myevent2', onMyEvent); - - obj2.istwo = true; - obj2.on('myevent1', onMyEvent); - obj2.on('myevent2', onMyEvent); - - obj.emit('myevent1'); - obj.emit('myevent2'); - obj2.emit('myevent1'); - obj2.emit('myevent2'); - - //we emit 4 times, but since obj2 is a child of obj the event should bubble - //up to obj and show up there as well. So the obj2.emit() calls each increment - //the counter twice. - expect(called).to.equal(6); - }); - - it('is backwards compatible with older .dispatchEvent({})', function () { - var called = 0, - data = { - some: 'thing', - hello: true - }; - - function onMyEvent(event) { - pixi_utils_EventTarget_Event_confirm(event, obj, data); - - called++; - } - - obj.on('myevent1', onMyEvent); - obj.on('myevent2', onMyEvent); - obj.on('myevent3', onMyEvent); - - data.type = 'myevent1'; - obj.emit(data); - - data.type = 'myevent2'; - obj.emit(data); - - data.type = 'myevent3'; - obj.emit(data); - - obj.off('myevent2', onMyEvent); - - data.type = 'myevent1'; - obj.emit(data); - - data.type = 'myevent2'; - obj.emit(data); - - data.type = 'myevent3'; - obj.emit(data); - - expect(called).to.equal(5); - }); - - it('is backwards compatible with older .call(this)', function () { - var Fn = function() { - PIXI.EventTarget.call(this); - }, - o = new Fn(); - - pixi_utils_EventTarget_confirm(o); - }); - - it('is backwards compatible with older .addEventListener("")', function () { - var called = 0, - data = { - some: 'thing', - hello: true - }; - - function onMyEvent(event) { - pixi_utils_EventTarget_Event_confirm(event, obj, data); - - called++; - } - - obj.addEventListener('myevent1', onMyEvent); - obj.addEventListener('myevent2', onMyEvent); - obj.addEventListener('myevent3', onMyEvent); - - data.type = 'myevent1'; - obj.emit(data); - - data.type = 'myevent2'; - obj.emit(data); - - data.type = 'myevent3'; - obj.emit(data); - - obj.off('myevent2', onMyEvent); - - data.type = 'myevent1'; - obj.emit(data); - - data.type = 'myevent2'; - obj.emit(data); - - data.type = 'myevent3'; - obj.emit(data); - - expect(called).to.equal(5); - }); - - it('event remove during emit call properly', function () { - var called = 0; - - function cb1() { - called++; - obj.off('myevent', cb1); - } - function cb2() { - called++; - obj.off('myevent', cb2); - } - function cb3() { - called++; - obj.off('myevent', cb3); - } - - obj.on('myevent', cb1); - obj.on('myevent', cb2); - obj.on('myevent', cb3); - obj.emit('myevent', ''); - - expect(called).to.equal(3); - }); -}); diff --git a/test/unit/pixi/utils/Polyk.js b/test/unit/pixi/utils/Polyk.js deleted file mode 100644 index dfc7128..0000000 --- a/test/unit/pixi/utils/Polyk.js +++ /dev/null @@ -1,14 +0,0 @@ -describe('pixi/utils/Polyk', function () { - 'use strict'; - - var expect = chai.expect; - var PolyK = PIXI.PolyK; - - it('Module exists', function () { - expect(PolyK).to.be.an('object'); - }); - - it('Members exist', function () { - expect(PolyK).to.respondTo('Triangulate'); - }); -}); diff --git a/test/unit/pixi/utils/Utils.js b/test/unit/pixi/utils/Utils.js deleted file mode 100644 index c97b3c6..0000000 --- a/test/unit/pixi/utils/Utils.js +++ /dev/null @@ -1,17 +0,0 @@ -describe('Utils', function () { - 'use strict'; - - var expect = chai.expect; - - it('requestAnimationFrame exists', function () { - expect(global).to.respondTo('requestAnimationFrame'); - }); - - it('cancelAnimationFrame exists', function () { - expect(global).to.respondTo('cancelAnimationFrame'); - }); - - it('requestAnimFrame exists', function () { - expect(global).to.respondTo('requestAnimFrame'); - }); -});