diff --git a/src/app/components/rating/rating.spec.ts b/src/app/components/rating/rating.spec.ts index cf51231a69e..344abc8adab 100755 --- a/src/app/components/rating/rating.spec.ts +++ b/src/app/components/rating/rating.spec.ts @@ -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', () => { @@ -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', () => {