Skip to content

Commit

Permalink
test for addOnRegister
Browse files Browse the repository at this point in the history
  • Loading branch information
nitishkumar333 committed Jan 25, 2024
1 parent 5fd47b1 commit 5c3dd36
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion src/components/AddOn/core/AddOnRegister/AddOnRegister.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,10 @@ jest.mock('react-toastify', () => ({
},
}));
const mockNavigate = jest.fn();
let mockId: string | undefined = 'id';
jest.mock('react-router-dom', () => ({
...jest.requireActual('react-router-dom'),
useParams: () => ({ orgId: 'id' }),
useParams: () => ({ orgId: mockId }),
useNavigate: () => mockNavigate,
}));

Expand Down Expand Up @@ -178,4 +179,19 @@ describe('Testing AddOnRegister', () => {
expect(mockNavigate).toHaveBeenCalledWith(0);
});
});
test('should be redirected to /orglist if orgId is undefined', async () => {
mockId = undefined;
render(
<ApolloProvider client={client}>
<Provider store={store}>
<BrowserRouter>
<I18nextProvider i18n={i18nForTest}>
{<AddOnRegister {...props} />}
</I18nextProvider>
</BrowserRouter>
</Provider>
</ApolloProvider>
);
expect(window.location.pathname).toEqual('/orglist');
});
});

0 comments on commit 5c3dd36

Please sign in to comment.