Skip to content

Commit

Permalink
Added Test when no organisation is selected
Browse files Browse the repository at this point in the history
  • Loading branch information
PratapRathi committed Dec 30, 2024
1 parent 4fc97ed commit 7e3a8e6
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions src/components/ProfileDropdown/ProfileDropdown.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,34 @@ describe('ProfileDropdown Component', () => {
expect(mockNavigate).toHaveBeenCalledWith('/user/settings');
});

test('navigates to /member/:orgId for non-user roles when orgId is not present', async () => {
window.history.pushState({}, 'Test page', '/orglist');
setItem('SuperAdmin', true); // Set as admin
setItem('id', '123');

render(
<MockedProvider mocks={MOCKS} addTypename={false}>
<BrowserRouter>
<I18nextProvider i18n={i18nForTest}>
<Routes>
<Route path="/orglist" element={<ProfileDropdown />} />
</Routes>
</I18nextProvider>
</BrowserRouter>
</MockedProvider>,
);

await act(async () => {
userEvent.click(screen.getByTestId('togDrop'));
});

await act(async () => {
userEvent.click(screen.getByTestId('profileBtn'));
});

expect(mockNavigate).toHaveBeenCalledWith('/member/');
});

test('navigates to /member/:userID for non-user roles', async () => {
window.history.pushState({}, 'Test page', '/321');
setItem('SuperAdmin', true); // Set as admin
Expand Down

0 comments on commit 7e3a8e6

Please sign in to comment.