One of my Karma test specs is set up like this:
'use strict';
describe('Controller: RegistrationCtrl', function () {
beforeEach(module('stageApp'));
var RegistrationCtrl, scope;
beforeEach(inject(function ($controller, $rootScope) {
scope = $rootScope.$new();
RegistrationCtrl = $controller('RegistrationCtrl', {
$scope: scope
});
}));
it('should be defined', function () {
expect(RegistrationCtrl.init).toBeDefined();
});
it('should be defined', function () {
expect(scope.testPassword).toBeDefined();
});
});
I am attempting to access the init function in my controller that was defined as follows:
var init = function () {
$scope.showProfileFeatures = false;
};
The test for scope.testPassword is passing successfully, but the test for init() is failing. I have tried accessing it with both RegistrationCtrl.init and just 'init' without success.
This is the functional test password function in my controller:
$scope.testPassword = function ($event) {
var password = $scope.regPassword;
if (password.length < 8) {
alert("bad password");
}
};