diff --git a/lib/content-services/social/like.component.spec.ts b/lib/content-services/social/like.component.spec.ts index 1b3ebc2f7f..c21e447ec6 100644 --- a/lib/content-services/social/like.component.spec.ts +++ b/lib/content-services/social/like.component.spec.ts @@ -60,6 +60,8 @@ describe('Like component', () => { } it('should load the likes by default on onChanges', async(() => { + component.ngOnChanges(); + simulateResponseWithLikes(2); fixture.whenStable().then(() => { diff --git a/lib/content-services/social/like.component.ts b/lib/content-services/social/like.component.ts index 8d69474d20..50d143dab4 100644 --- a/lib/content-services/social/like.component.ts +++ b/lib/content-services/social/like.component.ts @@ -15,7 +15,7 @@ * limitations under the License. */ -import { Component, EventEmitter, Input, OnInit, Output, ViewEncapsulation } from '@angular/core'; +import { Component, EventEmitter, Input, OnChanges, Output, ViewEncapsulation } from '@angular/core'; import { RatingService } from './services/rating.service'; @Component({ @@ -25,7 +25,7 @@ import { RatingService } from './services/rating.service'; providers: [RatingService], encapsulation: ViewEncapsulation.None }) -export class LikeComponent implements OnInit { +export class LikeComponent implements OnChanges { @Input() nodeId: string; @@ -39,7 +39,7 @@ export class LikeComponent implements OnInit { constructor(private ratingService: RatingService) {} - ngOnInit() { + ngOnChanges() { this.clean(); this.ratingService.getRating(this.nodeId, this.ratingType).subscribe(