|
| 1 | +import { NotificationEntity } from 'src/modules/notification/entities/notification.entity'; |
| 2 | +import { NotificationType } from 'src/modules/notification/constants'; |
| 3 | +import { Notification } from 'src/modules/notification/models/notification'; |
| 4 | +import { NotificationsDto } from 'src/modules/notification/dto'; |
| 5 | + |
| 6 | +export const mockGlobalNotificationsJson = { |
| 7 | + notifications: [ |
| 8 | + { |
| 9 | + title: 'RedisGraph End of Life', |
| 10 | + body: 'Redis Inc. has announced the end-of-life of <b>RedisGraph</b>. ' |
| 11 | + + 'We will carry out the process gradually, and in accordance with our commitment to our customers. ' |
| 12 | + + '<p> If you are using RedisGraph - please read the ' |
| 13 | + + '<a href="https://redis.com/blog/redisgraph-eol" target="_blank">following</a> carefully.', |
| 14 | + category: 'important', |
| 15 | + categoryColor: '#800D0D', |
| 16 | + timestamp: 1688549037, |
| 17 | + }, |
| 18 | + { |
| 19 | + title: 'Missing a feature or found a bug?', |
| 20 | + body: 'Would you like to see specific features added or have a bug to report? ' |
| 21 | + + '<p>' |
| 22 | + + ' <a href="https://github.com/RedisInsight/RedisInsight/issues" target="_blank">Share</a> ' |
| 23 | + + 'it with us! <p> ' |
| 24 | + + 'And <b>star</b> the repository if you like RedisInsight!', |
| 25 | + category: 'feedback', |
| 26 | + categoryColor: '#330D80', |
| 27 | + timestamp: 1662381434, |
| 28 | + }, |
| 29 | + ], |
| 30 | +}; |
| 31 | + |
| 32 | +export const mockNotification1 = Object.assign(new Notification(), { |
| 33 | + ...mockGlobalNotificationsJson.notifications[0], |
| 34 | + type: NotificationType.Global, |
| 35 | + read: true, |
| 36 | +}); |
| 37 | + |
| 38 | +export const mockNotification1Entity = Object.assign(new NotificationEntity(), mockNotification1); |
| 39 | + |
| 40 | +export const mockNotification1UPD = Object.assign(new Notification(), { |
| 41 | + ...mockNotification1, |
| 42 | + title: 'UPD RedisGraph End of Life', |
| 43 | +}); |
| 44 | + |
| 45 | +export const mockNotification1UPDEntity = Object.assign(new NotificationEntity(), mockNotification1UPD); |
| 46 | + |
| 47 | +export const mockNotification2 = Object.assign(new Notification(), { |
| 48 | + ...mockGlobalNotificationsJson.notifications[1], |
| 49 | + type: NotificationType.Global, |
| 50 | + read: false, |
| 51 | +}); |
| 52 | +export const mockNotification2Entity = Object.assign(new NotificationEntity(), mockNotification2); |
| 53 | + |
| 54 | +export const mockNotificationsDto = Object.assign(new NotificationsDto(), { |
| 55 | + notifications: [mockNotification1, mockNotification2], |
| 56 | + totalUnread: 1, |
| 57 | +}); |
| 58 | + |
| 59 | +export const mockNotificationRepository = jest.fn(() => ({ |
| 60 | + getNotifications: jest.fn().mockResolvedValue([mockNotification1Entity, mockNotification2Entity]), |
| 61 | + getTotalUnread: jest.fn().mockResolvedValue(mockNotificationsDto.totalUnread), |
| 62 | + readNotifications: jest.fn().mockResolvedValue([]), |
| 63 | + insertNotifications: jest.fn(), |
| 64 | + getGlobalNotifications: jest.fn(), |
| 65 | + deleteGlobalNotifications: jest.fn(), |
| 66 | +})); |
0 commit comments