Merge pull request #569 from chelseakomlo/master

Added Grunt task "test"
This commit is contained in:
Nayan Ambali 2013-12-11 20:27:05 -08:00
commit e789f267a5
7 changed files with 82 additions and 49 deletions

View File

@ -1,3 +1,7 @@
language: node_js
node_js:
- 0.10
- "0.10"
- "0.8"
- "0.6"
before_script:
- npm install -g grunt-cli

View File

@ -26,6 +26,12 @@ module.exports = function(grunt) {
all: ['Gruntfile.js', '<%= mifosx.app %>/scripts/**/*.js']
},
karma: {
unit: {
configFile: 'karma.conf.js'
}
},
//uglify the js files
uglify: {
options: {
@ -194,6 +200,7 @@ module.exports = function(grunt) {
grunt.loadNpmTasks('grunt-contrib-concat');
grunt.loadNpmTasks('grunt-contrib-requirejs');
grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks('grunt-karma');
// Default task(s).
@ -201,5 +208,6 @@ module.exports = function(grunt) {
grunt.registerTask('prod', ['clean', 'copy:prod', 'concat', 'uglify:prod']);
grunt.registerTask('dev', ['clean', 'copy:dev']);
grunt.registerTask('compile', ['jshint']);
grunt.registerTask('test', ['karma']);
};

View File

@ -77,3 +77,6 @@ Just open test/SpecRunner.html in the browser.
## Contribution guidelines
Please read the <a href="https://github.com/openMF/community-app/blob/master/Contributing.md" >contribution guidelines</a>
Testing

View File

@ -1,56 +1,60 @@
// Karma configuration
// base path, that will be used to resolve files and exclude
basePath = '';
module.exports = function (config) {
config.set({
basePath : '',
// list of files / patterns to load in the browser
files = [
JASMINE,
JASMINE_ADAPTER,
'app/bower_components/angular/angular.js',
'app/bower_components/angular-mocks/angular-mocks.js',
'app/scripts/*.js',
'app/scripts/**/*.js',
'test/mock/**/*.js',
'test/spec/**/*.js'
];
frameworks : ["jasmine"],
// list of files to exclude
exclude = [];
files : [
'./app/bower_components/angular/angular.js',
'./app/bower_components/angular-mocks/angular-mocks.js',
'./app/bower_components/underscore/underscore-min.js',
'./app/bower_components/requirejs/require.js',
'./app/scripts/mifosX.js',
'./app/scripts/models/*.js',
'./app/scripts/services/*.js',
'./app/scripts/directives/*.js',
'./app/scripts/controllers/**/*.js',
'./test/spec/**/*.js'
],
// test results reporter to use
// possible values: dots || progress || growl
reporters = ['progress'];
// list of files to exclude
exclude : [],
// web server port
port = 8080;
// test results reporter to use
// possible values: dots || progress || growl
reporters : ['progress'],
// cli runner port
runnerPort = 9100;
// web server port
port : 8080,
// cli runner port
runnerPort : 9100,
// enable / disable colors in the output (reporters and logs)
colors : true,
// level of logging
// possible values: LOG_DISABLE || LOG_ERROR || LOG_WARN || LOG_INFO || LOG_DEBUG
logLevel : LOG_INFO,
autoWatch : false,
browsers : ['PhantomJS'],
// If browser does not capture in given timeout [ms], kill it
captureTimeout : 5000,
// Continuous Integration mode
// if true, it capture browsers, run tests and exit
singleRun : true
});
}
// enable / disable colors in the output (reporters and logs)
colors = true;
// level of logging
// possible values: LOG_DISABLE || LOG_ERROR || LOG_WARN || LOG_INFO || LOG_DEBUG
logLevel = LOG_INFO;
// enable / disable watching file and executing tests whenever any file changes
autoWatch = false;
// Start these browsers, currently available:
// - Chrome
// - ChromeCanary
// - Firefox
// - Opera
// - Safari (only Mac)
// - PhantomJS
// - IE (only Windows)
browsers = ['Chrome'];
// If browser does not capture in given timeout [ms], kill it
captureTimeout = 5000;
// Continuous Integration mode
// if true, it capture browsers, run tests and exit
singleRun = false;

View File

@ -10,7 +10,21 @@
"grunt-contrib-clean": "~0.5.0",
"grunt-contrib-copy": "~0.4.1",
"grunt-contrib-concat": "~0.3.0",
"grunt-contrib-requirejs": "~0.3.1"
"grunt-contrib-requirejs": "~0.3.1",
"karma-script-launcher": "~0.1.0",
"karma-chrome-launcher": "~0.1.1",
"karma-html2js-preprocessor": "~0.1.0",
"karma-firefox-launcher": "~0.1.2",
"karma-jasmine": "~0.1.4",
"requirejs": "~2.1.9",
"karma-requirejs": "~0.2.0",
"karma-coffee-preprocessor": "~0.1.1",
"karma-phantomjs-launcher": "~0.1.1",
"karma": "~0.10.8",
"grunt-karma": "~0.6.2"
},
"scripts": {
"test": "grunt test --verbose"
},
"engines": {
"node": ">=0.8.0"

View File

@ -13,7 +13,7 @@ describe("LoginFormController", function() {
it("should initialise the login credentials", function() {
expect(this.scope.loginCredentials).toEqual({});
});
it("should initialise the authenticationFailed flag", function() {
expect(this.scope.authenticationFailed).toBeFalsy();
});

View File

@ -10,7 +10,7 @@ describe("MainController", function() {
sessionCallback = callback;
});
this.translate = jasmine.createSpy();
this.translate = jasmine.createSpyObj("translate", ["uses"]);
this.rootScope = jasmine.createSpy();
this.localStorageService = jasmine.createSpyObj("localStorageService", ["get"]);
@ -36,7 +36,7 @@ describe("MainController", function() {
describe("on receving 'UserAuthenticationSuccessEvent'", function() {
beforeEach(function() {
this.sessionManager.get.andReturn("test_session");
eventListener({}, "test_data");
});
@ -52,7 +52,7 @@ describe("MainController", function() {
describe("User logout", function() {
beforeEach(function() {
this.sessionManager.clear.andReturn("test_session");
this.scope.logout();
});