I need help testing my login controller, here is the structure of it:
describe('LoginController', function() {
beforeEach(module('task6'));
var $controller, LoginService;
beforeEach(inject(function(_$controller_, _LoginService_) {
$controller = _$controller_;
LoginService = _LoginService_;
}));
describe('LoginController.submitLogin', function() {
it('verify if user exists', function(done) {
var $scope = {};
var controller = $controller('LoginController', {$scope: $scope});
var resultValue;
controller.loginField = 'John';
controller.password = 'Smith';
LoginService.signIn(controller.loginField,
controller.password)
.then(function() {
expect(true).toBe(true);
done();
});
});
});
});
The signIn function looks like this:
function signIn(loginField, password) {
var defer = $q.defer();
if (loginField && password) {
defer.resolve("success");
} else {
defer.reject("failed");
}
return defer.promise;
}
However, I keep getting the error message "Async callback was not invoken within timeout specified..."