mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-24 17:32:15 +00:00
[AAE-2537] - fix mark as read notification (#5667)
* [AAE-2537] - fix mark as read notification * lint * fix unit test Co-authored-by: Silviu Popa <p3701014@L3700101120.ness.com>
This commit is contained in:
@@ -21,6 +21,7 @@ import { CoreTestingModule } from '../../testing/core.testing.module';
|
|||||||
import { NotificationHistoryComponent } from './notification-history.component';
|
import { NotificationHistoryComponent } from './notification-history.component';
|
||||||
import { OverlayContainer } from '@angular/cdk/overlay';
|
import { OverlayContainer } from '@angular/cdk/overlay';
|
||||||
import { NotificationService } from '../services/notification.service';
|
import { NotificationService } from '../services/notification.service';
|
||||||
|
import { StorageService } from '../../services/storage.service';
|
||||||
|
|
||||||
describe('Notification History Component', () => {
|
describe('Notification History Component', () => {
|
||||||
|
|
||||||
@@ -28,6 +29,7 @@ describe('Notification History Component', () => {
|
|||||||
let element: HTMLElement;
|
let element: HTMLElement;
|
||||||
let notificationService: NotificationService;
|
let notificationService: NotificationService;
|
||||||
let overlayContainerElement: HTMLElement;
|
let overlayContainerElement: HTMLElement;
|
||||||
|
let storage: StorageService;
|
||||||
|
|
||||||
function openNotification() {
|
function openNotification() {
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
@@ -44,6 +46,7 @@ describe('Notification History Component', () => {
|
|||||||
fixture = TestBed.createComponent(NotificationHistoryComponent);
|
fixture = TestBed.createComponent(NotificationHistoryComponent);
|
||||||
element = fixture.nativeElement;
|
element = fixture.nativeElement;
|
||||||
|
|
||||||
|
storage = TestBed.get(StorageService);
|
||||||
notificationService = TestBed.get(NotificationService);
|
notificationService = TestBed.get(NotificationService);
|
||||||
}));
|
}));
|
||||||
|
|
||||||
@@ -76,5 +79,17 @@ describe('Notification History Component', () => {
|
|||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should remove notification from storage when mark all as read', (done) => {
|
||||||
|
openNotification();
|
||||||
|
fixture.whenStable().then(() => {
|
||||||
|
const markAllAsRead = <HTMLButtonElement> overlayContainerElement.querySelector('#adf-notification-history-mark-as-read button');
|
||||||
|
markAllAsRead.click();
|
||||||
|
fixture.detectChanges();
|
||||||
|
expect(storage.getItem('notifications')).toBeNull();
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@@ -72,7 +72,7 @@ export class NotificationHistoryComponent implements OnDestroy {
|
|||||||
}
|
}
|
||||||
|
|
||||||
markAsRead() {
|
markAsRead() {
|
||||||
this.storageService.setItem('notifications', '');
|
this.storageService.removeItem('notifications');
|
||||||
this.notifications = [];
|
this.notifications = [];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user