Skip to content

Commit

Permalink
Merge pull request #15523 from RogueTea/rating-unit-tests-fix
Browse files Browse the repository at this point in the history
Rating: fix unit tests
  • Loading branch information
cetincakiroglu authored May 14, 2024
2 parents 0e5bb52 + c11ff74 commit d6f887e
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions src/app/components/rating/rating.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@ describe('Rating', () => {
fixture.detectChanges();

const starElements = fixture.debugElement.queryAll(By.css('span'));
expect(starElements[0].nativeElement.className).toContain('Primeng Rocks!');
expect(starElements[0].nativeElement.style.height).toEqual('300px');
expect(starElements[1].nativeElement.className).toContain('Primeng Rocks!');
expect(starElements[1].nativeElement.style.height).toEqual('300px');
});

it('should value 3', () => {
Expand All @@ -86,11 +86,18 @@ describe('Rating', () => {
rating.onRate.subscribe((value) => (onRateValue = value));
rating.onCancel.subscribe((value) => (onCancelRate = value));
thirdStarEl.parentElement.click();
cancelEl.parentElement.click();
fixture.detectChanges();

expect(onRateValue.value).toEqual(3);
expect(onCancelRate).toBeTruthy();

const cancelspy = spyOn(rating.onCancel, 'emit').and.callThrough();
const onModelChangeSpy = spyOn(rating, 'onModelChange').and.callThrough();
cancelEl.parentElement.click();
fixture.detectChanges();

expect(onModelChangeSpy).toHaveBeenCalled();
expect(rating.value).toEqual(null);
expect(cancelspy).toHaveBeenCalled();
});

it('should clear value', () => {
Expand Down

0 comments on commit d6f887e

Please sign in to comment.