Skip to content

Commit

Permalink
refactor: remove unnecessary checks
Browse files Browse the repository at this point in the history
Signed-off-by: rare-magma <[email protected]>
  • Loading branch information
rare-magma committed Sep 18, 2023
1 parent 15cd4df commit 1a56b74
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 12 deletions.
4 changes: 0 additions & 4 deletions src/context/BudgetContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,6 @@ const BudgetContext = createContext<BudgetContextInterface>({
});

function useBudget() {
if (BudgetContext === undefined) {
throw new Error("useBudget must be used within a Budget provider");
}

const {
budget,
setBudget,
Expand Down
6 changes: 2 additions & 4 deletions src/context/ConfigContext.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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(<TestComponent />)).toThrow(
"useConfig must be used within a Config provider",
);
expect(() => render(<TestComponent />)).toThrowError();
});
});
4 changes: 0 additions & 4 deletions src/context/ConfigContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,6 @@ const ConfigContext = createContext<ConfigContextInterface>({
});

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);

Expand Down

0 comments on commit 1a56b74

Please sign in to comment.