mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-10-01 14:41:32 +00:00
#17 unit test cases improvments
This commit is contained in:
@@ -22,8 +22,8 @@
|
||||
</div>
|
||||
<div class="mdl-card__actions mdl-card--border">
|
||||
<button type="submit" class="mdl-button mdl-js-button mdl-button--raised mdl-js-ripple-effect mdl-button--colored" [disabled]="!form.valid">{{'login-button' | translate }}</button>
|
||||
<div *ngIf="error" class="mdl-card__supporting-text" style="color: red;">{{'login-error-message' | translate }}</div>
|
||||
<div *ngIf="success" class="mdl-card__supporting-text" style="color: blue;">{{'login-success-message' | translate }}</div>
|
||||
<div *ngIf="error" id="login-error" class="mdl-card__supporting-text" style="color: red;">{{'login-error-message' | translate }}</div>
|
||||
<div *ngIf="success" id="login-success" class="mdl-card__supporting-text" style="color: blue;">{{'login-success-message' | translate }}</div>
|
||||
</div>
|
||||
<div class="mdl-card__menu">
|
||||
<div class="mdl-spinner mdl-js-spinner"></div>
|
||||
|
@@ -66,7 +66,7 @@ System.register(['angular2/core', 'angular2/router', 'angular2/common', '../serv
|
||||
};
|
||||
this.translationInit(translate);
|
||||
this.form.valueChanges.subscribe(function (data) { return _this.onValueChanged(data); });
|
||||
this.onValueChanged();
|
||||
this.onValueChanged(null);
|
||||
}
|
||||
/**
|
||||
* Method called on submit form
|
||||
|
@@ -1 +1 @@
|
||||
{"version":3,"file":"alfresco-login.js","sourceRoot":"","sources":["alfresco-login.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;YAiCA;gBAgBI;;;;;mBAKG;gBACH,gCAAoB,GAAgB,EACjB,IAAmC,EACnC,MAAc,EACrB,SAA2B;oBAzB3C,iBAsIC;oBAhHuB,QAAG,GAAH,GAAG,CAAa;oBACjB,SAAI,GAAJ,IAAI,CAA+B;oBACnC,WAAM,GAAN,MAAM,CAAQ;oBAvBxB,WAAM,GAAW,MAAM,CAAC;oBACvB,cAAS,GAAG,IAAI,mBAAY,EAAE,CAAC;oBAC/B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AC,KAAK,CAAC,CAAC,CAAC;wBACd,MAAM,CAAC,KAAK,CAAC;oBACjB,CAAC;oBAAC,IAAI,CAAC,CAAC;wBACJ,MAAM,CAAC,IAAI,CAAC;oBAChB,CAAC;gBACL,CAAC;gBAED;;;mBAGG;gBACH,gDAAe,GAAf,UAAgB,SAA2B;oBACvC,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;oBAC3B,IAAI,QAAQ,GAAG,SAAS,CAAC,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,kCAAkC;oBACnF,QAAQ,GAAG,WAAW,CAAC,IAAI,CAAC,QAAQ,CAAC,GAAG,QAAQ,GAAG,IAAI,CAAC;oBAExD,IAAI,CAAC,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC;oBAEpC,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;gBACjC,CAAC;gBApID;oBAAC,YAAK,EAAE;;sEAAA;gBACR;oBAAC,aAAM,EAAE;;yEAAA;gBACT;oBAAC,aAAM,EAAE;;uEAAA;gBAZb;oBAAC,gBAAS,CAAC;wBACP,QAAQ,EAAE,gBAAgB;wBAC1B,QAAQ,EAAE,YAAY;wBACtB,UAAU,EAAE,CAAC,0BAAiB,EAAE,wBAAe,CAAC;wBAChD,WAAW,EAAE,uBAAuB;wBACpC,SAAS,EAAE,CAAC,sBAAsB,CAAC;wBACnC,KAAK,EAAE,CAAC,6BAAa,CAAC;qBAEzB,CAAC;;0CAAA;gBAuIF,6BAAC;YAAD,CAAC,AAtID,IAsIC;YAtID,2DAsIC,CAAA"}
|
@@ -125,13 +125,13 @@ System.register(['angular2/platform/testing/browser', 'angular2/testing', 'angul
|
||||
component.isErrorStyle = function () {
|
||||
};
|
||||
var compiled = fixture.debugElement.nativeElement;
|
||||
component.form.controls['username']._value = 'us';
|
||||
component.form.controls.username._value = 'us';
|
||||
fixture.detectChanges();
|
||||
component.onValueChanged();
|
||||
fixture.detectChanges();
|
||||
testing_1.expect(component.formError).toBeDefined(true);
|
||||
testing_1.expect(component.formError['username']).toBeDefined(true);
|
||||
testing_1.expect(component.formError['username']).toEqual('input-min-message');
|
||||
testing_1.expect(component.formError.username).toBeDefined(true);
|
||||
testing_1.expect(component.formError.username).toEqual('input-min-message');
|
||||
testing_1.expect(compiled.querySelector('#username-error').innerText).toEqual('input-min-message');
|
||||
});
|
||||
}));
|
||||
@@ -143,14 +143,15 @@ System.register(['angular2/platform/testing/browser', 'angular2/testing', 'angul
|
||||
component.isErrorStyle = function () {
|
||||
};
|
||||
var compiled = fixture.debugElement.nativeElement;
|
||||
component.form.controls['username']._value = 'fake-user';
|
||||
component.form.controls['password']._value = 'fake-password';
|
||||
component.form.controls.username._value = 'fake-user';
|
||||
component.form.controls.password._value = 'fake-password';
|
||||
fixture.detectChanges();
|
||||
component.onValueChanged();
|
||||
fixture.detectChanges();
|
||||
testing_1.expect(component.formError).toBeDefined(true);
|
||||
testing_1.expect(component.formError['username']).toEqual('');
|
||||
testing_1.expect(component.formError['password']).toEqual('');
|
||||
testing_1.expect(component.formError.username).toEqual('');
|
||||
testing_1.expect(component.formError.password).toEqual('');
|
||||
testing_1.expect(compiled.querySelector('#login-error')).toBeNull();
|
||||
});
|
||||
}));
|
||||
testing_1.it('should render the new values after user and password values are changed', testing_1.injectAsync([testing_1.TestComponentBuilder], function (tcb) {
|
||||
@@ -160,12 +161,10 @@ System.register(['angular2/platform/testing/browser', 'angular2/testing', 'angul
|
||||
var component = fixture.componentInstance;
|
||||
component.isErrorStyle = function () {
|
||||
};
|
||||
fixture.detectChanges();
|
||||
var compiled = fixture.debugElement.nativeElement;
|
||||
var password = compiled.querySelector('input[type="password"]');
|
||||
var username = compiled.querySelector('input[type="text"]');
|
||||
password.value = 'my password';
|
||||
username.value = 'my username';
|
||||
component.form.controls.username._value = 'my username';
|
||||
component.form.controls.password._value = 'my password';
|
||||
fixture.detectChanges();
|
||||
testing_1.expect(compiled.querySelector('input[type="password"]').value).toEqual('my password');
|
||||
testing_1.expect(compiled.querySelector('input[type="text"]').value).toEqual('my username');
|
||||
});
|
||||
@@ -180,8 +179,9 @@ System.register(['angular2/platform/testing/browser', 'angular2/testing', 'angul
|
||||
component.isErrorStyle = function () {
|
||||
};
|
||||
var compiled = fixture.debugElement.nativeElement;
|
||||
component.form._value.username = 'fake-username';
|
||||
component.form._value.password = 'fake-password';
|
||||
component.form.controls.username._value = 'fake-username';
|
||||
component.form.controls.password._value = 'fake-password';
|
||||
fixture.detectChanges();
|
||||
compiled.querySelector('button').click();
|
||||
fixture.detectChanges();
|
||||
testing_1.expect(component.error).toBe(false);
|
||||
@@ -197,11 +197,13 @@ System.register(['angular2/platform/testing/browser', 'angular2/testing', 'angul
|
||||
component.isErrorStyle = function () {
|
||||
};
|
||||
var compiled = fixture.debugElement.nativeElement;
|
||||
component.form._value.username = 'fake-wrong-username';
|
||||
component.form._value.password = 'fake-password';
|
||||
component.form.controls.username._value = 'fake-wrong-username';
|
||||
component.form.controls.password._value = 'fake-password';
|
||||
fixture.detectChanges();
|
||||
compiled.querySelector('button').click();
|
||||
fixture.detectChanges();
|
||||
testing_1.expect(fixture.componentInstance.error).toBe(true);
|
||||
testing_1.expect(compiled.querySelector('#login-error').innerText).toEqual('login-error-message');
|
||||
});
|
||||
}));
|
||||
testing_1.it('should return error with a wrong password ', testing_1.injectAsync([testing_1.TestComponentBuilder], function (tcb) {
|
||||
@@ -213,11 +215,13 @@ System.register(['angular2/platform/testing/browser', 'angular2/testing', 'angul
|
||||
component.isErrorStyle = function () {
|
||||
};
|
||||
var compiled = fixture.debugElement.nativeElement;
|
||||
component.form._value.username = 'fake-username';
|
||||
component.form._value.password = 'fake-wrong-password';
|
||||
component.form.controls.username._value = 'fake-username';
|
||||
component.form.controls.password._value = 'fake-wrong-password';
|
||||
fixture.detectChanges();
|
||||
compiled.querySelector('button').click();
|
||||
fixture.detectChanges();
|
||||
testing_1.expect(fixture.componentInstance.error).toBe(true);
|
||||
testing_1.expect(compiled.querySelector('#login-error').innerText).toEqual('login-error-message');
|
||||
});
|
||||
}));
|
||||
testing_1.it('should return error with a wrong username and password ', testing_1.injectAsync([testing_1.TestComponentBuilder], function (tcb) {
|
||||
@@ -229,11 +233,13 @@ System.register(['angular2/platform/testing/browser', 'angular2/testing', 'angul
|
||||
component.isErrorStyle = function () {
|
||||
};
|
||||
var compiled = fixture.debugElement.nativeElement;
|
||||
component.form._value.username = 'fake-wrong-username';
|
||||
component.form._value.password = 'fake-wrong-password';
|
||||
component.form.controls.username._value = 'fake-wrong-username';
|
||||
component.form.controls.password._value = 'fake-wrong-password';
|
||||
fixture.detectChanges();
|
||||
compiled.querySelector('button').click();
|
||||
fixture.detectChanges();
|
||||
testing_1.expect(fixture.componentInstance.error).toBe(true);
|
||||
testing_1.expect(compiled.querySelector('#login-error').innerText).toEqual('login-error-message');
|
||||
});
|
||||
}));
|
||||
testing_1.it('should emit onSuccess event after the login has succeeded', testing_1.injectAsync([testing_1.TestComponentBuilder], function (tcb) {
|
||||
@@ -244,13 +250,16 @@ System.register(['angular2/platform/testing/browser', 'angular2/testing', 'angul
|
||||
component.isErrorStyle = function () {
|
||||
};
|
||||
spyOn(component.onSuccess, 'emit');
|
||||
component.form._value.username = 'fake-username';
|
||||
component.form._value.password = 'fake-password';
|
||||
// trigger the click
|
||||
var compiled = fixture.debugElement.nativeElement;
|
||||
component.form.controls.username._value = 'fake-username';
|
||||
component.form.controls.password._value = 'fake-password';
|
||||
fixture.detectChanges();
|
||||
var nativeElement = fixture.nativeElement;
|
||||
var button = nativeElement.querySelector('button');
|
||||
button.dispatchEvent(new Event('click'));
|
||||
fixture.detectChanges();
|
||||
testing_1.expect(fixture.componentInstance.error).toBe(false);
|
||||
testing_1.expect(compiled.querySelector('#login-success').innerHTML).toEqual('login-success-message');
|
||||
testing_1.expect(component.onSuccess.emit).toHaveBeenCalledWith({ value: 'Login OK' });
|
||||
});
|
||||
}));
|
||||
@@ -258,18 +267,21 @@ System.register(['angular2/platform/testing/browser', 'angular2/testing', 'angul
|
||||
return tcb
|
||||
.createAsync(alfresco_login_1.AlfrescoLoginComponent)
|
||||
.then(function (fixture) {
|
||||
//pipes.config();
|
||||
var component = fixture.componentInstance;
|
||||
component.isErrorStyle = function () {
|
||||
};
|
||||
spyOn(component.onError, 'emit');
|
||||
component.form._value.username = 'fake-wrong-username';
|
||||
component.form._value.password = 'fake-password';
|
||||
var compiled = fixture.debugElement.nativeElement;
|
||||
component.form.controls.username._value = 'fake-wrong-username';
|
||||
component.form.controls.password._value = 'fake-password';
|
||||
fixture.detectChanges();
|
||||
// trigger the click
|
||||
var nativeElement = fixture.nativeElement;
|
||||
var button = nativeElement.querySelector('button');
|
||||
button.dispatchEvent(new Event('click'));
|
||||
fixture.detectChanges();
|
||||
testing_1.expect(fixture.componentInstance.error).toBe(true);
|
||||
testing_1.expect(compiled.querySelector('#login-error').innerText).toEqual('login-error-message');
|
||||
testing_1.expect(component.onError.emit).toHaveBeenCalledWith({ value: 'Login KO' });
|
||||
});
|
||||
}));
|
||||
|
File diff suppressed because one or more lines are too long
@@ -27,9 +27,9 @@ import {dispatchEvent} from 'angular2/src/testing/utils';
|
||||
import {TranslateService, LangChangeEvent} from 'ng2-translate/ng2-translate';
|
||||
|
||||
class AuthenticationMock {
|
||||
public mockName:string = 'Mocked Service';
|
||||
public mockName: string = 'Mocked Service';
|
||||
|
||||
login(method:string, username:string, password:string) {
|
||||
login(method: string, username: string, password: string) {
|
||||
if (username === 'fake-username' && password === 'fake-password') {
|
||||
return Observable.of(true);
|
||||
} else {
|
||||
@@ -37,7 +37,7 @@ class AuthenticationMock {
|
||||
}
|
||||
}
|
||||
|
||||
getProviders():Array<any> {
|
||||
getProviders(): Array<any> {
|
||||
return [provide(AlfrescoAuthenticationService, {useValue: this})];
|
||||
}
|
||||
}
|
||||
@@ -54,7 +54,7 @@ class TranslationMock {
|
||||
}
|
||||
|
||||
public get(key: string|Array<string>, interpolateParams?: Object): Observable<string|any> {
|
||||
if(!key) {
|
||||
if (!key) {
|
||||
throw new Error('Parameter "key" required');
|
||||
}
|
||||
return Observable.of(key);
|
||||
@@ -84,7 +84,7 @@ describe('AlfrescoLogin', () => {
|
||||
location = l;
|
||||
}));
|
||||
|
||||
it('should render `Login` form with all the keys to be translated', injectAsync([TestComponentBuilder], (tcb:TestComponentBuilder) => {
|
||||
it('should render `Login` form with all the keys to be translated', injectAsync([TestComponentBuilder], (tcb: TestComponentBuilder) => {
|
||||
return tcb
|
||||
.createAsync(AlfrescoLoginComponent)
|
||||
.then((fixture) => {
|
||||
@@ -110,7 +110,7 @@ describe('AlfrescoLogin', () => {
|
||||
});
|
||||
}));
|
||||
|
||||
it('should render user and password input fields with default values', injectAsync([TestComponentBuilder], (tcb:TestComponentBuilder) => {
|
||||
it('should render user and password input fields with default values', injectAsync([TestComponentBuilder], (tcb: TestComponentBuilder) => {
|
||||
return tcb
|
||||
.createAsync(AlfrescoLoginComponent)
|
||||
.then((fixture) => {
|
||||
@@ -123,7 +123,7 @@ describe('AlfrescoLogin', () => {
|
||||
});
|
||||
}));
|
||||
|
||||
it('should render min-length error when the username is lower than 4 characters', injectAsync([TestComponentBuilder], (tcb:TestComponentBuilder) => {
|
||||
it('should render min-length error when the username is lower than 4 characters', injectAsync([TestComponentBuilder], (tcb: TestComponentBuilder) => {
|
||||
return tcb
|
||||
.createAsync(AlfrescoLoginComponent)
|
||||
.then((fixture) => {
|
||||
@@ -134,7 +134,7 @@ describe('AlfrescoLogin', () => {
|
||||
|
||||
let compiled = fixture.debugElement.nativeElement;
|
||||
|
||||
component.form.controls['username']._value = 'us';
|
||||
component.form.controls.username._value = 'us';
|
||||
|
||||
fixture.detectChanges();
|
||||
|
||||
@@ -143,13 +143,13 @@ describe('AlfrescoLogin', () => {
|
||||
fixture.detectChanges();
|
||||
|
||||
expect(component.formError).toBeDefined(true);
|
||||
expect(component.formError['username']).toBeDefined(true);
|
||||
expect(component.formError['username']).toEqual('input-min-message');
|
||||
expect(component.formError.username).toBeDefined(true);
|
||||
expect(component.formError.username).toEqual('input-min-message');
|
||||
expect(compiled.querySelector('#username-error').innerText).toEqual('input-min-message');
|
||||
});
|
||||
}));
|
||||
|
||||
it('should render no errors when the username and password are correct', injectAsync([TestComponentBuilder], (tcb:TestComponentBuilder) => {
|
||||
it('should render no errors when the username and password are correct', injectAsync([TestComponentBuilder], (tcb: TestComponentBuilder) => {
|
||||
return tcb
|
||||
.createAsync(AlfrescoLoginComponent)
|
||||
.then((fixture) => {
|
||||
@@ -160,8 +160,8 @@ describe('AlfrescoLogin', () => {
|
||||
|
||||
let compiled = fixture.debugElement.nativeElement;
|
||||
|
||||
component.form.controls['username']._value = 'fake-user';
|
||||
component.form.controls['password']._value = 'fake-password';
|
||||
component.form.controls.username._value = 'fake-user';
|
||||
component.form.controls.password._value = 'fake-password';
|
||||
|
||||
fixture.detectChanges();
|
||||
|
||||
@@ -170,12 +170,13 @@ describe('AlfrescoLogin', () => {
|
||||
fixture.detectChanges();
|
||||
|
||||
expect(component.formError).toBeDefined(true);
|
||||
expect(component.formError['username']).toEqual('');
|
||||
expect(component.formError['password']).toEqual('');
|
||||
expect(component.formError.username).toEqual('');
|
||||
expect(component.formError.password).toEqual('');
|
||||
expect(compiled.querySelector('#login-error')).toBeNull();
|
||||
});
|
||||
}));
|
||||
|
||||
it('should render the new values after user and password values are changed', injectAsync([TestComponentBuilder], (tcb:TestComponentBuilder) => {
|
||||
it('should render the new values after user and password values are changed', injectAsync([TestComponentBuilder], (tcb: TestComponentBuilder) => {
|
||||
return tcb
|
||||
.createAsync(AlfrescoLoginComponent)
|
||||
.then((fixture) => {
|
||||
@@ -184,22 +185,18 @@ describe('AlfrescoLogin', () => {
|
||||
|
||||
};
|
||||
|
||||
fixture.detectChanges();
|
||||
|
||||
let compiled = fixture.debugElement.nativeElement;
|
||||
component.form.controls.username._value = 'my username';
|
||||
component.form.controls.password._value = 'my password';
|
||||
|
||||
let password = compiled.querySelector('input[type="password"]');
|
||||
let username = compiled.querySelector('input[type="text"]');
|
||||
|
||||
password.value = 'my password';
|
||||
username.value = 'my username';
|
||||
fixture.detectChanges();
|
||||
|
||||
expect(compiled.querySelector('input[type="password"]').value).toEqual('my password');
|
||||
expect(compiled.querySelector('input[type="text"]').value).toEqual('my username');
|
||||
});
|
||||
}));
|
||||
|
||||
it('should navigate to Home route after the login have succeeded ', injectAsync([TestComponentBuilder], (tcb:TestComponentBuilder) => {
|
||||
it('should navigate to Home route after the login have succeeded ', injectAsync([TestComponentBuilder], (tcb: TestComponentBuilder) => {
|
||||
return tcb
|
||||
.createAsync(AlfrescoLoginComponent)
|
||||
.then((fixture) => {
|
||||
@@ -212,8 +209,10 @@ describe('AlfrescoLogin', () => {
|
||||
|
||||
let compiled = fixture.debugElement.nativeElement;
|
||||
|
||||
component.form._value.username = 'fake-username';
|
||||
component.form._value.password = 'fake-password';
|
||||
component.form.controls.username._value = 'fake-username';
|
||||
component.form.controls.password._value = 'fake-password';
|
||||
|
||||
fixture.detectChanges();
|
||||
|
||||
compiled.querySelector('button').click();
|
||||
|
||||
@@ -224,7 +223,7 @@ describe('AlfrescoLogin', () => {
|
||||
});
|
||||
}));
|
||||
|
||||
it('should return error with a wrong username ', injectAsync([TestComponentBuilder], (tcb:TestComponentBuilder) => {
|
||||
it('should return error with a wrong username ', injectAsync([TestComponentBuilder], (tcb: TestComponentBuilder) => {
|
||||
return tcb
|
||||
.createAsync(AlfrescoLoginComponent)
|
||||
.then((fixture) => {
|
||||
@@ -235,18 +234,21 @@ describe('AlfrescoLogin', () => {
|
||||
};
|
||||
let compiled = fixture.debugElement.nativeElement;
|
||||
|
||||
component.form._value.username = 'fake-wrong-username';
|
||||
component.form._value.password = 'fake-password';
|
||||
component.form.controls.username._value = 'fake-wrong-username';
|
||||
component.form.controls.password._value = 'fake-password';
|
||||
|
||||
fixture.detectChanges();
|
||||
|
||||
compiled.querySelector('button').click();
|
||||
|
||||
fixture.detectChanges();
|
||||
|
||||
expect(fixture.componentInstance.error).toBe(true);
|
||||
expect(compiled.querySelector('#login-error').innerText).toEqual('login-error-message');
|
||||
});
|
||||
}));
|
||||
|
||||
it('should return error with a wrong password ', injectAsync([TestComponentBuilder], (tcb:TestComponentBuilder) => {
|
||||
it('should return error with a wrong password ', injectAsync([TestComponentBuilder], (tcb: TestComponentBuilder) => {
|
||||
return tcb
|
||||
.createAsync(AlfrescoLoginComponent)
|
||||
.then((fixture) => {
|
||||
@@ -257,18 +259,21 @@ describe('AlfrescoLogin', () => {
|
||||
};
|
||||
let compiled = fixture.debugElement.nativeElement;
|
||||
|
||||
component.form._value.username = 'fake-username';
|
||||
component.form._value.password = 'fake-wrong-password';
|
||||
component.form.controls.username._value = 'fake-username';
|
||||
component.form.controls.password._value = 'fake-wrong-password';
|
||||
|
||||
fixture.detectChanges();
|
||||
|
||||
compiled.querySelector('button').click();
|
||||
|
||||
fixture.detectChanges();
|
||||
|
||||
expect(fixture.componentInstance.error).toBe(true);
|
||||
expect(compiled.querySelector('#login-error').innerText).toEqual('login-error-message');
|
||||
});
|
||||
}));
|
||||
|
||||
it('should return error with a wrong username and password ', injectAsync([TestComponentBuilder], (tcb:TestComponentBuilder) => {
|
||||
it('should return error with a wrong username and password ', injectAsync([TestComponentBuilder], (tcb: TestComponentBuilder) => {
|
||||
return tcb
|
||||
.createAsync(AlfrescoLoginComponent)
|
||||
.then((fixture) => {
|
||||
@@ -280,19 +285,22 @@ describe('AlfrescoLogin', () => {
|
||||
|
||||
let compiled = fixture.debugElement.nativeElement;
|
||||
|
||||
component.form._value.username = 'fake-wrong-username';
|
||||
component.form._value.password = 'fake-wrong-password';
|
||||
component.form.controls.username._value = 'fake-wrong-username';
|
||||
component.form.controls.password._value = 'fake-wrong-password';
|
||||
|
||||
fixture.detectChanges();
|
||||
|
||||
compiled.querySelector('button').click();
|
||||
|
||||
fixture.detectChanges();
|
||||
|
||||
expect(fixture.componentInstance.error).toBe(true);
|
||||
expect(compiled.querySelector('#login-error').innerText).toEqual('login-error-message');
|
||||
});
|
||||
}));
|
||||
|
||||
|
||||
it('should emit onSuccess event after the login has succeeded', injectAsync([TestComponentBuilder], (tcb:TestComponentBuilder) => {
|
||||
it('should emit onSuccess event after the login has succeeded', injectAsync([TestComponentBuilder], (tcb: TestComponentBuilder) => {
|
||||
return tcb
|
||||
.createAsync(AlfrescoLoginComponent)
|
||||
.then((fixture) => {
|
||||
@@ -302,33 +310,41 @@ describe('AlfrescoLogin', () => {
|
||||
};
|
||||
spyOn(component.onSuccess, 'emit');
|
||||
|
||||
component.form._value.username = 'fake-username';
|
||||
component.form._value.password = 'fake-password';
|
||||
let compiled = fixture.debugElement.nativeElement;
|
||||
|
||||
component.form.controls.username._value = 'fake-username';
|
||||
component.form.controls.password._value = 'fake-password';
|
||||
|
||||
fixture.detectChanges();
|
||||
|
||||
// trigger the click
|
||||
let nativeElement = fixture.nativeElement;
|
||||
let button = nativeElement.querySelector('button');
|
||||
button.dispatchEvent(new Event('click'));
|
||||
|
||||
fixture.detectChanges();
|
||||
|
||||
expect(fixture.componentInstance.error).toBe(false);
|
||||
expect(compiled.querySelector('#login-success').innerHTML).toEqual('login-success-message');
|
||||
expect(component.onSuccess.emit).toHaveBeenCalledWith({value: 'Login OK'});
|
||||
});
|
||||
}));
|
||||
|
||||
it('should emit onError event after the login has failed', injectAsync([TestComponentBuilder], (tcb:TestComponentBuilder) => {
|
||||
it('should emit onError event after the login has failed', injectAsync([TestComponentBuilder], (tcb: TestComponentBuilder) => {
|
||||
return tcb
|
||||
.createAsync(AlfrescoLoginComponent)
|
||||
.then((fixture) => {
|
||||
//pipes.config();
|
||||
let component = fixture.componentInstance;
|
||||
component.isErrorStyle = function () {
|
||||
|
||||
};
|
||||
spyOn(component.onError, 'emit');
|
||||
|
||||
component.form._value.username = 'fake-wrong-username';
|
||||
component.form._value.password = 'fake-password';
|
||||
let compiled = fixture.debugElement.nativeElement;
|
||||
|
||||
component.form.controls.username._value = 'fake-wrong-username';
|
||||
component.form.controls.password._value = 'fake-password';
|
||||
|
||||
fixture.detectChanges();
|
||||
|
||||
// trigger the click
|
||||
let nativeElement = fixture.nativeElement;
|
||||
@@ -337,6 +353,8 @@ describe('AlfrescoLogin', () => {
|
||||
|
||||
fixture.detectChanges();
|
||||
|
||||
expect(fixture.componentInstance.error).toBe(true);
|
||||
expect(compiled.querySelector('#login-error').innerText).toEqual('login-error-message');
|
||||
expect(component.onError.emit).toHaveBeenCalledWith({value: 'Login KO'});
|
||||
});
|
||||
}));
|
||||
|
@@ -81,7 +81,7 @@ export class AlfrescoLoginComponent {
|
||||
|
||||
this.form.valueChanges.subscribe(data => this.onValueChanged(data));
|
||||
|
||||
this.onValueChanged();
|
||||
this.onValueChanged(null);
|
||||
}
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user