diff --git a/test/core/AnimatedSprite.js b/test/core/AnimatedSprite.js new file mode 100644 index 0000000..eced661 --- /dev/null +++ b/test/core/AnimatedSprite.js @@ -0,0 +1,97 @@ +'use strict'; + +describe('PIXI.extras.AnimatedSprite', function () +{ + describe('instance', function () + { + beforeEach(function () + { + this.textures = [PIXI.Texture.EMPTY]; + }); + + afterEach(function () + { + expect(this.sprite.animationSpeed).to.be.equal(1); + expect(this.sprite.loop).to.be.true; + expect(this.sprite.onComplete).to.be.null; + expect(this.sprite.onFrameChange).to.be.null; + expect(this.sprite.onLoop).to.be.null; + expect(this.sprite.playing).to.be.false; + + this.sprite.destroy(); + this.sprite = null; + }); + + it('should be correct with default options', function () + { + this.sprite = new PIXI.extras.AnimatedSprite(this.textures); + expect(this.sprite._autoUpdate).to.be.true; + }); + + it('should be correct with autoUpdate=false', function () + { + this.sprite = new PIXI.extras.AnimatedSprite(this.textures, false); + expect(this.sprite._autoUpdate).to.be.false; + }); + }); + + describe('.stop()', function () + { + before(function () + { + this.sprite = new PIXI.extras.AnimatedSprite([PIXI.Texture.EMPTY], false); + }); + + after(function () + { + this.sprite.destroy(); + this.sprite = null; + }); + + afterEach(function () + { + this.sprite.stop(); + expect(this.sprite.playing).to.be.false; + }); + + it('should stop playing if it is playing', function () + { + this.sprite.playing = true; + }); + + it('should do nothing if it is not playing', function () + { + this.sprite.playing = false; + }); + }); + + describe('.play()', function () + { + before(function () + { + this.sprite = new PIXI.extras.AnimatedSprite([PIXI.Texture.EMPTY], false); + }); + + after(function () + { + this.sprite.destroy(); + this.sprite = null; + }); + + afterEach(function () + { + this.sprite.play(); + expect(this.sprite.playing).to.be.true; + }); + + it('should start playing if it is not playing', function () + { + this.sprite.playing = false; + }); + + it('should do nothing if it is playing', function () + { + this.sprite.playing = true; + }); + }); +}); diff --git a/test/core/AnimatedSprite.js b/test/core/AnimatedSprite.js new file mode 100644 index 0000000..eced661 --- /dev/null +++ b/test/core/AnimatedSprite.js @@ -0,0 +1,97 @@ +'use strict'; + +describe('PIXI.extras.AnimatedSprite', function () +{ + describe('instance', function () + { + beforeEach(function () + { + this.textures = [PIXI.Texture.EMPTY]; + }); + + afterEach(function () + { + expect(this.sprite.animationSpeed).to.be.equal(1); + expect(this.sprite.loop).to.be.true; + expect(this.sprite.onComplete).to.be.null; + expect(this.sprite.onFrameChange).to.be.null; + expect(this.sprite.onLoop).to.be.null; + expect(this.sprite.playing).to.be.false; + + this.sprite.destroy(); + this.sprite = null; + }); + + it('should be correct with default options', function () + { + this.sprite = new PIXI.extras.AnimatedSprite(this.textures); + expect(this.sprite._autoUpdate).to.be.true; + }); + + it('should be correct with autoUpdate=false', function () + { + this.sprite = new PIXI.extras.AnimatedSprite(this.textures, false); + expect(this.sprite._autoUpdate).to.be.false; + }); + }); + + describe('.stop()', function () + { + before(function () + { + this.sprite = new PIXI.extras.AnimatedSprite([PIXI.Texture.EMPTY], false); + }); + + after(function () + { + this.sprite.destroy(); + this.sprite = null; + }); + + afterEach(function () + { + this.sprite.stop(); + expect(this.sprite.playing).to.be.false; + }); + + it('should stop playing if it is playing', function () + { + this.sprite.playing = true; + }); + + it('should do nothing if it is not playing', function () + { + this.sprite.playing = false; + }); + }); + + describe('.play()', function () + { + before(function () + { + this.sprite = new PIXI.extras.AnimatedSprite([PIXI.Texture.EMPTY], false); + }); + + after(function () + { + this.sprite.destroy(); + this.sprite = null; + }); + + afterEach(function () + { + this.sprite.play(); + expect(this.sprite.playing).to.be.true; + }); + + it('should start playing if it is not playing', function () + { + this.sprite.playing = false; + }); + + it('should do nothing if it is playing', function () + { + this.sprite.playing = true; + }); + }); +}); diff --git a/test/core/index.js b/test/core/index.js index 65e0a58..e0ec004 100755 --- a/test/core/index.js +++ b/test/core/index.js @@ -1,5 +1,6 @@ 'use strict'; +require('./AnimatedSprite'); require('./Application'); require('./TransformStatic'); require('./Bounds');