I have following controller that has only private functions. I am struggling to test this controller. Shall I test if it is doing $emit, since the ImageService has been tested? How do I test $emit in this case? Or shall I test if it is calling the ImageService.fetchImageStacks method? In this case, how do I trigger init function?
(function (angular, global, undefined) {
'use strict';
var ImageController = {};
ImageController.$inject = [
'$rootScope',
'$log',
'ImageService'
];
ImageController = function (
$rootScope,
$log,
ImageService
) {
var getImageStacks = function() {
ImageService
.fetchImageStacks()
.success(function (result) {
ImageService.setImageStacks(result);
$rootScope.$emit('rootScope:imageStacksUpdated', result);
})
.error(function (){
$log.error('Failed to get imageStackInfo file.');
});
};
var init = function () {
getImageStacks();
};
init();
return {
getImageStacks: getImageStacks
};
}
angular.module('myApp')
.controller('ImageController', ImageController);
})(angular, this);
Aucun commentaire:
Enregistrer un commentaire