Skip to content

Commit

Permalink
renaming canDelete variable
Browse files Browse the repository at this point in the history
  • Loading branch information
dr-bizz committed Dec 10, 2024
1 parent 74469b5 commit 7976977
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ describe('DeleteContactModal', () => {
expect(getByRole('button', { name: 'delete contact' })).toBeDisabled();
});

describe('Disable deletion', () => {
describe('Show third party message', () => {
interface TestProps {
testName: string;
props: TestComponentProps;
Expand Down Expand Up @@ -156,17 +156,21 @@ describe('DeleteContactModal', () => {
];

test.each(tests)('$testName', async ({ props }) => {
const { findByText } = render(<TestComponent {...props} />);
const { findByText, getByRole } = render(<TestComponent {...props} />);

expect(
await findByText(
/its data may sync with Donation Services or other third-party systems/,
),
).toBeInTheDocument();

expect(
getByRole('button', { name: 'delete contact' }),
).toBeInTheDocument();
});
});

describe('Enable deletion', () => {
describe('Show normal delete message', () => {
it('should show modal and be able to delete user', async () => {
const { getByText, getByRole } = render(
<TestComponent
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ const LoadingIndicator = styled(CircularProgress)(({ theme }) => ({
}));

interface DataInfo {
canDelete: boolean;
canDeleteWithoutIssues: boolean;
contactSource: string;
addressSources: string[];
emailSources: string[];
Expand Down Expand Up @@ -59,7 +59,7 @@ export const DeleteContactModal: React.FC<DeleteContactModalProps> = ({
const dataInfo: DataInfo = useMemo(() => {
if (!contactSources) {
return {
canDelete: true,
canDeleteWithoutIssues: true,
contactSource: sourceToStr(t, 'MPDX'),
addressSources: [],
emailSources: [],
Expand Down Expand Up @@ -96,7 +96,7 @@ export const DeleteContactModal: React.FC<DeleteContactModalProps> = ({
});

return {
canDelete:
canDeleteWithoutIssues:
isEditableSource(contactSources.source ?? '') &&
!addressSources.size &&
!emailSources.size &&
Expand All @@ -117,7 +117,7 @@ export const DeleteContactModal: React.FC<DeleteContactModalProps> = ({
handleClose={() => setOpen(false)}
>
<DialogContent dividers>
{dataInfo.canDelete ? (
{dataInfo.canDeleteWithoutIssues ? (
<Typography>
{t(
`Are you sure you want to permanently delete this contact? Doing so will permanently delete this contacts information, as well as task history. This cannot be undone. If you wish to keep this information, you can try hiding this contact instead.`,
Expand Down

0 comments on commit 7976977

Please sign in to comment.