Skip to content

Commit

Permalink
Merge pull request #28 from amina-deriv/amina/feature/90115/update_ju…
Browse files Browse the repository at this point in the history
…risdiction

Amina/feature/90115/update jurisdiction
  • Loading branch information
shaheer-deriv committed May 22, 2023
2 parents 2946ebd + e5b1c3a commit 2585e53
Show file tree
Hide file tree
Showing 409 changed files with 6,590 additions and 4,861 deletions.
2 changes: 1 addition & 1 deletion packages/account/build/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ module.exports = function (env) {
'proof-of-identity-form-on-signup': 'Components/poi/poi-form-on-signup',
'proof-of-identity-container-for-mt5':
'Sections/Verification/ProofOfIdentity/proof-of-identity-container-for-mt5',
'poi-poa-docs-submitted': 'Components/poi-poa-docs-submitted/poi-poa-docs-submitted.jsx',
'poi-poa-docs-submitted': 'Components/poi-poa-docs-submitted/poi-poa-docs-submitted',
'reset-trading-password-modal': 'Components/reset-trading-password-modal',
'risk-tolerance-warning-modal': 'Components/trading-assessment/risk-tolerance-warning-modal.jsx',
'self-exclusion': 'Components/self-exclusion',
Expand Down
4 changes: 2 additions & 2 deletions packages/account/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
},
"scripts": {
"start": "npm run test && npm run serve",
"serve": "echo \"Serving...\" && webpack --progress --watch --config \"./build/webpack.config.js\"",
"build": "f () { webpack --config \"./build/webpack.config.js\" --env base=$1;}; f",
"serve": "echo \"Serving...\" && NODE_OPTIONS='-r ts-node/register' webpack --progress --watch --config \"./build/webpack.config.js\"",
"build": "f () { NODE_OPTIONS='-r ts-node/register' webpack --config \"./build/webpack.config.js\" --env base=$1;}; f",
"build:travis": "rimraf dist && webpack --config \"./build/webpack.config.js\" --mode=production",
"test": "echo \"No test specified\"",
"test:eslint": "eslint \"./src/**/*.?(js|jsx|ts|tsx)\"",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jest.mock('@deriv/shared', () => ({
makeCancellablePromise: jest.fn(() => ({ cancel: jest.fn(), promise: Promise.resolve('resolved') })),
}));

jest.mock('../../real-account-signup/helpers/utils.js', () => ({
jest.mock('../../real-account-signup/helpers/utils.ts', () => ({
splitValidationResultTypes: jest.fn(() => ({
errors: {},
warnings: {},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jest.mock('@deriv/shared', () => ({
isMobile: jest.fn().mockReturnValue(false),
}));

jest.mock('../../real-account-signup/helpers/utils.js', () => ({
jest.mock('../../real-account-signup/helpers/utils.ts', () => ({
splitValidationResultTypes: jest.fn(() => ({
warnings: {},
errors: {},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import React from 'react';
import { fireEvent, render, screen, waitFor } from '@testing-library/react';
import { isDesktop, isMobile } from '@deriv/shared';
import FinancialDetails from '../financial-details';
import FinancialDetails, { TFinancialInformationAndTradingExperience, TFinancialDetails } from '../financial-details';
import { FormikValues } from 'formik';

jest.mock('@deriv/shared', () => ({
...jest.requireActual('@deriv/shared'),
Expand All @@ -13,7 +14,7 @@ const modal_root_el = document.createElement('div');
modal_root_el.setAttribute('id', 'modal_root');
document.body.appendChild(modal_root_el);

const fields_enums = {
const fields_enums: TFinancialInformationAndTradingExperience = {
account_turnover_enum: [
{ value: 'account turnover 1', text: 'account turnover 1' },
{ value: 'account turnover 2', text: 'account turnover 2' },
Expand Down Expand Up @@ -47,20 +48,44 @@ const fields_enums = {
{ value: 'source of wealth 1', text: 'source of wealth 1' },
{ value: 'source of wealth 2', text: 'source of wealth 2' },
],
employment_status_enum: [
{ value: 'employment status 1', text: 'employment status 1' },
{ value: 'employment status 2', text: 'employment status 2' },
],
};

describe('<FinancialDetails />', () => {
let mock_props = {};
let mock_props: TFinancialDetails & TFinancialInformationAndTradingExperience = {
getCurrentStep: jest.fn(),
goToNextStep: jest.fn(),
onCancel: jest.fn(),
onSave: jest.fn(),
onSubmit: jest.fn(),
validate: jest.fn(() => ({ errors: {} })),
goToPreviousStep: jest.fn(() => ({ errors: {} })),
value: {},
income_source_enum: [{}],
employment_status_enum: [{}],
employment_industry_enum: [{}],
occupation_enum: [{}],
source_of_wealth_enum: [{}],
education_level_enum: [{}],
net_income_enum: [{}],
estimated_worth_enum: [{}],
account_turnover_enum: [{}],
forex_trading_experience_enum: [{}],
forex_trading_frequency_enum: [{}],
binary_options_trading_experience_enum: [{}],
binary_options_trading_frequency_enum: [{}],
cfd_trading_experience_enum: [{}],
cfd_trading_frequency_enum: [{}],
other_instruments_trading_experience_enum: [{}],
other_instruments_trading_frequency_enum: [{}],
};

beforeEach(() => {
mock_props = {
getCurrentStep: jest.fn(),
goToNextStep: jest.fn(),
onCancel: jest.fn(),
onSave: jest.fn(),
onSubmit: jest.fn(),
validate: jest.fn(() => ({ errors: {} })),
value: {},
...mock_props,
...fields_enums,
};
});
Expand Down Expand Up @@ -89,8 +114,8 @@ describe('<FinancialDetails />', () => {
});

it('should render "FinancialDetails" for mobile', () => {
isDesktop.mockReturnValue(false);
isMobile.mockReturnValue(true);
(isDesktop as jest.Mock).mockReturnValue(false);
(isMobile as jest.Mock).mockReturnValue(true);

render(<FinancialDetails {...mock_props} />);

Expand All @@ -116,36 +141,41 @@ describe('<FinancialDetails />', () => {
});

it('should trigger "Previous" or "Submit" button', async () => {
isDesktop.mockReturnValue(false);
isMobile.mockReturnValue(true);
(isDesktop as jest.Mock).mockReturnValue(false);
(isMobile as jest.Mock).mockReturnValue(true);

render(<FinancialDetails {...mock_props} />);

fieldsRenderCheck();

const select_inputs = screen.getAllByRole('combobox');

const account_turnover_select = select_inputs.find(option => option.name === 'account_turnover');

const education_level_select = select_inputs.find(option => option.name === 'education_level');
const employment_indystry_select = select_inputs.find(option => option.name === 'employment_industry');
const estimated_worth_select = select_inputs.find(option => option.name === 'estimated_worth');
const income_source_select = select_inputs.find(option => option.name === 'income_source');
const net_income_select = select_inputs.find(option => option.name === 'net_income');
const occuppation_select = select_inputs.find(option => option.name === 'occupation');

const source_of_wealth_select = select_inputs.find(option => option.name === 'source_of_wealth');

fireEvent.change(account_turnover_select, { target: { value: 'account turnover 1' } });

fireEvent.change(education_level_select, { target: { value: 'education level 2' } });
fireEvent.change(employment_indystry_select, { target: { value: 'employment industry 1' } });
fireEvent.change(estimated_worth_select, { target: { value: 'estimated worth 2' } });
fireEvent.change(income_source_select, { target: { value: 'income source 1' } });
fireEvent.change(net_income_select, { target: { value: 'net income 1' } });
fireEvent.change(occuppation_select, { target: { value: 'occupation 2' } });

fireEvent.change(source_of_wealth_select, { target: { value: 'source of wealth 1' } });
const account_turnover_select = select_inputs.find(
(option: FormikValues) => option.name === 'account_turnover'
);
const education_level_select = select_inputs.find((option: FormikValues) => option.name === 'education_level');
const employment_indystry_select = select_inputs.find(
(option: FormikValues) => option.name === 'employment_industry'
);
const estimated_worth_select = select_inputs.find((option: FormikValues) => option.name === 'estimated_worth');
const income_source_select = select_inputs.find((option: FormikValues) => option.name === 'income_source');
const net_income_select = select_inputs.find((option: FormikValues) => option.name === 'net_income');
const occuppation_select = select_inputs.find((option: FormikValues) => option.name === 'occupation');

const source_of_wealth_select = select_inputs.find(
(option: FormikValues) => option.name === 'source_of_wealth'
);

fireEvent.change(account_turnover_select as HTMLElement, { target: { value: 'account turnover 1' } });

fireEvent.change(education_level_select as HTMLElement, { target: { value: 'education level 2' } });
fireEvent.change(employment_indystry_select as HTMLElement, { target: { value: 'employment industry 1' } });
fireEvent.change(estimated_worth_select as HTMLElement, { target: { value: 'estimated worth 2' } });
fireEvent.change(income_source_select as HTMLElement, { target: { value: 'income source 1' } });
fireEvent.change(net_income_select as HTMLElement, { target: { value: 'net income 1' } });
fireEvent.change(occuppation_select as HTMLElement, { target: { value: 'occupation 2' } });

fireEvent.change(source_of_wealth_select as HTMLElement, { target: { value: 'source of wealth 1' } });

const btns = screen.getAllByRole('button');
expect(btns[1]).toHaveTextContent('Next');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -508,7 +508,7 @@ export const AccountTurnover = ({
);

type TForexTradingExperience = {
forex_trading_experience_enum: object[];
forex_trading_experience_enum?: object[];
};

export const ForexTradingExperience = ({
Expand Down Expand Up @@ -564,7 +564,7 @@ export const ForexTradingExperience = ({
);

type TForexTradingFrequency = {
forex_trading_frequency_enum: object[];
forex_trading_frequency_enum?: object[];
};

export const ForexTradingFrequency = ({
Expand Down Expand Up @@ -620,7 +620,7 @@ export const ForexTradingFrequency = ({
);

type TBinaryOptionsTradingExperience = {
binary_options_trading_experience_enum: object[];
binary_options_trading_experience_enum?: object[];
};

export const BinaryOptionsTradingExperience = ({
Expand Down Expand Up @@ -676,7 +676,7 @@ export const BinaryOptionsTradingExperience = ({
);

type TBinaryOptionsTradingFrequency = {
binary_options_trading_frequency_enum: object[];
binary_options_trading_frequency_enum?: object[];
};

export const BinaryOptionsTradingFrequency = ({
Expand Down Expand Up @@ -732,7 +732,7 @@ export const BinaryOptionsTradingFrequency = ({
);

type TCFDTradingExperience = {
cfd_trading_experience_enum: object[];
cfd_trading_experience_enum?: object[];
};

export const CFDTradingExperience = ({
Expand Down Expand Up @@ -788,7 +788,7 @@ export const CFDTradingExperience = ({
);

type TCFDTradingFrequency = {
cfd_trading_frequency_enum: object[];
cfd_trading_frequency_enum?: object[];
};

export const CFDTradingFrequency = ({
Expand Down Expand Up @@ -844,7 +844,7 @@ export const CFDTradingFrequency = ({
);

type TOtherInstrumentsTradingExperience = {
other_instruments_trading_experience_enum: object[];
other_instruments_trading_experience_enum?: object[];
};

export const OtherInstrumentsTradingExperience = ({
Expand Down Expand Up @@ -906,7 +906,7 @@ export const OtherInstrumentsTradingExperience = ({
);

type TOtherInstrumentsTradingFrequency = {
other_instruments_trading_frequency_enum: object[];
other_instruments_trading_frequency_enum?: object[];
};

export const OtherInstrumentsTradingFrequency = ({
Expand Down
Loading

0 comments on commit 2585e53

Please sign in to comment.