diff --git a/CruftEngine.sublime-workspace b/CruftEngine.sublime-workspace index 92e1b27..b6e55ed 100644 --- a/CruftEngine.sublime-workspace +++ b/CruftEngine.sublime-workspace @@ -15,14 +15,6 @@ }, "buffers": [ - { - "file": "index.js", - "settings": - { - "buffer_size": 0, - "line_ending": "Unix" - } - }, { "contents": "", "file": "Gulpfile.js", @@ -34,35 +26,24 @@ "line_ending": "Unix" } }, - { - "file": "game/TESTFILE.json", - "settings": - { - "buffer_size": 0, - "line_ending": "Unix" - } - }, - { - "file": "game/index.html", - "settings": - { - "buffer_size": 0, - "line_ending": "Unix" - } - }, { "file": "package.json", "settings": { - "buffer_size": 0, + "buffer_size": 891, "line_ending": "Unix" } } ], "build_system": "", + "build_system_choices": + [ + ], + "build_varint": "", "command_palette": { "height": 102.0, + "last_filter": "", "selected_items": [ [ @@ -78,7 +59,11 @@ }, "console": { - "height": 132.0 + "height": 132.0, + "history": + [ + "import urllib.request,os,hashlib; h = 'eb2297e1a458f27d836c04bb0cbaf282' + 'd0e7a3098092775ccb37ca9d6b2e4b7d'; pf = 'Package Control.sublime-package'; ipp = sublime.installed_packages_path(); urllib.request.install_opener( urllib.request.build_opener( urllib.request.ProxyHandler()) ); by = urllib.request.urlopen( 'http://packagecontrol.io/' + pf.replace(' ', '%20')).read(); dh = hashlib.sha256(by).hexdigest(); print('Error validating download (got %s instead of %s), please try manual install' % (dh, h)) if dh != h else open(os.path.join( ipp, pf), 'wb' ).write(by)" + ] }, "distraction_free": { @@ -91,6 +76,9 @@ }, "file_history": [ + "/C/cygwin64/home/Matthew/CruftEngine/game/index.html", + "/C/cygwin64/home/Matthew/CruftEngine/game/TESTFILE.json", + "/C/cygwin64/home/Matthew/CruftEngine/index.js", "/home/yusef/Documents/dev/cruft/game/engine/package.json", "/home/yusef/Documents/dev/cruft/game/engine/core/http.js", "/home/yusef/Documents/dev/cruft/game/engine/core/Cache.js", @@ -150,38 +138,13 @@ "groups": [ { - "selected": 1, + "selected": 0, "sheets": [ { "buffer": 0, - "file": "index.js", - "settings": - { - "buffer_size": 0, - "regions": - { - }, - "selection": - [ - [ - 0, - 0 - ] - ], - "settings": - { - "syntax": "Packages/JavaScript/JavaScript.tmLanguage" - }, - "translation.x": 0.0, - "translation.y": 0.0, - "zoom_level": 1.0 - }, - "type": "text" - }, - { - "buffer": 1, "file": "Gulpfile.js", + "semi_transient": false, "settings": { "buffer_size": 0, @@ -203,66 +166,16 @@ "translation.y": 0.0, "zoom_level": 1.0 }, + "stack_index": 0, "type": "text" }, { - "buffer": 2, - "file": "game/TESTFILE.json", - "settings": - { - "buffer_size": 0, - "regions": - { - }, - "selection": - [ - [ - 0, - 0 - ] - ], - "settings": - { - "syntax": "Packages/JavaScript/JSON.tmLanguage" - }, - "translation.x": 0.0, - "translation.y": 0.0, - "zoom_level": 1.0 - }, - "type": "text" - }, - { - "buffer": 3, - "file": "game/index.html", - "settings": - { - "buffer_size": 0, - "regions": - { - }, - "selection": - [ - [ - 0, - 0 - ] - ], - "settings": - { - "syntax": "Packages/HTML/HTML.tmLanguage" - }, - "translation.x": 0.0, - "translation.y": 0.0, - "zoom_level": 1.0 - }, - "type": "text" - }, - { - "buffer": 4, + "buffer": 1, "file": "package.json", + "semi_transient": false, "settings": { - "buffer_size": 0, + "buffer_size": 891, "regions": { }, @@ -283,6 +196,7 @@ "translation.y": 0.0, "zoom_level": 1.0 }, + "stack_index": 1, "type": "text" } ] @@ -319,6 +233,12 @@ ] }, "menu_visible": true, + "output.find_results": + { + "height": 0.0 + }, + "pinned_build_system": "", + "project": "CruftEngine.sublime-project", "replace": { "height": 0.0 @@ -327,6 +247,7 @@ "select_file": { "height": 0.0, + "last_filter": "", "selected_items": [ ], @@ -335,15 +256,32 @@ "select_project": { "height": 0.0, + "last_filter": "", + "selected_items": + [ + ], + "width": 0.0 + }, + "select_symbol": + { + "height": 0.0, + "last_filter": "", "selected_items": [ ], "width": 0.0 }, + "selected_group": 0, + "settings": + { + }, "show_minimap": true, "show_open_files": false, "show_tabs": true, "side_bar_visible": true, "side_bar_width": 150.0, - "status_bar_visible": true + "status_bar_visible": true, + "template_settings": + { + } } diff --git a/gulpfile.js b/gulpfile.js index a8259ed..8c63889 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -8,6 +8,7 @@ var gls = require('gulp-live-server'); var runSequence = require('run-sequence'); var cache = require('gulp-cached'); var server = gls.new("server.js"); +var karma = require('karma').Server; var ENGINE_SRC = ["engine/**/*.js"]; @@ -89,6 +90,13 @@ gulp.task("server", function () { server.start(); }) +gulp.task('test:single', function (done) { + new karma({ + configFile: __dirname + '/karma.conf.js', + singleRun: true + }, done).start(); +}); + //echo fs.inotify.max_user_watches=582222 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p gulp.task("default", function () { runSequence( diff --git a/karma.conf.js b/karma.conf.js new file mode 100755 index 0000000..0dbed68 --- /dev/null +++ b/karma.conf.js @@ -0,0 +1,90 @@ +// Karma configuration +// Generated on Sat Feb 20 2016 13:01:48 GMT-0600 (Central Standard Time) + +module.exports = function(config) { + config.set({ + + // base path that will be used to resolve all patterns (eg. files, exclude) + basePath: '', + + + // frameworks to use + // available frameworks: https://npmjs.org/browse/keyword/karma-adapter + frameworks: ['requirejs', 'traceur', 'jasmine'], + + + // list of files / patterns to load in the browser + files: [ + { pattern: 'engine/**/*.js', included: false }, + { pattern: 'tests/**/*.test.js', included: false }, + 'tests/main-test.js' + ], + + + // list of files to exclude + exclude: [ + ], + + + // preprocess matching files before serving them to the browser + // available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor + preprocessors: { + 'engine/**/*.js': ['traceur'], + 'tests/**/*.test.js': ['traceur'] + }, + + traceurPreprocessor: { + // options passed to the traceur-compiler + // see traceur --longhelp for list of options + options: { + experimental: true, + sourceMaps: true, + modules: 'amd' + } + }, + + // test results reporter to use + // possible values: 'dots', 'progress' + // available reporters: https://npmjs.org/browse/keyword/karma-reporter + reporters: ['progress'], + + + // web server port + port: 9876, + + + // enable / disable colors in the output (reporters and logs) + colors: true, + + + // level of logging + // possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG + logLevel: config.LOG_INFO, + + + // enable / disable watching file and executing tests whenever any file changes + autoWatch: false, + + + // start these browsers + // available browser launchers: https://npmjs.org/browse/keyword/karma-launcher + browsers: ['PhantomJS'], + + + // Continuous Integration mode + // if true, Karma captures browsers, runs the tests and exits + singleRun: false, + + // Concurrency level + // how many browser should be started simultaneous + concurrency: Infinity, + + plugins: [ + 'karma-requirejs', + 'karma-traceur-preprocessor', + 'karma-jasmine', + 'karma-chrome-launcher', + 'karma-phantomjs-launcher' + ] + }) +} diff --git a/package.json b/package.json old mode 100644 new mode 100755 index 5d58fb7..e64f5b3 --- a/package.json +++ b/package.json @@ -19,15 +19,28 @@ "url": "https://github.com/mjneil/CruftEngine/issues" }, "devDependencies": { - "vinyl-source-stream": "~1.1.0", + "browserify": "~13.0.0", "del": "~2.2.0", + "es6ify": "^1.6.0", + "express": "~4.13.4", "gulp": "~3.9.0", + "gulp-cached": "~1.1.0", "gulp-concat": "~2.6.0", - "gulp-traceur": "~0.17.2", - "browserify": "~13.0.0", "gulp-live-server": "0.0.29", - "express": "~4.13.4", + "gulp-traceur": "~0.17.2", + "jasmine-core": "^2.4.1", + "karma": "^0.13.21", + "karma-browserify": "^5.0.1", + "karma-chrome-launcher": "^0.2.2", + "karma-jasmine": "^0.3.7", + "karma-phantomjs-launcher": "^1.0.0", + "karma-requirejs": "^0.2.5", + "karma-traceur-preprocessor": "^0.4.0", + "phantomjs-prebuilt": "^2.1.4", + "requirejs": "^2.1.22", "run-sequence": "~1.1.5", - "gulp-cached": "~1.1.0" + "traceur": "0.0.102", + "vinyl-source-stream": "~1.1.0", + "watchify": "^3.7.0" } } diff --git a/tests/main-test.js b/tests/main-test.js new file mode 100755 index 0000000..7c09072 --- /dev/null +++ b/tests/main-test.js @@ -0,0 +1,38 @@ +/** + * For loading all "test" cases according to the Karma config - "files". + * + */ + +/** + * The array of test cases + * + * @type {Array} + */ +var tests = []; +for (var file in window.__karma__.files) { + if (window.__karma__.files.hasOwnProperty(file)) { + if (/\.test\.js$/.test(file)) { + tests.push(file); + } + } +} + +/** + * RequireJS config + */ +requirejs.config({ + // Karma serves files from '/base' + baseUrl: '/base', + + paths: { + }, + + shim: { + }, + + // ask Require.js to load these files (all our tests) + deps: tests, + + // start test run, once Require.js is done + callback: window.__karma__.start +}); \ No newline at end of file diff --git a/tests/vec2.test.js b/tests/vec2.test.js new file mode 100755 index 0000000..e64ba4d --- /dev/null +++ b/tests/vec2.test.js @@ -0,0 +1,16 @@ +import vec2 from 'engine/math/vec2.js'; + +describe('vec2', () => { + let vec; + + beforeEach(() => { + vec = vec2.zero(); + }); + + it('should be an a 0 vec2. i.e. (0,0)', () => { + expect(vec.x).toBe(0); + expect(vec.y).toBe(0); + }); + + +}) \ No newline at end of file