diff --git a/Gruntfile.js b/Gruntfile.js index 6440030d..6981bb2d 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -31,6 +31,7 @@ module.exports = function(grunt) { mode : '?debug', delay : delay }, + async : false, direct : false, logLevel : 'info', printCommand : false, diff --git a/karma.conf.js b/karma.conf.js new file mode 100644 index 00000000..91d9f73b --- /dev/null +++ b/karma.conf.js @@ -0,0 +1,70 @@ +// Karma configuration +// Generated on Tue Jul 22 2014 23:49:26 GMT+0200 (Romance Daylight Time) + +module.exports = function(config) { + + var mapToSrcFolder = function (path) {return ['src', path].join('/');}; + + var piskelScripts = require('./src/piskel-script-list.js').scripts.map(mapToSrcFolder); + piskelScripts.push('test/**/*.js'); + 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: ['jasmine'], + + + // list of files / patterns to load in the browser + files: piskelScripts, + + + // list of files to exclude + exclude: [ + 'src/js/app.js', + 'test/integration/**/*.js' + ], + + + // preprocess matching files before serving them to the browser + // available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor + preprocessors: { + }, + + + // 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: ['Chrome'], + + + // Continuous Integration mode + // if true, Karma captures browsers, runs the tests and exits + singleRun: false + }); +}; diff --git a/package.json b/package.json index 1363a98c..e5c39646 100644 --- a/package.json +++ b/package.json @@ -14,7 +14,9 @@ "start": "nodewebkit" }, "devDependencies": { + "dateformat": "1.0.8-1.2.3", "grunt": "~0.4.5", + "grunt-closure-tools": "~0.9.7", "grunt-contrib-clean": "0.5.0", "grunt-contrib-concat": "0.5.0", "grunt-contrib-copy": "0.5.0", @@ -22,14 +24,15 @@ "grunt-contrib-uglify": "0.5.0", "grunt-contrib-watch": "0.6.1", "grunt-express": "1.4.1", - "grunt-replace": "0.7.8", "grunt-ghost": "1.1.0", - "grunt-open": "0.2.3", "grunt-leading-indent": "0.1.0", - "grunt-closure-tools": "~0.9.7", "grunt-node-webkit-builder": "0.1.21", - "nodewebkit": "~0.9.2-8", - "dateformat" : "1.0.8-1.2.3" + "grunt-open": "0.2.3", + "grunt-replace": "0.7.8", + "karma": "0.12.17", + "karma-chrome-launcher": "^0.1.4", + "karma-jasmine": "^0.1.5", + "nodewebkit": "~0.9.2-8" }, "window": { "title": "Piskel", diff --git a/test/integration/casperjs/smoke_test.js b/test/integration/casperjs/smoke_test.js index c9782511..2bc25ab1 100644 --- a/test/integration/casperjs/smoke_test.js +++ b/test/integration/casperjs/smoke_test.js @@ -7,7 +7,7 @@ casper this.echo(casper.cli.get('baseUrl')+"?debug"); // If there was a JS error after the page load, casper won't perform asserts this.test.assertExists('html', 'Casper JS cannot assert DOM elements. A JS error has probably occured.'); - + this.test.assertExists('#drawing-canvas-container canvas', 'Check if drawing canvas element is created'); }) .run(function () { diff --git a/test/js/service/HistoryServiceTest.js b/test/js/service/HistoryServiceTest.js new file mode 100644 index 00000000..b85a64a4 --- /dev/null +++ b/test/js/service/HistoryServiceTest.js @@ -0,0 +1,8 @@ +describe("History Service suite", function() { + it("contains spec with an expectation", function() { + + var mockPiskelController = {}; + var historyService = new pskl.service.HistoryService(mockPiskelController); + expect(historyService.currentIndex).toBe(0); + }); +}); \ No newline at end of file