diff --git a/Gruntfile.js b/Gruntfile.js index 3c05d5f14b..56efe1185f 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -241,7 +241,13 @@ module.exports = function (grunt) { pull : true } } + }, + + karma: { + unit: { + configFile: "karma.conf.js" } + } }); grunt.loadNpmTasks("grunt-contrib-clean"); @@ -253,6 +259,7 @@ module.exports = function (grunt) { grunt.loadNpmTasks("grunt-contrib-uglify"); grunt.loadNpmTasks("grunt-build-gh-pages"); grunt.loadNpmTasks("grunt-jsdoc"); + grunt.loadNpmTasks("grunt-karma"); grunt.loadNpmTasks("grunt-replace"); // Custom Tasks @@ -271,6 +278,7 @@ module.exports = function (grunt) { ]); grunt.registerTask("doc", [ "replace:docs", "jsdoc" ]); grunt.registerTask("test", [ "lint", "connect:server", "jasmine" ]); + grunt.registerTask("testChrome", [ "karma" ]); grunt.registerTask("serve", [ "connect:keepalive" ]); grunt.registerTask("gh-pages", [ "test", diff --git a/karma.conf.js b/karma.conf.js new file mode 100644 index 0000000000..7ef9b4ad87 --- /dev/null +++ b/karma.conf.js @@ -0,0 +1,25 @@ +module.exports = function(config) { + + var sourceFiles = require("./sourceFiles.json"); + var testSpecs = require("./testSpecs.json"); + + var files = sourceFiles.concat("tests/spec/helper-spec.js").concat(testSpecs); + var files = files.concat([{pattern: 'tests/data/**/*', watched: false, included: false, served: true}]); + + + config.set({ + + basePath: '', + + //test framework would be jasmine however other frameworks can be used + frameworks: ['jasmine'], + //all js files needed for tests to run order matters! e.g. do not load angular mocks before angular ect... + files: files, + + browsers: ['Chrome'], // You may use 'ChromeCanary', 'Chromium' or any other supported browser + proxies: { + "/tests/": "/base/tests/" + } + // you can define custom flags + }) +} \ No newline at end of file diff --git a/package.json b/package.json index edeb5936cb..26d1cfd19f 100644 --- a/package.json +++ b/package.json @@ -22,19 +22,23 @@ "dependencies": {}, "devDependencies": { "dot": "git+/~https://github.com/parasyte/doT.git#bug/replace-ext", - "grunt": "^0.4.5", + "grunt": "^1.0.1", "grunt-build-gh-pages": "^1.0.5", - "grunt-contrib-clean": "^1.0.0", + "grunt-contrib-clean": "^1.1.0", "grunt-contrib-concat": "^1.0.1", "grunt-contrib-connect": "^1.0.2", "grunt-contrib-copy": "^1.0.0", - "grunt-contrib-jasmine": "^1.0.3", - "grunt-eslint": "^19.0.0", - "grunt-contrib-uglify": "^1.0.1", - "grunt-jsdoc": "^1.1.0", + "grunt-contrib-jasmine": "^1.1.0", + "grunt-eslint": "^20.0.0", + "grunt-contrib-uglify": "^3.0.1", + "grunt-jsdoc": "^2.1.0", + "grunt-karma": "^2.0.0", "grunt-replace": "^1.0.1", "grunt-shell": "^2.1.0", + "karma-chrome-launcher": "2.2.0", "jasmine-core": "~2.5.2", + "karma": "^1.7.0", + "karma-jasmine": "^1.1.0", "q": "^1.4.1", "shelljs": "^0.5.3" }, diff --git a/src/renderable/renderable.js b/src/renderable/renderable.js index 6d1d684d1a..e0ca07ec18 100644 --- a/src/renderable/renderable.js +++ b/src/renderable/renderable.js @@ -269,7 +269,7 @@ if (typeof (alpha) === "number") { this.alpha = alpha.clamp(0.0, 1.0); // Set to 1 if alpha is NaN - if (this.alpha !== this.alpha) { + if (isNaN(this.alpha)) { this.alpha = 1.0; } }