Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dev/feature/karma jasmine #63

Open
wants to merge 3 commits into
base: feature
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
"animate.css": "^3.5.2",
"angular-material-icons": "~0.7.1",
"underscore": "^1.8.3",
"angular-translate": "^2.13.0",
"angular-translate": "^2.13.0",
"angular-translate-loader-static-files": "^2.13.0"
},
"install": {
Expand Down
10 changes: 9 additions & 1 deletion gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ var batch = require('gulp-batch'),
gulp = require('gulp'),
inject = require('gulp-inject'),
server = require('gulp-server-livereload'),
watch = require('gulp-watch');
watch = require('gulp-watch'),
karma = require('karma').server;

gulp.task('server', ['watch', 'index'], function() {

Expand Down Expand Up @@ -57,3 +58,10 @@ gulp.task('index', function () {
return target.pipe(inject(sources, {ignorePath: 'source'}))
.pipe(gulp.dest('./source'));
});

gulp.task('tests', function (done) {
return karma.start({
configFile: __dirname + '/karma.conf.js',
singleRun: true
}, done);
});
86 changes: 86 additions & 0 deletions karma.conf.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
// Karma configuration
// Generated on Tue Nov 15 2016 08:03:59 GMT-0500 (PET)

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: [
"./source/js/lib/angular/angular.js",
"./source/js/lib/angular-animate/angular-animate.js",
"./source/js/lib/angular-material/angular-material.js",
"./source/js/lib/angular-aria/angular-aria.js",
"./source/js/lib/angular-material-icons/angular-material-icons.min.js",
"./source/js/lib/angular-messages/angular-messages.js",
"./source/js/lib/angular-resource/angular-resource.js",
"./source/js/lib/angular-route/angular-route.js",
"./source/js/lib/angular-sanitize/angular-sanitize.js",
"./source/js/lib/angular-translate/angular-translate.js",
"./source/js/lib/angular-translate-loader-static-files/angular-translate-loader-static-files.js",
"./source/js/lib/angular-ui-router/angular-ui-router.js",
"./source/js/lib/ngstorage/ngStorage.js",
"./source/js/lib/underscore/underscore.js",
"./node_modules/angular-mocks/angular-mocks.js",
"./source/js/app/module/*.js",
"./source/js/app/**/*.js",
"./source/js/app/config/test/controller/login.ctrl.spec.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: ['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: 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,

// Concurrency level
// how many browser should be started simultaneous
concurrency: Infinity
})
}
10 changes: 9 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

{
"name": "belatrix-web-connect",
"version": "0.0.1",
Expand Down Expand Up @@ -26,5 +25,14 @@
"gulp-inject": "^4.1.0",
"gulp-server-livereload": "^1.8.2",
"gulp-watch": "^4.3.9"
},
"devDependencies": {
"angular-mocks": "^1.x.x",
"jasmine-core": "^2.5.2",
"jasmine-jquery": "^2.1.1",
"karma": "^1.3.0",
"karma-chrome-launcher": "^2.0.0",
"karma-jasmine": "^1.0.2",
"karma-junit-reporter": "^1.1.0"
}
}
17 changes: 17 additions & 0 deletions source/js/app/config/test/controller/login.ctrl.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
describe("Login controller tests", function() {
beforeEach(module('app'));
var loginController, scope, loginService;
beforeEach(inject(function ($rootScope, $controller, _loginService_) {
scope = $rootScope.$new();
loginService = _loginService_;
loginController = $controller('controller.login', {
$scope: scope
});
}));

it("should sign in successfully", function() {
spyOn(loginService, 'signIn');
scope.getSignIn();
expect(loginService.signIn).toHaveBeenCalled();
});
});