Increase test coverage for /modules/ui (#3314)
* Increase test coverage for `/modules/ui` Co-authored-by: v1b3m <vibenjamin6@gmail.com> Co-authored-by: FellipeMTX <fellipefacdir@gmail.com> Co-authored-by: Fellipe Montes <102544529+FellipeMTX@users.noreply.github.com> * Merge main Co-authored-by: v1b3m <vibenjamin6@gmail.com> Co-authored-by: FellipeMTX <fellipefacdir@gmail.com> Co-authored-by: Fellipe Montes <102544529+FellipeMTX@users.noreply.github.com> * Fix tests * Fix tests * Fix --------- Co-authored-by: gitstart-twenty <gitstart-twenty@users.noreply.github.com> Co-authored-by: v1b3m <vibenjamin6@gmail.com> Co-authored-by: FellipeMTX <fellipefacdir@gmail.com> Co-authored-by: Fellipe Montes <102544529+FellipeMTX@users.noreply.github.com> Co-authored-by: Charles Bochet <charles@twenty.com>
This commit is contained in:
@ -0,0 +1,40 @@
|
||||
import * as reactRouterDom from 'react-router-dom';
|
||||
|
||||
import { useIsMenuNavbarDisplayed } from '../useIsMenuNavbarDisplayed';
|
||||
|
||||
jest.mock('react-router-dom', () => ({
|
||||
useLocation: jest.fn(),
|
||||
}));
|
||||
|
||||
const setupMockLocation = (pathname: string) => {
|
||||
jest.spyOn(reactRouterDom, 'useLocation').mockReturnValueOnce({
|
||||
pathname,
|
||||
state: undefined,
|
||||
key: '',
|
||||
search: '',
|
||||
hash: '',
|
||||
});
|
||||
};
|
||||
|
||||
describe('useIsMenuNavbarDisplayed', () => {
|
||||
it('Should return true for paths starting with "/companies"', () => {
|
||||
setupMockLocation('/companies');
|
||||
|
||||
const result = useIsMenuNavbarDisplayed();
|
||||
expect(result).toBeTruthy();
|
||||
});
|
||||
|
||||
it('Should return true for paths starting with "/companies/"', () => {
|
||||
setupMockLocation('/companies/test-some-subpath');
|
||||
|
||||
const result = useIsMenuNavbarDisplayed();
|
||||
expect(result).toBeTruthy();
|
||||
});
|
||||
|
||||
it('Should return false for paths not starting with "/companies"', () => {
|
||||
setupMockLocation('/test-path');
|
||||
|
||||
const result = useIsMenuNavbarDisplayed();
|
||||
expect(result).toBeFalsy();
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user