I (as a js/ng newbie) wanna know how do I start on my unit-test journey for the following angular code (Controller with some functions) and mocking necessary? Would appreciate beautiful suggestions. Thanks
angular.module('HelloWorld')
.controller('myCtrl', function ($scope, firstService, secondService, messageService) {
'use strict';
function goWhereTheWindBlows() { // some implementation }
$scope.mainFun = function(var1) {
firstService.showSomething(var1, function() {
var result = secondService.read(var1);
// result is the result of http get (200 or 400)
extracted(result);
}, goWhereTheWindBlows);
function extracted(result) {
result.then(function () {
messageService.addMessage({ message: 'Success', type: 'standard' });
}, function () {
messageService.addMessage({ message: 'Failure', type: 'error' });
});
}
};
});
Aucun commentaire:
Enregistrer un commentaire