Skip to content

Commit

Permalink
test(package): added and fixed register comp. spec #323
Browse files Browse the repository at this point in the history
  • Loading branch information
AnthonyNahas committed Aug 22, 2019
1 parent 980385c commit e8d9d4f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,9 @@
<!-- </div>-->

<button mat-raised-button
aria-label="CREATE AN ACCOUNT"
id="createAccountButton"
class="submit-button"
aria-label="CREATE AN ACCOUNT"
[color]="colorAccent"
[disabled]="registerForm.invalid"
(click)="createAccount()">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,25 +106,28 @@ describe('NgxAuthFirebaseuiRegisterComponent', () => {
expect(errors['required']).toBeFalsy();
});

it('login form validity', () => {
it('register form validity', () => {
expect(component.registerForm.valid).toBeFalsy();
component.registerForm.controls['name'].setValue('Test XYZ');
component.registerForm.controls['email'].setValue('[email protected]');
component.registerForm.controls['password'].setValue('123456789');
component.registerForm.controls['passwordConfirm'].setValue('123456789');
expect(component.registerForm.valid).toBeTruthy();
});

it('should login button be disabled if the login form is invalid', () => {
const loginButton: DebugElement = fixture.debugElement.query(By.css('#loginButton'));
expect(loginButton.nativeElement.disabled).toBeTruthy();
console.log('loginButton', loginButton);
it('should create account button be disabled if the register form is invalid', () => {
const createAccountButton: DebugElement = fixture.debugElement.query(By.css('#createAccountButton'));
expect(createAccountButton.nativeElement.disabled).toBeTruthy();
});

it('should create button be enabled if the register form is valid', () => {
const loginButton: DebugElement = fixture.debugElement.query(By.css('#loginButton'));
const createAccountButton: DebugElement = fixture.debugElement.query(By.css('#createAccountButton'));
component.registerForm.controls['name'].setValue('Test XYZ');
component.registerForm.controls['email'].setValue('[email protected]');
component.registerForm.controls['password'].setValue('123456789');
component.registerForm.controls['passwordConfirm'].setValue('123456789');
fixture.detectChanges();
expect(loginButton.nativeElement.disabled).toBeFalsy();
expect(createAccountButton.nativeElement.disabled).toBeFalsy();
});

});

0 comments on commit e8d9d4f

Please sign in to comment.