-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
150 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
.form-field { | ||
width: 100%; | ||
} | ||
|
||
.container { | ||
display: flex; | ||
justify-content: end; | ||
} |
31 changes: 30 additions & 1 deletion
31
modules/feature/auth/form/src/lib/auth-form/auth-form-email/auth-form-email.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,30 @@ | ||
<p>auth-form-email works!</p> | ||
<mat-form-field appearance="outline" class="form-field"> | ||
<mat-label>Informe seu email</mat-label> | ||
<input | ||
[formControl]="control" | ||
autofocus | ||
matInput | ||
placeholder="Ex: [email protected]" | ||
type="email" | ||
/> | ||
@if (control.hasError('email') && !control.hasError('required')) { | ||
<mat-error data-testid="error-email" | ||
>Por favor, informe um e-mail válido</mat-error | ||
> | ||
} @if (control.hasError('required')) { | ||
<mat-error data-testid="error-required" | ||
>O e-mail é <strong>obrigatório</strong></mat-error | ||
> | ||
} | ||
</mat-form-field> | ||
|
||
<div class="container"> | ||
<button | ||
[disabled]="control.invalid" | ||
mat-raised-button | ||
color="primary" | ||
[routerLink]="['../', 'password']" | ||
> | ||
Próximo | ||
</button> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,17 @@ | ||
import { ComponentFixture, TestBed } from '@angular/core/testing'; | ||
import { AuthFormEmailComponent } from './auth-form-email.component'; | ||
import { AuthFormComponent } from '../auth-form.component'; | ||
import { NoopAnimationsModule } from '@angular/platform-browser/animations'; | ||
import { provideRouter } from '@angular/router'; | ||
|
||
describe('AuthFormEmailComponent', () => { | ||
let component: AuthFormEmailComponent; | ||
let fixture: ComponentFixture<AuthFormEmailComponent>; | ||
|
||
beforeEach(async () => { | ||
await TestBed.configureTestingModule({ | ||
imports: [AuthFormEmailComponent], | ||
providers: [AuthFormComponent], | ||
imports: [AuthFormEmailComponent, NoopAnimationsModule], | ||
providers: [AuthFormComponent, provideRouter([])], | ||
}).compileComponents(); | ||
|
||
fixture = TestBed.createComponent(AuthFormEmailComponent); | ||
|
@@ -20,4 +22,40 @@ describe('AuthFormEmailComponent', () => { | |
it('should create', () => { | ||
expect(component).toBeTruthy(); | ||
}); | ||
|
||
it('should enable button when control is valid', () => { | ||
const button = fixture.nativeElement.querySelector('button'); | ||
expect(button.disabled).toBe(true); | ||
|
||
component.control.setValue('[email protected]'); | ||
fixture.detectChanges(); | ||
|
||
expect(button.disabled).toBe(false); | ||
}); | ||
|
||
it('should display required error message', () => { | ||
component.control.markAllAsTouched(); | ||
fixture.detectChanges(); | ||
const error = fixture.nativeElement.querySelector( | ||
'[data-testid="error-required"]' | ||
); | ||
|
||
expect(error).toBeTruthy(); | ||
}); | ||
|
||
it('should display email error message', () => { | ||
// component.control.setValue('teste'); | ||
const input: HTMLInputElement = | ||
fixture.nativeElement.querySelector('input'); | ||
input.value = 'teste'; | ||
input.dispatchEvent(new Event('input')); | ||
|
||
component.control.markAllAsTouched(); | ||
fixture.detectChanges(); | ||
const error = fixture.nativeElement.querySelector( | ||
'[data-testid="error-email"]' | ||
); | ||
|
||
expect(error).toBeTruthy(); | ||
}); | ||
}); |
12 changes: 11 additions & 1 deletion
12
modules/feature/auth/form/src/lib/auth-form/auth-form-email/auth-form-email.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
.form-field { | ||
width: 100%; | ||
} | ||
|
||
.container { | ||
display: flex; | ||
justify-content: end; | ||
} |
15 changes: 14 additions & 1 deletion
15
.../feature/auth/form/src/lib/auth-form/auth-form-password/auth-form-password.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,14 @@ | ||
<p>auth-form-password works!</p> | ||
<mat-form-field appearance="outline" class="form-field"> | ||
<mat-label>Informe sua senha</mat-label> | ||
<input | ||
[formControl]="control" | ||
autofocus | ||
matInput | ||
placeholder="Mínimo de 6 caracteres" | ||
type="password" | ||
/> | ||
</mat-form-field> | ||
|
||
<div class="container"> | ||
<button mat-raised-button color="primary">Entrar</button> | ||
</div> |
6 changes: 4 additions & 2 deletions
6
...ature/auth/form/src/lib/auth-form/auth-form-password/auth-form-password.component.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 9 additions & 1 deletion
10
...es/feature/auth/form/src/lib/auth-form/auth-form-password/auth-form-password.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
modules/feature/auth/form/src/lib/auth-form/auth-form.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
<form class="form" [formGroup]="form"> | ||
<mat-card class="form__card"> | ||
<h1>Entrar</h1> | ||
<router-outlet /> | ||
</mat-card> | ||
</form> |