Skip to content

Commit

Permalink
chore(tests): Fix DeleteUser tests and adjust thresholds (#4845)
Browse files Browse the repository at this point in the history
  • Loading branch information
ioanabrooks authored Dec 13, 2023
1 parent 4f643b0 commit 4797073
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 28 deletions.
16 changes: 4 additions & 12 deletions packages/react/jest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,12 @@ const config: Config = {
// do not collect coverage for the Authenticator
'!<rootDir>/src/components/Authenticator/**/*.(ts|tsx)',
],
// coverageThreshold: {
// global: {
// branches: 80,
// functions: 80,
// lines: 91,
// statements: 91,
// },
// },
coverageThreshold: {
global: {
branches: 61.11,
functions: 30.79,
lines: 42.73,
statements: 44.58,
branches: 80,
functions: 80,
lines: 91,
statements: 95,
},
},
moduleNameMapper: { '^uuid$': '<rootDir>/../../node_modules/uuid' },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,7 @@ describe('DeleteUser', () => {
expect(deleteUser).toHaveLength(1);
});

// @todo-migration
it.skip('calls deleteUser with expected arguments', async () => {
it('calls deleteUser with expected arguments', async () => {
deleteUserSpy.mockResolvedValue();

const onSuccess = jest.fn();
Expand All @@ -92,9 +91,9 @@ describe('DeleteUser', () => {
name: deleteAccountButtonText,
});

await act(async () => {
fireEvent.click(deleteAccountButton);
fireEvent.click(deleteAccountButton);

await act(async () => {
const confirmDeleteButton = await screen.findByRole('button', {
name: confirmDeleteButtonText,
});
Expand Down Expand Up @@ -212,8 +211,7 @@ describe('DeleteUser', () => {
expect(await screen.findByText('Custom Warning Message')).toBeDefined();
});

// @todo-migration fix
it.skip('onSuccess is called with component overrides after successful user deletion', async () => {
it('onSuccess is called with component overrides after successful user deletion', async () => {
deleteUserSpy.mockResolvedValue();

const onSuccess = jest.fn();
Expand All @@ -222,10 +220,9 @@ describe('DeleteUser', () => {
const deleteAccountButton = await screen.findByRole('button', {
name: 'Custom Delete Button',
});
fireEvent.click(deleteAccountButton);

await act(async () => {
fireEvent.click(deleteAccountButton);

const confirmDeleteButton = await screen.findByRole('button', {
name: 'Custom Confirm Button',
});
Expand All @@ -238,8 +235,7 @@ describe('DeleteUser', () => {
await waitFor(() => expect(onSuccess).toHaveBeenCalledTimes(1));
});

// @todo-migration fix
it.skip('calls deleteUser with expected arguments and component overrides', async () => {
it('calls deleteUser with expected arguments and component overrides', async () => {
deleteUserSpy.mockResolvedValue();

const onSuccess = jest.fn();
Expand All @@ -248,9 +244,9 @@ describe('DeleteUser', () => {
const deleteAccountButton = await screen.findByRole('button', {
name: 'Custom Delete Button',
});
await act(async () => {
fireEvent.click(deleteAccountButton);
fireEvent.click(deleteAccountButton);

await act(async () => {
const confirmDeleteButton = await screen.findByRole('button', {
name: 'Custom Confirm Button',
});
Expand All @@ -262,18 +258,16 @@ describe('DeleteUser', () => {
expect(deleteUserSpy).toHaveBeenCalledTimes(1);
});

// @todo-migration
it.skip('error message is displayed with component overrides after unsuccessful submit', async () => {
it('error message is displayed with component overrides after unsuccessful submit', async () => {
deleteUserSpy.mockRejectedValue(new Error('Mock Error'));

render(<DeleteUser components={components} />);

const deleteAccountButton = await screen.findByRole('button', {
name: 'Custom Delete Button',
});
fireEvent.click(deleteAccountButton);
await act(async () => {
fireEvent.click(deleteAccountButton);

const confirmDeleteButton = await screen.findByRole('button', {
name: 'Custom Confirm Button',
});
Expand Down

0 comments on commit 4797073

Please sign in to comment.