) => {
+ return (
+
+
+
+
+
+
+
+ );
+ };
+
+ it('should not render component if contract type is not Vanillas or Turbos', () => {
+ const { container } = render(mockTradeTypeTabs());
+
+ expect(container).toBeEmptyDOMElement();
+ });
+
+ it('should render correct tabs name for Vanillas', () => {
+ defaultMockStore.modules.trade.contract_type = TRADE_TYPES.VANILLA.CALL;
+ render(mockTradeTypeTabs({ is_minimized: true }));
+
+ expect(screen.getByText('Call')).toBeInTheDocument();
+ expect(screen.getByText('Put')).toBeInTheDocument();
+
+ userEvent.click(screen.getByText('Put'));
+ });
+
+ it('should call onChange function if user clicks on another tab and not call it if he clicks on the already chosen one', () => {
+ defaultMockStore.modules.trade.contract_type = TRADE_TYPES.TURBOS.LONG;
+ render(mockTradeTypeTabs());
+
+ const current_tab = screen.getByText('Up');
+ const another_tab = screen.getByText('Down');
+ expect(defaultMockStore.modules.trade.onChange).not.toBeCalled();
+ userEvent.click(current_tab);
+ expect(defaultMockStore.modules.trade.onChange).not.toBeCalled();
+
+ userEvent.click(another_tab);
+ expect(defaultMockStore.modules.trade.onChange).toBeCalled();
+ });
+});
diff --git a/packages/trader/src/AppV2/Components/TradeParameters/__tests__/trade-parameters-container.spec.tsx b/packages/trader/src/AppV2/Components/TradeParameters/__tests__/trade-parameters-container.spec.tsx
new file mode 100644
index 000000000000..508777e820c3
--- /dev/null
+++ b/packages/trader/src/AppV2/Components/TradeParameters/__tests__/trade-parameters-container.spec.tsx
@@ -0,0 +1,29 @@
+import React from 'react';
+import { render, screen } from '@testing-library/react';
+import TradeParametersContainer from '../trade-parameters-container';
+
+const children = 'children';
+const mock_children = {children}
;
+
+jest.mock('react-transition-group', () => ({
+ CSSTransition: jest.fn(({ children }) => {children}
),
+}));
+jest.mock('../../Guide', () => jest.fn(() => 'Guide'));
+
+describe('TradeParametersContainer', () => {
+ it('should render a proper content with children if is_minimized is false', () => {
+ render({mock_children});
+
+ expect(screen.getByText('Set your trade')).toBeInTheDocument();
+ expect(screen.getByText('Guide')).toBeInTheDocument();
+ expect(screen.getByText(children)).toBeInTheDocument();
+ });
+
+ it('should render only children if is_minimized is true', () => {
+ render({mock_children});
+
+ expect(screen.queryByText('Set your trade')).not.toBeInTheDocument();
+ expect(screen.queryByText('Guide')).not.toBeInTheDocument();
+ expect(screen.getByText(children)).toBeInTheDocument();
+ });
+});
diff --git a/packages/trader/src/AppV2/Components/TradeParameters/__tests__/trade-parameters.spec.tsx b/packages/trader/src/AppV2/Components/TradeParameters/__tests__/trade-parameters.spec.tsx
new file mode 100644
index 000000000000..ae058aa82f13
--- /dev/null
+++ b/packages/trader/src/AppV2/Components/TradeParameters/__tests__/trade-parameters.spec.tsx
@@ -0,0 +1,171 @@
+import React from 'react';
+import { render, screen } from '@testing-library/react';
+import { TRADE_TYPES } from '@deriv/shared';
+import { mockStore } from '@deriv/stores';
+import ModulesProvider from 'Stores/Providers/modules-providers';
+import TraderProviders from '../../../../trader-providers';
+import { ReportsStoreProvider } from '../../../../../../reports/src/Stores/useReportsStores';
+import TradeParameters from '../trade-parameters';
+
+const TRADE_PARAMS = {
+ ALLOW_EQUALS: 'AllowEquals',
+ DURATION: 'Duration',
+ STAKE: 'Stake',
+ BARRIER: 'Barrier',
+ GROWTH_RATE: 'GrowthRate',
+ TAKE_PROFIT: 'TakeProfit',
+ ACCUMULATORS_INFORMATION: 'AccumulatorsInformation',
+ MULTIPLIER: 'Multiplier',
+ RISK_MANAGEMENT: 'RiskManagement',
+ MULTIPLIERS_INFORMATION: 'MultipliersInformation',
+ TRADE_TYPE_TABS: 'TradeTypeTabs',
+ STRIKE: 'Strike',
+ PAYOUT_PER_POINT: 'PayoutPerPoint',
+ LAST_DIGIT_PREDICTION: 'LastDigitPrediction',
+};
+const data_test = 'dt_trade_param';
+
+jest.mock('../AllowEquals', () => jest.fn(() => {TRADE_PARAMS.ALLOW_EQUALS}
));
+jest.mock('../Duration', () => jest.fn(() => {TRADE_PARAMS.DURATION}
));
+jest.mock('../Stake', () => jest.fn(() => {TRADE_PARAMS.STAKE}
));
+jest.mock('../Barrier', () => jest.fn(() => {TRADE_PARAMS.BARRIER}
));
+jest.mock('../GrowthRate', () => jest.fn(() => {TRADE_PARAMS.GROWTH_RATE}
));
+jest.mock('../TakeProfit', () => jest.fn(() => {TRADE_PARAMS.TAKE_PROFIT}
));
+jest.mock('../AccumulatorsInformation', () =>
+ jest.fn(() => {TRADE_PARAMS.ACCUMULATORS_INFORMATION}
)
+);
+jest.mock('../Multiplier', () => jest.fn(() => {TRADE_PARAMS.MULTIPLIER}
));
+jest.mock('../RiskManagement', () => jest.fn(() => {TRADE_PARAMS.RISK_MANAGEMENT}
));
+jest.mock('../MultipliersInformation', () =>
+ jest.fn(() => {TRADE_PARAMS.MULTIPLIERS_INFORMATION}
)
+);
+jest.mock('../TradeTypeTabs', () => jest.fn(() => {TRADE_PARAMS.TRADE_TYPE_TABS}
));
+jest.mock('../Strike', () => jest.fn(() => {TRADE_PARAMS.STRIKE}
));
+jest.mock('../PayoutPerPoint', () => jest.fn(() => {TRADE_PARAMS.PAYOUT_PER_POINT}
));
+jest.mock('../LastDigitPrediction', () =>
+ jest.fn(() => {TRADE_PARAMS.LAST_DIGIT_PREDICTION}
)
+);
+
+describe('TradeParameters', () => {
+ let defaultMockStore: ReturnType;
+
+ beforeEach(() => {
+ defaultMockStore = mockStore({});
+ });
+
+ const mockTradeParameters = () => {
+ return (
+
+
+
+
+
+
+
+ );
+ };
+
+ it('should render correct trade params for Accumulators', () => {
+ defaultMockStore.modules.trade.contract_type = TRADE_TYPES.ACCUMULATOR;
+ render(mockTradeParameters());
+
+ expect(screen.getByText(TRADE_PARAMS.GROWTH_RATE)).toBeInTheDocument();
+ expect(screen.getByText(TRADE_PARAMS.STAKE)).toBeInTheDocument();
+ expect(screen.getByText(TRADE_PARAMS.TAKE_PROFIT)).toBeInTheDocument();
+ expect(screen.getByText(TRADE_PARAMS.ACCUMULATORS_INFORMATION)).toBeInTheDocument();
+ expect(screen.getAllByTestId(data_test)).toHaveLength(4);
+ });
+
+ it('should render correct trade params for Vanillas', () => {
+ defaultMockStore.modules.trade.contract_type = TRADE_TYPES.VANILLA.CALL;
+ render(mockTradeParameters());
+
+ expect(screen.getByText(TRADE_PARAMS.TRADE_TYPE_TABS)).toBeInTheDocument();
+ expect(screen.getByText(TRADE_PARAMS.DURATION)).toBeInTheDocument();
+ expect(screen.getByText(TRADE_PARAMS.STRIKE)).toBeInTheDocument();
+ expect(screen.getByText(TRADE_PARAMS.STAKE)).toBeInTheDocument();
+ expect(screen.getAllByTestId(data_test)).toHaveLength(4);
+ });
+
+ it('should render correct trade params for Turbos', () => {
+ defaultMockStore.modules.trade.contract_type = TRADE_TYPES.TURBOS.LONG;
+ render(mockTradeParameters());
+
+ expect(screen.getByText(TRADE_PARAMS.TRADE_TYPE_TABS)).toBeInTheDocument();
+ expect(screen.getByText(TRADE_PARAMS.DURATION)).toBeInTheDocument();
+ expect(screen.getByText(TRADE_PARAMS.PAYOUT_PER_POINT)).toBeInTheDocument();
+ expect(screen.getByText(TRADE_PARAMS.STAKE)).toBeInTheDocument();
+ expect(screen.getByText(TRADE_PARAMS.TAKE_PROFIT)).toBeInTheDocument();
+ expect(screen.getAllByTestId(data_test)).toHaveLength(5);
+ });
+
+ it('should render correct trade params for Multipliers', () => {
+ defaultMockStore.modules.trade.contract_type = TRADE_TYPES.MULTIPLIER;
+ render(mockTradeParameters());
+
+ expect(screen.getByText(TRADE_PARAMS.MULTIPLIER)).toBeInTheDocument();
+ expect(screen.getByText(TRADE_PARAMS.STAKE)).toBeInTheDocument();
+ expect(screen.getByText(TRADE_PARAMS.RISK_MANAGEMENT)).toBeInTheDocument();
+ expect(screen.getByText(TRADE_PARAMS.MULTIPLIERS_INFORMATION)).toBeInTheDocument();
+ expect(screen.getAllByTestId(data_test)).toHaveLength(4);
+ });
+
+ it('should render correct trade params for Rise/Fall', () => {
+ defaultMockStore.modules.trade.contract_type = TRADE_TYPES.RISE_FALL;
+ render(mockTradeParameters());
+
+ expect(screen.getByText(TRADE_PARAMS.DURATION)).toBeInTheDocument();
+ expect(screen.getByText(TRADE_PARAMS.STAKE)).toBeInTheDocument();
+ expect(screen.getByText(TRADE_PARAMS.ALLOW_EQUALS)).toBeInTheDocument();
+ expect(screen.getAllByTestId(data_test)).toHaveLength(3);
+ });
+
+ it('should render correct trade params for Higher/Lower', () => {
+ defaultMockStore.modules.trade.contract_type = TRADE_TYPES.HIGH_LOW;
+ render(mockTradeParameters());
+
+ expect(screen.getByText(TRADE_PARAMS.DURATION)).toBeInTheDocument();
+ expect(screen.getByText(TRADE_PARAMS.BARRIER)).toBeInTheDocument();
+ expect(screen.getByText(TRADE_PARAMS.STAKE)).toBeInTheDocument();
+ expect(screen.getAllByTestId(data_test)).toHaveLength(3);
+ });
+
+ it('should render correct trade params for Touch/No Touch', () => {
+ defaultMockStore.modules.trade.contract_type = TRADE_TYPES.TOUCH;
+ render(mockTradeParameters());
+
+ expect(screen.getByText(TRADE_PARAMS.DURATION)).toBeInTheDocument();
+ expect(screen.getByText(TRADE_PARAMS.BARRIER)).toBeInTheDocument();
+ expect(screen.getByText(TRADE_PARAMS.STAKE)).toBeInTheDocument();
+ expect(screen.getAllByTestId(data_test)).toHaveLength(3);
+ });
+
+ it('should render correct trade params for Matches/Differs', () => {
+ defaultMockStore.modules.trade.contract_type = TRADE_TYPES.MATCH_DIFF;
+ render(mockTradeParameters());
+
+ expect(screen.getByText(TRADE_PARAMS.LAST_DIGIT_PREDICTION)).toBeInTheDocument();
+ expect(screen.getByText(TRADE_PARAMS.DURATION)).toBeInTheDocument();
+ expect(screen.getByText(TRADE_PARAMS.STAKE)).toBeInTheDocument();
+ expect(screen.getAllByTestId(data_test)).toHaveLength(3);
+ });
+
+ it('should render correct trade params for Even/Odd', () => {
+ defaultMockStore.modules.trade.contract_type = TRADE_TYPES.EVEN_ODD;
+ render(mockTradeParameters());
+
+ expect(screen.getByText(TRADE_PARAMS.DURATION)).toBeInTheDocument();
+ expect(screen.getByText(TRADE_PARAMS.STAKE)).toBeInTheDocument();
+ expect(screen.getAllByTestId(data_test)).toHaveLength(2);
+ });
+
+ it('should render correct trade params for Over/Under', () => {
+ defaultMockStore.modules.trade.contract_type = TRADE_TYPES.OVER_UNDER;
+ render(mockTradeParameters());
+
+ expect(screen.getByText(TRADE_PARAMS.LAST_DIGIT_PREDICTION)).toBeInTheDocument();
+ expect(screen.getByText(TRADE_PARAMS.DURATION)).toBeInTheDocument();
+ expect(screen.getByText(TRADE_PARAMS.STAKE)).toBeInTheDocument();
+ expect(screen.getAllByTestId(data_test)).toHaveLength(3);
+ });
+});