From 8b69908600f2c2a801b3ac474014bba28984a11f Mon Sep 17 00:00:00 2001 From: Andre Christoga Pramaditya Date: Tue, 14 Jun 2022 21:31:47 +0700 Subject: [PATCH] feat(jest): 80% coverage for store/ui/mutations --- store/ui/mutations.test.ts | 145 +++++++++++++++++++++++++++++++++++++ 1 file changed, 145 insertions(+) diff --git a/store/ui/mutations.test.ts b/store/ui/mutations.test.ts index 1b6594c9e7..838fa69cb5 100644 --- a/store/ui/mutations.test.ts +++ b/store/ui/mutations.test.ts @@ -3920,6 +3920,151 @@ describe('mutations', () => { }, ]) }) + test('update group notifications', () => { + // previously they are unread + const localizedState = { + contextMenuStatus: false, + showSidebarUsers: true, + showSidebar: true, + notifications: [ + { + _id: '01g2y9d6499169rzs5etrff48w', + _mod: 1652431427721842400, + at: 1652431426842, + content: { description: 'New DM', title: 'Notification' }, + from: 'Andre2', + id: '69c1ad1d-37e9-4ff5-b929-de5509512a11', + state: 'UNREAD', + type: 'Direct Message', + }, + { + _id: '01g2ya7w44h4c5mm4bgyedkrvy', + _mod: 1652432302212590600, + at: 1652432301322, + content: { description: 'New DM', title: 'Notification' }, + from: 'Andre2', + id: '62fceb8d-60a5-4434-92e8-c07f52f9e8e6', + state: 'UNREAD', + type: 'Group Message', + }, + ], + showSearchResult: false, + showSettings: false, + showMedia: false, + settingsSideBar: true, + settingsRoute: 'personalize', + quickProfile: false, + userProfile: {}, + contextMenuValues: [], + contextMenuPosition: { + x: 0, + y: 0, + }, + quickProfilePosition: { + x: 0, + y: 0, + }, + modals: { + callToAction: false, + changelog: false, + createServer: false, + creategroup: false, + crop: false, + error: false, + glyph: false, + }, + groupInvite: { + isOpen: false, + marketplace: false, + newfolder: false, + quickchat: false, + renameFile: false, + userProfile: false, + wallet: false, + walletMini: false, + glyphModalPack: '', + chatbarContent: '', + }, + replyChatbarContent: { + from: '', + id: '', + payload: '', + chatbarFocus: false, + fullscreen: false, + showPinned: false, + }, + enhancers: { + containerWidth: 0, + defaultHeight: '30rem', + defaultWidth: '24rem', + floating: false, + position: [0, 0], + route: 'emotes', + show: false, + messages: [], + unreadMessage: 0, + isScrollOver: false, + showOlderMessagesInfo: false, + isTyping: false, + isReacted: false, + activeChannel: undefined, + }, + settingReaction: { + groupID: null, + messageID: null, + status: false, + hoveredGlyphInfo: undefined, + }, + glyphMarketplaceView: { + shopId: null, + view: 'home', + }, + editMessage: { + from: '', + id: '', + payload: '', + mostEmojiUsed: [], + recentGlyphs: [], + }, + theme: {}, + base: { + class: '', + name: 'default', + text: 'Default', + value: 'default', + }, + flair: { + text: 'Satellite', + value: '#2761fd', + filesUploadStatus: '', + renameItem: undefined, + filePreview: undefined, + fileDownloadList: [], + chatImageOverlay: undefined, + }, + fileSort: { + asc: true, + category: 'modified', + }, + swiperSlideIndex: 0, + } + mutations.default.updateGroupNotifications(localizedState) + expect(localizedState.notifications).toEqual([ + { + _id: '01g2y9d6499169rzs5etrff48w', + _mod: 1652431427721842400, + at: 1652431426842, + content: { + description: 'New DM', + title: 'Notification', + }, + from: 'Andre2', + id: '69c1ad1d-37e9-4ff5-b929-de5509512a11', + state: 'UNREAD', + type: 'Direct Message', + }, + ]) + }) test('remove specified notification', () => { // previously they are unread const localizedState = {