From 1a56b74b42878787c12b6c179ac610fff8407ae1 Mon Sep 17 00:00:00 2001 From: rare-magma Date: Mon, 18 Sep 2023 19:25:59 +0200 Subject: [PATCH] refactor: remove unnecessary checks Signed-off-by: rare-magma --- src/context/BudgetContext.tsx | 4 ---- src/context/ConfigContext.test.tsx | 6 ++---- src/context/ConfigContext.tsx | 4 ---- 3 files changed, 2 insertions(+), 12 deletions(-) diff --git a/src/context/BudgetContext.tsx b/src/context/BudgetContext.tsx index a3124e1..90cb113 100644 --- a/src/context/BudgetContext.tsx +++ b/src/context/BudgetContext.tsx @@ -37,10 +37,6 @@ const BudgetContext = createContext({ }); function useBudget() { - if (BudgetContext === undefined) { - throw new Error("useBudget must be used within a Budget provider"); - } - const { budget, setBudget, diff --git a/src/context/ConfigContext.test.tsx b/src/context/ConfigContext.test.tsx index 2bf64a4..f832ce2 100644 --- a/src/context/ConfigContext.test.tsx +++ b/src/context/ConfigContext.test.tsx @@ -25,12 +25,10 @@ describe("ConfigProvider", () => { expect(getByLabelText("c").textContent).toEqual("USD"); }); - it.skip("throws error when not used within provider", () => { + it("throws error when not used within provider", () => { // configContextSpy.mockClear(); configContextSpy.mockReset(); cleanup(); - expect(() => render()).toThrow( - "useConfig must be used within a Config provider", - ); + expect(() => render()).toThrowError(); }); }); diff --git a/src/context/ConfigContext.tsx b/src/context/ConfigContext.tsx index 540211d..ee7b5e7 100644 --- a/src/context/ConfigContext.tsx +++ b/src/context/ConfigContext.tsx @@ -23,10 +23,6 @@ const ConfigContext = createContext({ }); function useConfig() { - if (ConfigContext === undefined) { - throw new Error("useConfig must be used within a Config provider"); - } - const { intlConfig, setIntlConfig } = useContext(ConfigContext); const { currency, setCurrency } = useContext(ConfigContext);