diff --git a/.jscsrc b/.jscsrc new file mode 100644 index 0000000..a45edf4 --- /dev/null +++ b/.jscsrc @@ -0,0 +1,27 @@ +{ + "requireCurlyBraces": [ + "for", + "while", + "do", + "try", + "catch" + ], + "requireSpaceAfterKeywords": [ + "default" + ], + "requireSpacesInFunctionExpression": { + "beforeOpeningCurlyBrace": true + }, + "disallowSpacesInFunctionExpression": { + "beforeOpeningRoundBrace": true + }, + "disallowEmptyBlocks": true, + "disallowSpaceAfterObjectKeys": true, + "requireCommaBeforeLineBreak": true, + "disallowSpaceBeforePostfixUnaryOperators": ["++", "--"], + "disallowImplicitTypeConversion": ["numeric", "boolean", "binary", "string"], + "validateIndentation": 4, + "disallowMixedSpacesAndTabs": true, + "disallowTrailingWhitespace": true, + "safeContextKeyword": "self" +} \ No newline at end of file diff --git a/makefile b/makefile new file mode 100644 index 0000000..86730ca --- /dev/null +++ b/makefile @@ -0,0 +1,20 @@ +JSCS_PATH = ./node_modules/.bin/jscs +KARMA_PATH = ./node_modules/.bin/karma +KARMA_CONFIG = ./test/fixtures/karma.conf.js + +# Performs code governance (lint + style) test +lint: + @$(JSCS_PATH) ./js/* + @$(JSCS_PATH) ./test/unit/* + +# Performs unit tests +unit: + @$(KARMA_PATH) start $(KARMA_CONFIG) $* + +# Run all test targets +test: + @make lint + @make unit + +# Ignore directory structure +.PHONY: lint unit test \ No newline at end of file diff --git a/package.json b/package.json index 7a6ba49..9f9beb5 100644 --- a/package.json +++ b/package.json @@ -2,10 +2,15 @@ "name": "scratch-html5", "description": "HTML 5 based Scratch project player", "repository": "https://github.com/LLK/scratch-html5", + "scripts": { + "test": "make test" + }, + "dependencies": {}, "devDependencies": { - "karma" : "~0.10", - "jasmine-jquery" : "1.3.3", - "karma-html2js-preprocessor" : "~0.1.0", - "underscore" : "~1.6.0" + "jasmine-jquery": "~1.3.3", + "jscs": "~1.3.0", + "karma": "~0.10", + "karma-html2js-preprocessor": "~0.1.0", + "underscore": "~1.6.0" } } diff --git a/scripts/test.sh b/scripts/test.sh deleted file mode 100755 index 972001f..0000000 --- a/scripts/test.sh +++ /dev/null @@ -1,9 +0,0 @@ -#!/bin/bash - -BASE_DIR=`dirname $0` - -echo "" -echo "Starting Karma Server (http://karma-runner.github.io)" -echo "-------------------------------------------------------------------" - -$BASE_DIR/../node_modules/karma/bin/karma start $BASE_DIR/../config/karma.conf.js $* diff --git a/config/karma.conf.js b/test/fixtures/karma.conf.js similarity index 96% rename from config/karma.conf.js rename to test/fixtures/karma.conf.js index 5c66717..ed8d99b 100644 --- a/config/karma.conf.js +++ b/test/fixtures/karma.conf.js @@ -1,6 +1,6 @@ module.exports = function(config){ config.set({ - basePath : '../', + basePath : '../../', files : [ 'test/artifacts/**/*.js',