Permalink
Please sign in to comment.
Showing
with
115 additions
and 1,320 deletions.
- +2 −7 package.json
- BIN test/functional/example-1-basics/bunny.png
- BIN test/functional/example-1-basics/frame-30.png
- BIN test/functional/example-1-basics/frame-60.png
- BIN test/functional/example-1-basics/frame-90.png
- +0 −133 test/functional/example-1-basics/index.js
- +1 −0 test/setup.js
- +0 −22 test/unit/bin/pixi.js
- +89 −0 test/unit/core/utils/util.test.js
- +6 −0 test/unit/index.test.js
- +0 −10 test/unit/pixi-v2/InteractionManager.js
- +0 −9 test/unit/pixi-v2/Pixi.js
- +0 −21 test/unit/pixi-v2/core/Circle.js
- +0 −24 test/unit/pixi-v2/core/Ellipse.js
- +0 −14 test/unit/pixi-v2/core/Matrix.js
- +0 −15 test/unit/pixi-v2/core/Point.js
- +0 −20 test/unit/pixi-v2/core/Polygon.js
- +0 −15 test/unit/pixi-v2/core/Rectangle.js
- +0 −21 test/unit/pixi-v2/display/DisplayObject.js
- +0 −67 test/unit/pixi-v2/display/DisplayObjectContainer.js
- +0 −33 test/unit/pixi-v2/display/MovieClip.js
- +0 −28 test/unit/pixi-v2/display/Sprite.js
- +0 −49 test/unit/pixi-v2/display/Stage.js
- +0 −31 test/unit/pixi-v2/extras/Rope.js
- +0 −10 test/unit/pixi-v2/extras/Spine.js
- +0 −26 test/unit/pixi-v2/extras/Strip.js
- +0 −24 test/unit/pixi-v2/extras/TilingSprite.js
- +0 −10 test/unit/pixi-v2/filters/FilterBlock.js
- +0 −10 test/unit/pixi-v2/loaders/AssetLoader.js
- +0 −9 test/unit/pixi-v2/loaders/BitmapFontLoader.js
- +0 −10 test/unit/pixi-v2/loaders/ImageLoader.js
- +0 −10 test/unit/pixi-v2/loaders/JsonLoader.js
- +0 −10 test/unit/pixi-v2/loaders/SpineLoader.js
- +0 −10 test/unit/pixi-v2/loaders/SpriteSheetLoader.js
- +0 −44 test/unit/pixi-v2/primitives/Graphics.js
- +0 −15 test/unit/pixi-v2/renderers/canvas/CanvasGraphics.js
- +0 −36 test/unit/pixi-v2/renderers/canvas/CanvasRenderer.js
- +0 −20 test/unit/pixi-v2/renderers/webgl/WebGLGraphics.js
- +0 −49 test/unit/pixi-v2/renderers/webgl/WebGLRenderer.js
- +0 −13 test/unit/pixi-v2/renderers/webgl/WebGLShaders.js
- +0 −10 test/unit/pixi-v2/renderers/webgl/WebGLSpriteBatch.js
- +0 −10 test/unit/pixi-v2/text/BitmapText.js
- +0 −10 test/unit/pixi-v2/text/Text.js
- +0 −11 test/unit/pixi-v2/textures/BaseTexture.js
- +0 −15 test/unit/pixi-v2/textures/RenderTexture.js
- +0 −26 test/unit/pixi-v2/textures/Texture.js
- +0 −10 test/unit/pixi-v2/utils/Detector.js
- +0 −361 test/unit/pixi-v2/utils/EventTarget.js
- +0 −14 test/unit/pixi-v2/utils/Polyk.js
- +0 −17 test/unit/pixi-v2/utils/Utils.js
- +0 −11 test/unit/src/index.js
- +17 −0 testem.json
9
package.json
BIN
test/functional/example-1-basics/bunny.png
Deleted file not rendered
BIN
test/functional/example-1-basics/frame-30.png
Deleted file not rendered
BIN
test/functional/example-1-basics/frame-60.png
Deleted file not rendered
BIN
test/functional/example-1-basics/frame-90.png
Deleted file not rendered
133
test/functional/example-1-basics/index.js
@@ -1,133 +0,0 @@ | ||
-describe('Example 1 - Basics', function () { | ||
- 'use strict'; | ||
- | ||
- var baseUri = '/base/test/functional/example-1-basics'; | ||
- var expect = chai.expect; | ||
- var currentFrame = 0; | ||
- var frameEvents = {}; | ||
- var stage; | ||
- var renderer; | ||
- var bunny; | ||
- | ||
- function onFrame(frame, callback) { | ||
- frameEvents[frame] = callback; | ||
- } | ||
- | ||
- function animate() { | ||
- currentFrame += 1; | ||
- | ||
- window.requestAnimFrame( animate ); | ||
- | ||
- // just for fun, lets rotate mr rabbit a little | ||
- bunny.rotation += 0.1; | ||
- | ||
- // render the stage | ||
- renderer.render(stage); | ||
- | ||
- if (frameEvents[currentFrame]) | ||
- frameEvents[currentFrame](currentFrame); | ||
- } | ||
- | ||
- function initScene() { | ||
- // create an new instance of a pixi stage | ||
- stage = new PIXI.Stage(0x66FF99); | ||
- | ||
- // create a renderer instance | ||
- renderer = PIXI.autoDetectRenderer(400, 300); | ||
- console.log('Is PIXI.WebGLRenderer: ' + (renderer instanceof PIXI.WebGLRenderer)); | ||
- | ||
- // add the renderer view element to the DOM | ||
- document.body.appendChild(renderer.view); | ||
- | ||
- window.requestAnimFrame( animate ); | ||
- | ||
- // create a texture from an image path | ||
- var texture = PIXI.Texture.fromImage(baseUri + '/bunny.png'); | ||
- // create a new Sprite using the texture | ||
- bunny = new PIXI.Sprite(texture); | ||
- | ||
- // center the sprites anchor point | ||
- bunny.anchor.x = 0.5; | ||
- bunny.anchor.y = 0.5; | ||
- | ||
- // move the sprite t the center of the screen | ||
- bunny.position.x = 200; | ||
- bunny.position.y = 150; | ||
- | ||
- stage.addChild(bunny); | ||
- } | ||
- | ||
- it('assets loaded', function (done) { | ||
- var loader = new PIXI.AssetLoader([ | ||
- baseUri + '/bunny.png', | ||
- baseUri + '/frame-30.png', | ||
- baseUri + '/frame-60.png', | ||
- baseUri + '/frame-90.png' | ||
- ]); | ||
- // loader.on('onProgress', function (event) { | ||
- // console.log(event.content); | ||
- // }); | ||
- loader.on('onComplete', function () { | ||
- done(); | ||
- initScene(); | ||
- }); | ||
- loader.load(); | ||
- }); | ||
- | ||
- it('frame 30 should match', function (done) { | ||
- this.timeout(700); | ||
- onFrame(30, function () { | ||
- var str = renderer.view.toDataURL('image/png'); | ||
- //console.log('<img src="' + str + '" />'); | ||
- resemble(str) | ||
- .compareTo(baseUri + '/frame-30.png') | ||
- .onComplete(function (data) { | ||
- expect(data).to.be.an('object'); | ||
- expect(data.isSameDimensions).to.equal(true); | ||
- expect(data.misMatchPercentage).to.be.below(0.2); | ||
- done(); | ||
- }); | ||
- }); | ||
- }); | ||
- | ||
- it('frame 60 should match', function (done) { | ||
- this.timeout(1200); | ||
- onFrame(60, function () { | ||
- var str = renderer.view.toDataURL('image/png'); | ||
- //console.log('<img src="' + str + '" />'); | ||
- resemble(str) | ||
- .compareTo(baseUri + '/frame-60.png') | ||
- .onComplete(function (data) { | ||
- expect(data).to.be.an('object'); | ||
- expect(data.isSameDimensions).to.equal(true); | ||
- expect(data.misMatchPercentage).to.be.below(0.2); | ||
- done(); | ||
- }); | ||
- }); | ||
- }); | ||
- | ||
- it('frame 90 should match', function (done) { | ||
- this.timeout(1700); | ||
- onFrame(90, function () { | ||
- var str = renderer.view.toDataURL('image/png'); | ||
- //console.log('<img src="' + str + '" />'); | ||
- resemble(str) | ||
- .compareTo(baseUri + '/frame-90.png') | ||
- .onComplete(function (data) { | ||
- expect(data).to.be.an('object'); | ||
- expect(data.isSameDimensions).to.equal(true); | ||
- expect(data.misMatchPercentage).to.be.below(0.2); | ||
- done(); | ||
- }); | ||
- }); | ||
- }); | ||
- | ||
- // it('capture something', function (done) { | ||
- // this.timeout(2000000); | ||
- // onFrame(30, function () { | ||
- // var img = new Image(); | ||
- // img.src = renderer.view.toDataURL('image/png'); | ||
- // document.body.appendChild(img); | ||
- // }); | ||
- // }); | ||
-}); |
1
test/setup.js
@@ -0,0 +1 @@ | ||
+expect = chai.expect; |
22
test/unit/bin/pixi.js
@@ -1,22 +0,0 @@ | ||
-describe('bin/pixi.js', function () { | ||
- 'use strict'; | ||
- | ||
- var expect = chai.expect; | ||
- | ||
- it('Standalone PIXI exists', function () { | ||
- expect(PIXI). | ||
- to.be.an('object'); | ||
- }); | ||
- | ||
- /** | ||
- * @todo This does not actually work with Browserify | ||
- * option in use. The standalone option wraps | ||
- * the bundle in a UMD closure and prevents | ||
- * the `require` function, and consequently | ||
- * the "pixi.js" module, from being exposed. | ||
- */ | ||
- //it('Module exists', function () { | ||
- // expect(require('pixi.js')). | ||
- // to.be.an('object'); | ||
- //}); | ||
-}); |
89
test/unit/core/utils/util.test.js
@@ -0,0 +1,89 @@ | ||
+describe('PIXI.utils', function () { | ||
+ describe('.uuid', function () { | ||
+ it('should exist', function () { | ||
+ expect(PIXI.utils.uuid) | ||
+ .to.be.a('function'); | ||
+ }); | ||
+ | ||
+ it('should return a number', function () { | ||
+ expect(PIXI.utils.uuid()) | ||
+ .to.be.a('number'); | ||
+ }); | ||
+ }); | ||
+ | ||
+ describe('.hex2rgb', function () { | ||
+ it('should exist', function () { | ||
+ expect(PIXI.utils.hex2rgb) | ||
+ .to.be.a('function'); | ||
+ }); | ||
+ | ||
+ it('should properly convert number to rgb array'); | ||
+ }); | ||
+ | ||
+ describe('.hex2string', function () { | ||
+ it('should exist', function () { | ||
+ expect(PIXI.utils.hex2string) | ||
+ .to.be.a('function'); | ||
+ }); | ||
+ | ||
+ it('should properly convert number to hex color string'); | ||
+ }); | ||
+ | ||
+ describe('.rgb2hex', function () { | ||
+ it('should exist', function () { | ||
+ expect(PIXI.utils.rgb2hex) | ||
+ .to.be.a('function'); | ||
+ }); | ||
+ | ||
+ it('should properly convert rgb array to hex color string'); | ||
+ }); | ||
+ | ||
+ describe('.getNextPowerOfTwo', function () { | ||
+ it('should exist', function () { | ||
+ expect(PIXI.utils.getNextPowerOfTwo) | ||
+ .to.be.a('function'); | ||
+ }); | ||
+ | ||
+ it('should return the next POT for a number'); | ||
+ }); | ||
+ | ||
+ describe('.isPowerOfTwo', function () { | ||
+ it('should exist', function () { | ||
+ expect(PIXI.utils.isPowerOfTwo) | ||
+ .to.be.a('function'); | ||
+ }); | ||
+ | ||
+ it('should return true if a number is a POT'); | ||
+ it('should return false if a number is not a POT'); | ||
+ }); | ||
+ | ||
+ describe('.getResolutionOfUrl', function () { | ||
+ it('should exist', function () { | ||
+ expect(PIXI.utils.getResolutionOfUrl) | ||
+ .to.be.a('function'); | ||
+ }); | ||
+ | ||
+ it('should return the correct resolution based on a URL'); | ||
+ }); | ||
+ | ||
+ describe('.canUseNewCanvasBlendModes', function () { | ||
+ it('should exist', function () { | ||
+ expect(PIXI.utils.canUseNewCanvasBlendModes) | ||
+ .to.be.a('function'); | ||
+ }); | ||
+ }); | ||
+ | ||
+ describe('.sayHello', function () { | ||
+ it('should exist', function () { | ||
+ expect(PIXI.utils.sayHello) | ||
+ .to.be.a('function'); | ||
+ }); | ||
+ }); | ||
+ | ||
+ describe('.isWebGLSupported', function () { | ||
+ it('should exist', function () { | ||
+ expect(PIXI.utils.isWebGLSupported) | ||
+ .to.be.a('function'); | ||
+ }); | ||
+ }); | ||
+}); |
6
test/unit/index.test.js
@@ -0,0 +1,6 @@ | ||
+describe('PIXI', function () { | ||
+ it('exists', function () { | ||
+ expect(PIXI) | ||
+ .to.be.an('object'); | ||
+ }); | ||
+}); |
10
test/unit/pixi-v2/InteractionManager.js
@@ -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'); | ||
- }); | ||
-}); |
9
test/unit/pixi-v2/Pixi.js
@@ -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'); | ||
- }); | ||
-}); |
21
test/unit/pixi-v2/core/Circle.js
@@ -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); | ||
- }); | ||
-}); |
24
test/unit/pixi-v2/core/Ellipse.js
@@ -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); | ||
- }); | ||
-}); |
14
test/unit/pixi-v2/core/Matrix.js
@@ -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); | ||
- }); | ||
-}); |
15
test/unit/pixi-v2/core/Point.js
@@ -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); | ||
- }); | ||
-}); |
20
test/unit/pixi-v2/core/Polygon.js
@@ -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); | ||
- }); | ||
-}); |
15
test/unit/pixi-v2/core/Rectangle.js
@@ -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); | ||
- }); | ||
-}); |
21
test/unit/pixi-v2/display/DisplayObject.js
@@ -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); | ||
- }); | ||
-}); |
67
test/unit/pixi-v2/display/DisplayObjectContainer.js
@@ -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(); | ||
- }); | ||
-}); |
33
test/unit/pixi-v2/display/MovieClip.js
@@ -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); | ||
- }); | ||
-}); |
28
test/unit/pixi-v2/display/Sprite.js
@@ -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); | ||
- }); | ||
-}); |
49
test/unit/pixi-v2/display/Stage.js
@@ -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); | ||
- }); | ||
-}); |
31
test/unit/pixi-v2/extras/Rope.js
@@ -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 | ||
- }); | ||
-}); |
10
test/unit/pixi-v2/extras/Spine.js
@@ -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'); | ||
- }); | ||
-}); |
26
test/unit/pixi-v2/extras/Strip.js
@@ -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); | ||
- }); | ||
-}); |
24
test/unit/pixi-v2/extras/TilingSprite.js
@@ -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 | ||
- }); | ||
-}); |
10
test/unit/pixi-v2/filters/FilterBlock.js
@@ -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'); | ||
- }); | ||
-}); |
10
test/unit/pixi-v2/loaders/AssetLoader.js
@@ -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'); | ||
- }); | ||
-}); |
9
test/unit/pixi-v2/loaders/BitmapFontLoader.js
@@ -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'); | ||
- }); | ||
-}); |
10
test/unit/pixi-v2/loaders/ImageLoader.js
@@ -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'); | ||
- }); | ||
-}); |
10
test/unit/pixi-v2/loaders/JsonLoader.js
@@ -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'); | ||
- }); | ||
-}); |
10
test/unit/pixi-v2/loaders/SpineLoader.js
@@ -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'); | ||
- }); | ||
-}); |
10
test/unit/pixi-v2/loaders/SpriteSheetLoader.js
@@ -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'); | ||
- }); | ||
-}); |
44
test/unit/pixi-v2/primitives/Graphics.js
@@ -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); | ||
- }); | ||
-}); |
15
test/unit/pixi-v2/renderers/canvas/CanvasGraphics.js
@@ -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'); | ||
- }); | ||
-}); |
36
test/unit/pixi-v2/renderers/canvas/CanvasRenderer.js
@@ -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(''); | ||
- }); | ||
- }); | ||
-}); |
20
test/unit/pixi-v2/renderers/webgl/WebGLGraphics.js
@@ -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'); | ||
- }); | ||
-}); |
49
test/unit/pixi-v2/renderers/webgl/WebGLRenderer.js
@@ -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(''); | ||
- }); | ||
- }); | ||
-}); |
13
test/unit/pixi-v2/renderers/webgl/WebGLShaders.js
@@ -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'); | ||
- }); | ||
-}); |
10
test/unit/pixi-v2/renderers/webgl/WebGLSpriteBatch.js
@@ -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'); | ||
- }); | ||
-}); |
10
test/unit/pixi-v2/text/BitmapText.js
@@ -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'); | ||
- }); | ||
-}); |
10
test/unit/pixi-v2/text/Text.js
@@ -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'); | ||
- }); | ||
-}); |
11
test/unit/pixi-v2/textures/BaseTexture.js
@@ -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'); | ||
- }); | ||
-}); |
15
test/unit/pixi-v2/textures/RenderTexture.js
@@ -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); | ||
- }); | ||
-}); |
26
test/unit/pixi-v2/textures/Texture.js
@@ -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); | ||
- }); | ||
-}); |
10
test/unit/pixi-v2/utils/Detector.js
@@ -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'); | ||
- }); | ||
-}); |
361
test/unit/pixi-v2/utils/EventTarget.js
@@ -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); | ||
- }); | ||
-}); |
14
test/unit/pixi-v2/utils/Polyk.js
@@ -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'); | ||
- }); | ||
-}); |
17
test/unit/pixi-v2/utils/Utils.js
@@ -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'); | ||
- }); | ||
-}); |
11
test/unit/src/index.js
@@ -1,11 +0,0 @@ | ||
-describe('src', function () { | ||
- 'use strict'; | ||
- | ||
- var expect = chai.expect; | ||
- var pixi = require('../../../src'); | ||
- | ||
- it('Module exists', function () { | ||
- expect(pixi) | ||
- .to.be.an('object'); | ||
- }); | ||
-}); |
17
testem.json
@@ -0,0 +1,17 @@ | ||
+{ | ||
+ "framework" : "mocha+chai", | ||
+ "launch_in_dev" : ["Chrome", "Firefox"], | ||
+ "launch_in_ci" : ["Firefox"], | ||
+ "src_files" : [ | ||
+ "bin/pixi.js", | ||
+ | ||
+ "test/setup.js", | ||
+ "test/unit/**/*.test.js" | ||
+ ], | ||
+ "launchers": { | ||
+ "node": { | ||
+ "command": "./node_modules/.bin/mocha -r ./test/setup.js -R tap --recursive ./test/unit/", | ||
+ "protocol": "tap" | ||
+ } | ||
+ } | ||
+} |
0 comments on commit
3b3f948