#567 Login Component should emit object not strings

This commit is contained in:
Mario Romano
2016-08-12 17:09:39 +01:00
parent 100cd73ca8
commit 7c54df1333
2 changed files with 4 additions and 8 deletions

View File

@@ -348,7 +348,7 @@ describe('AlfrescoLogin', () => {
expect(component.success).toBe(true); expect(component.success).toBe(true);
expect(compiled.querySelector('#login-success')).toBeDefined(); expect(compiled.querySelector('#login-success')).toBeDefined();
expect(compiled.querySelector('#login-success').innerHTML).toEqual('LOGIN.MESSAGES.LOGIN-SUCCESS'); expect(compiled.querySelector('#login-success').innerHTML).toEqual('LOGIN.MESSAGES.LOGIN-SUCCESS');
expect(component.onSuccess.emit).toHaveBeenCalledWith({value: 'Login OK'}); expect(component.onSuccess.emit).toHaveBeenCalledWith(true);
}); });
it('should emit onError event after the login has failed', () => { it('should emit onError event after the login has failed', () => {
@@ -379,7 +379,7 @@ describe('AlfrescoLogin', () => {
expect(component.success).toBe(false); expect(component.success).toBe(false);
expect(compiled.querySelector('#login-error')).toBeDefined(); expect(compiled.querySelector('#login-error')).toBeDefined();
expect(compiled.querySelector('#login-error').innerText).toEqual('LOGIN.MESSAGES.LOGIN-ERROR'); expect(compiled.querySelector('#login-error').innerText).toEqual('LOGIN.MESSAGES.LOGIN-ERROR');
expect(component.onError.emit).toHaveBeenCalledWith({value: 'Login KO'}); expect(component.onError.emit).toHaveBeenCalledWith('Fake server error');
}); });
it('should render the password in clear when the toggleShowPassword is call', () => { it('should render the password in clear when the toggleShowPassword is call', () => {

View File

@@ -108,15 +108,11 @@ export class AlfrescoLoginComponent {
.subscribe( .subscribe(
(token: any) => { (token: any) => {
this.success = true; this.success = true;
this.onSuccess.emit({ this.onSuccess.emit(token);
value: 'Login OK'
});
}, },
(err: any) => { (err: any) => {
this.error = true; this.error = true;
this.onError.emit({ this.onError.emit(err);
value: 'Login KO'
});
console.log(err); console.log(err);
this.success = false; this.success = false;
}, },