diff --git a/lib/core/notifications/components/notification-history.component.spec.ts b/lib/core/notifications/components/notification-history.component.spec.ts index 9697f83a0b..da5857723d 100644 --- a/lib/core/notifications/components/notification-history.component.spec.ts +++ b/lib/core/notifications/components/notification-history.component.spec.ts @@ -21,6 +21,7 @@ import { CoreTestingModule } from '../../testing/core.testing.module'; import { NotificationHistoryComponent } from './notification-history.component'; import { OverlayContainer } from '@angular/cdk/overlay'; import { NotificationService } from '../services/notification.service'; +import { StorageService } from '../../services/storage.service'; describe('Notification History Component', () => { @@ -28,6 +29,7 @@ describe('Notification History Component', () => { let element: HTMLElement; let notificationService: NotificationService; let overlayContainerElement: HTMLElement; + let storage: StorageService; function openNotification() { fixture.detectChanges(); @@ -44,6 +46,7 @@ describe('Notification History Component', () => { fixture = TestBed.createComponent(NotificationHistoryComponent); element = fixture.nativeElement; + storage = TestBed.get(StorageService); notificationService = TestBed.get(NotificationService); })); @@ -76,5 +79,17 @@ describe('Notification History Component', () => { done(); }); }); + + it('should remove notification from storage when mark all as read', (done) => { + openNotification(); + fixture.whenStable().then(() => { + const markAllAsRead = overlayContainerElement.querySelector('#adf-notification-history-mark-as-read button'); + markAllAsRead.click(); + fixture.detectChanges(); + expect(storage.getItem('notifications')).toBeNull(); + done(); + }); + + }); }); }); diff --git a/lib/core/notifications/components/notification-history.component.ts b/lib/core/notifications/components/notification-history.component.ts index 7b21821a9c..95098f5763 100644 --- a/lib/core/notifications/components/notification-history.component.ts +++ b/lib/core/notifications/components/notification-history.component.ts @@ -72,7 +72,7 @@ export class NotificationHistoryComponent implements OnDestroy { } markAsRead() { - this.storageService.setItem('notifications', ''); + this.storageService.removeItem('notifications'); this.notifications = []; }