@gympass/yoga 7.66.0 → 7.66.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/cjs/Dialog/web/Dialog.js +12 -7
- package/cjs/Drawer/web/Drawer.js +5 -1
- package/esm/Accordion/web/Accordion.test.js +19 -0
- package/esm/ActionRequirement/index.native.js +2 -0
- package/esm/ActionRequirement/native/ActionRequirement.js +48 -0
- package/esm/ActionRequirement/native/ActionRequirement.test.js +45 -0
- package/esm/ActionRequirement/native/ActionRequirementStyles.js +25 -0
- package/esm/ActionRequirement/native/index.js +6 -0
- package/esm/ActionRequirement/web/ActionRequirement.test.js +36 -0
- package/esm/AutoComplete/web/AutoComplete.test.js +139 -0
- package/esm/Avatar/index.native.js +4 -0
- package/esm/Avatar/native/Avatar.js +96 -0
- package/esm/Avatar/native/Avatar.test.js +46 -0
- package/esm/Avatar/native/AvatarCircle.js +24 -0
- package/esm/Avatar/web/Avatar.test.js +63 -0
- package/esm/Banner/index.native.js +2 -0
- package/esm/Banner/native/Banner.js +128 -0
- package/esm/Banner/native/Banner.test.js +103 -0
- package/esm/Banner/native/index.js +2 -0
- package/esm/Banner/web/Banner.test.js +109 -0
- package/esm/BottomSheet/web/BottomSheet.test.js +48 -0
- package/esm/Box/index.native.js +2 -0
- package/esm/Box/native/Box.js +4 -0
- package/esm/Box/native/Box.test.js +16 -0
- package/esm/Box/native/index.js +2 -0
- package/esm/Box/web/Box.test.js +16 -0
- package/esm/Button/index.native.js +8 -0
- package/esm/Button/native/Button.js +110 -0
- package/esm/Button/native/Button.test.js +475 -0
- package/esm/Button/native/Icon.js +82 -0
- package/esm/Button/native/Link.js +35 -0
- package/esm/Button/native/Text.js +74 -0
- package/esm/Button/native/withTouchable.js +63 -0
- package/esm/Button/web/Button.test.js +772 -0
- package/esm/Card/index.native.js +2 -0
- package/esm/Card/native/Card/Actions.js +12 -0
- package/esm/Card/native/Card/Card.js +92 -0
- package/esm/Card/native/Card/Card.test.js +15 -0
- package/esm/Card/native/Card/Content.js +8 -0
- package/esm/Card/native/Card/Header.js +8 -0
- package/esm/Card/native/Card/index.js +8 -0
- package/esm/Card/native/EventCard/EventCard.js +169 -0
- package/esm/Card/native/EventCard/EventCard.test.js +65 -0
- package/esm/Card/native/EventCard/index.js +2 -0
- package/esm/Card/native/GymCard/CheckIn/Avatar.js +17 -0
- package/esm/Card/native/GymCard/CheckIn/CheckIn.js +66 -0
- package/esm/Card/native/GymCard/CheckIn/CheckIn.test.js +39 -0
- package/esm/Card/native/GymCard/CheckIn/Content.js +11 -0
- package/esm/Card/native/GymCard/CheckIn/Header.js +11 -0
- package/esm/Card/native/GymCard/CheckIn/index.js +2 -0
- package/esm/Card/native/GymCard/index.js +5 -0
- package/esm/Card/native/PlanCard/Actions.js +22 -0
- package/esm/Card/native/PlanCard/Content.js +75 -0
- package/esm/Card/native/PlanCard/List.js +73 -0
- package/esm/Card/native/PlanCard/PlanCard.js +51 -0
- package/esm/Card/native/PlanCard/PlanCard.test.js +84 -0
- package/esm/Card/native/PlanCard/Subtitle.js +15 -0
- package/esm/Card/native/PlanCard/Tag.js +34 -0
- package/esm/Card/native/PlanCard/index.js +15 -0
- package/esm/Card/native/index.js +5 -0
- package/esm/Card/web/Card/Card.test.js +14 -0
- package/esm/Card/web/EventCard/EventCard.test.js +27 -0
- package/esm/Card/web/PlanCard/PlanCard.test.js +94 -0
- package/esm/Checkbox/index.native.js +3 -0
- package/esm/Checkbox/native/Checkbox.js +179 -0
- package/esm/Checkbox/native/Checkbox.test.js +115 -0
- package/esm/Checkbox/native/Switch.js +115 -0
- package/esm/Checkbox/native/Switch.test.js +54 -0
- package/esm/Checkbox/native/index.js +3 -0
- package/esm/Checkbox/web/Checkbox.test.js +153 -0
- package/esm/Checkbox/web/Switch.test.js +56 -0
- package/esm/Chips/index.native.js +2 -0
- package/esm/Chips/native/Chips.js +104 -0
- package/esm/Chips/native/Chips.test.js +143 -0
- package/esm/Chips/native/Counter.js +20 -0
- package/esm/Chips/native/index.js +2 -0
- package/esm/Chips/web/Chips.test.js +128 -0
- package/esm/Datepicker/web/Datepicker.test.js +247 -0
- package/esm/Dialog/web/Dialog.js +13 -8
- package/esm/Dialog/web/Dialog.test.js +62 -0
- package/esm/Divider/index.native.js +2 -0
- package/esm/Divider/native/Divider.js +29 -0
- package/esm/Divider/native/Divider.test.js +29 -0
- package/esm/Divider/native/index.js +2 -0
- package/esm/Divider/web/Divider.test.js +29 -0
- package/esm/Drawer/web/Drawer.js +6 -2
- package/esm/Drawer/web/Drawer.test.js +33 -0
- package/esm/Dropdown/index.native.js +2 -0
- package/esm/Dropdown/native/Backdrop.js +93 -0
- package/esm/Dropdown/native/Backdrop.test.js +26 -0
- package/esm/Dropdown/native/Dropdown.js +142 -0
- package/esm/Dropdown/native/Dropdown.test.js +78 -0
- package/esm/Dropdown/native/Options.android.js +66 -0
- package/esm/Dropdown/native/Options.ios.js +71 -0
- package/esm/Dropdown/native/index.js +2 -0
- package/esm/Dropdown/web/Dropdown.test.js +93 -0
- package/esm/Feedback/web/Feedback.test.js +83 -0
- package/esm/Grid/web/Col.test.js +48 -0
- package/esm/Grid/web/Container.test.js +14 -0
- package/esm/Grid/web/Hide.test.js +31 -0
- package/esm/Grid/web/Row.test.js +14 -0
- package/esm/Header/web/Header.test.js +38 -0
- package/esm/Heading/web/Heading.test.js +58 -0
- package/esm/Icon/index.native.js +2 -0
- package/esm/Icon/native/Icon.test.js +47 -0
- package/esm/Icon/native/index.js +2 -0
- package/esm/Icon/web/Icon.test.js +47 -0
- package/esm/Input/index.native.js +6 -0
- package/esm/Input/native/Email.js +15 -0
- package/esm/Input/native/Email.test.js +13 -0
- package/esm/Input/native/Helper.js +62 -0
- package/esm/Input/native/Input.js +234 -0
- package/esm/Input/native/Input.test.js +181 -0
- package/esm/Input/native/Number.js +12 -0
- package/esm/Input/native/Number.test.js +13 -0
- package/esm/Input/native/Password.js +112 -0
- package/esm/Input/native/Password.test.js +125 -0
- package/esm/Input/native/Tel.js +14 -0
- package/esm/Input/native/Tel.test.js +13 -0
- package/esm/Input/native/index.js +6 -0
- package/esm/Input/web/Email.test.js +13 -0
- package/esm/Input/web/Input.test.js +145 -0
- package/esm/Input/web/Number.test.js +13 -0
- package/esm/Input/web/Password.test.js +90 -0
- package/esm/Input/web/Phone.test.js +95 -0
- package/esm/Input/web/Tel.test.js +13 -0
- package/esm/List/index.native.js +3 -0
- package/esm/List/native/List.js +22 -0
- package/esm/List/native/List.test.js +106 -0
- package/esm/List/native/ListItem.js +51 -0
- package/esm/List/native/index.js +3 -0
- package/esm/List/web/List.test.js +62 -0
- package/esm/Menu/web/Menu.test.js +115 -0
- package/esm/Popover/web/Popover.test.js +19 -0
- package/esm/Progress/index.native.js +2 -0
- package/esm/Progress/native/Progress.js +103 -0
- package/esm/Progress/native/Progress.test.js +222 -0
- package/esm/Progress/native/index.js +2 -0
- package/esm/Progress/web/Progress.test.js +222 -0
- package/esm/RadioGroup/index.native.js +4 -0
- package/esm/RadioGroup/native/Button/RadioButton.js +64 -0
- package/esm/RadioGroup/native/Button/RadioButton.test.js +96 -0
- package/esm/RadioGroup/native/Radio/Radio.js +88 -0
- package/esm/RadioGroup/native/Radio/Radio.test.js +112 -0
- package/esm/RadioGroup/native/RadioGroup.js +66 -0
- package/esm/RadioGroup/native/RadioGroup.test.js +50 -0
- package/esm/RadioGroup/native/index.js +4 -0
- package/esm/RadioGroup/web/Button/RadioButton.test.js +121 -0
- package/esm/RadioGroup/web/Radio/Radio.test.js +108 -0
- package/esm/RadioGroup/web/RadioGroup.test.js +83 -0
- package/esm/Rating/index.native.js +2 -0
- package/esm/Rating/native/Rating.js +186 -0
- package/esm/Rating/native/Rating.test.js +121 -0
- package/esm/Rating/native/index.js +2 -0
- package/esm/Rating/web/Rating.test.js +184 -0
- package/esm/Result/index.native.js +8 -0
- package/esm/Result/native/Attendances.js +55 -0
- package/esm/Result/native/Details.js +97 -0
- package/esm/Result/native/Rate.js +35 -0
- package/esm/Result/native/Result.js +86 -0
- package/esm/Result/native/Result.test.js +107 -0
- package/esm/Result/native/ResultButton.js +13 -0
- package/esm/Result/native/Tags.js +41 -0
- package/esm/Result/native/TinyTextIcon.js +18 -0
- package/esm/Result/native/index.js +2 -0
- package/esm/Skeleton/index.native.js +2 -0
- package/esm/Skeleton/native/Skeleton.js +94 -0
- package/esm/Skeleton/native/Skeleton.test.js +78 -0
- package/esm/Skeleton/native/index.js +2 -0
- package/esm/Skeleton/web/Skeleton.test.js +77 -0
- package/esm/Slider/index.native.js +2 -0
- package/esm/Slider/native/Label.js +19 -0
- package/esm/Slider/native/Marker.js +68 -0
- package/esm/Slider/native/Slider.js +156 -0
- package/esm/Slider/native/Slider.test.js +122 -0
- package/esm/Slider/native/Step.js +14 -0
- package/esm/Slider/native/Tooltip.js +90 -0
- package/esm/Slider/web/Slider.test.js +86 -0
- package/esm/Snackbar/index.native.js +2 -0
- package/esm/Snackbar/native/Snackbar.js +199 -0
- package/esm/Snackbar/native/Snackbar.test.js +100 -0
- package/esm/Snackbar/native/SnackbarAnimationWrapper.js +124 -0
- package/esm/Snackbar/native/index.js +2 -0
- package/esm/Snackbar/web/Snackbar.test.js +118 -0
- package/esm/Stepper/index.native.js +3 -0
- package/esm/Stepper/native/Dots.js +45 -0
- package/esm/Stepper/native/Line.js +35 -0
- package/esm/Stepper/native/Step.js +19 -0
- package/esm/Stepper/native/Stepper.js +52 -0
- package/esm/Stepper/native/Stepper.test.js +70 -0
- package/esm/Stepper/native/index.js +3 -0
- package/esm/Stepper/web/Stepper.test.js +67 -0
- package/esm/Tag/index.native.js +4 -0
- package/esm/Tag/native/Informative.js +72 -0
- package/esm/Tag/native/Tag.js +75 -0
- package/esm/Tag/native/Tag.test.js +94 -0
- package/esm/Tag/native/index.js +2 -0
- package/esm/Tag/web/Tag.test.js +79 -0
- package/esm/Text/index.native.js +16 -0
- package/esm/Text/native/Text.js +69 -0
- package/esm/Text/native/Text.test.js +149 -0
- package/esm/Text/native/index.js +2 -0
- package/esm/Text/web/Text.test.js +149 -0
- package/esm/TextArea/index.native.js +2 -0
- package/esm/TextArea/native/TextArea.js +59 -0
- package/esm/TextArea/native/TextArea.test.js +11 -0
- package/esm/TextArea/native/index.js +2 -0
- package/esm/TextArea/web/TextArea.test.js +11 -0
- package/esm/Theme/Provider/index.native.js +2 -0
- package/esm/Theme/Provider/native/index.js +2 -0
- package/esm/Theme/Provider/web/FontLoader.test.js +11 -0
- package/esm/Theme/Provider/web/GlobalStyle.test.js +17 -0
- package/esm/Theme/helpers/themeReader/native/native.test.js +53 -0
- package/esm/Theme/helpers/themeReader/web/web.test.js +41 -0
- package/esm/Theme/index.native.js +5 -0
- package/esm/index.native.js +26 -0
- package/esm/shared/index.native.js +2 -0
- package/package.json +2 -2
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { render, fireEvent } from '@testing-library/react-native';
|
|
3
|
+
import { ThemeProvider, Input } from '../..';
|
|
4
|
+
describe('<Input.Password />', function () {
|
|
5
|
+
describe('Snapshots', function () {
|
|
6
|
+
it('should match with default input', function () {
|
|
7
|
+
var _render = render( /*#__PURE__*/React.createElement(ThemeProvider, null, /*#__PURE__*/React.createElement(Input.Password, null))),
|
|
8
|
+
toJSON = _render.toJSON;
|
|
9
|
+
|
|
10
|
+
expect(toJSON()).toMatchSnapshot();
|
|
11
|
+
});
|
|
12
|
+
it('should match when input is focused', function () {
|
|
13
|
+
var _render2 = render( /*#__PURE__*/React.createElement(ThemeProvider, null, /*#__PURE__*/React.createElement(Input.Password, {
|
|
14
|
+
label: "Input",
|
|
15
|
+
testID: "input"
|
|
16
|
+
}))),
|
|
17
|
+
toJSON = _render2.toJSON,
|
|
18
|
+
getByTestId = _render2.getByTestId;
|
|
19
|
+
|
|
20
|
+
fireEvent(getByTestId('input'), 'focus');
|
|
21
|
+
expect(toJSON()).toMatchSnapshot();
|
|
22
|
+
});
|
|
23
|
+
it('should match with disabled input', function () {
|
|
24
|
+
var _render3 = render( /*#__PURE__*/React.createElement(ThemeProvider, null, /*#__PURE__*/React.createElement(Input.Password, {
|
|
25
|
+
disabled: true
|
|
26
|
+
}))),
|
|
27
|
+
toJSON = _render3.toJSON;
|
|
28
|
+
|
|
29
|
+
expect(toJSON()).toMatchSnapshot();
|
|
30
|
+
});
|
|
31
|
+
it('should match with full width', function () {
|
|
32
|
+
var _render4 = render( /*#__PURE__*/React.createElement(ThemeProvider, null, /*#__PURE__*/React.createElement(Input.Password, {
|
|
33
|
+
label: "Label",
|
|
34
|
+
full: true
|
|
35
|
+
}))),
|
|
36
|
+
toJSON = _render4.toJSON;
|
|
37
|
+
|
|
38
|
+
expect(toJSON()).toMatchSnapshot();
|
|
39
|
+
});
|
|
40
|
+
});
|
|
41
|
+
describe('Events', function () {
|
|
42
|
+
it('should call onChangeText', function () {
|
|
43
|
+
var onChangeTextMock = jest.fn();
|
|
44
|
+
|
|
45
|
+
var _render5 = render( /*#__PURE__*/React.createElement(ThemeProvider, null, /*#__PURE__*/React.createElement(Input.Password, {
|
|
46
|
+
label: "Input",
|
|
47
|
+
testID: "input",
|
|
48
|
+
onChangeText: onChangeTextMock
|
|
49
|
+
}))),
|
|
50
|
+
getByTestId = _render5.getByTestId;
|
|
51
|
+
|
|
52
|
+
fireEvent.changeText(getByTestId('input'), 'foo');
|
|
53
|
+
expect(onChangeTextMock).toHaveBeenCalled();
|
|
54
|
+
});
|
|
55
|
+
it('should not call onChangeText when input is readOnly', function () {
|
|
56
|
+
var onChangeTextMock = jest.fn();
|
|
57
|
+
|
|
58
|
+
var _render6 = render( /*#__PURE__*/React.createElement(ThemeProvider, null, /*#__PURE__*/React.createElement(Input.Password, {
|
|
59
|
+
label: "Input",
|
|
60
|
+
testID: "input",
|
|
61
|
+
onChangeText: onChangeTextMock,
|
|
62
|
+
readOnly: true
|
|
63
|
+
}))),
|
|
64
|
+
getByTestId = _render6.getByTestId;
|
|
65
|
+
|
|
66
|
+
fireEvent(getByTestId('input'), 'focus');
|
|
67
|
+
expect(onChangeTextMock).not.toHaveBeenCalled();
|
|
68
|
+
});
|
|
69
|
+
it('should not call onChangeText when input is disabled', function () {
|
|
70
|
+
var onChangeTextMock = jest.fn();
|
|
71
|
+
|
|
72
|
+
var _render7 = render( /*#__PURE__*/React.createElement(ThemeProvider, null, /*#__PURE__*/React.createElement(Input.Password, {
|
|
73
|
+
label: "Input",
|
|
74
|
+
testID: "input",
|
|
75
|
+
onChangeText: onChangeTextMock,
|
|
76
|
+
disabled: true
|
|
77
|
+
}))),
|
|
78
|
+
getByTestId = _render7.getByTestId;
|
|
79
|
+
|
|
80
|
+
fireEvent(getByTestId('input'), 'focus');
|
|
81
|
+
expect(onChangeTextMock).not.toHaveBeenCalled();
|
|
82
|
+
});
|
|
83
|
+
it('should call onFocus', function () {
|
|
84
|
+
var onFocusMock = jest.fn();
|
|
85
|
+
|
|
86
|
+
var _render8 = render( /*#__PURE__*/React.createElement(ThemeProvider, null, /*#__PURE__*/React.createElement(Input.Password, {
|
|
87
|
+
label: "Input",
|
|
88
|
+
testID: "input",
|
|
89
|
+
onFocus: onFocusMock
|
|
90
|
+
}))),
|
|
91
|
+
getByTestId = _render8.getByTestId;
|
|
92
|
+
|
|
93
|
+
fireEvent(getByTestId('input'), 'focus');
|
|
94
|
+
expect(onFocusMock).toHaveBeenCalled();
|
|
95
|
+
});
|
|
96
|
+
it('should call onBlur', function () {
|
|
97
|
+
var onBlurMock = jest.fn();
|
|
98
|
+
|
|
99
|
+
var _render9 = render( /*#__PURE__*/React.createElement(ThemeProvider, null, /*#__PURE__*/React.createElement(Input.Password, {
|
|
100
|
+
label: "Input",
|
|
101
|
+
testID: "input",
|
|
102
|
+
onBlur: onBlurMock
|
|
103
|
+
}))),
|
|
104
|
+
getByTestId = _render9.getByTestId;
|
|
105
|
+
|
|
106
|
+
fireEvent(getByTestId('input'), 'focus');
|
|
107
|
+
fireEvent(getByTestId('input'), 'blur');
|
|
108
|
+
expect(onBlurMock).toHaveBeenCalled();
|
|
109
|
+
});
|
|
110
|
+
});
|
|
111
|
+
describe('visibility button', function () {
|
|
112
|
+
it('should toggle password visibility when press visibility button', function () {
|
|
113
|
+
var _render10 = render( /*#__PURE__*/React.createElement(ThemeProvider, null, /*#__PURE__*/React.createElement(Input.Password, {
|
|
114
|
+
label: "Input",
|
|
115
|
+
testID: "input"
|
|
116
|
+
}))),
|
|
117
|
+
getByRole = _render10.getByRole,
|
|
118
|
+
getByTestId = _render10.getByTestId;
|
|
119
|
+
|
|
120
|
+
expect(getByTestId('input').props.secureTextEntry).toBe(true);
|
|
121
|
+
fireEvent.press(getByRole('button'));
|
|
122
|
+
expect(getByTestId('input').props.secureTextEntry).toBe(false);
|
|
123
|
+
});
|
|
124
|
+
});
|
|
125
|
+
});
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
2
|
+
|
|
3
|
+
import React from 'react';
|
|
4
|
+
import Input from './Input';
|
|
5
|
+
var Tel = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
6
|
+
return /*#__PURE__*/React.createElement(Input, _extends({
|
|
7
|
+
ref: ref
|
|
8
|
+
}, props, {
|
|
9
|
+
keyboardType: "phone-pad",
|
|
10
|
+
autoCompleteType: "tel",
|
|
11
|
+
textContentType: "telephoneNumber"
|
|
12
|
+
}));
|
|
13
|
+
});
|
|
14
|
+
export default Tel;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { render } from '@testing-library/react-native';
|
|
3
|
+
import { ThemeProvider, Input } from '../..';
|
|
4
|
+
describe('<Input.Tel />', function () {
|
|
5
|
+
describe('Snapshots', function () {
|
|
6
|
+
it('should match with default input', function () {
|
|
7
|
+
var _render = render( /*#__PURE__*/React.createElement(ThemeProvider, null, /*#__PURE__*/React.createElement(Input.Tel, null))),
|
|
8
|
+
toJSON = _render.toJSON;
|
|
9
|
+
|
|
10
|
+
expect(toJSON()).toMatchSnapshot();
|
|
11
|
+
});
|
|
12
|
+
});
|
|
13
|
+
});
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { render } from '@testing-library/react';
|
|
3
|
+
import { ThemeProvider, Input } from '../..';
|
|
4
|
+
describe('<Input.Email />', function () {
|
|
5
|
+
describe('Snapshots', function () {
|
|
6
|
+
it('should match with default input', function () {
|
|
7
|
+
var _render = render( /*#__PURE__*/React.createElement(ThemeProvider, null, /*#__PURE__*/React.createElement(Input.Email, null))),
|
|
8
|
+
container = _render.container;
|
|
9
|
+
|
|
10
|
+
expect(container).toMatchSnapshot();
|
|
11
|
+
});
|
|
12
|
+
});
|
|
13
|
+
});
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { render, fireEvent, screen } from '@testing-library/react';
|
|
3
|
+
import { ThemeProvider, Input } from '../..';
|
|
4
|
+
describe('<Input />', function () {
|
|
5
|
+
describe('Snapshots', function () {
|
|
6
|
+
it('should match with default input', function () {
|
|
7
|
+
var _render = render( /*#__PURE__*/React.createElement(ThemeProvider, null, /*#__PURE__*/React.createElement(Input, null))),
|
|
8
|
+
container = _render.container;
|
|
9
|
+
|
|
10
|
+
expect(container).toMatchSnapshot();
|
|
11
|
+
});
|
|
12
|
+
it('should match with label', function () {
|
|
13
|
+
var _render2 = render( /*#__PURE__*/React.createElement(ThemeProvider, null, /*#__PURE__*/React.createElement(Input, {
|
|
14
|
+
label: "Input"
|
|
15
|
+
}))),
|
|
16
|
+
container = _render2.container;
|
|
17
|
+
|
|
18
|
+
expect(container).toMatchSnapshot();
|
|
19
|
+
});
|
|
20
|
+
it('should match with disabled input', function () {
|
|
21
|
+
var _render3 = render( /*#__PURE__*/React.createElement(ThemeProvider, null, /*#__PURE__*/React.createElement(Input, {
|
|
22
|
+
disabled: true
|
|
23
|
+
}))),
|
|
24
|
+
container = _render3.container;
|
|
25
|
+
|
|
26
|
+
expect(container).toMatchSnapshot();
|
|
27
|
+
});
|
|
28
|
+
it('should match with error', function () {
|
|
29
|
+
var _render4 = render( /*#__PURE__*/React.createElement(ThemeProvider, null, /*#__PURE__*/React.createElement(Input, {
|
|
30
|
+
error: "Error message"
|
|
31
|
+
}))),
|
|
32
|
+
container = _render4.container;
|
|
33
|
+
|
|
34
|
+
expect(container).toMatchSnapshot();
|
|
35
|
+
});
|
|
36
|
+
it('should match with helper text and max length', function () {
|
|
37
|
+
var _render5 = render( /*#__PURE__*/React.createElement(ThemeProvider, null, /*#__PURE__*/React.createElement(Input, {
|
|
38
|
+
helper: "Helper text",
|
|
39
|
+
maxLength: 20
|
|
40
|
+
}))),
|
|
41
|
+
container = _render5.container;
|
|
42
|
+
|
|
43
|
+
expect(container).toMatchSnapshot();
|
|
44
|
+
});
|
|
45
|
+
it('should match with helper text, max length and hideMaxLength', function () {
|
|
46
|
+
var _render6 = render( /*#__PURE__*/React.createElement(ThemeProvider, null, /*#__PURE__*/React.createElement(Input, {
|
|
47
|
+
helper: "Helper text",
|
|
48
|
+
maxLength: 20,
|
|
49
|
+
hideMaxLength: true
|
|
50
|
+
}))),
|
|
51
|
+
container = _render6.container;
|
|
52
|
+
|
|
53
|
+
expect(container).toMatchSnapshot();
|
|
54
|
+
});
|
|
55
|
+
it('should match with full width', function () {
|
|
56
|
+
var _render7 = render( /*#__PURE__*/React.createElement(ThemeProvider, null, /*#__PURE__*/React.createElement(Input, {
|
|
57
|
+
label: "Label",
|
|
58
|
+
full: true
|
|
59
|
+
}))),
|
|
60
|
+
container = _render7.container;
|
|
61
|
+
|
|
62
|
+
expect(container).toMatchSnapshot();
|
|
63
|
+
});
|
|
64
|
+
});
|
|
65
|
+
describe('Events', function () {
|
|
66
|
+
it('should call onChange', function () {
|
|
67
|
+
var onChangeMock = jest.fn();
|
|
68
|
+
render( /*#__PURE__*/React.createElement(ThemeProvider, null, /*#__PURE__*/React.createElement(Input, {
|
|
69
|
+
label: "Input",
|
|
70
|
+
onChange: onChangeMock,
|
|
71
|
+
"data-testid": "input"
|
|
72
|
+
})));
|
|
73
|
+
fireEvent.change(screen.getByTestId('input'), {
|
|
74
|
+
target: {
|
|
75
|
+
value: 'foo'
|
|
76
|
+
}
|
|
77
|
+
});
|
|
78
|
+
expect(onChangeMock).toHaveBeenCalled();
|
|
79
|
+
});
|
|
80
|
+
it('should call onFocus', function () {
|
|
81
|
+
var onFocusMock = jest.fn();
|
|
82
|
+
render( /*#__PURE__*/React.createElement(ThemeProvider, null, /*#__PURE__*/React.createElement(Input, {
|
|
83
|
+
label: "Input",
|
|
84
|
+
"data-testid": "input",
|
|
85
|
+
onFocus: onFocusMock
|
|
86
|
+
})));
|
|
87
|
+
fireEvent.focus(screen.getByTestId('input'));
|
|
88
|
+
expect(onFocusMock).toHaveBeenCalled();
|
|
89
|
+
});
|
|
90
|
+
it('should call onBlur', function () {
|
|
91
|
+
var onBlurMock = jest.fn();
|
|
92
|
+
render( /*#__PURE__*/React.createElement(ThemeProvider, null, /*#__PURE__*/React.createElement(Input, {
|
|
93
|
+
label: "Input",
|
|
94
|
+
"data-testid": "input",
|
|
95
|
+
onBlur: onBlurMock
|
|
96
|
+
})));
|
|
97
|
+
fireEvent.focus(screen.getByTestId('input'));
|
|
98
|
+
fireEvent.blur(screen.getByTestId('input'));
|
|
99
|
+
expect(onBlurMock).toHaveBeenCalled();
|
|
100
|
+
});
|
|
101
|
+
});
|
|
102
|
+
describe('maxLength', function () {
|
|
103
|
+
it('should update maxLength counter when add character', function () {
|
|
104
|
+
var _render8 = render( /*#__PURE__*/React.createElement(ThemeProvider, null, /*#__PURE__*/React.createElement(Input, {
|
|
105
|
+
label: "Input",
|
|
106
|
+
maxLength: 10
|
|
107
|
+
}))),
|
|
108
|
+
rerender = _render8.rerender;
|
|
109
|
+
|
|
110
|
+
expect(screen.getByText('0/10').textContent).toBe('0/10');
|
|
111
|
+
rerender( /*#__PURE__*/React.createElement(ThemeProvider, null, /*#__PURE__*/React.createElement(Input, {
|
|
112
|
+
label: "Input",
|
|
113
|
+
value: "foo",
|
|
114
|
+
maxLength: 10
|
|
115
|
+
})));
|
|
116
|
+
expect(screen.getByText('3/10').textContent).toBe('3/10');
|
|
117
|
+
});
|
|
118
|
+
});
|
|
119
|
+
describe('clean button', function () {
|
|
120
|
+
it('should call onClean when press clean button', function () {
|
|
121
|
+
var onClean = jest.fn();
|
|
122
|
+
render( /*#__PURE__*/React.createElement(ThemeProvider, null, /*#__PURE__*/React.createElement(Input, {
|
|
123
|
+
label: "Input",
|
|
124
|
+
value: "foo",
|
|
125
|
+
onClean: onClean
|
|
126
|
+
})));
|
|
127
|
+
fireEvent.click(screen.queryByRole('button'));
|
|
128
|
+
expect(onClean).toHaveBeenCalled();
|
|
129
|
+
});
|
|
130
|
+
it('should test if clean button is present', function () {
|
|
131
|
+
var _render9 = render( /*#__PURE__*/React.createElement(ThemeProvider, null, /*#__PURE__*/React.createElement(Input, {
|
|
132
|
+
label: "Input"
|
|
133
|
+
}))),
|
|
134
|
+
rerender = _render9.rerender; // closeButton
|
|
135
|
+
|
|
136
|
+
|
|
137
|
+
expect(screen.queryByRole('button')).toBeNull();
|
|
138
|
+
rerender( /*#__PURE__*/React.createElement(ThemeProvider, null, /*#__PURE__*/React.createElement(Input, {
|
|
139
|
+
label: "Input",
|
|
140
|
+
value: "foo"
|
|
141
|
+
})));
|
|
142
|
+
expect(screen.queryByRole('button')).not.toBeNull();
|
|
143
|
+
});
|
|
144
|
+
});
|
|
145
|
+
});
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { render } from '@testing-library/react';
|
|
3
|
+
import { ThemeProvider, Input } from '../..';
|
|
4
|
+
describe('<Input.Number />', function () {
|
|
5
|
+
describe('Snapshots', function () {
|
|
6
|
+
it('should match with default input', function () {
|
|
7
|
+
var _render = render( /*#__PURE__*/React.createElement(ThemeProvider, null, /*#__PURE__*/React.createElement(Input.Number, null))),
|
|
8
|
+
container = _render.container;
|
|
9
|
+
|
|
10
|
+
expect(container).toMatchSnapshot();
|
|
11
|
+
});
|
|
12
|
+
});
|
|
13
|
+
});
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { render, fireEvent } from '@testing-library/react';
|
|
3
|
+
import { ThemeProvider, Input } from '../..';
|
|
4
|
+
describe('<Input.Password />', function () {
|
|
5
|
+
describe('Snapshots', function () {
|
|
6
|
+
it('should match with default input', function () {
|
|
7
|
+
var _render = render( /*#__PURE__*/React.createElement(ThemeProvider, null, /*#__PURE__*/React.createElement(Input.Password, null))),
|
|
8
|
+
container = _render.container;
|
|
9
|
+
|
|
10
|
+
expect(container).toMatchSnapshot();
|
|
11
|
+
});
|
|
12
|
+
it('should match with disabled input', function () {
|
|
13
|
+
var _render2 = render( /*#__PURE__*/React.createElement(ThemeProvider, null, /*#__PURE__*/React.createElement(Input.Password, {
|
|
14
|
+
disabled: true
|
|
15
|
+
}))),
|
|
16
|
+
container = _render2.container;
|
|
17
|
+
|
|
18
|
+
expect(container).toMatchSnapshot();
|
|
19
|
+
});
|
|
20
|
+
it('should match with full width', function () {
|
|
21
|
+
var _render3 = render( /*#__PURE__*/React.createElement(ThemeProvider, null, /*#__PURE__*/React.createElement(Input.Password, {
|
|
22
|
+
label: "Label",
|
|
23
|
+
full: true
|
|
24
|
+
}))),
|
|
25
|
+
container = _render3.container;
|
|
26
|
+
|
|
27
|
+
expect(container).toMatchSnapshot();
|
|
28
|
+
});
|
|
29
|
+
});
|
|
30
|
+
describe('Events', function () {
|
|
31
|
+
it('should call onChange', function () {
|
|
32
|
+
var onChangeMock = jest.fn();
|
|
33
|
+
|
|
34
|
+
var _render4 = render( /*#__PURE__*/React.createElement(ThemeProvider, null, /*#__PURE__*/React.createElement(Input.Password, {
|
|
35
|
+
label: "Input",
|
|
36
|
+
"data-testid": "input",
|
|
37
|
+
onChange: onChangeMock
|
|
38
|
+
}))),
|
|
39
|
+
getByTestId = _render4.getByTestId;
|
|
40
|
+
|
|
41
|
+
fireEvent.change(getByTestId('input'), {
|
|
42
|
+
target: {
|
|
43
|
+
value: 'foo'
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
expect(onChangeMock).toHaveBeenCalled();
|
|
47
|
+
});
|
|
48
|
+
it('should call onFocus', function () {
|
|
49
|
+
var onFocusMock = jest.fn();
|
|
50
|
+
|
|
51
|
+
var _render5 = render( /*#__PURE__*/React.createElement(ThemeProvider, null, /*#__PURE__*/React.createElement(Input.Password, {
|
|
52
|
+
label: "Input",
|
|
53
|
+
"data-testid": "input",
|
|
54
|
+
onFocus: onFocusMock
|
|
55
|
+
}))),
|
|
56
|
+
getByTestId = _render5.getByTestId;
|
|
57
|
+
|
|
58
|
+
fireEvent.focus(getByTestId('input'));
|
|
59
|
+
expect(onFocusMock).toHaveBeenCalled();
|
|
60
|
+
});
|
|
61
|
+
it('should call onBlur', function () {
|
|
62
|
+
var onBlurMock = jest.fn();
|
|
63
|
+
|
|
64
|
+
var _render6 = render( /*#__PURE__*/React.createElement(ThemeProvider, null, /*#__PURE__*/React.createElement(Input.Password, {
|
|
65
|
+
label: "Input",
|
|
66
|
+
"data-testid": "input",
|
|
67
|
+
onBlur: onBlurMock
|
|
68
|
+
}))),
|
|
69
|
+
getByTestId = _render6.getByTestId;
|
|
70
|
+
|
|
71
|
+
fireEvent.focus(getByTestId('input'));
|
|
72
|
+
fireEvent.blur(getByTestId('input'));
|
|
73
|
+
expect(onBlurMock).toHaveBeenCalled();
|
|
74
|
+
});
|
|
75
|
+
});
|
|
76
|
+
describe('visibility button', function () {
|
|
77
|
+
it('should toggle password visibility when click visibility button', function () {
|
|
78
|
+
var _render7 = render( /*#__PURE__*/React.createElement(ThemeProvider, null, /*#__PURE__*/React.createElement(Input.Password, {
|
|
79
|
+
label: "Input",
|
|
80
|
+
"data-testid": "input"
|
|
81
|
+
}))),
|
|
82
|
+
getByRole = _render7.getByRole,
|
|
83
|
+
getByTestId = _render7.getByTestId;
|
|
84
|
+
|
|
85
|
+
expect(getByTestId('input').type).toBe('password');
|
|
86
|
+
fireEvent.click(getByRole('button'));
|
|
87
|
+
expect(getByTestId('input').type).toBe('text');
|
|
88
|
+
});
|
|
89
|
+
});
|
|
90
|
+
});
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return exports; }; var exports = {}, Op = Object.prototype, hasOwn = Op.hasOwnProperty, $Symbol = "function" == typeof Symbol ? Symbol : {}, iteratorSymbol = $Symbol.iterator || "@@iterator", asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator", toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag"; function define(obj, key, value) { return Object.defineProperty(obj, key, { value: value, enumerable: !0, configurable: !0, writable: !0 }), obj[key]; } try { define({}, ""); } catch (err) { define = function define(obj, key, value) { return obj[key] = value; }; } function wrap(innerFn, outerFn, self, tryLocsList) { var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator, generator = Object.create(protoGenerator.prototype), context = new Context(tryLocsList || []); return generator._invoke = function (innerFn, self, context) { var state = "suspendedStart"; return function (method, arg) { if ("executing" === state) throw new Error("Generator is already running"); if ("completed" === state) { if ("throw" === method) throw arg; return doneResult(); } for (context.method = method, context.arg = arg;;) { var delegate = context.delegate; if (delegate) { var delegateResult = maybeInvokeDelegate(delegate, context); if (delegateResult) { if (delegateResult === ContinueSentinel) continue; return delegateResult; } } if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) { if ("suspendedStart" === state) throw state = "completed", context.arg; context.dispatchException(context.arg); } else "return" === context.method && context.abrupt("return", context.arg); state = "executing"; var record = tryCatch(innerFn, self, context); if ("normal" === record.type) { if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue; return { value: record.arg, done: context.done }; } "throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg); } }; }(innerFn, self, context), generator; } function tryCatch(fn, obj, arg) { try { return { type: "normal", arg: fn.call(obj, arg) }; } catch (err) { return { type: "throw", arg: err }; } } exports.wrap = wrap; var ContinueSentinel = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var IteratorPrototype = {}; define(IteratorPrototype, iteratorSymbol, function () { return this; }); var getProto = Object.getPrototypeOf, NativeIteratorPrototype = getProto && getProto(getProto(values([]))); NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype); var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype); function defineIteratorMethods(prototype) { ["next", "throw", "return"].forEach(function (method) { define(prototype, method, function (arg) { return this._invoke(method, arg); }); }); } function AsyncIterator(generator, PromiseImpl) { function invoke(method, arg, resolve, reject) { var record = tryCatch(generator[method], generator, arg); if ("throw" !== record.type) { var result = record.arg, value = result.value; return value && "object" == typeof value && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) { invoke("next", value, resolve, reject); }, function (err) { invoke("throw", err, resolve, reject); }) : PromiseImpl.resolve(value).then(function (unwrapped) { result.value = unwrapped, resolve(result); }, function (error) { return invoke("throw", error, resolve, reject); }); } reject(record.arg); } var previousPromise; this._invoke = function (method, arg) { function callInvokeWithMethodAndArg() { return new PromiseImpl(function (resolve, reject) { invoke(method, arg, resolve, reject); }); } return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); }; } function maybeInvokeDelegate(delegate, context) { var method = delegate.iterator[context.method]; if (undefined === method) { if (context.delegate = null, "throw" === context.method) { if (delegate.iterator["return"] && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method)) return ContinueSentinel; context.method = "throw", context.arg = new TypeError("The iterator does not provide a 'throw' method"); } return ContinueSentinel; } var record = tryCatch(method, delegate.iterator, context.arg); if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel; var info = record.arg; return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, "return" !== context.method && (context.method = "next", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"), context.delegate = null, ContinueSentinel); } function pushTryEntry(locs) { var entry = { tryLoc: locs[0] }; 1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry); } function resetTryEntry(entry) { var record = entry.completion || {}; record.type = "normal", delete record.arg, entry.completion = record; } function Context(tryLocsList) { this.tryEntries = [{ tryLoc: "root" }], tryLocsList.forEach(pushTryEntry, this), this.reset(!0); } function values(iterable) { if (iterable) { var iteratorMethod = iterable[iteratorSymbol]; if (iteratorMethod) return iteratorMethod.call(iterable); if ("function" == typeof iterable.next) return iterable; if (!isNaN(iterable.length)) { var i = -1, next = function next() { for (; ++i < iterable.length;) { if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next; } return next.value = undefined, next.done = !0, next; }; return next.next = next; } } return { next: doneResult }; } function doneResult() { return { value: undefined, done: !0 }; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, define(Gp, "constructor", GeneratorFunctionPrototype), define(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) { var ctor = "function" == typeof genFun && genFun.constructor; return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name)); }, exports.mark = function (genFun) { return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun; }, exports.awrap = function (arg) { return { __await: arg }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () { return this; }), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) { void 0 === PromiseImpl && (PromiseImpl = Promise); var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl); return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) { return result.done ? result.value : iter.next(); }); }, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () { return this; }), define(Gp, "toString", function () { return "[object Generator]"; }), exports.keys = function (object) { var keys = []; for (var key in object) { keys.push(key); } return keys.reverse(), function next() { for (; keys.length;) { var key = keys.pop(); if (key in object) return next.value = key, next.done = !1, next; } return next.done = !0, next; }; }, exports.values = values, Context.prototype = { constructor: Context, reset: function reset(skipTempReset) { if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, this.tryEntries.forEach(resetTryEntry), !skipTempReset) for (var name in this) { "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined); } }, stop: function stop() { this.done = !0; var rootRecord = this.tryEntries[0].completion; if ("throw" === rootRecord.type) throw rootRecord.arg; return this.rval; }, dispatchException: function dispatchException(exception) { if (this.done) throw exception; var context = this; function handle(loc, caught) { return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught; } for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i], record = entry.completion; if ("root" === entry.tryLoc) return handle("end"); if (entry.tryLoc <= this.prev) { var hasCatch = hasOwn.call(entry, "catchLoc"), hasFinally = hasOwn.call(entry, "finallyLoc"); if (hasCatch && hasFinally) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } else if (hasCatch) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); } else { if (!hasFinally) throw new Error("try statement without catch or finally"); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } } } }, abrupt: function abrupt(type, arg) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) { var finallyEntry = entry; break; } } finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null); var record = finallyEntry ? finallyEntry.completion : {}; return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record); }, complete: function complete(record, afterLoc) { if ("throw" === record.type) throw record.arg; return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel; }, finish: function finish(finallyLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel; } }, "catch": function _catch(tryLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc === tryLoc) { var record = entry.completion; if ("throw" === record.type) { var thrown = record.arg; resetTryEntry(entry); } return thrown; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(iterable, resultName, nextLoc) { return this.delegate = { iterator: values(iterable), resultName: resultName, nextLoc: nextLoc }, "next" === this.method && (this.arg = undefined), ContinueSentinel; } }, exports; }
|
|
2
|
+
|
|
3
|
+
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
|
4
|
+
|
|
5
|
+
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
|
6
|
+
|
|
7
|
+
import React from 'react';
|
|
8
|
+
import { render, fireEvent, waitFor } from '@testing-library/react';
|
|
9
|
+
import { ThemeProvider, Input } from '../..';
|
|
10
|
+
var numbersFormats = [{
|
|
11
|
+
country: 'BR',
|
|
12
|
+
base: '+5511959112508',
|
|
13
|
+
expected: '+55 (11) 959112508'
|
|
14
|
+
}, {
|
|
15
|
+
country: 'US',
|
|
16
|
+
base: '+12025550134',
|
|
17
|
+
expected: '+1 (202) 555-0134'
|
|
18
|
+
}, {
|
|
19
|
+
country: 'PT',
|
|
20
|
+
base: '+351911803423',
|
|
21
|
+
expected: '+351 911 803 423'
|
|
22
|
+
}];
|
|
23
|
+
describe('<Input.Phone />', function () {
|
|
24
|
+
describe('Snapshots', function () {
|
|
25
|
+
it('should match with default input', function () {
|
|
26
|
+
var _render = render( /*#__PURE__*/React.createElement(ThemeProvider, null, /*#__PURE__*/React.createElement(Input.Phone, null))),
|
|
27
|
+
container = _render.container;
|
|
28
|
+
|
|
29
|
+
expect(container).toMatchSnapshot();
|
|
30
|
+
});
|
|
31
|
+
it('should match with disabled input', function () {
|
|
32
|
+
var _render2 = render( /*#__PURE__*/React.createElement(ThemeProvider, null, /*#__PURE__*/React.createElement(Input.Password, {
|
|
33
|
+
disabled: true
|
|
34
|
+
}))),
|
|
35
|
+
container = _render2.container;
|
|
36
|
+
|
|
37
|
+
expect(container).toMatchSnapshot();
|
|
38
|
+
});
|
|
39
|
+
it('should match with error', function () {
|
|
40
|
+
var _render3 = render( /*#__PURE__*/React.createElement(ThemeProvider, null, /*#__PURE__*/React.createElement(Input, {
|
|
41
|
+
error: "Error message"
|
|
42
|
+
}))),
|
|
43
|
+
container = _render3.container;
|
|
44
|
+
|
|
45
|
+
expect(container).toMatchSnapshot();
|
|
46
|
+
});
|
|
47
|
+
it('should match with full width', function () {
|
|
48
|
+
var _render4 = render( /*#__PURE__*/React.createElement(ThemeProvider, null, /*#__PURE__*/React.createElement(Input.Password, {
|
|
49
|
+
label: "Label",
|
|
50
|
+
full: true
|
|
51
|
+
}))),
|
|
52
|
+
container = _render4.container;
|
|
53
|
+
|
|
54
|
+
expect(container).toMatchSnapshot();
|
|
55
|
+
});
|
|
56
|
+
});
|
|
57
|
+
describe('Behaviour', function () {
|
|
58
|
+
numbersFormats.forEach(function (spec) {
|
|
59
|
+
it("Should render number in " + spec.country + " format according to phone value", function () {
|
|
60
|
+
var _render5 = render( /*#__PURE__*/React.createElement(ThemeProvider, null, /*#__PURE__*/React.createElement(Input.Phone, {
|
|
61
|
+
value: spec.base
|
|
62
|
+
}))),
|
|
63
|
+
getByDisplayValue = _render5.getByDisplayValue;
|
|
64
|
+
|
|
65
|
+
expect(getByDisplayValue(spec.expected)).toBeInTheDocument();
|
|
66
|
+
});
|
|
67
|
+
});
|
|
68
|
+
it('should prefix the phone number with newly selected country dial code', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
69
|
+
var _render6, getByRole, getByText, getByDisplayValue;
|
|
70
|
+
|
|
71
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
72
|
+
while (1) {
|
|
73
|
+
switch (_context.prev = _context.next) {
|
|
74
|
+
case 0:
|
|
75
|
+
_render6 = render( /*#__PURE__*/React.createElement(ThemeProvider, null, /*#__PURE__*/React.createElement(Input.Phone, {
|
|
76
|
+
defaultCountry: "us"
|
|
77
|
+
}))), getByRole = _render6.getByRole, getByText = _render6.getByText, getByDisplayValue = _render6.getByDisplayValue;
|
|
78
|
+
_context.next = 3;
|
|
79
|
+
return waitFor(function () {
|
|
80
|
+
fireEvent.click(getByRole('button'));
|
|
81
|
+
fireEvent.click(getByText('Portugal'));
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
case 3:
|
|
85
|
+
expect(getByDisplayValue('+351')).toBeInTheDocument();
|
|
86
|
+
|
|
87
|
+
case 4:
|
|
88
|
+
case "end":
|
|
89
|
+
return _context.stop();
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
}, _callee);
|
|
93
|
+
})));
|
|
94
|
+
});
|
|
95
|
+
});
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { render } from '@testing-library/react';
|
|
3
|
+
import { ThemeProvider, Input } from '../..';
|
|
4
|
+
describe('<Input.Tel />', function () {
|
|
5
|
+
describe('Snapshots', function () {
|
|
6
|
+
it('should match with default input', function () {
|
|
7
|
+
var _render = render( /*#__PURE__*/React.createElement(ThemeProvider, null, /*#__PURE__*/React.createElement(Input.Tel, null))),
|
|
8
|
+
container = _render.container;
|
|
9
|
+
|
|
10
|
+
expect(container).toMatchSnapshot();
|
|
11
|
+
});
|
|
12
|
+
});
|
|
13
|
+
});
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
var _templateObject;
|
|
2
|
+
|
|
3
|
+
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
4
|
+
|
|
5
|
+
function _taggedTemplateLiteralLoose(strings, raw) { if (!raw) { raw = strings.slice(0); } strings.raw = raw; return strings; }
|
|
6
|
+
|
|
7
|
+
import React from 'react';
|
|
8
|
+
import styled from 'styled-components';
|
|
9
|
+
var StyledFlatList = styled.FlatList(_templateObject || (_templateObject = _taggedTemplateLiteralLoose(["\n width: 100%;\n"])));
|
|
10
|
+
/** Lists are a continuous group of text or images. They are composed of items
|
|
11
|
+
containing primary and supplemental actions, which are represented by icons and
|
|
12
|
+
text. */
|
|
13
|
+
|
|
14
|
+
var List = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
|
15
|
+
var rest = _extends({}, _ref);
|
|
16
|
+
|
|
17
|
+
return /*#__PURE__*/React.createElement(StyledFlatList, _extends({
|
|
18
|
+
ref: ref
|
|
19
|
+
}, rest));
|
|
20
|
+
});
|
|
21
|
+
List.displayName = 'List';
|
|
22
|
+
export default List;
|