@alphapoint/apex-web 5.5.6 → 5.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/apex.integration.test.js +435 -0
- package/lib/apex.js +37 -1
- package/lib/apex.test.js +138 -0
- package/lib/components/2FA/PasskeyOption.js +126 -0
- package/lib/components/2FA/TwoFactorAuthComponent.js +24 -5
- package/lib/components/2FA/TwoFactorAuthComponent.test.js +94 -0
- package/lib/components/2FA/TwoFactorAuthContainer.js +139 -27
- package/lib/components/2FA/TwoFactorAuthContainer.test.js +627 -0
- package/lib/components/AccountsDropdown/AccountsDropdownComponent.css +6 -0
- package/lib/components/AccountsDropdown/AccountsDropdownComponent.js +6 -2
- package/lib/components/AccountsDropdown/AccountsDropdownComponent.test.js +43 -0
- package/lib/components/AccountsDropdown/AccountsDropdownContainer.js +3 -1
- package/lib/components/BalancesList/BalancesListContainer.js +4 -1
- package/lib/components/ConfirmBlockTradeModal/ConfirmBlockTradeModalContainer.js +34 -6
- package/lib/components/ConfirmBlockTradeModal/ConfirmBlockTradeModalContainer.test.js +298 -0
- package/lib/components/ConfirmOrderModal/ConfirmOrderModalComponent.js +26 -4
- package/lib/components/ConfirmOrderModal/ConfirmOrderModalContainer.js +4 -1
- package/lib/components/DigitalAssets/digitalAssetsPriceLabel.test.js +238 -0
- package/lib/components/EnableTwoFactorAuth/Disable2FAForm.js +22 -7
- package/lib/components/EnableTwoFactorAuth/Disable2FAModal.js +15 -5
- package/lib/components/EnableTwoFactorAuth/Disable2FAModal.test.js +460 -0
- package/lib/components/EnableTwoFactorAuth/Disable2FAModalContainer.js +108 -16
- package/lib/components/EnableTwoFactorAuth/EnableTwoFactorAuthComponent.js +7 -0
- package/lib/components/EnableTwoFactorAuth/EnableTwoFactorAuthComponent.test.js +105 -0
- package/lib/components/EnableTwoFactorAuth/EnableTwoFactorAuthContainerFactory.js +15 -3
- package/lib/components/FusionAuth/UnlinkOAuthIdentityModal.css +13 -0
- package/lib/components/FusionAuth/UnlinkOAuthIdentityModal.js +246 -0
- package/lib/components/FusionAuth/UnlinkOAuthIdentityModal.test.js +521 -0
- package/lib/components/InstrumentPositions/InstrumentPositionsContainer.js +4 -1
- package/lib/components/Login/LoginFormComponent.js +1 -1
- package/lib/components/MarginBalances/MarginDepositWithdraw/MarginDepositModal/MarginDepositFormContainer.js +2 -1
- package/lib/components/NoAccountBanner/NoAccountBanner.css +9 -0
- package/lib/components/NoAccountBanner/NoAccountBanner.js +58 -0
- package/lib/components/NoAccountBanner/index.js +16 -0
- package/lib/components/NoAccountPlaceholder/NoAccountPlaceholder.css +31 -0
- package/lib/components/NoAccountPlaceholder/NoAccountPlaceholder.js +33 -0
- package/lib/components/NoAccountPlaceholder/index.js +9 -0
- package/lib/components/OrderEntryComponents/advancedForm/AdvancedOrderFormContainer.js +2 -0
- package/lib/components/OrderEntryComponents/common/FormAmountFields.js +5 -0
- package/lib/components/OrderEntryComponents/common/TwapScheduleFields.js +98 -0
- package/lib/components/OrderEntryComponents/defaultForm/OrderEntryAnchoring.js +86 -39
- package/lib/components/OrderEntryComponents/defaultForm/OrderEntryAnchoring.test.js +326 -0
- package/lib/components/OrderEntryComponents/defaultForm/OrderEntryContainer.js +10 -2
- package/lib/components/OrderHistoryComponents/DepositsStatus/DepositsStatusComponent.js +1 -1
- package/lib/components/OrderHistoryComponents/DepositsStatus/DepositsStatusComponent.test.js +99 -0
- package/lib/components/OrderHistoryComponents/InactiveOrders/InactiveOrdersComponent.js +1 -1
- package/lib/components/OrderHistoryComponents/OpenOrders/OpenOrdersComponent.js +1 -1
- package/lib/components/OrderHistoryComponents/WithdrawStatus/WithdrawStatusComponent.js +1 -1
- package/lib/components/OrderHistoryComponents/WithdrawStatus/WithdrawStatusComponent.test.js +113 -0
- package/lib/components/Settings/ProfileAndSecurity/PasskeysSettingsCard/PasskeysSettingsCard.css +108 -0
- package/lib/components/Settings/ProfileAndSecurity/PasskeysSettingsCard/PasskeysSettingsCard.test.js +983 -0
- package/lib/components/Settings/ProfileAndSecurity/PasskeysSettingsCard/PasskeysSettingsCardComponent.js +500 -0
- package/lib/components/Settings/ProfileAndSecurity/PasskeysSettingsCard/index.js +9 -0
- package/lib/components/Settings/ProfileAndSecurity/ProfileSettingsCard/ProfileForm/SsoLinkRowComponent.css +4 -0
- package/lib/components/Settings/ProfileAndSecurity/ProfileSettingsCard/ProfileForm/SsoLinkRowComponent.js +29 -17
- package/lib/components/Settings/ProfileAndSecurity/ProfileSettingsCard/ProfileForm/SsoLinkRowComponent.test.js +135 -0
- package/lib/components/Settings/ProfileAndSecurity/TwoFactorAuthSettingsCard/EnableTwoFactorAuth/EnableTwoFactorAuthComponent.js +12 -4
- package/lib/components/Settings/ProfileAndSecurity/TwoFactorAuthSettingsCard/EnableTwoFactorAuth/EnableTwoFactorAuthComponent.test.js +268 -0
- package/lib/components/TwoFactorAuthForm/TwoFactorAuthForm.test.js +475 -0
- package/lib/components/TwoFactorAuthForm/TwoFactorAuthFormComponent.js +26 -5
- package/lib/components/TwoFactorAuthForm/TwoFactorAuthFormContainer.js +50 -32
- package/lib/components/common/APAutoTabInput/APAutoTabInput.js +5 -2
- package/lib/components/common/APSelect/APSelect.js +3 -1
- package/lib/components/common/ErrorBoundary/ErrorBoundary.css +35 -0
- package/lib/components/common/ErrorBoundary/ErrorBoundary.js +87 -0
- package/lib/config/CONFIG.md +4 -0
- package/lib/config/configDefault.json +2 -1
- package/lib/constants/sendOrder/orderEntryFormConstants.js +23 -4
- package/lib/constants/sendOrder/timeInForceConstants.js +3 -1
- package/lib/constants/sendOrder/twapRejectReasons.js +26 -0
- package/lib/helpers/errorTextFormatter.js +13 -4
- package/lib/helpers/errorTextFormatter.test.js +26 -0
- package/lib/helpers/orderHistoryHelper.js +13 -1
- package/lib/helpers/orderHistoryHelper.test.js +58 -13
- package/lib/helpers/passkeyApi.js +228 -0
- package/lib/helpers/passkeyApi.test.js +171 -0
- package/lib/helpers/placeOrderHelper.js +76 -61
- package/lib/helpers/placeOrderHelper.test.js +169 -10
- package/lib/helpers/recalculateOrderHelper.js +4 -1
- package/lib/helpers/recalculateOrderHelper.test.js +88 -2
- package/lib/helpers/twapOrderHelper.js +265 -0
- package/lib/helpers/twapOrderHelper.test.js +467 -0
- package/lib/helpers/twoFactorAuthCancellation.js +38 -0
- package/lib/helpers/webauthnHelper.js +300 -0
- package/lib/helpers/webauthnHelper.test.js +199 -0
- package/lib/hocs/forAccount.js +33 -0
- package/lib/hocs/forAccount.test.js +50 -0
- package/lib/hocs/forVerified.js +16 -2
- package/lib/hocs/withAuthentication.js +3 -1
- package/lib/hocs/withOneSubmission.js +168 -0
- package/lib/index.js +3 -2
- package/lib/layouts/HeaderLayout/HeaderLayout.js +2 -1
- package/lib/layouts/WalletsLayout/WalletsLayoutContainer.js +3 -1
- package/lib/layouts/WalletsLayout/WalletsLayoutContainer.test.js +84 -0
- package/lib/redux/actions/apiActions.js +77 -9
- package/lib/redux/actions/apiActions.test.js +233 -0
- package/lib/redux/actions/authActions.js +514 -198
- package/lib/redux/actions/authActions.test.js +627 -47
- package/lib/redux/actions/depositActions.js +1 -1
- package/lib/redux/actions/depositActions.test.js +100 -30
- package/lib/redux/actions/fusionAuthActions.test.js +265 -84
- package/lib/redux/actions/interestAccountActions.js +12 -3
- package/lib/redux/actions/interestAccountActions.test.js +73 -0
- package/lib/redux/actions/modalActions.js +1 -0
- package/lib/redux/actions/orderEntryActions.blockTrade.test.js +306 -0
- package/lib/redux/actions/orderEntryActions.js +74 -22
- package/lib/redux/actions/orderEntryActions.test.js +63 -11
- package/lib/redux/actions/orderHistoryActions.js +20 -8
- package/lib/redux/actions/orderHistoryActions.test.js +63 -0
- package/lib/redux/actions/userActions.js +379 -179
- package/lib/redux/actions/userActions.test.js +925 -234
- package/lib/redux/actions/withdrawActions.js +62 -29
- package/lib/redux/actions/withdrawActions.test.js +246 -73
- package/lib/redux/actions/withdrawActions.travelRule.test.js +17 -3
- package/lib/redux/margin/actions/marginActions.js +6 -3
- package/lib/redux/margin/actions/marginActions.test.js +166 -0
- package/lib/redux/middlewares/authMiddleware.js +5 -0
- package/lib/redux/middlewares/authMiddleware.test.js +88 -29
- package/lib/redux/reducers/authReducer.js +1 -0
- package/lib/redux/reducers/authReducer.test.js +38 -0
- package/lib/redux/reducers/userReducer.js +10 -0
- package/lib/redux/reducers/userReducer.test.js +29 -0
- package/lib/redux/selectors/orderEntrySelector.js +19 -8
- package/lib/redux/selectors/orderEntrySelector.test.js +209 -0
- package/lib/redux/selectors/orderTotalSelector.test.js +40 -1
- package/lib/redux/selectors/recentActivitySelector.js +8 -2
- package/lib/redux/selectors/recentActivitySelector.v2.test.js +33 -0
- package/lib/redux/selectors/userSelectors.js +6 -1
- package/lib/redux/selectors/userSelectors.test.js +28 -0
- package/lib/services/fms/fms.js +2 -0
- package/lib/services/fms/fms.test.js +35 -0
- package/package.json +4 -4
|
@@ -0,0 +1,326 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
4
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
5
|
+
var _client = require("react-dom/client");
|
|
6
|
+
var _reactRedux = require("react-redux");
|
|
7
|
+
var _redux = require("redux");
|
|
8
|
+
var _reduxForm = require("redux-form");
|
|
9
|
+
var _config = _interopRequireDefault(require("../../../config"));
|
|
10
|
+
var _orderEntryFormConstants = require("../../../constants/sendOrder/orderEntryFormConstants");
|
|
11
|
+
var _OrderEntryAnchoring = _interopRequireDefault(require("./OrderEntryAnchoring"));
|
|
12
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
|
|
13
|
+
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, "default": e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
|
|
14
|
+
function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }
|
|
15
|
+
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
16
|
+
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
17
|
+
function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
|
|
18
|
+
function _toConsumableArray(r) { return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableSpread(); }
|
|
19
|
+
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
20
|
+
function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
|
|
21
|
+
function _iterableToArray(r) { if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r); }
|
|
22
|
+
function _arrayWithoutHoles(r) { if (Array.isArray(r)) return _arrayLikeToArray(r); }
|
|
23
|
+
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
|
|
24
|
+
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
|
|
25
|
+
jest.mock('react-i18next', function () {
|
|
26
|
+
return {
|
|
27
|
+
useTranslation: function useTranslation() {
|
|
28
|
+
return {
|
|
29
|
+
t: function t(key) {
|
|
30
|
+
return "t(".concat(key, ")");
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
// The form's other sections have their own store dependencies and are not what these specs cover.
|
|
38
|
+
jest.mock('./BuySellTabs', function () {
|
|
39
|
+
return function () {
|
|
40
|
+
return null;
|
|
41
|
+
};
|
|
42
|
+
});
|
|
43
|
+
jest.mock('../common/FormAmountFields.js', function () {
|
|
44
|
+
return {
|
|
45
|
+
FormAmountFields: function FormAmountFields() {
|
|
46
|
+
return null;
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
});
|
|
50
|
+
jest.mock('../common/OrderEntryEstimates.js', function () {
|
|
51
|
+
return {
|
|
52
|
+
OrderEntryEstimates: function OrderEntryEstimates() {
|
|
53
|
+
return null;
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
});
|
|
57
|
+
jest.mock('../../ConfirmOrderModal/index.js', function () {
|
|
58
|
+
return function () {
|
|
59
|
+
return null;
|
|
60
|
+
};
|
|
61
|
+
});
|
|
62
|
+
jest.mock('../../ConfirmOrderModal/OrderWarningModalComponent.js', function () {
|
|
63
|
+
return function () {
|
|
64
|
+
return null;
|
|
65
|
+
};
|
|
66
|
+
});
|
|
67
|
+
jest.mock('../../VerificationRequired/VerificationRequiredContainer.js', function () {
|
|
68
|
+
return function () {
|
|
69
|
+
return null;
|
|
70
|
+
};
|
|
71
|
+
});
|
|
72
|
+
global.IS_REACT_ACT_ENVIRONMENT = true;
|
|
73
|
+
var FORM_NAME = 'orderEntry';
|
|
74
|
+
var OrderEntryForm = (0, _reduxForm.reduxForm)({
|
|
75
|
+
form: FORM_NAME
|
|
76
|
+
})(_OrderEntryAnchoring["default"]);
|
|
77
|
+
var ORDER_TYPES = ['Market Order', 'Limit Order', 'Stop Market', 'Stop Limit'];
|
|
78
|
+
// configDefault.json allows Trailing Stop, Reserve and TWAP on spot, and only Reserve on margin.
|
|
79
|
+
var SPOT_ORDER_TYPES = [].concat(ORDER_TYPES, ['Trailing Stop Market', 'Trailing Stop Limit', 'Reserve Order', 'TWAP']);
|
|
80
|
+
var MARGIN_ORDER_TYPES = [].concat(ORDER_TYPES, ['Reserve Order']);
|
|
81
|
+
var mountedRoots = [];
|
|
82
|
+
var render = function render() {
|
|
83
|
+
var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
|
|
84
|
+
_ref$isMarginActive = _ref.isMarginActive,
|
|
85
|
+
isMarginActive = _ref$isMarginActive === void 0 ? false : _ref$isMarginActive;
|
|
86
|
+
var store = (0, _redux.createStore)((0, _redux.combineReducers)({
|
|
87
|
+
form: _reduxForm.reducer
|
|
88
|
+
}));
|
|
89
|
+
var container = document.createElement('div');
|
|
90
|
+
document.body.appendChild(container);
|
|
91
|
+
var root = (0, _client.createRoot)(container);
|
|
92
|
+
mountedRoots.push(root);
|
|
93
|
+
var renderForm = function renderForm(props) {
|
|
94
|
+
return (0, _react.act)(function () {
|
|
95
|
+
return root.render(/*#__PURE__*/_react["default"].createElement(_reactRedux.Provider, {
|
|
96
|
+
store: store
|
|
97
|
+
}, /*#__PURE__*/_react["default"].createElement(OrderEntryForm, _extends({
|
|
98
|
+
initialValues: {
|
|
99
|
+
side: _orderEntryFormConstants.buyValue,
|
|
100
|
+
orderType: 'Limit Order'
|
|
101
|
+
},
|
|
102
|
+
reduxFormChange: function reduxFormChange(key, value) {
|
|
103
|
+
return store.dispatch((0, _reduxForm.change)(FORM_NAME, key, value));
|
|
104
|
+
},
|
|
105
|
+
reduxFormUntouch: function reduxFormUntouch() {
|
|
106
|
+
for (var _len = arguments.length, fields = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
107
|
+
fields[_key] = arguments[_key];
|
|
108
|
+
}
|
|
109
|
+
return store.dispatch(_reduxForm.untouch.apply(void 0, [FORM_NAME].concat(fields)));
|
|
110
|
+
},
|
|
111
|
+
openReportBlockTradeSidePane: function openReportBlockTradeSidePane() {},
|
|
112
|
+
side: _orderEntryFormConstants.buyValue,
|
|
113
|
+
isBuy: true,
|
|
114
|
+
disableTrading: false,
|
|
115
|
+
maxQuantity: 10
|
|
116
|
+
}, props))));
|
|
117
|
+
});
|
|
118
|
+
};
|
|
119
|
+
renderForm({
|
|
120
|
+
isMarginActive: isMarginActive
|
|
121
|
+
});
|
|
122
|
+
return {
|
|
123
|
+
store: store,
|
|
124
|
+
container: container,
|
|
125
|
+
select: container.querySelector('select[name="orderType"]'),
|
|
126
|
+
values: function values() {
|
|
127
|
+
return store.getState().form[FORM_NAME].values;
|
|
128
|
+
},
|
|
129
|
+
setMarginActive: function setMarginActive(active) {
|
|
130
|
+
return renderForm({
|
|
131
|
+
isMarginActive: active
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
};
|
|
135
|
+
};
|
|
136
|
+
var optionValues = function optionValues(select) {
|
|
137
|
+
return _toConsumableArray(select.options).map(function (option) {
|
|
138
|
+
return option.value;
|
|
139
|
+
});
|
|
140
|
+
};
|
|
141
|
+
describe('OrderEntryAnchoring - Order Type dropdown', function () {
|
|
142
|
+
afterEach(function () {
|
|
143
|
+
(0, _react.act)(function () {
|
|
144
|
+
return mountedRoots.splice(0).forEach(function (root) {
|
|
145
|
+
return root.unmount();
|
|
146
|
+
});
|
|
147
|
+
});
|
|
148
|
+
document.body.innerHTML = '';
|
|
149
|
+
});
|
|
150
|
+
it('offers the four default types plus the advanced types the spot config allows', function () {
|
|
151
|
+
expect(optionValues(render().select)).toEqual(SPOT_ORDER_TYPES);
|
|
152
|
+
});
|
|
153
|
+
it('offers the four default types plus the advanced types the margin config allows', function () {
|
|
154
|
+
expect(optionValues(render({
|
|
155
|
+
isMarginActive: true
|
|
156
|
+
}).select)).toEqual(MARGIN_ORDER_TYPES);
|
|
157
|
+
});
|
|
158
|
+
it('offers Fill Or Kill and Immediate or Cancel when the config allows them', function () {
|
|
159
|
+
var SpotAllowedOrderTypes = _config["default"].Trading.SpotAllowedOrderTypes;
|
|
160
|
+
_config["default"].Trading.SpotAllowedOrderTypes = [].concat(_toConsumableArray(SpotAllowedOrderTypes), ['Fill Or Kill', 'Immediate or Cancel']);
|
|
161
|
+
try {
|
|
162
|
+
expect(optionValues(render().select)).toEqual([].concat(ORDER_TYPES, ['Trailing Stop Market', 'Trailing Stop Limit', 'Fill Or Kill', 'Immediate or Cancel', 'Reserve Order', 'TWAP']));
|
|
163
|
+
} finally {
|
|
164
|
+
_config["default"].Trading.SpotAllowedOrderTypes = SpotAllowedOrderTypes;
|
|
165
|
+
}
|
|
166
|
+
});
|
|
167
|
+
it('falls back to Limit Order when margin turns on and the margin config leaves out the selected type', function () {
|
|
168
|
+
var _render = render(),
|
|
169
|
+
select = _render.select,
|
|
170
|
+
values = _render.values,
|
|
171
|
+
setMarginActive = _render.setMarginActive;
|
|
172
|
+
(0, _react.act)(function () {
|
|
173
|
+
select.value = 'Trailing Stop Market';
|
|
174
|
+
select.dispatchEvent(new Event('change', {
|
|
175
|
+
bubbles: true
|
|
176
|
+
}));
|
|
177
|
+
});
|
|
178
|
+
expect(values().orderType).toEqual('Trailing Stop Market');
|
|
179
|
+
setMarginActive(true);
|
|
180
|
+
expect(values().orderType).toEqual('Limit Order');
|
|
181
|
+
expect(select.value).toEqual('Limit Order');
|
|
182
|
+
});
|
|
183
|
+
it('keeps the selected type when margin turns on and the margin config allows it', function () {
|
|
184
|
+
var _render2 = render(),
|
|
185
|
+
select = _render2.select,
|
|
186
|
+
values = _render2.values,
|
|
187
|
+
setMarginActive = _render2.setMarginActive;
|
|
188
|
+
(0, _react.act)(function () {
|
|
189
|
+
select.value = 'Reserve Order';
|
|
190
|
+
select.dispatchEvent(new Event('change', {
|
|
191
|
+
bubbles: true
|
|
192
|
+
}));
|
|
193
|
+
});
|
|
194
|
+
setMarginActive(true);
|
|
195
|
+
expect(values().orderType).toEqual('Reserve Order');
|
|
196
|
+
expect(select.value).toEqual('Reserve Order');
|
|
197
|
+
});
|
|
198
|
+
it('has no Advanced Orders link, since every type is in the dropdown', function () {
|
|
199
|
+
expect(render().container.textContent).not.toContain('Advanced Orders');
|
|
200
|
+
});
|
|
201
|
+
it('offers all four types and shows the type the form submits, although the config leaves out Limit Order', function () {
|
|
202
|
+
var _config$Trading = _config["default"].Trading,
|
|
203
|
+
SpotAllowedOrderTypes = _config$Trading.SpotAllowedOrderTypes,
|
|
204
|
+
MarginAllowedOrderTypes = _config$Trading.MarginAllowedOrderTypes;
|
|
205
|
+
_config["default"].Trading.SpotAllowedOrderTypes = ['Market Order', 'Stop Market', 'Stop Limit'];
|
|
206
|
+
_config["default"].Trading.MarginAllowedOrderTypes = ['Market Order', 'Stop Market', 'Stop Limit'];
|
|
207
|
+
try {
|
|
208
|
+
var _render3 = render(),
|
|
209
|
+
store = _render3.store,
|
|
210
|
+
select = _render3.select,
|
|
211
|
+
values = _render3.values;
|
|
212
|
+
expect(optionValues(select)).toEqual(ORDER_TYPES);
|
|
213
|
+
expect(values().orderType).toEqual('Limit Order');
|
|
214
|
+
expect(select.value).toEqual('Limit Order');
|
|
215
|
+
|
|
216
|
+
// The order-book handlers set the type programmatically, without a change event.
|
|
217
|
+
(0, _react.act)(function () {
|
|
218
|
+
store.dispatch((0, _reduxForm.change)(FORM_NAME, 'orderType', 'Market Order'));
|
|
219
|
+
});
|
|
220
|
+
expect(select.value).toEqual('Market Order');
|
|
221
|
+
} finally {
|
|
222
|
+
_config["default"].Trading.SpotAllowedOrderTypes = SpotAllowedOrderTypes;
|
|
223
|
+
_config["default"].Trading.MarginAllowedOrderTypes = MarginAllowedOrderTypes;
|
|
224
|
+
}
|
|
225
|
+
});
|
|
226
|
+
it('translates the option labels but keeps the untranslated order type as the value', function () {
|
|
227
|
+
var _render4 = render(),
|
|
228
|
+
select = _render4.select;
|
|
229
|
+
expect(_toConsumableArray(select.options).map(function (option) {
|
|
230
|
+
return option.textContent;
|
|
231
|
+
})).toEqual(SPOT_ORDER_TYPES.map(function (orderType) {
|
|
232
|
+
return "t(".concat(orderType, ")");
|
|
233
|
+
}));
|
|
234
|
+
expect(optionValues(select)).toEqual(SPOT_ORDER_TYPES);
|
|
235
|
+
});
|
|
236
|
+
it("keeps each type's tooltip and data-test hook from the segmented button", function () {
|
|
237
|
+
var _render5 = render(),
|
|
238
|
+
select = _render5.select;
|
|
239
|
+
expect(_toConsumableArray(select.options).slice(0, 4).map(function (option) {
|
|
240
|
+
return [option.dataset.test, option.title];
|
|
241
|
+
})).toEqual([['Market Order Type', 't(Buy or sell at the best available price)'], ['Limit Order Type', 't(Buy or sell at the specified price or better)'], ['Stop Order Type', 't(Buy or sell once the price reaches a specified Stop Price)'], ['Stop Limit Order Type', 't(Buy or sell at the specified price or better once the price reaches a specified Stop Price)']]);
|
|
242
|
+
});
|
|
243
|
+
it('renders the select without unknown DOM props', function () {
|
|
244
|
+
var consoleError = jest.spyOn(console, 'error').mockImplementation(function () {});
|
|
245
|
+
try {
|
|
246
|
+
var _render6 = render(),
|
|
247
|
+
select = _render6.select;
|
|
248
|
+
expect(select.hasAttribute('stylename')).toBe(false);
|
|
249
|
+
expect(consoleError.mock.calls.filter(function (_ref2) {
|
|
250
|
+
var _ref3 = _slicedToArray(_ref2, 1),
|
|
251
|
+
message = _ref3[0];
|
|
252
|
+
return String(message).includes('React does not recognize');
|
|
253
|
+
})).toEqual([]);
|
|
254
|
+
} finally {
|
|
255
|
+
consoleError.mockRestore();
|
|
256
|
+
}
|
|
257
|
+
});
|
|
258
|
+
it('shows the form value as the selected order type', function () {
|
|
259
|
+
expect(render().select.value).toEqual('Limit Order');
|
|
260
|
+
});
|
|
261
|
+
it('switches the form order type and clears the prices and amounts when a type is picked', function () {
|
|
262
|
+
var _render7 = render(),
|
|
263
|
+
store = _render7.store,
|
|
264
|
+
select = _render7.select,
|
|
265
|
+
values = _render7.values;
|
|
266
|
+
(0, _react.act)(function () {
|
|
267
|
+
store.dispatch((0, _reduxForm.change)(FORM_NAME, 'limitPrice', '100'));
|
|
268
|
+
store.dispatch((0, _reduxForm.change)(FORM_NAME, 'stopPrice', '90'));
|
|
269
|
+
store.dispatch((0, _reduxForm.change)(FORM_NAME, 'quantity', '2'));
|
|
270
|
+
store.dispatch((0, _reduxForm.change)(FORM_NAME, 'value', '200'));
|
|
271
|
+
store.dispatch((0, _reduxForm.change)(FORM_NAME, 'trailingAmount', '5'));
|
|
272
|
+
store.dispatch((0, _reduxForm.change)(FORM_NAME, 'limitOffset', '1'));
|
|
273
|
+
store.dispatch((0, _reduxForm.change)(FORM_NAME, 'displayQuantity', '0.5'));
|
|
274
|
+
store.dispatch((0, _reduxForm.change)(FORM_NAME, 'durationMinutes', '30'));
|
|
275
|
+
store.dispatch((0, _reduxForm.change)(FORM_NAME, 'slices', '6'));
|
|
276
|
+
});
|
|
277
|
+
expect(values()).toEqual(expect.objectContaining({
|
|
278
|
+
limitPrice: '100',
|
|
279
|
+
stopPrice: '90',
|
|
280
|
+
quantity: '2',
|
|
281
|
+
value: '200',
|
|
282
|
+
trailingAmount: '5',
|
|
283
|
+
limitOffset: '1',
|
|
284
|
+
displayQuantity: '0.5',
|
|
285
|
+
durationMinutes: '30',
|
|
286
|
+
slices: '6'
|
|
287
|
+
}));
|
|
288
|
+
(0, _react.act)(function () {
|
|
289
|
+
select.value = 'Stop Limit';
|
|
290
|
+
select.dispatchEvent(new Event('change', {
|
|
291
|
+
bubbles: true
|
|
292
|
+
}));
|
|
293
|
+
});
|
|
294
|
+
|
|
295
|
+
// redux-form drops a field changed to '' from `values`, so only side and the new type remain.
|
|
296
|
+
expect(values()).toEqual({
|
|
297
|
+
side: _orderEntryFormConstants.buyValue,
|
|
298
|
+
orderType: 'Stop Limit'
|
|
299
|
+
});
|
|
300
|
+
});
|
|
301
|
+
it('leaves the cleared fields untouched, so they do not show "required" errors after a type change', function () {
|
|
302
|
+
var _render8 = render(),
|
|
303
|
+
store = _render8.store,
|
|
304
|
+
select = _render8.select;
|
|
305
|
+
var touchedFields = function touchedFields() {
|
|
306
|
+
var _store$getState$form$ = store.getState().form[FORM_NAME].fields,
|
|
307
|
+
fields = _store$getState$form$ === void 0 ? {} : _store$getState$form$;
|
|
308
|
+
return ['limitPrice', 'stopPrice', 'value', 'quantity'].filter(function (field) {
|
|
309
|
+
return fields[field] && fields[field].touched;
|
|
310
|
+
});
|
|
311
|
+
};
|
|
312
|
+
(0, _react.act)(function () {
|
|
313
|
+
store.dispatch((0, _reduxForm.change)(FORM_NAME, 'limitPrice', '100'));
|
|
314
|
+
store.dispatch((0, _reduxForm.change)(FORM_NAME, 'quantity', '2'));
|
|
315
|
+
store.dispatch((0, _reduxForm.touch)(FORM_NAME, 'limitPrice', 'quantity'));
|
|
316
|
+
});
|
|
317
|
+
expect(touchedFields()).toEqual(['limitPrice', 'quantity']);
|
|
318
|
+
(0, _react.act)(function () {
|
|
319
|
+
select.value = 'Stop Limit';
|
|
320
|
+
select.dispatchEvent(new Event('change', {
|
|
321
|
+
bubbles: true
|
|
322
|
+
}));
|
|
323
|
+
});
|
|
324
|
+
expect(touchedFields()).toEqual([]);
|
|
325
|
+
});
|
|
326
|
+
});
|
|
@@ -36,6 +36,11 @@ var initialValues = {
|
|
|
36
36
|
value: '',
|
|
37
37
|
limitPrice: '',
|
|
38
38
|
stopPrice: '',
|
|
39
|
+
trailingAmount: '',
|
|
40
|
+
limitOffset: '',
|
|
41
|
+
pegPriceType: '1',
|
|
42
|
+
durationMinutes: '',
|
|
43
|
+
slices: '',
|
|
39
44
|
fee: '0',
|
|
40
45
|
totalAmount: '0',
|
|
41
46
|
timeInForce: '1',
|
|
@@ -58,8 +63,11 @@ var mapDispatchToProps = {
|
|
|
58
63
|
reduxFormChange: function reduxFormChange(key, val) {
|
|
59
64
|
return (0, _reduxForm.change)(ORDER_FORM_NAME, key, val);
|
|
60
65
|
},
|
|
61
|
-
|
|
62
|
-
|
|
66
|
+
reduxFormUntouch: function reduxFormUntouch() {
|
|
67
|
+
for (var _len = arguments.length, fields = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
68
|
+
fields[_key] = arguments[_key];
|
|
69
|
+
}
|
|
70
|
+
return _reduxForm.untouch.apply(void 0, [ORDER_FORM_NAME].concat(fields));
|
|
63
71
|
},
|
|
64
72
|
openReportBlockTradeSidePane: function openReportBlockTradeSidePane() {
|
|
65
73
|
return (0, _sidePaneActions.openSidePane)(_sidePanesConstants.SIDE_PANES.REPORT_BLOCK_TRADE);
|
|
@@ -63,7 +63,7 @@ var DepositsStatusComponent = function DepositsStatusComponent(props) {
|
|
|
63
63
|
},
|
|
64
64
|
cell: function cell(_ref3) {
|
|
65
65
|
var row = _ref3.row;
|
|
66
|
-
return t(row.original.Status);
|
|
66
|
+
return row.original.Status === 'AddressBlacklisted' ? t('Under Review') : t(row.original.Status);
|
|
67
67
|
}
|
|
68
68
|
}, {
|
|
69
69
|
header: t('Transaction Id'),
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
4
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
5
|
+
var _client = _interopRequireDefault(require("react-dom/client"));
|
|
6
|
+
var _DepositsStatusComponent = _interopRequireDefault(require("./DepositsStatusComponent"));
|
|
7
|
+
var _table = require("../../data/table");
|
|
8
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
|
|
9
|
+
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, "default": e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
|
|
10
|
+
global.IS_REACT_ACT_ENVIRONMENT = true;
|
|
11
|
+
jest.mock('../../../helpers/dateHelper', function () {
|
|
12
|
+
return {
|
|
13
|
+
formatDateTime: jest.fn(function (dateTime) {
|
|
14
|
+
return "formatted-".concat(dateTime);
|
|
15
|
+
})
|
|
16
|
+
};
|
|
17
|
+
});
|
|
18
|
+
jest.mock('../../../helpers/numberFormatter', function () {
|
|
19
|
+
return {
|
|
20
|
+
formatNumberToLocale: jest.fn(function (number) {
|
|
21
|
+
return "".concat(number);
|
|
22
|
+
})
|
|
23
|
+
};
|
|
24
|
+
});
|
|
25
|
+
jest.mock('../../../helpers/cssClassesHelper', function () {
|
|
26
|
+
return {
|
|
27
|
+
getBEMClasses: jest.fn(function (baseClass) {
|
|
28
|
+
return function (modifier) {
|
|
29
|
+
return modifier ? "".concat(baseClass, "--").concat(modifier) : baseClass;
|
|
30
|
+
};
|
|
31
|
+
})
|
|
32
|
+
};
|
|
33
|
+
});
|
|
34
|
+
jest.mock('../../data/table', function () {
|
|
35
|
+
return {
|
|
36
|
+
Table: jest.fn(function () {
|
|
37
|
+
return null;
|
|
38
|
+
})
|
|
39
|
+
};
|
|
40
|
+
});
|
|
41
|
+
jest.mock('react-i18next', function () {
|
|
42
|
+
return {
|
|
43
|
+
useTranslation: function useTranslation() {
|
|
44
|
+
return {
|
|
45
|
+
t: function t(key) {
|
|
46
|
+
return "translated:".concat(key);
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
});
|
|
52
|
+
describe('DepositsStatusComponent status label', function () {
|
|
53
|
+
var defaultProps = {
|
|
54
|
+
data: [],
|
|
55
|
+
decimalPlaces: {},
|
|
56
|
+
config: {
|
|
57
|
+
maxLines: 10,
|
|
58
|
+
usePagination: false
|
|
59
|
+
},
|
|
60
|
+
getDepositTickets: jest.fn(),
|
|
61
|
+
selectedAccountId: 1,
|
|
62
|
+
fetching: false,
|
|
63
|
+
openTravelRuleModal: jest.fn()
|
|
64
|
+
};
|
|
65
|
+
var container;
|
|
66
|
+
var root;
|
|
67
|
+
var renderStatusCell = function renderStatusCell(status) {
|
|
68
|
+
(0, _react.act)(function () {
|
|
69
|
+
root.render(/*#__PURE__*/_react["default"].createElement(_DepositsStatusComponent["default"], defaultProps));
|
|
70
|
+
});
|
|
71
|
+
var columns = _table.Table.mock.calls[_table.Table.mock.calls.length - 1][0].columns;
|
|
72
|
+
var statusColumn = columns.find(function (col) {
|
|
73
|
+
return col.dataTest === 'Status';
|
|
74
|
+
});
|
|
75
|
+
return statusColumn.cell({
|
|
76
|
+
row: {
|
|
77
|
+
original: {
|
|
78
|
+
Status: status
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
});
|
|
82
|
+
};
|
|
83
|
+
beforeEach(function () {
|
|
84
|
+
jest.clearAllMocks();
|
|
85
|
+
container = document.createElement('div');
|
|
86
|
+
root = _client["default"].createRoot(container);
|
|
87
|
+
});
|
|
88
|
+
afterEach(function () {
|
|
89
|
+
(0, _react.act)(function () {
|
|
90
|
+
root.unmount();
|
|
91
|
+
});
|
|
92
|
+
});
|
|
93
|
+
it('shows the translated Under Review label for an AddressBlacklisted ticket', function () {
|
|
94
|
+
expect(renderStatusCell('AddressBlacklisted')).toBe('translated:Under Review');
|
|
95
|
+
});
|
|
96
|
+
it('shows the translated raw status for any other ticket', function () {
|
|
97
|
+
expect(renderStatusCell('FullyProcessed')).toBe('translated:FullyProcessed');
|
|
98
|
+
});
|
|
99
|
+
});
|
|
@@ -116,7 +116,7 @@ var InactiveOrdersComponent = function InactiveOrdersComponent(props) {
|
|
|
116
116
|
var row = _ref6.row;
|
|
117
117
|
return /*#__PURE__*/_react["default"].createElement("div", {
|
|
118
118
|
className: baseClass('price')
|
|
119
|
-
}, (isFutures ? _orderHistoryHelper.getFuturesOrderPriceToDisplay : _orderHistoryHelper.getOrderPriceToDisplay)(row.original, (0, _decimalPlacesHelper.convertIncrementToIntDecimalPlaces)(row.original.selectedInstrument.PriceIncrement)));
|
|
119
|
+
}, (isFutures ? _orderHistoryHelper.getFuturesOrderPriceToDisplay : _orderHistoryHelper.getOrderPriceToDisplay)(row.original, (0, _decimalPlacesHelper.convertIncrementToIntDecimalPlaces)(row.original.selectedInstrument.PriceIncrement), t));
|
|
120
120
|
}
|
|
121
121
|
}, {
|
|
122
122
|
header: t('Date/Time'),
|
|
@@ -115,7 +115,7 @@ var OpenOrdersComponent = function OpenOrdersComponent(props) {
|
|
|
115
115
|
var row = _ref5.row;
|
|
116
116
|
return /*#__PURE__*/_react["default"].createElement("div", {
|
|
117
117
|
className: baseClass('price')
|
|
118
|
-
}, (0, _orderHistoryHelper.getOrderPriceToDisplay)(row.original, (0, _decimalPlacesHelper.convertIncrementToIntDecimalPlaces)(row.original.selectedInstrument.PriceIncrement)));
|
|
118
|
+
}, (0, _orderHistoryHelper.getOrderPriceToDisplay)(row.original, (0, _decimalPlacesHelper.convertIncrementToIntDecimalPlaces)(row.original.selectedInstrument.PriceIncrement), t));
|
|
119
119
|
}
|
|
120
120
|
}, {
|
|
121
121
|
header: t('Date/Time'),
|
|
@@ -60,7 +60,7 @@ var WithdrawStatusComponent = function WithdrawStatusComponent(props) {
|
|
|
60
60
|
},
|
|
61
61
|
cell: function cell(_ref3) {
|
|
62
62
|
var row = _ref3.row;
|
|
63
|
-
return t(row.original.Status);
|
|
63
|
+
return row.original.Status === 'AddressBlacklisted' ? t('Under Review') : t(row.original.Status);
|
|
64
64
|
}
|
|
65
65
|
}, {
|
|
66
66
|
header: t('Transaction Id'),
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
4
|
+
var _client = _interopRequireDefault(require("react-dom/client"));
|
|
5
|
+
var _WithdrawStatusComponent = _interopRequireDefault(require("./WithdrawStatusComponent"));
|
|
6
|
+
var _table = require("../../data/table");
|
|
7
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
|
|
8
|
+
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, "default": e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
|
|
9
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
10
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
11
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
12
|
+
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
|
13
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
|
14
|
+
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
15
|
+
global.IS_REACT_ACT_ENVIRONMENT = true;
|
|
16
|
+
jest.mock('../../../helpers/dateHelper', function () {
|
|
17
|
+
return {
|
|
18
|
+
formatDateTime: jest.fn(function (dateTime) {
|
|
19
|
+
return "formatted-".concat(dateTime);
|
|
20
|
+
})
|
|
21
|
+
};
|
|
22
|
+
});
|
|
23
|
+
jest.mock('../../../helpers/numberFormatter', function () {
|
|
24
|
+
return {
|
|
25
|
+
formatNumberToLocale: jest.fn(function (number) {
|
|
26
|
+
return "".concat(number);
|
|
27
|
+
})
|
|
28
|
+
};
|
|
29
|
+
});
|
|
30
|
+
jest.mock('../../../helpers/cssClassesHelper', function () {
|
|
31
|
+
return {
|
|
32
|
+
getBEMClasses: jest.fn(function (baseClass) {
|
|
33
|
+
return function (modifier) {
|
|
34
|
+
return modifier ? "".concat(baseClass, "--").concat(modifier) : baseClass;
|
|
35
|
+
};
|
|
36
|
+
})
|
|
37
|
+
};
|
|
38
|
+
});
|
|
39
|
+
jest.mock('../../data/table', function () {
|
|
40
|
+
return {
|
|
41
|
+
Table: jest.fn(function () {
|
|
42
|
+
return null;
|
|
43
|
+
})
|
|
44
|
+
};
|
|
45
|
+
});
|
|
46
|
+
jest.mock('react-i18next', function () {
|
|
47
|
+
var mockReact = require('react');
|
|
48
|
+
return {
|
|
49
|
+
withTranslation: function withTranslation() {
|
|
50
|
+
return function (Component) {
|
|
51
|
+
var WithTranslation = function WithTranslation(props) {
|
|
52
|
+
var t = function t(key) {
|
|
53
|
+
return "translated:".concat(key);
|
|
54
|
+
};
|
|
55
|
+
return mockReact.createElement(Component, _objectSpread(_objectSpread({}, props), {}, {
|
|
56
|
+
t: t
|
|
57
|
+
}));
|
|
58
|
+
};
|
|
59
|
+
WithTranslation.displayName = "withTranslation(".concat(Component.displayName || Component.name, ")");
|
|
60
|
+
return WithTranslation;
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
});
|
|
65
|
+
describe('WithdrawStatusComponent status label', function () {
|
|
66
|
+
var defaultProps = {
|
|
67
|
+
data: [],
|
|
68
|
+
decimalPlaces: {},
|
|
69
|
+
config: {
|
|
70
|
+
maxLines: 10,
|
|
71
|
+
usePagination: false
|
|
72
|
+
},
|
|
73
|
+
cancelWithdrawTicket: jest.fn(),
|
|
74
|
+
selectedAccountId: '1',
|
|
75
|
+
getWithdrawTickets: jest.fn(),
|
|
76
|
+
OMSId: 1,
|
|
77
|
+
fetching: false
|
|
78
|
+
};
|
|
79
|
+
var container;
|
|
80
|
+
var root;
|
|
81
|
+
var renderStatusCell = function renderStatusCell(status) {
|
|
82
|
+
(0, _react.act)(function () {
|
|
83
|
+
root.render(/*#__PURE__*/_react["default"].createElement(_WithdrawStatusComponent["default"], defaultProps));
|
|
84
|
+
});
|
|
85
|
+
var columns = _table.Table.mock.calls[_table.Table.mock.calls.length - 1][0].columns;
|
|
86
|
+
var statusColumn = columns.find(function (col) {
|
|
87
|
+
return col.dataTest === 'Status';
|
|
88
|
+
});
|
|
89
|
+
return statusColumn.cell({
|
|
90
|
+
row: {
|
|
91
|
+
original: {
|
|
92
|
+
Status: status
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
});
|
|
96
|
+
};
|
|
97
|
+
beforeEach(function () {
|
|
98
|
+
jest.clearAllMocks();
|
|
99
|
+
container = document.createElement('div');
|
|
100
|
+
root = _client["default"].createRoot(container);
|
|
101
|
+
});
|
|
102
|
+
afterEach(function () {
|
|
103
|
+
(0, _react.act)(function () {
|
|
104
|
+
root.unmount();
|
|
105
|
+
});
|
|
106
|
+
});
|
|
107
|
+
it('shows the translated Under Review label for an AddressBlacklisted ticket', function () {
|
|
108
|
+
expect(renderStatusCell('AddressBlacklisted')).toBe('translated:Under Review');
|
|
109
|
+
});
|
|
110
|
+
it('shows the translated raw status for any other ticket', function () {
|
|
111
|
+
expect(renderStatusCell('FullyProcessed')).toBe('translated:FullyProcessed');
|
|
112
|
+
});
|
|
113
|
+
});
|