Here is the code from my login.js file:
var loginModule = angular.module('loginModule', [])
.controller('LoginCtrl', function ($scope, $auth, $location) {
if (!$auth.isAuthenticated()) {
$scope.oneAtATime = true;
$scope.login = function () {
$auth.login({userName: $scope.username, password: $scope.password, isEncript: false})
.then(function () {
console.log($auth.getMessage());
})
.catch(function (response) {
console.log(response);
});
};
}
else {
$location.path('/home');
}
$scope.status = 'true';
});
And here is the unit test code:
describe('login()', function() {
it('should be able to handle login errors', function () {
var user = {
email: '<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="65030a0a250704174b060a08">[email protected]</a>',
password: '1234',
isEncript: false
};
this.$httpBackend.expectPOST('app/controller/apicall.php?serviceName=login').respond(200);
this.$auth.login(user).then(angular.noop, function () {
});
this.$httpBackend.flush();
expect(user.isEncript).toBe(false);
});
});
});
......................I am encountering the following error.......................................
$auth login() should be able to handle login errors FAILED
Error: Unexpected request: POST ../../controller/apicall.php?serviceName=login
Expected POST /app/controller/apicall.php?serviceName=login
I need help in resolving this error. Can you assist me with solving it?