From d673921fbb561ecea470ce219496ca4eccfd1f74 Mon Sep 17 00:00:00 2001 From: ruben-rebelo Date: Thu, 1 Feb 2024 09:19:51 +0000 Subject: [PATCH 1/5] [TS migration] Migrate @react-native-firebase/crashlytics mock --- .../@react-native-firebase/crashlytics.js | 7 ------- .../@react-native-firebase/crashlytics.ts | 20 +++++++++++++++++++ 2 files changed, 20 insertions(+), 7 deletions(-) delete mode 100644 __mocks__/@react-native-firebase/crashlytics.js create mode 100644 __mocks__/@react-native-firebase/crashlytics.ts diff --git a/__mocks__/@react-native-firebase/crashlytics.js b/__mocks__/@react-native-firebase/crashlytics.js deleted file mode 100644 index cc7ff3f55e4a..000000000000 --- a/__mocks__/@react-native-firebase/crashlytics.js +++ /dev/null @@ -1,7 +0,0 @@ -// uses and we need to mock the imported crashlytics module -// due to an error that happens otherwise https://github.com/invertase/react-native-firebase/issues/2475 -export default () => ({ - log: jest.fn(), - recordError: jest.fn(), - setCrashlyticsCollectionEnabled: jest.fn(), -}); diff --git a/__mocks__/@react-native-firebase/crashlytics.ts b/__mocks__/@react-native-firebase/crashlytics.ts new file mode 100644 index 000000000000..bc0b5b8639bf --- /dev/null +++ b/__mocks__/@react-native-firebase/crashlytics.ts @@ -0,0 +1,20 @@ +import type { FirebaseCrashlyticsTypes } from '@react-native-firebase/crashlytics'; + +// uses and we need to mock the imported crashlytics module +// due to an error that happens otherwise https://github.com/invertase/react-native-firebase/issues/2475 + +type CrashlyticsModule = { + log: FirebaseCrashlyticsTypes.Module['log']; + recordError: FirebaseCrashlyticsTypes.Module['recordError']; + setCrashlyticsCollectionEnabled: FirebaseCrashlyticsTypes.Module['setCrashlyticsCollectionEnabled']; +} + +type CrashlyticsMock = () => CrashlyticsModule; + +const crashlyticsMock: CrashlyticsMock = () => ({ + log: jest.fn(), + recordError: jest.fn(), + setCrashlyticsCollectionEnabled: jest.fn(), +}); + +export default crashlyticsMock From 9928820f9e3d0b0406028f5dd8fc6170e2da9523 Mon Sep 17 00:00:00 2001 From: ruben-rebelo Date: Thu, 1 Feb 2024 09:35:10 +0000 Subject: [PATCH 2/5] [TS migration][crashlytics] Lint and prettier fixed --- __mocks__/@react-native-firebase/crashlytics.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/__mocks__/@react-native-firebase/crashlytics.ts b/__mocks__/@react-native-firebase/crashlytics.ts index bc0b5b8639bf..99419c2df388 100644 --- a/__mocks__/@react-native-firebase/crashlytics.ts +++ b/__mocks__/@react-native-firebase/crashlytics.ts @@ -1,4 +1,4 @@ -import type { FirebaseCrashlyticsTypes } from '@react-native-firebase/crashlytics'; +import type {FirebaseCrashlyticsTypes} from '@react-native-firebase/crashlytics'; // uses and we need to mock the imported crashlytics module // due to an error that happens otherwise https://github.com/invertase/react-native-firebase/issues/2475 @@ -7,7 +7,7 @@ type CrashlyticsModule = { log: FirebaseCrashlyticsTypes.Module['log']; recordError: FirebaseCrashlyticsTypes.Module['recordError']; setCrashlyticsCollectionEnabled: FirebaseCrashlyticsTypes.Module['setCrashlyticsCollectionEnabled']; -} +}; type CrashlyticsMock = () => CrashlyticsModule; @@ -17,4 +17,4 @@ const crashlyticsMock: CrashlyticsMock = () => ({ setCrashlyticsCollectionEnabled: jest.fn(), }); -export default crashlyticsMock +export default crashlyticsMock; From 951f93f1865376265a1969cac27f8812ff9596a8 Mon Sep 17 00:00:00 2001 From: Ruben Rebelo <39693995+ruben-rebelo@users.noreply.github.com> Date: Fri, 2 Feb 2024 09:11:42 +0000 Subject: [PATCH 3/5] [TS migration][Crashlytics] Adjusted comment position MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Fábio Henriques --- __mocks__/@react-native-firebase/crashlytics.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/__mocks__/@react-native-firebase/crashlytics.ts b/__mocks__/@react-native-firebase/crashlytics.ts index 99419c2df388..c4b3942fa9b2 100644 --- a/__mocks__/@react-native-firebase/crashlytics.ts +++ b/__mocks__/@react-native-firebase/crashlytics.ts @@ -11,6 +11,8 @@ type CrashlyticsModule = { type CrashlyticsMock = () => CrashlyticsModule; +// uses and we need to mock the imported crashlytics module +// due to an error that happens otherwise https://github.com/invertase/react-native-firebase/issues/2475 const crashlyticsMock: CrashlyticsMock = () => ({ log: jest.fn(), recordError: jest.fn(), From b2e90afa24193ff5f656f18f097f71913cad8122 Mon Sep 17 00:00:00 2001 From: Ruben Rebelo <39693995+ruben-rebelo@users.noreply.github.com> Date: Fri, 2 Feb 2024 09:51:48 +0000 Subject: [PATCH 4/5] [TS migration][crashlytics] Comment change Co-authored-by: Viktoryia Kliushun --- __mocks__/@react-native-firebase/crashlytics.ts | 3 --- 1 file changed, 3 deletions(-) diff --git a/__mocks__/@react-native-firebase/crashlytics.ts b/__mocks__/@react-native-firebase/crashlytics.ts index c4b3942fa9b2..66bd841d5259 100644 --- a/__mocks__/@react-native-firebase/crashlytics.ts +++ b/__mocks__/@react-native-firebase/crashlytics.ts @@ -1,8 +1,5 @@ import type {FirebaseCrashlyticsTypes} from '@react-native-firebase/crashlytics'; -// uses and we need to mock the imported crashlytics module -// due to an error that happens otherwise https://github.com/invertase/react-native-firebase/issues/2475 - type CrashlyticsModule = { log: FirebaseCrashlyticsTypes.Module['log']; recordError: FirebaseCrashlyticsTypes.Module['recordError']; From b1411184967b8cecf9aa8e519a7df2fd43302248 Mon Sep 17 00:00:00 2001 From: Ruben Rebelo <39693995+ruben-rebelo@users.noreply.github.com> Date: Wed, 7 Feb 2024 08:40:26 +0000 Subject: [PATCH 5/5] [TS migration][crashlytics] Update __mocks__/@react-native-firebase/crashlytics.ts Co-authored-by: Abdelhafidh Belalia <16493223+s77rt@users.noreply.github.com> --- __mocks__/@react-native-firebase/crashlytics.ts | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/__mocks__/@react-native-firebase/crashlytics.ts b/__mocks__/@react-native-firebase/crashlytics.ts index 66bd841d5259..2df845ba0c69 100644 --- a/__mocks__/@react-native-firebase/crashlytics.ts +++ b/__mocks__/@react-native-firebase/crashlytics.ts @@ -1,10 +1,6 @@ import type {FirebaseCrashlyticsTypes} from '@react-native-firebase/crashlytics'; -type CrashlyticsModule = { - log: FirebaseCrashlyticsTypes.Module['log']; - recordError: FirebaseCrashlyticsTypes.Module['recordError']; - setCrashlyticsCollectionEnabled: FirebaseCrashlyticsTypes.Module['setCrashlyticsCollectionEnabled']; -}; +type CrashlyticsModule = Pick; type CrashlyticsMock = () => CrashlyticsModule;