Skip to content

Commit

Permalink
formatting fix
Browse files Browse the repository at this point in the history
  • Loading branch information
AnshulKahar2729 committed Sep 24, 2024
1 parent 84ad1ba commit b038259
Show file tree
Hide file tree
Showing 16 changed files with 87 additions and 75 deletions.
2 changes: 1 addition & 1 deletion public/locales/en/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -84,4 +84,4 @@
"successfullyUpdated": "Successfully Updated",
"sort": "Sort",
"confirm": "Confirm"
}
}
2 changes: 1 addition & 1 deletion public/locales/en/errors.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@
"notFoundMsg": "Oops! The Page you requested was not found!",
"errorOccurredCouldntCreate": "An error occurred. Couldn't create {{entity}}",
"errorLoading": "Error occured while loading {{entity}} data"
}
}
2 changes: 1 addition & 1 deletion public/locales/en/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -1324,4 +1324,4 @@
"errorOccured": "An error occurred. Please try again later.",
"orgLeft": "You have left the organization."
}
}
}
2 changes: 1 addition & 1 deletion public/locales/fr/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -84,4 +84,4 @@
"removedSuccessfully": "{{item}} supprimé avec succès",
"successfullyUpdated": "Mis à jour avec succès",
"confirm": "Confirmer"
}
}
2 changes: 1 addition & 1 deletion public/locales/fr/errors.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@
"notFoundMsg": "Oops! ",
"errorOccurredCouldntCreate": "Une erreur s'est produite. Impossible de créer {{entity}}",
"errorLoading": "Une erreur s'est produite lors du chargement des données {{entity}}"
}
}
2 changes: 1 addition & 1 deletion public/locales/fr/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -1324,4 +1324,4 @@
"errorOccured": "Une erreur s'est produite. Veuillez réessayer plus tard.",
"orgLeft": "Vous avez quitté l'organisation."
}
}
}
2 changes: 1 addition & 1 deletion public/locales/hi/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -84,4 +84,4 @@
"removedSuccessfully": "{{item}} सफलतापूर्वक हटाया गया",
"successfullyUpdated": "सफलतापूर्वक अपडेट किया गया",
"confirm": "पुष्टि करें"
}
}
2 changes: 1 addition & 1 deletion public/locales/hi/errors.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@
"notFoundMsg": "उफ़! ",
"errorOccurredCouldntCreate": "एक त्रुटि हुई। {{entity}} नहीं बना सके",
"errorLoading": "{{entity}} डेटा लोड करते समय त्रुटि हुई"
}
}
2 changes: 1 addition & 1 deletion public/locales/hi/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -1324,4 +1324,4 @@
"errorOccured": "एक त्रुटि पाई गई। कृपया बाद में पुन: प्रयास करें।",
"orgLeft": "आपने संगठन छोड़ दिया है."
}
}
}
2 changes: 1 addition & 1 deletion public/locales/sp/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -84,4 +84,4 @@
"removedSuccessfully": "{{item}} eliminado con éxito",
"successfullyUpdated": "Actualizado con éxito",
"confirm": "Confirmar"
}
}
2 changes: 1 addition & 1 deletion public/locales/sp/errors.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@
"notFoundMsg": "Oops! The Page you requested was not found!",
"errorOccurredCouldntCreate": "Ocurrió un error. No se pudo crear {{entity}}",
"errorLoading": "Ocurrió un error al cargar los datos de {{entity}}"
}
}
2 changes: 1 addition & 1 deletion public/locales/sp/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -1314,4 +1314,4 @@
"errorOccured": "Se produjo un error. Inténtelo de nuevo más tarde.",
"orgLeft": "Has abandonado la organización."
}
}
}
2 changes: 1 addition & 1 deletion public/locales/zh/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -83,4 +83,4 @@
"updatedSuccessfully": "{{item}} 更新成功",
"removedSuccessfully": "{{item}} 删除成功",
"successfullyUpdated": "更新成功"
}
}
2 changes: 1 addition & 1 deletion public/locales/zh/errors.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@
"notFoundMsg": "哎呀!",
"errorOccurredCouldntCreate": "发生错误。 无法创建{{entity}}",
"errorLoading": "加载{{entity}}数据时出错"
}
}
132 changes: 72 additions & 60 deletions src/components/UserPortal/UserSidebarOrg/LeaveConfirmModal.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,87 +6,99 @@ import { LEAVE_ORGANIZATION } from 'GraphQl/Mutations/OrganizationMutations';
import { toast } from 'react-toastify';

jest.mock('react-toastify', () => ({
toast: {
success: jest.fn(),
error: jest.fn(),
},
toast: {
success: jest.fn(),
error: jest.fn(),
},
}));

jest.mock('react-router-dom', () => ({
redirect: jest.fn(),
redirect: jest.fn(),
}));

jest.mock('react-i18next', () => ({
useTranslation: () => ({
t: (key: string) => key,
}),
useTranslation: () => ({
t: (key: string) => key,
}),
}));

const mocks = [
{
request: {
query: LEAVE_ORGANIZATION,
variables: { organizationId: '6437904485008f171cf29924' },
},
result: {
data: {
leaveOrganization: true,
},
},
{
request: {
query: LEAVE_ORGANIZATION,
variables: { organizationId: '6437904485008f171cf29924' },
},
result: {
data: {
leaveOrganization: true,
},
},
},
];

describe('LeaveConfirmModal', () => {
const onHide = jest.fn();
const onHide = jest.fn();

it('calls onHide when cancel button is clicked', () => {
render(
<MockedProvider mocks={mocks} addTypename={false}>
<LeaveConfirmModal show={true} onHide={onHide} orgId="6437904485008f171cf29924" />
</MockedProvider>
);
it('calls onHide when cancel button is clicked', () => {
render(
<MockedProvider mocks={mocks} addTypename={false}>
<LeaveConfirmModal
show={true}
onHide={onHide}
orgId="6437904485008f171cf29924"
/>
</MockedProvider>,
);

fireEvent.click(screen.getByText('cancel'));
expect(onHide).toHaveBeenCalled();
});
fireEvent.click(screen.getByText('cancel'));
expect(onHide).toHaveBeenCalled();
});

it('calls leaveOrganization mutation and handles success', async () => {
render(
<MockedProvider mocks={mocks} addTypename={false}>
<LeaveConfirmModal show={true} onHide={onHide} orgId="6437904485008f171cf29924" />
</MockedProvider>
);
it('calls leaveOrganization mutation and handles success', async () => {
render(
<MockedProvider mocks={mocks} addTypename={false}>
<LeaveConfirmModal
show={true}
onHide={onHide}
orgId="6437904485008f171cf29924"
/>
</MockedProvider>,
);

fireEvent.click(screen.getByText('confirm'));
fireEvent.click(screen.getByText('confirm'));

await waitFor(() => {
expect(toast.success);
expect(onHide).toHaveBeenCalled();
});
await waitFor(() => {
expect(toast.success);
expect(onHide).toHaveBeenCalled();
});
});

it('handles error when leaveOrganization mutation fails', async () => {
const errorMocks = [
{
request: {
query: LEAVE_ORGANIZATION,
variables: { organizationId: '6437904485008f171cf29924' },
},
error: new Error('An error occurred. Please try again later.'),
},
];
it('handles error when leaveOrganization mutation fails', async () => {
const errorMocks = [
{
request: {
query: LEAVE_ORGANIZATION,
variables: { organizationId: '6437904485008f171cf29924' },
},
error: new Error('An error occurred. Please try again later.'),
},
];

render(
<MockedProvider mocks={errorMocks} addTypename={false}>
<LeaveConfirmModal show={true} onHide={onHide} orgId="6437904485008f171cf29924" />
</MockedProvider>
);
render(
<MockedProvider mocks={errorMocks} addTypename={false}>
<LeaveConfirmModal
show={true}
onHide={onHide}
orgId="6437904485008f171cf29924"
/>
</MockedProvider>,
);

fireEvent.click(screen.getByText('confirm'));
fireEvent.click(screen.getByText('confirm'));

await waitFor(() => {
expect(toast.error).toHaveBeenCalledWith('errorOccured');
expect(onHide).toHaveBeenCalled();
});
await waitFor(() => {
expect(toast.error).toHaveBeenCalledWith('errorOccured');
expect(onHide).toHaveBeenCalled();
});
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -73,4 +73,4 @@ const LeaveConfirmModal: FC<InterfaceLeaveConfirmModalProps> = ({
);
};

export default LeaveConfirmModal;
export default LeaveConfirmModal;

0 comments on commit b038259

Please sign in to comment.