test('get weather', async () => { const { getByText, queryByText, container } = render(<Weather location="charleston" />) await wait(() => expect(queryByText(/loading/i)).not.toBeInTheDocument()) expect(getByText(/raining/)).toBeInTheDocument() })
it('submits with correct data', async () => { const handler = jest.fn((_, { setSubmitting }) => { setSubmitting(false); }); const { container, getByText, getByPlaceholderText } = render(<Login onSubmit={handler} />); fireEvent.change(getByPlaceholderText('Email address'), { target: { value: 'test@user.com' } }); fireEvent.change(getByPlaceholderText('Password'), { target: { value: 'password' } }); const submitButton = getByText(/log in/i); expect(container.firstChild).toHaveFormValues({ email: 'test@user.com', password: 'password' }); expect(submitButton).not.toHaveAttribute('disabled'); fireEvent.click(submitButton); expect(submitButton).toHaveAttribute('disabled'); await wait(() => { expect(handler).toHaveBeenCalledWith( { email: 'test@user.com', password: 'password' }, expect.objectContaining({ setSubmitting: expect.any(Function) }) ); expect(submitButton).not.toHaveAttribute('disabled'); }); });
it('submits with correct data', async () => { const handler = jest.fn((_, { setSubmitting }) => { setSubmitting(false); }); const { container, getByText, getByPlaceholderText } = render( <ForgotPassword onSubmit={handler} /> ); fireEvent.change(getByPlaceholderText('Email address'), { target: { value: 'test@user.com' } }); const submitButton = getByText(/submit/i); expect(container.firstChild).toHaveFormValues({ email: 'test@user.com' }); expect(submitButton).not.toHaveAttribute('disabled'); fireEvent.click(submitButton); expect(submitButton).toHaveAttribute('disabled'); await wait(() => { expect(handler).toHaveBeenCalledWith( { email: 'test@user.com' }, expect.objectContaining({ setSubmitting: expect.any(Function) }) ); expect(submitButton).not.toHaveAttribute('disabled'); }); });
expect(loadMapArgs[1]).toEqual(config.options); return wait().then(() => {
it('submits with correct data', async () => { const handler = jest.fn((_, { setSubmitting }) => { setSubmitting(false); }); const { container, getByText, getByPlaceholderText } = render(<Signup onSubmit={handler} />); fireEvent.change(getByPlaceholderText('Name'), { target: { value: 'John Doe' } }); fireEvent.change(getByPlaceholderText('Email address'), { target: { value: 'test@user.com' } }); fireEvent.change(getByPlaceholderText('Password'), { target: { value: 'password' } }); const submitButton = getByText(/sign up/i); expect(container.firstChild).toHaveFormValues({ name: 'John Doe', email: 'test@user.com', password: 'password' }); expect(submitButton).not.toHaveAttribute('disabled'); fireEvent.click(submitButton); expect(submitButton).toHaveAttribute('disabled'); await wait(() => { expect(handler).toHaveBeenCalledWith( { email: 'test@user.com', name: 'John Doe', password: 'password' }, expect.objectContaining({ setSubmitting: expect.any(Function) }) ); expect(submitButton).not.toHaveAttribute('disabled'); }); });
await wait(() => r.getByText('Some Name')); await wait(() => r.getByText(/Something went wrong/)); }); }); await wait(() => r.getByText('See my pets')); await wait(() => r.getByText(/Pets of Some Name/)); await wait(() => r.getByText('See my pets')); await wait(() => r.getByText(/See more pets/)); await wait(() => r.getByText('Badger the Pet')); await wait(() => r.getByText('Some Name'));
it('submits with correct data', async () => { const handler = jest.fn((_, { setSubmitting }) => { setSubmitting(false); }); const { container, getByText, getByPlaceholderText } = render( <ResetPassword token="aabbcc" onSubmit={handler} /> ); fireEvent.change(getByPlaceholderText('New password'), { target: { value: 'newpassword' } }); fireEvent.change(getByPlaceholderText('Re-enter new password'), { target: { value: 'newpassword' } }); const submitButton = getByText(/reset password/i); expect(container.firstChild).toHaveFormValues({ password: 'newpassword', repeatPassword: 'newpassword' }); expect(submitButton).not.toHaveAttribute('disabled'); fireEvent.click(submitButton); expect(submitButton).toHaveAttribute('disabled'); await wait(() => { expect(handler).toHaveBeenCalledWith( { password: 'newpassword', repeatPassword: 'newpassword', token: 'aabbcc' }, expect.objectContaining({ setSubmitting: expect.any(Function) }) ); expect(submitButton).not.toHaveAttribute('disabled'); }); });
it('submits with correct data', async () => { const handler = jest.fn((_, { setSubmitting }) => { setSubmitting(false); }); const { container, getByText, getByPlaceholderText } = render(<Login onSubmit={handler} />); fireEvent.change(getByPlaceholderText('Email address'), { target: { value: 'test@user.com' } }); fireEvent.change(getByPlaceholderText('Password'), { target: { value: 'password' } }); const submitButton = getByText(/log in/i); expect(container.firstChild).toHaveFormValues({ email: 'test@user.com', password: 'password' }); expect(submitButton).not.toHaveAttribute('disabled'); fireEvent.click(submitButton); expect(submitButton).toHaveAttribute('disabled'); await wait(() => { expect(handler).toHaveBeenCalledWith( { email: 'test@user.com', password: 'password' }, expect.objectContaining({ setSubmitting: expect.any(Function) }) ); expect(submitButton).not.toHaveAttribute('disabled'); }); });
it('submits with correct data', async () => { const handler = jest.fn((_, { setSubmitting }) => { setSubmitting(false); }); const { container, getByText, getByPlaceholderText } = render( <ForgotPassword onSubmit={handler} /> ); fireEvent.change(getByPlaceholderText('Email address'), { target: { value: 'test@user.com' } }); const submitButton = getByText(/submit/i); expect(container.firstChild).toHaveFormValues({ email: 'test@user.com' }); expect(submitButton).not.toHaveAttribute('disabled'); fireEvent.click(submitButton); expect(submitButton).toHaveAttribute('disabled'); await wait(() => { expect(handler).toHaveBeenCalledWith( { email: 'test@user.com' }, expect.objectContaining({ setSubmitting: expect.any(Function) }) ); expect(submitButton).not.toHaveAttribute('disabled'); }); });
it('submits with correct data', async () => { const handler = jest.fn((_, { setSubmitting }) => { setSubmitting(false); }); const { container, getByText, getByPlaceholderText } = render(<Signup onSubmit={handler} />); fireEvent.change(getByPlaceholderText('Name'), { target: { value: 'John Doe' } }); fireEvent.change(getByPlaceholderText('Email address'), { target: { value: 'test@user.com' } }); fireEvent.change(getByPlaceholderText('Password'), { target: { value: 'password' } }); const submitButton = getByText(/sign up/i); expect(container.firstChild).toHaveFormValues({ name: 'John Doe', email: 'test@user.com', password: 'password' }); expect(submitButton).not.toHaveAttribute('disabled'); fireEvent.click(submitButton); expect(submitButton).toHaveAttribute('disabled'); await wait(() => { expect(handler).toHaveBeenCalledWith( { email: 'test@user.com', name: 'John Doe', password: 'password' }, expect.objectContaining({ setSubmitting: expect.any(Function) }) ); expect(submitButton).not.toHaveAttribute('disabled'); }); });
it('submits with correct data', async () => { const handler = jest.fn((_, { setSubmitting }) => { setSubmitting(false); }); const { container, getByText, getByPlaceholderText } = render( <ResetPassword token="aabbcc" onSubmit={handler} /> ); fireEvent.change(getByPlaceholderText('New password'), { target: { value: 'newpassword' } }); fireEvent.change(getByPlaceholderText('Re-enter new password'), { target: { value: 'newpassword' } }); const submitButton = getByText(/reset password/i); expect(container.firstChild).toHaveFormValues({ password: 'newpassword', repeatPassword: 'newpassword' }); expect(submitButton).not.toHaveAttribute('disabled'); fireEvent.click(submitButton); expect(submitButton).toHaveAttribute('disabled'); await wait(() => { expect(handler).toHaveBeenCalledWith( { password: 'newpassword', repeatPassword: 'newpassword', token: 'aabbcc' }, expect.objectContaining({ setSubmitting: expect.any(Function) }) ); expect(submitButton).not.toHaveAttribute('disabled'); }); });