-
Notifications
You must be signed in to change notification settings - Fork 5
Shuhan #3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Shuhan #3
Conversation
parent) component to counter(child) component
…corresponding test
| <!-- <app-counter *ngFor="let counter of counters, index as i" [number]="counter.num" (change)="counter.num = $event"> | ||
| </app-counter> | ||
| <button (click)="removeCounter(i)" >Remove</button> --> | ||
| <div class="counter-format" *ngFor="let counter of counters; let i = index"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good: remove counter from group instead of passing the id to counter! 👍
|
Good:
|
| @@ -0,0 +1,11 @@ | |||
| <button (click)="onAdd()">Add counter</button> | |||
| <!-- <app-counter *ngFor="let counter of counters, index as i" [number]="counter.num" (change)="counter.num = $event"> | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suggestion: remove dead code
| const incrementValue=3 | ||
| component.counters[0].num += incrementValue | ||
|
|
||
| expect(component.sum).toEqual(initialSum+incrementValue) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suggestion: initialSum+incrementValue can be extracted as a const named expected
| it('should reset numbers in counters to 0 when call resetSum', () => { | ||
| component.reset() | ||
| const resetSum = component.sum | ||
| expect(resetSum).toBe(0) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suggestion: no need to verify Sum here, since we already cover the logic in another test
| const resetSum = component.sum | ||
| expect(resetSum).toBe(0) | ||
|
|
||
| component.counters.forEach(counter => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
well: nice to verify counters when test reset.
| }) | ||
|
|
||
| it('should reset numbers in counters to 0 when call resetSum', () => { | ||
| component.reset() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suggestion: we also need give init data for counters, to see the value change, like
components.counters = {
{num: 1},
{num: 2}
}
No description provided.