Skip to content

[WIP] PR to fix the react testing library console warnings in the PR for issue-101 #111

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 3 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
104 changes: 52 additions & 52 deletions src/components/Auth/AuthForm.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,59 +41,59 @@ describe('AuthForm', () => {

describe('Signup', () => {
it('Register a new user on the signup form', async () => {
const { getByText, getByLabelText } = render(
<BrowserRouter>
<SignUpForm />
</BrowserRouter>
);

const mockRegisterResponse = jest.fn().mockResolvedValue({
data: {
username: 'Carolyne.Carter',
token:
'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VybmFtZSI6IkNhcm9seW5lLkNhcnRlciIsImlhdCI6MTU4NDMzODQ4NiwiZXhwIjoxNTg0MzQyMDg2LCJ1c2VyX2lkIjo4MCwib3JpZ19pYXQiOjE1ODQzMzg0ODZ9.saO6OCOKV1uwHjTbM-iDGmhbkMNCnzrGFj4TBYnTv2E',
first_name: 'Carolyne',
last_name: 'Carter',
email: '[email protected]',
},
await act(async () => {
const { getByText, getByLabelText } = render(
<BrowserRouter>
<SignUpForm />
</BrowserRouter>
);

const mockRegisterResponse = jest.fn().mockResolvedValue({
data: {
username: 'Carolyne.Carter',
token:
'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VybmFtZSI6IkNhcm9seW5lLkNhcnRlciIsImlhdCI6MTU4NDMzODQ4NiwiZXhwIjoxNTg0MzQyMDg2LCJ1c2VyX2lkIjo4MCwib3JpZ19pYXQiOjE1ODQzMzg0ODZ9.saO6OCOKV1uwHjTbM-iDGmhbkMNCnzrGFj4TBYnTv2E',
first_name: 'Carolyne',
last_name: 'Carter',
email: '[email protected]',
},
});
await act(async () =>
fireEvent.change(getByLabelText(/username/i), {
target: { value: 'Carolyne.Carter' },
})
);
await act(async () =>
fireEvent.change(getByLabelText(/password/i), {
target: { value: 'password' },
})
);

await act(async () =>
fireEvent.change(getByLabelText(/email/i), {
target: { value: '[email protected]' },
})
);

await act(async () =>
fireEvent.change(getByLabelText(/first name/i), {
target: { value: 'Carolyne' },
})
);

await act(async () =>
fireEvent.change(getByLabelText(/last name/i), {
target: { value: 'Carter' },
})
);

const submit = getByText('Sign Up');
await act(async () => fireEvent.click(submit));

await act(async () => mockRegisterResponse());

expect(mockRegisterResponse).toHaveBeenCalledTimes(1);
});

await act(async () =>
fireEvent.change(getByLabelText(/username/i), {
target: { value: 'Carolyne.Carter' },
})
);

await act(async () =>
fireEvent.change(getByLabelText(/password/i), {
target: { value: 'password' },
})
);

await act(async () =>
fireEvent.change(getByLabelText(/email/i), {
target: { value: '[email protected]' },
})
);

await act(async () =>
fireEvent.change(getByLabelText(/first name/i), {
target: { value: 'Carolyne' },
})
);

await act(async () =>
fireEvent.change(getByLabelText(/last name/i), {
target: { value: 'Carter' },
})
);

const submit = getByText('Sign Up');
await act(async () => fireEvent.click(submit));

await act(async () => mockRegisterResponse());

expect(mockRegisterResponse).toHaveBeenCalledTimes(1);
});
});

Expand Down