Skip to content

Commit

Permalink
adding basic tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Stephanie Katterwe committed Mar 16, 2022
1 parent 3c953c1 commit 1a0d6eb
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion src/app/home/home.component.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,5 70,19 @@ describe('HomeComponent', () => {
expect(elem.nativeElement.textContent).toContain('Counter: 1');
});

it('should not decrease below 0', () => {});
it('should not decrease below 0', () => {
fixture.detectChanges();

expect(component.count).toEqual(0);

const decreaseButton: DebugElement = fixture.debugElement.query(By.css('[data-testid="btn-decrease"]'));
decreaseButton.triggerEventHandler('click', null);

expect(component.count).toEqual(0);

fixture.detectChanges(); // NOT TRIGGER ON INIT JUST UPDATES VALUE REFERENCES FROM COMPONENT IN DOM

const elem: DebugElement = fixture.debugElement.query(By.css('p'));
expect(elem.nativeElement.textContent).toContain('Counter: 0');
});
});

0 comments on commit 1a0d6eb

Please sign in to comment.