From 52ffe4ec9604b71449dcf0e247664a16d7593076 Mon Sep 17 00:00:00 2001 From: Ole Date: Wed, 15 May 2024 14:30:47 +0200 Subject: [PATCH] chore: Make tests independent from Echo --- src/app/store/config/EchoModel.tsx | 3 ++- src/setupJest.tsx | 12 ++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/app/store/config/EchoModel.tsx b/src/app/store/config/EchoModel.tsx index 94b2def6aec..08a5f370b87 100644 --- a/src/app/store/config/EchoModel.tsx +++ b/src/app/store/config/EchoModel.tsx @@ -36,7 +36,8 @@ export const getEchoModel = (): EchoModel => ({ state.state = echoJson }), fetchRemoteEcho: thunk(async (actions) => { - const disableRemoteFetch = unsafe_getDevToggle("DTDisableEchoRemoteFetch") + // Disable when dev toggle is enabled or when running tests + const disableRemoteFetch = unsafe_getDevToggle("DTDisableEchoRemoteFetch") || __TEST__ if (disableRemoteFetch) { return } diff --git a/src/setupJest.tsx b/src/setupJest.tsx index 2a78c5a2fec..a16d2e090e3 100644 --- a/src/setupJest.tsx +++ b/src/setupJest.tsx @@ -696,3 +696,15 @@ jest.mock("@react-native-community/geolocation", () => ({ setRNConfiguration: jest.fn(), stopObserving: jest.fn(), })) + +// Enable all feature flags by default + +jest.mock("app/store/GlobalStore", () => ({ + ...jest.requireActual("app/store/GlobalStore"), + unsafe_getFeatureFlag: jest.fn().mockReturnValue(true), +})) + +jest.mock("app/utils/hooks/useFeatureFlag", () => ({ + ...jest.requireActual("app/utils/hooks/useFeatureFlag"), + useFeatureFlag: jest.fn().mockReturnValue(true), +}))