notificationType?: IndexationNotificationType;
}
+const COMPLETED_NOTIFICATION_DISPLAY_DURATION = 5000;
+
export class IndexationNotification extends React.PureComponent<Props, State> {
state: State = {};
isSystemAdmin = false;
notificationType: IndexationNotificationType.Completed
});
IndexationNotificationHelper.markCompletedNotificationAsDisplayed();
+
+ // Hide after some time
+ setTimeout(() => {
+ this.refreshNotification();
+ }, COMPLETED_NOTIFICATION_DISPLAY_DURATION);
} else {
this.setState({ notificationType: undefined });
}
expect(wrapper.state().notificationType).toBe(IndexationNotificationType.Completed);
});
- it('should be hidden on refresh once displayed', () => {
+ it('should be hidden once displayed', () => {
+ jest.useFakeTimers();
(IndexationNotificationHelper.shouldDisplayCompletedNotification as jest.Mock).mockReturnValueOnce(
true
);
expect(wrapper.state().notificationType).toBe(IndexationNotificationType.Completed);
expect(IndexationNotificationHelper.markCompletedNotificationAsDisplayed).toHaveBeenCalled();
+
+ jest.runAllTimers();
+ expect(wrapper.state().notificationType).toBeUndefined();
+
+ jest.useRealTimers();
});
});