diff --git a/package.json b/package.json index 6fc5290..ce76d2f 100644 --- a/package.json +++ b/package.json @@ -16,7 +16,7 @@ "url": "https://github.com/GoodBoyDigital/pixi.js.git" }, "scripts": { - "test": "gulp test", + "test": "gulp && testem ci", "docs": "jsdoc -c ./gulp/util/jsdoc.conf.json -R README.md" }, "dependencies": { @@ -45,16 +45,11 @@ "ink-docstrap": "git+https://github.com/Pilatch/docstrap.git", "jsdoc": "^3.3.0-alpha13", "jshint-summary": "^0.4.0", - "karma": "^0.12.28", - "karma-browserify": "^4.0.0", - "karma-chai": "^0.1.0", - "karma-firefox-launcher": "^0.1.0", - "karma-mocha": "^0.1.10", - "karma-spec-reporter": "^0.0.16", "minimist": "^1.1.1", "mocha": "^2.1.0", "require-dir": "^0.3.0", "run-sequence": "^1.0.2", + "testem": "^0.8.2", "vinyl-buffer": "^1.0.0", "vinyl-source-stream": "^1.1.0", "watchify": "^3.1.1" diff --git a/package.json b/package.json index 6fc5290..ce76d2f 100644 --- a/package.json +++ b/package.json @@ -16,7 +16,7 @@ "url": "https://github.com/GoodBoyDigital/pixi.js.git" }, "scripts": { - "test": "gulp test", + "test": "gulp && testem ci", "docs": "jsdoc -c ./gulp/util/jsdoc.conf.json -R README.md" }, "dependencies": { @@ -45,16 +45,11 @@ "ink-docstrap": "git+https://github.com/Pilatch/docstrap.git", "jsdoc": "^3.3.0-alpha13", "jshint-summary": "^0.4.0", - "karma": "^0.12.28", - "karma-browserify": "^4.0.0", - "karma-chai": "^0.1.0", - "karma-firefox-launcher": "^0.1.0", - "karma-mocha": "^0.1.10", - "karma-spec-reporter": "^0.0.16", "minimist": "^1.1.1", "mocha": "^2.1.0", "require-dir": "^0.3.0", "run-sequence": "^1.0.2", + "testem": "^0.8.2", "vinyl-buffer": "^1.0.0", "vinyl-source-stream": "^1.1.0", "watchify": "^3.1.1" diff --git a/test/functional/example-1-basics/bunny.png b/test/functional/example-1-basics/bunny.png deleted file mode 100644 index 79c3167..0000000 --- a/test/functional/example-1-basics/bunny.png +++ /dev/null Binary files differ diff --git a/package.json b/package.json index 6fc5290..ce76d2f 100644 --- a/package.json +++ b/package.json @@ -16,7 +16,7 @@ "url": "https://github.com/GoodBoyDigital/pixi.js.git" }, "scripts": { - "test": "gulp test", + "test": "gulp && testem ci", "docs": "jsdoc -c ./gulp/util/jsdoc.conf.json -R README.md" }, "dependencies": { @@ -45,16 +45,11 @@ "ink-docstrap": "git+https://github.com/Pilatch/docstrap.git", "jsdoc": "^3.3.0-alpha13", "jshint-summary": "^0.4.0", - "karma": "^0.12.28", - "karma-browserify": "^4.0.0", - "karma-chai": "^0.1.0", - "karma-firefox-launcher": "^0.1.0", - "karma-mocha": "^0.1.10", - "karma-spec-reporter": "^0.0.16", "minimist": "^1.1.1", "mocha": "^2.1.0", "require-dir": "^0.3.0", "run-sequence": "^1.0.2", + "testem": "^0.8.2", "vinyl-buffer": "^1.0.0", "vinyl-source-stream": "^1.1.0", "watchify": "^3.1.1" diff --git a/test/functional/example-1-basics/bunny.png b/test/functional/example-1-basics/bunny.png deleted file mode 100644 index 79c3167..0000000 --- a/test/functional/example-1-basics/bunny.png +++ /dev/null Binary files differ diff --git a/test/functional/example-1-basics/frame-30.png b/test/functional/example-1-basics/frame-30.png deleted file mode 100644 index 96e3409..0000000 --- a/test/functional/example-1-basics/frame-30.png +++ /dev/null Binary files differ diff --git a/package.json b/package.json index 6fc5290..ce76d2f 100644 --- a/package.json +++ b/package.json @@ -16,7 +16,7 @@ "url": "https://github.com/GoodBoyDigital/pixi.js.git" }, "scripts": { - "test": "gulp test", + "test": "gulp && testem ci", "docs": "jsdoc -c ./gulp/util/jsdoc.conf.json -R README.md" }, "dependencies": { @@ -45,16 +45,11 @@ "ink-docstrap": "git+https://github.com/Pilatch/docstrap.git", "jsdoc": "^3.3.0-alpha13", "jshint-summary": "^0.4.0", - "karma": "^0.12.28", - "karma-browserify": "^4.0.0", - "karma-chai": "^0.1.0", - "karma-firefox-launcher": "^0.1.0", - "karma-mocha": "^0.1.10", - "karma-spec-reporter": "^0.0.16", "minimist": "^1.1.1", "mocha": "^2.1.0", "require-dir": "^0.3.0", "run-sequence": "^1.0.2", + "testem": "^0.8.2", "vinyl-buffer": "^1.0.0", "vinyl-source-stream": "^1.1.0", "watchify": "^3.1.1" diff --git a/test/functional/example-1-basics/bunny.png b/test/functional/example-1-basics/bunny.png deleted file mode 100644 index 79c3167..0000000 --- a/test/functional/example-1-basics/bunny.png +++ /dev/null Binary files differ diff --git a/test/functional/example-1-basics/frame-30.png b/test/functional/example-1-basics/frame-30.png deleted file mode 100644 index 96e3409..0000000 --- a/test/functional/example-1-basics/frame-30.png +++ /dev/null Binary files differ diff --git a/test/functional/example-1-basics/frame-60.png b/test/functional/example-1-basics/frame-60.png deleted file mode 100644 index af3f4ce..0000000 --- a/test/functional/example-1-basics/frame-60.png +++ /dev/null Binary files differ diff --git a/package.json b/package.json index 6fc5290..ce76d2f 100644 --- a/package.json +++ b/package.json @@ -16,7 +16,7 @@ "url": "https://github.com/GoodBoyDigital/pixi.js.git" }, "scripts": { - "test": "gulp test", + "test": "gulp && testem ci", "docs": "jsdoc -c ./gulp/util/jsdoc.conf.json -R README.md" }, "dependencies": { @@ -45,16 +45,11 @@ "ink-docstrap": "git+https://github.com/Pilatch/docstrap.git", "jsdoc": "^3.3.0-alpha13", "jshint-summary": "^0.4.0", - "karma": "^0.12.28", - "karma-browserify": "^4.0.0", - "karma-chai": "^0.1.0", - "karma-firefox-launcher": "^0.1.0", - "karma-mocha": "^0.1.10", - "karma-spec-reporter": "^0.0.16", "minimist": "^1.1.1", "mocha": "^2.1.0", "require-dir": "^0.3.0", "run-sequence": "^1.0.2", + "testem": "^0.8.2", "vinyl-buffer": "^1.0.0", "vinyl-source-stream": "^1.1.0", "watchify": "^3.1.1" diff --git a/test/functional/example-1-basics/bunny.png b/test/functional/example-1-basics/bunny.png deleted file mode 100644 index 79c3167..0000000 --- a/test/functional/example-1-basics/bunny.png +++ /dev/null Binary files differ diff --git a/test/functional/example-1-basics/frame-30.png b/test/functional/example-1-basics/frame-30.png deleted file mode 100644 index 96e3409..0000000 --- a/test/functional/example-1-basics/frame-30.png +++ /dev/null Binary files differ diff --git a/test/functional/example-1-basics/frame-60.png b/test/functional/example-1-basics/frame-60.png deleted file mode 100644 index af3f4ce..0000000 --- a/test/functional/example-1-basics/frame-60.png +++ /dev/null Binary files differ diff --git a/test/functional/example-1-basics/frame-90.png b/test/functional/example-1-basics/frame-90.png deleted file mode 100644 index 099b823..0000000 --- a/test/functional/example-1-basics/frame-90.png +++ /dev/null Binary files differ diff --git a/package.json b/package.json index 6fc5290..ce76d2f 100644 --- a/package.json +++ b/package.json @@ -16,7 +16,7 @@ "url": "https://github.com/GoodBoyDigital/pixi.js.git" }, "scripts": { - "test": "gulp test", + "test": "gulp && testem ci", "docs": "jsdoc -c ./gulp/util/jsdoc.conf.json -R README.md" }, "dependencies": { @@ -45,16 +45,11 @@ "ink-docstrap": "git+https://github.com/Pilatch/docstrap.git", "jsdoc": "^3.3.0-alpha13", "jshint-summary": "^0.4.0", - "karma": "^0.12.28", - "karma-browserify": "^4.0.0", - "karma-chai": "^0.1.0", - "karma-firefox-launcher": "^0.1.0", - "karma-mocha": "^0.1.10", - "karma-spec-reporter": "^0.0.16", "minimist": "^1.1.1", "mocha": "^2.1.0", "require-dir": "^0.3.0", "run-sequence": "^1.0.2", + "testem": "^0.8.2", "vinyl-buffer": "^1.0.0", "vinyl-source-stream": "^1.1.0", "watchify": "^3.1.1" diff --git a/test/functional/example-1-basics/bunny.png b/test/functional/example-1-basics/bunny.png deleted file mode 100644 index 79c3167..0000000 --- a/test/functional/example-1-basics/bunny.png +++ /dev/null Binary files differ diff --git a/test/functional/example-1-basics/frame-30.png b/test/functional/example-1-basics/frame-30.png deleted file mode 100644 index 96e3409..0000000 --- a/test/functional/example-1-basics/frame-30.png +++ /dev/null Binary files differ diff --git a/test/functional/example-1-basics/frame-60.png b/test/functional/example-1-basics/frame-60.png deleted file mode 100644 index af3f4ce..0000000 --- a/test/functional/example-1-basics/frame-60.png +++ /dev/null Binary files differ diff --git a/test/functional/example-1-basics/frame-90.png b/test/functional/example-1-basics/frame-90.png deleted file mode 100644 index 099b823..0000000 --- a/test/functional/example-1-basics/frame-90.png +++ /dev/null Binary files differ diff --git a/test/functional/example-1-basics/index.js b/test/functional/example-1-basics/index.js deleted file mode 100644 index 2ad32bd..0000000 --- a/test/functional/example-1-basics/index.js +++ /dev/null @@ -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(''); - 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(''); - 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(''); - 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); - // }); - // }); -}); diff --git a/package.json b/package.json index 6fc5290..ce76d2f 100644 --- a/package.json +++ b/package.json @@ -16,7 +16,7 @@ "url": "https://github.com/GoodBoyDigital/pixi.js.git" }, "scripts": { - "test": "gulp test", + "test": "gulp && testem ci", "docs": "jsdoc -c ./gulp/util/jsdoc.conf.json -R README.md" }, "dependencies": { @@ -45,16 +45,11 @@ "ink-docstrap": "git+https://github.com/Pilatch/docstrap.git", "jsdoc": "^3.3.0-alpha13", "jshint-summary": "^0.4.0", - "karma": "^0.12.28", - "karma-browserify": "^4.0.0", - "karma-chai": "^0.1.0", - "karma-firefox-launcher": "^0.1.0", - "karma-mocha": "^0.1.10", - "karma-spec-reporter": "^0.0.16", "minimist": "^1.1.1", "mocha": "^2.1.0", "require-dir": "^0.3.0", "run-sequence": "^1.0.2", + "testem": "^0.8.2", "vinyl-buffer": "^1.0.0", "vinyl-source-stream": "^1.1.0", "watchify": "^3.1.1" diff --git a/test/functional/example-1-basics/bunny.png b/test/functional/example-1-basics/bunny.png deleted file mode 100644 index 79c3167..0000000 --- a/test/functional/example-1-basics/bunny.png +++ /dev/null Binary files differ diff --git a/test/functional/example-1-basics/frame-30.png b/test/functional/example-1-basics/frame-30.png deleted file mode 100644 index 96e3409..0000000 --- a/test/functional/example-1-basics/frame-30.png +++ /dev/null Binary files differ diff --git a/test/functional/example-1-basics/frame-60.png b/test/functional/example-1-basics/frame-60.png deleted file mode 100644 index af3f4ce..0000000 --- a/test/functional/example-1-basics/frame-60.png +++ /dev/null Binary files differ diff --git a/test/functional/example-1-basics/frame-90.png b/test/functional/example-1-basics/frame-90.png deleted file mode 100644 index 099b823..0000000 --- a/test/functional/example-1-basics/frame-90.png +++ /dev/null Binary files differ diff --git a/test/functional/example-1-basics/index.js b/test/functional/example-1-basics/index.js deleted file mode 100644 index 2ad32bd..0000000 --- a/test/functional/example-1-basics/index.js +++ /dev/null @@ -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(''); - 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(''); - 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(''); - 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); - // }); - // }); -}); diff --git a/test/setup.js b/test/setup.js new file mode 100644 index 0000000..69e1b7a --- /dev/null +++ b/test/setup.js @@ -0,0 +1 @@ +expect = chai.expect; diff --git a/package.json b/package.json index 6fc5290..ce76d2f 100644 --- a/package.json +++ b/package.json @@ -16,7 +16,7 @@ "url": "https://github.com/GoodBoyDigital/pixi.js.git" }, "scripts": { - "test": "gulp test", + "test": "gulp && testem ci", "docs": "jsdoc -c ./gulp/util/jsdoc.conf.json -R README.md" }, "dependencies": { @@ -45,16 +45,11 @@ "ink-docstrap": "git+https://github.com/Pilatch/docstrap.git", "jsdoc": "^3.3.0-alpha13", "jshint-summary": "^0.4.0", - "karma": "^0.12.28", - "karma-browserify": "^4.0.0", - "karma-chai": "^0.1.0", - "karma-firefox-launcher": "^0.1.0", - "karma-mocha": "^0.1.10", - "karma-spec-reporter": "^0.0.16", "minimist": "^1.1.1", "mocha": "^2.1.0", "require-dir": "^0.3.0", "run-sequence": "^1.0.2", + "testem": "^0.8.2", "vinyl-buffer": "^1.0.0", "vinyl-source-stream": "^1.1.0", "watchify": "^3.1.1" diff --git a/test/functional/example-1-basics/bunny.png b/test/functional/example-1-basics/bunny.png deleted file mode 100644 index 79c3167..0000000 --- a/test/functional/example-1-basics/bunny.png +++ /dev/null Binary files differ diff --git a/test/functional/example-1-basics/frame-30.png b/test/functional/example-1-basics/frame-30.png deleted file mode 100644 index 96e3409..0000000 --- a/test/functional/example-1-basics/frame-30.png +++ /dev/null Binary files differ diff --git a/test/functional/example-1-basics/frame-60.png b/test/functional/example-1-basics/frame-60.png deleted file mode 100644 index af3f4ce..0000000 --- a/test/functional/example-1-basics/frame-60.png +++ /dev/null Binary files differ diff --git a/test/functional/example-1-basics/frame-90.png b/test/functional/example-1-basics/frame-90.png deleted file mode 100644 index 099b823..0000000 --- a/test/functional/example-1-basics/frame-90.png +++ /dev/null Binary files differ diff --git a/test/functional/example-1-basics/index.js b/test/functional/example-1-basics/index.js deleted file mode 100644 index 2ad32bd..0000000 --- a/test/functional/example-1-basics/index.js +++ /dev/null @@ -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(''); - 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(''); - 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(''); - 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); - // }); - // }); -}); diff --git a/test/setup.js b/test/setup.js new file mode 100644 index 0000000..69e1b7a --- /dev/null +++ b/test/setup.js @@ -0,0 +1 @@ +expect = chai.expect; diff --git a/test/unit/bin/pixi.js b/test/unit/bin/pixi.js deleted file mode 100644 index 077cd88..0000000 --- a/test/unit/bin/pixi.js +++ /dev/null @@ -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'); - //}); -}); diff --git a/package.json b/package.json index 6fc5290..ce76d2f 100644 --- a/package.json +++ b/package.json @@ -16,7 +16,7 @@ "url": "https://github.com/GoodBoyDigital/pixi.js.git" }, "scripts": { - "test": "gulp test", + "test": "gulp && testem ci", "docs": "jsdoc -c ./gulp/util/jsdoc.conf.json -R README.md" }, "dependencies": { @@ -45,16 +45,11 @@ "ink-docstrap": "git+https://github.com/Pilatch/docstrap.git", "jsdoc": "^3.3.0-alpha13", "jshint-summary": "^0.4.0", - "karma": "^0.12.28", - "karma-browserify": "^4.0.0", - "karma-chai": "^0.1.0", - "karma-firefox-launcher": "^0.1.0", - "karma-mocha": "^0.1.10", - "karma-spec-reporter": "^0.0.16", "minimist": "^1.1.1", "mocha": "^2.1.0", "require-dir": "^0.3.0", "run-sequence": "^1.0.2", + "testem": "^0.8.2", "vinyl-buffer": "^1.0.0", "vinyl-source-stream": "^1.1.0", "watchify": "^3.1.1" diff --git a/test/functional/example-1-basics/bunny.png b/test/functional/example-1-basics/bunny.png deleted file mode 100644 index 79c3167..0000000 --- a/test/functional/example-1-basics/bunny.png +++ /dev/null Binary files differ diff --git a/test/functional/example-1-basics/frame-30.png b/test/functional/example-1-basics/frame-30.png deleted file mode 100644 index 96e3409..0000000 --- a/test/functional/example-1-basics/frame-30.png +++ /dev/null Binary files differ diff --git a/test/functional/example-1-basics/frame-60.png b/test/functional/example-1-basics/frame-60.png deleted file mode 100644 index af3f4ce..0000000 --- a/test/functional/example-1-basics/frame-60.png +++ /dev/null Binary files differ diff --git a/test/functional/example-1-basics/frame-90.png b/test/functional/example-1-basics/frame-90.png deleted file mode 100644 index 099b823..0000000 --- a/test/functional/example-1-basics/frame-90.png +++ /dev/null Binary files differ diff --git a/test/functional/example-1-basics/index.js b/test/functional/example-1-basics/index.js deleted file mode 100644 index 2ad32bd..0000000 --- a/test/functional/example-1-basics/index.js +++ /dev/null @@ -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(''); - 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(''); - 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(''); - 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); - // }); - // }); -}); diff --git a/test/setup.js b/test/setup.js new file mode 100644 index 0000000..69e1b7a --- /dev/null +++ b/test/setup.js @@ -0,0 +1 @@ +expect = chai.expect; diff --git a/test/unit/bin/pixi.js b/test/unit/bin/pixi.js deleted file mode 100644 index 077cd88..0000000 --- a/test/unit/bin/pixi.js +++ /dev/null @@ -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'); - //}); -}); diff --git a/test/unit/core/utils/util.test.js b/test/unit/core/utils/util.test.js new file mode 100644 index 0000000..30c63f3 --- /dev/null +++ b/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'); + }); + }); +}); diff --git a/package.json b/package.json index 6fc5290..ce76d2f 100644 --- a/package.json +++ b/package.json @@ -16,7 +16,7 @@ "url": "https://github.com/GoodBoyDigital/pixi.js.git" }, "scripts": { - "test": "gulp test", + "test": "gulp && testem ci", "docs": "jsdoc -c ./gulp/util/jsdoc.conf.json -R README.md" }, "dependencies": { @@ -45,16 +45,11 @@ "ink-docstrap": "git+https://github.com/Pilatch/docstrap.git", "jsdoc": "^3.3.0-alpha13", "jshint-summary": "^0.4.0", - "karma": "^0.12.28", - "karma-browserify": "^4.0.0", - "karma-chai": "^0.1.0", - "karma-firefox-launcher": "^0.1.0", - "karma-mocha": "^0.1.10", - "karma-spec-reporter": "^0.0.16", "minimist": "^1.1.1", "mocha": "^2.1.0", "require-dir": "^0.3.0", "run-sequence": "^1.0.2", + "testem": "^0.8.2", "vinyl-buffer": "^1.0.0", "vinyl-source-stream": "^1.1.0", "watchify": "^3.1.1" diff --git a/test/functional/example-1-basics/bunny.png b/test/functional/example-1-basics/bunny.png deleted file mode 100644 index 79c3167..0000000 --- a/test/functional/example-1-basics/bunny.png +++ /dev/null Binary files differ diff --git a/test/functional/example-1-basics/frame-30.png b/test/functional/example-1-basics/frame-30.png deleted file mode 100644 index 96e3409..0000000 --- a/test/functional/example-1-basics/frame-30.png +++ /dev/null Binary files differ diff --git a/test/functional/example-1-basics/frame-60.png b/test/functional/example-1-basics/frame-60.png deleted file mode 100644 index af3f4ce..0000000 --- a/test/functional/example-1-basics/frame-60.png +++ /dev/null Binary files differ diff --git a/test/functional/example-1-basics/frame-90.png b/test/functional/example-1-basics/frame-90.png deleted file mode 100644 index 099b823..0000000 --- a/test/functional/example-1-basics/frame-90.png +++ /dev/null Binary files differ diff --git a/test/functional/example-1-basics/index.js b/test/functional/example-1-basics/index.js deleted file mode 100644 index 2ad32bd..0000000 --- a/test/functional/example-1-basics/index.js +++ /dev/null @@ -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(''); - 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(''); - 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(''); - 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); - // }); - // }); -}); diff --git a/test/setup.js b/test/setup.js new file mode 100644 index 0000000..69e1b7a --- /dev/null +++ b/test/setup.js @@ -0,0 +1 @@ +expect = chai.expect; diff --git a/test/unit/bin/pixi.js b/test/unit/bin/pixi.js deleted file mode 100644 index 077cd88..0000000 --- a/test/unit/bin/pixi.js +++ /dev/null @@ -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'); - //}); -}); diff --git a/test/unit/core/utils/util.test.js b/test/unit/core/utils/util.test.js new file mode 100644 index 0000000..30c63f3 --- /dev/null +++ b/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'); + }); + }); +}); diff --git a/test/unit/index.test.js b/test/unit/index.test.js new file mode 100644 index 0000000..37e1d2a --- /dev/null +++ b/test/unit/index.test.js @@ -0,0 +1,6 @@ +describe('PIXI', function () { + it('exists', function () { + expect(PIXI) + .to.be.an('object'); + }); +}); diff --git a/package.json b/package.json index 6fc5290..ce76d2f 100644 --- a/package.json +++ b/package.json @@ -16,7 +16,7 @@ "url": "https://github.com/GoodBoyDigital/pixi.js.git" }, "scripts": { - "test": "gulp test", + "test": "gulp && testem ci", "docs": "jsdoc -c ./gulp/util/jsdoc.conf.json -R README.md" }, "dependencies": { @@ -45,16 +45,11 @@ "ink-docstrap": "git+https://github.com/Pilatch/docstrap.git", "jsdoc": "^3.3.0-alpha13", "jshint-summary": "^0.4.0", - "karma": "^0.12.28", - "karma-browserify": "^4.0.0", - "karma-chai": "^0.1.0", - "karma-firefox-launcher": "^0.1.0", - "karma-mocha": "^0.1.10", - "karma-spec-reporter": "^0.0.16", "minimist": "^1.1.1", "mocha": "^2.1.0", "require-dir": "^0.3.0", "run-sequence": "^1.0.2", + "testem": "^0.8.2", "vinyl-buffer": "^1.0.0", "vinyl-source-stream": "^1.1.0", "watchify": "^3.1.1" diff --git a/test/functional/example-1-basics/bunny.png b/test/functional/example-1-basics/bunny.png deleted file mode 100644 index 79c3167..0000000 --- a/test/functional/example-1-basics/bunny.png +++ /dev/null Binary files differ diff --git a/test/functional/example-1-basics/frame-30.png b/test/functional/example-1-basics/frame-30.png deleted file mode 100644 index 96e3409..0000000 --- a/test/functional/example-1-basics/frame-30.png +++ /dev/null Binary files differ diff --git a/test/functional/example-1-basics/frame-60.png b/test/functional/example-1-basics/frame-60.png deleted file mode 100644 index af3f4ce..0000000 --- a/test/functional/example-1-basics/frame-60.png +++ /dev/null Binary files differ diff --git a/test/functional/example-1-basics/frame-90.png b/test/functional/example-1-basics/frame-90.png deleted file mode 100644 index 099b823..0000000 --- a/test/functional/example-1-basics/frame-90.png +++ /dev/null Binary files differ diff --git a/test/functional/example-1-basics/index.js b/test/functional/example-1-basics/index.js deleted file mode 100644 index 2ad32bd..0000000 --- a/test/functional/example-1-basics/index.js +++ /dev/null @@ -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(''); - 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(''); - 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(''); - 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); - // }); - // }); -}); diff --git a/test/setup.js b/test/setup.js new file mode 100644 index 0000000..69e1b7a --- /dev/null +++ b/test/setup.js @@ -0,0 +1 @@ +expect = chai.expect; diff --git a/test/unit/bin/pixi.js b/test/unit/bin/pixi.js deleted file mode 100644 index 077cd88..0000000 --- a/test/unit/bin/pixi.js +++ /dev/null @@ -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'); - //}); -}); diff --git a/test/unit/core/utils/util.test.js b/test/unit/core/utils/util.test.js new file mode 100644 index 0000000..30c63f3 --- /dev/null +++ b/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'); + }); + }); +}); diff --git a/test/unit/index.test.js b/test/unit/index.test.js new file mode 100644 index 0000000..37e1d2a --- /dev/null +++ b/test/unit/index.test.js @@ -0,0 +1,6 @@ +describe('PIXI', function () { + it('exists', function () { + expect(PIXI) + .to.be.an('object'); + }); +}); diff --git a/test/unit/pixi-v2/InteractionManager.js b/test/unit/pixi-v2/InteractionManager.js deleted file mode 100644 index ed3001f..0000000 --- a/test/unit/pixi-v2/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/package.json b/package.json index 6fc5290..ce76d2f 100644 --- a/package.json +++ b/package.json @@ -16,7 +16,7 @@ "url": "https://github.com/GoodBoyDigital/pixi.js.git" }, "scripts": { - "test": "gulp test", + "test": "gulp && testem ci", "docs": "jsdoc -c ./gulp/util/jsdoc.conf.json -R README.md" }, "dependencies": { @@ -45,16 +45,11 @@ "ink-docstrap": "git+https://github.com/Pilatch/docstrap.git", "jsdoc": "^3.3.0-alpha13", "jshint-summary": "^0.4.0", - "karma": "^0.12.28", - "karma-browserify": "^4.0.0", - "karma-chai": "^0.1.0", - "karma-firefox-launcher": "^0.1.0", - "karma-mocha": "^0.1.10", - "karma-spec-reporter": "^0.0.16", "minimist": "^1.1.1", "mocha": "^2.1.0", "require-dir": "^0.3.0", "run-sequence": "^1.0.2", + "testem": "^0.8.2", "vinyl-buffer": "^1.0.0", "vinyl-source-stream": "^1.1.0", "watchify": "^3.1.1" diff --git a/test/functional/example-1-basics/bunny.png b/test/functional/example-1-basics/bunny.png deleted file mode 100644 index 79c3167..0000000 --- a/test/functional/example-1-basics/bunny.png +++ /dev/null Binary files differ diff --git a/test/functional/example-1-basics/frame-30.png b/test/functional/example-1-basics/frame-30.png deleted file mode 100644 index 96e3409..0000000 --- a/test/functional/example-1-basics/frame-30.png +++ /dev/null Binary files differ diff --git a/test/functional/example-1-basics/frame-60.png b/test/functional/example-1-basics/frame-60.png deleted file mode 100644 index af3f4ce..0000000 --- a/test/functional/example-1-basics/frame-60.png +++ /dev/null Binary files differ diff --git a/test/functional/example-1-basics/frame-90.png b/test/functional/example-1-basics/frame-90.png deleted file mode 100644 index 099b823..0000000 --- a/test/functional/example-1-basics/frame-90.png +++ /dev/null Binary files differ diff --git a/test/functional/example-1-basics/index.js b/test/functional/example-1-basics/index.js deleted file mode 100644 index 2ad32bd..0000000 --- a/test/functional/example-1-basics/index.js +++ /dev/null @@ -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(''); - 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(''); - 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(''); - 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); - // }); - // }); -}); diff --git a/test/setup.js b/test/setup.js new file mode 100644 index 0000000..69e1b7a --- /dev/null +++ b/test/setup.js @@ -0,0 +1 @@ +expect = chai.expect; diff --git a/test/unit/bin/pixi.js b/test/unit/bin/pixi.js deleted file mode 100644 index 077cd88..0000000 --- a/test/unit/bin/pixi.js +++ /dev/null @@ -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'); - //}); -}); diff --git a/test/unit/core/utils/util.test.js b/test/unit/core/utils/util.test.js new file mode 100644 index 0000000..30c63f3 --- /dev/null +++ b/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'); + }); + }); +}); diff --git a/test/unit/index.test.js b/test/unit/index.test.js new file mode 100644 index 0000000..37e1d2a --- /dev/null +++ b/test/unit/index.test.js @@ -0,0 +1,6 @@ +describe('PIXI', function () { + it('exists', function () { + expect(PIXI) + .to.be.an('object'); + }); +}); diff --git a/test/unit/pixi-v2/InteractionManager.js b/test/unit/pixi-v2/InteractionManager.js deleted file mode 100644 index ed3001f..0000000 --- a/test/unit/pixi-v2/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/Pixi.js b/test/unit/pixi-v2/Pixi.js deleted file mode 100644 index 27debc1..0000000 --- a/test/unit/pixi-v2/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/package.json b/package.json index 6fc5290..ce76d2f 100644 --- a/package.json +++ b/package.json @@ -16,7 +16,7 @@ "url": "https://github.com/GoodBoyDigital/pixi.js.git" }, "scripts": { - "test": "gulp test", + "test": "gulp && testem ci", "docs": "jsdoc -c ./gulp/util/jsdoc.conf.json -R README.md" }, "dependencies": { @@ -45,16 +45,11 @@ "ink-docstrap": "git+https://github.com/Pilatch/docstrap.git", "jsdoc": "^3.3.0-alpha13", "jshint-summary": "^0.4.0", - "karma": "^0.12.28", - "karma-browserify": "^4.0.0", - "karma-chai": "^0.1.0", - "karma-firefox-launcher": "^0.1.0", - "karma-mocha": "^0.1.10", - "karma-spec-reporter": "^0.0.16", "minimist": "^1.1.1", "mocha": "^2.1.0", "require-dir": "^0.3.0", "run-sequence": "^1.0.2", + "testem": "^0.8.2", "vinyl-buffer": "^1.0.0", "vinyl-source-stream": "^1.1.0", "watchify": "^3.1.1" diff --git a/test/functional/example-1-basics/bunny.png b/test/functional/example-1-basics/bunny.png deleted file mode 100644 index 79c3167..0000000 --- a/test/functional/example-1-basics/bunny.png +++ /dev/null Binary files differ diff --git a/test/functional/example-1-basics/frame-30.png b/test/functional/example-1-basics/frame-30.png deleted file mode 100644 index 96e3409..0000000 --- a/test/functional/example-1-basics/frame-30.png +++ /dev/null Binary files differ diff --git a/test/functional/example-1-basics/frame-60.png b/test/functional/example-1-basics/frame-60.png deleted file mode 100644 index af3f4ce..0000000 --- a/test/functional/example-1-basics/frame-60.png +++ /dev/null Binary files differ diff --git a/test/functional/example-1-basics/frame-90.png b/test/functional/example-1-basics/frame-90.png deleted file mode 100644 index 099b823..0000000 --- a/test/functional/example-1-basics/frame-90.png +++ /dev/null Binary files differ diff --git a/test/functional/example-1-basics/index.js b/test/functional/example-1-basics/index.js deleted file mode 100644 index 2ad32bd..0000000 --- a/test/functional/example-1-basics/index.js +++ /dev/null @@ -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(''); - 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(''); - 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(''); - 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); - // }); - // }); -}); diff --git a/test/setup.js b/test/setup.js new file mode 100644 index 0000000..69e1b7a --- /dev/null +++ b/test/setup.js @@ -0,0 +1 @@ +expect = chai.expect; diff --git a/test/unit/bin/pixi.js b/test/unit/bin/pixi.js deleted file mode 100644 index 077cd88..0000000 --- a/test/unit/bin/pixi.js +++ /dev/null @@ -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'); - //}); -}); diff --git a/test/unit/core/utils/util.test.js b/test/unit/core/utils/util.test.js new file mode 100644 index 0000000..30c63f3 --- /dev/null +++ b/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'); + }); + }); +}); diff --git a/test/unit/index.test.js b/test/unit/index.test.js new file mode 100644 index 0000000..37e1d2a --- /dev/null +++ b/test/unit/index.test.js @@ -0,0 +1,6 @@ +describe('PIXI', function () { + it('exists', function () { + expect(PIXI) + .to.be.an('object'); + }); +}); diff --git a/test/unit/pixi-v2/InteractionManager.js b/test/unit/pixi-v2/InteractionManager.js deleted file mode 100644 index ed3001f..0000000 --- a/test/unit/pixi-v2/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/Pixi.js b/test/unit/pixi-v2/Pixi.js deleted file mode 100644 index 27debc1..0000000 --- a/test/unit/pixi-v2/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/core/Circle.js b/test/unit/pixi-v2/core/Circle.js deleted file mode 100644 index fbcfa17..0000000 --- a/test/unit/pixi-v2/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/package.json b/package.json index 6fc5290..ce76d2f 100644 --- a/package.json +++ b/package.json @@ -16,7 +16,7 @@ "url": "https://github.com/GoodBoyDigital/pixi.js.git" }, "scripts": { - "test": "gulp test", + "test": "gulp && testem ci", "docs": "jsdoc -c ./gulp/util/jsdoc.conf.json -R README.md" }, "dependencies": { @@ -45,16 +45,11 @@ "ink-docstrap": "git+https://github.com/Pilatch/docstrap.git", "jsdoc": "^3.3.0-alpha13", "jshint-summary": "^0.4.0", - "karma": "^0.12.28", - "karma-browserify": "^4.0.0", - "karma-chai": "^0.1.0", - "karma-firefox-launcher": "^0.1.0", - "karma-mocha": "^0.1.10", - "karma-spec-reporter": "^0.0.16", "minimist": "^1.1.1", "mocha": "^2.1.0", "require-dir": "^0.3.0", "run-sequence": "^1.0.2", + "testem": "^0.8.2", "vinyl-buffer": "^1.0.0", "vinyl-source-stream": "^1.1.0", "watchify": "^3.1.1" diff --git a/test/functional/example-1-basics/bunny.png b/test/functional/example-1-basics/bunny.png deleted file mode 100644 index 79c3167..0000000 --- a/test/functional/example-1-basics/bunny.png +++ /dev/null Binary files differ diff --git a/test/functional/example-1-basics/frame-30.png b/test/functional/example-1-basics/frame-30.png deleted file mode 100644 index 96e3409..0000000 --- a/test/functional/example-1-basics/frame-30.png +++ /dev/null Binary files differ diff --git a/test/functional/example-1-basics/frame-60.png b/test/functional/example-1-basics/frame-60.png deleted file mode 100644 index af3f4ce..0000000 --- a/test/functional/example-1-basics/frame-60.png +++ /dev/null Binary files differ diff --git a/test/functional/example-1-basics/frame-90.png b/test/functional/example-1-basics/frame-90.png deleted file mode 100644 index 099b823..0000000 --- a/test/functional/example-1-basics/frame-90.png +++ /dev/null Binary files differ diff --git a/test/functional/example-1-basics/index.js b/test/functional/example-1-basics/index.js deleted file mode 100644 index 2ad32bd..0000000 --- a/test/functional/example-1-basics/index.js +++ /dev/null @@ -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(''); - 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(''); - 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(''); - 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); - // }); - // }); -}); diff --git a/test/setup.js b/test/setup.js new file mode 100644 index 0000000..69e1b7a --- /dev/null +++ b/test/setup.js @@ -0,0 +1 @@ +expect = chai.expect; diff --git a/test/unit/bin/pixi.js b/test/unit/bin/pixi.js deleted file mode 100644 index 077cd88..0000000 --- a/test/unit/bin/pixi.js +++ /dev/null @@ -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'); - //}); -}); diff --git a/test/unit/core/utils/util.test.js b/test/unit/core/utils/util.test.js new file mode 100644 index 0000000..30c63f3 --- /dev/null +++ b/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'); + }); + }); +}); diff --git a/test/unit/index.test.js b/test/unit/index.test.js new file mode 100644 index 0000000..37e1d2a --- /dev/null +++ b/test/unit/index.test.js @@ -0,0 +1,6 @@ +describe('PIXI', function () { + it('exists', function () { + expect(PIXI) + .to.be.an('object'); + }); +}); diff --git a/test/unit/pixi-v2/InteractionManager.js b/test/unit/pixi-v2/InteractionManager.js deleted file mode 100644 index ed3001f..0000000 --- a/test/unit/pixi-v2/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/Pixi.js b/test/unit/pixi-v2/Pixi.js deleted file mode 100644 index 27debc1..0000000 --- a/test/unit/pixi-v2/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/core/Circle.js b/test/unit/pixi-v2/core/Circle.js deleted file mode 100644 index fbcfa17..0000000 --- a/test/unit/pixi-v2/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/core/Ellipse.js b/test/unit/pixi-v2/core/Ellipse.js deleted file mode 100644 index 026b56f..0000000 --- a/test/unit/pixi-v2/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/package.json b/package.json index 6fc5290..ce76d2f 100644 --- a/package.json +++ b/package.json @@ -16,7 +16,7 @@ "url": "https://github.com/GoodBoyDigital/pixi.js.git" }, "scripts": { - "test": "gulp test", + "test": "gulp && testem ci", "docs": "jsdoc -c ./gulp/util/jsdoc.conf.json -R README.md" }, "dependencies": { @@ -45,16 +45,11 @@ "ink-docstrap": "git+https://github.com/Pilatch/docstrap.git", "jsdoc": "^3.3.0-alpha13", "jshint-summary": "^0.4.0", - "karma": "^0.12.28", - "karma-browserify": "^4.0.0", - "karma-chai": "^0.1.0", - "karma-firefox-launcher": "^0.1.0", - "karma-mocha": "^0.1.10", - "karma-spec-reporter": "^0.0.16", "minimist": "^1.1.1", "mocha": "^2.1.0", "require-dir": "^0.3.0", "run-sequence": "^1.0.2", + "testem": "^0.8.2", "vinyl-buffer": "^1.0.0", "vinyl-source-stream": "^1.1.0", "watchify": "^3.1.1" diff --git a/test/functional/example-1-basics/bunny.png b/test/functional/example-1-basics/bunny.png deleted file mode 100644 index 79c3167..0000000 --- a/test/functional/example-1-basics/bunny.png +++ /dev/null Binary files differ diff --git a/test/functional/example-1-basics/frame-30.png b/test/functional/example-1-basics/frame-30.png deleted file mode 100644 index 96e3409..0000000 --- a/test/functional/example-1-basics/frame-30.png +++ /dev/null Binary files differ diff --git a/test/functional/example-1-basics/frame-60.png b/test/functional/example-1-basics/frame-60.png deleted file mode 100644 index af3f4ce..0000000 --- a/test/functional/example-1-basics/frame-60.png +++ /dev/null Binary files differ diff --git a/test/functional/example-1-basics/frame-90.png b/test/functional/example-1-basics/frame-90.png deleted file mode 100644 index 099b823..0000000 --- a/test/functional/example-1-basics/frame-90.png +++ /dev/null Binary files differ diff --git a/test/functional/example-1-basics/index.js b/test/functional/example-1-basics/index.js deleted file mode 100644 index 2ad32bd..0000000 --- a/test/functional/example-1-basics/index.js +++ /dev/null @@ -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(''); - 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(''); - 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(''); - 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); - // }); - // }); -}); diff --git a/test/setup.js b/test/setup.js new file mode 100644 index 0000000..69e1b7a --- /dev/null +++ b/test/setup.js @@ -0,0 +1 @@ +expect = chai.expect; diff --git a/test/unit/bin/pixi.js b/test/unit/bin/pixi.js deleted file mode 100644 index 077cd88..0000000 --- a/test/unit/bin/pixi.js +++ /dev/null @@ -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'); - //}); -}); diff --git a/test/unit/core/utils/util.test.js b/test/unit/core/utils/util.test.js new file mode 100644 index 0000000..30c63f3 --- /dev/null +++ b/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'); + }); + }); +}); diff --git a/test/unit/index.test.js b/test/unit/index.test.js new file mode 100644 index 0000000..37e1d2a --- /dev/null +++ b/test/unit/index.test.js @@ -0,0 +1,6 @@ +describe('PIXI', function () { + it('exists', function () { + expect(PIXI) + .to.be.an('object'); + }); +}); diff --git a/test/unit/pixi-v2/InteractionManager.js b/test/unit/pixi-v2/InteractionManager.js deleted file mode 100644 index ed3001f..0000000 --- a/test/unit/pixi-v2/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/Pixi.js b/test/unit/pixi-v2/Pixi.js deleted file mode 100644 index 27debc1..0000000 --- a/test/unit/pixi-v2/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/core/Circle.js b/test/unit/pixi-v2/core/Circle.js deleted file mode 100644 index fbcfa17..0000000 --- a/test/unit/pixi-v2/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/core/Ellipse.js b/test/unit/pixi-v2/core/Ellipse.js deleted file mode 100644 index 026b56f..0000000 --- a/test/unit/pixi-v2/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/core/Matrix.js b/test/unit/pixi-v2/core/Matrix.js deleted file mode 100644 index da75e2e..0000000 --- a/test/unit/pixi-v2/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/package.json b/package.json index 6fc5290..ce76d2f 100644 --- a/package.json +++ b/package.json @@ -16,7 +16,7 @@ "url": "https://github.com/GoodBoyDigital/pixi.js.git" }, "scripts": { - "test": "gulp test", + "test": "gulp && testem ci", "docs": "jsdoc -c ./gulp/util/jsdoc.conf.json -R README.md" }, "dependencies": { @@ -45,16 +45,11 @@ "ink-docstrap": "git+https://github.com/Pilatch/docstrap.git", "jsdoc": "^3.3.0-alpha13", "jshint-summary": "^0.4.0", - "karma": "^0.12.28", - "karma-browserify": "^4.0.0", - "karma-chai": "^0.1.0", - "karma-firefox-launcher": "^0.1.0", - "karma-mocha": "^0.1.10", - "karma-spec-reporter": "^0.0.16", "minimist": "^1.1.1", "mocha": "^2.1.0", "require-dir": "^0.3.0", "run-sequence": "^1.0.2", + "testem": "^0.8.2", "vinyl-buffer": "^1.0.0", "vinyl-source-stream": "^1.1.0", "watchify": "^3.1.1" diff --git a/test/functional/example-1-basics/bunny.png b/test/functional/example-1-basics/bunny.png deleted file mode 100644 index 79c3167..0000000 --- a/test/functional/example-1-basics/bunny.png +++ /dev/null Binary files differ diff --git a/test/functional/example-1-basics/frame-30.png b/test/functional/example-1-basics/frame-30.png deleted file mode 100644 index 96e3409..0000000 --- a/test/functional/example-1-basics/frame-30.png +++ /dev/null Binary files differ diff --git a/test/functional/example-1-basics/frame-60.png b/test/functional/example-1-basics/frame-60.png deleted file mode 100644 index af3f4ce..0000000 --- a/test/functional/example-1-basics/frame-60.png +++ /dev/null Binary files differ diff --git a/test/functional/example-1-basics/frame-90.png b/test/functional/example-1-basics/frame-90.png deleted file mode 100644 index 099b823..0000000 --- a/test/functional/example-1-basics/frame-90.png +++ /dev/null Binary files differ diff --git a/test/functional/example-1-basics/index.js b/test/functional/example-1-basics/index.js deleted file mode 100644 index 2ad32bd..0000000 --- a/test/functional/example-1-basics/index.js +++ /dev/null @@ -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(''); - 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(''); - 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(''); - 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); - // }); - // }); -}); diff --git a/test/setup.js b/test/setup.js new file mode 100644 index 0000000..69e1b7a --- /dev/null +++ b/test/setup.js @@ -0,0 +1 @@ +expect = chai.expect; diff --git a/test/unit/bin/pixi.js b/test/unit/bin/pixi.js deleted file mode 100644 index 077cd88..0000000 --- a/test/unit/bin/pixi.js +++ /dev/null @@ -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'); - //}); -}); diff --git a/test/unit/core/utils/util.test.js b/test/unit/core/utils/util.test.js new file mode 100644 index 0000000..30c63f3 --- /dev/null +++ b/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'); + }); + }); +}); diff --git a/test/unit/index.test.js b/test/unit/index.test.js new file mode 100644 index 0000000..37e1d2a --- /dev/null +++ b/test/unit/index.test.js @@ -0,0 +1,6 @@ +describe('PIXI', function () { + it('exists', function () { + expect(PIXI) + .to.be.an('object'); + }); +}); diff --git a/test/unit/pixi-v2/InteractionManager.js b/test/unit/pixi-v2/InteractionManager.js deleted file mode 100644 index ed3001f..0000000 --- a/test/unit/pixi-v2/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/Pixi.js b/test/unit/pixi-v2/Pixi.js deleted file mode 100644 index 27debc1..0000000 --- a/test/unit/pixi-v2/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/core/Circle.js b/test/unit/pixi-v2/core/Circle.js deleted file mode 100644 index fbcfa17..0000000 --- a/test/unit/pixi-v2/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/core/Ellipse.js b/test/unit/pixi-v2/core/Ellipse.js deleted file mode 100644 index 026b56f..0000000 --- a/test/unit/pixi-v2/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/core/Matrix.js b/test/unit/pixi-v2/core/Matrix.js deleted file mode 100644 index da75e2e..0000000 --- a/test/unit/pixi-v2/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/core/Point.js b/test/unit/pixi-v2/core/Point.js deleted file mode 100644 index c4d5163..0000000 --- a/test/unit/pixi-v2/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/package.json b/package.json index 6fc5290..ce76d2f 100644 --- a/package.json +++ b/package.json @@ -16,7 +16,7 @@ "url": "https://github.com/GoodBoyDigital/pixi.js.git" }, "scripts": { - "test": "gulp test", + "test": "gulp && testem ci", "docs": "jsdoc -c ./gulp/util/jsdoc.conf.json -R README.md" }, "dependencies": { @@ -45,16 +45,11 @@ "ink-docstrap": "git+https://github.com/Pilatch/docstrap.git", "jsdoc": "^3.3.0-alpha13", "jshint-summary": "^0.4.0", - "karma": "^0.12.28", - "karma-browserify": "^4.0.0", - "karma-chai": "^0.1.0", - "karma-firefox-launcher": "^0.1.0", - "karma-mocha": "^0.1.10", - "karma-spec-reporter": "^0.0.16", "minimist": "^1.1.1", "mocha": "^2.1.0", "require-dir": "^0.3.0", "run-sequence": "^1.0.2", + "testem": "^0.8.2", "vinyl-buffer": "^1.0.0", "vinyl-source-stream": "^1.1.0", "watchify": "^3.1.1" diff --git a/test/functional/example-1-basics/bunny.png b/test/functional/example-1-basics/bunny.png deleted file mode 100644 index 79c3167..0000000 --- a/test/functional/example-1-basics/bunny.png +++ /dev/null Binary files differ diff --git a/test/functional/example-1-basics/frame-30.png b/test/functional/example-1-basics/frame-30.png deleted file mode 100644 index 96e3409..0000000 --- a/test/functional/example-1-basics/frame-30.png +++ /dev/null Binary files differ diff --git a/test/functional/example-1-basics/frame-60.png b/test/functional/example-1-basics/frame-60.png deleted file mode 100644 index af3f4ce..0000000 --- a/test/functional/example-1-basics/frame-60.png +++ /dev/null Binary files differ diff --git a/test/functional/example-1-basics/frame-90.png b/test/functional/example-1-basics/frame-90.png deleted file mode 100644 index 099b823..0000000 --- a/test/functional/example-1-basics/frame-90.png +++ /dev/null Binary files differ diff --git a/test/functional/example-1-basics/index.js b/test/functional/example-1-basics/index.js deleted file mode 100644 index 2ad32bd..0000000 --- a/test/functional/example-1-basics/index.js +++ /dev/null @@ -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(''); - 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(''); - 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(''); - 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); - // }); - // }); -}); diff --git a/test/setup.js b/test/setup.js new file mode 100644 index 0000000..69e1b7a --- /dev/null +++ b/test/setup.js @@ -0,0 +1 @@ +expect = chai.expect; diff --git a/test/unit/bin/pixi.js b/test/unit/bin/pixi.js deleted file mode 100644 index 077cd88..0000000 --- a/test/unit/bin/pixi.js +++ /dev/null @@ -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'); - //}); -}); diff --git a/test/unit/core/utils/util.test.js b/test/unit/core/utils/util.test.js new file mode 100644 index 0000000..30c63f3 --- /dev/null +++ b/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'); + }); + }); +}); diff --git a/test/unit/index.test.js b/test/unit/index.test.js new file mode 100644 index 0000000..37e1d2a --- /dev/null +++ b/test/unit/index.test.js @@ -0,0 +1,6 @@ +describe('PIXI', function () { + it('exists', function () { + expect(PIXI) + .to.be.an('object'); + }); +}); diff --git a/test/unit/pixi-v2/InteractionManager.js b/test/unit/pixi-v2/InteractionManager.js deleted file mode 100644 index ed3001f..0000000 --- a/test/unit/pixi-v2/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/Pixi.js b/test/unit/pixi-v2/Pixi.js deleted file mode 100644 index 27debc1..0000000 --- a/test/unit/pixi-v2/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/core/Circle.js b/test/unit/pixi-v2/core/Circle.js deleted file mode 100644 index fbcfa17..0000000 --- a/test/unit/pixi-v2/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/core/Ellipse.js b/test/unit/pixi-v2/core/Ellipse.js deleted file mode 100644 index 026b56f..0000000 --- a/test/unit/pixi-v2/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/core/Matrix.js b/test/unit/pixi-v2/core/Matrix.js deleted file mode 100644 index da75e2e..0000000 --- a/test/unit/pixi-v2/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/core/Point.js b/test/unit/pixi-v2/core/Point.js deleted file mode 100644 index c4d5163..0000000 --- a/test/unit/pixi-v2/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/core/Polygon.js b/test/unit/pixi-v2/core/Polygon.js deleted file mode 100644 index dc8c918..0000000 --- a/test/unit/pixi-v2/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/package.json b/package.json index 6fc5290..ce76d2f 100644 --- a/package.json +++ b/package.json @@ -16,7 +16,7 @@ "url": "https://github.com/GoodBoyDigital/pixi.js.git" }, "scripts": { - "test": "gulp test", + "test": "gulp && testem ci", "docs": "jsdoc -c ./gulp/util/jsdoc.conf.json -R README.md" }, "dependencies": { @@ -45,16 +45,11 @@ "ink-docstrap": "git+https://github.com/Pilatch/docstrap.git", "jsdoc": "^3.3.0-alpha13", "jshint-summary": "^0.4.0", - "karma": "^0.12.28", - "karma-browserify": "^4.0.0", - "karma-chai": "^0.1.0", - "karma-firefox-launcher": "^0.1.0", - "karma-mocha": "^0.1.10", - "karma-spec-reporter": "^0.0.16", "minimist": "^1.1.1", "mocha": "^2.1.0", "require-dir": "^0.3.0", "run-sequence": "^1.0.2", + "testem": "^0.8.2", "vinyl-buffer": "^1.0.0", "vinyl-source-stream": "^1.1.0", "watchify": "^3.1.1" diff --git a/test/functional/example-1-basics/bunny.png b/test/functional/example-1-basics/bunny.png deleted file mode 100644 index 79c3167..0000000 --- a/test/functional/example-1-basics/bunny.png +++ /dev/null Binary files differ diff --git a/test/functional/example-1-basics/frame-30.png b/test/functional/example-1-basics/frame-30.png deleted file mode 100644 index 96e3409..0000000 --- a/test/functional/example-1-basics/frame-30.png +++ /dev/null Binary files differ diff --git a/test/functional/example-1-basics/frame-60.png b/test/functional/example-1-basics/frame-60.png deleted file mode 100644 index af3f4ce..0000000 --- a/test/functional/example-1-basics/frame-60.png +++ /dev/null Binary files differ diff --git a/test/functional/example-1-basics/frame-90.png b/test/functional/example-1-basics/frame-90.png deleted file mode 100644 index 099b823..0000000 --- a/test/functional/example-1-basics/frame-90.png +++ /dev/null Binary files differ diff --git a/test/functional/example-1-basics/index.js b/test/functional/example-1-basics/index.js deleted file mode 100644 index 2ad32bd..0000000 --- a/test/functional/example-1-basics/index.js +++ /dev/null @@ -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(''); - 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(''); - 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(''); - 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); - // }); - // }); -}); diff --git a/test/setup.js b/test/setup.js new file mode 100644 index 0000000..69e1b7a --- /dev/null +++ b/test/setup.js @@ -0,0 +1 @@ +expect = chai.expect; diff --git a/test/unit/bin/pixi.js b/test/unit/bin/pixi.js deleted file mode 100644 index 077cd88..0000000 --- a/test/unit/bin/pixi.js +++ /dev/null @@ -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'); - //}); -}); diff --git a/test/unit/core/utils/util.test.js b/test/unit/core/utils/util.test.js new file mode 100644 index 0000000..30c63f3 --- /dev/null +++ b/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'); + }); + }); +}); diff --git a/test/unit/index.test.js b/test/unit/index.test.js new file mode 100644 index 0000000..37e1d2a --- /dev/null +++ b/test/unit/index.test.js @@ -0,0 +1,6 @@ +describe('PIXI', function () { + it('exists', function () { + expect(PIXI) + .to.be.an('object'); + }); +}); diff --git a/test/unit/pixi-v2/InteractionManager.js b/test/unit/pixi-v2/InteractionManager.js deleted file mode 100644 index ed3001f..0000000 --- a/test/unit/pixi-v2/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/Pixi.js b/test/unit/pixi-v2/Pixi.js deleted file mode 100644 index 27debc1..0000000 --- a/test/unit/pixi-v2/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/core/Circle.js b/test/unit/pixi-v2/core/Circle.js deleted file mode 100644 index fbcfa17..0000000 --- a/test/unit/pixi-v2/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/core/Ellipse.js b/test/unit/pixi-v2/core/Ellipse.js deleted file mode 100644 index 026b56f..0000000 --- a/test/unit/pixi-v2/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/core/Matrix.js b/test/unit/pixi-v2/core/Matrix.js deleted file mode 100644 index da75e2e..0000000 --- a/test/unit/pixi-v2/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/core/Point.js b/test/unit/pixi-v2/core/Point.js deleted file mode 100644 index c4d5163..0000000 --- a/test/unit/pixi-v2/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/core/Polygon.js b/test/unit/pixi-v2/core/Polygon.js deleted file mode 100644 index dc8c918..0000000 --- a/test/unit/pixi-v2/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/core/Rectangle.js b/test/unit/pixi-v2/core/Rectangle.js deleted file mode 100644 index d43316e..0000000 --- a/test/unit/pixi-v2/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/package.json b/package.json index 6fc5290..ce76d2f 100644 --- a/package.json +++ b/package.json @@ -16,7 +16,7 @@ "url": "https://github.com/GoodBoyDigital/pixi.js.git" }, "scripts": { - "test": "gulp test", + "test": "gulp && testem ci", "docs": "jsdoc -c ./gulp/util/jsdoc.conf.json -R README.md" }, "dependencies": { @@ -45,16 +45,11 @@ "ink-docstrap": "git+https://github.com/Pilatch/docstrap.git", "jsdoc": "^3.3.0-alpha13", "jshint-summary": "^0.4.0", - "karma": "^0.12.28", - "karma-browserify": "^4.0.0", - "karma-chai": "^0.1.0", - "karma-firefox-launcher": "^0.1.0", - "karma-mocha": "^0.1.10", - "karma-spec-reporter": "^0.0.16", "minimist": "^1.1.1", "mocha": "^2.1.0", "require-dir": "^0.3.0", "run-sequence": "^1.0.2", + "testem": "^0.8.2", "vinyl-buffer": "^1.0.0", "vinyl-source-stream": "^1.1.0", "watchify": "^3.1.1" diff --git a/test/functional/example-1-basics/bunny.png b/test/functional/example-1-basics/bunny.png deleted file mode 100644 index 79c3167..0000000 --- a/test/functional/example-1-basics/bunny.png +++ /dev/null Binary files differ diff --git a/test/functional/example-1-basics/frame-30.png b/test/functional/example-1-basics/frame-30.png deleted file mode 100644 index 96e3409..0000000 --- a/test/functional/example-1-basics/frame-30.png +++ /dev/null Binary files differ diff --git a/test/functional/example-1-basics/frame-60.png b/test/functional/example-1-basics/frame-60.png deleted file mode 100644 index af3f4ce..0000000 --- a/test/functional/example-1-basics/frame-60.png +++ /dev/null Binary files differ diff --git a/test/functional/example-1-basics/frame-90.png b/test/functional/example-1-basics/frame-90.png deleted file mode 100644 index 099b823..0000000 --- a/test/functional/example-1-basics/frame-90.png +++ /dev/null Binary files differ diff --git a/test/functional/example-1-basics/index.js b/test/functional/example-1-basics/index.js deleted file mode 100644 index 2ad32bd..0000000 --- a/test/functional/example-1-basics/index.js +++ /dev/null @@ -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(''); - 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(''); - 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(''); - 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); - // }); - // }); -}); diff --git a/test/setup.js b/test/setup.js new file mode 100644 index 0000000..69e1b7a --- /dev/null +++ b/test/setup.js @@ -0,0 +1 @@ +expect = chai.expect; diff --git a/test/unit/bin/pixi.js b/test/unit/bin/pixi.js deleted file mode 100644 index 077cd88..0000000 --- a/test/unit/bin/pixi.js +++ /dev/null @@ -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'); - //}); -}); diff --git a/test/unit/core/utils/util.test.js b/test/unit/core/utils/util.test.js new file mode 100644 index 0000000..30c63f3 --- /dev/null +++ b/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'); + }); + }); +}); diff --git a/test/unit/index.test.js b/test/unit/index.test.js new file mode 100644 index 0000000..37e1d2a --- /dev/null +++ b/test/unit/index.test.js @@ -0,0 +1,6 @@ +describe('PIXI', function () { + it('exists', function () { + expect(PIXI) + .to.be.an('object'); + }); +}); diff --git a/test/unit/pixi-v2/InteractionManager.js b/test/unit/pixi-v2/InteractionManager.js deleted file mode 100644 index ed3001f..0000000 --- a/test/unit/pixi-v2/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/Pixi.js b/test/unit/pixi-v2/Pixi.js deleted file mode 100644 index 27debc1..0000000 --- a/test/unit/pixi-v2/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/core/Circle.js b/test/unit/pixi-v2/core/Circle.js deleted file mode 100644 index fbcfa17..0000000 --- a/test/unit/pixi-v2/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/core/Ellipse.js b/test/unit/pixi-v2/core/Ellipse.js deleted file mode 100644 index 026b56f..0000000 --- a/test/unit/pixi-v2/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/core/Matrix.js b/test/unit/pixi-v2/core/Matrix.js deleted file mode 100644 index da75e2e..0000000 --- a/test/unit/pixi-v2/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/core/Point.js b/test/unit/pixi-v2/core/Point.js deleted file mode 100644 index c4d5163..0000000 --- a/test/unit/pixi-v2/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/core/Polygon.js b/test/unit/pixi-v2/core/Polygon.js deleted file mode 100644 index dc8c918..0000000 --- a/test/unit/pixi-v2/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/core/Rectangle.js b/test/unit/pixi-v2/core/Rectangle.js deleted file mode 100644 index d43316e..0000000 --- a/test/unit/pixi-v2/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/display/DisplayObject.js b/test/unit/pixi-v2/display/DisplayObject.js deleted file mode 100644 index 044acf8..0000000 --- a/test/unit/pixi-v2/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/package.json b/package.json index 6fc5290..ce76d2f 100644 --- a/package.json +++ b/package.json @@ -16,7 +16,7 @@ "url": "https://github.com/GoodBoyDigital/pixi.js.git" }, "scripts": { - "test": "gulp test", + "test": "gulp && testem ci", "docs": "jsdoc -c ./gulp/util/jsdoc.conf.json -R README.md" }, "dependencies": { @@ -45,16 +45,11 @@ "ink-docstrap": "git+https://github.com/Pilatch/docstrap.git", "jsdoc": "^3.3.0-alpha13", "jshint-summary": "^0.4.0", - "karma": "^0.12.28", - "karma-browserify": "^4.0.0", - "karma-chai": "^0.1.0", - "karma-firefox-launcher": "^0.1.0", - "karma-mocha": "^0.1.10", - "karma-spec-reporter": "^0.0.16", "minimist": "^1.1.1", "mocha": "^2.1.0", "require-dir": "^0.3.0", "run-sequence": "^1.0.2", + "testem": "^0.8.2", "vinyl-buffer": "^1.0.0", "vinyl-source-stream": "^1.1.0", "watchify": "^3.1.1" diff --git a/test/functional/example-1-basics/bunny.png b/test/functional/example-1-basics/bunny.png deleted file mode 100644 index 79c3167..0000000 --- a/test/functional/example-1-basics/bunny.png +++ /dev/null Binary files differ diff --git a/test/functional/example-1-basics/frame-30.png b/test/functional/example-1-basics/frame-30.png deleted file mode 100644 index 96e3409..0000000 --- a/test/functional/example-1-basics/frame-30.png +++ /dev/null Binary files differ diff --git a/test/functional/example-1-basics/frame-60.png b/test/functional/example-1-basics/frame-60.png deleted file mode 100644 index af3f4ce..0000000 --- a/test/functional/example-1-basics/frame-60.png +++ /dev/null Binary files differ diff --git a/test/functional/example-1-basics/frame-90.png b/test/functional/example-1-basics/frame-90.png deleted file mode 100644 index 099b823..0000000 --- a/test/functional/example-1-basics/frame-90.png +++ /dev/null Binary files differ diff --git a/test/functional/example-1-basics/index.js b/test/functional/example-1-basics/index.js deleted file mode 100644 index 2ad32bd..0000000 --- a/test/functional/example-1-basics/index.js +++ /dev/null @@ -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(''); - 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(''); - 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(''); - 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); - // }); - // }); -}); diff --git a/test/setup.js b/test/setup.js new file mode 100644 index 0000000..69e1b7a --- /dev/null +++ b/test/setup.js @@ -0,0 +1 @@ +expect = chai.expect; diff --git a/test/unit/bin/pixi.js b/test/unit/bin/pixi.js deleted file mode 100644 index 077cd88..0000000 --- a/test/unit/bin/pixi.js +++ /dev/null @@ -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'); - //}); -}); diff --git a/test/unit/core/utils/util.test.js b/test/unit/core/utils/util.test.js new file mode 100644 index 0000000..30c63f3 --- /dev/null +++ b/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'); + }); + }); +}); diff --git a/test/unit/index.test.js b/test/unit/index.test.js new file mode 100644 index 0000000..37e1d2a --- /dev/null +++ b/test/unit/index.test.js @@ -0,0 +1,6 @@ +describe('PIXI', function () { + it('exists', function () { + expect(PIXI) + .to.be.an('object'); + }); +}); diff --git a/test/unit/pixi-v2/InteractionManager.js b/test/unit/pixi-v2/InteractionManager.js deleted file mode 100644 index ed3001f..0000000 --- a/test/unit/pixi-v2/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/Pixi.js b/test/unit/pixi-v2/Pixi.js deleted file mode 100644 index 27debc1..0000000 --- a/test/unit/pixi-v2/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/core/Circle.js b/test/unit/pixi-v2/core/Circle.js deleted file mode 100644 index fbcfa17..0000000 --- a/test/unit/pixi-v2/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/core/Ellipse.js b/test/unit/pixi-v2/core/Ellipse.js deleted file mode 100644 index 026b56f..0000000 --- a/test/unit/pixi-v2/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/core/Matrix.js b/test/unit/pixi-v2/core/Matrix.js deleted file mode 100644 index da75e2e..0000000 --- a/test/unit/pixi-v2/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/core/Point.js b/test/unit/pixi-v2/core/Point.js deleted file mode 100644 index c4d5163..0000000 --- a/test/unit/pixi-v2/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/core/Polygon.js b/test/unit/pixi-v2/core/Polygon.js deleted file mode 100644 index dc8c918..0000000 --- a/test/unit/pixi-v2/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/core/Rectangle.js b/test/unit/pixi-v2/core/Rectangle.js deleted file mode 100644 index d43316e..0000000 --- a/test/unit/pixi-v2/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/display/DisplayObject.js b/test/unit/pixi-v2/display/DisplayObject.js deleted file mode 100644 index 044acf8..0000000 --- a/test/unit/pixi-v2/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/display/DisplayObjectContainer.js b/test/unit/pixi-v2/display/DisplayObjectContainer.js deleted file mode 100644 index 15a3376..0000000 --- a/test/unit/pixi-v2/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/package.json b/package.json index 6fc5290..ce76d2f 100644 --- a/package.json +++ b/package.json @@ -16,7 +16,7 @@ "url": "https://github.com/GoodBoyDigital/pixi.js.git" }, "scripts": { - "test": "gulp test", + "test": "gulp && testem ci", "docs": "jsdoc -c ./gulp/util/jsdoc.conf.json -R README.md" }, "dependencies": { @@ -45,16 +45,11 @@ "ink-docstrap": "git+https://github.com/Pilatch/docstrap.git", "jsdoc": "^3.3.0-alpha13", "jshint-summary": "^0.4.0", - "karma": "^0.12.28", - "karma-browserify": "^4.0.0", - "karma-chai": "^0.1.0", - "karma-firefox-launcher": "^0.1.0", - "karma-mocha": "^0.1.10", - "karma-spec-reporter": "^0.0.16", "minimist": "^1.1.1", "mocha": "^2.1.0", "require-dir": "^0.3.0", "run-sequence": "^1.0.2", + "testem": "^0.8.2", "vinyl-buffer": "^1.0.0", "vinyl-source-stream": "^1.1.0", "watchify": "^3.1.1" diff --git a/test/functional/example-1-basics/bunny.png b/test/functional/example-1-basics/bunny.png deleted file mode 100644 index 79c3167..0000000 --- a/test/functional/example-1-basics/bunny.png +++ /dev/null Binary files differ diff --git a/test/functional/example-1-basics/frame-30.png b/test/functional/example-1-basics/frame-30.png deleted file mode 100644 index 96e3409..0000000 --- a/test/functional/example-1-basics/frame-30.png +++ /dev/null Binary files differ diff --git a/test/functional/example-1-basics/frame-60.png b/test/functional/example-1-basics/frame-60.png deleted file mode 100644 index af3f4ce..0000000 --- a/test/functional/example-1-basics/frame-60.png +++ /dev/null Binary files differ diff --git a/test/functional/example-1-basics/frame-90.png b/test/functional/example-1-basics/frame-90.png deleted file mode 100644 index 099b823..0000000 --- a/test/functional/example-1-basics/frame-90.png +++ /dev/null Binary files differ diff --git a/test/functional/example-1-basics/index.js b/test/functional/example-1-basics/index.js deleted file mode 100644 index 2ad32bd..0000000 --- a/test/functional/example-1-basics/index.js +++ /dev/null @@ -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(''); - 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(''); - 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(''); - 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); - // }); - // }); -}); diff --git a/test/setup.js b/test/setup.js new file mode 100644 index 0000000..69e1b7a --- /dev/null +++ b/test/setup.js @@ -0,0 +1 @@ +expect = chai.expect; diff --git a/test/unit/bin/pixi.js b/test/unit/bin/pixi.js deleted file mode 100644 index 077cd88..0000000 --- a/test/unit/bin/pixi.js +++ /dev/null @@ -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'); - //}); -}); diff --git a/test/unit/core/utils/util.test.js b/test/unit/core/utils/util.test.js new file mode 100644 index 0000000..30c63f3 --- /dev/null +++ b/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'); + }); + }); +}); diff --git a/test/unit/index.test.js b/test/unit/index.test.js new file mode 100644 index 0000000..37e1d2a --- /dev/null +++ b/test/unit/index.test.js @@ -0,0 +1,6 @@ +describe('PIXI', function () { + it('exists', function () { + expect(PIXI) + .to.be.an('object'); + }); +}); diff --git a/test/unit/pixi-v2/InteractionManager.js b/test/unit/pixi-v2/InteractionManager.js deleted file mode 100644 index ed3001f..0000000 --- a/test/unit/pixi-v2/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/Pixi.js b/test/unit/pixi-v2/Pixi.js deleted file mode 100644 index 27debc1..0000000 --- a/test/unit/pixi-v2/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/core/Circle.js b/test/unit/pixi-v2/core/Circle.js deleted file mode 100644 index fbcfa17..0000000 --- a/test/unit/pixi-v2/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/core/Ellipse.js b/test/unit/pixi-v2/core/Ellipse.js deleted file mode 100644 index 026b56f..0000000 --- a/test/unit/pixi-v2/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/core/Matrix.js b/test/unit/pixi-v2/core/Matrix.js deleted file mode 100644 index da75e2e..0000000 --- a/test/unit/pixi-v2/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/core/Point.js b/test/unit/pixi-v2/core/Point.js deleted file mode 100644 index c4d5163..0000000 --- a/test/unit/pixi-v2/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/core/Polygon.js b/test/unit/pixi-v2/core/Polygon.js deleted file mode 100644 index dc8c918..0000000 --- a/test/unit/pixi-v2/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/core/Rectangle.js b/test/unit/pixi-v2/core/Rectangle.js deleted file mode 100644 index d43316e..0000000 --- a/test/unit/pixi-v2/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/display/DisplayObject.js b/test/unit/pixi-v2/display/DisplayObject.js deleted file mode 100644 index 044acf8..0000000 --- a/test/unit/pixi-v2/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/display/DisplayObjectContainer.js b/test/unit/pixi-v2/display/DisplayObjectContainer.js deleted file mode 100644 index 15a3376..0000000 --- a/test/unit/pixi-v2/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/display/MovieClip.js b/test/unit/pixi-v2/display/MovieClip.js deleted file mode 100644 index f3c6c6a..0000000 --- a/test/unit/pixi-v2/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/package.json b/package.json index 6fc5290..ce76d2f 100644 --- a/package.json +++ b/package.json @@ -16,7 +16,7 @@ "url": "https://github.com/GoodBoyDigital/pixi.js.git" }, "scripts": { - "test": "gulp test", + "test": "gulp && testem ci", "docs": "jsdoc -c ./gulp/util/jsdoc.conf.json -R README.md" }, "dependencies": { @@ -45,16 +45,11 @@ "ink-docstrap": "git+https://github.com/Pilatch/docstrap.git", "jsdoc": "^3.3.0-alpha13", "jshint-summary": "^0.4.0", - "karma": "^0.12.28", - "karma-browserify": "^4.0.0", - "karma-chai": "^0.1.0", - "karma-firefox-launcher": "^0.1.0", - "karma-mocha": "^0.1.10", - "karma-spec-reporter": "^0.0.16", "minimist": "^1.1.1", "mocha": "^2.1.0", "require-dir": "^0.3.0", "run-sequence": "^1.0.2", + "testem": "^0.8.2", "vinyl-buffer": "^1.0.0", "vinyl-source-stream": "^1.1.0", "watchify": "^3.1.1" diff --git a/test/functional/example-1-basics/bunny.png b/test/functional/example-1-basics/bunny.png deleted file mode 100644 index 79c3167..0000000 --- a/test/functional/example-1-basics/bunny.png +++ /dev/null Binary files differ diff --git a/test/functional/example-1-basics/frame-30.png b/test/functional/example-1-basics/frame-30.png deleted file mode 100644 index 96e3409..0000000 --- a/test/functional/example-1-basics/frame-30.png +++ /dev/null Binary files differ diff --git a/test/functional/example-1-basics/frame-60.png b/test/functional/example-1-basics/frame-60.png deleted file mode 100644 index af3f4ce..0000000 --- a/test/functional/example-1-basics/frame-60.png +++ /dev/null Binary files differ diff --git a/test/functional/example-1-basics/frame-90.png b/test/functional/example-1-basics/frame-90.png deleted file mode 100644 index 099b823..0000000 --- a/test/functional/example-1-basics/frame-90.png +++ /dev/null Binary files differ diff --git a/test/functional/example-1-basics/index.js b/test/functional/example-1-basics/index.js deleted file mode 100644 index 2ad32bd..0000000 --- a/test/functional/example-1-basics/index.js +++ /dev/null @@ -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(''); - 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(''); - 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(''); - 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); - // }); - // }); -}); diff --git a/test/setup.js b/test/setup.js new file mode 100644 index 0000000..69e1b7a --- /dev/null +++ b/test/setup.js @@ -0,0 +1 @@ +expect = chai.expect; diff --git a/test/unit/bin/pixi.js b/test/unit/bin/pixi.js deleted file mode 100644 index 077cd88..0000000 --- a/test/unit/bin/pixi.js +++ /dev/null @@ -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'); - //}); -}); diff --git a/test/unit/core/utils/util.test.js b/test/unit/core/utils/util.test.js new file mode 100644 index 0000000..30c63f3 --- /dev/null +++ b/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'); + }); + }); +}); diff --git a/test/unit/index.test.js b/test/unit/index.test.js new file mode 100644 index 0000000..37e1d2a --- /dev/null +++ b/test/unit/index.test.js @@ -0,0 +1,6 @@ +describe('PIXI', function () { + it('exists', function () { + expect(PIXI) + .to.be.an('object'); + }); +}); diff --git a/test/unit/pixi-v2/InteractionManager.js b/test/unit/pixi-v2/InteractionManager.js deleted file mode 100644 index ed3001f..0000000 --- a/test/unit/pixi-v2/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/Pixi.js b/test/unit/pixi-v2/Pixi.js deleted file mode 100644 index 27debc1..0000000 --- a/test/unit/pixi-v2/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/core/Circle.js b/test/unit/pixi-v2/core/Circle.js deleted file mode 100644 index fbcfa17..0000000 --- a/test/unit/pixi-v2/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/core/Ellipse.js b/test/unit/pixi-v2/core/Ellipse.js deleted file mode 100644 index 026b56f..0000000 --- a/test/unit/pixi-v2/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/core/Matrix.js b/test/unit/pixi-v2/core/Matrix.js deleted file mode 100644 index da75e2e..0000000 --- a/test/unit/pixi-v2/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/core/Point.js b/test/unit/pixi-v2/core/Point.js deleted file mode 100644 index c4d5163..0000000 --- a/test/unit/pixi-v2/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/core/Polygon.js b/test/unit/pixi-v2/core/Polygon.js deleted file mode 100644 index dc8c918..0000000 --- a/test/unit/pixi-v2/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/core/Rectangle.js b/test/unit/pixi-v2/core/Rectangle.js deleted file mode 100644 index d43316e..0000000 --- a/test/unit/pixi-v2/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/display/DisplayObject.js b/test/unit/pixi-v2/display/DisplayObject.js deleted file mode 100644 index 044acf8..0000000 --- a/test/unit/pixi-v2/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/display/DisplayObjectContainer.js b/test/unit/pixi-v2/display/DisplayObjectContainer.js deleted file mode 100644 index 15a3376..0000000 --- a/test/unit/pixi-v2/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/display/MovieClip.js b/test/unit/pixi-v2/display/MovieClip.js deleted file mode 100644 index f3c6c6a..0000000 --- a/test/unit/pixi-v2/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/display/Sprite.js b/test/unit/pixi-v2/display/Sprite.js deleted file mode 100644 index 30c8076..0000000 --- a/test/unit/pixi-v2/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/package.json b/package.json index 6fc5290..ce76d2f 100644 --- a/package.json +++ b/package.json @@ -16,7 +16,7 @@ "url": "https://github.com/GoodBoyDigital/pixi.js.git" }, "scripts": { - "test": "gulp test", + "test": "gulp && testem ci", "docs": "jsdoc -c ./gulp/util/jsdoc.conf.json -R README.md" }, "dependencies": { @@ -45,16 +45,11 @@ "ink-docstrap": "git+https://github.com/Pilatch/docstrap.git", "jsdoc": "^3.3.0-alpha13", "jshint-summary": "^0.4.0", - "karma": "^0.12.28", - "karma-browserify": "^4.0.0", - "karma-chai": "^0.1.0", - "karma-firefox-launcher": "^0.1.0", - "karma-mocha": "^0.1.10", - "karma-spec-reporter": "^0.0.16", "minimist": "^1.1.1", "mocha": "^2.1.0", "require-dir": "^0.3.0", "run-sequence": "^1.0.2", + "testem": "^0.8.2", "vinyl-buffer": "^1.0.0", "vinyl-source-stream": "^1.1.0", "watchify": "^3.1.1" diff --git a/test/functional/example-1-basics/bunny.png b/test/functional/example-1-basics/bunny.png deleted file mode 100644 index 79c3167..0000000 --- a/test/functional/example-1-basics/bunny.png +++ /dev/null Binary files differ diff --git a/test/functional/example-1-basics/frame-30.png b/test/functional/example-1-basics/frame-30.png deleted file mode 100644 index 96e3409..0000000 --- a/test/functional/example-1-basics/frame-30.png +++ /dev/null Binary files differ diff --git a/test/functional/example-1-basics/frame-60.png b/test/functional/example-1-basics/frame-60.png deleted file mode 100644 index af3f4ce..0000000 --- a/test/functional/example-1-basics/frame-60.png +++ /dev/null Binary files differ diff --git a/test/functional/example-1-basics/frame-90.png b/test/functional/example-1-basics/frame-90.png deleted file mode 100644 index 099b823..0000000 --- a/test/functional/example-1-basics/frame-90.png +++ /dev/null Binary files differ diff --git a/test/functional/example-1-basics/index.js b/test/functional/example-1-basics/index.js deleted file mode 100644 index 2ad32bd..0000000 --- a/test/functional/example-1-basics/index.js +++ /dev/null @@ -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(''); - 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(''); - 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(''); - 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); - // }); - // }); -}); diff --git a/test/setup.js b/test/setup.js new file mode 100644 index 0000000..69e1b7a --- /dev/null +++ b/test/setup.js @@ -0,0 +1 @@ +expect = chai.expect; diff --git a/test/unit/bin/pixi.js b/test/unit/bin/pixi.js deleted file mode 100644 index 077cd88..0000000 --- a/test/unit/bin/pixi.js +++ /dev/null @@ -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'); - //}); -}); diff --git a/test/unit/core/utils/util.test.js b/test/unit/core/utils/util.test.js new file mode 100644 index 0000000..30c63f3 --- /dev/null +++ b/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'); + }); + }); +}); diff --git a/test/unit/index.test.js b/test/unit/index.test.js new file mode 100644 index 0000000..37e1d2a --- /dev/null +++ b/test/unit/index.test.js @@ -0,0 +1,6 @@ +describe('PIXI', function () { + it('exists', function () { + expect(PIXI) + .to.be.an('object'); + }); +}); diff --git a/test/unit/pixi-v2/InteractionManager.js b/test/unit/pixi-v2/InteractionManager.js deleted file mode 100644 index ed3001f..0000000 --- a/test/unit/pixi-v2/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/Pixi.js b/test/unit/pixi-v2/Pixi.js deleted file mode 100644 index 27debc1..0000000 --- a/test/unit/pixi-v2/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/core/Circle.js b/test/unit/pixi-v2/core/Circle.js deleted file mode 100644 index fbcfa17..0000000 --- a/test/unit/pixi-v2/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/core/Ellipse.js b/test/unit/pixi-v2/core/Ellipse.js deleted file mode 100644 index 026b56f..0000000 --- a/test/unit/pixi-v2/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/core/Matrix.js b/test/unit/pixi-v2/core/Matrix.js deleted file mode 100644 index da75e2e..0000000 --- a/test/unit/pixi-v2/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/core/Point.js b/test/unit/pixi-v2/core/Point.js deleted file mode 100644 index c4d5163..0000000 --- a/test/unit/pixi-v2/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/core/Polygon.js b/test/unit/pixi-v2/core/Polygon.js deleted file mode 100644 index dc8c918..0000000 --- a/test/unit/pixi-v2/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/core/Rectangle.js b/test/unit/pixi-v2/core/Rectangle.js deleted file mode 100644 index d43316e..0000000 --- a/test/unit/pixi-v2/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/display/DisplayObject.js b/test/unit/pixi-v2/display/DisplayObject.js deleted file mode 100644 index 044acf8..0000000 --- a/test/unit/pixi-v2/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/display/DisplayObjectContainer.js b/test/unit/pixi-v2/display/DisplayObjectContainer.js deleted file mode 100644 index 15a3376..0000000 --- a/test/unit/pixi-v2/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/display/MovieClip.js b/test/unit/pixi-v2/display/MovieClip.js deleted file mode 100644 index f3c6c6a..0000000 --- a/test/unit/pixi-v2/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/display/Sprite.js b/test/unit/pixi-v2/display/Sprite.js deleted file mode 100644 index 30c8076..0000000 --- a/test/unit/pixi-v2/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/display/Stage.js b/test/unit/pixi-v2/display/Stage.js deleted file mode 100644 index 6974c2e..0000000 --- a/test/unit/pixi-v2/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/package.json b/package.json index 6fc5290..ce76d2f 100644 --- a/package.json +++ b/package.json @@ -16,7 +16,7 @@ "url": "https://github.com/GoodBoyDigital/pixi.js.git" }, "scripts": { - "test": "gulp test", + "test": "gulp && testem ci", "docs": "jsdoc -c ./gulp/util/jsdoc.conf.json -R README.md" }, "dependencies": { @@ -45,16 +45,11 @@ "ink-docstrap": "git+https://github.com/Pilatch/docstrap.git", "jsdoc": "^3.3.0-alpha13", "jshint-summary": "^0.4.0", - "karma": "^0.12.28", - "karma-browserify": "^4.0.0", - "karma-chai": "^0.1.0", - "karma-firefox-launcher": "^0.1.0", - "karma-mocha": "^0.1.10", - "karma-spec-reporter": "^0.0.16", "minimist": "^1.1.1", "mocha": "^2.1.0", "require-dir": "^0.3.0", "run-sequence": "^1.0.2", + "testem": "^0.8.2", "vinyl-buffer": "^1.0.0", "vinyl-source-stream": "^1.1.0", "watchify": "^3.1.1" diff --git a/test/functional/example-1-basics/bunny.png b/test/functional/example-1-basics/bunny.png deleted file mode 100644 index 79c3167..0000000 --- a/test/functional/example-1-basics/bunny.png +++ /dev/null Binary files differ diff --git a/test/functional/example-1-basics/frame-30.png b/test/functional/example-1-basics/frame-30.png deleted file mode 100644 index 96e3409..0000000 --- a/test/functional/example-1-basics/frame-30.png +++ /dev/null Binary files differ diff --git a/test/functional/example-1-basics/frame-60.png b/test/functional/example-1-basics/frame-60.png deleted file mode 100644 index af3f4ce..0000000 --- a/test/functional/example-1-basics/frame-60.png +++ /dev/null Binary files differ diff --git a/test/functional/example-1-basics/frame-90.png b/test/functional/example-1-basics/frame-90.png deleted file mode 100644 index 099b823..0000000 --- a/test/functional/example-1-basics/frame-90.png +++ /dev/null Binary files differ diff --git a/test/functional/example-1-basics/index.js b/test/functional/example-1-basics/index.js deleted file mode 100644 index 2ad32bd..0000000 --- a/test/functional/example-1-basics/index.js +++ /dev/null @@ -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(''); - 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(''); - 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(''); - 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); - // }); - // }); -}); diff --git a/test/setup.js b/test/setup.js new file mode 100644 index 0000000..69e1b7a --- /dev/null +++ b/test/setup.js @@ -0,0 +1 @@ +expect = chai.expect; diff --git a/test/unit/bin/pixi.js b/test/unit/bin/pixi.js deleted file mode 100644 index 077cd88..0000000 --- a/test/unit/bin/pixi.js +++ /dev/null @@ -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'); - //}); -}); diff --git a/test/unit/core/utils/util.test.js b/test/unit/core/utils/util.test.js new file mode 100644 index 0000000..30c63f3 --- /dev/null +++ b/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'); + }); + }); +}); diff --git a/test/unit/index.test.js b/test/unit/index.test.js new file mode 100644 index 0000000..37e1d2a --- /dev/null +++ b/test/unit/index.test.js @@ -0,0 +1,6 @@ +describe('PIXI', function () { + it('exists', function () { + expect(PIXI) + .to.be.an('object'); + }); +}); diff --git a/test/unit/pixi-v2/InteractionManager.js b/test/unit/pixi-v2/InteractionManager.js deleted file mode 100644 index ed3001f..0000000 --- a/test/unit/pixi-v2/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/Pixi.js b/test/unit/pixi-v2/Pixi.js deleted file mode 100644 index 27debc1..0000000 --- a/test/unit/pixi-v2/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/core/Circle.js b/test/unit/pixi-v2/core/Circle.js deleted file mode 100644 index fbcfa17..0000000 --- a/test/unit/pixi-v2/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/core/Ellipse.js b/test/unit/pixi-v2/core/Ellipse.js deleted file mode 100644 index 026b56f..0000000 --- a/test/unit/pixi-v2/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/core/Matrix.js b/test/unit/pixi-v2/core/Matrix.js deleted file mode 100644 index da75e2e..0000000 --- a/test/unit/pixi-v2/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/core/Point.js b/test/unit/pixi-v2/core/Point.js deleted file mode 100644 index c4d5163..0000000 --- a/test/unit/pixi-v2/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/core/Polygon.js b/test/unit/pixi-v2/core/Polygon.js deleted file mode 100644 index dc8c918..0000000 --- a/test/unit/pixi-v2/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/core/Rectangle.js b/test/unit/pixi-v2/core/Rectangle.js deleted file mode 100644 index d43316e..0000000 --- a/test/unit/pixi-v2/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/display/DisplayObject.js b/test/unit/pixi-v2/display/DisplayObject.js deleted file mode 100644 index 044acf8..0000000 --- a/test/unit/pixi-v2/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/display/DisplayObjectContainer.js b/test/unit/pixi-v2/display/DisplayObjectContainer.js deleted file mode 100644 index 15a3376..0000000 --- a/test/unit/pixi-v2/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/display/MovieClip.js b/test/unit/pixi-v2/display/MovieClip.js deleted file mode 100644 index f3c6c6a..0000000 --- a/test/unit/pixi-v2/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/display/Sprite.js b/test/unit/pixi-v2/display/Sprite.js deleted file mode 100644 index 30c8076..0000000 --- a/test/unit/pixi-v2/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/display/Stage.js b/test/unit/pixi-v2/display/Stage.js deleted file mode 100644 index 6974c2e..0000000 --- a/test/unit/pixi-v2/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/extras/Rope.js b/test/unit/pixi-v2/extras/Rope.js deleted file mode 100644 index 05885ac..0000000 --- a/test/unit/pixi-v2/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/package.json b/package.json index 6fc5290..ce76d2f 100644 --- a/package.json +++ b/package.json @@ -16,7 +16,7 @@ "url": "https://github.com/GoodBoyDigital/pixi.js.git" }, "scripts": { - "test": "gulp test", + "test": "gulp && testem ci", "docs": "jsdoc -c ./gulp/util/jsdoc.conf.json -R README.md" }, "dependencies": { @@ -45,16 +45,11 @@ "ink-docstrap": "git+https://github.com/Pilatch/docstrap.git", "jsdoc": "^3.3.0-alpha13", "jshint-summary": "^0.4.0", - "karma": "^0.12.28", - "karma-browserify": "^4.0.0", - "karma-chai": "^0.1.0", - "karma-firefox-launcher": "^0.1.0", - "karma-mocha": "^0.1.10", - "karma-spec-reporter": "^0.0.16", "minimist": "^1.1.1", "mocha": "^2.1.0", "require-dir": "^0.3.0", "run-sequence": "^1.0.2", + "testem": "^0.8.2", "vinyl-buffer": "^1.0.0", "vinyl-source-stream": "^1.1.0", "watchify": "^3.1.1" diff --git a/test/functional/example-1-basics/bunny.png b/test/functional/example-1-basics/bunny.png deleted file mode 100644 index 79c3167..0000000 --- a/test/functional/example-1-basics/bunny.png +++ /dev/null Binary files differ diff --git a/test/functional/example-1-basics/frame-30.png b/test/functional/example-1-basics/frame-30.png deleted file mode 100644 index 96e3409..0000000 --- a/test/functional/example-1-basics/frame-30.png +++ /dev/null Binary files differ diff --git a/test/functional/example-1-basics/frame-60.png b/test/functional/example-1-basics/frame-60.png deleted file mode 100644 index af3f4ce..0000000 --- a/test/functional/example-1-basics/frame-60.png +++ /dev/null Binary files differ diff --git a/test/functional/example-1-basics/frame-90.png b/test/functional/example-1-basics/frame-90.png deleted file mode 100644 index 099b823..0000000 --- a/test/functional/example-1-basics/frame-90.png +++ /dev/null Binary files differ diff --git a/test/functional/example-1-basics/index.js b/test/functional/example-1-basics/index.js deleted file mode 100644 index 2ad32bd..0000000 --- a/test/functional/example-1-basics/index.js +++ /dev/null @@ -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(''); - 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(''); - 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(''); - 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); - // }); - // }); -}); diff --git a/test/setup.js b/test/setup.js new file mode 100644 index 0000000..69e1b7a --- /dev/null +++ b/test/setup.js @@ -0,0 +1 @@ +expect = chai.expect; diff --git a/test/unit/bin/pixi.js b/test/unit/bin/pixi.js deleted file mode 100644 index 077cd88..0000000 --- a/test/unit/bin/pixi.js +++ /dev/null @@ -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'); - //}); -}); diff --git a/test/unit/core/utils/util.test.js b/test/unit/core/utils/util.test.js new file mode 100644 index 0000000..30c63f3 --- /dev/null +++ b/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'); + }); + }); +}); diff --git a/test/unit/index.test.js b/test/unit/index.test.js new file mode 100644 index 0000000..37e1d2a --- /dev/null +++ b/test/unit/index.test.js @@ -0,0 +1,6 @@ +describe('PIXI', function () { + it('exists', function () { + expect(PIXI) + .to.be.an('object'); + }); +}); diff --git a/test/unit/pixi-v2/InteractionManager.js b/test/unit/pixi-v2/InteractionManager.js deleted file mode 100644 index ed3001f..0000000 --- a/test/unit/pixi-v2/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/Pixi.js b/test/unit/pixi-v2/Pixi.js deleted file mode 100644 index 27debc1..0000000 --- a/test/unit/pixi-v2/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/core/Circle.js b/test/unit/pixi-v2/core/Circle.js deleted file mode 100644 index fbcfa17..0000000 --- a/test/unit/pixi-v2/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/core/Ellipse.js b/test/unit/pixi-v2/core/Ellipse.js deleted file mode 100644 index 026b56f..0000000 --- a/test/unit/pixi-v2/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/core/Matrix.js b/test/unit/pixi-v2/core/Matrix.js deleted file mode 100644 index da75e2e..0000000 --- a/test/unit/pixi-v2/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/core/Point.js b/test/unit/pixi-v2/core/Point.js deleted file mode 100644 index c4d5163..0000000 --- a/test/unit/pixi-v2/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/core/Polygon.js b/test/unit/pixi-v2/core/Polygon.js deleted file mode 100644 index dc8c918..0000000 --- a/test/unit/pixi-v2/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/core/Rectangle.js b/test/unit/pixi-v2/core/Rectangle.js deleted file mode 100644 index d43316e..0000000 --- a/test/unit/pixi-v2/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/display/DisplayObject.js b/test/unit/pixi-v2/display/DisplayObject.js deleted file mode 100644 index 044acf8..0000000 --- a/test/unit/pixi-v2/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/display/DisplayObjectContainer.js b/test/unit/pixi-v2/display/DisplayObjectContainer.js deleted file mode 100644 index 15a3376..0000000 --- a/test/unit/pixi-v2/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/display/MovieClip.js b/test/unit/pixi-v2/display/MovieClip.js deleted file mode 100644 index f3c6c6a..0000000 --- a/test/unit/pixi-v2/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/display/Sprite.js b/test/unit/pixi-v2/display/Sprite.js deleted file mode 100644 index 30c8076..0000000 --- a/test/unit/pixi-v2/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/display/Stage.js b/test/unit/pixi-v2/display/Stage.js deleted file mode 100644 index 6974c2e..0000000 --- a/test/unit/pixi-v2/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/extras/Rope.js b/test/unit/pixi-v2/extras/Rope.js deleted file mode 100644 index 05885ac..0000000 --- a/test/unit/pixi-v2/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/extras/Spine.js b/test/unit/pixi-v2/extras/Spine.js deleted file mode 100644 index 0708bc0..0000000 --- a/test/unit/pixi-v2/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/package.json b/package.json index 6fc5290..ce76d2f 100644 --- a/package.json +++ b/package.json @@ -16,7 +16,7 @@ "url": "https://github.com/GoodBoyDigital/pixi.js.git" }, "scripts": { - "test": "gulp test", + "test": "gulp && testem ci", "docs": "jsdoc -c ./gulp/util/jsdoc.conf.json -R README.md" }, "dependencies": { @@ -45,16 +45,11 @@ "ink-docstrap": "git+https://github.com/Pilatch/docstrap.git", "jsdoc": "^3.3.0-alpha13", "jshint-summary": "^0.4.0", - "karma": "^0.12.28", - "karma-browserify": "^4.0.0", - "karma-chai": "^0.1.0", - "karma-firefox-launcher": "^0.1.0", - "karma-mocha": "^0.1.10", - "karma-spec-reporter": "^0.0.16", "minimist": "^1.1.1", "mocha": "^2.1.0", "require-dir": "^0.3.0", "run-sequence": "^1.0.2", + "testem": "^0.8.2", "vinyl-buffer": "^1.0.0", "vinyl-source-stream": "^1.1.0", "watchify": "^3.1.1" diff --git a/test/functional/example-1-basics/bunny.png b/test/functional/example-1-basics/bunny.png deleted file mode 100644 index 79c3167..0000000 --- a/test/functional/example-1-basics/bunny.png +++ /dev/null Binary files differ diff --git a/test/functional/example-1-basics/frame-30.png b/test/functional/example-1-basics/frame-30.png deleted file mode 100644 index 96e3409..0000000 --- a/test/functional/example-1-basics/frame-30.png +++ /dev/null Binary files differ diff --git a/test/functional/example-1-basics/frame-60.png b/test/functional/example-1-basics/frame-60.png deleted file mode 100644 index af3f4ce..0000000 --- a/test/functional/example-1-basics/frame-60.png +++ /dev/null Binary files differ diff --git a/test/functional/example-1-basics/frame-90.png b/test/functional/example-1-basics/frame-90.png deleted file mode 100644 index 099b823..0000000 --- a/test/functional/example-1-basics/frame-90.png +++ /dev/null Binary files differ diff --git a/test/functional/example-1-basics/index.js b/test/functional/example-1-basics/index.js deleted file mode 100644 index 2ad32bd..0000000 --- a/test/functional/example-1-basics/index.js +++ /dev/null @@ -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(''); - 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(''); - 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(''); - 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); - // }); - // }); -}); diff --git a/test/setup.js b/test/setup.js new file mode 100644 index 0000000..69e1b7a --- /dev/null +++ b/test/setup.js @@ -0,0 +1 @@ +expect = chai.expect; diff --git a/test/unit/bin/pixi.js b/test/unit/bin/pixi.js deleted file mode 100644 index 077cd88..0000000 --- a/test/unit/bin/pixi.js +++ /dev/null @@ -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'); - //}); -}); diff --git a/test/unit/core/utils/util.test.js b/test/unit/core/utils/util.test.js new file mode 100644 index 0000000..30c63f3 --- /dev/null +++ b/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'); + }); + }); +}); diff --git a/test/unit/index.test.js b/test/unit/index.test.js new file mode 100644 index 0000000..37e1d2a --- /dev/null +++ b/test/unit/index.test.js @@ -0,0 +1,6 @@ +describe('PIXI', function () { + it('exists', function () { + expect(PIXI) + .to.be.an('object'); + }); +}); diff --git a/test/unit/pixi-v2/InteractionManager.js b/test/unit/pixi-v2/InteractionManager.js deleted file mode 100644 index ed3001f..0000000 --- a/test/unit/pixi-v2/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/Pixi.js b/test/unit/pixi-v2/Pixi.js deleted file mode 100644 index 27debc1..0000000 --- a/test/unit/pixi-v2/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/core/Circle.js b/test/unit/pixi-v2/core/Circle.js deleted file mode 100644 index fbcfa17..0000000 --- a/test/unit/pixi-v2/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/core/Ellipse.js b/test/unit/pixi-v2/core/Ellipse.js deleted file mode 100644 index 026b56f..0000000 --- a/test/unit/pixi-v2/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/core/Matrix.js b/test/unit/pixi-v2/core/Matrix.js deleted file mode 100644 index da75e2e..0000000 --- a/test/unit/pixi-v2/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/core/Point.js b/test/unit/pixi-v2/core/Point.js deleted file mode 100644 index c4d5163..0000000 --- a/test/unit/pixi-v2/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/core/Polygon.js b/test/unit/pixi-v2/core/Polygon.js deleted file mode 100644 index dc8c918..0000000 --- a/test/unit/pixi-v2/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/core/Rectangle.js b/test/unit/pixi-v2/core/Rectangle.js deleted file mode 100644 index d43316e..0000000 --- a/test/unit/pixi-v2/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/display/DisplayObject.js b/test/unit/pixi-v2/display/DisplayObject.js deleted file mode 100644 index 044acf8..0000000 --- a/test/unit/pixi-v2/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/display/DisplayObjectContainer.js b/test/unit/pixi-v2/display/DisplayObjectContainer.js deleted file mode 100644 index 15a3376..0000000 --- a/test/unit/pixi-v2/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/display/MovieClip.js b/test/unit/pixi-v2/display/MovieClip.js deleted file mode 100644 index f3c6c6a..0000000 --- a/test/unit/pixi-v2/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/display/Sprite.js b/test/unit/pixi-v2/display/Sprite.js deleted file mode 100644 index 30c8076..0000000 --- a/test/unit/pixi-v2/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/display/Stage.js b/test/unit/pixi-v2/display/Stage.js deleted file mode 100644 index 6974c2e..0000000 --- a/test/unit/pixi-v2/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/extras/Rope.js b/test/unit/pixi-v2/extras/Rope.js deleted file mode 100644 index 05885ac..0000000 --- a/test/unit/pixi-v2/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/extras/Spine.js b/test/unit/pixi-v2/extras/Spine.js deleted file mode 100644 index 0708bc0..0000000 --- a/test/unit/pixi-v2/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/extras/Strip.js b/test/unit/pixi-v2/extras/Strip.js deleted file mode 100644 index 230af90..0000000 --- a/test/unit/pixi-v2/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/package.json b/package.json index 6fc5290..ce76d2f 100644 --- a/package.json +++ b/package.json @@ -16,7 +16,7 @@ "url": "https://github.com/GoodBoyDigital/pixi.js.git" }, "scripts": { - "test": "gulp test", + "test": "gulp && testem ci", "docs": "jsdoc -c ./gulp/util/jsdoc.conf.json -R README.md" }, "dependencies": { @@ -45,16 +45,11 @@ "ink-docstrap": "git+https://github.com/Pilatch/docstrap.git", "jsdoc": "^3.3.0-alpha13", "jshint-summary": "^0.4.0", - "karma": "^0.12.28", - "karma-browserify": "^4.0.0", - "karma-chai": "^0.1.0", - "karma-firefox-launcher": "^0.1.0", - "karma-mocha": "^0.1.10", - "karma-spec-reporter": "^0.0.16", "minimist": "^1.1.1", "mocha": "^2.1.0", "require-dir": "^0.3.0", "run-sequence": "^1.0.2", + "testem": "^0.8.2", "vinyl-buffer": "^1.0.0", "vinyl-source-stream": "^1.1.0", "watchify": "^3.1.1" diff --git a/test/functional/example-1-basics/bunny.png b/test/functional/example-1-basics/bunny.png deleted file mode 100644 index 79c3167..0000000 --- a/test/functional/example-1-basics/bunny.png +++ /dev/null Binary files differ diff --git a/test/functional/example-1-basics/frame-30.png b/test/functional/example-1-basics/frame-30.png deleted file mode 100644 index 96e3409..0000000 --- a/test/functional/example-1-basics/frame-30.png +++ /dev/null Binary files differ diff --git a/test/functional/example-1-basics/frame-60.png b/test/functional/example-1-basics/frame-60.png deleted file mode 100644 index af3f4ce..0000000 --- a/test/functional/example-1-basics/frame-60.png +++ /dev/null Binary files differ diff --git a/test/functional/example-1-basics/frame-90.png b/test/functional/example-1-basics/frame-90.png deleted file mode 100644 index 099b823..0000000 --- a/test/functional/example-1-basics/frame-90.png +++ /dev/null Binary files differ diff --git a/test/functional/example-1-basics/index.js b/test/functional/example-1-basics/index.js deleted file mode 100644 index 2ad32bd..0000000 --- a/test/functional/example-1-basics/index.js +++ /dev/null @@ -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(''); - 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(''); - 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(''); - 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); - // }); - // }); -}); diff --git a/test/setup.js b/test/setup.js new file mode 100644 index 0000000..69e1b7a --- /dev/null +++ b/test/setup.js @@ -0,0 +1 @@ +expect = chai.expect; diff --git a/test/unit/bin/pixi.js b/test/unit/bin/pixi.js deleted file mode 100644 index 077cd88..0000000 --- a/test/unit/bin/pixi.js +++ /dev/null @@ -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'); - //}); -}); diff --git a/test/unit/core/utils/util.test.js b/test/unit/core/utils/util.test.js new file mode 100644 index 0000000..30c63f3 --- /dev/null +++ b/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'); + }); + }); +}); diff --git a/test/unit/index.test.js b/test/unit/index.test.js new file mode 100644 index 0000000..37e1d2a --- /dev/null +++ b/test/unit/index.test.js @@ -0,0 +1,6 @@ +describe('PIXI', function () { + it('exists', function () { + expect(PIXI) + .to.be.an('object'); + }); +}); diff --git a/test/unit/pixi-v2/InteractionManager.js b/test/unit/pixi-v2/InteractionManager.js deleted file mode 100644 index ed3001f..0000000 --- a/test/unit/pixi-v2/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/Pixi.js b/test/unit/pixi-v2/Pixi.js deleted file mode 100644 index 27debc1..0000000 --- a/test/unit/pixi-v2/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/core/Circle.js b/test/unit/pixi-v2/core/Circle.js deleted file mode 100644 index fbcfa17..0000000 --- a/test/unit/pixi-v2/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/core/Ellipse.js b/test/unit/pixi-v2/core/Ellipse.js deleted file mode 100644 index 026b56f..0000000 --- a/test/unit/pixi-v2/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/core/Matrix.js b/test/unit/pixi-v2/core/Matrix.js deleted file mode 100644 index da75e2e..0000000 --- a/test/unit/pixi-v2/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/core/Point.js b/test/unit/pixi-v2/core/Point.js deleted file mode 100644 index c4d5163..0000000 --- a/test/unit/pixi-v2/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/core/Polygon.js b/test/unit/pixi-v2/core/Polygon.js deleted file mode 100644 index dc8c918..0000000 --- a/test/unit/pixi-v2/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/core/Rectangle.js b/test/unit/pixi-v2/core/Rectangle.js deleted file mode 100644 index d43316e..0000000 --- a/test/unit/pixi-v2/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/display/DisplayObject.js b/test/unit/pixi-v2/display/DisplayObject.js deleted file mode 100644 index 044acf8..0000000 --- a/test/unit/pixi-v2/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/display/DisplayObjectContainer.js b/test/unit/pixi-v2/display/DisplayObjectContainer.js deleted file mode 100644 index 15a3376..0000000 --- a/test/unit/pixi-v2/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/display/MovieClip.js b/test/unit/pixi-v2/display/MovieClip.js deleted file mode 100644 index f3c6c6a..0000000 --- a/test/unit/pixi-v2/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/display/Sprite.js b/test/unit/pixi-v2/display/Sprite.js deleted file mode 100644 index 30c8076..0000000 --- a/test/unit/pixi-v2/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/display/Stage.js b/test/unit/pixi-v2/display/Stage.js deleted file mode 100644 index 6974c2e..0000000 --- a/test/unit/pixi-v2/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/extras/Rope.js b/test/unit/pixi-v2/extras/Rope.js deleted file mode 100644 index 05885ac..0000000 --- a/test/unit/pixi-v2/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/extras/Spine.js b/test/unit/pixi-v2/extras/Spine.js deleted file mode 100644 index 0708bc0..0000000 --- a/test/unit/pixi-v2/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/extras/Strip.js b/test/unit/pixi-v2/extras/Strip.js deleted file mode 100644 index 230af90..0000000 --- a/test/unit/pixi-v2/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/extras/TilingSprite.js b/test/unit/pixi-v2/extras/TilingSprite.js deleted file mode 100644 index 56aea14..0000000 --- a/test/unit/pixi-v2/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/package.json b/package.json index 6fc5290..ce76d2f 100644 --- a/package.json +++ b/package.json @@ -16,7 +16,7 @@ "url": "https://github.com/GoodBoyDigital/pixi.js.git" }, "scripts": { - "test": "gulp test", + "test": "gulp && testem ci", "docs": "jsdoc -c ./gulp/util/jsdoc.conf.json -R README.md" }, "dependencies": { @@ -45,16 +45,11 @@ "ink-docstrap": "git+https://github.com/Pilatch/docstrap.git", "jsdoc": "^3.3.0-alpha13", "jshint-summary": "^0.4.0", - "karma": "^0.12.28", - "karma-browserify": "^4.0.0", - "karma-chai": "^0.1.0", - "karma-firefox-launcher": "^0.1.0", - "karma-mocha": "^0.1.10", - "karma-spec-reporter": "^0.0.16", "minimist": "^1.1.1", "mocha": "^2.1.0", "require-dir": "^0.3.0", "run-sequence": "^1.0.2", + "testem": "^0.8.2", "vinyl-buffer": "^1.0.0", "vinyl-source-stream": "^1.1.0", "watchify": "^3.1.1" diff --git a/test/functional/example-1-basics/bunny.png b/test/functional/example-1-basics/bunny.png deleted file mode 100644 index 79c3167..0000000 --- a/test/functional/example-1-basics/bunny.png +++ /dev/null Binary files differ diff --git a/test/functional/example-1-basics/frame-30.png b/test/functional/example-1-basics/frame-30.png deleted file mode 100644 index 96e3409..0000000 --- a/test/functional/example-1-basics/frame-30.png +++ /dev/null Binary files differ diff --git a/test/functional/example-1-basics/frame-60.png b/test/functional/example-1-basics/frame-60.png deleted file mode 100644 index af3f4ce..0000000 --- a/test/functional/example-1-basics/frame-60.png +++ /dev/null Binary files differ diff --git a/test/functional/example-1-basics/frame-90.png b/test/functional/example-1-basics/frame-90.png deleted file mode 100644 index 099b823..0000000 --- a/test/functional/example-1-basics/frame-90.png +++ /dev/null Binary files differ diff --git a/test/functional/example-1-basics/index.js b/test/functional/example-1-basics/index.js deleted file mode 100644 index 2ad32bd..0000000 --- a/test/functional/example-1-basics/index.js +++ /dev/null @@ -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(''); - 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(''); - 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(''); - 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); - // }); - // }); -}); diff --git a/test/setup.js b/test/setup.js new file mode 100644 index 0000000..69e1b7a --- /dev/null +++ b/test/setup.js @@ -0,0 +1 @@ +expect = chai.expect; diff --git a/test/unit/bin/pixi.js b/test/unit/bin/pixi.js deleted file mode 100644 index 077cd88..0000000 --- a/test/unit/bin/pixi.js +++ /dev/null @@ -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'); - //}); -}); diff --git a/test/unit/core/utils/util.test.js b/test/unit/core/utils/util.test.js new file mode 100644 index 0000000..30c63f3 --- /dev/null +++ b/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'); + }); + }); +}); diff --git a/test/unit/index.test.js b/test/unit/index.test.js new file mode 100644 index 0000000..37e1d2a --- /dev/null +++ b/test/unit/index.test.js @@ -0,0 +1,6 @@ +describe('PIXI', function () { + it('exists', function () { + expect(PIXI) + .to.be.an('object'); + }); +}); diff --git a/test/unit/pixi-v2/InteractionManager.js b/test/unit/pixi-v2/InteractionManager.js deleted file mode 100644 index ed3001f..0000000 --- a/test/unit/pixi-v2/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/Pixi.js b/test/unit/pixi-v2/Pixi.js deleted file mode 100644 index 27debc1..0000000 --- a/test/unit/pixi-v2/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/core/Circle.js b/test/unit/pixi-v2/core/Circle.js deleted file mode 100644 index fbcfa17..0000000 --- a/test/unit/pixi-v2/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/core/Ellipse.js b/test/unit/pixi-v2/core/Ellipse.js deleted file mode 100644 index 026b56f..0000000 --- a/test/unit/pixi-v2/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/core/Matrix.js b/test/unit/pixi-v2/core/Matrix.js deleted file mode 100644 index da75e2e..0000000 --- a/test/unit/pixi-v2/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/core/Point.js b/test/unit/pixi-v2/core/Point.js deleted file mode 100644 index c4d5163..0000000 --- a/test/unit/pixi-v2/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/core/Polygon.js b/test/unit/pixi-v2/core/Polygon.js deleted file mode 100644 index dc8c918..0000000 --- a/test/unit/pixi-v2/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/core/Rectangle.js b/test/unit/pixi-v2/core/Rectangle.js deleted file mode 100644 index d43316e..0000000 --- a/test/unit/pixi-v2/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/display/DisplayObject.js b/test/unit/pixi-v2/display/DisplayObject.js deleted file mode 100644 index 044acf8..0000000 --- a/test/unit/pixi-v2/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/display/DisplayObjectContainer.js b/test/unit/pixi-v2/display/DisplayObjectContainer.js deleted file mode 100644 index 15a3376..0000000 --- a/test/unit/pixi-v2/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/display/MovieClip.js b/test/unit/pixi-v2/display/MovieClip.js deleted file mode 100644 index f3c6c6a..0000000 --- a/test/unit/pixi-v2/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/display/Sprite.js b/test/unit/pixi-v2/display/Sprite.js deleted file mode 100644 index 30c8076..0000000 --- a/test/unit/pixi-v2/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/display/Stage.js b/test/unit/pixi-v2/display/Stage.js deleted file mode 100644 index 6974c2e..0000000 --- a/test/unit/pixi-v2/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/extras/Rope.js b/test/unit/pixi-v2/extras/Rope.js deleted file mode 100644 index 05885ac..0000000 --- a/test/unit/pixi-v2/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/extras/Spine.js b/test/unit/pixi-v2/extras/Spine.js deleted file mode 100644 index 0708bc0..0000000 --- a/test/unit/pixi-v2/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/extras/Strip.js b/test/unit/pixi-v2/extras/Strip.js deleted file mode 100644 index 230af90..0000000 --- a/test/unit/pixi-v2/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/extras/TilingSprite.js b/test/unit/pixi-v2/extras/TilingSprite.js deleted file mode 100644 index 56aea14..0000000 --- a/test/unit/pixi-v2/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/filters/FilterBlock.js b/test/unit/pixi-v2/filters/FilterBlock.js deleted file mode 100644 index 870cec0..0000000 --- a/test/unit/pixi-v2/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/package.json b/package.json index 6fc5290..ce76d2f 100644 --- a/package.json +++ b/package.json @@ -16,7 +16,7 @@ "url": "https://github.com/GoodBoyDigital/pixi.js.git" }, "scripts": { - "test": "gulp test", + "test": "gulp && testem ci", "docs": "jsdoc -c ./gulp/util/jsdoc.conf.json -R README.md" }, "dependencies": { @@ -45,16 +45,11 @@ "ink-docstrap": "git+https://github.com/Pilatch/docstrap.git", "jsdoc": "^3.3.0-alpha13", "jshint-summary": "^0.4.0", - "karma": "^0.12.28", - "karma-browserify": "^4.0.0", - "karma-chai": "^0.1.0", - "karma-firefox-launcher": "^0.1.0", - "karma-mocha": "^0.1.10", - "karma-spec-reporter": "^0.0.16", "minimist": "^1.1.1", "mocha": "^2.1.0", "require-dir": "^0.3.0", "run-sequence": "^1.0.2", + "testem": "^0.8.2", "vinyl-buffer": "^1.0.0", "vinyl-source-stream": "^1.1.0", "watchify": "^3.1.1" diff --git a/test/functional/example-1-basics/bunny.png b/test/functional/example-1-basics/bunny.png deleted file mode 100644 index 79c3167..0000000 --- a/test/functional/example-1-basics/bunny.png +++ /dev/null Binary files differ diff --git a/test/functional/example-1-basics/frame-30.png b/test/functional/example-1-basics/frame-30.png deleted file mode 100644 index 96e3409..0000000 --- a/test/functional/example-1-basics/frame-30.png +++ /dev/null Binary files differ diff --git a/test/functional/example-1-basics/frame-60.png b/test/functional/example-1-basics/frame-60.png deleted file mode 100644 index af3f4ce..0000000 --- a/test/functional/example-1-basics/frame-60.png +++ /dev/null Binary files differ diff --git a/test/functional/example-1-basics/frame-90.png b/test/functional/example-1-basics/frame-90.png deleted file mode 100644 index 099b823..0000000 --- a/test/functional/example-1-basics/frame-90.png +++ /dev/null Binary files differ diff --git a/test/functional/example-1-basics/index.js b/test/functional/example-1-basics/index.js deleted file mode 100644 index 2ad32bd..0000000 --- a/test/functional/example-1-basics/index.js +++ /dev/null @@ -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(''); - 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(''); - 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(''); - 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); - // }); - // }); -}); diff --git a/test/setup.js b/test/setup.js new file mode 100644 index 0000000..69e1b7a --- /dev/null +++ b/test/setup.js @@ -0,0 +1 @@ +expect = chai.expect; diff --git a/test/unit/bin/pixi.js b/test/unit/bin/pixi.js deleted file mode 100644 index 077cd88..0000000 --- a/test/unit/bin/pixi.js +++ /dev/null @@ -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'); - //}); -}); diff --git a/test/unit/core/utils/util.test.js b/test/unit/core/utils/util.test.js new file mode 100644 index 0000000..30c63f3 --- /dev/null +++ b/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'); + }); + }); +}); diff --git a/test/unit/index.test.js b/test/unit/index.test.js new file mode 100644 index 0000000..37e1d2a --- /dev/null +++ b/test/unit/index.test.js @@ -0,0 +1,6 @@ +describe('PIXI', function () { + it('exists', function () { + expect(PIXI) + .to.be.an('object'); + }); +}); diff --git a/test/unit/pixi-v2/InteractionManager.js b/test/unit/pixi-v2/InteractionManager.js deleted file mode 100644 index ed3001f..0000000 --- a/test/unit/pixi-v2/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/Pixi.js b/test/unit/pixi-v2/Pixi.js deleted file mode 100644 index 27debc1..0000000 --- a/test/unit/pixi-v2/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/core/Circle.js b/test/unit/pixi-v2/core/Circle.js deleted file mode 100644 index fbcfa17..0000000 --- a/test/unit/pixi-v2/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/core/Ellipse.js b/test/unit/pixi-v2/core/Ellipse.js deleted file mode 100644 index 026b56f..0000000 --- a/test/unit/pixi-v2/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/core/Matrix.js b/test/unit/pixi-v2/core/Matrix.js deleted file mode 100644 index da75e2e..0000000 --- a/test/unit/pixi-v2/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/core/Point.js b/test/unit/pixi-v2/core/Point.js deleted file mode 100644 index c4d5163..0000000 --- a/test/unit/pixi-v2/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/core/Polygon.js b/test/unit/pixi-v2/core/Polygon.js deleted file mode 100644 index dc8c918..0000000 --- a/test/unit/pixi-v2/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/core/Rectangle.js b/test/unit/pixi-v2/core/Rectangle.js deleted file mode 100644 index d43316e..0000000 --- a/test/unit/pixi-v2/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/display/DisplayObject.js b/test/unit/pixi-v2/display/DisplayObject.js deleted file mode 100644 index 044acf8..0000000 --- a/test/unit/pixi-v2/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/display/DisplayObjectContainer.js b/test/unit/pixi-v2/display/DisplayObjectContainer.js deleted file mode 100644 index 15a3376..0000000 --- a/test/unit/pixi-v2/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/display/MovieClip.js b/test/unit/pixi-v2/display/MovieClip.js deleted file mode 100644 index f3c6c6a..0000000 --- a/test/unit/pixi-v2/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/display/Sprite.js b/test/unit/pixi-v2/display/Sprite.js deleted file mode 100644 index 30c8076..0000000 --- a/test/unit/pixi-v2/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/display/Stage.js b/test/unit/pixi-v2/display/Stage.js deleted file mode 100644 index 6974c2e..0000000 --- a/test/unit/pixi-v2/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/extras/Rope.js b/test/unit/pixi-v2/extras/Rope.js deleted file mode 100644 index 05885ac..0000000 --- a/test/unit/pixi-v2/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/extras/Spine.js b/test/unit/pixi-v2/extras/Spine.js deleted file mode 100644 index 0708bc0..0000000 --- a/test/unit/pixi-v2/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/extras/Strip.js b/test/unit/pixi-v2/extras/Strip.js deleted file mode 100644 index 230af90..0000000 --- a/test/unit/pixi-v2/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/extras/TilingSprite.js b/test/unit/pixi-v2/extras/TilingSprite.js deleted file mode 100644 index 56aea14..0000000 --- a/test/unit/pixi-v2/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/filters/FilterBlock.js b/test/unit/pixi-v2/filters/FilterBlock.js deleted file mode 100644 index 870cec0..0000000 --- a/test/unit/pixi-v2/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/loaders/AssetLoader.js b/test/unit/pixi-v2/loaders/AssetLoader.js deleted file mode 100644 index a0aa0b5..0000000 --- a/test/unit/pixi-v2/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/package.json b/package.json index 6fc5290..ce76d2f 100644 --- a/package.json +++ b/package.json @@ -16,7 +16,7 @@ "url": "https://github.com/GoodBoyDigital/pixi.js.git" }, "scripts": { - "test": "gulp test", + "test": "gulp && testem ci", "docs": "jsdoc -c ./gulp/util/jsdoc.conf.json -R README.md" }, "dependencies": { @@ -45,16 +45,11 @@ "ink-docstrap": "git+https://github.com/Pilatch/docstrap.git", "jsdoc": "^3.3.0-alpha13", "jshint-summary": "^0.4.0", - "karma": "^0.12.28", - "karma-browserify": "^4.0.0", - "karma-chai": "^0.1.0", - "karma-firefox-launcher": "^0.1.0", - "karma-mocha": "^0.1.10", - "karma-spec-reporter": "^0.0.16", "minimist": "^1.1.1", "mocha": "^2.1.0", "require-dir": "^0.3.0", "run-sequence": "^1.0.2", + "testem": "^0.8.2", "vinyl-buffer": "^1.0.0", "vinyl-source-stream": "^1.1.0", "watchify": "^3.1.1" diff --git a/test/functional/example-1-basics/bunny.png b/test/functional/example-1-basics/bunny.png deleted file mode 100644 index 79c3167..0000000 --- a/test/functional/example-1-basics/bunny.png +++ /dev/null Binary files differ diff --git a/test/functional/example-1-basics/frame-30.png b/test/functional/example-1-basics/frame-30.png deleted file mode 100644 index 96e3409..0000000 --- a/test/functional/example-1-basics/frame-30.png +++ /dev/null Binary files differ diff --git a/test/functional/example-1-basics/frame-60.png b/test/functional/example-1-basics/frame-60.png deleted file mode 100644 index af3f4ce..0000000 --- a/test/functional/example-1-basics/frame-60.png +++ /dev/null Binary files differ diff --git a/test/functional/example-1-basics/frame-90.png b/test/functional/example-1-basics/frame-90.png deleted file mode 100644 index 099b823..0000000 --- a/test/functional/example-1-basics/frame-90.png +++ /dev/null Binary files differ diff --git a/test/functional/example-1-basics/index.js b/test/functional/example-1-basics/index.js deleted file mode 100644 index 2ad32bd..0000000 --- a/test/functional/example-1-basics/index.js +++ /dev/null @@ -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(''); - 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(''); - 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(''); - 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); - // }); - // }); -}); diff --git a/test/setup.js b/test/setup.js new file mode 100644 index 0000000..69e1b7a --- /dev/null +++ b/test/setup.js @@ -0,0 +1 @@ +expect = chai.expect; diff --git a/test/unit/bin/pixi.js b/test/unit/bin/pixi.js deleted file mode 100644 index 077cd88..0000000 --- a/test/unit/bin/pixi.js +++ /dev/null @@ -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'); - //}); -}); diff --git a/test/unit/core/utils/util.test.js b/test/unit/core/utils/util.test.js new file mode 100644 index 0000000..30c63f3 --- /dev/null +++ b/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'); + }); + }); +}); diff --git a/test/unit/index.test.js b/test/unit/index.test.js new file mode 100644 index 0000000..37e1d2a --- /dev/null +++ b/test/unit/index.test.js @@ -0,0 +1,6 @@ +describe('PIXI', function () { + it('exists', function () { + expect(PIXI) + .to.be.an('object'); + }); +}); diff --git a/test/unit/pixi-v2/InteractionManager.js b/test/unit/pixi-v2/InteractionManager.js deleted file mode 100644 index ed3001f..0000000 --- a/test/unit/pixi-v2/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/Pixi.js b/test/unit/pixi-v2/Pixi.js deleted file mode 100644 index 27debc1..0000000 --- a/test/unit/pixi-v2/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/core/Circle.js b/test/unit/pixi-v2/core/Circle.js deleted file mode 100644 index fbcfa17..0000000 --- a/test/unit/pixi-v2/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/core/Ellipse.js b/test/unit/pixi-v2/core/Ellipse.js deleted file mode 100644 index 026b56f..0000000 --- a/test/unit/pixi-v2/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/core/Matrix.js b/test/unit/pixi-v2/core/Matrix.js deleted file mode 100644 index da75e2e..0000000 --- a/test/unit/pixi-v2/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/core/Point.js b/test/unit/pixi-v2/core/Point.js deleted file mode 100644 index c4d5163..0000000 --- a/test/unit/pixi-v2/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/core/Polygon.js b/test/unit/pixi-v2/core/Polygon.js deleted file mode 100644 index dc8c918..0000000 --- a/test/unit/pixi-v2/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/core/Rectangle.js b/test/unit/pixi-v2/core/Rectangle.js deleted file mode 100644 index d43316e..0000000 --- a/test/unit/pixi-v2/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/display/DisplayObject.js b/test/unit/pixi-v2/display/DisplayObject.js deleted file mode 100644 index 044acf8..0000000 --- a/test/unit/pixi-v2/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/display/DisplayObjectContainer.js b/test/unit/pixi-v2/display/DisplayObjectContainer.js deleted file mode 100644 index 15a3376..0000000 --- a/test/unit/pixi-v2/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/display/MovieClip.js b/test/unit/pixi-v2/display/MovieClip.js deleted file mode 100644 index f3c6c6a..0000000 --- a/test/unit/pixi-v2/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/display/Sprite.js b/test/unit/pixi-v2/display/Sprite.js deleted file mode 100644 index 30c8076..0000000 --- a/test/unit/pixi-v2/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/display/Stage.js b/test/unit/pixi-v2/display/Stage.js deleted file mode 100644 index 6974c2e..0000000 --- a/test/unit/pixi-v2/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/extras/Rope.js b/test/unit/pixi-v2/extras/Rope.js deleted file mode 100644 index 05885ac..0000000 --- a/test/unit/pixi-v2/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/extras/Spine.js b/test/unit/pixi-v2/extras/Spine.js deleted file mode 100644 index 0708bc0..0000000 --- a/test/unit/pixi-v2/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/extras/Strip.js b/test/unit/pixi-v2/extras/Strip.js deleted file mode 100644 index 230af90..0000000 --- a/test/unit/pixi-v2/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/extras/TilingSprite.js b/test/unit/pixi-v2/extras/TilingSprite.js deleted file mode 100644 index 56aea14..0000000 --- a/test/unit/pixi-v2/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/filters/FilterBlock.js b/test/unit/pixi-v2/filters/FilterBlock.js deleted file mode 100644 index 870cec0..0000000 --- a/test/unit/pixi-v2/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/loaders/AssetLoader.js b/test/unit/pixi-v2/loaders/AssetLoader.js deleted file mode 100644 index a0aa0b5..0000000 --- a/test/unit/pixi-v2/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/loaders/BitmapFontLoader.js b/test/unit/pixi-v2/loaders/BitmapFontLoader.js deleted file mode 100644 index 046f018..0000000 --- a/test/unit/pixi-v2/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/package.json b/package.json index 6fc5290..ce76d2f 100644 --- a/package.json +++ b/package.json @@ -16,7 +16,7 @@ "url": "https://github.com/GoodBoyDigital/pixi.js.git" }, "scripts": { - "test": "gulp test", + "test": "gulp && testem ci", "docs": "jsdoc -c ./gulp/util/jsdoc.conf.json -R README.md" }, "dependencies": { @@ -45,16 +45,11 @@ "ink-docstrap": "git+https://github.com/Pilatch/docstrap.git", "jsdoc": "^3.3.0-alpha13", "jshint-summary": "^0.4.0", - "karma": "^0.12.28", - "karma-browserify": "^4.0.0", - "karma-chai": "^0.1.0", - "karma-firefox-launcher": "^0.1.0", - "karma-mocha": "^0.1.10", - "karma-spec-reporter": "^0.0.16", "minimist": "^1.1.1", "mocha": "^2.1.0", "require-dir": "^0.3.0", "run-sequence": "^1.0.2", + "testem": "^0.8.2", "vinyl-buffer": "^1.0.0", "vinyl-source-stream": "^1.1.0", "watchify": "^3.1.1" diff --git a/test/functional/example-1-basics/bunny.png b/test/functional/example-1-basics/bunny.png deleted file mode 100644 index 79c3167..0000000 --- a/test/functional/example-1-basics/bunny.png +++ /dev/null Binary files differ diff --git a/test/functional/example-1-basics/frame-30.png b/test/functional/example-1-basics/frame-30.png deleted file mode 100644 index 96e3409..0000000 --- a/test/functional/example-1-basics/frame-30.png +++ /dev/null Binary files differ diff --git a/test/functional/example-1-basics/frame-60.png b/test/functional/example-1-basics/frame-60.png deleted file mode 100644 index af3f4ce..0000000 --- a/test/functional/example-1-basics/frame-60.png +++ /dev/null Binary files differ diff --git a/test/functional/example-1-basics/frame-90.png b/test/functional/example-1-basics/frame-90.png deleted file mode 100644 index 099b823..0000000 --- a/test/functional/example-1-basics/frame-90.png +++ /dev/null Binary files differ diff --git a/test/functional/example-1-basics/index.js b/test/functional/example-1-basics/index.js deleted file mode 100644 index 2ad32bd..0000000 --- a/test/functional/example-1-basics/index.js +++ /dev/null @@ -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(''); - 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(''); - 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(''); - 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); - // }); - // }); -}); diff --git a/test/setup.js b/test/setup.js new file mode 100644 index 0000000..69e1b7a --- /dev/null +++ b/test/setup.js @@ -0,0 +1 @@ +expect = chai.expect; diff --git a/test/unit/bin/pixi.js b/test/unit/bin/pixi.js deleted file mode 100644 index 077cd88..0000000 --- a/test/unit/bin/pixi.js +++ /dev/null @@ -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'); - //}); -}); diff --git a/test/unit/core/utils/util.test.js b/test/unit/core/utils/util.test.js new file mode 100644 index 0000000..30c63f3 --- /dev/null +++ b/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'); + }); + }); +}); diff --git a/test/unit/index.test.js b/test/unit/index.test.js new file mode 100644 index 0000000..37e1d2a --- /dev/null +++ b/test/unit/index.test.js @@ -0,0 +1,6 @@ +describe('PIXI', function () { + it('exists', function () { + expect(PIXI) + .to.be.an('object'); + }); +}); diff --git a/test/unit/pixi-v2/InteractionManager.js b/test/unit/pixi-v2/InteractionManager.js deleted file mode 100644 index ed3001f..0000000 --- a/test/unit/pixi-v2/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/Pixi.js b/test/unit/pixi-v2/Pixi.js deleted file mode 100644 index 27debc1..0000000 --- a/test/unit/pixi-v2/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/core/Circle.js b/test/unit/pixi-v2/core/Circle.js deleted file mode 100644 index fbcfa17..0000000 --- a/test/unit/pixi-v2/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/core/Ellipse.js b/test/unit/pixi-v2/core/Ellipse.js deleted file mode 100644 index 026b56f..0000000 --- a/test/unit/pixi-v2/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/core/Matrix.js b/test/unit/pixi-v2/core/Matrix.js deleted file mode 100644 index da75e2e..0000000 --- a/test/unit/pixi-v2/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/core/Point.js b/test/unit/pixi-v2/core/Point.js deleted file mode 100644 index c4d5163..0000000 --- a/test/unit/pixi-v2/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/core/Polygon.js b/test/unit/pixi-v2/core/Polygon.js deleted file mode 100644 index dc8c918..0000000 --- a/test/unit/pixi-v2/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/core/Rectangle.js b/test/unit/pixi-v2/core/Rectangle.js deleted file mode 100644 index d43316e..0000000 --- a/test/unit/pixi-v2/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/display/DisplayObject.js b/test/unit/pixi-v2/display/DisplayObject.js deleted file mode 100644 index 044acf8..0000000 --- a/test/unit/pixi-v2/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/display/DisplayObjectContainer.js b/test/unit/pixi-v2/display/DisplayObjectContainer.js deleted file mode 100644 index 15a3376..0000000 --- a/test/unit/pixi-v2/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/display/MovieClip.js b/test/unit/pixi-v2/display/MovieClip.js deleted file mode 100644 index f3c6c6a..0000000 --- a/test/unit/pixi-v2/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/display/Sprite.js b/test/unit/pixi-v2/display/Sprite.js deleted file mode 100644 index 30c8076..0000000 --- a/test/unit/pixi-v2/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/display/Stage.js b/test/unit/pixi-v2/display/Stage.js deleted file mode 100644 index 6974c2e..0000000 --- a/test/unit/pixi-v2/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/extras/Rope.js b/test/unit/pixi-v2/extras/Rope.js deleted file mode 100644 index 05885ac..0000000 --- a/test/unit/pixi-v2/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/extras/Spine.js b/test/unit/pixi-v2/extras/Spine.js deleted file mode 100644 index 0708bc0..0000000 --- a/test/unit/pixi-v2/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/extras/Strip.js b/test/unit/pixi-v2/extras/Strip.js deleted file mode 100644 index 230af90..0000000 --- a/test/unit/pixi-v2/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/extras/TilingSprite.js b/test/unit/pixi-v2/extras/TilingSprite.js deleted file mode 100644 index 56aea14..0000000 --- a/test/unit/pixi-v2/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/filters/FilterBlock.js b/test/unit/pixi-v2/filters/FilterBlock.js deleted file mode 100644 index 870cec0..0000000 --- a/test/unit/pixi-v2/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/loaders/AssetLoader.js b/test/unit/pixi-v2/loaders/AssetLoader.js deleted file mode 100644 index a0aa0b5..0000000 --- a/test/unit/pixi-v2/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/loaders/BitmapFontLoader.js b/test/unit/pixi-v2/loaders/BitmapFontLoader.js deleted file mode 100644 index 046f018..0000000 --- a/test/unit/pixi-v2/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/loaders/ImageLoader.js b/test/unit/pixi-v2/loaders/ImageLoader.js deleted file mode 100644 index 8b1f556..0000000 --- a/test/unit/pixi-v2/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/package.json b/package.json index 6fc5290..ce76d2f 100644 --- a/package.json +++ b/package.json @@ -16,7 +16,7 @@ "url": "https://github.com/GoodBoyDigital/pixi.js.git" }, "scripts": { - "test": "gulp test", + "test": "gulp && testem ci", "docs": "jsdoc -c ./gulp/util/jsdoc.conf.json -R README.md" }, "dependencies": { @@ -45,16 +45,11 @@ "ink-docstrap": "git+https://github.com/Pilatch/docstrap.git", "jsdoc": "^3.3.0-alpha13", "jshint-summary": "^0.4.0", - "karma": "^0.12.28", - "karma-browserify": "^4.0.0", - "karma-chai": "^0.1.0", - "karma-firefox-launcher": "^0.1.0", - "karma-mocha": "^0.1.10", - "karma-spec-reporter": "^0.0.16", "minimist": "^1.1.1", "mocha": "^2.1.0", "require-dir": "^0.3.0", "run-sequence": "^1.0.2", + "testem": "^0.8.2", "vinyl-buffer": "^1.0.0", "vinyl-source-stream": "^1.1.0", "watchify": "^3.1.1" diff --git a/test/functional/example-1-basics/bunny.png b/test/functional/example-1-basics/bunny.png deleted file mode 100644 index 79c3167..0000000 --- a/test/functional/example-1-basics/bunny.png +++ /dev/null Binary files differ diff --git a/test/functional/example-1-basics/frame-30.png b/test/functional/example-1-basics/frame-30.png deleted file mode 100644 index 96e3409..0000000 --- a/test/functional/example-1-basics/frame-30.png +++ /dev/null Binary files differ diff --git a/test/functional/example-1-basics/frame-60.png b/test/functional/example-1-basics/frame-60.png deleted file mode 100644 index af3f4ce..0000000 --- a/test/functional/example-1-basics/frame-60.png +++ /dev/null Binary files differ diff --git a/test/functional/example-1-basics/frame-90.png b/test/functional/example-1-basics/frame-90.png deleted file mode 100644 index 099b823..0000000 --- a/test/functional/example-1-basics/frame-90.png +++ /dev/null Binary files differ diff --git a/test/functional/example-1-basics/index.js b/test/functional/example-1-basics/index.js deleted file mode 100644 index 2ad32bd..0000000 --- a/test/functional/example-1-basics/index.js +++ /dev/null @@ -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(''); - 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(''); - 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(''); - 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); - // }); - // }); -}); diff --git a/test/setup.js b/test/setup.js new file mode 100644 index 0000000..69e1b7a --- /dev/null +++ b/test/setup.js @@ -0,0 +1 @@ +expect = chai.expect; diff --git a/test/unit/bin/pixi.js b/test/unit/bin/pixi.js deleted file mode 100644 index 077cd88..0000000 --- a/test/unit/bin/pixi.js +++ /dev/null @@ -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'); - //}); -}); diff --git a/test/unit/core/utils/util.test.js b/test/unit/core/utils/util.test.js new file mode 100644 index 0000000..30c63f3 --- /dev/null +++ b/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'); + }); + }); +}); diff --git a/test/unit/index.test.js b/test/unit/index.test.js new file mode 100644 index 0000000..37e1d2a --- /dev/null +++ b/test/unit/index.test.js @@ -0,0 +1,6 @@ +describe('PIXI', function () { + it('exists', function () { + expect(PIXI) + .to.be.an('object'); + }); +}); diff --git a/test/unit/pixi-v2/InteractionManager.js b/test/unit/pixi-v2/InteractionManager.js deleted file mode 100644 index ed3001f..0000000 --- a/test/unit/pixi-v2/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/Pixi.js b/test/unit/pixi-v2/Pixi.js deleted file mode 100644 index 27debc1..0000000 --- a/test/unit/pixi-v2/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/core/Circle.js b/test/unit/pixi-v2/core/Circle.js deleted file mode 100644 index fbcfa17..0000000 --- a/test/unit/pixi-v2/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/core/Ellipse.js b/test/unit/pixi-v2/core/Ellipse.js deleted file mode 100644 index 026b56f..0000000 --- a/test/unit/pixi-v2/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/core/Matrix.js b/test/unit/pixi-v2/core/Matrix.js deleted file mode 100644 index da75e2e..0000000 --- a/test/unit/pixi-v2/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/core/Point.js b/test/unit/pixi-v2/core/Point.js deleted file mode 100644 index c4d5163..0000000 --- a/test/unit/pixi-v2/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/core/Polygon.js b/test/unit/pixi-v2/core/Polygon.js deleted file mode 100644 index dc8c918..0000000 --- a/test/unit/pixi-v2/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/core/Rectangle.js b/test/unit/pixi-v2/core/Rectangle.js deleted file mode 100644 index d43316e..0000000 --- a/test/unit/pixi-v2/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/display/DisplayObject.js b/test/unit/pixi-v2/display/DisplayObject.js deleted file mode 100644 index 044acf8..0000000 --- a/test/unit/pixi-v2/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/display/DisplayObjectContainer.js b/test/unit/pixi-v2/display/DisplayObjectContainer.js deleted file mode 100644 index 15a3376..0000000 --- a/test/unit/pixi-v2/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/display/MovieClip.js b/test/unit/pixi-v2/display/MovieClip.js deleted file mode 100644 index f3c6c6a..0000000 --- a/test/unit/pixi-v2/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/display/Sprite.js b/test/unit/pixi-v2/display/Sprite.js deleted file mode 100644 index 30c8076..0000000 --- a/test/unit/pixi-v2/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/display/Stage.js b/test/unit/pixi-v2/display/Stage.js deleted file mode 100644 index 6974c2e..0000000 --- a/test/unit/pixi-v2/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/extras/Rope.js b/test/unit/pixi-v2/extras/Rope.js deleted file mode 100644 index 05885ac..0000000 --- a/test/unit/pixi-v2/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/extras/Spine.js b/test/unit/pixi-v2/extras/Spine.js deleted file mode 100644 index 0708bc0..0000000 --- a/test/unit/pixi-v2/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/extras/Strip.js b/test/unit/pixi-v2/extras/Strip.js deleted file mode 100644 index 230af90..0000000 --- a/test/unit/pixi-v2/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/extras/TilingSprite.js b/test/unit/pixi-v2/extras/TilingSprite.js deleted file mode 100644 index 56aea14..0000000 --- a/test/unit/pixi-v2/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/filters/FilterBlock.js b/test/unit/pixi-v2/filters/FilterBlock.js deleted file mode 100644 index 870cec0..0000000 --- a/test/unit/pixi-v2/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/loaders/AssetLoader.js b/test/unit/pixi-v2/loaders/AssetLoader.js deleted file mode 100644 index a0aa0b5..0000000 --- a/test/unit/pixi-v2/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/loaders/BitmapFontLoader.js b/test/unit/pixi-v2/loaders/BitmapFontLoader.js deleted file mode 100644 index 046f018..0000000 --- a/test/unit/pixi-v2/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/loaders/ImageLoader.js b/test/unit/pixi-v2/loaders/ImageLoader.js deleted file mode 100644 index 8b1f556..0000000 --- a/test/unit/pixi-v2/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/loaders/JsonLoader.js b/test/unit/pixi-v2/loaders/JsonLoader.js deleted file mode 100644 index c577e83..0000000 --- a/test/unit/pixi-v2/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/package.json b/package.json index 6fc5290..ce76d2f 100644 --- a/package.json +++ b/package.json @@ -16,7 +16,7 @@ "url": "https://github.com/GoodBoyDigital/pixi.js.git" }, "scripts": { - "test": "gulp test", + "test": "gulp && testem ci", "docs": "jsdoc -c ./gulp/util/jsdoc.conf.json -R README.md" }, "dependencies": { @@ -45,16 +45,11 @@ "ink-docstrap": "git+https://github.com/Pilatch/docstrap.git", "jsdoc": "^3.3.0-alpha13", "jshint-summary": "^0.4.0", - "karma": "^0.12.28", - "karma-browserify": "^4.0.0", - "karma-chai": "^0.1.0", - "karma-firefox-launcher": "^0.1.0", - "karma-mocha": "^0.1.10", - "karma-spec-reporter": "^0.0.16", "minimist": "^1.1.1", "mocha": "^2.1.0", "require-dir": "^0.3.0", "run-sequence": "^1.0.2", + "testem": "^0.8.2", "vinyl-buffer": "^1.0.0", "vinyl-source-stream": "^1.1.0", "watchify": "^3.1.1" diff --git a/test/functional/example-1-basics/bunny.png b/test/functional/example-1-basics/bunny.png deleted file mode 100644 index 79c3167..0000000 --- a/test/functional/example-1-basics/bunny.png +++ /dev/null Binary files differ diff --git a/test/functional/example-1-basics/frame-30.png b/test/functional/example-1-basics/frame-30.png deleted file mode 100644 index 96e3409..0000000 --- a/test/functional/example-1-basics/frame-30.png +++ /dev/null Binary files differ diff --git a/test/functional/example-1-basics/frame-60.png b/test/functional/example-1-basics/frame-60.png deleted file mode 100644 index af3f4ce..0000000 --- a/test/functional/example-1-basics/frame-60.png +++ /dev/null Binary files differ diff --git a/test/functional/example-1-basics/frame-90.png b/test/functional/example-1-basics/frame-90.png deleted file mode 100644 index 099b823..0000000 --- a/test/functional/example-1-basics/frame-90.png +++ /dev/null Binary files differ diff --git a/test/functional/example-1-basics/index.js b/test/functional/example-1-basics/index.js deleted file mode 100644 index 2ad32bd..0000000 --- a/test/functional/example-1-basics/index.js +++ /dev/null @@ -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(''); - 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(''); - 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(''); - 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); - // }); - // }); -}); diff --git a/test/setup.js b/test/setup.js new file mode 100644 index 0000000..69e1b7a --- /dev/null +++ b/test/setup.js @@ -0,0 +1 @@ +expect = chai.expect; diff --git a/test/unit/bin/pixi.js b/test/unit/bin/pixi.js deleted file mode 100644 index 077cd88..0000000 --- a/test/unit/bin/pixi.js +++ /dev/null @@ -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'); - //}); -}); diff --git a/test/unit/core/utils/util.test.js b/test/unit/core/utils/util.test.js new file mode 100644 index 0000000..30c63f3 --- /dev/null +++ b/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'); + }); + }); +}); diff --git a/test/unit/index.test.js b/test/unit/index.test.js new file mode 100644 index 0000000..37e1d2a --- /dev/null +++ b/test/unit/index.test.js @@ -0,0 +1,6 @@ +describe('PIXI', function () { + it('exists', function () { + expect(PIXI) + .to.be.an('object'); + }); +}); diff --git a/test/unit/pixi-v2/InteractionManager.js b/test/unit/pixi-v2/InteractionManager.js deleted file mode 100644 index ed3001f..0000000 --- a/test/unit/pixi-v2/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/Pixi.js b/test/unit/pixi-v2/Pixi.js deleted file mode 100644 index 27debc1..0000000 --- a/test/unit/pixi-v2/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/core/Circle.js b/test/unit/pixi-v2/core/Circle.js deleted file mode 100644 index fbcfa17..0000000 --- a/test/unit/pixi-v2/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/core/Ellipse.js b/test/unit/pixi-v2/core/Ellipse.js deleted file mode 100644 index 026b56f..0000000 --- a/test/unit/pixi-v2/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/core/Matrix.js b/test/unit/pixi-v2/core/Matrix.js deleted file mode 100644 index da75e2e..0000000 --- a/test/unit/pixi-v2/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/core/Point.js b/test/unit/pixi-v2/core/Point.js deleted file mode 100644 index c4d5163..0000000 --- a/test/unit/pixi-v2/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/core/Polygon.js b/test/unit/pixi-v2/core/Polygon.js deleted file mode 100644 index dc8c918..0000000 --- a/test/unit/pixi-v2/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/core/Rectangle.js b/test/unit/pixi-v2/core/Rectangle.js deleted file mode 100644 index d43316e..0000000 --- a/test/unit/pixi-v2/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/display/DisplayObject.js b/test/unit/pixi-v2/display/DisplayObject.js deleted file mode 100644 index 044acf8..0000000 --- a/test/unit/pixi-v2/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/display/DisplayObjectContainer.js b/test/unit/pixi-v2/display/DisplayObjectContainer.js deleted file mode 100644 index 15a3376..0000000 --- a/test/unit/pixi-v2/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/display/MovieClip.js b/test/unit/pixi-v2/display/MovieClip.js deleted file mode 100644 index f3c6c6a..0000000 --- a/test/unit/pixi-v2/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/display/Sprite.js b/test/unit/pixi-v2/display/Sprite.js deleted file mode 100644 index 30c8076..0000000 --- a/test/unit/pixi-v2/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/display/Stage.js b/test/unit/pixi-v2/display/Stage.js deleted file mode 100644 index 6974c2e..0000000 --- a/test/unit/pixi-v2/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/extras/Rope.js b/test/unit/pixi-v2/extras/Rope.js deleted file mode 100644 index 05885ac..0000000 --- a/test/unit/pixi-v2/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/extras/Spine.js b/test/unit/pixi-v2/extras/Spine.js deleted file mode 100644 index 0708bc0..0000000 --- a/test/unit/pixi-v2/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/extras/Strip.js b/test/unit/pixi-v2/extras/Strip.js deleted file mode 100644 index 230af90..0000000 --- a/test/unit/pixi-v2/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/extras/TilingSprite.js b/test/unit/pixi-v2/extras/TilingSprite.js deleted file mode 100644 index 56aea14..0000000 --- a/test/unit/pixi-v2/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/filters/FilterBlock.js b/test/unit/pixi-v2/filters/FilterBlock.js deleted file mode 100644 index 870cec0..0000000 --- a/test/unit/pixi-v2/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/loaders/AssetLoader.js b/test/unit/pixi-v2/loaders/AssetLoader.js deleted file mode 100644 index a0aa0b5..0000000 --- a/test/unit/pixi-v2/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/loaders/BitmapFontLoader.js b/test/unit/pixi-v2/loaders/BitmapFontLoader.js deleted file mode 100644 index 046f018..0000000 --- a/test/unit/pixi-v2/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/loaders/ImageLoader.js b/test/unit/pixi-v2/loaders/ImageLoader.js deleted file mode 100644 index 8b1f556..0000000 --- a/test/unit/pixi-v2/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/loaders/JsonLoader.js b/test/unit/pixi-v2/loaders/JsonLoader.js deleted file mode 100644 index c577e83..0000000 --- a/test/unit/pixi-v2/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/loaders/SpineLoader.js b/test/unit/pixi-v2/loaders/SpineLoader.js deleted file mode 100644 index fdcc0b8..0000000 --- a/test/unit/pixi-v2/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/package.json b/package.json index 6fc5290..ce76d2f 100644 --- a/package.json +++ b/package.json @@ -16,7 +16,7 @@ "url": "https://github.com/GoodBoyDigital/pixi.js.git" }, "scripts": { - "test": "gulp test", + "test": "gulp && testem ci", "docs": "jsdoc -c ./gulp/util/jsdoc.conf.json -R README.md" }, "dependencies": { @@ -45,16 +45,11 @@ "ink-docstrap": "git+https://github.com/Pilatch/docstrap.git", "jsdoc": "^3.3.0-alpha13", "jshint-summary": "^0.4.0", - "karma": "^0.12.28", - "karma-browserify": "^4.0.0", - "karma-chai": "^0.1.0", - "karma-firefox-launcher": "^0.1.0", - "karma-mocha": "^0.1.10", - "karma-spec-reporter": "^0.0.16", "minimist": "^1.1.1", "mocha": "^2.1.0", "require-dir": "^0.3.0", "run-sequence": "^1.0.2", + "testem": "^0.8.2", "vinyl-buffer": "^1.0.0", "vinyl-source-stream": "^1.1.0", "watchify": "^3.1.1" diff --git a/test/functional/example-1-basics/bunny.png b/test/functional/example-1-basics/bunny.png deleted file mode 100644 index 79c3167..0000000 --- a/test/functional/example-1-basics/bunny.png +++ /dev/null Binary files differ diff --git a/test/functional/example-1-basics/frame-30.png b/test/functional/example-1-basics/frame-30.png deleted file mode 100644 index 96e3409..0000000 --- a/test/functional/example-1-basics/frame-30.png +++ /dev/null Binary files differ diff --git a/test/functional/example-1-basics/frame-60.png b/test/functional/example-1-basics/frame-60.png deleted file mode 100644 index af3f4ce..0000000 --- a/test/functional/example-1-basics/frame-60.png +++ /dev/null Binary files differ diff --git a/test/functional/example-1-basics/frame-90.png b/test/functional/example-1-basics/frame-90.png deleted file mode 100644 index 099b823..0000000 --- a/test/functional/example-1-basics/frame-90.png +++ /dev/null Binary files differ diff --git a/test/functional/example-1-basics/index.js b/test/functional/example-1-basics/index.js deleted file mode 100644 index 2ad32bd..0000000 --- a/test/functional/example-1-basics/index.js +++ /dev/null @@ -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(''); - 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(''); - 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(''); - 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); - // }); - // }); -}); diff --git a/test/setup.js b/test/setup.js new file mode 100644 index 0000000..69e1b7a --- /dev/null +++ b/test/setup.js @@ -0,0 +1 @@ +expect = chai.expect; diff --git a/test/unit/bin/pixi.js b/test/unit/bin/pixi.js deleted file mode 100644 index 077cd88..0000000 --- a/test/unit/bin/pixi.js +++ /dev/null @@ -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'); - //}); -}); diff --git a/test/unit/core/utils/util.test.js b/test/unit/core/utils/util.test.js new file mode 100644 index 0000000..30c63f3 --- /dev/null +++ b/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'); + }); + }); +}); diff --git a/test/unit/index.test.js b/test/unit/index.test.js new file mode 100644 index 0000000..37e1d2a --- /dev/null +++ b/test/unit/index.test.js @@ -0,0 +1,6 @@ +describe('PIXI', function () { + it('exists', function () { + expect(PIXI) + .to.be.an('object'); + }); +}); diff --git a/test/unit/pixi-v2/InteractionManager.js b/test/unit/pixi-v2/InteractionManager.js deleted file mode 100644 index ed3001f..0000000 --- a/test/unit/pixi-v2/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/Pixi.js b/test/unit/pixi-v2/Pixi.js deleted file mode 100644 index 27debc1..0000000 --- a/test/unit/pixi-v2/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/core/Circle.js b/test/unit/pixi-v2/core/Circle.js deleted file mode 100644 index fbcfa17..0000000 --- a/test/unit/pixi-v2/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/core/Ellipse.js b/test/unit/pixi-v2/core/Ellipse.js deleted file mode 100644 index 026b56f..0000000 --- a/test/unit/pixi-v2/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/core/Matrix.js b/test/unit/pixi-v2/core/Matrix.js deleted file mode 100644 index da75e2e..0000000 --- a/test/unit/pixi-v2/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/core/Point.js b/test/unit/pixi-v2/core/Point.js deleted file mode 100644 index c4d5163..0000000 --- a/test/unit/pixi-v2/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/core/Polygon.js b/test/unit/pixi-v2/core/Polygon.js deleted file mode 100644 index dc8c918..0000000 --- a/test/unit/pixi-v2/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/core/Rectangle.js b/test/unit/pixi-v2/core/Rectangle.js deleted file mode 100644 index d43316e..0000000 --- a/test/unit/pixi-v2/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/display/DisplayObject.js b/test/unit/pixi-v2/display/DisplayObject.js deleted file mode 100644 index 044acf8..0000000 --- a/test/unit/pixi-v2/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/display/DisplayObjectContainer.js b/test/unit/pixi-v2/display/DisplayObjectContainer.js deleted file mode 100644 index 15a3376..0000000 --- a/test/unit/pixi-v2/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/display/MovieClip.js b/test/unit/pixi-v2/display/MovieClip.js deleted file mode 100644 index f3c6c6a..0000000 --- a/test/unit/pixi-v2/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/display/Sprite.js b/test/unit/pixi-v2/display/Sprite.js deleted file mode 100644 index 30c8076..0000000 --- a/test/unit/pixi-v2/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/display/Stage.js b/test/unit/pixi-v2/display/Stage.js deleted file mode 100644 index 6974c2e..0000000 --- a/test/unit/pixi-v2/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/extras/Rope.js b/test/unit/pixi-v2/extras/Rope.js deleted file mode 100644 index 05885ac..0000000 --- a/test/unit/pixi-v2/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/extras/Spine.js b/test/unit/pixi-v2/extras/Spine.js deleted file mode 100644 index 0708bc0..0000000 --- a/test/unit/pixi-v2/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/extras/Strip.js b/test/unit/pixi-v2/extras/Strip.js deleted file mode 100644 index 230af90..0000000 --- a/test/unit/pixi-v2/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/extras/TilingSprite.js b/test/unit/pixi-v2/extras/TilingSprite.js deleted file mode 100644 index 56aea14..0000000 --- a/test/unit/pixi-v2/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/filters/FilterBlock.js b/test/unit/pixi-v2/filters/FilterBlock.js deleted file mode 100644 index 870cec0..0000000 --- a/test/unit/pixi-v2/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/loaders/AssetLoader.js b/test/unit/pixi-v2/loaders/AssetLoader.js deleted file mode 100644 index a0aa0b5..0000000 --- a/test/unit/pixi-v2/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/loaders/BitmapFontLoader.js b/test/unit/pixi-v2/loaders/BitmapFontLoader.js deleted file mode 100644 index 046f018..0000000 --- a/test/unit/pixi-v2/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/loaders/ImageLoader.js b/test/unit/pixi-v2/loaders/ImageLoader.js deleted file mode 100644 index 8b1f556..0000000 --- a/test/unit/pixi-v2/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/loaders/JsonLoader.js b/test/unit/pixi-v2/loaders/JsonLoader.js deleted file mode 100644 index c577e83..0000000 --- a/test/unit/pixi-v2/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/loaders/SpineLoader.js b/test/unit/pixi-v2/loaders/SpineLoader.js deleted file mode 100644 index fdcc0b8..0000000 --- a/test/unit/pixi-v2/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/loaders/SpriteSheetLoader.js b/test/unit/pixi-v2/loaders/SpriteSheetLoader.js deleted file mode 100644 index 57beb27..0000000 --- a/test/unit/pixi-v2/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/package.json b/package.json index 6fc5290..ce76d2f 100644 --- a/package.json +++ b/package.json @@ -16,7 +16,7 @@ "url": "https://github.com/GoodBoyDigital/pixi.js.git" }, "scripts": { - "test": "gulp test", + "test": "gulp && testem ci", "docs": "jsdoc -c ./gulp/util/jsdoc.conf.json -R README.md" }, "dependencies": { @@ -45,16 +45,11 @@ "ink-docstrap": "git+https://github.com/Pilatch/docstrap.git", "jsdoc": "^3.3.0-alpha13", "jshint-summary": "^0.4.0", - "karma": "^0.12.28", - "karma-browserify": "^4.0.0", - "karma-chai": "^0.1.0", - "karma-firefox-launcher": "^0.1.0", - "karma-mocha": "^0.1.10", - "karma-spec-reporter": "^0.0.16", "minimist": "^1.1.1", "mocha": "^2.1.0", "require-dir": "^0.3.0", "run-sequence": "^1.0.2", + "testem": "^0.8.2", "vinyl-buffer": "^1.0.0", "vinyl-source-stream": "^1.1.0", "watchify": "^3.1.1" diff --git a/test/functional/example-1-basics/bunny.png b/test/functional/example-1-basics/bunny.png deleted file mode 100644 index 79c3167..0000000 --- a/test/functional/example-1-basics/bunny.png +++ /dev/null Binary files differ diff --git a/test/functional/example-1-basics/frame-30.png b/test/functional/example-1-basics/frame-30.png deleted file mode 100644 index 96e3409..0000000 --- a/test/functional/example-1-basics/frame-30.png +++ /dev/null Binary files differ diff --git a/test/functional/example-1-basics/frame-60.png b/test/functional/example-1-basics/frame-60.png deleted file mode 100644 index af3f4ce..0000000 --- a/test/functional/example-1-basics/frame-60.png +++ /dev/null Binary files differ diff --git a/test/functional/example-1-basics/frame-90.png b/test/functional/example-1-basics/frame-90.png deleted file mode 100644 index 099b823..0000000 --- a/test/functional/example-1-basics/frame-90.png +++ /dev/null Binary files differ diff --git a/test/functional/example-1-basics/index.js b/test/functional/example-1-basics/index.js deleted file mode 100644 index 2ad32bd..0000000 --- a/test/functional/example-1-basics/index.js +++ /dev/null @@ -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(''); - 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(''); - 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(''); - 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); - // }); - // }); -}); diff --git a/test/setup.js b/test/setup.js new file mode 100644 index 0000000..69e1b7a --- /dev/null +++ b/test/setup.js @@ -0,0 +1 @@ +expect = chai.expect; diff --git a/test/unit/bin/pixi.js b/test/unit/bin/pixi.js deleted file mode 100644 index 077cd88..0000000 --- a/test/unit/bin/pixi.js +++ /dev/null @@ -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'); - //}); -}); diff --git a/test/unit/core/utils/util.test.js b/test/unit/core/utils/util.test.js new file mode 100644 index 0000000..30c63f3 --- /dev/null +++ b/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'); + }); + }); +}); diff --git a/test/unit/index.test.js b/test/unit/index.test.js new file mode 100644 index 0000000..37e1d2a --- /dev/null +++ b/test/unit/index.test.js @@ -0,0 +1,6 @@ +describe('PIXI', function () { + it('exists', function () { + expect(PIXI) + .to.be.an('object'); + }); +}); diff --git a/test/unit/pixi-v2/InteractionManager.js b/test/unit/pixi-v2/InteractionManager.js deleted file mode 100644 index ed3001f..0000000 --- a/test/unit/pixi-v2/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/Pixi.js b/test/unit/pixi-v2/Pixi.js deleted file mode 100644 index 27debc1..0000000 --- a/test/unit/pixi-v2/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/core/Circle.js b/test/unit/pixi-v2/core/Circle.js deleted file mode 100644 index fbcfa17..0000000 --- a/test/unit/pixi-v2/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/core/Ellipse.js b/test/unit/pixi-v2/core/Ellipse.js deleted file mode 100644 index 026b56f..0000000 --- a/test/unit/pixi-v2/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/core/Matrix.js b/test/unit/pixi-v2/core/Matrix.js deleted file mode 100644 index da75e2e..0000000 --- a/test/unit/pixi-v2/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/core/Point.js b/test/unit/pixi-v2/core/Point.js deleted file mode 100644 index c4d5163..0000000 --- a/test/unit/pixi-v2/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/core/Polygon.js b/test/unit/pixi-v2/core/Polygon.js deleted file mode 100644 index dc8c918..0000000 --- a/test/unit/pixi-v2/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/core/Rectangle.js b/test/unit/pixi-v2/core/Rectangle.js deleted file mode 100644 index d43316e..0000000 --- a/test/unit/pixi-v2/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/display/DisplayObject.js b/test/unit/pixi-v2/display/DisplayObject.js deleted file mode 100644 index 044acf8..0000000 --- a/test/unit/pixi-v2/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/display/DisplayObjectContainer.js b/test/unit/pixi-v2/display/DisplayObjectContainer.js deleted file mode 100644 index 15a3376..0000000 --- a/test/unit/pixi-v2/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/display/MovieClip.js b/test/unit/pixi-v2/display/MovieClip.js deleted file mode 100644 index f3c6c6a..0000000 --- a/test/unit/pixi-v2/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/display/Sprite.js b/test/unit/pixi-v2/display/Sprite.js deleted file mode 100644 index 30c8076..0000000 --- a/test/unit/pixi-v2/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/display/Stage.js b/test/unit/pixi-v2/display/Stage.js deleted file mode 100644 index 6974c2e..0000000 --- a/test/unit/pixi-v2/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/extras/Rope.js b/test/unit/pixi-v2/extras/Rope.js deleted file mode 100644 index 05885ac..0000000 --- a/test/unit/pixi-v2/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/extras/Spine.js b/test/unit/pixi-v2/extras/Spine.js deleted file mode 100644 index 0708bc0..0000000 --- a/test/unit/pixi-v2/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/extras/Strip.js b/test/unit/pixi-v2/extras/Strip.js deleted file mode 100644 index 230af90..0000000 --- a/test/unit/pixi-v2/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/extras/TilingSprite.js b/test/unit/pixi-v2/extras/TilingSprite.js deleted file mode 100644 index 56aea14..0000000 --- a/test/unit/pixi-v2/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/filters/FilterBlock.js b/test/unit/pixi-v2/filters/FilterBlock.js deleted file mode 100644 index 870cec0..0000000 --- a/test/unit/pixi-v2/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/loaders/AssetLoader.js b/test/unit/pixi-v2/loaders/AssetLoader.js deleted file mode 100644 index a0aa0b5..0000000 --- a/test/unit/pixi-v2/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/loaders/BitmapFontLoader.js b/test/unit/pixi-v2/loaders/BitmapFontLoader.js deleted file mode 100644 index 046f018..0000000 --- a/test/unit/pixi-v2/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/loaders/ImageLoader.js b/test/unit/pixi-v2/loaders/ImageLoader.js deleted file mode 100644 index 8b1f556..0000000 --- a/test/unit/pixi-v2/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/loaders/JsonLoader.js b/test/unit/pixi-v2/loaders/JsonLoader.js deleted file mode 100644 index c577e83..0000000 --- a/test/unit/pixi-v2/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/loaders/SpineLoader.js b/test/unit/pixi-v2/loaders/SpineLoader.js deleted file mode 100644 index fdcc0b8..0000000 --- a/test/unit/pixi-v2/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/loaders/SpriteSheetLoader.js b/test/unit/pixi-v2/loaders/SpriteSheetLoader.js deleted file mode 100644 index 57beb27..0000000 --- a/test/unit/pixi-v2/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/primitives/Graphics.js b/test/unit/pixi-v2/primitives/Graphics.js deleted file mode 100644 index f3849eb..0000000 --- a/test/unit/pixi-v2/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/package.json b/package.json index 6fc5290..ce76d2f 100644 --- a/package.json +++ b/package.json @@ -16,7 +16,7 @@ "url": "https://github.com/GoodBoyDigital/pixi.js.git" }, "scripts": { - "test": "gulp test", + "test": "gulp && testem ci", "docs": "jsdoc -c ./gulp/util/jsdoc.conf.json -R README.md" }, "dependencies": { @@ -45,16 +45,11 @@ "ink-docstrap": "git+https://github.com/Pilatch/docstrap.git", "jsdoc": "^3.3.0-alpha13", "jshint-summary": "^0.4.0", - "karma": "^0.12.28", - "karma-browserify": "^4.0.0", - "karma-chai": "^0.1.0", - "karma-firefox-launcher": "^0.1.0", - "karma-mocha": "^0.1.10", - "karma-spec-reporter": "^0.0.16", "minimist": "^1.1.1", "mocha": "^2.1.0", "require-dir": "^0.3.0", "run-sequence": "^1.0.2", + "testem": "^0.8.2", "vinyl-buffer": "^1.0.0", "vinyl-source-stream": "^1.1.0", "watchify": "^3.1.1" diff --git a/test/functional/example-1-basics/bunny.png b/test/functional/example-1-basics/bunny.png deleted file mode 100644 index 79c3167..0000000 --- a/test/functional/example-1-basics/bunny.png +++ /dev/null Binary files differ diff --git a/test/functional/example-1-basics/frame-30.png b/test/functional/example-1-basics/frame-30.png deleted file mode 100644 index 96e3409..0000000 --- a/test/functional/example-1-basics/frame-30.png +++ /dev/null Binary files differ diff --git a/test/functional/example-1-basics/frame-60.png b/test/functional/example-1-basics/frame-60.png deleted file mode 100644 index af3f4ce..0000000 --- a/test/functional/example-1-basics/frame-60.png +++ /dev/null Binary files differ diff --git a/test/functional/example-1-basics/frame-90.png b/test/functional/example-1-basics/frame-90.png deleted file mode 100644 index 099b823..0000000 --- a/test/functional/example-1-basics/frame-90.png +++ /dev/null Binary files differ diff --git a/test/functional/example-1-basics/index.js b/test/functional/example-1-basics/index.js deleted file mode 100644 index 2ad32bd..0000000 --- a/test/functional/example-1-basics/index.js +++ /dev/null @@ -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(''); - 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(''); - 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(''); - 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); - // }); - // }); -}); diff --git a/test/setup.js b/test/setup.js new file mode 100644 index 0000000..69e1b7a --- /dev/null +++ b/test/setup.js @@ -0,0 +1 @@ +expect = chai.expect; diff --git a/test/unit/bin/pixi.js b/test/unit/bin/pixi.js deleted file mode 100644 index 077cd88..0000000 --- a/test/unit/bin/pixi.js +++ /dev/null @@ -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'); - //}); -}); diff --git a/test/unit/core/utils/util.test.js b/test/unit/core/utils/util.test.js new file mode 100644 index 0000000..30c63f3 --- /dev/null +++ b/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'); + }); + }); +}); diff --git a/test/unit/index.test.js b/test/unit/index.test.js new file mode 100644 index 0000000..37e1d2a --- /dev/null +++ b/test/unit/index.test.js @@ -0,0 +1,6 @@ +describe('PIXI', function () { + it('exists', function () { + expect(PIXI) + .to.be.an('object'); + }); +}); diff --git a/test/unit/pixi-v2/InteractionManager.js b/test/unit/pixi-v2/InteractionManager.js deleted file mode 100644 index ed3001f..0000000 --- a/test/unit/pixi-v2/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/Pixi.js b/test/unit/pixi-v2/Pixi.js deleted file mode 100644 index 27debc1..0000000 --- a/test/unit/pixi-v2/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/core/Circle.js b/test/unit/pixi-v2/core/Circle.js deleted file mode 100644 index fbcfa17..0000000 --- a/test/unit/pixi-v2/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/core/Ellipse.js b/test/unit/pixi-v2/core/Ellipse.js deleted file mode 100644 index 026b56f..0000000 --- a/test/unit/pixi-v2/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/core/Matrix.js b/test/unit/pixi-v2/core/Matrix.js deleted file mode 100644 index da75e2e..0000000 --- a/test/unit/pixi-v2/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/core/Point.js b/test/unit/pixi-v2/core/Point.js deleted file mode 100644 index c4d5163..0000000 --- a/test/unit/pixi-v2/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/core/Polygon.js b/test/unit/pixi-v2/core/Polygon.js deleted file mode 100644 index dc8c918..0000000 --- a/test/unit/pixi-v2/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/core/Rectangle.js b/test/unit/pixi-v2/core/Rectangle.js deleted file mode 100644 index d43316e..0000000 --- a/test/unit/pixi-v2/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/display/DisplayObject.js b/test/unit/pixi-v2/display/DisplayObject.js deleted file mode 100644 index 044acf8..0000000 --- a/test/unit/pixi-v2/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/display/DisplayObjectContainer.js b/test/unit/pixi-v2/display/DisplayObjectContainer.js deleted file mode 100644 index 15a3376..0000000 --- a/test/unit/pixi-v2/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/display/MovieClip.js b/test/unit/pixi-v2/display/MovieClip.js deleted file mode 100644 index f3c6c6a..0000000 --- a/test/unit/pixi-v2/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/display/Sprite.js b/test/unit/pixi-v2/display/Sprite.js deleted file mode 100644 index 30c8076..0000000 --- a/test/unit/pixi-v2/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/display/Stage.js b/test/unit/pixi-v2/display/Stage.js deleted file mode 100644 index 6974c2e..0000000 --- a/test/unit/pixi-v2/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/extras/Rope.js b/test/unit/pixi-v2/extras/Rope.js deleted file mode 100644 index 05885ac..0000000 --- a/test/unit/pixi-v2/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/extras/Spine.js b/test/unit/pixi-v2/extras/Spine.js deleted file mode 100644 index 0708bc0..0000000 --- a/test/unit/pixi-v2/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/extras/Strip.js b/test/unit/pixi-v2/extras/Strip.js deleted file mode 100644 index 230af90..0000000 --- a/test/unit/pixi-v2/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/extras/TilingSprite.js b/test/unit/pixi-v2/extras/TilingSprite.js deleted file mode 100644 index 56aea14..0000000 --- a/test/unit/pixi-v2/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/filters/FilterBlock.js b/test/unit/pixi-v2/filters/FilterBlock.js deleted file mode 100644 index 870cec0..0000000 --- a/test/unit/pixi-v2/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/loaders/AssetLoader.js b/test/unit/pixi-v2/loaders/AssetLoader.js deleted file mode 100644 index a0aa0b5..0000000 --- a/test/unit/pixi-v2/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/loaders/BitmapFontLoader.js b/test/unit/pixi-v2/loaders/BitmapFontLoader.js deleted file mode 100644 index 046f018..0000000 --- a/test/unit/pixi-v2/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/loaders/ImageLoader.js b/test/unit/pixi-v2/loaders/ImageLoader.js deleted file mode 100644 index 8b1f556..0000000 --- a/test/unit/pixi-v2/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/loaders/JsonLoader.js b/test/unit/pixi-v2/loaders/JsonLoader.js deleted file mode 100644 index c577e83..0000000 --- a/test/unit/pixi-v2/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/loaders/SpineLoader.js b/test/unit/pixi-v2/loaders/SpineLoader.js deleted file mode 100644 index fdcc0b8..0000000 --- a/test/unit/pixi-v2/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/loaders/SpriteSheetLoader.js b/test/unit/pixi-v2/loaders/SpriteSheetLoader.js deleted file mode 100644 index 57beb27..0000000 --- a/test/unit/pixi-v2/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/primitives/Graphics.js b/test/unit/pixi-v2/primitives/Graphics.js deleted file mode 100644 index f3849eb..0000000 --- a/test/unit/pixi-v2/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/renderers/canvas/CanvasGraphics.js b/test/unit/pixi-v2/renderers/canvas/CanvasGraphics.js deleted file mode 100644 index 8f44472..0000000 --- a/test/unit/pixi-v2/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/package.json b/package.json index 6fc5290..ce76d2f 100644 --- a/package.json +++ b/package.json @@ -16,7 +16,7 @@ "url": "https://github.com/GoodBoyDigital/pixi.js.git" }, "scripts": { - "test": "gulp test", + "test": "gulp && testem ci", "docs": "jsdoc -c ./gulp/util/jsdoc.conf.json -R README.md" }, "dependencies": { @@ -45,16 +45,11 @@ "ink-docstrap": "git+https://github.com/Pilatch/docstrap.git", "jsdoc": "^3.3.0-alpha13", "jshint-summary": "^0.4.0", - "karma": "^0.12.28", - "karma-browserify": "^4.0.0", - "karma-chai": "^0.1.0", - "karma-firefox-launcher": "^0.1.0", - "karma-mocha": "^0.1.10", - "karma-spec-reporter": "^0.0.16", "minimist": "^1.1.1", "mocha": "^2.1.0", "require-dir": "^0.3.0", "run-sequence": "^1.0.2", + "testem": "^0.8.2", "vinyl-buffer": "^1.0.0", "vinyl-source-stream": "^1.1.0", "watchify": "^3.1.1" diff --git a/test/functional/example-1-basics/bunny.png b/test/functional/example-1-basics/bunny.png deleted file mode 100644 index 79c3167..0000000 --- a/test/functional/example-1-basics/bunny.png +++ /dev/null Binary files differ diff --git a/test/functional/example-1-basics/frame-30.png b/test/functional/example-1-basics/frame-30.png deleted file mode 100644 index 96e3409..0000000 --- a/test/functional/example-1-basics/frame-30.png +++ /dev/null Binary files differ diff --git a/test/functional/example-1-basics/frame-60.png b/test/functional/example-1-basics/frame-60.png deleted file mode 100644 index af3f4ce..0000000 --- a/test/functional/example-1-basics/frame-60.png +++ /dev/null Binary files differ diff --git a/test/functional/example-1-basics/frame-90.png b/test/functional/example-1-basics/frame-90.png deleted file mode 100644 index 099b823..0000000 --- a/test/functional/example-1-basics/frame-90.png +++ /dev/null Binary files differ diff --git a/test/functional/example-1-basics/index.js b/test/functional/example-1-basics/index.js deleted file mode 100644 index 2ad32bd..0000000 --- a/test/functional/example-1-basics/index.js +++ /dev/null @@ -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(''); - 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(''); - 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(''); - 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); - // }); - // }); -}); diff --git a/test/setup.js b/test/setup.js new file mode 100644 index 0000000..69e1b7a --- /dev/null +++ b/test/setup.js @@ -0,0 +1 @@ +expect = chai.expect; diff --git a/test/unit/bin/pixi.js b/test/unit/bin/pixi.js deleted file mode 100644 index 077cd88..0000000 --- a/test/unit/bin/pixi.js +++ /dev/null @@ -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'); - //}); -}); diff --git a/test/unit/core/utils/util.test.js b/test/unit/core/utils/util.test.js new file mode 100644 index 0000000..30c63f3 --- /dev/null +++ b/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'); + }); + }); +}); diff --git a/test/unit/index.test.js b/test/unit/index.test.js new file mode 100644 index 0000000..37e1d2a --- /dev/null +++ b/test/unit/index.test.js @@ -0,0 +1,6 @@ +describe('PIXI', function () { + it('exists', function () { + expect(PIXI) + .to.be.an('object'); + }); +}); diff --git a/test/unit/pixi-v2/InteractionManager.js b/test/unit/pixi-v2/InteractionManager.js deleted file mode 100644 index ed3001f..0000000 --- a/test/unit/pixi-v2/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/Pixi.js b/test/unit/pixi-v2/Pixi.js deleted file mode 100644 index 27debc1..0000000 --- a/test/unit/pixi-v2/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/core/Circle.js b/test/unit/pixi-v2/core/Circle.js deleted file mode 100644 index fbcfa17..0000000 --- a/test/unit/pixi-v2/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/core/Ellipse.js b/test/unit/pixi-v2/core/Ellipse.js deleted file mode 100644 index 026b56f..0000000 --- a/test/unit/pixi-v2/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/core/Matrix.js b/test/unit/pixi-v2/core/Matrix.js deleted file mode 100644 index da75e2e..0000000 --- a/test/unit/pixi-v2/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/core/Point.js b/test/unit/pixi-v2/core/Point.js deleted file mode 100644 index c4d5163..0000000 --- a/test/unit/pixi-v2/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/core/Polygon.js b/test/unit/pixi-v2/core/Polygon.js deleted file mode 100644 index dc8c918..0000000 --- a/test/unit/pixi-v2/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/core/Rectangle.js b/test/unit/pixi-v2/core/Rectangle.js deleted file mode 100644 index d43316e..0000000 --- a/test/unit/pixi-v2/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/display/DisplayObject.js b/test/unit/pixi-v2/display/DisplayObject.js deleted file mode 100644 index 044acf8..0000000 --- a/test/unit/pixi-v2/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/display/DisplayObjectContainer.js b/test/unit/pixi-v2/display/DisplayObjectContainer.js deleted file mode 100644 index 15a3376..0000000 --- a/test/unit/pixi-v2/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/display/MovieClip.js b/test/unit/pixi-v2/display/MovieClip.js deleted file mode 100644 index f3c6c6a..0000000 --- a/test/unit/pixi-v2/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/display/Sprite.js b/test/unit/pixi-v2/display/Sprite.js deleted file mode 100644 index 30c8076..0000000 --- a/test/unit/pixi-v2/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/display/Stage.js b/test/unit/pixi-v2/display/Stage.js deleted file mode 100644 index 6974c2e..0000000 --- a/test/unit/pixi-v2/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/extras/Rope.js b/test/unit/pixi-v2/extras/Rope.js deleted file mode 100644 index 05885ac..0000000 --- a/test/unit/pixi-v2/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/extras/Spine.js b/test/unit/pixi-v2/extras/Spine.js deleted file mode 100644 index 0708bc0..0000000 --- a/test/unit/pixi-v2/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/extras/Strip.js b/test/unit/pixi-v2/extras/Strip.js deleted file mode 100644 index 230af90..0000000 --- a/test/unit/pixi-v2/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/extras/TilingSprite.js b/test/unit/pixi-v2/extras/TilingSprite.js deleted file mode 100644 index 56aea14..0000000 --- a/test/unit/pixi-v2/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/filters/FilterBlock.js b/test/unit/pixi-v2/filters/FilterBlock.js deleted file mode 100644 index 870cec0..0000000 --- a/test/unit/pixi-v2/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/loaders/AssetLoader.js b/test/unit/pixi-v2/loaders/AssetLoader.js deleted file mode 100644 index a0aa0b5..0000000 --- a/test/unit/pixi-v2/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/loaders/BitmapFontLoader.js b/test/unit/pixi-v2/loaders/BitmapFontLoader.js deleted file mode 100644 index 046f018..0000000 --- a/test/unit/pixi-v2/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/loaders/ImageLoader.js b/test/unit/pixi-v2/loaders/ImageLoader.js deleted file mode 100644 index 8b1f556..0000000 --- a/test/unit/pixi-v2/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/loaders/JsonLoader.js b/test/unit/pixi-v2/loaders/JsonLoader.js deleted file mode 100644 index c577e83..0000000 --- a/test/unit/pixi-v2/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/loaders/SpineLoader.js b/test/unit/pixi-v2/loaders/SpineLoader.js deleted file mode 100644 index fdcc0b8..0000000 --- a/test/unit/pixi-v2/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/loaders/SpriteSheetLoader.js b/test/unit/pixi-v2/loaders/SpriteSheetLoader.js deleted file mode 100644 index 57beb27..0000000 --- a/test/unit/pixi-v2/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/primitives/Graphics.js b/test/unit/pixi-v2/primitives/Graphics.js deleted file mode 100644 index f3849eb..0000000 --- a/test/unit/pixi-v2/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/renderers/canvas/CanvasGraphics.js b/test/unit/pixi-v2/renderers/canvas/CanvasGraphics.js deleted file mode 100644 index 8f44472..0000000 --- a/test/unit/pixi-v2/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/renderers/canvas/CanvasRenderer.js b/test/unit/pixi-v2/renderers/canvas/CanvasRenderer.js deleted file mode 100644 index 1646444..0000000 --- a/test/unit/pixi-v2/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/package.json b/package.json index 6fc5290..ce76d2f 100644 --- a/package.json +++ b/package.json @@ -16,7 +16,7 @@ "url": "https://github.com/GoodBoyDigital/pixi.js.git" }, "scripts": { - "test": "gulp test", + "test": "gulp && testem ci", "docs": "jsdoc -c ./gulp/util/jsdoc.conf.json -R README.md" }, "dependencies": { @@ -45,16 +45,11 @@ "ink-docstrap": "git+https://github.com/Pilatch/docstrap.git", "jsdoc": "^3.3.0-alpha13", "jshint-summary": "^0.4.0", - "karma": "^0.12.28", - "karma-browserify": "^4.0.0", - "karma-chai": "^0.1.0", - "karma-firefox-launcher": "^0.1.0", - "karma-mocha": "^0.1.10", - "karma-spec-reporter": "^0.0.16", "minimist": "^1.1.1", "mocha": "^2.1.0", "require-dir": "^0.3.0", "run-sequence": "^1.0.2", + "testem": "^0.8.2", "vinyl-buffer": "^1.0.0", "vinyl-source-stream": "^1.1.0", "watchify": "^3.1.1" diff --git a/test/functional/example-1-basics/bunny.png b/test/functional/example-1-basics/bunny.png deleted file mode 100644 index 79c3167..0000000 --- a/test/functional/example-1-basics/bunny.png +++ /dev/null Binary files differ diff --git a/test/functional/example-1-basics/frame-30.png b/test/functional/example-1-basics/frame-30.png deleted file mode 100644 index 96e3409..0000000 --- a/test/functional/example-1-basics/frame-30.png +++ /dev/null Binary files differ diff --git a/test/functional/example-1-basics/frame-60.png b/test/functional/example-1-basics/frame-60.png deleted file mode 100644 index af3f4ce..0000000 --- a/test/functional/example-1-basics/frame-60.png +++ /dev/null Binary files differ diff --git a/test/functional/example-1-basics/frame-90.png b/test/functional/example-1-basics/frame-90.png deleted file mode 100644 index 099b823..0000000 --- a/test/functional/example-1-basics/frame-90.png +++ /dev/null Binary files differ diff --git a/test/functional/example-1-basics/index.js b/test/functional/example-1-basics/index.js deleted file mode 100644 index 2ad32bd..0000000 --- a/test/functional/example-1-basics/index.js +++ /dev/null @@ -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(''); - 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(''); - 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(''); - 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); - // }); - // }); -}); diff --git a/test/setup.js b/test/setup.js new file mode 100644 index 0000000..69e1b7a --- /dev/null +++ b/test/setup.js @@ -0,0 +1 @@ +expect = chai.expect; diff --git a/test/unit/bin/pixi.js b/test/unit/bin/pixi.js deleted file mode 100644 index 077cd88..0000000 --- a/test/unit/bin/pixi.js +++ /dev/null @@ -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'); - //}); -}); diff --git a/test/unit/core/utils/util.test.js b/test/unit/core/utils/util.test.js new file mode 100644 index 0000000..30c63f3 --- /dev/null +++ b/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'); + }); + }); +}); diff --git a/test/unit/index.test.js b/test/unit/index.test.js new file mode 100644 index 0000000..37e1d2a --- /dev/null +++ b/test/unit/index.test.js @@ -0,0 +1,6 @@ +describe('PIXI', function () { + it('exists', function () { + expect(PIXI) + .to.be.an('object'); + }); +}); diff --git a/test/unit/pixi-v2/InteractionManager.js b/test/unit/pixi-v2/InteractionManager.js deleted file mode 100644 index ed3001f..0000000 --- a/test/unit/pixi-v2/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/Pixi.js b/test/unit/pixi-v2/Pixi.js deleted file mode 100644 index 27debc1..0000000 --- a/test/unit/pixi-v2/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/core/Circle.js b/test/unit/pixi-v2/core/Circle.js deleted file mode 100644 index fbcfa17..0000000 --- a/test/unit/pixi-v2/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/core/Ellipse.js b/test/unit/pixi-v2/core/Ellipse.js deleted file mode 100644 index 026b56f..0000000 --- a/test/unit/pixi-v2/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/core/Matrix.js b/test/unit/pixi-v2/core/Matrix.js deleted file mode 100644 index da75e2e..0000000 --- a/test/unit/pixi-v2/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/core/Point.js b/test/unit/pixi-v2/core/Point.js deleted file mode 100644 index c4d5163..0000000 --- a/test/unit/pixi-v2/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/core/Polygon.js b/test/unit/pixi-v2/core/Polygon.js deleted file mode 100644 index dc8c918..0000000 --- a/test/unit/pixi-v2/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/core/Rectangle.js b/test/unit/pixi-v2/core/Rectangle.js deleted file mode 100644 index d43316e..0000000 --- a/test/unit/pixi-v2/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/display/DisplayObject.js b/test/unit/pixi-v2/display/DisplayObject.js deleted file mode 100644 index 044acf8..0000000 --- a/test/unit/pixi-v2/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/display/DisplayObjectContainer.js b/test/unit/pixi-v2/display/DisplayObjectContainer.js deleted file mode 100644 index 15a3376..0000000 --- a/test/unit/pixi-v2/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/display/MovieClip.js b/test/unit/pixi-v2/display/MovieClip.js deleted file mode 100644 index f3c6c6a..0000000 --- a/test/unit/pixi-v2/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/display/Sprite.js b/test/unit/pixi-v2/display/Sprite.js deleted file mode 100644 index 30c8076..0000000 --- a/test/unit/pixi-v2/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/display/Stage.js b/test/unit/pixi-v2/display/Stage.js deleted file mode 100644 index 6974c2e..0000000 --- a/test/unit/pixi-v2/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/extras/Rope.js b/test/unit/pixi-v2/extras/Rope.js deleted file mode 100644 index 05885ac..0000000 --- a/test/unit/pixi-v2/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/extras/Spine.js b/test/unit/pixi-v2/extras/Spine.js deleted file mode 100644 index 0708bc0..0000000 --- a/test/unit/pixi-v2/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/extras/Strip.js b/test/unit/pixi-v2/extras/Strip.js deleted file mode 100644 index 230af90..0000000 --- a/test/unit/pixi-v2/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/extras/TilingSprite.js b/test/unit/pixi-v2/extras/TilingSprite.js deleted file mode 100644 index 56aea14..0000000 --- a/test/unit/pixi-v2/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/filters/FilterBlock.js b/test/unit/pixi-v2/filters/FilterBlock.js deleted file mode 100644 index 870cec0..0000000 --- a/test/unit/pixi-v2/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/loaders/AssetLoader.js b/test/unit/pixi-v2/loaders/AssetLoader.js deleted file mode 100644 index a0aa0b5..0000000 --- a/test/unit/pixi-v2/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/loaders/BitmapFontLoader.js b/test/unit/pixi-v2/loaders/BitmapFontLoader.js deleted file mode 100644 index 046f018..0000000 --- a/test/unit/pixi-v2/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/loaders/ImageLoader.js b/test/unit/pixi-v2/loaders/ImageLoader.js deleted file mode 100644 index 8b1f556..0000000 --- a/test/unit/pixi-v2/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/loaders/JsonLoader.js b/test/unit/pixi-v2/loaders/JsonLoader.js deleted file mode 100644 index c577e83..0000000 --- a/test/unit/pixi-v2/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/loaders/SpineLoader.js b/test/unit/pixi-v2/loaders/SpineLoader.js deleted file mode 100644 index fdcc0b8..0000000 --- a/test/unit/pixi-v2/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/loaders/SpriteSheetLoader.js b/test/unit/pixi-v2/loaders/SpriteSheetLoader.js deleted file mode 100644 index 57beb27..0000000 --- a/test/unit/pixi-v2/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/primitives/Graphics.js b/test/unit/pixi-v2/primitives/Graphics.js deleted file mode 100644 index f3849eb..0000000 --- a/test/unit/pixi-v2/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/renderers/canvas/CanvasGraphics.js b/test/unit/pixi-v2/renderers/canvas/CanvasGraphics.js deleted file mode 100644 index 8f44472..0000000 --- a/test/unit/pixi-v2/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/renderers/canvas/CanvasRenderer.js b/test/unit/pixi-v2/renderers/canvas/CanvasRenderer.js deleted file mode 100644 index 1646444..0000000 --- a/test/unit/pixi-v2/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/renderers/webgl/WebGLGraphics.js b/test/unit/pixi-v2/renderers/webgl/WebGLGraphics.js deleted file mode 100644 index 5867b28..0000000 --- a/test/unit/pixi-v2/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/package.json b/package.json index 6fc5290..ce76d2f 100644 --- a/package.json +++ b/package.json @@ -16,7 +16,7 @@ "url": "https://github.com/GoodBoyDigital/pixi.js.git" }, "scripts": { - "test": "gulp test", + "test": "gulp && testem ci", "docs": "jsdoc -c ./gulp/util/jsdoc.conf.json -R README.md" }, "dependencies": { @@ -45,16 +45,11 @@ "ink-docstrap": "git+https://github.com/Pilatch/docstrap.git", "jsdoc": "^3.3.0-alpha13", "jshint-summary": "^0.4.0", - "karma": "^0.12.28", - "karma-browserify": "^4.0.0", - "karma-chai": "^0.1.0", - "karma-firefox-launcher": "^0.1.0", - "karma-mocha": "^0.1.10", - "karma-spec-reporter": "^0.0.16", "minimist": "^1.1.1", "mocha": "^2.1.0", "require-dir": "^0.3.0", "run-sequence": "^1.0.2", + "testem": "^0.8.2", "vinyl-buffer": "^1.0.0", "vinyl-source-stream": "^1.1.0", "watchify": "^3.1.1" diff --git a/test/functional/example-1-basics/bunny.png b/test/functional/example-1-basics/bunny.png deleted file mode 100644 index 79c3167..0000000 --- a/test/functional/example-1-basics/bunny.png +++ /dev/null Binary files differ diff --git a/test/functional/example-1-basics/frame-30.png b/test/functional/example-1-basics/frame-30.png deleted file mode 100644 index 96e3409..0000000 --- a/test/functional/example-1-basics/frame-30.png +++ /dev/null Binary files differ diff --git a/test/functional/example-1-basics/frame-60.png b/test/functional/example-1-basics/frame-60.png deleted file mode 100644 index af3f4ce..0000000 --- a/test/functional/example-1-basics/frame-60.png +++ /dev/null Binary files differ diff --git a/test/functional/example-1-basics/frame-90.png b/test/functional/example-1-basics/frame-90.png deleted file mode 100644 index 099b823..0000000 --- a/test/functional/example-1-basics/frame-90.png +++ /dev/null Binary files differ diff --git a/test/functional/example-1-basics/index.js b/test/functional/example-1-basics/index.js deleted file mode 100644 index 2ad32bd..0000000 --- a/test/functional/example-1-basics/index.js +++ /dev/null @@ -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(''); - 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(''); - 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(''); - 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); - // }); - // }); -}); diff --git a/test/setup.js b/test/setup.js new file mode 100644 index 0000000..69e1b7a --- /dev/null +++ b/test/setup.js @@ -0,0 +1 @@ +expect = chai.expect; diff --git a/test/unit/bin/pixi.js b/test/unit/bin/pixi.js deleted file mode 100644 index 077cd88..0000000 --- a/test/unit/bin/pixi.js +++ /dev/null @@ -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'); - //}); -}); diff --git a/test/unit/core/utils/util.test.js b/test/unit/core/utils/util.test.js new file mode 100644 index 0000000..30c63f3 --- /dev/null +++ b/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'); + }); + }); +}); diff --git a/test/unit/index.test.js b/test/unit/index.test.js new file mode 100644 index 0000000..37e1d2a --- /dev/null +++ b/test/unit/index.test.js @@ -0,0 +1,6 @@ +describe('PIXI', function () { + it('exists', function () { + expect(PIXI) + .to.be.an('object'); + }); +}); diff --git a/test/unit/pixi-v2/InteractionManager.js b/test/unit/pixi-v2/InteractionManager.js deleted file mode 100644 index ed3001f..0000000 --- a/test/unit/pixi-v2/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/Pixi.js b/test/unit/pixi-v2/Pixi.js deleted file mode 100644 index 27debc1..0000000 --- a/test/unit/pixi-v2/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/core/Circle.js b/test/unit/pixi-v2/core/Circle.js deleted file mode 100644 index fbcfa17..0000000 --- a/test/unit/pixi-v2/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/core/Ellipse.js b/test/unit/pixi-v2/core/Ellipse.js deleted file mode 100644 index 026b56f..0000000 --- a/test/unit/pixi-v2/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/core/Matrix.js b/test/unit/pixi-v2/core/Matrix.js deleted file mode 100644 index da75e2e..0000000 --- a/test/unit/pixi-v2/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/core/Point.js b/test/unit/pixi-v2/core/Point.js deleted file mode 100644 index c4d5163..0000000 --- a/test/unit/pixi-v2/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/core/Polygon.js b/test/unit/pixi-v2/core/Polygon.js deleted file mode 100644 index dc8c918..0000000 --- a/test/unit/pixi-v2/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/core/Rectangle.js b/test/unit/pixi-v2/core/Rectangle.js deleted file mode 100644 index d43316e..0000000 --- a/test/unit/pixi-v2/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/display/DisplayObject.js b/test/unit/pixi-v2/display/DisplayObject.js deleted file mode 100644 index 044acf8..0000000 --- a/test/unit/pixi-v2/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/display/DisplayObjectContainer.js b/test/unit/pixi-v2/display/DisplayObjectContainer.js deleted file mode 100644 index 15a3376..0000000 --- a/test/unit/pixi-v2/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/display/MovieClip.js b/test/unit/pixi-v2/display/MovieClip.js deleted file mode 100644 index f3c6c6a..0000000 --- a/test/unit/pixi-v2/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/display/Sprite.js b/test/unit/pixi-v2/display/Sprite.js deleted file mode 100644 index 30c8076..0000000 --- a/test/unit/pixi-v2/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/display/Stage.js b/test/unit/pixi-v2/display/Stage.js deleted file mode 100644 index 6974c2e..0000000 --- a/test/unit/pixi-v2/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/extras/Rope.js b/test/unit/pixi-v2/extras/Rope.js deleted file mode 100644 index 05885ac..0000000 --- a/test/unit/pixi-v2/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/extras/Spine.js b/test/unit/pixi-v2/extras/Spine.js deleted file mode 100644 index 0708bc0..0000000 --- a/test/unit/pixi-v2/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/extras/Strip.js b/test/unit/pixi-v2/extras/Strip.js deleted file mode 100644 index 230af90..0000000 --- a/test/unit/pixi-v2/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/extras/TilingSprite.js b/test/unit/pixi-v2/extras/TilingSprite.js deleted file mode 100644 index 56aea14..0000000 --- a/test/unit/pixi-v2/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/filters/FilterBlock.js b/test/unit/pixi-v2/filters/FilterBlock.js deleted file mode 100644 index 870cec0..0000000 --- a/test/unit/pixi-v2/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/loaders/AssetLoader.js b/test/unit/pixi-v2/loaders/AssetLoader.js deleted file mode 100644 index a0aa0b5..0000000 --- a/test/unit/pixi-v2/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/loaders/BitmapFontLoader.js b/test/unit/pixi-v2/loaders/BitmapFontLoader.js deleted file mode 100644 index 046f018..0000000 --- a/test/unit/pixi-v2/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/loaders/ImageLoader.js b/test/unit/pixi-v2/loaders/ImageLoader.js deleted file mode 100644 index 8b1f556..0000000 --- a/test/unit/pixi-v2/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/loaders/JsonLoader.js b/test/unit/pixi-v2/loaders/JsonLoader.js deleted file mode 100644 index c577e83..0000000 --- a/test/unit/pixi-v2/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/loaders/SpineLoader.js b/test/unit/pixi-v2/loaders/SpineLoader.js deleted file mode 100644 index fdcc0b8..0000000 --- a/test/unit/pixi-v2/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/loaders/SpriteSheetLoader.js b/test/unit/pixi-v2/loaders/SpriteSheetLoader.js deleted file mode 100644 index 57beb27..0000000 --- a/test/unit/pixi-v2/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/primitives/Graphics.js b/test/unit/pixi-v2/primitives/Graphics.js deleted file mode 100644 index f3849eb..0000000 --- a/test/unit/pixi-v2/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/renderers/canvas/CanvasGraphics.js b/test/unit/pixi-v2/renderers/canvas/CanvasGraphics.js deleted file mode 100644 index 8f44472..0000000 --- a/test/unit/pixi-v2/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/renderers/canvas/CanvasRenderer.js b/test/unit/pixi-v2/renderers/canvas/CanvasRenderer.js deleted file mode 100644 index 1646444..0000000 --- a/test/unit/pixi-v2/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/renderers/webgl/WebGLGraphics.js b/test/unit/pixi-v2/renderers/webgl/WebGLGraphics.js deleted file mode 100644 index 5867b28..0000000 --- a/test/unit/pixi-v2/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/renderers/webgl/WebGLRenderer.js b/test/unit/pixi-v2/renderers/webgl/WebGLRenderer.js deleted file mode 100644 index 1680a80..0000000 --- a/test/unit/pixi-v2/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/package.json b/package.json index 6fc5290..ce76d2f 100644 --- a/package.json +++ b/package.json @@ -16,7 +16,7 @@ "url": "https://github.com/GoodBoyDigital/pixi.js.git" }, "scripts": { - "test": "gulp test", + "test": "gulp && testem ci", "docs": "jsdoc -c ./gulp/util/jsdoc.conf.json -R README.md" }, "dependencies": { @@ -45,16 +45,11 @@ "ink-docstrap": "git+https://github.com/Pilatch/docstrap.git", "jsdoc": "^3.3.0-alpha13", "jshint-summary": "^0.4.0", - "karma": "^0.12.28", - "karma-browserify": "^4.0.0", - "karma-chai": "^0.1.0", - "karma-firefox-launcher": "^0.1.0", - "karma-mocha": "^0.1.10", - "karma-spec-reporter": "^0.0.16", "minimist": "^1.1.1", "mocha": "^2.1.0", "require-dir": "^0.3.0", "run-sequence": "^1.0.2", + "testem": "^0.8.2", "vinyl-buffer": "^1.0.0", "vinyl-source-stream": "^1.1.0", "watchify": "^3.1.1" diff --git a/test/functional/example-1-basics/bunny.png b/test/functional/example-1-basics/bunny.png deleted file mode 100644 index 79c3167..0000000 --- a/test/functional/example-1-basics/bunny.png +++ /dev/null Binary files differ diff --git a/test/functional/example-1-basics/frame-30.png b/test/functional/example-1-basics/frame-30.png deleted file mode 100644 index 96e3409..0000000 --- a/test/functional/example-1-basics/frame-30.png +++ /dev/null Binary files differ diff --git a/test/functional/example-1-basics/frame-60.png b/test/functional/example-1-basics/frame-60.png deleted file mode 100644 index af3f4ce..0000000 --- a/test/functional/example-1-basics/frame-60.png +++ /dev/null Binary files differ diff --git a/test/functional/example-1-basics/frame-90.png b/test/functional/example-1-basics/frame-90.png deleted file mode 100644 index 099b823..0000000 --- a/test/functional/example-1-basics/frame-90.png +++ /dev/null Binary files differ diff --git a/test/functional/example-1-basics/index.js b/test/functional/example-1-basics/index.js deleted file mode 100644 index 2ad32bd..0000000 --- a/test/functional/example-1-basics/index.js +++ /dev/null @@ -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(''); - 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(''); - 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(''); - 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); - // }); - // }); -}); diff --git a/test/setup.js b/test/setup.js new file mode 100644 index 0000000..69e1b7a --- /dev/null +++ b/test/setup.js @@ -0,0 +1 @@ +expect = chai.expect; diff --git a/test/unit/bin/pixi.js b/test/unit/bin/pixi.js deleted file mode 100644 index 077cd88..0000000 --- a/test/unit/bin/pixi.js +++ /dev/null @@ -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'); - //}); -}); diff --git a/test/unit/core/utils/util.test.js b/test/unit/core/utils/util.test.js new file mode 100644 index 0000000..30c63f3 --- /dev/null +++ b/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'); + }); + }); +}); diff --git a/test/unit/index.test.js b/test/unit/index.test.js new file mode 100644 index 0000000..37e1d2a --- /dev/null +++ b/test/unit/index.test.js @@ -0,0 +1,6 @@ +describe('PIXI', function () { + it('exists', function () { + expect(PIXI) + .to.be.an('object'); + }); +}); diff --git a/test/unit/pixi-v2/InteractionManager.js b/test/unit/pixi-v2/InteractionManager.js deleted file mode 100644 index ed3001f..0000000 --- a/test/unit/pixi-v2/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/Pixi.js b/test/unit/pixi-v2/Pixi.js deleted file mode 100644 index 27debc1..0000000 --- a/test/unit/pixi-v2/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/core/Circle.js b/test/unit/pixi-v2/core/Circle.js deleted file mode 100644 index fbcfa17..0000000 --- a/test/unit/pixi-v2/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/core/Ellipse.js b/test/unit/pixi-v2/core/Ellipse.js deleted file mode 100644 index 026b56f..0000000 --- a/test/unit/pixi-v2/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/core/Matrix.js b/test/unit/pixi-v2/core/Matrix.js deleted file mode 100644 index da75e2e..0000000 --- a/test/unit/pixi-v2/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/core/Point.js b/test/unit/pixi-v2/core/Point.js deleted file mode 100644 index c4d5163..0000000 --- a/test/unit/pixi-v2/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/core/Polygon.js b/test/unit/pixi-v2/core/Polygon.js deleted file mode 100644 index dc8c918..0000000 --- a/test/unit/pixi-v2/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/core/Rectangle.js b/test/unit/pixi-v2/core/Rectangle.js deleted file mode 100644 index d43316e..0000000 --- a/test/unit/pixi-v2/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/display/DisplayObject.js b/test/unit/pixi-v2/display/DisplayObject.js deleted file mode 100644 index 044acf8..0000000 --- a/test/unit/pixi-v2/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/display/DisplayObjectContainer.js b/test/unit/pixi-v2/display/DisplayObjectContainer.js deleted file mode 100644 index 15a3376..0000000 --- a/test/unit/pixi-v2/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/display/MovieClip.js b/test/unit/pixi-v2/display/MovieClip.js deleted file mode 100644 index f3c6c6a..0000000 --- a/test/unit/pixi-v2/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/display/Sprite.js b/test/unit/pixi-v2/display/Sprite.js deleted file mode 100644 index 30c8076..0000000 --- a/test/unit/pixi-v2/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/display/Stage.js b/test/unit/pixi-v2/display/Stage.js deleted file mode 100644 index 6974c2e..0000000 --- a/test/unit/pixi-v2/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/extras/Rope.js b/test/unit/pixi-v2/extras/Rope.js deleted file mode 100644 index 05885ac..0000000 --- a/test/unit/pixi-v2/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/extras/Spine.js b/test/unit/pixi-v2/extras/Spine.js deleted file mode 100644 index 0708bc0..0000000 --- a/test/unit/pixi-v2/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/extras/Strip.js b/test/unit/pixi-v2/extras/Strip.js deleted file mode 100644 index 230af90..0000000 --- a/test/unit/pixi-v2/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/extras/TilingSprite.js b/test/unit/pixi-v2/extras/TilingSprite.js deleted file mode 100644 index 56aea14..0000000 --- a/test/unit/pixi-v2/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/filters/FilterBlock.js b/test/unit/pixi-v2/filters/FilterBlock.js deleted file mode 100644 index 870cec0..0000000 --- a/test/unit/pixi-v2/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/loaders/AssetLoader.js b/test/unit/pixi-v2/loaders/AssetLoader.js deleted file mode 100644 index a0aa0b5..0000000 --- a/test/unit/pixi-v2/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/loaders/BitmapFontLoader.js b/test/unit/pixi-v2/loaders/BitmapFontLoader.js deleted file mode 100644 index 046f018..0000000 --- a/test/unit/pixi-v2/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/loaders/ImageLoader.js b/test/unit/pixi-v2/loaders/ImageLoader.js deleted file mode 100644 index 8b1f556..0000000 --- a/test/unit/pixi-v2/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/loaders/JsonLoader.js b/test/unit/pixi-v2/loaders/JsonLoader.js deleted file mode 100644 index c577e83..0000000 --- a/test/unit/pixi-v2/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/loaders/SpineLoader.js b/test/unit/pixi-v2/loaders/SpineLoader.js deleted file mode 100644 index fdcc0b8..0000000 --- a/test/unit/pixi-v2/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/loaders/SpriteSheetLoader.js b/test/unit/pixi-v2/loaders/SpriteSheetLoader.js deleted file mode 100644 index 57beb27..0000000 --- a/test/unit/pixi-v2/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/primitives/Graphics.js b/test/unit/pixi-v2/primitives/Graphics.js deleted file mode 100644 index f3849eb..0000000 --- a/test/unit/pixi-v2/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/renderers/canvas/CanvasGraphics.js b/test/unit/pixi-v2/renderers/canvas/CanvasGraphics.js deleted file mode 100644 index 8f44472..0000000 --- a/test/unit/pixi-v2/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/renderers/canvas/CanvasRenderer.js b/test/unit/pixi-v2/renderers/canvas/CanvasRenderer.js deleted file mode 100644 index 1646444..0000000 --- a/test/unit/pixi-v2/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/renderers/webgl/WebGLGraphics.js b/test/unit/pixi-v2/renderers/webgl/WebGLGraphics.js deleted file mode 100644 index 5867b28..0000000 --- a/test/unit/pixi-v2/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/renderers/webgl/WebGLRenderer.js b/test/unit/pixi-v2/renderers/webgl/WebGLRenderer.js deleted file mode 100644 index 1680a80..0000000 --- a/test/unit/pixi-v2/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/renderers/webgl/WebGLShaders.js b/test/unit/pixi-v2/renderers/webgl/WebGLShaders.js deleted file mode 100644 index 6e33e4f..0000000 --- a/test/unit/pixi-v2/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/package.json b/package.json index 6fc5290..ce76d2f 100644 --- a/package.json +++ b/package.json @@ -16,7 +16,7 @@ "url": "https://github.com/GoodBoyDigital/pixi.js.git" }, "scripts": { - "test": "gulp test", + "test": "gulp && testem ci", "docs": "jsdoc -c ./gulp/util/jsdoc.conf.json -R README.md" }, "dependencies": { @@ -45,16 +45,11 @@ "ink-docstrap": "git+https://github.com/Pilatch/docstrap.git", "jsdoc": "^3.3.0-alpha13", "jshint-summary": "^0.4.0", - "karma": "^0.12.28", - "karma-browserify": "^4.0.0", - "karma-chai": "^0.1.0", - "karma-firefox-launcher": "^0.1.0", - "karma-mocha": "^0.1.10", - "karma-spec-reporter": "^0.0.16", "minimist": "^1.1.1", "mocha": "^2.1.0", "require-dir": "^0.3.0", "run-sequence": "^1.0.2", + "testem": "^0.8.2", "vinyl-buffer": "^1.0.0", "vinyl-source-stream": "^1.1.0", "watchify": "^3.1.1" diff --git a/test/functional/example-1-basics/bunny.png b/test/functional/example-1-basics/bunny.png deleted file mode 100644 index 79c3167..0000000 --- a/test/functional/example-1-basics/bunny.png +++ /dev/null Binary files differ diff --git a/test/functional/example-1-basics/frame-30.png b/test/functional/example-1-basics/frame-30.png deleted file mode 100644 index 96e3409..0000000 --- a/test/functional/example-1-basics/frame-30.png +++ /dev/null Binary files differ diff --git a/test/functional/example-1-basics/frame-60.png b/test/functional/example-1-basics/frame-60.png deleted file mode 100644 index af3f4ce..0000000 --- a/test/functional/example-1-basics/frame-60.png +++ /dev/null Binary files differ diff --git a/test/functional/example-1-basics/frame-90.png b/test/functional/example-1-basics/frame-90.png deleted file mode 100644 index 099b823..0000000 --- a/test/functional/example-1-basics/frame-90.png +++ /dev/null Binary files differ diff --git a/test/functional/example-1-basics/index.js b/test/functional/example-1-basics/index.js deleted file mode 100644 index 2ad32bd..0000000 --- a/test/functional/example-1-basics/index.js +++ /dev/null @@ -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(''); - 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(''); - 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(''); - 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); - // }); - // }); -}); diff --git a/test/setup.js b/test/setup.js new file mode 100644 index 0000000..69e1b7a --- /dev/null +++ b/test/setup.js @@ -0,0 +1 @@ +expect = chai.expect; diff --git a/test/unit/bin/pixi.js b/test/unit/bin/pixi.js deleted file mode 100644 index 077cd88..0000000 --- a/test/unit/bin/pixi.js +++ /dev/null @@ -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'); - //}); -}); diff --git a/test/unit/core/utils/util.test.js b/test/unit/core/utils/util.test.js new file mode 100644 index 0000000..30c63f3 --- /dev/null +++ b/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'); + }); + }); +}); diff --git a/test/unit/index.test.js b/test/unit/index.test.js new file mode 100644 index 0000000..37e1d2a --- /dev/null +++ b/test/unit/index.test.js @@ -0,0 +1,6 @@ +describe('PIXI', function () { + it('exists', function () { + expect(PIXI) + .to.be.an('object'); + }); +}); diff --git a/test/unit/pixi-v2/InteractionManager.js b/test/unit/pixi-v2/InteractionManager.js deleted file mode 100644 index ed3001f..0000000 --- a/test/unit/pixi-v2/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/Pixi.js b/test/unit/pixi-v2/Pixi.js deleted file mode 100644 index 27debc1..0000000 --- a/test/unit/pixi-v2/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/core/Circle.js b/test/unit/pixi-v2/core/Circle.js deleted file mode 100644 index fbcfa17..0000000 --- a/test/unit/pixi-v2/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/core/Ellipse.js b/test/unit/pixi-v2/core/Ellipse.js deleted file mode 100644 index 026b56f..0000000 --- a/test/unit/pixi-v2/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/core/Matrix.js b/test/unit/pixi-v2/core/Matrix.js deleted file mode 100644 index da75e2e..0000000 --- a/test/unit/pixi-v2/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/core/Point.js b/test/unit/pixi-v2/core/Point.js deleted file mode 100644 index c4d5163..0000000 --- a/test/unit/pixi-v2/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/core/Polygon.js b/test/unit/pixi-v2/core/Polygon.js deleted file mode 100644 index dc8c918..0000000 --- a/test/unit/pixi-v2/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/core/Rectangle.js b/test/unit/pixi-v2/core/Rectangle.js deleted file mode 100644 index d43316e..0000000 --- a/test/unit/pixi-v2/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/display/DisplayObject.js b/test/unit/pixi-v2/display/DisplayObject.js deleted file mode 100644 index 044acf8..0000000 --- a/test/unit/pixi-v2/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/display/DisplayObjectContainer.js b/test/unit/pixi-v2/display/DisplayObjectContainer.js deleted file mode 100644 index 15a3376..0000000 --- a/test/unit/pixi-v2/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/display/MovieClip.js b/test/unit/pixi-v2/display/MovieClip.js deleted file mode 100644 index f3c6c6a..0000000 --- a/test/unit/pixi-v2/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/display/Sprite.js b/test/unit/pixi-v2/display/Sprite.js deleted file mode 100644 index 30c8076..0000000 --- a/test/unit/pixi-v2/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/display/Stage.js b/test/unit/pixi-v2/display/Stage.js deleted file mode 100644 index 6974c2e..0000000 --- a/test/unit/pixi-v2/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/extras/Rope.js b/test/unit/pixi-v2/extras/Rope.js deleted file mode 100644 index 05885ac..0000000 --- a/test/unit/pixi-v2/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/extras/Spine.js b/test/unit/pixi-v2/extras/Spine.js deleted file mode 100644 index 0708bc0..0000000 --- a/test/unit/pixi-v2/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/extras/Strip.js b/test/unit/pixi-v2/extras/Strip.js deleted file mode 100644 index 230af90..0000000 --- a/test/unit/pixi-v2/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/extras/TilingSprite.js b/test/unit/pixi-v2/extras/TilingSprite.js deleted file mode 100644 index 56aea14..0000000 --- a/test/unit/pixi-v2/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/filters/FilterBlock.js b/test/unit/pixi-v2/filters/FilterBlock.js deleted file mode 100644 index 870cec0..0000000 --- a/test/unit/pixi-v2/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/loaders/AssetLoader.js b/test/unit/pixi-v2/loaders/AssetLoader.js deleted file mode 100644 index a0aa0b5..0000000 --- a/test/unit/pixi-v2/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/loaders/BitmapFontLoader.js b/test/unit/pixi-v2/loaders/BitmapFontLoader.js deleted file mode 100644 index 046f018..0000000 --- a/test/unit/pixi-v2/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/loaders/ImageLoader.js b/test/unit/pixi-v2/loaders/ImageLoader.js deleted file mode 100644 index 8b1f556..0000000 --- a/test/unit/pixi-v2/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/loaders/JsonLoader.js b/test/unit/pixi-v2/loaders/JsonLoader.js deleted file mode 100644 index c577e83..0000000 --- a/test/unit/pixi-v2/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/loaders/SpineLoader.js b/test/unit/pixi-v2/loaders/SpineLoader.js deleted file mode 100644 index fdcc0b8..0000000 --- a/test/unit/pixi-v2/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/loaders/SpriteSheetLoader.js b/test/unit/pixi-v2/loaders/SpriteSheetLoader.js deleted file mode 100644 index 57beb27..0000000 --- a/test/unit/pixi-v2/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/primitives/Graphics.js b/test/unit/pixi-v2/primitives/Graphics.js deleted file mode 100644 index f3849eb..0000000 --- a/test/unit/pixi-v2/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/renderers/canvas/CanvasGraphics.js b/test/unit/pixi-v2/renderers/canvas/CanvasGraphics.js deleted file mode 100644 index 8f44472..0000000 --- a/test/unit/pixi-v2/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/renderers/canvas/CanvasRenderer.js b/test/unit/pixi-v2/renderers/canvas/CanvasRenderer.js deleted file mode 100644 index 1646444..0000000 --- a/test/unit/pixi-v2/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/renderers/webgl/WebGLGraphics.js b/test/unit/pixi-v2/renderers/webgl/WebGLGraphics.js deleted file mode 100644 index 5867b28..0000000 --- a/test/unit/pixi-v2/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/renderers/webgl/WebGLRenderer.js b/test/unit/pixi-v2/renderers/webgl/WebGLRenderer.js deleted file mode 100644 index 1680a80..0000000 --- a/test/unit/pixi-v2/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/renderers/webgl/WebGLShaders.js b/test/unit/pixi-v2/renderers/webgl/WebGLShaders.js deleted file mode 100644 index 6e33e4f..0000000 --- a/test/unit/pixi-v2/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/renderers/webgl/WebGLSpriteBatch.js b/test/unit/pixi-v2/renderers/webgl/WebGLSpriteBatch.js deleted file mode 100644 index e662b63..0000000 --- a/test/unit/pixi-v2/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/package.json b/package.json index 6fc5290..ce76d2f 100644 --- a/package.json +++ b/package.json @@ -16,7 +16,7 @@ "url": "https://github.com/GoodBoyDigital/pixi.js.git" }, "scripts": { - "test": "gulp test", + "test": "gulp && testem ci", "docs": "jsdoc -c ./gulp/util/jsdoc.conf.json -R README.md" }, "dependencies": { @@ -45,16 +45,11 @@ "ink-docstrap": "git+https://github.com/Pilatch/docstrap.git", "jsdoc": "^3.3.0-alpha13", "jshint-summary": "^0.4.0", - "karma": "^0.12.28", - "karma-browserify": "^4.0.0", - "karma-chai": "^0.1.0", - "karma-firefox-launcher": "^0.1.0", - "karma-mocha": "^0.1.10", - "karma-spec-reporter": "^0.0.16", "minimist": "^1.1.1", "mocha": "^2.1.0", "require-dir": "^0.3.0", "run-sequence": "^1.0.2", + "testem": "^0.8.2", "vinyl-buffer": "^1.0.0", "vinyl-source-stream": "^1.1.0", "watchify": "^3.1.1" diff --git a/test/functional/example-1-basics/bunny.png b/test/functional/example-1-basics/bunny.png deleted file mode 100644 index 79c3167..0000000 --- a/test/functional/example-1-basics/bunny.png +++ /dev/null Binary files differ diff --git a/test/functional/example-1-basics/frame-30.png b/test/functional/example-1-basics/frame-30.png deleted file mode 100644 index 96e3409..0000000 --- a/test/functional/example-1-basics/frame-30.png +++ /dev/null Binary files differ diff --git a/test/functional/example-1-basics/frame-60.png b/test/functional/example-1-basics/frame-60.png deleted file mode 100644 index af3f4ce..0000000 --- a/test/functional/example-1-basics/frame-60.png +++ /dev/null Binary files differ diff --git a/test/functional/example-1-basics/frame-90.png b/test/functional/example-1-basics/frame-90.png deleted file mode 100644 index 099b823..0000000 --- a/test/functional/example-1-basics/frame-90.png +++ /dev/null Binary files differ diff --git a/test/functional/example-1-basics/index.js b/test/functional/example-1-basics/index.js deleted file mode 100644 index 2ad32bd..0000000 --- a/test/functional/example-1-basics/index.js +++ /dev/null @@ -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(''); - 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(''); - 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(''); - 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); - // }); - // }); -}); diff --git a/test/setup.js b/test/setup.js new file mode 100644 index 0000000..69e1b7a --- /dev/null +++ b/test/setup.js @@ -0,0 +1 @@ +expect = chai.expect; diff --git a/test/unit/bin/pixi.js b/test/unit/bin/pixi.js deleted file mode 100644 index 077cd88..0000000 --- a/test/unit/bin/pixi.js +++ /dev/null @@ -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'); - //}); -}); diff --git a/test/unit/core/utils/util.test.js b/test/unit/core/utils/util.test.js new file mode 100644 index 0000000..30c63f3 --- /dev/null +++ b/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'); + }); + }); +}); diff --git a/test/unit/index.test.js b/test/unit/index.test.js new file mode 100644 index 0000000..37e1d2a --- /dev/null +++ b/test/unit/index.test.js @@ -0,0 +1,6 @@ +describe('PIXI', function () { + it('exists', function () { + expect(PIXI) + .to.be.an('object'); + }); +}); diff --git a/test/unit/pixi-v2/InteractionManager.js b/test/unit/pixi-v2/InteractionManager.js deleted file mode 100644 index ed3001f..0000000 --- a/test/unit/pixi-v2/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/Pixi.js b/test/unit/pixi-v2/Pixi.js deleted file mode 100644 index 27debc1..0000000 --- a/test/unit/pixi-v2/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/core/Circle.js b/test/unit/pixi-v2/core/Circle.js deleted file mode 100644 index fbcfa17..0000000 --- a/test/unit/pixi-v2/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/core/Ellipse.js b/test/unit/pixi-v2/core/Ellipse.js deleted file mode 100644 index 026b56f..0000000 --- a/test/unit/pixi-v2/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/core/Matrix.js b/test/unit/pixi-v2/core/Matrix.js deleted file mode 100644 index da75e2e..0000000 --- a/test/unit/pixi-v2/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/core/Point.js b/test/unit/pixi-v2/core/Point.js deleted file mode 100644 index c4d5163..0000000 --- a/test/unit/pixi-v2/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/core/Polygon.js b/test/unit/pixi-v2/core/Polygon.js deleted file mode 100644 index dc8c918..0000000 --- a/test/unit/pixi-v2/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/core/Rectangle.js b/test/unit/pixi-v2/core/Rectangle.js deleted file mode 100644 index d43316e..0000000 --- a/test/unit/pixi-v2/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/display/DisplayObject.js b/test/unit/pixi-v2/display/DisplayObject.js deleted file mode 100644 index 044acf8..0000000 --- a/test/unit/pixi-v2/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/display/DisplayObjectContainer.js b/test/unit/pixi-v2/display/DisplayObjectContainer.js deleted file mode 100644 index 15a3376..0000000 --- a/test/unit/pixi-v2/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/display/MovieClip.js b/test/unit/pixi-v2/display/MovieClip.js deleted file mode 100644 index f3c6c6a..0000000 --- a/test/unit/pixi-v2/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/display/Sprite.js b/test/unit/pixi-v2/display/Sprite.js deleted file mode 100644 index 30c8076..0000000 --- a/test/unit/pixi-v2/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/display/Stage.js b/test/unit/pixi-v2/display/Stage.js deleted file mode 100644 index 6974c2e..0000000 --- a/test/unit/pixi-v2/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/extras/Rope.js b/test/unit/pixi-v2/extras/Rope.js deleted file mode 100644 index 05885ac..0000000 --- a/test/unit/pixi-v2/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/extras/Spine.js b/test/unit/pixi-v2/extras/Spine.js deleted file mode 100644 index 0708bc0..0000000 --- a/test/unit/pixi-v2/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/extras/Strip.js b/test/unit/pixi-v2/extras/Strip.js deleted file mode 100644 index 230af90..0000000 --- a/test/unit/pixi-v2/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/extras/TilingSprite.js b/test/unit/pixi-v2/extras/TilingSprite.js deleted file mode 100644 index 56aea14..0000000 --- a/test/unit/pixi-v2/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/filters/FilterBlock.js b/test/unit/pixi-v2/filters/FilterBlock.js deleted file mode 100644 index 870cec0..0000000 --- a/test/unit/pixi-v2/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/loaders/AssetLoader.js b/test/unit/pixi-v2/loaders/AssetLoader.js deleted file mode 100644 index a0aa0b5..0000000 --- a/test/unit/pixi-v2/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/loaders/BitmapFontLoader.js b/test/unit/pixi-v2/loaders/BitmapFontLoader.js deleted file mode 100644 index 046f018..0000000 --- a/test/unit/pixi-v2/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/loaders/ImageLoader.js b/test/unit/pixi-v2/loaders/ImageLoader.js deleted file mode 100644 index 8b1f556..0000000 --- a/test/unit/pixi-v2/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/loaders/JsonLoader.js b/test/unit/pixi-v2/loaders/JsonLoader.js deleted file mode 100644 index c577e83..0000000 --- a/test/unit/pixi-v2/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/loaders/SpineLoader.js b/test/unit/pixi-v2/loaders/SpineLoader.js deleted file mode 100644 index fdcc0b8..0000000 --- a/test/unit/pixi-v2/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/loaders/SpriteSheetLoader.js b/test/unit/pixi-v2/loaders/SpriteSheetLoader.js deleted file mode 100644 index 57beb27..0000000 --- a/test/unit/pixi-v2/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/primitives/Graphics.js b/test/unit/pixi-v2/primitives/Graphics.js deleted file mode 100644 index f3849eb..0000000 --- a/test/unit/pixi-v2/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/renderers/canvas/CanvasGraphics.js b/test/unit/pixi-v2/renderers/canvas/CanvasGraphics.js deleted file mode 100644 index 8f44472..0000000 --- a/test/unit/pixi-v2/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/renderers/canvas/CanvasRenderer.js b/test/unit/pixi-v2/renderers/canvas/CanvasRenderer.js deleted file mode 100644 index 1646444..0000000 --- a/test/unit/pixi-v2/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/renderers/webgl/WebGLGraphics.js b/test/unit/pixi-v2/renderers/webgl/WebGLGraphics.js deleted file mode 100644 index 5867b28..0000000 --- a/test/unit/pixi-v2/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/renderers/webgl/WebGLRenderer.js b/test/unit/pixi-v2/renderers/webgl/WebGLRenderer.js deleted file mode 100644 index 1680a80..0000000 --- a/test/unit/pixi-v2/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/renderers/webgl/WebGLShaders.js b/test/unit/pixi-v2/renderers/webgl/WebGLShaders.js deleted file mode 100644 index 6e33e4f..0000000 --- a/test/unit/pixi-v2/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/renderers/webgl/WebGLSpriteBatch.js b/test/unit/pixi-v2/renderers/webgl/WebGLSpriteBatch.js deleted file mode 100644 index e662b63..0000000 --- a/test/unit/pixi-v2/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/text/BitmapText.js b/test/unit/pixi-v2/text/BitmapText.js deleted file mode 100644 index 9388e3d..0000000 --- a/test/unit/pixi-v2/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/package.json b/package.json index 6fc5290..ce76d2f 100644 --- a/package.json +++ b/package.json @@ -16,7 +16,7 @@ "url": "https://github.com/GoodBoyDigital/pixi.js.git" }, "scripts": { - "test": "gulp test", + "test": "gulp && testem ci", "docs": "jsdoc -c ./gulp/util/jsdoc.conf.json -R README.md" }, "dependencies": { @@ -45,16 +45,11 @@ "ink-docstrap": "git+https://github.com/Pilatch/docstrap.git", "jsdoc": "^3.3.0-alpha13", "jshint-summary": "^0.4.0", - "karma": "^0.12.28", - "karma-browserify": "^4.0.0", - "karma-chai": "^0.1.0", - "karma-firefox-launcher": "^0.1.0", - "karma-mocha": "^0.1.10", - "karma-spec-reporter": "^0.0.16", "minimist": "^1.1.1", "mocha": "^2.1.0", "require-dir": "^0.3.0", "run-sequence": "^1.0.2", + "testem": "^0.8.2", "vinyl-buffer": "^1.0.0", "vinyl-source-stream": "^1.1.0", "watchify": "^3.1.1" diff --git a/test/functional/example-1-basics/bunny.png b/test/functional/example-1-basics/bunny.png deleted file mode 100644 index 79c3167..0000000 --- a/test/functional/example-1-basics/bunny.png +++ /dev/null Binary files differ diff --git a/test/functional/example-1-basics/frame-30.png b/test/functional/example-1-basics/frame-30.png deleted file mode 100644 index 96e3409..0000000 --- a/test/functional/example-1-basics/frame-30.png +++ /dev/null Binary files differ diff --git a/test/functional/example-1-basics/frame-60.png b/test/functional/example-1-basics/frame-60.png deleted file mode 100644 index af3f4ce..0000000 --- a/test/functional/example-1-basics/frame-60.png +++ /dev/null Binary files differ diff --git a/test/functional/example-1-basics/frame-90.png b/test/functional/example-1-basics/frame-90.png deleted file mode 100644 index 099b823..0000000 --- a/test/functional/example-1-basics/frame-90.png +++ /dev/null Binary files differ diff --git a/test/functional/example-1-basics/index.js b/test/functional/example-1-basics/index.js deleted file mode 100644 index 2ad32bd..0000000 --- a/test/functional/example-1-basics/index.js +++ /dev/null @@ -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(''); - 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(''); - 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(''); - 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); - // }); - // }); -}); diff --git a/test/setup.js b/test/setup.js new file mode 100644 index 0000000..69e1b7a --- /dev/null +++ b/test/setup.js @@ -0,0 +1 @@ +expect = chai.expect; diff --git a/test/unit/bin/pixi.js b/test/unit/bin/pixi.js deleted file mode 100644 index 077cd88..0000000 --- a/test/unit/bin/pixi.js +++ /dev/null @@ -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'); - //}); -}); diff --git a/test/unit/core/utils/util.test.js b/test/unit/core/utils/util.test.js new file mode 100644 index 0000000..30c63f3 --- /dev/null +++ b/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'); + }); + }); +}); diff --git a/test/unit/index.test.js b/test/unit/index.test.js new file mode 100644 index 0000000..37e1d2a --- /dev/null +++ b/test/unit/index.test.js @@ -0,0 +1,6 @@ +describe('PIXI', function () { + it('exists', function () { + expect(PIXI) + .to.be.an('object'); + }); +}); diff --git a/test/unit/pixi-v2/InteractionManager.js b/test/unit/pixi-v2/InteractionManager.js deleted file mode 100644 index ed3001f..0000000 --- a/test/unit/pixi-v2/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/Pixi.js b/test/unit/pixi-v2/Pixi.js deleted file mode 100644 index 27debc1..0000000 --- a/test/unit/pixi-v2/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/core/Circle.js b/test/unit/pixi-v2/core/Circle.js deleted file mode 100644 index fbcfa17..0000000 --- a/test/unit/pixi-v2/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/core/Ellipse.js b/test/unit/pixi-v2/core/Ellipse.js deleted file mode 100644 index 026b56f..0000000 --- a/test/unit/pixi-v2/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/core/Matrix.js b/test/unit/pixi-v2/core/Matrix.js deleted file mode 100644 index da75e2e..0000000 --- a/test/unit/pixi-v2/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/core/Point.js b/test/unit/pixi-v2/core/Point.js deleted file mode 100644 index c4d5163..0000000 --- a/test/unit/pixi-v2/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/core/Polygon.js b/test/unit/pixi-v2/core/Polygon.js deleted file mode 100644 index dc8c918..0000000 --- a/test/unit/pixi-v2/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/core/Rectangle.js b/test/unit/pixi-v2/core/Rectangle.js deleted file mode 100644 index d43316e..0000000 --- a/test/unit/pixi-v2/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/display/DisplayObject.js b/test/unit/pixi-v2/display/DisplayObject.js deleted file mode 100644 index 044acf8..0000000 --- a/test/unit/pixi-v2/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/display/DisplayObjectContainer.js b/test/unit/pixi-v2/display/DisplayObjectContainer.js deleted file mode 100644 index 15a3376..0000000 --- a/test/unit/pixi-v2/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/display/MovieClip.js b/test/unit/pixi-v2/display/MovieClip.js deleted file mode 100644 index f3c6c6a..0000000 --- a/test/unit/pixi-v2/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/display/Sprite.js b/test/unit/pixi-v2/display/Sprite.js deleted file mode 100644 index 30c8076..0000000 --- a/test/unit/pixi-v2/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/display/Stage.js b/test/unit/pixi-v2/display/Stage.js deleted file mode 100644 index 6974c2e..0000000 --- a/test/unit/pixi-v2/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/extras/Rope.js b/test/unit/pixi-v2/extras/Rope.js deleted file mode 100644 index 05885ac..0000000 --- a/test/unit/pixi-v2/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/extras/Spine.js b/test/unit/pixi-v2/extras/Spine.js deleted file mode 100644 index 0708bc0..0000000 --- a/test/unit/pixi-v2/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/extras/Strip.js b/test/unit/pixi-v2/extras/Strip.js deleted file mode 100644 index 230af90..0000000 --- a/test/unit/pixi-v2/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/extras/TilingSprite.js b/test/unit/pixi-v2/extras/TilingSprite.js deleted file mode 100644 index 56aea14..0000000 --- a/test/unit/pixi-v2/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/filters/FilterBlock.js b/test/unit/pixi-v2/filters/FilterBlock.js deleted file mode 100644 index 870cec0..0000000 --- a/test/unit/pixi-v2/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/loaders/AssetLoader.js b/test/unit/pixi-v2/loaders/AssetLoader.js deleted file mode 100644 index a0aa0b5..0000000 --- a/test/unit/pixi-v2/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/loaders/BitmapFontLoader.js b/test/unit/pixi-v2/loaders/BitmapFontLoader.js deleted file mode 100644 index 046f018..0000000 --- a/test/unit/pixi-v2/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/loaders/ImageLoader.js b/test/unit/pixi-v2/loaders/ImageLoader.js deleted file mode 100644 index 8b1f556..0000000 --- a/test/unit/pixi-v2/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/loaders/JsonLoader.js b/test/unit/pixi-v2/loaders/JsonLoader.js deleted file mode 100644 index c577e83..0000000 --- a/test/unit/pixi-v2/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/loaders/SpineLoader.js b/test/unit/pixi-v2/loaders/SpineLoader.js deleted file mode 100644 index fdcc0b8..0000000 --- a/test/unit/pixi-v2/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/loaders/SpriteSheetLoader.js b/test/unit/pixi-v2/loaders/SpriteSheetLoader.js deleted file mode 100644 index 57beb27..0000000 --- a/test/unit/pixi-v2/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/primitives/Graphics.js b/test/unit/pixi-v2/primitives/Graphics.js deleted file mode 100644 index f3849eb..0000000 --- a/test/unit/pixi-v2/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/renderers/canvas/CanvasGraphics.js b/test/unit/pixi-v2/renderers/canvas/CanvasGraphics.js deleted file mode 100644 index 8f44472..0000000 --- a/test/unit/pixi-v2/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/renderers/canvas/CanvasRenderer.js b/test/unit/pixi-v2/renderers/canvas/CanvasRenderer.js deleted file mode 100644 index 1646444..0000000 --- a/test/unit/pixi-v2/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/renderers/webgl/WebGLGraphics.js b/test/unit/pixi-v2/renderers/webgl/WebGLGraphics.js deleted file mode 100644 index 5867b28..0000000 --- a/test/unit/pixi-v2/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/renderers/webgl/WebGLRenderer.js b/test/unit/pixi-v2/renderers/webgl/WebGLRenderer.js deleted file mode 100644 index 1680a80..0000000 --- a/test/unit/pixi-v2/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/renderers/webgl/WebGLShaders.js b/test/unit/pixi-v2/renderers/webgl/WebGLShaders.js deleted file mode 100644 index 6e33e4f..0000000 --- a/test/unit/pixi-v2/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/renderers/webgl/WebGLSpriteBatch.js b/test/unit/pixi-v2/renderers/webgl/WebGLSpriteBatch.js deleted file mode 100644 index e662b63..0000000 --- a/test/unit/pixi-v2/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/text/BitmapText.js b/test/unit/pixi-v2/text/BitmapText.js deleted file mode 100644 index 9388e3d..0000000 --- a/test/unit/pixi-v2/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/text/Text.js b/test/unit/pixi-v2/text/Text.js deleted file mode 100644 index 9bc9ac5..0000000 --- a/test/unit/pixi-v2/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/package.json b/package.json index 6fc5290..ce76d2f 100644 --- a/package.json +++ b/package.json @@ -16,7 +16,7 @@ "url": "https://github.com/GoodBoyDigital/pixi.js.git" }, "scripts": { - "test": "gulp test", + "test": "gulp && testem ci", "docs": "jsdoc -c ./gulp/util/jsdoc.conf.json -R README.md" }, "dependencies": { @@ -45,16 +45,11 @@ "ink-docstrap": "git+https://github.com/Pilatch/docstrap.git", "jsdoc": "^3.3.0-alpha13", "jshint-summary": "^0.4.0", - "karma": "^0.12.28", - "karma-browserify": "^4.0.0", - "karma-chai": "^0.1.0", - "karma-firefox-launcher": "^0.1.0", - "karma-mocha": "^0.1.10", - "karma-spec-reporter": "^0.0.16", "minimist": "^1.1.1", "mocha": "^2.1.0", "require-dir": "^0.3.0", "run-sequence": "^1.0.2", + "testem": "^0.8.2", "vinyl-buffer": "^1.0.0", "vinyl-source-stream": "^1.1.0", "watchify": "^3.1.1" diff --git a/test/functional/example-1-basics/bunny.png b/test/functional/example-1-basics/bunny.png deleted file mode 100644 index 79c3167..0000000 --- a/test/functional/example-1-basics/bunny.png +++ /dev/null Binary files differ diff --git a/test/functional/example-1-basics/frame-30.png b/test/functional/example-1-basics/frame-30.png deleted file mode 100644 index 96e3409..0000000 --- a/test/functional/example-1-basics/frame-30.png +++ /dev/null Binary files differ diff --git a/test/functional/example-1-basics/frame-60.png b/test/functional/example-1-basics/frame-60.png deleted file mode 100644 index af3f4ce..0000000 --- a/test/functional/example-1-basics/frame-60.png +++ /dev/null Binary files differ diff --git a/test/functional/example-1-basics/frame-90.png b/test/functional/example-1-basics/frame-90.png deleted file mode 100644 index 099b823..0000000 --- a/test/functional/example-1-basics/frame-90.png +++ /dev/null Binary files differ diff --git a/test/functional/example-1-basics/index.js b/test/functional/example-1-basics/index.js deleted file mode 100644 index 2ad32bd..0000000 --- a/test/functional/example-1-basics/index.js +++ /dev/null @@ -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(''); - 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(''); - 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(''); - 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); - // }); - // }); -}); diff --git a/test/setup.js b/test/setup.js new file mode 100644 index 0000000..69e1b7a --- /dev/null +++ b/test/setup.js @@ -0,0 +1 @@ +expect = chai.expect; diff --git a/test/unit/bin/pixi.js b/test/unit/bin/pixi.js deleted file mode 100644 index 077cd88..0000000 --- a/test/unit/bin/pixi.js +++ /dev/null @@ -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'); - //}); -}); diff --git a/test/unit/core/utils/util.test.js b/test/unit/core/utils/util.test.js new file mode 100644 index 0000000..30c63f3 --- /dev/null +++ b/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'); + }); + }); +}); diff --git a/test/unit/index.test.js b/test/unit/index.test.js new file mode 100644 index 0000000..37e1d2a --- /dev/null +++ b/test/unit/index.test.js @@ -0,0 +1,6 @@ +describe('PIXI', function () { + it('exists', function () { + expect(PIXI) + .to.be.an('object'); + }); +}); diff --git a/test/unit/pixi-v2/InteractionManager.js b/test/unit/pixi-v2/InteractionManager.js deleted file mode 100644 index ed3001f..0000000 --- a/test/unit/pixi-v2/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/Pixi.js b/test/unit/pixi-v2/Pixi.js deleted file mode 100644 index 27debc1..0000000 --- a/test/unit/pixi-v2/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/core/Circle.js b/test/unit/pixi-v2/core/Circle.js deleted file mode 100644 index fbcfa17..0000000 --- a/test/unit/pixi-v2/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/core/Ellipse.js b/test/unit/pixi-v2/core/Ellipse.js deleted file mode 100644 index 026b56f..0000000 --- a/test/unit/pixi-v2/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/core/Matrix.js b/test/unit/pixi-v2/core/Matrix.js deleted file mode 100644 index da75e2e..0000000 --- a/test/unit/pixi-v2/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/core/Point.js b/test/unit/pixi-v2/core/Point.js deleted file mode 100644 index c4d5163..0000000 --- a/test/unit/pixi-v2/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/core/Polygon.js b/test/unit/pixi-v2/core/Polygon.js deleted file mode 100644 index dc8c918..0000000 --- a/test/unit/pixi-v2/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/core/Rectangle.js b/test/unit/pixi-v2/core/Rectangle.js deleted file mode 100644 index d43316e..0000000 --- a/test/unit/pixi-v2/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/display/DisplayObject.js b/test/unit/pixi-v2/display/DisplayObject.js deleted file mode 100644 index 044acf8..0000000 --- a/test/unit/pixi-v2/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/display/DisplayObjectContainer.js b/test/unit/pixi-v2/display/DisplayObjectContainer.js deleted file mode 100644 index 15a3376..0000000 --- a/test/unit/pixi-v2/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/display/MovieClip.js b/test/unit/pixi-v2/display/MovieClip.js deleted file mode 100644 index f3c6c6a..0000000 --- a/test/unit/pixi-v2/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/display/Sprite.js b/test/unit/pixi-v2/display/Sprite.js deleted file mode 100644 index 30c8076..0000000 --- a/test/unit/pixi-v2/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/display/Stage.js b/test/unit/pixi-v2/display/Stage.js deleted file mode 100644 index 6974c2e..0000000 --- a/test/unit/pixi-v2/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/extras/Rope.js b/test/unit/pixi-v2/extras/Rope.js deleted file mode 100644 index 05885ac..0000000 --- a/test/unit/pixi-v2/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/extras/Spine.js b/test/unit/pixi-v2/extras/Spine.js deleted file mode 100644 index 0708bc0..0000000 --- a/test/unit/pixi-v2/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/extras/Strip.js b/test/unit/pixi-v2/extras/Strip.js deleted file mode 100644 index 230af90..0000000 --- a/test/unit/pixi-v2/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/extras/TilingSprite.js b/test/unit/pixi-v2/extras/TilingSprite.js deleted file mode 100644 index 56aea14..0000000 --- a/test/unit/pixi-v2/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/filters/FilterBlock.js b/test/unit/pixi-v2/filters/FilterBlock.js deleted file mode 100644 index 870cec0..0000000 --- a/test/unit/pixi-v2/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/loaders/AssetLoader.js b/test/unit/pixi-v2/loaders/AssetLoader.js deleted file mode 100644 index a0aa0b5..0000000 --- a/test/unit/pixi-v2/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/loaders/BitmapFontLoader.js b/test/unit/pixi-v2/loaders/BitmapFontLoader.js deleted file mode 100644 index 046f018..0000000 --- a/test/unit/pixi-v2/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/loaders/ImageLoader.js b/test/unit/pixi-v2/loaders/ImageLoader.js deleted file mode 100644 index 8b1f556..0000000 --- a/test/unit/pixi-v2/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/loaders/JsonLoader.js b/test/unit/pixi-v2/loaders/JsonLoader.js deleted file mode 100644 index c577e83..0000000 --- a/test/unit/pixi-v2/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/loaders/SpineLoader.js b/test/unit/pixi-v2/loaders/SpineLoader.js deleted file mode 100644 index fdcc0b8..0000000 --- a/test/unit/pixi-v2/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/loaders/SpriteSheetLoader.js b/test/unit/pixi-v2/loaders/SpriteSheetLoader.js deleted file mode 100644 index 57beb27..0000000 --- a/test/unit/pixi-v2/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/primitives/Graphics.js b/test/unit/pixi-v2/primitives/Graphics.js deleted file mode 100644 index f3849eb..0000000 --- a/test/unit/pixi-v2/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/renderers/canvas/CanvasGraphics.js b/test/unit/pixi-v2/renderers/canvas/CanvasGraphics.js deleted file mode 100644 index 8f44472..0000000 --- a/test/unit/pixi-v2/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/renderers/canvas/CanvasRenderer.js b/test/unit/pixi-v2/renderers/canvas/CanvasRenderer.js deleted file mode 100644 index 1646444..0000000 --- a/test/unit/pixi-v2/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/renderers/webgl/WebGLGraphics.js b/test/unit/pixi-v2/renderers/webgl/WebGLGraphics.js deleted file mode 100644 index 5867b28..0000000 --- a/test/unit/pixi-v2/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/renderers/webgl/WebGLRenderer.js b/test/unit/pixi-v2/renderers/webgl/WebGLRenderer.js deleted file mode 100644 index 1680a80..0000000 --- a/test/unit/pixi-v2/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/renderers/webgl/WebGLShaders.js b/test/unit/pixi-v2/renderers/webgl/WebGLShaders.js deleted file mode 100644 index 6e33e4f..0000000 --- a/test/unit/pixi-v2/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/renderers/webgl/WebGLSpriteBatch.js b/test/unit/pixi-v2/renderers/webgl/WebGLSpriteBatch.js deleted file mode 100644 index e662b63..0000000 --- a/test/unit/pixi-v2/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/text/BitmapText.js b/test/unit/pixi-v2/text/BitmapText.js deleted file mode 100644 index 9388e3d..0000000 --- a/test/unit/pixi-v2/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/text/Text.js b/test/unit/pixi-v2/text/Text.js deleted file mode 100644 index 9bc9ac5..0000000 --- a/test/unit/pixi-v2/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/textures/BaseTexture.js b/test/unit/pixi-v2/textures/BaseTexture.js deleted file mode 100644 index 502b724..0000000 --- a/test/unit/pixi-v2/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/package.json b/package.json index 6fc5290..ce76d2f 100644 --- a/package.json +++ b/package.json @@ -16,7 +16,7 @@ "url": "https://github.com/GoodBoyDigital/pixi.js.git" }, "scripts": { - "test": "gulp test", + "test": "gulp && testem ci", "docs": "jsdoc -c ./gulp/util/jsdoc.conf.json -R README.md" }, "dependencies": { @@ -45,16 +45,11 @@ "ink-docstrap": "git+https://github.com/Pilatch/docstrap.git", "jsdoc": "^3.3.0-alpha13", "jshint-summary": "^0.4.0", - "karma": "^0.12.28", - "karma-browserify": "^4.0.0", - "karma-chai": "^0.1.0", - "karma-firefox-launcher": "^0.1.0", - "karma-mocha": "^0.1.10", - "karma-spec-reporter": "^0.0.16", "minimist": "^1.1.1", "mocha": "^2.1.0", "require-dir": "^0.3.0", "run-sequence": "^1.0.2", + "testem": "^0.8.2", "vinyl-buffer": "^1.0.0", "vinyl-source-stream": "^1.1.0", "watchify": "^3.1.1" diff --git a/test/functional/example-1-basics/bunny.png b/test/functional/example-1-basics/bunny.png deleted file mode 100644 index 79c3167..0000000 --- a/test/functional/example-1-basics/bunny.png +++ /dev/null Binary files differ diff --git a/test/functional/example-1-basics/frame-30.png b/test/functional/example-1-basics/frame-30.png deleted file mode 100644 index 96e3409..0000000 --- a/test/functional/example-1-basics/frame-30.png +++ /dev/null Binary files differ diff --git a/test/functional/example-1-basics/frame-60.png b/test/functional/example-1-basics/frame-60.png deleted file mode 100644 index af3f4ce..0000000 --- a/test/functional/example-1-basics/frame-60.png +++ /dev/null Binary files differ diff --git a/test/functional/example-1-basics/frame-90.png b/test/functional/example-1-basics/frame-90.png deleted file mode 100644 index 099b823..0000000 --- a/test/functional/example-1-basics/frame-90.png +++ /dev/null Binary files differ diff --git a/test/functional/example-1-basics/index.js b/test/functional/example-1-basics/index.js deleted file mode 100644 index 2ad32bd..0000000 --- a/test/functional/example-1-basics/index.js +++ /dev/null @@ -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(''); - 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(''); - 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(''); - 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); - // }); - // }); -}); diff --git a/test/setup.js b/test/setup.js new file mode 100644 index 0000000..69e1b7a --- /dev/null +++ b/test/setup.js @@ -0,0 +1 @@ +expect = chai.expect; diff --git a/test/unit/bin/pixi.js b/test/unit/bin/pixi.js deleted file mode 100644 index 077cd88..0000000 --- a/test/unit/bin/pixi.js +++ /dev/null @@ -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'); - //}); -}); diff --git a/test/unit/core/utils/util.test.js b/test/unit/core/utils/util.test.js new file mode 100644 index 0000000..30c63f3 --- /dev/null +++ b/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'); + }); + }); +}); diff --git a/test/unit/index.test.js b/test/unit/index.test.js new file mode 100644 index 0000000..37e1d2a --- /dev/null +++ b/test/unit/index.test.js @@ -0,0 +1,6 @@ +describe('PIXI', function () { + it('exists', function () { + expect(PIXI) + .to.be.an('object'); + }); +}); diff --git a/test/unit/pixi-v2/InteractionManager.js b/test/unit/pixi-v2/InteractionManager.js deleted file mode 100644 index ed3001f..0000000 --- a/test/unit/pixi-v2/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/Pixi.js b/test/unit/pixi-v2/Pixi.js deleted file mode 100644 index 27debc1..0000000 --- a/test/unit/pixi-v2/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/core/Circle.js b/test/unit/pixi-v2/core/Circle.js deleted file mode 100644 index fbcfa17..0000000 --- a/test/unit/pixi-v2/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/core/Ellipse.js b/test/unit/pixi-v2/core/Ellipse.js deleted file mode 100644 index 026b56f..0000000 --- a/test/unit/pixi-v2/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/core/Matrix.js b/test/unit/pixi-v2/core/Matrix.js deleted file mode 100644 index da75e2e..0000000 --- a/test/unit/pixi-v2/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/core/Point.js b/test/unit/pixi-v2/core/Point.js deleted file mode 100644 index c4d5163..0000000 --- a/test/unit/pixi-v2/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/core/Polygon.js b/test/unit/pixi-v2/core/Polygon.js deleted file mode 100644 index dc8c918..0000000 --- a/test/unit/pixi-v2/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/core/Rectangle.js b/test/unit/pixi-v2/core/Rectangle.js deleted file mode 100644 index d43316e..0000000 --- a/test/unit/pixi-v2/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/display/DisplayObject.js b/test/unit/pixi-v2/display/DisplayObject.js deleted file mode 100644 index 044acf8..0000000 --- a/test/unit/pixi-v2/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/display/DisplayObjectContainer.js b/test/unit/pixi-v2/display/DisplayObjectContainer.js deleted file mode 100644 index 15a3376..0000000 --- a/test/unit/pixi-v2/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/display/MovieClip.js b/test/unit/pixi-v2/display/MovieClip.js deleted file mode 100644 index f3c6c6a..0000000 --- a/test/unit/pixi-v2/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/display/Sprite.js b/test/unit/pixi-v2/display/Sprite.js deleted file mode 100644 index 30c8076..0000000 --- a/test/unit/pixi-v2/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/display/Stage.js b/test/unit/pixi-v2/display/Stage.js deleted file mode 100644 index 6974c2e..0000000 --- a/test/unit/pixi-v2/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/extras/Rope.js b/test/unit/pixi-v2/extras/Rope.js deleted file mode 100644 index 05885ac..0000000 --- a/test/unit/pixi-v2/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/extras/Spine.js b/test/unit/pixi-v2/extras/Spine.js deleted file mode 100644 index 0708bc0..0000000 --- a/test/unit/pixi-v2/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/extras/Strip.js b/test/unit/pixi-v2/extras/Strip.js deleted file mode 100644 index 230af90..0000000 --- a/test/unit/pixi-v2/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/extras/TilingSprite.js b/test/unit/pixi-v2/extras/TilingSprite.js deleted file mode 100644 index 56aea14..0000000 --- a/test/unit/pixi-v2/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/filters/FilterBlock.js b/test/unit/pixi-v2/filters/FilterBlock.js deleted file mode 100644 index 870cec0..0000000 --- a/test/unit/pixi-v2/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/loaders/AssetLoader.js b/test/unit/pixi-v2/loaders/AssetLoader.js deleted file mode 100644 index a0aa0b5..0000000 --- a/test/unit/pixi-v2/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/loaders/BitmapFontLoader.js b/test/unit/pixi-v2/loaders/BitmapFontLoader.js deleted file mode 100644 index 046f018..0000000 --- a/test/unit/pixi-v2/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/loaders/ImageLoader.js b/test/unit/pixi-v2/loaders/ImageLoader.js deleted file mode 100644 index 8b1f556..0000000 --- a/test/unit/pixi-v2/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/loaders/JsonLoader.js b/test/unit/pixi-v2/loaders/JsonLoader.js deleted file mode 100644 index c577e83..0000000 --- a/test/unit/pixi-v2/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/loaders/SpineLoader.js b/test/unit/pixi-v2/loaders/SpineLoader.js deleted file mode 100644 index fdcc0b8..0000000 --- a/test/unit/pixi-v2/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/loaders/SpriteSheetLoader.js b/test/unit/pixi-v2/loaders/SpriteSheetLoader.js deleted file mode 100644 index 57beb27..0000000 --- a/test/unit/pixi-v2/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/primitives/Graphics.js b/test/unit/pixi-v2/primitives/Graphics.js deleted file mode 100644 index f3849eb..0000000 --- a/test/unit/pixi-v2/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/renderers/canvas/CanvasGraphics.js b/test/unit/pixi-v2/renderers/canvas/CanvasGraphics.js deleted file mode 100644 index 8f44472..0000000 --- a/test/unit/pixi-v2/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/renderers/canvas/CanvasRenderer.js b/test/unit/pixi-v2/renderers/canvas/CanvasRenderer.js deleted file mode 100644 index 1646444..0000000 --- a/test/unit/pixi-v2/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/renderers/webgl/WebGLGraphics.js b/test/unit/pixi-v2/renderers/webgl/WebGLGraphics.js deleted file mode 100644 index 5867b28..0000000 --- a/test/unit/pixi-v2/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/renderers/webgl/WebGLRenderer.js b/test/unit/pixi-v2/renderers/webgl/WebGLRenderer.js deleted file mode 100644 index 1680a80..0000000 --- a/test/unit/pixi-v2/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/renderers/webgl/WebGLShaders.js b/test/unit/pixi-v2/renderers/webgl/WebGLShaders.js deleted file mode 100644 index 6e33e4f..0000000 --- a/test/unit/pixi-v2/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/renderers/webgl/WebGLSpriteBatch.js b/test/unit/pixi-v2/renderers/webgl/WebGLSpriteBatch.js deleted file mode 100644 index e662b63..0000000 --- a/test/unit/pixi-v2/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/text/BitmapText.js b/test/unit/pixi-v2/text/BitmapText.js deleted file mode 100644 index 9388e3d..0000000 --- a/test/unit/pixi-v2/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/text/Text.js b/test/unit/pixi-v2/text/Text.js deleted file mode 100644 index 9bc9ac5..0000000 --- a/test/unit/pixi-v2/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/textures/BaseTexture.js b/test/unit/pixi-v2/textures/BaseTexture.js deleted file mode 100644 index 502b724..0000000 --- a/test/unit/pixi-v2/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/textures/RenderTexture.js b/test/unit/pixi-v2/textures/RenderTexture.js deleted file mode 100644 index 96acdb4..0000000 --- a/test/unit/pixi-v2/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/package.json b/package.json index 6fc5290..ce76d2f 100644 --- a/package.json +++ b/package.json @@ -16,7 +16,7 @@ "url": "https://github.com/GoodBoyDigital/pixi.js.git" }, "scripts": { - "test": "gulp test", + "test": "gulp && testem ci", "docs": "jsdoc -c ./gulp/util/jsdoc.conf.json -R README.md" }, "dependencies": { @@ -45,16 +45,11 @@ "ink-docstrap": "git+https://github.com/Pilatch/docstrap.git", "jsdoc": "^3.3.0-alpha13", "jshint-summary": "^0.4.0", - "karma": "^0.12.28", - "karma-browserify": "^4.0.0", - "karma-chai": "^0.1.0", - "karma-firefox-launcher": "^0.1.0", - "karma-mocha": "^0.1.10", - "karma-spec-reporter": "^0.0.16", "minimist": "^1.1.1", "mocha": "^2.1.0", "require-dir": "^0.3.0", "run-sequence": "^1.0.2", + "testem": "^0.8.2", "vinyl-buffer": "^1.0.0", "vinyl-source-stream": "^1.1.0", "watchify": "^3.1.1" diff --git a/test/functional/example-1-basics/bunny.png b/test/functional/example-1-basics/bunny.png deleted file mode 100644 index 79c3167..0000000 --- a/test/functional/example-1-basics/bunny.png +++ /dev/null Binary files differ diff --git a/test/functional/example-1-basics/frame-30.png b/test/functional/example-1-basics/frame-30.png deleted file mode 100644 index 96e3409..0000000 --- a/test/functional/example-1-basics/frame-30.png +++ /dev/null Binary files differ diff --git a/test/functional/example-1-basics/frame-60.png b/test/functional/example-1-basics/frame-60.png deleted file mode 100644 index af3f4ce..0000000 --- a/test/functional/example-1-basics/frame-60.png +++ /dev/null Binary files differ diff --git a/test/functional/example-1-basics/frame-90.png b/test/functional/example-1-basics/frame-90.png deleted file mode 100644 index 099b823..0000000 --- a/test/functional/example-1-basics/frame-90.png +++ /dev/null Binary files differ diff --git a/test/functional/example-1-basics/index.js b/test/functional/example-1-basics/index.js deleted file mode 100644 index 2ad32bd..0000000 --- a/test/functional/example-1-basics/index.js +++ /dev/null @@ -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(''); - 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(''); - 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(''); - 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); - // }); - // }); -}); diff --git a/test/setup.js b/test/setup.js new file mode 100644 index 0000000..69e1b7a --- /dev/null +++ b/test/setup.js @@ -0,0 +1 @@ +expect = chai.expect; diff --git a/test/unit/bin/pixi.js b/test/unit/bin/pixi.js deleted file mode 100644 index 077cd88..0000000 --- a/test/unit/bin/pixi.js +++ /dev/null @@ -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'); - //}); -}); diff --git a/test/unit/core/utils/util.test.js b/test/unit/core/utils/util.test.js new file mode 100644 index 0000000..30c63f3 --- /dev/null +++ b/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'); + }); + }); +}); diff --git a/test/unit/index.test.js b/test/unit/index.test.js new file mode 100644 index 0000000..37e1d2a --- /dev/null +++ b/test/unit/index.test.js @@ -0,0 +1,6 @@ +describe('PIXI', function () { + it('exists', function () { + expect(PIXI) + .to.be.an('object'); + }); +}); diff --git a/test/unit/pixi-v2/InteractionManager.js b/test/unit/pixi-v2/InteractionManager.js deleted file mode 100644 index ed3001f..0000000 --- a/test/unit/pixi-v2/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/Pixi.js b/test/unit/pixi-v2/Pixi.js deleted file mode 100644 index 27debc1..0000000 --- a/test/unit/pixi-v2/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/core/Circle.js b/test/unit/pixi-v2/core/Circle.js deleted file mode 100644 index fbcfa17..0000000 --- a/test/unit/pixi-v2/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/core/Ellipse.js b/test/unit/pixi-v2/core/Ellipse.js deleted file mode 100644 index 026b56f..0000000 --- a/test/unit/pixi-v2/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/core/Matrix.js b/test/unit/pixi-v2/core/Matrix.js deleted file mode 100644 index da75e2e..0000000 --- a/test/unit/pixi-v2/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/core/Point.js b/test/unit/pixi-v2/core/Point.js deleted file mode 100644 index c4d5163..0000000 --- a/test/unit/pixi-v2/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/core/Polygon.js b/test/unit/pixi-v2/core/Polygon.js deleted file mode 100644 index dc8c918..0000000 --- a/test/unit/pixi-v2/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/core/Rectangle.js b/test/unit/pixi-v2/core/Rectangle.js deleted file mode 100644 index d43316e..0000000 --- a/test/unit/pixi-v2/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/display/DisplayObject.js b/test/unit/pixi-v2/display/DisplayObject.js deleted file mode 100644 index 044acf8..0000000 --- a/test/unit/pixi-v2/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/display/DisplayObjectContainer.js b/test/unit/pixi-v2/display/DisplayObjectContainer.js deleted file mode 100644 index 15a3376..0000000 --- a/test/unit/pixi-v2/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/display/MovieClip.js b/test/unit/pixi-v2/display/MovieClip.js deleted file mode 100644 index f3c6c6a..0000000 --- a/test/unit/pixi-v2/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/display/Sprite.js b/test/unit/pixi-v2/display/Sprite.js deleted file mode 100644 index 30c8076..0000000 --- a/test/unit/pixi-v2/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/display/Stage.js b/test/unit/pixi-v2/display/Stage.js deleted file mode 100644 index 6974c2e..0000000 --- a/test/unit/pixi-v2/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/extras/Rope.js b/test/unit/pixi-v2/extras/Rope.js deleted file mode 100644 index 05885ac..0000000 --- a/test/unit/pixi-v2/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/extras/Spine.js b/test/unit/pixi-v2/extras/Spine.js deleted file mode 100644 index 0708bc0..0000000 --- a/test/unit/pixi-v2/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/extras/Strip.js b/test/unit/pixi-v2/extras/Strip.js deleted file mode 100644 index 230af90..0000000 --- a/test/unit/pixi-v2/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/extras/TilingSprite.js b/test/unit/pixi-v2/extras/TilingSprite.js deleted file mode 100644 index 56aea14..0000000 --- a/test/unit/pixi-v2/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/filters/FilterBlock.js b/test/unit/pixi-v2/filters/FilterBlock.js deleted file mode 100644 index 870cec0..0000000 --- a/test/unit/pixi-v2/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/loaders/AssetLoader.js b/test/unit/pixi-v2/loaders/AssetLoader.js deleted file mode 100644 index a0aa0b5..0000000 --- a/test/unit/pixi-v2/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/loaders/BitmapFontLoader.js b/test/unit/pixi-v2/loaders/BitmapFontLoader.js deleted file mode 100644 index 046f018..0000000 --- a/test/unit/pixi-v2/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/loaders/ImageLoader.js b/test/unit/pixi-v2/loaders/ImageLoader.js deleted file mode 100644 index 8b1f556..0000000 --- a/test/unit/pixi-v2/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/loaders/JsonLoader.js b/test/unit/pixi-v2/loaders/JsonLoader.js deleted file mode 100644 index c577e83..0000000 --- a/test/unit/pixi-v2/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/loaders/SpineLoader.js b/test/unit/pixi-v2/loaders/SpineLoader.js deleted file mode 100644 index fdcc0b8..0000000 --- a/test/unit/pixi-v2/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/loaders/SpriteSheetLoader.js b/test/unit/pixi-v2/loaders/SpriteSheetLoader.js deleted file mode 100644 index 57beb27..0000000 --- a/test/unit/pixi-v2/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/primitives/Graphics.js b/test/unit/pixi-v2/primitives/Graphics.js deleted file mode 100644 index f3849eb..0000000 --- a/test/unit/pixi-v2/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/renderers/canvas/CanvasGraphics.js b/test/unit/pixi-v2/renderers/canvas/CanvasGraphics.js deleted file mode 100644 index 8f44472..0000000 --- a/test/unit/pixi-v2/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/renderers/canvas/CanvasRenderer.js b/test/unit/pixi-v2/renderers/canvas/CanvasRenderer.js deleted file mode 100644 index 1646444..0000000 --- a/test/unit/pixi-v2/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/renderers/webgl/WebGLGraphics.js b/test/unit/pixi-v2/renderers/webgl/WebGLGraphics.js deleted file mode 100644 index 5867b28..0000000 --- a/test/unit/pixi-v2/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/renderers/webgl/WebGLRenderer.js b/test/unit/pixi-v2/renderers/webgl/WebGLRenderer.js deleted file mode 100644 index 1680a80..0000000 --- a/test/unit/pixi-v2/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/renderers/webgl/WebGLShaders.js b/test/unit/pixi-v2/renderers/webgl/WebGLShaders.js deleted file mode 100644 index 6e33e4f..0000000 --- a/test/unit/pixi-v2/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/renderers/webgl/WebGLSpriteBatch.js b/test/unit/pixi-v2/renderers/webgl/WebGLSpriteBatch.js deleted file mode 100644 index e662b63..0000000 --- a/test/unit/pixi-v2/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/text/BitmapText.js b/test/unit/pixi-v2/text/BitmapText.js deleted file mode 100644 index 9388e3d..0000000 --- a/test/unit/pixi-v2/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/text/Text.js b/test/unit/pixi-v2/text/Text.js deleted file mode 100644 index 9bc9ac5..0000000 --- a/test/unit/pixi-v2/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/textures/BaseTexture.js b/test/unit/pixi-v2/textures/BaseTexture.js deleted file mode 100644 index 502b724..0000000 --- a/test/unit/pixi-v2/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/textures/RenderTexture.js b/test/unit/pixi-v2/textures/RenderTexture.js deleted file mode 100644 index 96acdb4..0000000 --- a/test/unit/pixi-v2/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/textures/Texture.js b/test/unit/pixi-v2/textures/Texture.js deleted file mode 100644 index 090f64d..0000000 --- a/test/unit/pixi-v2/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/package.json b/package.json index 6fc5290..ce76d2f 100644 --- a/package.json +++ b/package.json @@ -16,7 +16,7 @@ "url": "https://github.com/GoodBoyDigital/pixi.js.git" }, "scripts": { - "test": "gulp test", + "test": "gulp && testem ci", "docs": "jsdoc -c ./gulp/util/jsdoc.conf.json -R README.md" }, "dependencies": { @@ -45,16 +45,11 @@ "ink-docstrap": "git+https://github.com/Pilatch/docstrap.git", "jsdoc": "^3.3.0-alpha13", "jshint-summary": "^0.4.0", - "karma": "^0.12.28", - "karma-browserify": "^4.0.0", - "karma-chai": "^0.1.0", - "karma-firefox-launcher": "^0.1.0", - "karma-mocha": "^0.1.10", - "karma-spec-reporter": "^0.0.16", "minimist": "^1.1.1", "mocha": "^2.1.0", "require-dir": "^0.3.0", "run-sequence": "^1.0.2", + "testem": "^0.8.2", "vinyl-buffer": "^1.0.0", "vinyl-source-stream": "^1.1.0", "watchify": "^3.1.1" diff --git a/test/functional/example-1-basics/bunny.png b/test/functional/example-1-basics/bunny.png deleted file mode 100644 index 79c3167..0000000 --- a/test/functional/example-1-basics/bunny.png +++ /dev/null Binary files differ diff --git a/test/functional/example-1-basics/frame-30.png b/test/functional/example-1-basics/frame-30.png deleted file mode 100644 index 96e3409..0000000 --- a/test/functional/example-1-basics/frame-30.png +++ /dev/null Binary files differ diff --git a/test/functional/example-1-basics/frame-60.png b/test/functional/example-1-basics/frame-60.png deleted file mode 100644 index af3f4ce..0000000 --- a/test/functional/example-1-basics/frame-60.png +++ /dev/null Binary files differ diff --git a/test/functional/example-1-basics/frame-90.png b/test/functional/example-1-basics/frame-90.png deleted file mode 100644 index 099b823..0000000 --- a/test/functional/example-1-basics/frame-90.png +++ /dev/null Binary files differ diff --git a/test/functional/example-1-basics/index.js b/test/functional/example-1-basics/index.js deleted file mode 100644 index 2ad32bd..0000000 --- a/test/functional/example-1-basics/index.js +++ /dev/null @@ -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(''); - 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(''); - 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(''); - 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); - // }); - // }); -}); diff --git a/test/setup.js b/test/setup.js new file mode 100644 index 0000000..69e1b7a --- /dev/null +++ b/test/setup.js @@ -0,0 +1 @@ +expect = chai.expect; diff --git a/test/unit/bin/pixi.js b/test/unit/bin/pixi.js deleted file mode 100644 index 077cd88..0000000 --- a/test/unit/bin/pixi.js +++ /dev/null @@ -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'); - //}); -}); diff --git a/test/unit/core/utils/util.test.js b/test/unit/core/utils/util.test.js new file mode 100644 index 0000000..30c63f3 --- /dev/null +++ b/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'); + }); + }); +}); diff --git a/test/unit/index.test.js b/test/unit/index.test.js new file mode 100644 index 0000000..37e1d2a --- /dev/null +++ b/test/unit/index.test.js @@ -0,0 +1,6 @@ +describe('PIXI', function () { + it('exists', function () { + expect(PIXI) + .to.be.an('object'); + }); +}); diff --git a/test/unit/pixi-v2/InteractionManager.js b/test/unit/pixi-v2/InteractionManager.js deleted file mode 100644 index ed3001f..0000000 --- a/test/unit/pixi-v2/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/Pixi.js b/test/unit/pixi-v2/Pixi.js deleted file mode 100644 index 27debc1..0000000 --- a/test/unit/pixi-v2/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/core/Circle.js b/test/unit/pixi-v2/core/Circle.js deleted file mode 100644 index fbcfa17..0000000 --- a/test/unit/pixi-v2/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/core/Ellipse.js b/test/unit/pixi-v2/core/Ellipse.js deleted file mode 100644 index 026b56f..0000000 --- a/test/unit/pixi-v2/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/core/Matrix.js b/test/unit/pixi-v2/core/Matrix.js deleted file mode 100644 index da75e2e..0000000 --- a/test/unit/pixi-v2/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/core/Point.js b/test/unit/pixi-v2/core/Point.js deleted file mode 100644 index c4d5163..0000000 --- a/test/unit/pixi-v2/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/core/Polygon.js b/test/unit/pixi-v2/core/Polygon.js deleted file mode 100644 index dc8c918..0000000 --- a/test/unit/pixi-v2/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/core/Rectangle.js b/test/unit/pixi-v2/core/Rectangle.js deleted file mode 100644 index d43316e..0000000 --- a/test/unit/pixi-v2/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/display/DisplayObject.js b/test/unit/pixi-v2/display/DisplayObject.js deleted file mode 100644 index 044acf8..0000000 --- a/test/unit/pixi-v2/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/display/DisplayObjectContainer.js b/test/unit/pixi-v2/display/DisplayObjectContainer.js deleted file mode 100644 index 15a3376..0000000 --- a/test/unit/pixi-v2/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/display/MovieClip.js b/test/unit/pixi-v2/display/MovieClip.js deleted file mode 100644 index f3c6c6a..0000000 --- a/test/unit/pixi-v2/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/display/Sprite.js b/test/unit/pixi-v2/display/Sprite.js deleted file mode 100644 index 30c8076..0000000 --- a/test/unit/pixi-v2/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/display/Stage.js b/test/unit/pixi-v2/display/Stage.js deleted file mode 100644 index 6974c2e..0000000 --- a/test/unit/pixi-v2/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/extras/Rope.js b/test/unit/pixi-v2/extras/Rope.js deleted file mode 100644 index 05885ac..0000000 --- a/test/unit/pixi-v2/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/extras/Spine.js b/test/unit/pixi-v2/extras/Spine.js deleted file mode 100644 index 0708bc0..0000000 --- a/test/unit/pixi-v2/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/extras/Strip.js b/test/unit/pixi-v2/extras/Strip.js deleted file mode 100644 index 230af90..0000000 --- a/test/unit/pixi-v2/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/extras/TilingSprite.js b/test/unit/pixi-v2/extras/TilingSprite.js deleted file mode 100644 index 56aea14..0000000 --- a/test/unit/pixi-v2/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/filters/FilterBlock.js b/test/unit/pixi-v2/filters/FilterBlock.js deleted file mode 100644 index 870cec0..0000000 --- a/test/unit/pixi-v2/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/loaders/AssetLoader.js b/test/unit/pixi-v2/loaders/AssetLoader.js deleted file mode 100644 index a0aa0b5..0000000 --- a/test/unit/pixi-v2/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/loaders/BitmapFontLoader.js b/test/unit/pixi-v2/loaders/BitmapFontLoader.js deleted file mode 100644 index 046f018..0000000 --- a/test/unit/pixi-v2/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/loaders/ImageLoader.js b/test/unit/pixi-v2/loaders/ImageLoader.js deleted file mode 100644 index 8b1f556..0000000 --- a/test/unit/pixi-v2/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/loaders/JsonLoader.js b/test/unit/pixi-v2/loaders/JsonLoader.js deleted file mode 100644 index c577e83..0000000 --- a/test/unit/pixi-v2/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/loaders/SpineLoader.js b/test/unit/pixi-v2/loaders/SpineLoader.js deleted file mode 100644 index fdcc0b8..0000000 --- a/test/unit/pixi-v2/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/loaders/SpriteSheetLoader.js b/test/unit/pixi-v2/loaders/SpriteSheetLoader.js deleted file mode 100644 index 57beb27..0000000 --- a/test/unit/pixi-v2/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/primitives/Graphics.js b/test/unit/pixi-v2/primitives/Graphics.js deleted file mode 100644 index f3849eb..0000000 --- a/test/unit/pixi-v2/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/renderers/canvas/CanvasGraphics.js b/test/unit/pixi-v2/renderers/canvas/CanvasGraphics.js deleted file mode 100644 index 8f44472..0000000 --- a/test/unit/pixi-v2/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/renderers/canvas/CanvasRenderer.js b/test/unit/pixi-v2/renderers/canvas/CanvasRenderer.js deleted file mode 100644 index 1646444..0000000 --- a/test/unit/pixi-v2/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/renderers/webgl/WebGLGraphics.js b/test/unit/pixi-v2/renderers/webgl/WebGLGraphics.js deleted file mode 100644 index 5867b28..0000000 --- a/test/unit/pixi-v2/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/renderers/webgl/WebGLRenderer.js b/test/unit/pixi-v2/renderers/webgl/WebGLRenderer.js deleted file mode 100644 index 1680a80..0000000 --- a/test/unit/pixi-v2/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/renderers/webgl/WebGLShaders.js b/test/unit/pixi-v2/renderers/webgl/WebGLShaders.js deleted file mode 100644 index 6e33e4f..0000000 --- a/test/unit/pixi-v2/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/renderers/webgl/WebGLSpriteBatch.js b/test/unit/pixi-v2/renderers/webgl/WebGLSpriteBatch.js deleted file mode 100644 index e662b63..0000000 --- a/test/unit/pixi-v2/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/text/BitmapText.js b/test/unit/pixi-v2/text/BitmapText.js deleted file mode 100644 index 9388e3d..0000000 --- a/test/unit/pixi-v2/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/text/Text.js b/test/unit/pixi-v2/text/Text.js deleted file mode 100644 index 9bc9ac5..0000000 --- a/test/unit/pixi-v2/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/textures/BaseTexture.js b/test/unit/pixi-v2/textures/BaseTexture.js deleted file mode 100644 index 502b724..0000000 --- a/test/unit/pixi-v2/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/textures/RenderTexture.js b/test/unit/pixi-v2/textures/RenderTexture.js deleted file mode 100644 index 96acdb4..0000000 --- a/test/unit/pixi-v2/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/textures/Texture.js b/test/unit/pixi-v2/textures/Texture.js deleted file mode 100644 index 090f64d..0000000 --- a/test/unit/pixi-v2/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/utils/Detector.js b/test/unit/pixi-v2/utils/Detector.js deleted file mode 100644 index 4cf6008..0000000 --- a/test/unit/pixi-v2/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/package.json b/package.json index 6fc5290..ce76d2f 100644 --- a/package.json +++ b/package.json @@ -16,7 +16,7 @@ "url": "https://github.com/GoodBoyDigital/pixi.js.git" }, "scripts": { - "test": "gulp test", + "test": "gulp && testem ci", "docs": "jsdoc -c ./gulp/util/jsdoc.conf.json -R README.md" }, "dependencies": { @@ -45,16 +45,11 @@ "ink-docstrap": "git+https://github.com/Pilatch/docstrap.git", "jsdoc": "^3.3.0-alpha13", "jshint-summary": "^0.4.0", - "karma": "^0.12.28", - "karma-browserify": "^4.0.0", - "karma-chai": "^0.1.0", - "karma-firefox-launcher": "^0.1.0", - "karma-mocha": "^0.1.10", - "karma-spec-reporter": "^0.0.16", "minimist": "^1.1.1", "mocha": "^2.1.0", "require-dir": "^0.3.0", "run-sequence": "^1.0.2", + "testem": "^0.8.2", "vinyl-buffer": "^1.0.0", "vinyl-source-stream": "^1.1.0", "watchify": "^3.1.1" diff --git a/test/functional/example-1-basics/bunny.png b/test/functional/example-1-basics/bunny.png deleted file mode 100644 index 79c3167..0000000 --- a/test/functional/example-1-basics/bunny.png +++ /dev/null Binary files differ diff --git a/test/functional/example-1-basics/frame-30.png b/test/functional/example-1-basics/frame-30.png deleted file mode 100644 index 96e3409..0000000 --- a/test/functional/example-1-basics/frame-30.png +++ /dev/null Binary files differ diff --git a/test/functional/example-1-basics/frame-60.png b/test/functional/example-1-basics/frame-60.png deleted file mode 100644 index af3f4ce..0000000 --- a/test/functional/example-1-basics/frame-60.png +++ /dev/null Binary files differ diff --git a/test/functional/example-1-basics/frame-90.png b/test/functional/example-1-basics/frame-90.png deleted file mode 100644 index 099b823..0000000 --- a/test/functional/example-1-basics/frame-90.png +++ /dev/null Binary files differ diff --git a/test/functional/example-1-basics/index.js b/test/functional/example-1-basics/index.js deleted file mode 100644 index 2ad32bd..0000000 --- a/test/functional/example-1-basics/index.js +++ /dev/null @@ -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(''); - 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(''); - 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(''); - 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); - // }); - // }); -}); diff --git a/test/setup.js b/test/setup.js new file mode 100644 index 0000000..69e1b7a --- /dev/null +++ b/test/setup.js @@ -0,0 +1 @@ +expect = chai.expect; diff --git a/test/unit/bin/pixi.js b/test/unit/bin/pixi.js deleted file mode 100644 index 077cd88..0000000 --- a/test/unit/bin/pixi.js +++ /dev/null @@ -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'); - //}); -}); diff --git a/test/unit/core/utils/util.test.js b/test/unit/core/utils/util.test.js new file mode 100644 index 0000000..30c63f3 --- /dev/null +++ b/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'); + }); + }); +}); diff --git a/test/unit/index.test.js b/test/unit/index.test.js new file mode 100644 index 0000000..37e1d2a --- /dev/null +++ b/test/unit/index.test.js @@ -0,0 +1,6 @@ +describe('PIXI', function () { + it('exists', function () { + expect(PIXI) + .to.be.an('object'); + }); +}); diff --git a/test/unit/pixi-v2/InteractionManager.js b/test/unit/pixi-v2/InteractionManager.js deleted file mode 100644 index ed3001f..0000000 --- a/test/unit/pixi-v2/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/Pixi.js b/test/unit/pixi-v2/Pixi.js deleted file mode 100644 index 27debc1..0000000 --- a/test/unit/pixi-v2/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/core/Circle.js b/test/unit/pixi-v2/core/Circle.js deleted file mode 100644 index fbcfa17..0000000 --- a/test/unit/pixi-v2/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/core/Ellipse.js b/test/unit/pixi-v2/core/Ellipse.js deleted file mode 100644 index 026b56f..0000000 --- a/test/unit/pixi-v2/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/core/Matrix.js b/test/unit/pixi-v2/core/Matrix.js deleted file mode 100644 index da75e2e..0000000 --- a/test/unit/pixi-v2/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/core/Point.js b/test/unit/pixi-v2/core/Point.js deleted file mode 100644 index c4d5163..0000000 --- a/test/unit/pixi-v2/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/core/Polygon.js b/test/unit/pixi-v2/core/Polygon.js deleted file mode 100644 index dc8c918..0000000 --- a/test/unit/pixi-v2/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/core/Rectangle.js b/test/unit/pixi-v2/core/Rectangle.js deleted file mode 100644 index d43316e..0000000 --- a/test/unit/pixi-v2/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/display/DisplayObject.js b/test/unit/pixi-v2/display/DisplayObject.js deleted file mode 100644 index 044acf8..0000000 --- a/test/unit/pixi-v2/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/display/DisplayObjectContainer.js b/test/unit/pixi-v2/display/DisplayObjectContainer.js deleted file mode 100644 index 15a3376..0000000 --- a/test/unit/pixi-v2/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/display/MovieClip.js b/test/unit/pixi-v2/display/MovieClip.js deleted file mode 100644 index f3c6c6a..0000000 --- a/test/unit/pixi-v2/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/display/Sprite.js b/test/unit/pixi-v2/display/Sprite.js deleted file mode 100644 index 30c8076..0000000 --- a/test/unit/pixi-v2/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/display/Stage.js b/test/unit/pixi-v2/display/Stage.js deleted file mode 100644 index 6974c2e..0000000 --- a/test/unit/pixi-v2/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/extras/Rope.js b/test/unit/pixi-v2/extras/Rope.js deleted file mode 100644 index 05885ac..0000000 --- a/test/unit/pixi-v2/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/extras/Spine.js b/test/unit/pixi-v2/extras/Spine.js deleted file mode 100644 index 0708bc0..0000000 --- a/test/unit/pixi-v2/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/extras/Strip.js b/test/unit/pixi-v2/extras/Strip.js deleted file mode 100644 index 230af90..0000000 --- a/test/unit/pixi-v2/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/extras/TilingSprite.js b/test/unit/pixi-v2/extras/TilingSprite.js deleted file mode 100644 index 56aea14..0000000 --- a/test/unit/pixi-v2/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/filters/FilterBlock.js b/test/unit/pixi-v2/filters/FilterBlock.js deleted file mode 100644 index 870cec0..0000000 --- a/test/unit/pixi-v2/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/loaders/AssetLoader.js b/test/unit/pixi-v2/loaders/AssetLoader.js deleted file mode 100644 index a0aa0b5..0000000 --- a/test/unit/pixi-v2/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/loaders/BitmapFontLoader.js b/test/unit/pixi-v2/loaders/BitmapFontLoader.js deleted file mode 100644 index 046f018..0000000 --- a/test/unit/pixi-v2/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/loaders/ImageLoader.js b/test/unit/pixi-v2/loaders/ImageLoader.js deleted file mode 100644 index 8b1f556..0000000 --- a/test/unit/pixi-v2/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/loaders/JsonLoader.js b/test/unit/pixi-v2/loaders/JsonLoader.js deleted file mode 100644 index c577e83..0000000 --- a/test/unit/pixi-v2/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/loaders/SpineLoader.js b/test/unit/pixi-v2/loaders/SpineLoader.js deleted file mode 100644 index fdcc0b8..0000000 --- a/test/unit/pixi-v2/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/loaders/SpriteSheetLoader.js b/test/unit/pixi-v2/loaders/SpriteSheetLoader.js deleted file mode 100644 index 57beb27..0000000 --- a/test/unit/pixi-v2/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/primitives/Graphics.js b/test/unit/pixi-v2/primitives/Graphics.js deleted file mode 100644 index f3849eb..0000000 --- a/test/unit/pixi-v2/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/renderers/canvas/CanvasGraphics.js b/test/unit/pixi-v2/renderers/canvas/CanvasGraphics.js deleted file mode 100644 index 8f44472..0000000 --- a/test/unit/pixi-v2/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/renderers/canvas/CanvasRenderer.js b/test/unit/pixi-v2/renderers/canvas/CanvasRenderer.js deleted file mode 100644 index 1646444..0000000 --- a/test/unit/pixi-v2/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/renderers/webgl/WebGLGraphics.js b/test/unit/pixi-v2/renderers/webgl/WebGLGraphics.js deleted file mode 100644 index 5867b28..0000000 --- a/test/unit/pixi-v2/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/renderers/webgl/WebGLRenderer.js b/test/unit/pixi-v2/renderers/webgl/WebGLRenderer.js deleted file mode 100644 index 1680a80..0000000 --- a/test/unit/pixi-v2/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/renderers/webgl/WebGLShaders.js b/test/unit/pixi-v2/renderers/webgl/WebGLShaders.js deleted file mode 100644 index 6e33e4f..0000000 --- a/test/unit/pixi-v2/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/renderers/webgl/WebGLSpriteBatch.js b/test/unit/pixi-v2/renderers/webgl/WebGLSpriteBatch.js deleted file mode 100644 index e662b63..0000000 --- a/test/unit/pixi-v2/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/text/BitmapText.js b/test/unit/pixi-v2/text/BitmapText.js deleted file mode 100644 index 9388e3d..0000000 --- a/test/unit/pixi-v2/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/text/Text.js b/test/unit/pixi-v2/text/Text.js deleted file mode 100644 index 9bc9ac5..0000000 --- a/test/unit/pixi-v2/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/textures/BaseTexture.js b/test/unit/pixi-v2/textures/BaseTexture.js deleted file mode 100644 index 502b724..0000000 --- a/test/unit/pixi-v2/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/textures/RenderTexture.js b/test/unit/pixi-v2/textures/RenderTexture.js deleted file mode 100644 index 96acdb4..0000000 --- a/test/unit/pixi-v2/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/textures/Texture.js b/test/unit/pixi-v2/textures/Texture.js deleted file mode 100644 index 090f64d..0000000 --- a/test/unit/pixi-v2/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/utils/Detector.js b/test/unit/pixi-v2/utils/Detector.js deleted file mode 100644 index 4cf6008..0000000 --- a/test/unit/pixi-v2/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/utils/EventTarget.js b/test/unit/pixi-v2/utils/EventTarget.js deleted file mode 100644 index 1cfc3a4..0000000 --- a/test/unit/pixi-v2/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/package.json b/package.json index 6fc5290..ce76d2f 100644 --- a/package.json +++ b/package.json @@ -16,7 +16,7 @@ "url": "https://github.com/GoodBoyDigital/pixi.js.git" }, "scripts": { - "test": "gulp test", + "test": "gulp && testem ci", "docs": "jsdoc -c ./gulp/util/jsdoc.conf.json -R README.md" }, "dependencies": { @@ -45,16 +45,11 @@ "ink-docstrap": "git+https://github.com/Pilatch/docstrap.git", "jsdoc": "^3.3.0-alpha13", "jshint-summary": "^0.4.0", - "karma": "^0.12.28", - "karma-browserify": "^4.0.0", - "karma-chai": "^0.1.0", - "karma-firefox-launcher": "^0.1.0", - "karma-mocha": "^0.1.10", - "karma-spec-reporter": "^0.0.16", "minimist": "^1.1.1", "mocha": "^2.1.0", "require-dir": "^0.3.0", "run-sequence": "^1.0.2", + "testem": "^0.8.2", "vinyl-buffer": "^1.0.0", "vinyl-source-stream": "^1.1.0", "watchify": "^3.1.1" diff --git a/test/functional/example-1-basics/bunny.png b/test/functional/example-1-basics/bunny.png deleted file mode 100644 index 79c3167..0000000 --- a/test/functional/example-1-basics/bunny.png +++ /dev/null Binary files differ diff --git a/test/functional/example-1-basics/frame-30.png b/test/functional/example-1-basics/frame-30.png deleted file mode 100644 index 96e3409..0000000 --- a/test/functional/example-1-basics/frame-30.png +++ /dev/null Binary files differ diff --git a/test/functional/example-1-basics/frame-60.png b/test/functional/example-1-basics/frame-60.png deleted file mode 100644 index af3f4ce..0000000 --- a/test/functional/example-1-basics/frame-60.png +++ /dev/null Binary files differ diff --git a/test/functional/example-1-basics/frame-90.png b/test/functional/example-1-basics/frame-90.png deleted file mode 100644 index 099b823..0000000 --- a/test/functional/example-1-basics/frame-90.png +++ /dev/null Binary files differ diff --git a/test/functional/example-1-basics/index.js b/test/functional/example-1-basics/index.js deleted file mode 100644 index 2ad32bd..0000000 --- a/test/functional/example-1-basics/index.js +++ /dev/null @@ -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(''); - 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(''); - 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(''); - 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); - // }); - // }); -}); diff --git a/test/setup.js b/test/setup.js new file mode 100644 index 0000000..69e1b7a --- /dev/null +++ b/test/setup.js @@ -0,0 +1 @@ +expect = chai.expect; diff --git a/test/unit/bin/pixi.js b/test/unit/bin/pixi.js deleted file mode 100644 index 077cd88..0000000 --- a/test/unit/bin/pixi.js +++ /dev/null @@ -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'); - //}); -}); diff --git a/test/unit/core/utils/util.test.js b/test/unit/core/utils/util.test.js new file mode 100644 index 0000000..30c63f3 --- /dev/null +++ b/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'); + }); + }); +}); diff --git a/test/unit/index.test.js b/test/unit/index.test.js new file mode 100644 index 0000000..37e1d2a --- /dev/null +++ b/test/unit/index.test.js @@ -0,0 +1,6 @@ +describe('PIXI', function () { + it('exists', function () { + expect(PIXI) + .to.be.an('object'); + }); +}); diff --git a/test/unit/pixi-v2/InteractionManager.js b/test/unit/pixi-v2/InteractionManager.js deleted file mode 100644 index ed3001f..0000000 --- a/test/unit/pixi-v2/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/Pixi.js b/test/unit/pixi-v2/Pixi.js deleted file mode 100644 index 27debc1..0000000 --- a/test/unit/pixi-v2/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/core/Circle.js b/test/unit/pixi-v2/core/Circle.js deleted file mode 100644 index fbcfa17..0000000 --- a/test/unit/pixi-v2/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/core/Ellipse.js b/test/unit/pixi-v2/core/Ellipse.js deleted file mode 100644 index 026b56f..0000000 --- a/test/unit/pixi-v2/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/core/Matrix.js b/test/unit/pixi-v2/core/Matrix.js deleted file mode 100644 index da75e2e..0000000 --- a/test/unit/pixi-v2/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/core/Point.js b/test/unit/pixi-v2/core/Point.js deleted file mode 100644 index c4d5163..0000000 --- a/test/unit/pixi-v2/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/core/Polygon.js b/test/unit/pixi-v2/core/Polygon.js deleted file mode 100644 index dc8c918..0000000 --- a/test/unit/pixi-v2/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/core/Rectangle.js b/test/unit/pixi-v2/core/Rectangle.js deleted file mode 100644 index d43316e..0000000 --- a/test/unit/pixi-v2/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/display/DisplayObject.js b/test/unit/pixi-v2/display/DisplayObject.js deleted file mode 100644 index 044acf8..0000000 --- a/test/unit/pixi-v2/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/display/DisplayObjectContainer.js b/test/unit/pixi-v2/display/DisplayObjectContainer.js deleted file mode 100644 index 15a3376..0000000 --- a/test/unit/pixi-v2/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/display/MovieClip.js b/test/unit/pixi-v2/display/MovieClip.js deleted file mode 100644 index f3c6c6a..0000000 --- a/test/unit/pixi-v2/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/display/Sprite.js b/test/unit/pixi-v2/display/Sprite.js deleted file mode 100644 index 30c8076..0000000 --- a/test/unit/pixi-v2/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/display/Stage.js b/test/unit/pixi-v2/display/Stage.js deleted file mode 100644 index 6974c2e..0000000 --- a/test/unit/pixi-v2/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/extras/Rope.js b/test/unit/pixi-v2/extras/Rope.js deleted file mode 100644 index 05885ac..0000000 --- a/test/unit/pixi-v2/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/extras/Spine.js b/test/unit/pixi-v2/extras/Spine.js deleted file mode 100644 index 0708bc0..0000000 --- a/test/unit/pixi-v2/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/extras/Strip.js b/test/unit/pixi-v2/extras/Strip.js deleted file mode 100644 index 230af90..0000000 --- a/test/unit/pixi-v2/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/extras/TilingSprite.js b/test/unit/pixi-v2/extras/TilingSprite.js deleted file mode 100644 index 56aea14..0000000 --- a/test/unit/pixi-v2/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/filters/FilterBlock.js b/test/unit/pixi-v2/filters/FilterBlock.js deleted file mode 100644 index 870cec0..0000000 --- a/test/unit/pixi-v2/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/loaders/AssetLoader.js b/test/unit/pixi-v2/loaders/AssetLoader.js deleted file mode 100644 index a0aa0b5..0000000 --- a/test/unit/pixi-v2/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/loaders/BitmapFontLoader.js b/test/unit/pixi-v2/loaders/BitmapFontLoader.js deleted file mode 100644 index 046f018..0000000 --- a/test/unit/pixi-v2/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/loaders/ImageLoader.js b/test/unit/pixi-v2/loaders/ImageLoader.js deleted file mode 100644 index 8b1f556..0000000 --- a/test/unit/pixi-v2/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/loaders/JsonLoader.js b/test/unit/pixi-v2/loaders/JsonLoader.js deleted file mode 100644 index c577e83..0000000 --- a/test/unit/pixi-v2/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/loaders/SpineLoader.js b/test/unit/pixi-v2/loaders/SpineLoader.js deleted file mode 100644 index fdcc0b8..0000000 --- a/test/unit/pixi-v2/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/loaders/SpriteSheetLoader.js b/test/unit/pixi-v2/loaders/SpriteSheetLoader.js deleted file mode 100644 index 57beb27..0000000 --- a/test/unit/pixi-v2/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/primitives/Graphics.js b/test/unit/pixi-v2/primitives/Graphics.js deleted file mode 100644 index f3849eb..0000000 --- a/test/unit/pixi-v2/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/renderers/canvas/CanvasGraphics.js b/test/unit/pixi-v2/renderers/canvas/CanvasGraphics.js deleted file mode 100644 index 8f44472..0000000 --- a/test/unit/pixi-v2/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/renderers/canvas/CanvasRenderer.js b/test/unit/pixi-v2/renderers/canvas/CanvasRenderer.js deleted file mode 100644 index 1646444..0000000 --- a/test/unit/pixi-v2/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/renderers/webgl/WebGLGraphics.js b/test/unit/pixi-v2/renderers/webgl/WebGLGraphics.js deleted file mode 100644 index 5867b28..0000000 --- a/test/unit/pixi-v2/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/renderers/webgl/WebGLRenderer.js b/test/unit/pixi-v2/renderers/webgl/WebGLRenderer.js deleted file mode 100644 index 1680a80..0000000 --- a/test/unit/pixi-v2/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/renderers/webgl/WebGLShaders.js b/test/unit/pixi-v2/renderers/webgl/WebGLShaders.js deleted file mode 100644 index 6e33e4f..0000000 --- a/test/unit/pixi-v2/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/renderers/webgl/WebGLSpriteBatch.js b/test/unit/pixi-v2/renderers/webgl/WebGLSpriteBatch.js deleted file mode 100644 index e662b63..0000000 --- a/test/unit/pixi-v2/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/text/BitmapText.js b/test/unit/pixi-v2/text/BitmapText.js deleted file mode 100644 index 9388e3d..0000000 --- a/test/unit/pixi-v2/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/text/Text.js b/test/unit/pixi-v2/text/Text.js deleted file mode 100644 index 9bc9ac5..0000000 --- a/test/unit/pixi-v2/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/textures/BaseTexture.js b/test/unit/pixi-v2/textures/BaseTexture.js deleted file mode 100644 index 502b724..0000000 --- a/test/unit/pixi-v2/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/textures/RenderTexture.js b/test/unit/pixi-v2/textures/RenderTexture.js deleted file mode 100644 index 96acdb4..0000000 --- a/test/unit/pixi-v2/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/textures/Texture.js b/test/unit/pixi-v2/textures/Texture.js deleted file mode 100644 index 090f64d..0000000 --- a/test/unit/pixi-v2/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/utils/Detector.js b/test/unit/pixi-v2/utils/Detector.js deleted file mode 100644 index 4cf6008..0000000 --- a/test/unit/pixi-v2/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/utils/EventTarget.js b/test/unit/pixi-v2/utils/EventTarget.js deleted file mode 100644 index 1cfc3a4..0000000 --- a/test/unit/pixi-v2/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/utils/Polyk.js b/test/unit/pixi-v2/utils/Polyk.js deleted file mode 100644 index dfc7128..0000000 --- a/test/unit/pixi-v2/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/package.json b/package.json index 6fc5290..ce76d2f 100644 --- a/package.json +++ b/package.json @@ -16,7 +16,7 @@ "url": "https://github.com/GoodBoyDigital/pixi.js.git" }, "scripts": { - "test": "gulp test", + "test": "gulp && testem ci", "docs": "jsdoc -c ./gulp/util/jsdoc.conf.json -R README.md" }, "dependencies": { @@ -45,16 +45,11 @@ "ink-docstrap": "git+https://github.com/Pilatch/docstrap.git", "jsdoc": "^3.3.0-alpha13", "jshint-summary": "^0.4.0", - "karma": "^0.12.28", - "karma-browserify": "^4.0.0", - "karma-chai": "^0.1.0", - "karma-firefox-launcher": "^0.1.0", - "karma-mocha": "^0.1.10", - "karma-spec-reporter": "^0.0.16", "minimist": "^1.1.1", "mocha": "^2.1.0", "require-dir": "^0.3.0", "run-sequence": "^1.0.2", + "testem": "^0.8.2", "vinyl-buffer": "^1.0.0", "vinyl-source-stream": "^1.1.0", "watchify": "^3.1.1" diff --git a/test/functional/example-1-basics/bunny.png b/test/functional/example-1-basics/bunny.png deleted file mode 100644 index 79c3167..0000000 --- a/test/functional/example-1-basics/bunny.png +++ /dev/null Binary files differ diff --git a/test/functional/example-1-basics/frame-30.png b/test/functional/example-1-basics/frame-30.png deleted file mode 100644 index 96e3409..0000000 --- a/test/functional/example-1-basics/frame-30.png +++ /dev/null Binary files differ diff --git a/test/functional/example-1-basics/frame-60.png b/test/functional/example-1-basics/frame-60.png deleted file mode 100644 index af3f4ce..0000000 --- a/test/functional/example-1-basics/frame-60.png +++ /dev/null Binary files differ diff --git a/test/functional/example-1-basics/frame-90.png b/test/functional/example-1-basics/frame-90.png deleted file mode 100644 index 099b823..0000000 --- a/test/functional/example-1-basics/frame-90.png +++ /dev/null Binary files differ diff --git a/test/functional/example-1-basics/index.js b/test/functional/example-1-basics/index.js deleted file mode 100644 index 2ad32bd..0000000 --- a/test/functional/example-1-basics/index.js +++ /dev/null @@ -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(''); - 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(''); - 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(''); - 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); - // }); - // }); -}); diff --git a/test/setup.js b/test/setup.js new file mode 100644 index 0000000..69e1b7a --- /dev/null +++ b/test/setup.js @@ -0,0 +1 @@ +expect = chai.expect; diff --git a/test/unit/bin/pixi.js b/test/unit/bin/pixi.js deleted file mode 100644 index 077cd88..0000000 --- a/test/unit/bin/pixi.js +++ /dev/null @@ -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'); - //}); -}); diff --git a/test/unit/core/utils/util.test.js b/test/unit/core/utils/util.test.js new file mode 100644 index 0000000..30c63f3 --- /dev/null +++ b/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'); + }); + }); +}); diff --git a/test/unit/index.test.js b/test/unit/index.test.js new file mode 100644 index 0000000..37e1d2a --- /dev/null +++ b/test/unit/index.test.js @@ -0,0 +1,6 @@ +describe('PIXI', function () { + it('exists', function () { + expect(PIXI) + .to.be.an('object'); + }); +}); diff --git a/test/unit/pixi-v2/InteractionManager.js b/test/unit/pixi-v2/InteractionManager.js deleted file mode 100644 index ed3001f..0000000 --- a/test/unit/pixi-v2/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/Pixi.js b/test/unit/pixi-v2/Pixi.js deleted file mode 100644 index 27debc1..0000000 --- a/test/unit/pixi-v2/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/core/Circle.js b/test/unit/pixi-v2/core/Circle.js deleted file mode 100644 index fbcfa17..0000000 --- a/test/unit/pixi-v2/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/core/Ellipse.js b/test/unit/pixi-v2/core/Ellipse.js deleted file mode 100644 index 026b56f..0000000 --- a/test/unit/pixi-v2/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/core/Matrix.js b/test/unit/pixi-v2/core/Matrix.js deleted file mode 100644 index da75e2e..0000000 --- a/test/unit/pixi-v2/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/core/Point.js b/test/unit/pixi-v2/core/Point.js deleted file mode 100644 index c4d5163..0000000 --- a/test/unit/pixi-v2/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/core/Polygon.js b/test/unit/pixi-v2/core/Polygon.js deleted file mode 100644 index dc8c918..0000000 --- a/test/unit/pixi-v2/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/core/Rectangle.js b/test/unit/pixi-v2/core/Rectangle.js deleted file mode 100644 index d43316e..0000000 --- a/test/unit/pixi-v2/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/display/DisplayObject.js b/test/unit/pixi-v2/display/DisplayObject.js deleted file mode 100644 index 044acf8..0000000 --- a/test/unit/pixi-v2/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/display/DisplayObjectContainer.js b/test/unit/pixi-v2/display/DisplayObjectContainer.js deleted file mode 100644 index 15a3376..0000000 --- a/test/unit/pixi-v2/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/display/MovieClip.js b/test/unit/pixi-v2/display/MovieClip.js deleted file mode 100644 index f3c6c6a..0000000 --- a/test/unit/pixi-v2/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/display/Sprite.js b/test/unit/pixi-v2/display/Sprite.js deleted file mode 100644 index 30c8076..0000000 --- a/test/unit/pixi-v2/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/display/Stage.js b/test/unit/pixi-v2/display/Stage.js deleted file mode 100644 index 6974c2e..0000000 --- a/test/unit/pixi-v2/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/extras/Rope.js b/test/unit/pixi-v2/extras/Rope.js deleted file mode 100644 index 05885ac..0000000 --- a/test/unit/pixi-v2/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/extras/Spine.js b/test/unit/pixi-v2/extras/Spine.js deleted file mode 100644 index 0708bc0..0000000 --- a/test/unit/pixi-v2/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/extras/Strip.js b/test/unit/pixi-v2/extras/Strip.js deleted file mode 100644 index 230af90..0000000 --- a/test/unit/pixi-v2/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/extras/TilingSprite.js b/test/unit/pixi-v2/extras/TilingSprite.js deleted file mode 100644 index 56aea14..0000000 --- a/test/unit/pixi-v2/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/filters/FilterBlock.js b/test/unit/pixi-v2/filters/FilterBlock.js deleted file mode 100644 index 870cec0..0000000 --- a/test/unit/pixi-v2/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/loaders/AssetLoader.js b/test/unit/pixi-v2/loaders/AssetLoader.js deleted file mode 100644 index a0aa0b5..0000000 --- a/test/unit/pixi-v2/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/loaders/BitmapFontLoader.js b/test/unit/pixi-v2/loaders/BitmapFontLoader.js deleted file mode 100644 index 046f018..0000000 --- a/test/unit/pixi-v2/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/loaders/ImageLoader.js b/test/unit/pixi-v2/loaders/ImageLoader.js deleted file mode 100644 index 8b1f556..0000000 --- a/test/unit/pixi-v2/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/loaders/JsonLoader.js b/test/unit/pixi-v2/loaders/JsonLoader.js deleted file mode 100644 index c577e83..0000000 --- a/test/unit/pixi-v2/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/loaders/SpineLoader.js b/test/unit/pixi-v2/loaders/SpineLoader.js deleted file mode 100644 index fdcc0b8..0000000 --- a/test/unit/pixi-v2/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/loaders/SpriteSheetLoader.js b/test/unit/pixi-v2/loaders/SpriteSheetLoader.js deleted file mode 100644 index 57beb27..0000000 --- a/test/unit/pixi-v2/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/primitives/Graphics.js b/test/unit/pixi-v2/primitives/Graphics.js deleted file mode 100644 index f3849eb..0000000 --- a/test/unit/pixi-v2/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/renderers/canvas/CanvasGraphics.js b/test/unit/pixi-v2/renderers/canvas/CanvasGraphics.js deleted file mode 100644 index 8f44472..0000000 --- a/test/unit/pixi-v2/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/renderers/canvas/CanvasRenderer.js b/test/unit/pixi-v2/renderers/canvas/CanvasRenderer.js deleted file mode 100644 index 1646444..0000000 --- a/test/unit/pixi-v2/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/renderers/webgl/WebGLGraphics.js b/test/unit/pixi-v2/renderers/webgl/WebGLGraphics.js deleted file mode 100644 index 5867b28..0000000 --- a/test/unit/pixi-v2/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/renderers/webgl/WebGLRenderer.js b/test/unit/pixi-v2/renderers/webgl/WebGLRenderer.js deleted file mode 100644 index 1680a80..0000000 --- a/test/unit/pixi-v2/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/renderers/webgl/WebGLShaders.js b/test/unit/pixi-v2/renderers/webgl/WebGLShaders.js deleted file mode 100644 index 6e33e4f..0000000 --- a/test/unit/pixi-v2/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/renderers/webgl/WebGLSpriteBatch.js b/test/unit/pixi-v2/renderers/webgl/WebGLSpriteBatch.js deleted file mode 100644 index e662b63..0000000 --- a/test/unit/pixi-v2/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/text/BitmapText.js b/test/unit/pixi-v2/text/BitmapText.js deleted file mode 100644 index 9388e3d..0000000 --- a/test/unit/pixi-v2/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/text/Text.js b/test/unit/pixi-v2/text/Text.js deleted file mode 100644 index 9bc9ac5..0000000 --- a/test/unit/pixi-v2/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/textures/BaseTexture.js b/test/unit/pixi-v2/textures/BaseTexture.js deleted file mode 100644 index 502b724..0000000 --- a/test/unit/pixi-v2/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/textures/RenderTexture.js b/test/unit/pixi-v2/textures/RenderTexture.js deleted file mode 100644 index 96acdb4..0000000 --- a/test/unit/pixi-v2/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/textures/Texture.js b/test/unit/pixi-v2/textures/Texture.js deleted file mode 100644 index 090f64d..0000000 --- a/test/unit/pixi-v2/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/utils/Detector.js b/test/unit/pixi-v2/utils/Detector.js deleted file mode 100644 index 4cf6008..0000000 --- a/test/unit/pixi-v2/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/utils/EventTarget.js b/test/unit/pixi-v2/utils/EventTarget.js deleted file mode 100644 index 1cfc3a4..0000000 --- a/test/unit/pixi-v2/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/utils/Polyk.js b/test/unit/pixi-v2/utils/Polyk.js deleted file mode 100644 index dfc7128..0000000 --- a/test/unit/pixi-v2/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/utils/Utils.js b/test/unit/pixi-v2/utils/Utils.js deleted file mode 100644 index c97b3c6..0000000 --- a/test/unit/pixi-v2/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'); - }); -}); diff --git a/package.json b/package.json index 6fc5290..ce76d2f 100644 --- a/package.json +++ b/package.json @@ -16,7 +16,7 @@ "url": "https://github.com/GoodBoyDigital/pixi.js.git" }, "scripts": { - "test": "gulp test", + "test": "gulp && testem ci", "docs": "jsdoc -c ./gulp/util/jsdoc.conf.json -R README.md" }, "dependencies": { @@ -45,16 +45,11 @@ "ink-docstrap": "git+https://github.com/Pilatch/docstrap.git", "jsdoc": "^3.3.0-alpha13", "jshint-summary": "^0.4.0", - "karma": "^0.12.28", - "karma-browserify": "^4.0.0", - "karma-chai": "^0.1.0", - "karma-firefox-launcher": "^0.1.0", - "karma-mocha": "^0.1.10", - "karma-spec-reporter": "^0.0.16", "minimist": "^1.1.1", "mocha": "^2.1.0", "require-dir": "^0.3.0", "run-sequence": "^1.0.2", + "testem": "^0.8.2", "vinyl-buffer": "^1.0.0", "vinyl-source-stream": "^1.1.0", "watchify": "^3.1.1" diff --git a/test/functional/example-1-basics/bunny.png b/test/functional/example-1-basics/bunny.png deleted file mode 100644 index 79c3167..0000000 --- a/test/functional/example-1-basics/bunny.png +++ /dev/null Binary files differ diff --git a/test/functional/example-1-basics/frame-30.png b/test/functional/example-1-basics/frame-30.png deleted file mode 100644 index 96e3409..0000000 --- a/test/functional/example-1-basics/frame-30.png +++ /dev/null Binary files differ diff --git a/test/functional/example-1-basics/frame-60.png b/test/functional/example-1-basics/frame-60.png deleted file mode 100644 index af3f4ce..0000000 --- a/test/functional/example-1-basics/frame-60.png +++ /dev/null Binary files differ diff --git a/test/functional/example-1-basics/frame-90.png b/test/functional/example-1-basics/frame-90.png deleted file mode 100644 index 099b823..0000000 --- a/test/functional/example-1-basics/frame-90.png +++ /dev/null Binary files differ diff --git a/test/functional/example-1-basics/index.js b/test/functional/example-1-basics/index.js deleted file mode 100644 index 2ad32bd..0000000 --- a/test/functional/example-1-basics/index.js +++ /dev/null @@ -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(''); - 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(''); - 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(''); - 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); - // }); - // }); -}); diff --git a/test/setup.js b/test/setup.js new file mode 100644 index 0000000..69e1b7a --- /dev/null +++ b/test/setup.js @@ -0,0 +1 @@ +expect = chai.expect; diff --git a/test/unit/bin/pixi.js b/test/unit/bin/pixi.js deleted file mode 100644 index 077cd88..0000000 --- a/test/unit/bin/pixi.js +++ /dev/null @@ -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'); - //}); -}); diff --git a/test/unit/core/utils/util.test.js b/test/unit/core/utils/util.test.js new file mode 100644 index 0000000..30c63f3 --- /dev/null +++ b/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'); + }); + }); +}); diff --git a/test/unit/index.test.js b/test/unit/index.test.js new file mode 100644 index 0000000..37e1d2a --- /dev/null +++ b/test/unit/index.test.js @@ -0,0 +1,6 @@ +describe('PIXI', function () { + it('exists', function () { + expect(PIXI) + .to.be.an('object'); + }); +}); diff --git a/test/unit/pixi-v2/InteractionManager.js b/test/unit/pixi-v2/InteractionManager.js deleted file mode 100644 index ed3001f..0000000 --- a/test/unit/pixi-v2/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/Pixi.js b/test/unit/pixi-v2/Pixi.js deleted file mode 100644 index 27debc1..0000000 --- a/test/unit/pixi-v2/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/core/Circle.js b/test/unit/pixi-v2/core/Circle.js deleted file mode 100644 index fbcfa17..0000000 --- a/test/unit/pixi-v2/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/core/Ellipse.js b/test/unit/pixi-v2/core/Ellipse.js deleted file mode 100644 index 026b56f..0000000 --- a/test/unit/pixi-v2/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/core/Matrix.js b/test/unit/pixi-v2/core/Matrix.js deleted file mode 100644 index da75e2e..0000000 --- a/test/unit/pixi-v2/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/core/Point.js b/test/unit/pixi-v2/core/Point.js deleted file mode 100644 index c4d5163..0000000 --- a/test/unit/pixi-v2/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/core/Polygon.js b/test/unit/pixi-v2/core/Polygon.js deleted file mode 100644 index dc8c918..0000000 --- a/test/unit/pixi-v2/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/core/Rectangle.js b/test/unit/pixi-v2/core/Rectangle.js deleted file mode 100644 index d43316e..0000000 --- a/test/unit/pixi-v2/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/display/DisplayObject.js b/test/unit/pixi-v2/display/DisplayObject.js deleted file mode 100644 index 044acf8..0000000 --- a/test/unit/pixi-v2/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/display/DisplayObjectContainer.js b/test/unit/pixi-v2/display/DisplayObjectContainer.js deleted file mode 100644 index 15a3376..0000000 --- a/test/unit/pixi-v2/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/display/MovieClip.js b/test/unit/pixi-v2/display/MovieClip.js deleted file mode 100644 index f3c6c6a..0000000 --- a/test/unit/pixi-v2/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/display/Sprite.js b/test/unit/pixi-v2/display/Sprite.js deleted file mode 100644 index 30c8076..0000000 --- a/test/unit/pixi-v2/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/display/Stage.js b/test/unit/pixi-v2/display/Stage.js deleted file mode 100644 index 6974c2e..0000000 --- a/test/unit/pixi-v2/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/extras/Rope.js b/test/unit/pixi-v2/extras/Rope.js deleted file mode 100644 index 05885ac..0000000 --- a/test/unit/pixi-v2/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/extras/Spine.js b/test/unit/pixi-v2/extras/Spine.js deleted file mode 100644 index 0708bc0..0000000 --- a/test/unit/pixi-v2/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/extras/Strip.js b/test/unit/pixi-v2/extras/Strip.js deleted file mode 100644 index 230af90..0000000 --- a/test/unit/pixi-v2/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/extras/TilingSprite.js b/test/unit/pixi-v2/extras/TilingSprite.js deleted file mode 100644 index 56aea14..0000000 --- a/test/unit/pixi-v2/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/filters/FilterBlock.js b/test/unit/pixi-v2/filters/FilterBlock.js deleted file mode 100644 index 870cec0..0000000 --- a/test/unit/pixi-v2/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/loaders/AssetLoader.js b/test/unit/pixi-v2/loaders/AssetLoader.js deleted file mode 100644 index a0aa0b5..0000000 --- a/test/unit/pixi-v2/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/loaders/BitmapFontLoader.js b/test/unit/pixi-v2/loaders/BitmapFontLoader.js deleted file mode 100644 index 046f018..0000000 --- a/test/unit/pixi-v2/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/loaders/ImageLoader.js b/test/unit/pixi-v2/loaders/ImageLoader.js deleted file mode 100644 index 8b1f556..0000000 --- a/test/unit/pixi-v2/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/loaders/JsonLoader.js b/test/unit/pixi-v2/loaders/JsonLoader.js deleted file mode 100644 index c577e83..0000000 --- a/test/unit/pixi-v2/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/loaders/SpineLoader.js b/test/unit/pixi-v2/loaders/SpineLoader.js deleted file mode 100644 index fdcc0b8..0000000 --- a/test/unit/pixi-v2/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/loaders/SpriteSheetLoader.js b/test/unit/pixi-v2/loaders/SpriteSheetLoader.js deleted file mode 100644 index 57beb27..0000000 --- a/test/unit/pixi-v2/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/primitives/Graphics.js b/test/unit/pixi-v2/primitives/Graphics.js deleted file mode 100644 index f3849eb..0000000 --- a/test/unit/pixi-v2/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/renderers/canvas/CanvasGraphics.js b/test/unit/pixi-v2/renderers/canvas/CanvasGraphics.js deleted file mode 100644 index 8f44472..0000000 --- a/test/unit/pixi-v2/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/renderers/canvas/CanvasRenderer.js b/test/unit/pixi-v2/renderers/canvas/CanvasRenderer.js deleted file mode 100644 index 1646444..0000000 --- a/test/unit/pixi-v2/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/renderers/webgl/WebGLGraphics.js b/test/unit/pixi-v2/renderers/webgl/WebGLGraphics.js deleted file mode 100644 index 5867b28..0000000 --- a/test/unit/pixi-v2/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/renderers/webgl/WebGLRenderer.js b/test/unit/pixi-v2/renderers/webgl/WebGLRenderer.js deleted file mode 100644 index 1680a80..0000000 --- a/test/unit/pixi-v2/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/renderers/webgl/WebGLShaders.js b/test/unit/pixi-v2/renderers/webgl/WebGLShaders.js deleted file mode 100644 index 6e33e4f..0000000 --- a/test/unit/pixi-v2/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/renderers/webgl/WebGLSpriteBatch.js b/test/unit/pixi-v2/renderers/webgl/WebGLSpriteBatch.js deleted file mode 100644 index e662b63..0000000 --- a/test/unit/pixi-v2/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/text/BitmapText.js b/test/unit/pixi-v2/text/BitmapText.js deleted file mode 100644 index 9388e3d..0000000 --- a/test/unit/pixi-v2/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/text/Text.js b/test/unit/pixi-v2/text/Text.js deleted file mode 100644 index 9bc9ac5..0000000 --- a/test/unit/pixi-v2/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/textures/BaseTexture.js b/test/unit/pixi-v2/textures/BaseTexture.js deleted file mode 100644 index 502b724..0000000 --- a/test/unit/pixi-v2/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/textures/RenderTexture.js b/test/unit/pixi-v2/textures/RenderTexture.js deleted file mode 100644 index 96acdb4..0000000 --- a/test/unit/pixi-v2/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/textures/Texture.js b/test/unit/pixi-v2/textures/Texture.js deleted file mode 100644 index 090f64d..0000000 --- a/test/unit/pixi-v2/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/utils/Detector.js b/test/unit/pixi-v2/utils/Detector.js deleted file mode 100644 index 4cf6008..0000000 --- a/test/unit/pixi-v2/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/utils/EventTarget.js b/test/unit/pixi-v2/utils/EventTarget.js deleted file mode 100644 index 1cfc3a4..0000000 --- a/test/unit/pixi-v2/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/utils/Polyk.js b/test/unit/pixi-v2/utils/Polyk.js deleted file mode 100644 index dfc7128..0000000 --- a/test/unit/pixi-v2/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/utils/Utils.js b/test/unit/pixi-v2/utils/Utils.js deleted file mode 100644 index c97b3c6..0000000 --- a/test/unit/pixi-v2/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'); - }); -}); diff --git a/test/unit/src/index.js b/test/unit/src/index.js deleted file mode 100644 index 9a0c3b1..0000000 --- a/test/unit/src/index.js +++ /dev/null @@ -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'); - }); -}); diff --git a/package.json b/package.json index 6fc5290..ce76d2f 100644 --- a/package.json +++ b/package.json @@ -16,7 +16,7 @@ "url": "https://github.com/GoodBoyDigital/pixi.js.git" }, "scripts": { - "test": "gulp test", + "test": "gulp && testem ci", "docs": "jsdoc -c ./gulp/util/jsdoc.conf.json -R README.md" }, "dependencies": { @@ -45,16 +45,11 @@ "ink-docstrap": "git+https://github.com/Pilatch/docstrap.git", "jsdoc": "^3.3.0-alpha13", "jshint-summary": "^0.4.0", - "karma": "^0.12.28", - "karma-browserify": "^4.0.0", - "karma-chai": "^0.1.0", - "karma-firefox-launcher": "^0.1.0", - "karma-mocha": "^0.1.10", - "karma-spec-reporter": "^0.0.16", "minimist": "^1.1.1", "mocha": "^2.1.0", "require-dir": "^0.3.0", "run-sequence": "^1.0.2", + "testem": "^0.8.2", "vinyl-buffer": "^1.0.0", "vinyl-source-stream": "^1.1.0", "watchify": "^3.1.1" diff --git a/test/functional/example-1-basics/bunny.png b/test/functional/example-1-basics/bunny.png deleted file mode 100644 index 79c3167..0000000 --- a/test/functional/example-1-basics/bunny.png +++ /dev/null Binary files differ diff --git a/test/functional/example-1-basics/frame-30.png b/test/functional/example-1-basics/frame-30.png deleted file mode 100644 index 96e3409..0000000 --- a/test/functional/example-1-basics/frame-30.png +++ /dev/null Binary files differ diff --git a/test/functional/example-1-basics/frame-60.png b/test/functional/example-1-basics/frame-60.png deleted file mode 100644 index af3f4ce..0000000 --- a/test/functional/example-1-basics/frame-60.png +++ /dev/null Binary files differ diff --git a/test/functional/example-1-basics/frame-90.png b/test/functional/example-1-basics/frame-90.png deleted file mode 100644 index 099b823..0000000 --- a/test/functional/example-1-basics/frame-90.png +++ /dev/null Binary files differ diff --git a/test/functional/example-1-basics/index.js b/test/functional/example-1-basics/index.js deleted file mode 100644 index 2ad32bd..0000000 --- a/test/functional/example-1-basics/index.js +++ /dev/null @@ -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(''); - 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(''); - 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(''); - 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); - // }); - // }); -}); diff --git a/test/setup.js b/test/setup.js new file mode 100644 index 0000000..69e1b7a --- /dev/null +++ b/test/setup.js @@ -0,0 +1 @@ +expect = chai.expect; diff --git a/test/unit/bin/pixi.js b/test/unit/bin/pixi.js deleted file mode 100644 index 077cd88..0000000 --- a/test/unit/bin/pixi.js +++ /dev/null @@ -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'); - //}); -}); diff --git a/test/unit/core/utils/util.test.js b/test/unit/core/utils/util.test.js new file mode 100644 index 0000000..30c63f3 --- /dev/null +++ b/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'); + }); + }); +}); diff --git a/test/unit/index.test.js b/test/unit/index.test.js new file mode 100644 index 0000000..37e1d2a --- /dev/null +++ b/test/unit/index.test.js @@ -0,0 +1,6 @@ +describe('PIXI', function () { + it('exists', function () { + expect(PIXI) + .to.be.an('object'); + }); +}); diff --git a/test/unit/pixi-v2/InteractionManager.js b/test/unit/pixi-v2/InteractionManager.js deleted file mode 100644 index ed3001f..0000000 --- a/test/unit/pixi-v2/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/Pixi.js b/test/unit/pixi-v2/Pixi.js deleted file mode 100644 index 27debc1..0000000 --- a/test/unit/pixi-v2/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/core/Circle.js b/test/unit/pixi-v2/core/Circle.js deleted file mode 100644 index fbcfa17..0000000 --- a/test/unit/pixi-v2/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/core/Ellipse.js b/test/unit/pixi-v2/core/Ellipse.js deleted file mode 100644 index 026b56f..0000000 --- a/test/unit/pixi-v2/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/core/Matrix.js b/test/unit/pixi-v2/core/Matrix.js deleted file mode 100644 index da75e2e..0000000 --- a/test/unit/pixi-v2/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/core/Point.js b/test/unit/pixi-v2/core/Point.js deleted file mode 100644 index c4d5163..0000000 --- a/test/unit/pixi-v2/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/core/Polygon.js b/test/unit/pixi-v2/core/Polygon.js deleted file mode 100644 index dc8c918..0000000 --- a/test/unit/pixi-v2/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/core/Rectangle.js b/test/unit/pixi-v2/core/Rectangle.js deleted file mode 100644 index d43316e..0000000 --- a/test/unit/pixi-v2/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/display/DisplayObject.js b/test/unit/pixi-v2/display/DisplayObject.js deleted file mode 100644 index 044acf8..0000000 --- a/test/unit/pixi-v2/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/display/DisplayObjectContainer.js b/test/unit/pixi-v2/display/DisplayObjectContainer.js deleted file mode 100644 index 15a3376..0000000 --- a/test/unit/pixi-v2/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/display/MovieClip.js b/test/unit/pixi-v2/display/MovieClip.js deleted file mode 100644 index f3c6c6a..0000000 --- a/test/unit/pixi-v2/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/display/Sprite.js b/test/unit/pixi-v2/display/Sprite.js deleted file mode 100644 index 30c8076..0000000 --- a/test/unit/pixi-v2/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/display/Stage.js b/test/unit/pixi-v2/display/Stage.js deleted file mode 100644 index 6974c2e..0000000 --- a/test/unit/pixi-v2/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/extras/Rope.js b/test/unit/pixi-v2/extras/Rope.js deleted file mode 100644 index 05885ac..0000000 --- a/test/unit/pixi-v2/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/extras/Spine.js b/test/unit/pixi-v2/extras/Spine.js deleted file mode 100644 index 0708bc0..0000000 --- a/test/unit/pixi-v2/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/extras/Strip.js b/test/unit/pixi-v2/extras/Strip.js deleted file mode 100644 index 230af90..0000000 --- a/test/unit/pixi-v2/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/extras/TilingSprite.js b/test/unit/pixi-v2/extras/TilingSprite.js deleted file mode 100644 index 56aea14..0000000 --- a/test/unit/pixi-v2/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/filters/FilterBlock.js b/test/unit/pixi-v2/filters/FilterBlock.js deleted file mode 100644 index 870cec0..0000000 --- a/test/unit/pixi-v2/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/loaders/AssetLoader.js b/test/unit/pixi-v2/loaders/AssetLoader.js deleted file mode 100644 index a0aa0b5..0000000 --- a/test/unit/pixi-v2/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/loaders/BitmapFontLoader.js b/test/unit/pixi-v2/loaders/BitmapFontLoader.js deleted file mode 100644 index 046f018..0000000 --- a/test/unit/pixi-v2/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/loaders/ImageLoader.js b/test/unit/pixi-v2/loaders/ImageLoader.js deleted file mode 100644 index 8b1f556..0000000 --- a/test/unit/pixi-v2/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/loaders/JsonLoader.js b/test/unit/pixi-v2/loaders/JsonLoader.js deleted file mode 100644 index c577e83..0000000 --- a/test/unit/pixi-v2/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/loaders/SpineLoader.js b/test/unit/pixi-v2/loaders/SpineLoader.js deleted file mode 100644 index fdcc0b8..0000000 --- a/test/unit/pixi-v2/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/loaders/SpriteSheetLoader.js b/test/unit/pixi-v2/loaders/SpriteSheetLoader.js deleted file mode 100644 index 57beb27..0000000 --- a/test/unit/pixi-v2/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/primitives/Graphics.js b/test/unit/pixi-v2/primitives/Graphics.js deleted file mode 100644 index f3849eb..0000000 --- a/test/unit/pixi-v2/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/renderers/canvas/CanvasGraphics.js b/test/unit/pixi-v2/renderers/canvas/CanvasGraphics.js deleted file mode 100644 index 8f44472..0000000 --- a/test/unit/pixi-v2/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/renderers/canvas/CanvasRenderer.js b/test/unit/pixi-v2/renderers/canvas/CanvasRenderer.js deleted file mode 100644 index 1646444..0000000 --- a/test/unit/pixi-v2/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/renderers/webgl/WebGLGraphics.js b/test/unit/pixi-v2/renderers/webgl/WebGLGraphics.js deleted file mode 100644 index 5867b28..0000000 --- a/test/unit/pixi-v2/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/renderers/webgl/WebGLRenderer.js b/test/unit/pixi-v2/renderers/webgl/WebGLRenderer.js deleted file mode 100644 index 1680a80..0000000 --- a/test/unit/pixi-v2/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/renderers/webgl/WebGLShaders.js b/test/unit/pixi-v2/renderers/webgl/WebGLShaders.js deleted file mode 100644 index 6e33e4f..0000000 --- a/test/unit/pixi-v2/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/renderers/webgl/WebGLSpriteBatch.js b/test/unit/pixi-v2/renderers/webgl/WebGLSpriteBatch.js deleted file mode 100644 index e662b63..0000000 --- a/test/unit/pixi-v2/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/text/BitmapText.js b/test/unit/pixi-v2/text/BitmapText.js deleted file mode 100644 index 9388e3d..0000000 --- a/test/unit/pixi-v2/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/text/Text.js b/test/unit/pixi-v2/text/Text.js deleted file mode 100644 index 9bc9ac5..0000000 --- a/test/unit/pixi-v2/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/textures/BaseTexture.js b/test/unit/pixi-v2/textures/BaseTexture.js deleted file mode 100644 index 502b724..0000000 --- a/test/unit/pixi-v2/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/textures/RenderTexture.js b/test/unit/pixi-v2/textures/RenderTexture.js deleted file mode 100644 index 96acdb4..0000000 --- a/test/unit/pixi-v2/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/textures/Texture.js b/test/unit/pixi-v2/textures/Texture.js deleted file mode 100644 index 090f64d..0000000 --- a/test/unit/pixi-v2/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/utils/Detector.js b/test/unit/pixi-v2/utils/Detector.js deleted file mode 100644 index 4cf6008..0000000 --- a/test/unit/pixi-v2/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/utils/EventTarget.js b/test/unit/pixi-v2/utils/EventTarget.js deleted file mode 100644 index 1cfc3a4..0000000 --- a/test/unit/pixi-v2/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/utils/Polyk.js b/test/unit/pixi-v2/utils/Polyk.js deleted file mode 100644 index dfc7128..0000000 --- a/test/unit/pixi-v2/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/utils/Utils.js b/test/unit/pixi-v2/utils/Utils.js deleted file mode 100644 index c97b3c6..0000000 --- a/test/unit/pixi-v2/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'); - }); -}); diff --git a/test/unit/src/index.js b/test/unit/src/index.js deleted file mode 100644 index 9a0c3b1..0000000 --- a/test/unit/src/index.js +++ /dev/null @@ -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'); - }); -}); diff --git a/testem.json b/testem.json new file mode 100644 index 0000000..84c76ef --- /dev/null +++ b/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" + } + } +}