My controller definition is as follows:
angular.module("rmt.account-info").controller('AccountInfoController', ['$scope', '$rootScope', '$modal', 'AccountInfoServices', 'UserServices', 'Profile',
function ($scope, $rootScope, $modal, AccountInfoServices, UserServices, Profile) {
and I am trying to write Unit Test for this controller as follows:
describe("Account Info Module", function(){
describe("Account Info Controller", function(){
var scope, ctrl;
beforeEach(function(){
module("rmt.account-info");
var accountInfoMockService = {}, userMockService = {}, mockedProfileFactory = {};
var fakeModal =
{
result: {
then: function(confirmCallback, cancelCallback){
this.confirmCallback = confirmCallback;
this.cancelCallback = cancelCallback;
}
},
close: function(item){
this.result.confirmCallback(item);
},
dismiss: function(reason){
this.result.cancelCallback(reason);
}
};
module(function($provide, $modal){
$provide.value('AccountInfoServices', accountInfoMockService);
$provide.value('UserServices', userMockService);
$provide.value('Profile', mockedProfileFactory);
spyOn($modal, 'open').and.returnValue(fakeModal);
return null;
});
});
beforeEach(inject(function(_$rootScope_, _$controller_, _$modal_, _AccountInfoServices_, _UserServices_, _Profile_){
scope = _$rootScope_.new();
$rootScope = _$rootScope_;
$modal = _$modal_;
AccountInfoServices = _AccountInfoServices_;
UserServices = _UserServices_;
Profile = _Profile_;
ctrl = _$controller_("accountInfoController", {
$scope : scope,
$rootScope : $rootScope,
$modal : $modal,
AccountInfoServices : AccountInfoServices,
UserServices : UserServices,
Profile : Profile
});
}));
describe("Initial State", function(){
it("should instantiate the controller properly", function(){
expect(ctrl).not.toBeUndefined();
});
});
});
describe("Account Info Service", function(){
});
});
Please help to know where I am going wrong, I get the following error in my terminal:
Failed to instantiate module {0} due to: {1}
Using Karma as Test Runner and Jasmine - testing framework
Aucun commentaire:
Enregistrer un commentaire