describe( 'Forgot Password: with username', ()=> {
let dirElementInput;
beforeEach( ()=> {
// Find the input control:
dirElementInput = directiveElem.find('input'); // Set some text!
angular.element(dirElementInput).val('ahto.simakuutio@gmail.com').trigger('input');
$scope.$apply();
} ); it( 'should have username', ()=> {
expect(directiveCtrl.user.username ).toEqual('ahto.simakuutio@gmail.com');
} ); it('should call UserService\'s forgotPassword function', ()=>{ spyOn(UserService, 'forgotPassword');
angular.element( directiveElem.find( 'button' )[ 2 ] )
.click();
expect(UserService.forgotPassword).toHaveBeenCalled();
});
} ); describe('Forgot password: without username', ()=>{
let dirElementInput;
beforeEach( ()=> {
dirElementInput = directiveElem.find('input');
angular.element(dirElementInput).val('').trigger('input');
$scope.$apply();
}); it('should have empty username value', ()=>{
expect(directiveCtrl.user.username).toBeUndefined();
}); it('should not call UserService\'s ForgotPassword function', ()=>{ spyOn(UserService, 'forgotPassword');
angular.element( directiveElem.find( 'button' )[ 2 ] )
.click();
expect(UserService.forgotPassword).not.toHaveBeenCalled();
})
});