Skip to content

Commit

Permalink
updating unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
NiranjanaBinoy committed Oct 7, 2024
1 parent 2e15e0e commit 8013ee7
Showing 1 changed file with 40 additions and 35 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,33 +47,34 @@ describe('DeleteMetaMetricsDataButton', () => {

it('renders correctly', () => {
const store = configureStore({});
const { getByText, getByTestId, getAllByText } = renderWithProvider(
const { getByTestId, getAllByText, container } = renderWithProvider(
<DeleteMetaMetricsDataButton />,
store,
);
expect(getByTestId('delete-metametrics-data-button')).toBeInTheDocument();
expect(getAllByText('Delete MetaMetrics data')).toHaveLength(2);
expect(
getByText(
/This will delete historical MetaMetrics data associated with your use on this device. Your wallet and accounts will remain exactly as they are now after this data has been deleted. This process may take up to 30 days. View our/u,
),
).toBeInTheDocument();
container.querySelector('.settings-page__content-description')
?.textContent,
).toMatchInlineSnapshot(
`" This will delete historical MetaMetrics data associated with your use on this device. Your wallet and accounts will remain exactly as they are now after this data has been deleted. This process may take up to 30 days. View our Privacy policy. "`,
);
});

it('should enable the data deletion button when metrics is opted in and metametrics id is available ', async () => {
const store = configureStore({});
const { getByRole, getByText } = renderWithProvider(
const { getByRole, container } = renderWithProvider(
<DeleteMetaMetricsDataButton />,
store,
);
expect(
getByRole('button', { name: 'Delete MetaMetrics data' }),
).toBeEnabled();
expect(
getByText(
/This will delete historical MetaMetrics data associated with your use on this device. Your wallet and accounts will remain exactly as they are now after this data has been deleted. This process may take up to 30 days. View our/u,
),
).toBeInTheDocument();
container.querySelector('.settings-page__content-description')
?.textContent,
).toMatchInlineSnapshot(
`" This will delete historical MetaMetrics data associated with your use on this device. Your wallet and accounts will remain exactly as they are now after this data has been deleted. This process may take up to 30 days. View our Privacy policy. "`,
);
});
it('should enable the data deletion button when page mounts after a deletion task is performed and more data is recoded after the deletion', async () => {
useSelectorMock.mockImplementation((selector) => {
Expand All @@ -86,18 +87,19 @@ describe('DeleteMetaMetricsDataButton', () => {
return undefined;
});
const store = configureStore({});
const { getByRole, getByText } = renderWithProvider(
const { getByRole, container } = renderWithProvider(
<DeleteMetaMetricsDataButton />,
store,
);
expect(
getByRole('button', { name: 'Delete MetaMetrics data' }),
).toBeEnabled();
expect(
getByText(
/This will delete historical MetaMetrics data associated with your use on this device. Your wallet and accounts will remain exactly as they are now after this data has been deleted. This process may take up to 30 days. View our/u,
),
).toBeInTheDocument();
container.querySelector('.settings-page__content-description')
?.textContent,
).toMatchInlineSnapshot(
`" This will delete historical MetaMetrics data associated with your use on this device. Your wallet and accounts will remain exactly as they are now after this data has been deleted. This process may take up to 30 days. View our Privacy policy. "`,
);
});

// if user does not opt in to participate in metrics or for profile sync, metametricsId will not be created.
Expand All @@ -109,23 +111,24 @@ describe('DeleteMetaMetricsDataButton', () => {
return undefined;
});
const store = configureStore({});
const { getByRole, getByText } = renderWithProvider(
const { getByRole, container } = renderWithProvider(
<DeleteMetaMetricsDataButton />,
store,
);
expect(
getByRole('button', { name: 'Delete MetaMetrics data' }),
).toBeDisabled();
expect(
getByText(
/This will delete historical MetaMetrics data associated with your use on this device. Your wallet and accounts will remain exactly as they are now after this data has been deleted. This process may take up to 30 days. View our/u,
),
).toBeInTheDocument();
container.querySelector('.settings-page__content-description')
?.textContent,
).toMatchInlineSnapshot(
`" This will delete historical MetaMetrics data associated with your use on this device. Your wallet and accounts will remain exactly as they are now after this data has been deleted. This process may take up to 30 days. View our Privacy policy. "`,
);
expect(
getByText(
/Since you've never opted into MetaMetrics, there's no data to delete here./u,
),
).toBeInTheDocument();
container.querySelector('.settings-page__content-item-col')?.textContent,
).toMatchInlineSnapshot(
`"Since you've never opted into MetaMetrics, there's no data to delete here.Delete MetaMetrics data"`,
);
});

// particilapteInMetrics will be false before the deletion is performed, this way no further data will be recorded after deletion.
Expand All @@ -146,18 +149,19 @@ describe('DeleteMetaMetricsDataButton', () => {
return undefined;
});
const store = configureStore({});
const { getByRole, getByText } = renderWithProvider(
const { getByRole, container } = renderWithProvider(
<DeleteMetaMetricsDataButton />,
store,
);
expect(
getByRole('button', { name: 'Delete MetaMetrics data' }),
).toBeDisabled();
expect(
getByText(
/You initiated this action on 7\/06\/2024. This process can take up to 30 days. View the/u,
),
).toBeInTheDocument();
container.querySelector('.settings-page__content-description')
?.textContent,
).toMatchInlineSnapshot(
`" You initiated this action on 7/06/2024. This process can take up to 30 days. View the Privacy policy "`,
);
});

// particilapteInMetrics will be false before the deletion is performed, this way no further data will be recorded after deletion.
Expand All @@ -178,18 +182,19 @@ describe('DeleteMetaMetricsDataButton', () => {
return undefined;
});
const store = configureStore({});
const { getByRole, getByText } = renderWithProvider(
const { getByRole, container } = renderWithProvider(
<DeleteMetaMetricsDataButton />,
store,
);
expect(
getByRole('button', { name: 'Delete MetaMetrics data' }),
).toBeDisabled();
expect(
getByText(
/You initiated this action on 7\/06\/2024. This process can take up to 30 days. View the/u,
),
).toBeInTheDocument();
container.querySelector('.settings-page__content-description')
?.textContent,
).toMatchInlineSnapshot(
`" You initiated this action on 7/06/2024. This process can take up to 30 days. View the Privacy policy "`,
);
});

it('should open the modal on the button click', () => {
Expand Down

0 comments on commit 8013ee7

Please sign in to comment.