Skip to content

Commit

Permalink
fix: tests
Browse files Browse the repository at this point in the history
  • Loading branch information
aldbr committed Dec 19, 2023
1 parent 0b5dd67 commit 141c59b
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
4 changes: 3 additions & 1 deletion src/hooks/theme.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { ThemeContext } from "@/contexts/ThemeProvider";
import { PaletteMode } from "@mui/material";
import { createTheme } from "@mui/material/styles";
import { useContext } from "react";

Expand All @@ -20,13 +21,14 @@ export const useTheme = () => {
* @returns the Material-UI theme
* @throws an error if the hook is not used within a ThemeProvider
*/

export const useMUITheme = () => {
const { theme } = useTheme();

// Create a Material-UI theme based on the current mode
const muiTheme = createTheme({
palette: {
mode: theme,
mode: theme as PaletteMode,
primary: {
main: "#ffffff",
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import React from "react";
import { render, fireEvent } from "@testing-library/react";
import { ProfileButton } from "@/components/ui/ProfileButton";
import { useOidcAccessToken, useOidc } from "@axa-fr/react-oidc";
import { OIDCConfigurationContext } from "@/contexts/OIDCConfigurationProvider";

// Mocking the hooks
jest.mock("@axa-fr/react-oidc");
Expand Down Expand Up @@ -51,11 +52,20 @@ describe("<ProfileButton />", () => {
logout: mockLogout,
});
(useOidcAccessToken as jest.Mock).mockReturnValue({
accessToken: "mockAccessToken",
accessTokenPayload: { preferred_username: "John" },
});

const { getByText } = render(<ProfileButton />);
// Mock context value
const mockContextValue = {
configuration: { scope: "mockScope" },
setConfiguration: jest.fn(),
};

const { getByText } = render(
<OIDCConfigurationContext.Provider value={mockContextValue}>
<ProfileButton />
</OIDCConfigurationContext.Provider>,
);

// Open the menu by clicking the avatar
fireEvent.click(getByText("J"));
Expand Down

0 comments on commit 141c59b

Please sign in to comment.