diff --git a/packages/sprite-animated/package.json b/packages/sprite-animated/package.json index 05dae84..6393f66 100644 --- a/packages/sprite-animated/package.json +++ b/packages/sprite-animated/package.json @@ -18,6 +18,9 @@ "publishConfig": { "access": "public" }, + "scripts": { + "test": "floss --path test" + }, "files": [ "lib" ], diff --git a/packages/sprite-animated/package.json b/packages/sprite-animated/package.json index 05dae84..6393f66 100644 --- a/packages/sprite-animated/package.json +++ b/packages/sprite-animated/package.json @@ -18,6 +18,9 @@ "publishConfig": { "access": "public" }, + "scripts": { + "test": "floss --path test" + }, "files": [ "lib" ], diff --git a/packages/sprite-animated/test/.eslintrc.json b/packages/sprite-animated/test/.eslintrc.json new file mode 100644 index 0000000..2094b04 --- /dev/null +++ b/packages/sprite-animated/test/.eslintrc.json @@ -0,0 +1,12 @@ +{ + "globals": { + "expect": false, + "assert": false, + "sinon": false, + "PIXI": false + }, + "rules": { + "func-names": 0, + "no-unused-expressions": 0 + } +} \ No newline at end of file diff --git a/packages/sprite-animated/package.json b/packages/sprite-animated/package.json index 05dae84..6393f66 100644 --- a/packages/sprite-animated/package.json +++ b/packages/sprite-animated/package.json @@ -18,6 +18,9 @@ "publishConfig": { "access": "public" }, + "scripts": { + "test": "floss --path test" + }, "files": [ "lib" ], diff --git a/packages/sprite-animated/test/.eslintrc.json b/packages/sprite-animated/test/.eslintrc.json new file mode 100644 index 0000000..2094b04 --- /dev/null +++ b/packages/sprite-animated/test/.eslintrc.json @@ -0,0 +1,12 @@ +{ + "globals": { + "expect": false, + "assert": false, + "sinon": false, + "PIXI": false + }, + "rules": { + "func-names": 0, + "no-unused-expressions": 0 + } +} \ No newline at end of file diff --git a/packages/sprite-animated/test/AnimatedSprite.js b/packages/sprite-animated/test/AnimatedSprite.js new file mode 100644 index 0000000..07a7f49 --- /dev/null +++ b/packages/sprite-animated/test/AnimatedSprite.js @@ -0,0 +1,98 @@ +const { AnimatedSprite } = require('../'); +const { Texture } = require('@pixi/core'); + +describe('PIXI.AnimatedSprite', function () +{ + describe('instance', function () + { + beforeEach(function () + { + this.textures = [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 AnimatedSprite(this.textures); + expect(this.sprite._autoUpdate).to.be.true; + }); + + it('should be correct with autoUpdate=false', function () + { + this.sprite = new AnimatedSprite(this.textures, false); + expect(this.sprite._autoUpdate).to.be.false; + }); + }); + + describe('.stop()', function () + { + before(function () + { + this.sprite = new AnimatedSprite([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 AnimatedSprite([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/packages/sprite-animated/package.json b/packages/sprite-animated/package.json index 05dae84..6393f66 100644 --- a/packages/sprite-animated/package.json +++ b/packages/sprite-animated/package.json @@ -18,6 +18,9 @@ "publishConfig": { "access": "public" }, + "scripts": { + "test": "floss --path test" + }, "files": [ "lib" ], diff --git a/packages/sprite-animated/test/.eslintrc.json b/packages/sprite-animated/test/.eslintrc.json new file mode 100644 index 0000000..2094b04 --- /dev/null +++ b/packages/sprite-animated/test/.eslintrc.json @@ -0,0 +1,12 @@ +{ + "globals": { + "expect": false, + "assert": false, + "sinon": false, + "PIXI": false + }, + "rules": { + "func-names": 0, + "no-unused-expressions": 0 + } +} \ No newline at end of file diff --git a/packages/sprite-animated/test/AnimatedSprite.js b/packages/sprite-animated/test/AnimatedSprite.js new file mode 100644 index 0000000..07a7f49 --- /dev/null +++ b/packages/sprite-animated/test/AnimatedSprite.js @@ -0,0 +1,98 @@ +const { AnimatedSprite } = require('../'); +const { Texture } = require('@pixi/core'); + +describe('PIXI.AnimatedSprite', function () +{ + describe('instance', function () + { + beforeEach(function () + { + this.textures = [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 AnimatedSprite(this.textures); + expect(this.sprite._autoUpdate).to.be.true; + }); + + it('should be correct with autoUpdate=false', function () + { + this.sprite = new AnimatedSprite(this.textures, false); + expect(this.sprite._autoUpdate).to.be.false; + }); + }); + + describe('.stop()', function () + { + before(function () + { + this.sprite = new AnimatedSprite([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 AnimatedSprite([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/packages/sprite-animated/test/index.js b/packages/sprite-animated/test/index.js new file mode 100644 index 0000000..ee29cdf --- /dev/null +++ b/packages/sprite-animated/test/index.js @@ -0,0 +1 @@ +require('./AnimatedSprite');