From 7c54df133381563cd9c773bdbe873ea005eb5bab Mon Sep 17 00:00:00 2001 From: Mario Romano Date: Fri, 12 Aug 2016 17:09:39 +0100 Subject: [PATCH] #567 Login Component should emit object not strings --- .../src/components/alfresco-login.component.spec.ts | 4 ++-- .../src/components/alfresco-login.component.ts | 8 ++------ 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/ng2-components/ng2-alfresco-login/src/components/alfresco-login.component.spec.ts b/ng2-components/ng2-alfresco-login/src/components/alfresco-login.component.spec.ts index 541f38e262..8c8432c156 100644 --- a/ng2-components/ng2-alfresco-login/src/components/alfresco-login.component.spec.ts +++ b/ng2-components/ng2-alfresco-login/src/components/alfresco-login.component.spec.ts @@ -348,7 +348,7 @@ describe('AlfrescoLogin', () => { expect(component.success).toBe(true); expect(compiled.querySelector('#login-success')).toBeDefined(); 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', () => { @@ -379,7 +379,7 @@ describe('AlfrescoLogin', () => { expect(component.success).toBe(false); expect(compiled.querySelector('#login-error')).toBeDefined(); 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', () => { diff --git a/ng2-components/ng2-alfresco-login/src/components/alfresco-login.component.ts b/ng2-components/ng2-alfresco-login/src/components/alfresco-login.component.ts index c5fa4405bc..f13fc2562d 100644 --- a/ng2-components/ng2-alfresco-login/src/components/alfresco-login.component.ts +++ b/ng2-components/ng2-alfresco-login/src/components/alfresco-login.component.ts @@ -108,15 +108,11 @@ export class AlfrescoLoginComponent { .subscribe( (token: any) => { this.success = true; - this.onSuccess.emit({ - value: 'Login OK' - }); + this.onSuccess.emit(token); }, (err: any) => { this.error = true; - this.onError.emit({ - value: 'Login KO' - }); + this.onError.emit(err); console.log(err); this.success = false; },