Skip to content

Commit

Permalink
fix(announcements): Fix the error showing in the onchange (#27777)
Browse files Browse the repository at this point in the history
* #27773 Fix the error showing in the onchange

* Adding test

* Adding test
  • Loading branch information
manuelrojas committed Mar 1, 2024
1 parent 84d170e commit 8328aa1
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
Expand Up @@ -111,4 +111,18 @@ describe('DotToolbarAnnouncementsComponent', () => {
const announcementLink = spectator.query(byTestId('announcements__about-link'));
expect(announcementLink.getAttribute('target')).toBe('_blank');
});

it('should call markAnnouncementsAsRead on ng on init', () => {
const refreshUtmParametersSpy = spyOn(
spectator.component.announcementsStore,
'refreshUtmParameters'
);
spectator.component.ngOnInit();
expect(refreshUtmParametersSpy).toHaveBeenCalled();

// Checking that is not called again in the ngOnChanges
refreshUtmParametersSpy.calls.reset();
spectator.component.ngOnChanges({ showUnreadAnnouncement: { currentValue: false } });
expect(refreshUtmParametersSpy).not.toHaveBeenCalled();
});
});
Expand Up @@ -61,12 +61,12 @@ export class DotToolbarAnnouncementsComponent implements OnInit, OnChanges {

ngOnInit(): void {
this.announcementsStore.load();
this.announcementsStore.refreshUtmParameters();
this.aboutLinks = this.getAboutLinks();
}

ngOnChanges(changes): void {
if (!changes.showUnreadAnnouncement.currentValue) {
this.announcementsStore.refreshUtmParameters();
this.announcementsStore.markAnnouncementsAsRead();
}
}
Expand Down

0 comments on commit 8328aa1

Please sign in to comment.