about summary refs log tree commit diff
path: root/__mocks__
diff options
context:
space:
mode:
authorPaul Frazee <pfrazee@gmail.com>2023-01-24 19:32:24 -0600
committerGitHub <noreply@github.com>2023-01-24 19:32:24 -0600
commit869f6c4e0e464b7f5be9ef5676210ae8844bd834 (patch)
treea9a823723099129bb25c4b57435925b481d54266 /__mocks__
parent21f5f4de157a73b3c4406461b2a36555b1bff228 (diff)
downloadvoidsky-869f6c4e0e464b7f5be9ef5676210ae8844bd834.tar.zst
Initial pass at push notifications + some fixes to the session management (#91)
* Fix: test the session during resume to ensure it's valid

* Don't delete sessions for now

* Add notifee and request notif permissions on first login

* Set unread notifications badge on app icon

* Trigger a notifee card on new notifications

* Experimental: use react-native-background-fetch to check for notifications

* Add missing mocks

* Fix to resumeSession()
Diffstat (limited to '__mocks__')
-rw-r--r--__mocks__/@notifee/react-native.ts6
-rw-r--r--__mocks__/react-native-background-fetch.ts4
-rw-r--r--__mocks__/state-mock.ts21
3 files changed, 21 insertions, 10 deletions
diff --git a/__mocks__/@notifee/react-native.ts b/__mocks__/@notifee/react-native.ts
new file mode 100644
index 000000000..7e5ccec93
--- /dev/null
+++ b/__mocks__/@notifee/react-native.ts
@@ -0,0 +1,6 @@
+export default {
+  requestPermission: jest.fn(),
+  onForegroundEvent: jest.fn(),
+  setBadgeCount: jest.fn(),
+  displayNotification: jest.fn(),
+}
diff --git a/__mocks__/react-native-background-fetch.ts b/__mocks__/react-native-background-fetch.ts
new file mode 100644
index 000000000..0cb644c4d
--- /dev/null
+++ b/__mocks__/react-native-background-fetch.ts
@@ -0,0 +1,4 @@
+export default {
+  configure: jest.fn().mockResolvedValue(0),
+  finish: jest.fn(),
+}
diff --git a/__mocks__/state-mock.ts b/__mocks__/state-mock.ts
index 129f9c859..f5676288f 100644
--- a/__mocks__/state-mock.ts
+++ b/__mocks__/state-mock.ts
@@ -64,7 +64,7 @@ export const mockedProfileStore = {
   isUser: true,
   isScene: false,
   setup: jest.fn().mockResolvedValue({aborted: false}),
-  refresh: jest.fn(),
+  refresh: jest.fn().mockResolvedValue({}),
   toggleFollowing: jest.fn().mockResolvedValue({}),
   updateProfile: jest.fn(),
   // unknown required because of the missing private methods: _xLoading, _xIdle, _load, _replaceAll
@@ -106,7 +106,7 @@ export const mockedMembersStore = {
   isEmpty: false,
   isMember: jest.fn(),
   setup: jest.fn().mockResolvedValue({aborted: false}),
-  refresh: jest.fn(),
+  refresh: jest.fn().mockResolvedValue({}),
   loadMore: jest.fn(),
   removeMember: jest.fn(),
   // unknown required because of the missing private methods: _xLoading, _xIdle, _fetch, _replaceAll, _append
@@ -149,7 +149,7 @@ export const mockedMembershipsStore = {
   isEmpty: false,
   isMemberOf: jest.fn(),
   setup: jest.fn().mockResolvedValue({aborted: false}),
-  refresh: jest.fn(),
+  refresh: jest.fn().mockResolvedValue({}),
   loadMore: jest.fn(),
   // unknown required because of the missing private methods: _xLoading, _xIdle, _fetch, _replaceAll, _append
 } as unknown as MembershipsViewModel
@@ -413,6 +413,7 @@ export const mockedNotificationsViewItemStore = {
     createdAt: '',
   }),
   fetchAdditionalData: jest.fn(),
+  toNotifeeOpts: jest.fn(),
 } as NotificationsViewItemModel
 
 export const mockedNotificationsStore = {
@@ -510,7 +511,7 @@ export const mockedNavigationTabStore = {
     },
   ],
   navigate: jest.fn(),
-  refresh: jest.fn(),
+  refresh: jest.fn().mockResolvedValue({}),
   goBack: jest.fn(),
   fixedTabReset: jest.fn(),
   goForward: jest.fn(),
@@ -539,7 +540,7 @@ export const mockedNavigationStore = {
   tabCount: 1,
   isCurrentScreen: jest.fn(),
   navigate: jest.fn(),
-  refresh: jest.fn(),
+  refresh: jest.fn().mockResolvedValue({}),
   setTitle: jest.fn(),
   handleLink: jest.fn(),
   switchTo: jest.fn(),
@@ -587,7 +588,7 @@ export const mockedMeStore = {
   clear: jest.fn(),
   load: jest.fn(),
   clearNotificationCount: jest.fn(),
-  fetchStateUpdate: jest.fn(),
+  fetchNotifications: jest.fn(),
   refreshMemberships: jest.fn(),
 } as MeModel
 
@@ -679,7 +680,7 @@ export const mockedProfileUiStore = {
   setSelectedViewIndex: jest.fn(),
   setup: jest.fn().mockResolvedValue({aborted: false}),
   update: jest.fn(),
-  refresh: jest.fn(),
+  refresh: jest.fn().mockResolvedValue({}),
   loadMore: jest.fn(),
 } as ProfileUiModel
 
@@ -788,7 +789,7 @@ export const mockedSuggestedActorsStore = {
   hasError: false,
   isEmpty: false,
   setup: jest.fn().mockResolvedValue(null),
-  refresh: jest.fn(),
+  refresh: jest.fn().mockResolvedValue({}),
   // unknown required because of the missing private methods: _xLoading, _xIdle, _fetch, _appendAll, _append
 } as unknown as SuggestedActorsViewModel
 
@@ -828,7 +829,7 @@ export const mockedUserFollowersStore = {
   hasError: false,
   isEmpty: false,
   setup: jest.fn(),
-  refresh: jest.fn(),
+  refresh: jest.fn().mockResolvedValue({}),
   loadMore: jest.fn(),
   // unknown required because of the missing private methods: _xIdle, _xLoading, _fetch, _replaceAll, _append
 } as unknown as UserFollowersViewModel
@@ -869,7 +870,7 @@ export const mockedUserFollowsStore = {
   hasError: false,
   isEmpty: false,
   setup: jest.fn(),
-  refresh: jest.fn(),
+  refresh: jest.fn().mockResolvedValue({}),
   loadMore: jest.fn(),
   // unknown required because of the missing private methods: _xIdle, _xLoading, _fetch, _replaceAll, _append
 } as unknown as UserFollowsViewModel