Ajout exo Karma
This commit is contained in:
12
javascript/angular/exercices/karma/app/app.js
vendored
Normal file
12
javascript/angular/exercices/karma/app/app.js
vendored
Normal file
@ -0,0 +1,12 @@
|
||||
var myApp = angular.module('myApp', []);
|
||||
|
||||
myApp.controller('ExoCtrl', ['$scope', function($scope) {
|
||||
|
||||
$scope.val1 = 1;
|
||||
$scope.val2 = 2;
|
||||
|
||||
$scope.add = function() {
|
||||
$scope.result = $scope.val1 + $scope.val2;
|
||||
};
|
||||
|
||||
}]);
|
68
javascript/angular/exercices/karma/karma.conf.js
Normal file
68
javascript/angular/exercices/karma/karma.conf.js
Normal file
@ -0,0 +1,68 @@
|
||||
// Karma configuration
|
||||
// Generated on Fri Apr 10 2015 00:15:38 GMT+0200 (CEST)
|
||||
|
||||
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: [
|
||||
'../node_modules/angular/angular.js',
|
||||
'node_modules/angular-mocks/angular-mocks.js',
|
||||
'app/app.js',
|
||||
'test/**/*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: ['Firefox'],
|
||||
|
||||
|
||||
// Continuous Integration mode
|
||||
// if true, Karma captures browsers, runs the tests and exits
|
||||
singleRun: false
|
||||
});
|
||||
};
|
21
javascript/angular/exercices/karma/package.json
Normal file
21
javascript/angular/exercices/karma/package.json
Normal file
@ -0,0 +1,21 @@
|
||||
{
|
||||
"name": "karma-exercice",
|
||||
"version": "1.0.0",
|
||||
"description": "",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
"test": "echo \"Error: no test specified\" && exit 1"
|
||||
},
|
||||
"author": "",
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"angular-mocks": "^1.3.15",
|
||||
"karma": "^0.12.31"
|
||||
},
|
||||
"devDependencies": {
|
||||
"jasmine-core": "^2.2.0",
|
||||
"karma-chrome-launcher": "^0.1.7",
|
||||
"karma-firefox-launcher": "^0.1.4",
|
||||
"karma-jasmine": "^0.3.5"
|
||||
}
|
||||
}
|
29
javascript/angular/exercices/karma/test/ExoControllerSpec.js
vendored
Normal file
29
javascript/angular/exercices/karma/test/ExoControllerSpec.js
vendored
Normal file
@ -0,0 +1,29 @@
|
||||
describe('ExoController', function() {
|
||||
|
||||
beforeEach(module('myApp'));
|
||||
|
||||
var $controller;
|
||||
|
||||
beforeEach(inject(function(_$controller_){
|
||||
$controller = _$controller_;
|
||||
}));
|
||||
|
||||
describe('$scope.add', function() {
|
||||
|
||||
it('Il additionne les valeurs $scope.val1 et $scope.val2 et stocke le résultat dans $scope.result', function() {
|
||||
|
||||
var $scope = {};
|
||||
var controller = $controller('ExoCtrl', {$scope: $scope});
|
||||
$scope.val1 = 2;
|
||||
$scope.val2 = 4;
|
||||
|
||||
$scope.add();
|
||||
|
||||
expect($scope.result).toEqual(6);
|
||||
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
});
|
12
javascript/angular/exercices/protractor/app/app.js
vendored
Normal file
12
javascript/angular/exercices/protractor/app/app.js
vendored
Normal file
@ -0,0 +1,12 @@
|
||||
var myApp = angular.module('myApp', []);
|
||||
|
||||
myApp.controller('ExoCtrl', ['$scope', function($scope) {
|
||||
|
||||
$scope.val1 = 1;
|
||||
$scope.val2 = 2;
|
||||
|
||||
$scope.add = function() {
|
||||
$scope.result = $scope.val1 + $scope.val2;
|
||||
};
|
||||
|
||||
}]);
|
@ -37,7 +37,7 @@
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
<script src="../node_modules/angular/angular.js"></script>
|
||||
<script src="../../node_modules/angular/angular.js"></script>
|
||||
<script src="todos.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
Reference in New Issue
Block a user