diff --git a/jest.config.js b/jest.config.js index aad1cc9d..cc4721ae 100644 --- a/jest.config.js +++ b/jest.config.js @@ -8,5 +8,6 @@ module.exports = { '^@store(.*)$': '/src/store$1', '^@helper-functions(.*)$': '/src/helper-functions$1', '^@constants(.*)$': '/src/constants$1', + '^@custom-hooks(.*)$': '/src/custom-hooks$1', }, }; diff --git a/src/store/keyboard/context.js b/src/store/keyboard/context.js index 63361209..22aa4626 100644 --- a/src/store/keyboard/context.js +++ b/src/store/keyboard/context.js @@ -2,16 +2,16 @@ import { createContext, useContext, useState } from 'react'; const KeyboardContext = createContext(); -export const KeyboardProvider = ({ children }) => { +export const KeyboardProvider = ({ children, initialValue }) => { const [isOptionKeyPressed, setIsOptionKeyPressed] = useState(false); - const initialValue = { + const value = { isOptionKeyPressed, setIsOptionKeyPressed, }; return ( - + {children} ); diff --git a/src/test/unit/components/member-profile/index.test.js b/src/test/unit/components/member-profile/index.test.js index 5c53a91a..33fada76 100644 --- a/src/test/unit/components/member-profile/index.test.js +++ b/src/test/unit/components/member-profile/index.test.js @@ -2,6 +2,7 @@ import { render, screen } from '@testing-library/react'; import Profile from '@components/member-profile'; import { TaskContextProvider } from '@store/tasks/tasks-context'; import { UserContextProvider } from '@store/user/user-context'; +import { KeyboardProvider } from '@store/keyboard/context'; const notaMember = { roles: { @@ -20,24 +21,49 @@ const initialUserContext = { isSuperUser: true, }; +jest.mock('next/router', () => { + return { + useRouter: jest.fn().mockReturnValue({ + query: { + dev: true, + }, + }), + }; +}); + describe('Members Profile', () => { - it('Should render member status properly', () => { + it('Should render member status properly', async () => { render( - - - - - + + + + + + + ); let memberStatus = screen.getByText('User is not a Member'); expect(memberStatus).toBeInTheDocument(); + render( - - - - - + + + + + + + ); memberStatus = screen.getByText('User is a Member'); @@ -46,11 +72,18 @@ describe('Members Profile', () => { it('Should render the info icon correctly', () => { render( - - - - - + + + + + + + ); const icon = screen.getByAltText('info icon');