Skip to content

Commit

Permalink
<feat> Add testing suite.
Browse files Browse the repository at this point in the history
  • Loading branch information
rmi22186 committed Feb 3, 2015
1 parent 43754d7 commit 220fa5a
Show file tree
Hide file tree
Showing 4 changed files with 97 additions and 1 deletion.
11 changes: 10 additions & 1 deletion gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ var gulp = require('gulp');
browserSync = require('browser-sync');
series = require('stream-series');
inject = require("gulp-inject");
karma = require('karma').server;

var paths = {
scripts: ['client/**/*.js']
Expand Down Expand Up @@ -51,6 +52,14 @@ gulp.task('serve', function () {
nodemon({ script: 'server.js', ignore: ['node_modules/**/*.js'] });
});

gulp.task('default', ['scripts', 'browser-sync'], function() {
gulp.task('test', function(done) {
karma.start({
configFile: __dirname + '/my.conf.js',
singleRun: true
}, function() { done();
});
});

gulp.task('default', ['scripts', 'browser-sync', 'test'], function() {
gulp.watch(paths.scripts, ['scripts', browserSync.reload]);
});
67 changes: 67 additions & 0 deletions my.conf.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
// Karma configuration
// Generated on Mon Feb 02 2015 14:52:02 GMT-0800 (PST)

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: ['jasmine'],


// list of files / patterns to load in the browser
files: [
'./*.js',
'./server/**/*.js',
'./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: {
},


// test results reporter to use
// possible values: 'dots', 'progress'
// available reporters: https://npmjs.org/browse/keyword/karma-reporter
reporters: [],


// 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: true,


// 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
});
};
4 changes: 4 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@
"gulp-jshint": "^1.9.2",
"gulp-rename": "^1.2.0",
"gulp-uglify": "^1.1.0",
"jasmine-core": "^2.2.0",
"karma": "^0.12.31",
"karma-chrome-launcher": "^0.1.7",
"karma-jasmine": "^0.3.5",
"sqlite3": "^3.0.4",
"stream-series": "^0.1.1"
}
Expand Down
16 changes: 16 additions & 0 deletions test/tests.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
describe('Unit: selectLanguageController', function() {
// Load the module with MainController
beforeEach(module('languageApp'));

var ctrl, scope;
// inject the $controller and $rootScope services
// in the beforeEach block
beforeEach(inject(function($controller, $rootScope) {
// Create a new scope that's a child of the $rootScope
scope = $rootScope.$new();
// Create the controller
ctrl = $controller('selectLanguageController', {
$scope: scope
});
}));
});

0 comments on commit 220fa5a

Please sign in to comment.