Skip to content

Commit

Permalink
improve code coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
gkbishnoi07 committed Mar 10, 2025
1 parent f716477 commit b1d1502
Show file tree
Hide file tree
Showing 6 changed files with 310 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ const MOCKS = [
},
result: {
data: {
organizationsConnection: [
organizations: [
{
__typename: 'Organization',
_id: '2',
Expand Down
24 changes: 24 additions & 0 deletions src/screens/Requests/Requests.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -365,4 +365,28 @@ describe('Testing Requests screen', () => {
await wait(200);
// This test should not throw any errors
});

test('Shows warning toast when there are no organizations', async () => {
const { toast } = await import('react-toastify');

render(
<MockedProvider addTypename={false} link={link2}>
<BrowserRouter>
<Provider store={store}>
<I18nextProvider i18n={i18nForTest}>
<ToastContainer />
<Requests />
</I18nextProvider>
</Provider>
</BrowserRouter>
</MockedProvider>,
);

// Wait for the component to finish loading and the effect to run
await wait(200);

// Verify that the toast.warning function was called with the expected message
expect(toast.warning).toHaveBeenCalledWith(expect.any(String));
expect(toast.warning).toHaveBeenCalledTimes(1);
});
});
12 changes: 6 additions & 6 deletions src/screens/Requests/RequestsMocks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export const EMPTY_REQUEST_MOCKS = [
},
result: {
data: {
organizationsConnection: [
organizations: [
{
_id: 'org1',
image: null,
Expand Down Expand Up @@ -72,7 +72,7 @@ export const MOCKS = [
},
result: {
data: {
organizationsConnection: [
organizations: [
{
_id: 'org1',
image: null,
Expand Down Expand Up @@ -156,7 +156,7 @@ export const MOCKS4 = [
},
result: {
data: {
organizationsConnection: [
organizations: [
{
_id: 'org1',
image: null,
Expand Down Expand Up @@ -388,7 +388,7 @@ export const MOCKS2 = [
},
result: {
data: {
organizationsConnection: [
organizations: [
{
_id: 'org1',
image: null,
Expand Down Expand Up @@ -463,7 +463,7 @@ export const MOCKS3 = [
},
result: {
data: {
organizationsConnection: [
organizations: [
{
_id: 'org1',
image: null,
Expand Down Expand Up @@ -544,7 +544,7 @@ export const EMPTY_MOCKS = [
},
result: {
data: {
organizationsConnection: [],
organizations: [],
},
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ const mocks = [
},
result: {
data: {
organizationsConnection: [
organizations: [
{
_id: 'org123',
name: 'Tech Enthusiasts Club',
Expand Down
4 changes: 2 additions & 2 deletions src/screens/Users/User.mocks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ export const MOCKS = [
},
result: {
data: {
organizationsConnection: [
organizations: [
{
_id: 123,
image: null,
Expand Down Expand Up @@ -431,7 +431,7 @@ export const MOCKS2 = [
},
result: {
data: {
organizationsConnection: [
organizations: [
{
_id: 123,
image: null,
Expand Down
Loading

0 comments on commit b1d1502

Please sign in to comment.