tg-core-components 5.2.1-history-time-label.0 → 5.3.0-master.1
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/es/components/AcceptUpdatedTaC/index.js +8 -3
- package/es/components/Checkbox/index.js +93 -0
- package/es/components/Deposit/CardInput/index.js +1 -3
- package/es/components/Input/index.js +222 -22
- package/es/components/InputWrapper/index.js +69 -0
- package/es/components/Notification.js +4 -4
- package/es/components/Select/index.js +202 -64
- package/es/components/Select/test.js +111 -0
- package/es/index.js +2 -1
- package/es/lib/utils/translate.js +1 -8
- package/es/widgets/AccountDetail/index.js +53 -77
- package/es/widgets/ActivateWidget/index.js +59 -293
- package/es/widgets/BonusWidget/BonusCode.js +24 -17
- package/es/widgets/BonusWidget/index.js +83 -45
- package/es/widgets/Cashier/Deposit/PaymentForm/NewTab.js +28 -0
- package/es/widgets/Cashier/Deposit/PaymentForm/index.js +6 -2
- package/es/widgets/CashierAccordion/Deposit/BonusCodeInput/index.js +9 -6
- package/es/widgets/CashierAccordion/Deposit/DepositWidget/index.js +19 -29
- package/es/widgets/CashierAccordion/Payment/PaymentAccountForms/index.js +163 -347
- package/es/widgets/CashierAccordion/Payment/PaymentAccountParser.js +0 -6
- package/es/widgets/CashierAccordion/Withdraw/WithdrawWidget/index.js +8 -22
- package/es/widgets/ChangePassword/index.js +53 -40
- package/es/widgets/HistoryWidget/index.js +69 -51
- package/es/widgets/HistoryWidget/message.js +17 -20
- package/es/widgets/RequestResetPassword/index.js +15 -14
- package/es/widgets/ResetPassword/index.js +22 -18
- package/es/widgets/ResponsibleGamingAccordion/LimitStatus/index.js +5 -2
- package/es/widgets/ResponsibleGamingAccordion/PeriodItemContent/index.js +1 -2
- package/es/widgets/ResponsibleGamingSingleSignUp/AmountItem/index.js +1 -2
- package/es/widgets/ResponsibleGamingWidget/Timespan.js +14 -24
- package/es/widgets/ResponsibleGamingWidget/helpers.js +2 -2
- package/es/widgets/ResponsibleGamingWidget/validate.js +1 -1
- package/es/widgets/Settings/index.js +2 -2
- package/es/widgets/SignIn/SignInForm.js +4 -6
- package/es/widgets/SignIn/index.js +21 -21
- package/es/widgets/SignUp/ContactInfoStep.js +5 -6
- package/es/widgets/SportsbookSettings/index.js +10 -24
- package/es/widgets/Subscriptions/index.js +3 -5
- package/lib/components/AcceptUpdatedTaC/index.js +11 -3
- package/lib/components/Checkbox/index.js +106 -0
- package/lib/components/Deposit/CardInput/index.js +1 -3
- package/lib/components/Input/index.js +223 -26
- package/lib/components/InputWrapper/index.js +85 -0
- package/lib/components/Notification.js +3 -3
- package/lib/components/Select/index.js +209 -63
- package/lib/components/Select/test.js +121 -0
- package/lib/index.js +9 -4
- package/lib/lib/utils/translate.js +1 -8
- package/lib/widgets/AccountDetail/index.js +53 -86
- package/lib/widgets/ActivateWidget/index.js +58 -305
- package/lib/widgets/BonusWidget/BonusCode.js +24 -20
- package/lib/widgets/BonusWidget/index.js +85 -44
- package/lib/widgets/Cashier/Deposit/PaymentForm/NewTab.js +44 -0
- package/lib/widgets/Cashier/Deposit/PaymentForm/index.js +9 -2
- package/lib/widgets/CashierAccordion/Deposit/BonusCodeInput/index.js +13 -7
- package/lib/widgets/CashierAccordion/Deposit/DepositWidget/index.js +22 -32
- package/lib/widgets/CashierAccordion/Payment/PaymentAccountForms/index.js +195 -378
- package/lib/widgets/CashierAccordion/Payment/PaymentAccountParser.js +0 -6
- package/lib/widgets/CashierAccordion/Withdraw/WithdrawWidget/index.js +10 -24
- package/lib/widgets/ChangePassword/index.js +53 -43
- package/lib/widgets/HistoryWidget/index.js +69 -51
- package/lib/widgets/HistoryWidget/message.js +17 -20
- package/lib/widgets/RequestResetPassword/index.js +15 -17
- package/lib/widgets/ResetPassword/index.js +25 -21
- package/lib/widgets/ResponsibleGamingAccordion/LimitStatus/index.js +5 -2
- package/lib/widgets/ResponsibleGamingAccordion/PeriodItemContent/index.js +1 -2
- package/lib/widgets/ResponsibleGamingSingleSignUp/AmountItem/index.js +1 -2
- package/lib/widgets/ResponsibleGamingWidget/Timespan.js +14 -24
- package/lib/widgets/ResponsibleGamingWidget/helpers.js +2 -2
- package/lib/widgets/ResponsibleGamingWidget/validate.js +1 -1
- package/lib/widgets/Settings/index.js +6 -6
- package/lib/widgets/SignIn/SignInForm.js +7 -6
- package/lib/widgets/SignIn/index.js +25 -25
- package/lib/widgets/SignUp/ContactInfoStep.js +8 -6
- package/lib/widgets/SportsbookSettings/index.js +10 -24
- package/lib/widgets/Subscriptions/index.js +3 -11
- package/package.json +8 -3
- package/es/components/Input/BirthdateInput.js +0 -171
- package/es/components/Input/Checkbox.js +0 -51
- package/es/components/Input/Input.js +0 -73
- package/es/components/Input/PasswordInput.js +0 -84
- package/es/components/Input/PhoneNumberInput.js +0 -110
- package/es/components/Input/input.test.js +0 -80
- package/es/components/Input/old-input.test.js +0 -100
- package/es/components/common.js +0 -339
- package/lib/components/Input/BirthdateInput.js +0 -192
- package/lib/components/Input/Checkbox.js +0 -65
- package/lib/components/Input/Input.js +0 -87
- package/lib/components/Input/PasswordInput.js +0 -101
- package/lib/components/Input/PhoneNumberInput.js +0 -127
- package/lib/components/Input/input.test.js +0 -89
- package/lib/components/Input/old-input.test.js +0 -107
- package/lib/components/common.js +0 -359
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
|
|
7
|
+
var _react = require('react');
|
|
8
|
+
|
|
9
|
+
var _react2 = _interopRequireDefault(_react);
|
|
10
|
+
|
|
11
|
+
var _propTypes = require('prop-types');
|
|
12
|
+
|
|
13
|
+
var _propTypes2 = _interopRequireDefault(_propTypes);
|
|
14
|
+
|
|
15
|
+
var _classnames = require('classnames');
|
|
16
|
+
|
|
17
|
+
var _classnames2 = _interopRequireDefault(_classnames);
|
|
18
|
+
|
|
19
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
20
|
+
|
|
21
|
+
var InputWrapper = function InputWrapper(_ref) {
|
|
22
|
+
var children = _ref.children,
|
|
23
|
+
className = _ref.className,
|
|
24
|
+
disabled = _ref.disabled,
|
|
25
|
+
require = _ref.require,
|
|
26
|
+
error = _ref.error,
|
|
27
|
+
title = _ref.title,
|
|
28
|
+
hasValue = _ref.hasValue,
|
|
29
|
+
isFocusing = _ref.isFocusing;
|
|
30
|
+
return _react2.default.createElement(
|
|
31
|
+
'div',
|
|
32
|
+
{
|
|
33
|
+
className: (0, _classnames2.default)('tg_input ' + className, {
|
|
34
|
+
tg_input_value: hasValue,
|
|
35
|
+
input_focus: isFocusing,
|
|
36
|
+
error: error,
|
|
37
|
+
has_title: title
|
|
38
|
+
}) },
|
|
39
|
+
_react2.default.createElement(
|
|
40
|
+
'div',
|
|
41
|
+
{ className: 'input-wrapper' },
|
|
42
|
+
title && _react2.default.createElement(
|
|
43
|
+
'div',
|
|
44
|
+
{ className: (0, _classnames2.default)('input_title', { 'opa-d5': disabled }) },
|
|
45
|
+
title + ' ' + (require ? '*' : '')
|
|
46
|
+
),
|
|
47
|
+
children,
|
|
48
|
+
_react2.default.createElement('div', { className: 'bottom-line' }),
|
|
49
|
+
_react2.default.createElement(
|
|
50
|
+
'div',
|
|
51
|
+
{ className: 'error-message' },
|
|
52
|
+
error
|
|
53
|
+
)
|
|
54
|
+
)
|
|
55
|
+
);
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
InputWrapper.propTypes = {
|
|
59
|
+
/** Determine if select has value */
|
|
60
|
+
hasValue: _propTypes2.default.bool,
|
|
61
|
+
/** Determine if select is focuesd */
|
|
62
|
+
isFocusing: _propTypes2.default.bool,
|
|
63
|
+
/** Determine if select is disable */
|
|
64
|
+
disabled: _propTypes2.default.bool,
|
|
65
|
+
/** Title to show above the select */
|
|
66
|
+
title: _propTypes2.default.string,
|
|
67
|
+
/** Error message to display */
|
|
68
|
+
error: _propTypes2.default.string,
|
|
69
|
+
/** Determine if the select is required */
|
|
70
|
+
require: _propTypes2.default.bool,
|
|
71
|
+
/** Optional className passed in as props */
|
|
72
|
+
className: _propTypes2.default.string
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
InputWrapper.defaultProps = {
|
|
76
|
+
hasValue: false,
|
|
77
|
+
isFocusing: false,
|
|
78
|
+
disabled: false,
|
|
79
|
+
title: '',
|
|
80
|
+
error: '',
|
|
81
|
+
require: false,
|
|
82
|
+
className: ''
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
exports.default = InputWrapper;
|
|
@@ -85,9 +85,9 @@ var Notification = function (_Component) {
|
|
|
85
85
|
timeout = _props2$timeout === undefined ? 5 : _props2$timeout,
|
|
86
86
|
action = _props2.action,
|
|
87
87
|
defaultAction = _props2.defaultAction,
|
|
88
|
-
btnText = _props2.btnText,
|
|
89
88
|
icon = _props2.icon,
|
|
90
|
-
direction = _props2.direction
|
|
89
|
+
direction = _props2.direction,
|
|
90
|
+
btnText = _props2.btnText;
|
|
91
91
|
|
|
92
92
|
|
|
93
93
|
return _react2.default.createElement(
|
|
@@ -184,6 +184,6 @@ var Notification = function (_Component) {
|
|
|
184
184
|
return Notification;
|
|
185
185
|
}(_react.Component);
|
|
186
186
|
|
|
187
|
-
var enhance = (0, _recompose.compose)(_withSwipeListeners2.default
|
|
187
|
+
var enhance = (0, _recompose.compose)(_withSwipeListeners2.default);
|
|
188
188
|
|
|
189
189
|
exports.default = enhance(Notification);
|
|
@@ -4,13 +4,23 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
|
|
7
|
-
var
|
|
7
|
+
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
|
|
8
8
|
|
|
9
9
|
var _react = require('react');
|
|
10
10
|
|
|
11
11
|
var _react2 = _interopRequireDefault(_react);
|
|
12
12
|
|
|
13
|
-
var
|
|
13
|
+
var _Icon = require('../Icon');
|
|
14
|
+
|
|
15
|
+
var _Icon2 = _interopRequireDefault(_Icon);
|
|
16
|
+
|
|
17
|
+
var _InputWrapper = require('../InputWrapper');
|
|
18
|
+
|
|
19
|
+
var _InputWrapper2 = _interopRequireDefault(_InputWrapper);
|
|
20
|
+
|
|
21
|
+
var _propTypes = require('prop-types');
|
|
22
|
+
|
|
23
|
+
var _propTypes2 = _interopRequireDefault(_propTypes);
|
|
14
24
|
|
|
15
25
|
var _classnames = require('classnames');
|
|
16
26
|
|
|
@@ -18,66 +28,202 @@ var _classnames2 = _interopRequireDefault(_classnames);
|
|
|
18
28
|
|
|
19
29
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
20
30
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
31
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
32
|
+
|
|
33
|
+
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
|
|
34
|
+
|
|
35
|
+
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
|
|
36
|
+
|
|
37
|
+
var Select = function (_PureComponent) {
|
|
38
|
+
_inherits(Select, _PureComponent);
|
|
39
|
+
|
|
40
|
+
function Select(props) {
|
|
41
|
+
_classCallCheck(this, Select);
|
|
42
|
+
|
|
43
|
+
var _this = _possibleConstructorReturn(this, (Select.__proto__ || Object.getPrototypeOf(Select)).call(this, props));
|
|
44
|
+
|
|
45
|
+
_this._generateOptions = function () {
|
|
46
|
+
var _this$props = _this.props,
|
|
47
|
+
options = _this$props.options,
|
|
48
|
+
require = _this$props.require,
|
|
49
|
+
placeholder = _this$props.placeholder;
|
|
50
|
+
var isFocusing = _this.state.isFocusing;
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
if (!options) return false;
|
|
54
|
+
|
|
55
|
+
var selectOptions = options.map(function (item, index) {
|
|
56
|
+
if (Array.isArray(item.value)) {
|
|
57
|
+
return _react2.default.createElement(
|
|
58
|
+
'optgroup',
|
|
59
|
+
{ label: item.label },
|
|
60
|
+
item.value.map(function (v, i) {
|
|
61
|
+
return _react2.default.createElement(
|
|
62
|
+
'option',
|
|
63
|
+
{ key: i, value: v.value },
|
|
64
|
+
v.label || v
|
|
65
|
+
);
|
|
66
|
+
})
|
|
67
|
+
);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
return _react2.default.createElement(
|
|
71
|
+
'option',
|
|
72
|
+
{ key: index, value: item.value },
|
|
73
|
+
item.label || item
|
|
74
|
+
);
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
if (placeholder) selectOptions.unshift(_react2.default.createElement(
|
|
78
|
+
'option',
|
|
79
|
+
{ key: 'placeholder', disabled: isFocusing && require },
|
|
80
|
+
placeholder
|
|
81
|
+
));
|
|
82
|
+
|
|
83
|
+
return selectOptions;
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
_this._handleChange = function (e) {
|
|
87
|
+
var _this$props2 = _this.props,
|
|
88
|
+
onChange = _this$props2.onChange,
|
|
89
|
+
name = _this$props2.name;
|
|
90
|
+
|
|
91
|
+
var value = e.currentTarget.value;
|
|
92
|
+
|
|
93
|
+
_this.setState({
|
|
94
|
+
value: value,
|
|
95
|
+
hasValue: !!value
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
onChange && onChange(e, name, value);
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
_this._handleFocus = function () {
|
|
102
|
+
_this.setState({
|
|
103
|
+
isFocusing: true
|
|
104
|
+
});
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
_this._handleBlur = function () {
|
|
108
|
+
var onBlur = _this.props.onBlur;
|
|
109
|
+
var value = _this.state.value;
|
|
110
|
+
|
|
111
|
+
|
|
112
|
+
_this.setState({
|
|
113
|
+
isFocusing: false
|
|
114
|
+
});
|
|
115
|
+
|
|
116
|
+
onBlur && onBlur(value);
|
|
117
|
+
};
|
|
118
|
+
|
|
119
|
+
_this.state = {
|
|
120
|
+
isFocusing: false,
|
|
121
|
+
value: '',
|
|
122
|
+
hasValue: false
|
|
123
|
+
};
|
|
124
|
+
return _this;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
_createClass(Select, [{
|
|
128
|
+
key: 'componentDidMount',
|
|
129
|
+
value: function componentDidMount() {
|
|
130
|
+
var _props = this.props,
|
|
131
|
+
placeholder = _props.placeholder,
|
|
132
|
+
options = _props.options;
|
|
133
|
+
|
|
134
|
+
|
|
135
|
+
var value = this.props.value;
|
|
136
|
+
|
|
137
|
+
if (!value && !placeholder && options) {
|
|
138
|
+
value = options[0].value || options[0];
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
this.setState({ value: value, hasValue: !!value });
|
|
142
|
+
}
|
|
143
|
+
}, {
|
|
144
|
+
key: 'componentDidUpdate',
|
|
145
|
+
value: function componentDidUpdate(prevProps) {
|
|
146
|
+
if (this.props.value !== prevProps.value) {
|
|
147
|
+
this.setState({ value: this.props.value, hasValue: !!this.props.value });
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
}, {
|
|
151
|
+
key: 'render',
|
|
152
|
+
value: function render() {
|
|
153
|
+
var _props2 = this.props,
|
|
154
|
+
className = _props2.className,
|
|
155
|
+
title = _props2.title,
|
|
156
|
+
name = _props2.name,
|
|
157
|
+
error = _props2.error,
|
|
158
|
+
disabled = _props2.disabled,
|
|
159
|
+
require = _props2.require;
|
|
160
|
+
var _state = this.state,
|
|
161
|
+
hasValue = _state.hasValue,
|
|
162
|
+
value = _state.value,
|
|
163
|
+
isFocusing = _state.isFocusing;
|
|
164
|
+
|
|
165
|
+
|
|
166
|
+
return _react2.default.createElement(
|
|
167
|
+
_InputWrapper2.default,
|
|
168
|
+
{
|
|
169
|
+
title: title,
|
|
170
|
+
className: className,
|
|
171
|
+
hasValue: hasValue,
|
|
172
|
+
isFocusing: isFocusing,
|
|
173
|
+
error: error,
|
|
174
|
+
disabled: disabled,
|
|
175
|
+
require: require },
|
|
176
|
+
_react2.default.createElement(
|
|
177
|
+
'select',
|
|
178
|
+
{
|
|
179
|
+
disabled: disabled,
|
|
180
|
+
name: name,
|
|
181
|
+
value: value,
|
|
182
|
+
onChange: this._handleChange,
|
|
183
|
+
onFocus: this._handleFocus,
|
|
184
|
+
onBlur: this._handleBlur },
|
|
185
|
+
this._generateOptions()
|
|
186
|
+
),
|
|
187
|
+
_react2.default.createElement(
|
|
188
|
+
'div',
|
|
189
|
+
{ className: (0, _classnames2.default)('select-icon', { 'opa-d5': disabled }) },
|
|
190
|
+
_react2.default.createElement(_Icon2.default, { icon: 'angle-down' })
|
|
191
|
+
)
|
|
192
|
+
);
|
|
193
|
+
}
|
|
194
|
+
}]);
|
|
195
|
+
|
|
196
|
+
return Select;
|
|
197
|
+
}(_react.PureComponent);
|
|
198
|
+
|
|
199
|
+
Select.propTypes = {
|
|
200
|
+
/** Determine if select is disable */
|
|
201
|
+
disabled: _propTypes2.default.bool,
|
|
202
|
+
/** Title to show above the select */
|
|
203
|
+
title: _propTypes2.default.string,
|
|
204
|
+
/** Error message to display */
|
|
205
|
+
error: _propTypes2.default.string,
|
|
206
|
+
/** Name of the element */
|
|
207
|
+
name: _propTypes2.default.string,
|
|
208
|
+
/** Determine if the select is required */
|
|
209
|
+
require: _propTypes2.default.bool,
|
|
210
|
+
/** Optional className passed in as props */
|
|
211
|
+
className: _propTypes2.default.string,
|
|
212
|
+
/** Placeholder */
|
|
213
|
+
placeholder: _propTypes2.default.string,
|
|
214
|
+
/** Manually pick the default selected option */
|
|
215
|
+
value: _propTypes2.default.string
|
|
216
|
+
};
|
|
217
|
+
|
|
218
|
+
Select.defaultProps = {
|
|
219
|
+
disabled: false,
|
|
220
|
+
title: '',
|
|
221
|
+
error: '',
|
|
222
|
+
name: '',
|
|
223
|
+
require: false,
|
|
224
|
+
className: '',
|
|
225
|
+
value: '',
|
|
226
|
+
placeholder: ''
|
|
79
227
|
};
|
|
80
|
-
TGSelect.Option = _common.Select.Option;
|
|
81
|
-
TGSelect.OptGroup = _common.Select.OptGroup;
|
|
82
228
|
|
|
83
|
-
exports.default =
|
|
229
|
+
exports.default = Select;
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var _react = require('react');
|
|
4
|
+
|
|
5
|
+
var _react2 = _interopRequireDefault(_react);
|
|
6
|
+
|
|
7
|
+
var _reactDom = require('react-dom');
|
|
8
|
+
|
|
9
|
+
var _testUtils = require('react-dom/test-utils');
|
|
10
|
+
|
|
11
|
+
var _index = require('./index');
|
|
12
|
+
|
|
13
|
+
var _index2 = _interopRequireDefault(_index);
|
|
14
|
+
|
|
15
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
16
|
+
|
|
17
|
+
function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } }
|
|
18
|
+
|
|
19
|
+
var container = null;
|
|
20
|
+
beforeEach(function () {
|
|
21
|
+
// setup a DOM element as a render target
|
|
22
|
+
container = document.createElement('div');
|
|
23
|
+
document.body.appendChild(container);
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
afterEach(function () {
|
|
27
|
+
// cleanup on exiting
|
|
28
|
+
(0, _reactDom.unmountComponentAtNode)(container);
|
|
29
|
+
container.remove();
|
|
30
|
+
container = null;
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
describe('renders with correct options', function () {
|
|
34
|
+
it('with only options', function () {
|
|
35
|
+
(0, _testUtils.act)(function () {
|
|
36
|
+
(0, _reactDom.render)(_react2.default.createElement(_index2.default, { options: ['Male', 'Female'] }), container);
|
|
37
|
+
});
|
|
38
|
+
expect([].concat(_toConsumableArray(container.querySelectorAll('option'))).map(function (o) {
|
|
39
|
+
return o.textContent;
|
|
40
|
+
}).join(',')).toBe('Male,Female');
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
it('with preset value and placeholder', function () {
|
|
44
|
+
(0, _testUtils.act)(function () {
|
|
45
|
+
(0, _reactDom.render)(_react2.default.createElement(_index2.default, {
|
|
46
|
+
options: ['Male', 'Female'],
|
|
47
|
+
value: 'Female',
|
|
48
|
+
placeholder: 'Gender'
|
|
49
|
+
}), container);
|
|
50
|
+
});
|
|
51
|
+
expect([].concat(_toConsumableArray(container.querySelectorAll('option'))).map(function (o) {
|
|
52
|
+
return o.textContent;
|
|
53
|
+
}).join(',')).toBe('Gender,Male,Female');
|
|
54
|
+
});
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
describe('renders with correct initial value', function () {
|
|
58
|
+
it('with only options', function () {
|
|
59
|
+
(0, _testUtils.act)(function () {
|
|
60
|
+
(0, _reactDom.render)(_react2.default.createElement(_index2.default, { options: ['Male', 'Female'] }), container);
|
|
61
|
+
});
|
|
62
|
+
expect(container.querySelector('select').value).toBe('Male');
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
it('with preset value', function () {
|
|
66
|
+
(0, _testUtils.act)(function () {
|
|
67
|
+
(0, _reactDom.render)(_react2.default.createElement(_index2.default, { options: ['Male', 'Female'], value: 'Female' }), container);
|
|
68
|
+
});
|
|
69
|
+
expect(container.querySelector('select').value).toBe('Female');
|
|
70
|
+
});
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
describe('renders with correct placeholder value', function () {
|
|
74
|
+
it('with placeholder', function () {
|
|
75
|
+
(0, _testUtils.act)(function () {
|
|
76
|
+
(0, _reactDom.render)(_react2.default.createElement(_index2.default, { options: ['Male', 'Female'], placeholder: 'Gender' }), container);
|
|
77
|
+
});
|
|
78
|
+
expect(container.querySelector('select').value).toBe('Gender');
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
it('with preset value title and placeholder', function () {
|
|
82
|
+
(0, _testUtils.act)(function () {
|
|
83
|
+
(0, _reactDom.render)(_react2.default.createElement(_index2.default, {
|
|
84
|
+
options: ['Male', 'Female'],
|
|
85
|
+
value: 'Female',
|
|
86
|
+
title: 'What is your gender',
|
|
87
|
+
placeholder: 'gender'
|
|
88
|
+
}), container);
|
|
89
|
+
});
|
|
90
|
+
expect(container.querySelector('select').value).toBe('Female');
|
|
91
|
+
});
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
describe('renders with correct placeholder value', function () {
|
|
95
|
+
it('with placeholder and require', function () {
|
|
96
|
+
(0, _testUtils.act)(function () {
|
|
97
|
+
(0, _reactDom.render)(_react2.default.createElement(_index2.default, { options: ['Male', 'Female'], placeholder: 'Gender', require: true }), container);
|
|
98
|
+
});
|
|
99
|
+
expect(container.querySelector('select').value).toBe('Gender');
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
it('with preset value, title, placeholder and require', function () {
|
|
103
|
+
(0, _testUtils.act)(function () {
|
|
104
|
+
(0, _reactDom.render)(_react2.default.createElement(_index2.default, {
|
|
105
|
+
options: ['Male', 'Female'],
|
|
106
|
+
value: 'Male',
|
|
107
|
+
title: 'What is your gender',
|
|
108
|
+
placeholder: 'gender',
|
|
109
|
+
require: true
|
|
110
|
+
}), container);
|
|
111
|
+
});
|
|
112
|
+
expect(container.querySelector('select').value).toBe('Male');
|
|
113
|
+
});
|
|
114
|
+
|
|
115
|
+
it('with placeholder and require', function () {
|
|
116
|
+
(0, _testUtils.act)(function () {
|
|
117
|
+
(0, _reactDom.render)(_react2.default.createElement(_index2.default, { options: ['Male', 'Female'], placeholder: 'Gender', require: true }), container);
|
|
118
|
+
});
|
|
119
|
+
expect(container.querySelector('select').value).toBe('Gender');
|
|
120
|
+
});
|
|
121
|
+
});
|