diff --git a/app/components/App/AvailableFunds/__tests__/index.test.js b/app/components/App/AvailableFunds/__tests__/index.test.js new file mode 100644 index 0000000..8f10570 --- /dev/null +++ b/app/components/App/AvailableFunds/__tests__/index.test.js @@ -0,0 +1,71 @@ +import React from 'react'; +import { renderWithProviders } from '../../../../../internals/testing/redux-utils'; +import AvailableFunds from '../index'; + +describe('', () => { + it('should render without crashing', () => { + const initialState = { + global: { + user: { + name: 'Test User', + availableFunds: 2500.75, + }, + isLogged: true, + }, + }; + + const { container } = renderWithProviders(, { + initialState, + }); + expect(container.firstChild).toBeInTheDocument(); + }); + + it('should render with different fund amounts', () => { + const initialState = { + global: { + user: { + name: 'Test User', + availableFunds: 10000.0, + }, + isLogged: true, + }, + }; + + const { container } = renderWithProviders(, { + initialState, + }); + expect(container.firstChild).toBeInTheDocument(); + }); + + it('should handle zero funds', () => { + const initialState = { + global: { + user: { + name: 'Test User', + availableFunds: 0, + }, + isLogged: true, + }, + }; + + const { container } = renderWithProviders(, { + initialState, + }); + expect(container.firstChild).toBeInTheDocument(); + }); + + it('should handle loading state', () => { + const initialState = { + global: { + user: { name: 'Test User' }, + isLogged: true, + isLoading: true, + }, + }; + + const { container } = renderWithProviders(, { + initialState, + }); + expect(container.firstChild).toBeInTheDocument(); + }); +}); diff --git a/app/components/App/BankCards/__tests__/__snapshots__/index.test.js.snap b/app/components/App/BankCards/__tests__/__snapshots__/index.test.js.snap index 7e1be30..ae238d3 100644 --- a/app/components/App/BankCards/__tests__/__snapshots__/index.test.js.snap +++ b/app/components/App/BankCards/__tests__/__snapshots__/index.test.js.snap @@ -1,8 +1,8 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP +// Jest Snapshot v1, https://jestjs.io/docs/snapshot-testing exports[` should render a BankCards 1`] = `
should render a BankCards 1`] = ` class="ant-card-extra" >
({ + ...jest.requireActual('react-redux'), + useDispatch: () => mockDispatch, +})); + +describe('', () => { + beforeEach(() => { + mockDispatch.mockClear(); + }); + + it('should render without crashing when modal is closed', () => { + const initialState = { + global: { isOpenedModal: false }, + loading: { requests: {} }, + }; + + const { container } = renderWithProviders(, { initialState }); + expect(container.firstChild).toBeNull(); + }); + + it('should render modal when isOpenedModal is true', () => { + const initialState = { + global: { isOpenedModal: true }, + loading: { requests: {} }, + }; + + const { getByRole } = renderWithProviders(, { initialState }); + expect(getByRole('dialog')).toBeInTheDocument(); + }); + + it('should show loading state when logout is in progress', () => { + const initialState = { + global: { isOpenedModal: true }, + loading: { + requests: { + 'app/App/LOGOUT_REQUEST': { isLoading: true }, + }, + }, + }; + + const { getByRole } = renderWithProviders(, { initialState }); + const modal = getByRole('dialog'); + expect(modal).toBeInTheDocument(); + }); + + it('should dispatch logout action when Yes button is clicked', () => { + const initialState = { + global: { isOpenedModal: true }, + loading: { requests: {} }, + }; + + const { getByRole } = renderWithProviders(, { initialState }); + const yesButton = getByRole('button', { name: /yes/i }); + + yesButton.click(); + expect(mockDispatch).toHaveBeenCalledWith( + expect.objectContaining({ + type: 'app/App/LOGOUT_REQUEST', + }), + ); + }); + + it('should dispatch toggle modal action when Cancel button is clicked', () => { + const initialState = { + global: { isOpenedModal: true }, + loading: { requests: {} }, + }; + + const { getByRole } = renderWithProviders(, { initialState }); + const cancelButton = getByRole('button', { name: /cancel/i }); + + cancelButton.click(); + expect(mockDispatch).toHaveBeenCalledWith( + expect.objectContaining({ + type: 'app/App/TOGGLE_CONFIRM_MODAL', + }), + ); + }); + + it('should show loading state in modal when logout is in progress', () => { + const initialState = { + global: { isOpenedModal: true }, + loading: { + requests: { + 'app/App/LOGOUT_REQUEST': { isLoading: true }, + }, + }, + }; + + const { getByRole } = renderWithProviders(, { initialState }); + const yesButton = getByRole('button', { name: /yes/i }); + + expect(yesButton).toBeInTheDocument(); + }); + + it('should show correct modal title', () => { + const initialState = { + global: { isOpenedModal: true }, + loading: { requests: {} }, + }; + + const { getByRole } = renderWithProviders(, { initialState }); + const modal = getByRole('dialog'); + + expect(modal).toBeInTheDocument(); + }); + + it('should handle modal close via onCancel', () => { + const initialState = { + global: { isOpenedModal: true }, + loading: { requests: {} }, + }; + + const { getByRole } = renderWithProviders(, { initialState }); + const modal = getByRole('dialog'); + + const closeButton = modal.querySelector('.ant-modal-close'); + if (closeButton) { + closeButton.click(); + expect(mockDispatch).toHaveBeenCalledWith( + expect.objectContaining({ + type: 'app/App/TOGGLE_CONFIRM_MODAL', + }), + ); + } + }); +}); diff --git a/app/components/App/HeaderAction/__tests__/__snapshots__/index.test.js.snap b/app/components/App/HeaderAction/__tests__/__snapshots__/index.test.js.snap index bc8f093..dc11774 100644 --- a/app/components/App/HeaderAction/__tests__/__snapshots__/index.test.js.snap +++ b/app/components/App/HeaderAction/__tests__/__snapshots__/index.test.js.snap @@ -1,14 +1,14 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP +// Jest Snapshot v1, https://jestjs.io/docs/snapshot-testing exports[` should render a HeaderAction 1`] = `
-
-
-
-
- -
-
-
-
-
- - Registration does not require confirmation by the email. - -
`; diff --git a/app/components/ForgotPasswordContent/EmailAddress/index.js b/app/components/ForgotPasswordContent/EmailAddress/index.js index 5ec5e43..a95b98e 100644 --- a/app/components/ForgotPasswordContent/EmailAddress/index.js +++ b/app/components/ForgotPasswordContent/EmailAddress/index.js @@ -1,9 +1,9 @@ import React from 'react'; import { useSelector, useDispatch } from 'react-redux'; import { createStructuredSelector } from 'reselect'; -import { Input, Checkbox } from 'antd'; -import { intlShape, injectIntl, FormattedMessage } from 'react-intl'; -import { checkEmailAction, changeInputAction } from 'containers/App/actions'; +import { Input } from 'antd'; +import { intlShape, injectIntl } from 'react-intl'; +import { changeInputAction } from 'containers/App/actions'; import { makeSelectEmail } from 'containers/ForgetPasswordPage/selectors'; import { StyledFormItem } from 'components/Form/styles'; @@ -20,7 +20,6 @@ function EmailAddress({ intl, onValidateFields }) { const dispatch = useDispatch(); const onChangeInput = (event) => dispatch(changeInputAction(event.target)); - return ( <> diff --git a/app/components/ForgotPasswordContent/EmailAddress/messages.js b/app/components/ForgotPasswordContent/EmailAddress/messages.js index 82427f5..cb6ddc6 100644 --- a/app/components/ForgotPasswordContent/EmailAddress/messages.js +++ b/app/components/ForgotPasswordContent/EmailAddress/messages.js @@ -6,7 +6,8 @@ import { defineMessages } from 'react-intl'; -export const scope = 'app.components.ForgetPassword.ForgetPasswordContent.EmailAddress'; +export const scope = + 'app.components.ForgetPassword.ForgetPasswordContent.EmailAddress'; export default defineMessages({ label: { diff --git a/app/components/ForgotPasswordForm/__tests__/index.test.js b/app/components/ForgotPasswordForm/__tests__/index.test.js new file mode 100644 index 0000000..3b36ade --- /dev/null +++ b/app/components/ForgotPasswordForm/__tests__/index.test.js @@ -0,0 +1,89 @@ +import React from 'react'; +import { renderWithProviders } from '../../../../internals/testing/redux-utils'; +import ForgotPasswordForm from '../index'; + +describe('', () => { + it('should render without crashing', () => { + const initialState = { + global: { + isLogged: false, + isLoading: false, + error: null, + }, + forgotPassword: { + email: '', + isLoading: false, + error: null, + success: false, + }, + }; + + const { container } = renderWithProviders(, { + initialState, + }); + expect(container.firstChild).toBeInTheDocument(); + }); + + it('should render with email input', () => { + const initialState = { + global: { + isLogged: false, + isLoading: false, + error: null, + }, + forgotPassword: { + email: 'test@example.com', + isLoading: false, + error: null, + success: false, + }, + }; + + const { container } = renderWithProviders(, { + initialState, + }); + expect(container.firstChild).toBeInTheDocument(); + }); + + it('should handle loading state', () => { + const initialState = { + global: { + isLogged: false, + isLoading: false, + error: null, + }, + forgotPassword: { + email: 'test@example.com', + isLoading: true, + error: null, + success: false, + }, + }; + + const { container } = renderWithProviders(, { + initialState, + }); + expect(container.firstChild).toBeInTheDocument(); + }); + + it('should handle success state', () => { + const initialState = { + global: { + isLogged: false, + isLoading: false, + error: null, + }, + forgotPassword: { + email: 'test@example.com', + isLoading: false, + error: null, + success: true, + }, + }; + + const { container } = renderWithProviders(, { + initialState, + }); + expect(container.firstChild).toBeInTheDocument(); + }); +}); diff --git a/app/components/ForgotPasswordForm/index.js b/app/components/ForgotPasswordForm/index.js index 4fd447a..177a4a0 100644 --- a/app/components/ForgotPasswordForm/index.js +++ b/app/components/ForgotPasswordForm/index.js @@ -9,10 +9,10 @@ import { StyledForm, StyledFormWrapper } from 'components/Form/styles'; import { forgotPasswordAction } from 'containers/ForgetPasswordPage/actions'; import React from 'react'; import { useDispatch, useSelector } from 'react-redux'; -import EmailAddress from '../ForgotPasswordContent/EmailAddress' -import { makeSelectIsSuccess } from 'containers/ForgetPasswordPage/selectors' -import messages from './messages'; +import { makeSelectIsSuccess } from 'containers/ForgetPasswordPage/selectors'; import { FormattedMessage } from 'react-intl'; +import EmailAddress from '../ForgotPasswordContent/EmailAddress'; +import messages from './messages'; import { StyledResult } from './styles'; function ForgotPasswordForm() { @@ -37,25 +37,23 @@ function ForgotPasswordForm() { {isSuccess ? ( } - subTitle={ } - + title={} + subTitle={} /> - ) : ( - - - + - - )} - - ) + ); } ForgotPasswordForm.propTypes = {}; diff --git a/app/components/ForgotPasswordForm/messages.js b/app/components/ForgotPasswordForm/messages.js index 825ad37..0cce1ab 100644 --- a/app/components/ForgotPasswordForm/messages.js +++ b/app/components/ForgotPasswordForm/messages.js @@ -15,6 +15,7 @@ export default defineMessages({ }, description: { id: `${scope}.description`, - defaultMessage: 'Check your email. A link with the option to reset the password has been sent to the address provided.', + defaultMessage: + 'Check your email. A link with the option to reset the password has been sent to the address provided.', }, }); diff --git a/app/components/ForgotPasswordForm/styles.js b/app/components/ForgotPasswordForm/styles.js index 3a52f33..c6b7150 100644 --- a/app/components/ForgotPasswordForm/styles.js +++ b/app/components/ForgotPasswordForm/styles.js @@ -1,7 +1,4 @@ import styled from 'styled-components'; import { Result } from 'antd'; -import { typography, colors } from 'utils'; -export const StyledResult = styled(Result)` - -`; \ No newline at end of file +export const StyledResult = styled(Result)``; diff --git a/app/components/ForgotPasswordRedirect/__tests__/index.test.js b/app/components/ForgotPasswordRedirect/__tests__/index.test.js new file mode 100644 index 0000000..fe06d15 --- /dev/null +++ b/app/components/ForgotPasswordRedirect/__tests__/index.test.js @@ -0,0 +1,61 @@ +import React from 'react'; +import { renderWithProviders } from '../../../../internals/testing/redux-utils'; +import ForgotPasswordRedirect from '../index'; + +describe('', () => { + it('should render without crashing', () => { + const initialState = { + global: { + isLogged: false, + isLoading: false, + }, + }; + + const { container } = renderWithProviders(, { + initialState, + }); + expect(container.firstChild).toBeInTheDocument(); + }); + + it('should handle redirect with token', () => { + const initialState = { + global: { + isLogged: false, + resetToken: 'test-token-123', + }, + }; + + const { container } = renderWithProviders(, { + initialState, + }); + expect(container.firstChild).toBeInTheDocument(); + }); + + it('should handle loading state', () => { + const initialState = { + global: { + isLogged: false, + isLoading: true, + }, + }; + + const { container } = renderWithProviders(, { + initialState, + }); + expect(container.firstChild).toBeInTheDocument(); + }); + + it('should handle error state', () => { + const initialState = { + global: { + isLogged: false, + error: 'Invalid reset token', + }, + }; + + const { container } = renderWithProviders(, { + initialState, + }); + expect(container.firstChild).toBeInTheDocument(); + }); +}); diff --git a/app/components/ForgotPasswordRedirect/index.js b/app/components/ForgotPasswordRedirect/index.js index d935e75..ad02ba5 100644 --- a/app/components/ForgotPasswordRedirect/index.js +++ b/app/components/ForgotPasswordRedirect/index.js @@ -7,13 +7,12 @@ import React from 'react'; // import PropTypes from 'prop-types'; // import styled from 'styled-components'; -import {Button} from 'antd'; import { FormattedMessage } from 'react-intl'; -import messages from './messages'; import { push } from 'connected-react-router'; import { routes } from 'utils'; import { useDispatch } from 'react-redux'; +import messages from './messages'; import { StyledButton } from './styles'; function ForgotPasswordRedirect() { diff --git a/app/components/ForgotPasswordRedirect/styles.js b/app/components/ForgotPasswordRedirect/styles.js index 691438c..6857d27 100644 --- a/app/components/ForgotPasswordRedirect/styles.js +++ b/app/components/ForgotPasswordRedirect/styles.js @@ -1,9 +1,9 @@ import styled from 'styled-components'; import { Button } from 'antd'; -import { colors } from 'utils'; +import { colors } from 'utils'; export const StyledButton = styled(Button)` - color: ${colors.black}; - padding: 0 0 20px; - height: 100%; + color: ${colors.black}; + padding: 0 0 20px; + height: 100%; `; diff --git a/app/components/Header/__tests__/__snapshots__/index.test.js.snap b/app/components/Header/__tests__/__snapshots__/index.test.js.snap index 3a2cc2e..39b588b 100644 --- a/app/components/Header/__tests__/__snapshots__/index.test.js.snap +++ b/app/components/Header/__tests__/__snapshots__/index.test.js.snap @@ -1,15 +1,15 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP +// Jest Snapshot v1, https://jestjs.io/docs/snapshot-testing exports[`
should render a div 1`] = `
Bank Application should render a div 1`] = ` Adrian Pietrzak should render a information 1`] = `
If you take advantage of our promotion and register your account by the end of this year, you will receive 10,00 USD from us. Accounts already created will also receive this from us. diff --git a/app/components/LoadingIndicator/__tests__/__snapshots__/index.test.js.snap b/app/components/LoadingIndicator/__tests__/__snapshots__/index.test.js.snap index 60c3821..7c0e39a 100644 --- a/app/components/LoadingIndicator/__tests__/__snapshots__/index.test.js.snap +++ b/app/components/LoadingIndicator/__tests__/__snapshots__/index.test.js.snap @@ -1,12 +1,12 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP +// Jest Snapshot v1, https://jestjs.io/docs/snapshot-testing exports[` should render a LoadingIndicator 1`] = `
', () => { + const mockProps = { + steps: [{ title: Step 1 }, { title: Step 2 }], + onValidateFields: jest.fn(), + }; + + it('should render without crashing', () => { + const initialState = { + global: { + isLogged: false, + isLoading: false, + }, + login: { + isLoading: false, + error: null, + }, + }; + + const { container } = renderWithProviders(, { + initialState, + }); + expect(container.firstChild).toBeInTheDocument(); + }); + + it('should handle login loading state', () => { + const initialState = { + global: { + isLogged: false, + isLoading: false, + }, + login: { + isLoading: true, + error: null, + }, + }; + + const { container } = renderWithProviders(, { + initialState, + }); + expect(container.firstChild).toBeInTheDocument(); + }); + + it('should handle login error', () => { + const initialState = { + global: { + isLogged: false, + isLoading: false, + }, + login: { + isLoading: false, + error: 'Invalid credentials', + }, + }; + + const { container } = renderWithProviders(, { + initialState, + }); + expect(container.firstChild).toBeInTheDocument(); + }); + + it('should handle successful login', () => { + const initialState = { + global: { + isLogged: true, + isLoading: false, + user: { name: 'Test User' }, + }, + login: { + isLoading: false, + error: null, + success: true, + }, + }; + + const { container } = renderWithProviders(, { + initialState, + }); + expect(container.firstChild).toBeInTheDocument(); + }); +}); diff --git a/app/components/LoginContent/Password/__tests__/__snapshots__/index.test.js.snap b/app/components/LoginContent/Password/__tests__/__snapshots__/index.test.js.snap index e829033..c462a46 100644 --- a/app/components/LoginContent/Password/__tests__/__snapshots__/index.test.js.snap +++ b/app/components/LoginContent/Password/__tests__/__snapshots__/index.test.js.snap @@ -1,11 +1,11 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP +// Jest Snapshot v1, https://jestjs.io/docs/snapshot-testing exports[` should render a Password 1`] = `
should render a PinCode 1`] = `
should render a PinCode 1`] = ` class="ant-form-item-control-input-content" >
should render a PinCode 1`] = ` aria-label="Increase Value" class="ant-input-number-handler ant-input-number-handler-up" role="button" - unselectable="unselectable" + unselectable="on" > should render a PinCode 1`] = ` aria-label="Decrease Value" class="ant-input-number-handler ant-input-number-handler-down" role="button" - unselectable="unselectable" + unselectable="on" > { + describe('', () => { + it('should render without crashing', () => { + const initialState = { + global: { + isLogged: false, + isLoading: false, + }, + }; + + const { container } = renderWithProviders( + + + , + { initialState }, + ); + expect(container.firstChild).toBeInTheDocument(); + }); + + it('should handle loading state', () => { + const initialState = { + global: { + isLogged: false, + isLoading: true, + }, + }; + + const { container } = renderWithProviders( +
+ + , + { initialState }, + ); + expect(container.firstChild).toBeInTheDocument(); + }); + }); + + describe('', () => { + it('should render without crashing', () => { + const initialState = { + global: { + isLogged: false, + isLoading: false, + }, + }; + + const { container } = renderWithProviders( +
+ + , + { initialState }, + ); + expect(container.firstChild).toBeInTheDocument(); + }); + + it('should handle error state', () => { + const initialState = { + global: { + isLogged: false, + isLoading: false, + error: 'Login failed', + }, + }; + + const { container } = renderWithProviders( +
+ + , + { initialState }, + ); + expect(container.firstChild).toBeInTheDocument(); + }); + }); +}); diff --git a/app/components/LoginForm/__tests__/index.test.js b/app/components/LoginForm/__tests__/index.test.js new file mode 100644 index 0000000..2ccc01e --- /dev/null +++ b/app/components/LoginForm/__tests__/index.test.js @@ -0,0 +1,62 @@ +import React from 'react'; +import { renderWithProviders } from '../../../../internals/testing/redux-utils'; +import LoginForm from '../index'; + +describe('', () => { + it('should render without crashing', () => { + const initialState = { + global: { + isLogged: false, + isLoading: false, + error: null, + }, + login: { + email: '', + password: '', + isLoading: false, + error: null, + }, + }; + + const { container } = renderWithProviders(, { initialState }); + expect(container.firstChild).toBeInTheDocument(); + }); + + it('should render with form data', () => { + const initialState = { + global: { + isLogged: false, + isLoading: false, + error: null, + }, + login: { + email: 'test@example.com', + password: 'password123', + isLoading: false, + error: null, + }, + }; + + const { container } = renderWithProviders(, { initialState }); + expect(container.firstChild).toBeInTheDocument(); + }); + + it('should handle form validation errors', () => { + const initialState = { + global: { + isLogged: false, + isLoading: false, + error: null, + }, + login: { + email: 'invalid-email', + password: '', + isLoading: false, + error: 'Invalid email or password', + }, + }; + + const { container } = renderWithProviders(, { initialState }); + expect(container.firstChild).toBeInTheDocument(); + }); +}); diff --git a/app/components/LoginForm/index.js b/app/components/LoginForm/index.js index 2730d10..824bd64 100644 --- a/app/components/LoginForm/index.js +++ b/app/components/LoginForm/index.js @@ -13,8 +13,7 @@ import LoginAction from 'components/LoginAction'; import { PinCode, Password } from 'components/LoginContent'; import { nextStepAction } from 'containers/App/actions'; import { loginAction } from 'containers/LoginPage/actions'; -import ForgotPasswordRedirect from 'components/ForgotPasswordRedirect' - +import ForgotPasswordRedirect from 'components/ForgotPasswordRedirect'; const stateSelector = createStructuredSelector({ currentStep: makeSelectCurrentStep(), diff --git a/app/components/Privacy/__tests__/index.test.js b/app/components/Privacy/__tests__/index.test.js new file mode 100644 index 0000000..d7ce443 --- /dev/null +++ b/app/components/Privacy/__tests__/index.test.js @@ -0,0 +1,41 @@ +import React from 'react'; +import { renderWithProviders } from '../../../../internals/testing/redux-utils'; +import Privacy from '../index'; + +describe('', () => { + it('should render without crashing', () => { + const initialState = { + global: { + user: { name: 'Test User' }, + isLogged: false, + }, + }; + + const { container } = renderWithProviders(, { initialState }); + expect(container.firstChild).toBeInTheDocument(); + }); + + it('should render privacy content', () => { + const initialState = { + global: { + user: { name: 'Test User' }, + isLogged: false, + }, + }; + + const { container } = renderWithProviders(, { initialState }); + expect(container.firstChild).toBeInTheDocument(); + }); + + it('should handle user interaction', () => { + const initialState = { + global: { + user: { name: 'Test User' }, + isLogged: true, + }, + }; + + const { container } = renderWithProviders(, { initialState }); + expect(container.firstChild).toBeInTheDocument(); + }); +}); diff --git a/app/components/RedirectToggle/__tests__/__snapshots__/index.test.js.snap b/app/components/RedirectToggle/__tests__/__snapshots__/index.test.js.snap index c63c3c5..4fe4f8f 100644 --- a/app/components/RedirectToggle/__tests__/__snapshots__/index.test.js.snap +++ b/app/components/RedirectToggle/__tests__/__snapshots__/index.test.js.snap @@ -1,15 +1,15 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP +// Jest Snapshot v1, https://jestjs.io/docs/snapshot-testing exports[` should render a information 1`] = `
If you already have a bank account, you can log in by clicking on