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
@Component({ | |
selector: 'my-app', | |
template: ` | |
<h1>Envie seu feedback</h1> | |
<form [formGroup]="form" (ngSubmit)="onSubmit()"> | |
<div> | |
<label> | |
Sua avaliação: | |
<app-star-rating formControlName="rating"></app-star-rating> | |
</label> |
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
<i>{{ displayText }}</i> | |
<div class="stars" [ngClass]="{ disabled }"> | |
<ng-container *ngFor="let rating of ratings"> | |
<svg | |
title="{{ rating.text }}" | |
height="25" | |
width="23" | |
class="star rating" | |
[ngClass]="{ selected: rating.stars <= value }" | |
(mouseover)="displayText = !disabled ? rating.text : ''" |
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
type Rating = { stars: number; text: string }; | |
@Component({ | |
selector: 'app-star-rating', | |
templateUrl: './star-rating.component.html', | |
providers: [ | |
{ | |
provide: NG_VALUE_ACCESSOR, | |
useExisting: forwardRef(() => StarRatingComponent), | |
multi: true, |
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
@Component({ | |
selector: 'app-star-rating', | |
templateUrl: './star-rating.component.html', | |
providers: [ | |
{ | |
provide: NG_VALUE_ACCESSOR, | |
useExisting: forwardRef(() => StarRatingComponent), | |
multi: true, | |
}, | |
], |
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
@Component({ | |
selector: 'app-star-rating', | |
templateUrl: './star-rating.component.html' | |
}) | |
export class StarRatingComponent implements ControlValueAccessor { | |
protected disabled: boolean; | |
protected value: number; | |
onChanged: (stars: number) => void; | |
onTouched: () => void; |
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
import { render, screen } from '@testing-library/angular'; | |
const setup = async () => { | |
await render(UsersComponent); | |
} | |
describe('UsersComponent', () => { | |
it('should display table', async () => { | |
await setup(); | |
const table = screen.getByTestId('table'); |
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
const usersPo = new UsersPageObject(); | |
Given('acesso a página de usuários', () => { | |
usersPo.navigateToPage(); | |
}); | |
When('o carregamento é finalizado', () => { | |
usersPo.hideLoading(); | |
}); |
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
#language: pt | |
Funcionalidade: Usuários | |
Cenário: Visualizar usuários | |
Dado acesso a página de usuários | |
Quando o carregamento é finalizado | |
Então devo visualizar uma listagem com todos os usuários |
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
bootstrapApplication(AppComponent, { | |
providers: [ | |
provideRouter(appRoutes) | |
] | |
}); |