@gympass/yoga 7.59.0 → 7.60.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/Card/web/PlanCard/Content.js +11 -6
- package/cjs/Drawer/web/Content.js +1 -4
- package/esm/Card/web/PlanCard/Content.js +11 -6
- package/esm/Drawer/web/Content.js +1 -4
- package/package.json +5 -5
- package/cjs/ActionRequirement/native/ActionRequirement.test.js +0 -1
- package/cjs/ActionRequirement/web/ActionRequirement.test.js +0 -40
- package/cjs/AutoComplete/web/AutoComplete.test.js +0 -156
- package/cjs/Avatar/native/Avatar.test.js +0 -1
- package/cjs/Avatar/web/Avatar.test.js +0 -72
- package/cjs/Banner/native/Banner.test.js +0 -1
- package/cjs/Banner/web/Banner.test.js +0 -121
- package/cjs/BottomSheet/web/BottomSheet.test.js +0 -61
- package/cjs/Box/native/Box.test.js +0 -1
- package/cjs/Box/web/Box.test.js +0 -23
- package/cjs/Button/native/Button.test.js +0 -1
- package/cjs/Button/web/Button.test.js +0 -778
- package/cjs/Card/native/Card/Card.test.js +0 -1
- package/cjs/Card/native/EventCard/EventCard.test.js +0 -1
- package/cjs/Card/native/GymCard/CheckIn/CheckIn.test.js +0 -1
- package/cjs/Card/native/PlanCard/PlanCard.test.js +0 -1
- package/cjs/Card/web/Card/Card.test.js +0 -22
- package/cjs/Card/web/EventCard/EventCard.test.js +0 -35
- package/cjs/Card/web/PlanCard/PlanCard.test.js +0 -95
- package/cjs/Checkbox/native/Checkbox.test.js +0 -1
- package/cjs/Checkbox/native/Switch.test.js +0 -1
- package/cjs/Checkbox/web/Checkbox.test.js +0 -161
- package/cjs/Checkbox/web/Switch.test.js +0 -65
- package/cjs/Chips/native/Chips.test.js +0 -1
- package/cjs/Chips/web/Chips.test.js +0 -138
- package/cjs/Datepicker/web/Datepicker.test.js +0 -286
- package/cjs/Dialog/web/Dialog.test.js +0 -78
- package/cjs/Divider/native/Divider.test.js +0 -1
- package/cjs/Divider/web/Divider.test.js +0 -36
- package/cjs/Drawer/web/Drawer.test.js +0 -46
- package/cjs/Dropdown/native/Backdrop.test.js +0 -1
- package/cjs/Dropdown/native/Dropdown.test.js +0 -1
- package/cjs/Dropdown/web/Dropdown.test.js +0 -102
- package/cjs/Feedback/web/Feedback.test.js +0 -89
- package/cjs/Grid/web/Col.test.js +0 -56
- package/cjs/Grid/web/Container.test.js +0 -22
- package/cjs/Grid/web/Hide.test.js +0 -39
- package/cjs/Grid/web/Row.test.js +0 -22
- package/cjs/Header/web/Header.test.js +0 -49
- package/cjs/Heading/web/Heading.test.js +0 -68
- package/cjs/Icon/native/Icon.test.js +0 -1
- package/cjs/Icon/web/Icon.test.js +0 -53
- package/cjs/Input/native/Email.test.js +0 -1
- package/cjs/Input/native/Input.test.js +0 -1
- package/cjs/Input/native/Number.test.js +0 -1
- package/cjs/Input/native/Password.test.js +0 -1
- package/cjs/Input/native/Tel.test.js +0 -1
- package/cjs/Input/web/Email.test.js +0 -20
- package/cjs/Input/web/Input.test.js +0 -161
- package/cjs/Input/web/Number.test.js +0 -20
- package/cjs/Input/web/Password.test.js +0 -103
- package/cjs/Input/web/Tel.test.js +0 -20
- package/cjs/List/native/List.test.js +0 -1
- package/cjs/List/web/List.test.js +0 -69
- package/cjs/Menu/web/Menu.test.js +0 -123
- package/cjs/Popover/web/Popover.test.js +0 -27
- package/cjs/Progress/native/Progress.test.js +0 -1
- package/cjs/Progress/web/Progress.test.js +0 -229
- package/cjs/RadioGroup/native/Button/RadioButton.test.js +0 -1
- package/cjs/RadioGroup/native/Radio/Radio.test.js +0 -1
- package/cjs/RadioGroup/native/RadioGroup.test.js +0 -1
- package/cjs/RadioGroup/web/Button/RadioButton.test.js +0 -132
- package/cjs/RadioGroup/web/Radio/Radio.test.js +0 -119
- package/cjs/RadioGroup/web/RadioGroup.test.js +0 -93
- package/cjs/Rating/native/Rating.test.js +0 -1
- package/cjs/Rating/web/Rating.test.js +0 -201
- package/cjs/Result/native/Result.test.js +0 -1
- package/cjs/Skeleton/native/Skeleton.test.js +0 -1
- package/cjs/Skeleton/web/Skeleton.test.js +0 -84
- package/cjs/Slider/native/Slider.test.js +0 -1
- package/cjs/Slider/web/Slider.test.js +0 -95
- package/cjs/Snackbar/native/Snackbar.test.js +0 -1
- package/cjs/Snackbar/web/Snackbar.test.js +0 -137
- package/cjs/Stepper/native/Stepper.test.js +0 -1
- package/cjs/Stepper/web/Stepper.test.js +0 -75
- package/cjs/Tag/native/Tag.test.js +0 -1
- package/cjs/Tag/web/Tag.test.js +0 -87
- package/cjs/Text/native/Text.test.js +0 -1
- package/cjs/Text/web/Text.test.js +0 -157
- package/cjs/TextArea/native/TextArea.test.js +0 -1
- package/cjs/TextArea/web/TextArea.test.js +0 -18
- package/cjs/Theme/Provider/web/FontLoader.test.js +0 -19
- package/cjs/Theme/Provider/web/GlobalStyle.test.js +0 -27
- package/cjs/Theme/helpers/themeReader/native/native.test.js +0 -1
- package/cjs/Theme/helpers/themeReader/web/web.test.js +0 -54
- package/esm/ActionRequirement/index.native.js +0 -2
- package/esm/ActionRequirement/native/ActionRequirement.js +0 -48
- package/esm/ActionRequirement/native/ActionRequirement.test.js +0 -45
- package/esm/ActionRequirement/native/ActionRequirementStyles.js +0 -25
- package/esm/ActionRequirement/native/index.js +0 -6
- package/esm/ActionRequirement/web/ActionRequirement.test.js +0 -31
- package/esm/AutoComplete/web/AutoComplete.test.js +0 -139
- package/esm/Avatar/index.native.js +0 -4
- package/esm/Avatar/native/Avatar.js +0 -96
- package/esm/Avatar/native/Avatar.test.js +0 -46
- package/esm/Avatar/native/AvatarCircle.js +0 -24
- package/esm/Avatar/web/Avatar.test.js +0 -63
- package/esm/Banner/index.native.js +0 -2
- package/esm/Banner/native/Banner.js +0 -128
- package/esm/Banner/native/Banner.test.js +0 -103
- package/esm/Banner/native/index.js +0 -2
- package/esm/Banner/web/Banner.test.js +0 -109
- package/esm/BottomSheet/web/BottomSheet.test.js +0 -48
- package/esm/Box/index.native.js +0 -2
- package/esm/Box/native/Box.js +0 -4
- package/esm/Box/native/Box.test.js +0 -16
- package/esm/Box/native/index.js +0 -2
- package/esm/Box/web/Box.test.js +0 -16
- package/esm/Button/index.native.js +0 -8
- package/esm/Button/native/Button.js +0 -110
- package/esm/Button/native/Button.test.js +0 -475
- package/esm/Button/native/Icon.js +0 -82
- package/esm/Button/native/Link.js +0 -35
- package/esm/Button/native/Text.js +0 -74
- package/esm/Button/native/withTouchable.js +0 -63
- package/esm/Button/web/Button.test.js +0 -764
- package/esm/Card/index.native.js +0 -2
- package/esm/Card/native/Card/Actions.js +0 -12
- package/esm/Card/native/Card/Card.js +0 -92
- package/esm/Card/native/Card/Card.test.js +0 -15
- package/esm/Card/native/Card/Content.js +0 -8
- package/esm/Card/native/Card/Header.js +0 -8
- package/esm/Card/native/Card/index.js +0 -8
- package/esm/Card/native/EventCard/EventCard.js +0 -169
- package/esm/Card/native/EventCard/EventCard.test.js +0 -65
- package/esm/Card/native/EventCard/index.js +0 -2
- package/esm/Card/native/GymCard/CheckIn/Avatar.js +0 -17
- package/esm/Card/native/GymCard/CheckIn/CheckIn.js +0 -66
- package/esm/Card/native/GymCard/CheckIn/CheckIn.test.js +0 -39
- package/esm/Card/native/GymCard/CheckIn/Content.js +0 -11
- package/esm/Card/native/GymCard/CheckIn/Header.js +0 -11
- package/esm/Card/native/GymCard/CheckIn/index.js +0 -2
- package/esm/Card/native/GymCard/index.js +0 -5
- package/esm/Card/native/PlanCard/Actions.js +0 -22
- package/esm/Card/native/PlanCard/Content.js +0 -75
- package/esm/Card/native/PlanCard/List.js +0 -73
- package/esm/Card/native/PlanCard/PlanCard.js +0 -51
- package/esm/Card/native/PlanCard/PlanCard.test.js +0 -84
- package/esm/Card/native/PlanCard/Subtitle.js +0 -15
- package/esm/Card/native/PlanCard/Tag.js +0 -34
- package/esm/Card/native/PlanCard/index.js +0 -15
- package/esm/Card/native/index.js +0 -5
- package/esm/Card/web/Card/Card.test.js +0 -14
- package/esm/Card/web/EventCard/EventCard.test.js +0 -27
- package/esm/Card/web/PlanCard/PlanCard.test.js +0 -85
- package/esm/Checkbox/index.native.js +0 -3
- package/esm/Checkbox/native/Checkbox.js +0 -179
- package/esm/Checkbox/native/Checkbox.test.js +0 -115
- package/esm/Checkbox/native/Switch.js +0 -115
- package/esm/Checkbox/native/Switch.test.js +0 -54
- package/esm/Checkbox/native/index.js +0 -3
- package/esm/Checkbox/web/Checkbox.test.js +0 -153
- package/esm/Checkbox/web/Switch.test.js +0 -56
- package/esm/Chips/index.native.js +0 -2
- package/esm/Chips/native/Chips.js +0 -104
- package/esm/Chips/native/Chips.test.js +0 -143
- package/esm/Chips/native/Counter.js +0 -20
- package/esm/Chips/native/index.js +0 -2
- package/esm/Chips/web/Chips.test.js +0 -128
- package/esm/Datepicker/web/Datepicker.test.js +0 -247
- package/esm/Dialog/web/Dialog.test.js +0 -62
- package/esm/Divider/index.native.js +0 -2
- package/esm/Divider/native/Divider.js +0 -29
- package/esm/Divider/native/Divider.test.js +0 -29
- package/esm/Divider/native/index.js +0 -2
- package/esm/Divider/web/Divider.test.js +0 -29
- package/esm/Drawer/web/Drawer.test.js +0 -33
- package/esm/Dropdown/index.native.js +0 -2
- package/esm/Dropdown/native/Backdrop.js +0 -93
- package/esm/Dropdown/native/Backdrop.test.js +0 -26
- package/esm/Dropdown/native/Dropdown.js +0 -142
- package/esm/Dropdown/native/Dropdown.test.js +0 -78
- package/esm/Dropdown/native/Options.android.js +0 -66
- package/esm/Dropdown/native/Options.ios.js +0 -71
- package/esm/Dropdown/native/index.js +0 -2
- package/esm/Dropdown/web/Dropdown.test.js +0 -93
- package/esm/Feedback/web/Feedback.test.js +0 -83
- package/esm/Grid/web/Col.test.js +0 -48
- package/esm/Grid/web/Container.test.js +0 -14
- package/esm/Grid/web/Hide.test.js +0 -31
- package/esm/Grid/web/Row.test.js +0 -14
- package/esm/Header/web/Header.test.js +0 -38
- package/esm/Heading/web/Heading.test.js +0 -58
- package/esm/Icon/index.native.js +0 -2
- package/esm/Icon/native/Icon.test.js +0 -47
- package/esm/Icon/native/index.js +0 -2
- package/esm/Icon/web/Icon.test.js +0 -47
- package/esm/Input/index.native.js +0 -6
- package/esm/Input/native/Email.js +0 -15
- package/esm/Input/native/Email.test.js +0 -13
- package/esm/Input/native/Helper.js +0 -62
- package/esm/Input/native/Input.js +0 -234
- package/esm/Input/native/Input.test.js +0 -181
- package/esm/Input/native/Number.js +0 -12
- package/esm/Input/native/Number.test.js +0 -13
- package/esm/Input/native/Password.js +0 -112
- package/esm/Input/native/Password.test.js +0 -125
- package/esm/Input/native/Tel.js +0 -14
- package/esm/Input/native/Tel.test.js +0 -13
- package/esm/Input/native/index.js +0 -6
- package/esm/Input/web/Email.test.js +0 -13
- package/esm/Input/web/Input.test.js +0 -145
- package/esm/Input/web/Number.test.js +0 -13
- package/esm/Input/web/Password.test.js +0 -90
- package/esm/Input/web/Tel.test.js +0 -13
- package/esm/List/index.native.js +0 -3
- package/esm/List/native/List.js +0 -22
- package/esm/List/native/List.test.js +0 -106
- package/esm/List/native/ListItem.js +0 -51
- package/esm/List/native/index.js +0 -3
- package/esm/List/web/List.test.js +0 -62
- package/esm/Menu/web/Menu.test.js +0 -115
- package/esm/Popover/web/Popover.test.js +0 -19
- package/esm/Progress/index.native.js +0 -2
- package/esm/Progress/native/Progress.js +0 -103
- package/esm/Progress/native/Progress.test.js +0 -222
- package/esm/Progress/native/index.js +0 -2
- package/esm/Progress/web/Progress.test.js +0 -222
- package/esm/RadioGroup/index.native.js +0 -4
- package/esm/RadioGroup/native/Button/RadioButton.js +0 -64
- package/esm/RadioGroup/native/Button/RadioButton.test.js +0 -96
- package/esm/RadioGroup/native/Radio/Radio.js +0 -88
- package/esm/RadioGroup/native/Radio/Radio.test.js +0 -112
- package/esm/RadioGroup/native/RadioGroup.js +0 -66
- package/esm/RadioGroup/native/RadioGroup.test.js +0 -50
- package/esm/RadioGroup/native/index.js +0 -4
- package/esm/RadioGroup/web/Button/RadioButton.test.js +0 -121
- package/esm/RadioGroup/web/Radio/Radio.test.js +0 -108
- package/esm/RadioGroup/web/RadioGroup.test.js +0 -83
- package/esm/Rating/index.native.js +0 -2
- package/esm/Rating/native/Rating.js +0 -186
- package/esm/Rating/native/Rating.test.js +0 -121
- package/esm/Rating/native/index.js +0 -2
- package/esm/Rating/web/Rating.test.js +0 -184
- package/esm/Result/index.native.js +0 -8
- package/esm/Result/native/Attendances.js +0 -55
- package/esm/Result/native/Details.js +0 -97
- package/esm/Result/native/Rate.js +0 -35
- package/esm/Result/native/Result.js +0 -86
- package/esm/Result/native/Result.test.js +0 -107
- package/esm/Result/native/ResultButton.js +0 -13
- package/esm/Result/native/Tags.js +0 -41
- package/esm/Result/native/TinyTextIcon.js +0 -18
- package/esm/Result/native/index.js +0 -2
- package/esm/Skeleton/index.native.js +0 -2
- package/esm/Skeleton/native/Skeleton.js +0 -94
- package/esm/Skeleton/native/Skeleton.test.js +0 -78
- package/esm/Skeleton/native/index.js +0 -2
- package/esm/Skeleton/web/Skeleton.test.js +0 -77
- package/esm/Slider/index.native.js +0 -2
- package/esm/Slider/native/Label.js +0 -19
- package/esm/Slider/native/Marker.js +0 -68
- package/esm/Slider/native/Slider.js +0 -156
- package/esm/Slider/native/Slider.test.js +0 -122
- package/esm/Slider/native/Step.js +0 -14
- package/esm/Slider/native/Tooltip.js +0 -90
- package/esm/Slider/web/Slider.test.js +0 -86
- package/esm/Snackbar/index.native.js +0 -2
- package/esm/Snackbar/native/Snackbar.js +0 -199
- package/esm/Snackbar/native/Snackbar.test.js +0 -100
- package/esm/Snackbar/native/SnackbarAnimationWrapper.js +0 -124
- package/esm/Snackbar/native/index.js +0 -2
- package/esm/Snackbar/web/Snackbar.test.js +0 -118
- package/esm/Stepper/index.native.js +0 -3
- package/esm/Stepper/native/Dots.js +0 -45
- package/esm/Stepper/native/Line.js +0 -35
- package/esm/Stepper/native/Step.js +0 -19
- package/esm/Stepper/native/Stepper.js +0 -52
- package/esm/Stepper/native/Stepper.test.js +0 -70
- package/esm/Stepper/native/index.js +0 -3
- package/esm/Stepper/web/Stepper.test.js +0 -67
- package/esm/Tag/index.native.js +0 -4
- package/esm/Tag/native/Informative.js +0 -72
- package/esm/Tag/native/Tag.js +0 -75
- package/esm/Tag/native/Tag.test.js +0 -94
- package/esm/Tag/native/index.js +0 -2
- package/esm/Tag/web/Tag.test.js +0 -79
- package/esm/Text/index.native.js +0 -16
- package/esm/Text/native/Text.js +0 -69
- package/esm/Text/native/Text.test.js +0 -149
- package/esm/Text/native/index.js +0 -2
- package/esm/Text/web/Text.test.js +0 -149
- package/esm/TextArea/index.native.js +0 -2
- package/esm/TextArea/native/TextArea.js +0 -59
- package/esm/TextArea/native/TextArea.test.js +0 -11
- package/esm/TextArea/native/index.js +0 -2
- package/esm/TextArea/web/TextArea.test.js +0 -11
- package/esm/Theme/Provider/index.native.js +0 -2
- package/esm/Theme/Provider/native/index.js +0 -2
- package/esm/Theme/Provider/web/FontLoader.test.js +0 -11
- package/esm/Theme/Provider/web/GlobalStyle.test.js +0 -17
- package/esm/Theme/helpers/themeReader/native/native.test.js +0 -53
- package/esm/Theme/helpers/themeReader/web/web.test.js +0 -41
- package/esm/Theme/index.native.js +0 -5
- package/esm/index.native.js +0 -26
- package/esm/shared/index.native.js +0 -2
|
@@ -1,108 +0,0 @@
|
|
|
1
|
-
/* eslint-disable no-console */
|
|
2
|
-
import React from 'react';
|
|
3
|
-
import { render, fireEvent } from '@testing-library/react';
|
|
4
|
-
import RadioGroup from '../..';
|
|
5
|
-
import ThemeProvider from '../../../Theme';
|
|
6
|
-
import RadioGroupContext from '../../RadioGroupContext';
|
|
7
|
-
var originalError = console.error;
|
|
8
|
-
beforeEach(function () {
|
|
9
|
-
console.error = jest.fn();
|
|
10
|
-
});
|
|
11
|
-
afterEach(function () {
|
|
12
|
-
console.error = originalError;
|
|
13
|
-
});
|
|
14
|
-
describe('<RadioGroup />', function () {
|
|
15
|
-
describe('<RadioGroup.Radio />', function () {
|
|
16
|
-
describe('Snapshots', function () {
|
|
17
|
-
it('should match snapshot with default radio', function () {
|
|
18
|
-
var _render = render( /*#__PURE__*/React.createElement(ThemeProvider, null, /*#__PURE__*/React.createElement(RadioGroup.Radio, null))),
|
|
19
|
-
container = _render.container;
|
|
20
|
-
|
|
21
|
-
expect(container).toMatchSnapshot();
|
|
22
|
-
});
|
|
23
|
-
});
|
|
24
|
-
describe('Props', function () {
|
|
25
|
-
it('should contains input type radio', function () {
|
|
26
|
-
var _render2 = render( /*#__PURE__*/React.createElement(ThemeProvider, null, /*#__PURE__*/React.createElement(RadioGroup.Radio, {
|
|
27
|
-
"data-testid": "radio"
|
|
28
|
-
}))),
|
|
29
|
-
getByTestId = _render2.getByTestId;
|
|
30
|
-
|
|
31
|
-
expect(getByTestId('radio').type).toBe('radio');
|
|
32
|
-
});
|
|
33
|
-
it('value should be as prop value', function () {
|
|
34
|
-
var _render3 = render( /*#__PURE__*/React.createElement(ThemeProvider, null, /*#__PURE__*/React.createElement(RadioGroup.Radio, {
|
|
35
|
-
"data-testid": "radio",
|
|
36
|
-
value: "radio1"
|
|
37
|
-
}))),
|
|
38
|
-
getByTestId = _render3.getByTestId;
|
|
39
|
-
|
|
40
|
-
expect(getByTestId('radio').value).toBe('radio1');
|
|
41
|
-
});
|
|
42
|
-
it('checked should be the selectedValue provided from Context', function () {
|
|
43
|
-
var _render4 = render( /*#__PURE__*/React.createElement(RadioGroupContext.Provider, {
|
|
44
|
-
value: {
|
|
45
|
-
selectedValue: 'Radio 2'
|
|
46
|
-
}
|
|
47
|
-
}, /*#__PURE__*/React.createElement(ThemeProvider, null, /*#__PURE__*/React.createElement(RadioGroup.Radio, {
|
|
48
|
-
"data-testid": "radio",
|
|
49
|
-
value: "Radio 1"
|
|
50
|
-
}), /*#__PURE__*/React.createElement(RadioGroup.Radio, {
|
|
51
|
-
"data-testid": "radio",
|
|
52
|
-
value: "Radio 2"
|
|
53
|
-
})))),
|
|
54
|
-
getAllByTestId = _render4.getAllByTestId;
|
|
55
|
-
|
|
56
|
-
var _getAllByTestId = getAllByTestId('radio'),
|
|
57
|
-
radio = _getAllByTestId[0],
|
|
58
|
-
radio2 = _getAllByTestId[1];
|
|
59
|
-
|
|
60
|
-
expect(radio.checked).toBe(false);
|
|
61
|
-
expect(radio2.checked).toBe(true);
|
|
62
|
-
});
|
|
63
|
-
it('name should be the one provided by context', function () {
|
|
64
|
-
var name = 'test';
|
|
65
|
-
|
|
66
|
-
var _render5 = render( /*#__PURE__*/React.createElement(RadioGroupContext.Provider, {
|
|
67
|
-
value: {
|
|
68
|
-
name: name
|
|
69
|
-
}
|
|
70
|
-
}, /*#__PURE__*/React.createElement(ThemeProvider, null, /*#__PURE__*/React.createElement(RadioGroup.Radio, {
|
|
71
|
-
"data-testid": "radio",
|
|
72
|
-
value: "Radio 1"
|
|
73
|
-
}), /*#__PURE__*/React.createElement(RadioGroup.Radio, {
|
|
74
|
-
"data-testid": "radio",
|
|
75
|
-
value: "Radio 2"
|
|
76
|
-
}), /*#__PURE__*/React.createElement(RadioGroup.Radio, {
|
|
77
|
-
"data-testid": "radio",
|
|
78
|
-
value: "Radio 3"
|
|
79
|
-
})))),
|
|
80
|
-
getAllByTestId = _render5.getAllByTestId;
|
|
81
|
-
|
|
82
|
-
var radios = getAllByTestId('radio');
|
|
83
|
-
radios.map(function (radio) {
|
|
84
|
-
return expect(radio.name).toBe(name);
|
|
85
|
-
});
|
|
86
|
-
});
|
|
87
|
-
});
|
|
88
|
-
describe('Events', function () {
|
|
89
|
-
it('should call onchange from Context', function () {
|
|
90
|
-
var onChangeMock = jest.fn();
|
|
91
|
-
|
|
92
|
-
var _render6 = render( /*#__PURE__*/React.createElement(RadioGroupContext.Provider, {
|
|
93
|
-
value: {
|
|
94
|
-
onChange: onChangeMock
|
|
95
|
-
}
|
|
96
|
-
}, /*#__PURE__*/React.createElement(ThemeProvider, null, /*#__PURE__*/React.createElement(RadioGroup.Radio, {
|
|
97
|
-
"data-testid": "radio",
|
|
98
|
-
value: "Radio 1"
|
|
99
|
-
})))),
|
|
100
|
-
getByTestId = _render6.getByTestId;
|
|
101
|
-
|
|
102
|
-
var radio = getByTestId('radio');
|
|
103
|
-
fireEvent.click(radio);
|
|
104
|
-
expect(onChangeMock).toHaveBeenCalled();
|
|
105
|
-
});
|
|
106
|
-
});
|
|
107
|
-
});
|
|
108
|
-
});
|
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { render, fireEvent } from '@testing-library/react';
|
|
3
|
-
import RadioGroup from '..';
|
|
4
|
-
import ThemeProvider from '../../Theme';
|
|
5
|
-
describe('<RadioGroup />', function () {
|
|
6
|
-
describe('Snapshots', function () {
|
|
7
|
-
it('should match snapshot with default radiogroup', function () {
|
|
8
|
-
var _render = render( /*#__PURE__*/React.createElement(ThemeProvider, null, /*#__PURE__*/React.createElement(RadioGroup, null))),
|
|
9
|
-
container = _render.container;
|
|
10
|
-
|
|
11
|
-
expect(container).toMatchSnapshot();
|
|
12
|
-
});
|
|
13
|
-
it('should match snapshot with full radiogroup', function () {
|
|
14
|
-
var _render2 = render( /*#__PURE__*/React.createElement(ThemeProvider, null, /*#__PURE__*/React.createElement(RadioGroup, {
|
|
15
|
-
full: true
|
|
16
|
-
}))),
|
|
17
|
-
container = _render2.container;
|
|
18
|
-
|
|
19
|
-
expect(container).toMatchSnapshot();
|
|
20
|
-
});
|
|
21
|
-
it('should match snapshot with radios as children', function () {
|
|
22
|
-
var _render3 = render( /*#__PURE__*/React.createElement(ThemeProvider, null, /*#__PURE__*/React.createElement(RadioGroup, null, /*#__PURE__*/React.createElement(RadioGroup.Button, null, "Option 1"), /*#__PURE__*/React.createElement(RadioGroup.Button, null, "Option 2"), /*#__PURE__*/React.createElement(RadioGroup.Button, null, "Option 3")))),
|
|
23
|
-
container = _render3.container,
|
|
24
|
-
getAllByText = _render3.getAllByText;
|
|
25
|
-
|
|
26
|
-
expect(container).toMatchSnapshot();
|
|
27
|
-
expect(getAllByText(/^Option/)).toHaveLength(3);
|
|
28
|
-
});
|
|
29
|
-
it('should match snapshot with small radios', function () {
|
|
30
|
-
var _render4 = render( /*#__PURE__*/React.createElement(ThemeProvider, null, /*#__PURE__*/React.createElement(RadioGroup, {
|
|
31
|
-
small: true
|
|
32
|
-
}, /*#__PURE__*/React.createElement(RadioGroup.Button, null, "Option 1"), /*#__PURE__*/React.createElement(RadioGroup.Button, null, "Option 2"), /*#__PURE__*/React.createElement(RadioGroup.Button, null, "Option 3")))),
|
|
33
|
-
container = _render4.container;
|
|
34
|
-
|
|
35
|
-
expect(container).toMatchSnapshot();
|
|
36
|
-
});
|
|
37
|
-
it('should has setted the selected value', function () {
|
|
38
|
-
var _render5 = render( /*#__PURE__*/React.createElement(ThemeProvider, null, /*#__PURE__*/React.createElement(RadioGroup, {
|
|
39
|
-
selectedValue: "Option 2"
|
|
40
|
-
}, /*#__PURE__*/React.createElement(RadioGroup.Button, null, "Option 1"), /*#__PURE__*/React.createElement(RadioGroup.Button, null, "Option 2"), /*#__PURE__*/React.createElement(RadioGroup.Button, null, "Option 3")))),
|
|
41
|
-
container = _render5.container,
|
|
42
|
-
getByText = _render5.getByText;
|
|
43
|
-
|
|
44
|
-
expect(container).toMatchSnapshot();
|
|
45
|
-
expect(getByText('Option 2').checked).toBe(true);
|
|
46
|
-
});
|
|
47
|
-
it('should set the name for all children', function () {
|
|
48
|
-
var groupName = 'test';
|
|
49
|
-
|
|
50
|
-
var _render6 = render( /*#__PURE__*/React.createElement(ThemeProvider, null, /*#__PURE__*/React.createElement(RadioGroup, {
|
|
51
|
-
name: groupName
|
|
52
|
-
}, /*#__PURE__*/React.createElement(RadioGroup.Button, {
|
|
53
|
-
"data-testid": "Option 1"
|
|
54
|
-
}, "Option 1"), /*#__PURE__*/React.createElement(RadioGroup.Button, {
|
|
55
|
-
"data-testid": "Option 2"
|
|
56
|
-
}, "Option 2"), /*#__PURE__*/React.createElement(RadioGroup.Button, {
|
|
57
|
-
"data-testid": "Option 3"
|
|
58
|
-
}, "Option 3")))),
|
|
59
|
-
container = _render6.container,
|
|
60
|
-
getAllByTestId = _render6.getAllByTestId;
|
|
61
|
-
|
|
62
|
-
expect(container).toMatchSnapshot(); // use testid to get the input[type=radio] instead of label
|
|
63
|
-
|
|
64
|
-
getAllByTestId(/^Option/).map(function (radio) {
|
|
65
|
-
return expect(radio.name).toBe(groupName);
|
|
66
|
-
});
|
|
67
|
-
});
|
|
68
|
-
});
|
|
69
|
-
});
|
|
70
|
-
describe('Events', function () {
|
|
71
|
-
it('should set the onchange for its children', function () {
|
|
72
|
-
var onChangeMock = jest.fn();
|
|
73
|
-
|
|
74
|
-
var _render7 = render( /*#__PURE__*/React.createElement(ThemeProvider, null, /*#__PURE__*/React.createElement(RadioGroup, {
|
|
75
|
-
onChange: onChangeMock
|
|
76
|
-
}, /*#__PURE__*/React.createElement(RadioGroup.Button, null, "Option 1"), /*#__PURE__*/React.createElement(RadioGroup.Button, null, "Option 2"), /*#__PURE__*/React.createElement(RadioGroup.Button, null, "Option 3")))),
|
|
77
|
-
getByText = _render7.getByText;
|
|
78
|
-
|
|
79
|
-
var firstOption = getByText('Option 1');
|
|
80
|
-
fireEvent.click(firstOption);
|
|
81
|
-
expect(onChangeMock).toHaveBeenCalled();
|
|
82
|
-
});
|
|
83
|
-
});
|
|
@@ -1,186 +0,0 @@
|
|
|
1
|
-
var _excluded = ["value", "max", "readOnly", "onRate", "theme", "icon"];
|
|
2
|
-
|
|
3
|
-
var _templateObject;
|
|
4
|
-
|
|
5
|
-
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); }
|
|
6
|
-
|
|
7
|
-
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
8
|
-
|
|
9
|
-
function _taggedTemplateLiteralLoose(strings, raw) { if (!raw) { raw = strings.slice(0); } strings.raw = raw; return strings; }
|
|
10
|
-
|
|
11
|
-
import React, { useState, useEffect } from 'react';
|
|
12
|
-
import { PanResponder } from 'react-native';
|
|
13
|
-
import styled, { withTheme } from 'styled-components';
|
|
14
|
-
import { number, func, bool, shape } from 'prop-types';
|
|
15
|
-
import { StarFilled } from '@gympass/yoga-icons';
|
|
16
|
-
import { max as maxPropType } from '../../shared';
|
|
17
|
-
var SVG_DEFAULT_SIZE = 12;
|
|
18
|
-
var RatingWrapper = styled.View(_templateObject || (_templateObject = _taggedTemplateLiteralLoose(["\n flex-direction: row;\n justify-content: center;\n align-items: center;\n\n ", "\n"])), function (_ref) {
|
|
19
|
-
var width = _ref.width,
|
|
20
|
-
height = _ref.height;
|
|
21
|
-
return "\n width: " + width + "px;\n height: " + height + "px;\n ";
|
|
22
|
-
});
|
|
23
|
-
/** Use the Rating component to view other people's opinions and experiences. */
|
|
24
|
-
|
|
25
|
-
var Rating = function Rating(_ref2) {
|
|
26
|
-
var value = _ref2.value,
|
|
27
|
-
max = _ref2.max,
|
|
28
|
-
readOnly = _ref2.readOnly,
|
|
29
|
-
onRate = _ref2.onRate,
|
|
30
|
-
_ref2$theme$yoga = _ref2.theme.yoga,
|
|
31
|
-
colors = _ref2$theme$yoga.colors,
|
|
32
|
-
rating = _ref2$theme$yoga.components.rating,
|
|
33
|
-
_ref2$icon = _ref2.icon,
|
|
34
|
-
_ref2$icon$type = _ref2$icon.type,
|
|
35
|
-
Icon = _ref2$icon$type === void 0 ? StarFilled : _ref2$icon$type,
|
|
36
|
-
_ref2$icon$size = _ref2$icon.size,
|
|
37
|
-
iconSize = _ref2$icon$size === void 0 ? 24 : _ref2$icon$size,
|
|
38
|
-
rest = _objectWithoutPropertiesLoose(_ref2, _excluded);
|
|
39
|
-
|
|
40
|
-
var _useState = useState({}),
|
|
41
|
-
panResponder = _useState[0],
|
|
42
|
-
setPanResponder = _useState[1];
|
|
43
|
-
|
|
44
|
-
var _useState2 = useState({}),
|
|
45
|
-
wrapperLayout = _useState2[0],
|
|
46
|
-
setWrapperLayout = _useState2[1];
|
|
47
|
-
|
|
48
|
-
var _useState3 = useState(0),
|
|
49
|
-
swipeRating = _useState3[0],
|
|
50
|
-
setSwipeRating = _useState3[1];
|
|
51
|
-
|
|
52
|
-
var _useState4 = useState(false),
|
|
53
|
-
swipping = _useState4[0],
|
|
54
|
-
toggleSwipping = _useState4[1];
|
|
55
|
-
|
|
56
|
-
function getCurrentRating(swipeValue) {
|
|
57
|
-
var currentRating = 1;
|
|
58
|
-
|
|
59
|
-
if (swipeValue > wrapperLayout.width) {
|
|
60
|
-
currentRating = max;
|
|
61
|
-
} else if (swipeValue <= 0) {
|
|
62
|
-
currentRating = 0;
|
|
63
|
-
} else {
|
|
64
|
-
currentRating = Math.round(swipeValue / (wrapperLayout.width / max));
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
return currentRating || 1;
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
useEffect(function () {
|
|
71
|
-
var responder = PanResponder.create({
|
|
72
|
-
onStartShouldSetPanResponder: function onStartShouldSetPanResponder() {
|
|
73
|
-
return true;
|
|
74
|
-
},
|
|
75
|
-
onStartShouldSetPanResponderCapture: function onStartShouldSetPanResponderCapture() {
|
|
76
|
-
return true;
|
|
77
|
-
},
|
|
78
|
-
onMoveShouldSetPanResponder: function onMoveShouldSetPanResponder() {
|
|
79
|
-
return true;
|
|
80
|
-
},
|
|
81
|
-
onMoveShouldSetPanResponderCapture: function onMoveShouldSetPanResponderCapture() {
|
|
82
|
-
return true;
|
|
83
|
-
},
|
|
84
|
-
onPanResponderTerminationRequest: function onPanResponderTerminationRequest() {
|
|
85
|
-
return true;
|
|
86
|
-
},
|
|
87
|
-
onPanResponderGrant: function onPanResponderGrant(_ref3) {
|
|
88
|
-
var pageX = _ref3.nativeEvent.pageX;
|
|
89
|
-
toggleSwipping(true);
|
|
90
|
-
setSwipeRating(getCurrentRating(pageX - wrapperLayout.x));
|
|
91
|
-
},
|
|
92
|
-
onPanResponderMove: function onPanResponderMove(_ref4) {
|
|
93
|
-
var pageX = _ref4.nativeEvent.pageX;
|
|
94
|
-
setSwipeRating(getCurrentRating(pageX - wrapperLayout.x));
|
|
95
|
-
},
|
|
96
|
-
onPanResponderRelease: function onPanResponderRelease(_ref5) {
|
|
97
|
-
var pageX = _ref5.nativeEvent.pageX;
|
|
98
|
-
setSwipeRating(0);
|
|
99
|
-
toggleSwipping(false);
|
|
100
|
-
onRate(getCurrentRating(pageX - wrapperLayout.x));
|
|
101
|
-
}
|
|
102
|
-
});
|
|
103
|
-
setPanResponder(responder);
|
|
104
|
-
}, [wrapperLayout]);
|
|
105
|
-
return /*#__PURE__*/React.createElement(RatingWrapper, _extends({
|
|
106
|
-
height: iconSize,
|
|
107
|
-
width: iconSize * max,
|
|
108
|
-
pointerEvents: readOnly ? 'none' : 'auto'
|
|
109
|
-
}, rest, panResponder.panHandlers, {
|
|
110
|
-
onLayout: function onLayout(_ref6) {
|
|
111
|
-
var layout = _ref6.nativeEvent.layout;
|
|
112
|
-
return setWrapperLayout(layout);
|
|
113
|
-
}
|
|
114
|
-
}), Array.from({
|
|
115
|
-
length: max
|
|
116
|
-
}, function (_, i) {
|
|
117
|
-
var diff = i + 1 - value;
|
|
118
|
-
|
|
119
|
-
if (swipeRating >= i + 1 || !swipping && diff <= 0) {
|
|
120
|
-
return /*#__PURE__*/React.createElement(Icon, {
|
|
121
|
-
key: "filled-" + i,
|
|
122
|
-
fill: rating.backgroundColor,
|
|
123
|
-
width: iconSize,
|
|
124
|
-
height: iconSize
|
|
125
|
-
});
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
if (diff > 0 && diff < 1) {
|
|
129
|
-
var width = (1 - diff) * iconSize;
|
|
130
|
-
var dWidth = diff * iconSize;
|
|
131
|
-
var wViewBox = SVG_DEFAULT_SIZE * (1 - diff);
|
|
132
|
-
var dViewBox = SVG_DEFAULT_SIZE * diff;
|
|
133
|
-
return /*#__PURE__*/React.createElement(React.Fragment, {
|
|
134
|
-
key: "half-" + i
|
|
135
|
-
}, /*#__PURE__*/React.createElement(Icon, {
|
|
136
|
-
fill: rating.backgroundColor,
|
|
137
|
-
width: width,
|
|
138
|
-
height: iconSize,
|
|
139
|
-
viewBox: "0 0 " + wViewBox + " " + SVG_DEFAULT_SIZE
|
|
140
|
-
}), /*#__PURE__*/React.createElement(Icon, {
|
|
141
|
-
fill: colors.elements.lineAndBorders,
|
|
142
|
-
width: dWidth,
|
|
143
|
-
height: iconSize,
|
|
144
|
-
viewBox: wViewBox + " 0 " + dViewBox + " " + SVG_DEFAULT_SIZE
|
|
145
|
-
}));
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
return /*#__PURE__*/React.createElement(Icon, {
|
|
149
|
-
key: "unfilled-" + i,
|
|
150
|
-
fill: colors.elements.lineAndBorders,
|
|
151
|
-
width: iconSize,
|
|
152
|
-
height: iconSize
|
|
153
|
-
});
|
|
154
|
-
}));
|
|
155
|
-
};
|
|
156
|
-
|
|
157
|
-
Rating.propTypes = {
|
|
158
|
-
value: number,
|
|
159
|
-
|
|
160
|
-
/** The icon to display */
|
|
161
|
-
icon: shape({
|
|
162
|
-
type: func,
|
|
163
|
-
size: maxPropType(24)
|
|
164
|
-
}),
|
|
165
|
-
|
|
166
|
-
/** Maximum rating */
|
|
167
|
-
max: number,
|
|
168
|
-
|
|
169
|
-
/** false to make it interactable */
|
|
170
|
-
readOnly: bool,
|
|
171
|
-
|
|
172
|
-
/** Event to be fired on click */
|
|
173
|
-
onRate: func
|
|
174
|
-
};
|
|
175
|
-
Rating.defaultProps = {
|
|
176
|
-
value: undefined,
|
|
177
|
-
icon: {
|
|
178
|
-
type: StarFilled,
|
|
179
|
-
size: 24
|
|
180
|
-
},
|
|
181
|
-
max: 5,
|
|
182
|
-
readOnly: true,
|
|
183
|
-
onRate: function onRate(rating) {} // eslint-disable-line no-unused-vars
|
|
184
|
-
|
|
185
|
-
};
|
|
186
|
-
export default withTheme(Rating);
|
|
@@ -1,121 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { render } from '@testing-library/react-native';
|
|
3
|
-
import Svg, { Circle } from 'react-native-svg';
|
|
4
|
-
import { ThemeProvider } from '../..';
|
|
5
|
-
import Rating from '.';
|
|
6
|
-
describe('<Rating />', function () {
|
|
7
|
-
describe('Snapshots', function () {
|
|
8
|
-
it('should match snapshot with Rating', function () {
|
|
9
|
-
var _render = render( /*#__PURE__*/React.createElement(ThemeProvider, null, /*#__PURE__*/React.createElement(Rating, null))),
|
|
10
|
-
toJSON = _render.toJSON;
|
|
11
|
-
|
|
12
|
-
expect(toJSON()).toMatchSnapshot();
|
|
13
|
-
});
|
|
14
|
-
it('should match snapshot when it is not readOnly', function () {
|
|
15
|
-
var _render2 = render( /*#__PURE__*/React.createElement(ThemeProvider, null, /*#__PURE__*/React.createElement(Rating, {
|
|
16
|
-
readOnly: false
|
|
17
|
-
}))),
|
|
18
|
-
toJSON = _render2.toJSON;
|
|
19
|
-
|
|
20
|
-
expect(toJSON()).toMatchSnapshot();
|
|
21
|
-
});
|
|
22
|
-
it('should match snapshot with different values', function () {
|
|
23
|
-
var _render3 = render( /*#__PURE__*/React.createElement(ThemeProvider, null, /*#__PURE__*/React.createElement(Rating, {
|
|
24
|
-
value: 0
|
|
25
|
-
}), /*#__PURE__*/React.createElement(Rating, {
|
|
26
|
-
value: 0.5
|
|
27
|
-
}), /*#__PURE__*/React.createElement(Rating, {
|
|
28
|
-
value: 1
|
|
29
|
-
}), /*#__PURE__*/React.createElement(Rating, {
|
|
30
|
-
value: 1.1
|
|
31
|
-
}), /*#__PURE__*/React.createElement(Rating, {
|
|
32
|
-
value: 1.2
|
|
33
|
-
}), /*#__PURE__*/React.createElement(Rating, {
|
|
34
|
-
value: 1.3
|
|
35
|
-
}), /*#__PURE__*/React.createElement(Rating, {
|
|
36
|
-
value: 1.4
|
|
37
|
-
}), /*#__PURE__*/React.createElement(Rating, {
|
|
38
|
-
value: 1.5
|
|
39
|
-
}), /*#__PURE__*/React.createElement(Rating, {
|
|
40
|
-
value: 1.6
|
|
41
|
-
}), /*#__PURE__*/React.createElement(Rating, {
|
|
42
|
-
value: 1.7
|
|
43
|
-
}), /*#__PURE__*/React.createElement(Rating, {
|
|
44
|
-
value: 1.8
|
|
45
|
-
}), /*#__PURE__*/React.createElement(Rating, {
|
|
46
|
-
value: 1.9
|
|
47
|
-
}), /*#__PURE__*/React.createElement(Rating, {
|
|
48
|
-
value: 2
|
|
49
|
-
}), /*#__PURE__*/React.createElement(Rating, {
|
|
50
|
-
value: 2.5
|
|
51
|
-
}), /*#__PURE__*/React.createElement(Rating, {
|
|
52
|
-
value: 3
|
|
53
|
-
}), /*#__PURE__*/React.createElement(Rating, {
|
|
54
|
-
value: 3.5
|
|
55
|
-
}), /*#__PURE__*/React.createElement(Rating, {
|
|
56
|
-
value: 4
|
|
57
|
-
}), /*#__PURE__*/React.createElement(Rating, {
|
|
58
|
-
value: 4.5
|
|
59
|
-
}))),
|
|
60
|
-
toJSON = _render3.toJSON;
|
|
61
|
-
|
|
62
|
-
expect(toJSON()).toMatchSnapshot();
|
|
63
|
-
});
|
|
64
|
-
it('should match snapshot with different icon quantity', function () {
|
|
65
|
-
var _render4 = render( /*#__PURE__*/React.createElement(ThemeProvider, null, /*#__PURE__*/React.createElement(Rating, {
|
|
66
|
-
max: 3,
|
|
67
|
-
value: 0
|
|
68
|
-
}), /*#__PURE__*/React.createElement(Rating, {
|
|
69
|
-
max: 3,
|
|
70
|
-
value: 0.5
|
|
71
|
-
}), /*#__PURE__*/React.createElement(Rating, {
|
|
72
|
-
max: 3,
|
|
73
|
-
value: 1
|
|
74
|
-
}), /*#__PURE__*/React.createElement(Rating, {
|
|
75
|
-
max: 3,
|
|
76
|
-
value: 1.5
|
|
77
|
-
}), /*#__PURE__*/React.createElement(Rating, {
|
|
78
|
-
max: 3,
|
|
79
|
-
value: 2
|
|
80
|
-
}), /*#__PURE__*/React.createElement(Rating, {
|
|
81
|
-
max: 3,
|
|
82
|
-
value: 2.5
|
|
83
|
-
}), /*#__PURE__*/React.createElement(Rating, {
|
|
84
|
-
max: 3,
|
|
85
|
-
value: 3
|
|
86
|
-
}))),
|
|
87
|
-
toJSON = _render4.toJSON;
|
|
88
|
-
|
|
89
|
-
expect(toJSON()).toMatchSnapshot();
|
|
90
|
-
});
|
|
91
|
-
it('should match snapshot with different icon', function () {
|
|
92
|
-
var CircleIcon = function CircleIcon(props) {
|
|
93
|
-
return /*#__PURE__*/React.createElement(Svg, props, /*#__PURE__*/React.createElement(Circle, {
|
|
94
|
-
cx: 12,
|
|
95
|
-
cy: 12,
|
|
96
|
-
r: 12
|
|
97
|
-
}));
|
|
98
|
-
};
|
|
99
|
-
|
|
100
|
-
var _render5 = render( /*#__PURE__*/React.createElement(ThemeProvider, null, /*#__PURE__*/React.createElement(Rating, {
|
|
101
|
-
icon: {
|
|
102
|
-
type: CircleIcon
|
|
103
|
-
},
|
|
104
|
-
value: 0
|
|
105
|
-
}), /*#__PURE__*/React.createElement(Rating, {
|
|
106
|
-
icon: {
|
|
107
|
-
type: CircleIcon
|
|
108
|
-
},
|
|
109
|
-
value: 1
|
|
110
|
-
}), /*#__PURE__*/React.createElement(Rating, {
|
|
111
|
-
icon: {
|
|
112
|
-
type: CircleIcon
|
|
113
|
-
},
|
|
114
|
-
value: 2
|
|
115
|
-
}))),
|
|
116
|
-
toJSON = _render5.toJSON;
|
|
117
|
-
|
|
118
|
-
expect(toJSON()).toMatchSnapshot();
|
|
119
|
-
});
|
|
120
|
-
});
|
|
121
|
-
});
|
|
@@ -1,184 +0,0 @@
|
|
|
1
|
-
/* eslint-disable jsx-a11y/mouse-events-have-key-events */
|
|
2
|
-
import React from 'react';
|
|
3
|
-
import { render, fireEvent } from '@testing-library/react';
|
|
4
|
-
import { ThemeProvider } from '../..';
|
|
5
|
-
import Rating from '.';
|
|
6
|
-
describe('<Rating />', function () {
|
|
7
|
-
var originalOffsetWidth = Object.getOwnPropertyDescriptor(HTMLElement.prototype, 'offsetWidth');
|
|
8
|
-
beforeAll(function () {
|
|
9
|
-
Object.defineProperty(HTMLElement.prototype, 'offsetWidth', {
|
|
10
|
-
configurable: true,
|
|
11
|
-
value: 76 // 5 stars (5 * 12px + 4 * 4px gutter)
|
|
12
|
-
|
|
13
|
-
});
|
|
14
|
-
});
|
|
15
|
-
afterAll(function () {
|
|
16
|
-
Object.defineProperty(HTMLElement.prototype, 'offsetWidth', originalOffsetWidth);
|
|
17
|
-
});
|
|
18
|
-
describe('Snapshots', function () {
|
|
19
|
-
it('should match snapshot with Rating', function () {
|
|
20
|
-
var _render = render( /*#__PURE__*/React.createElement(ThemeProvider, null, /*#__PURE__*/React.createElement(Rating, null))),
|
|
21
|
-
container = _render.container;
|
|
22
|
-
|
|
23
|
-
expect(container).toMatchSnapshot();
|
|
24
|
-
});
|
|
25
|
-
it('should match snapshot with different values', function () {
|
|
26
|
-
var _render2 = render( /*#__PURE__*/React.createElement(ThemeProvider, null, /*#__PURE__*/React.createElement(Rating, {
|
|
27
|
-
value: 0
|
|
28
|
-
}), /*#__PURE__*/React.createElement(Rating, {
|
|
29
|
-
value: 0.5
|
|
30
|
-
}), /*#__PURE__*/React.createElement(Rating, {
|
|
31
|
-
value: 1
|
|
32
|
-
}), /*#__PURE__*/React.createElement(Rating, {
|
|
33
|
-
value: 1.1
|
|
34
|
-
}), /*#__PURE__*/React.createElement(Rating, {
|
|
35
|
-
value: 1.2
|
|
36
|
-
}), /*#__PURE__*/React.createElement(Rating, {
|
|
37
|
-
value: 1.3
|
|
38
|
-
}), /*#__PURE__*/React.createElement(Rating, {
|
|
39
|
-
value: 1.4
|
|
40
|
-
}), /*#__PURE__*/React.createElement(Rating, {
|
|
41
|
-
value: 1.5
|
|
42
|
-
}), /*#__PURE__*/React.createElement(Rating, {
|
|
43
|
-
value: 1.6
|
|
44
|
-
}), /*#__PURE__*/React.createElement(Rating, {
|
|
45
|
-
value: 1.7
|
|
46
|
-
}), /*#__PURE__*/React.createElement(Rating, {
|
|
47
|
-
value: 1.8
|
|
48
|
-
}), /*#__PURE__*/React.createElement(Rating, {
|
|
49
|
-
value: 1.9
|
|
50
|
-
}), /*#__PURE__*/React.createElement(Rating, {
|
|
51
|
-
value: 2
|
|
52
|
-
}), /*#__PURE__*/React.createElement(Rating, {
|
|
53
|
-
value: 2.5
|
|
54
|
-
}), /*#__PURE__*/React.createElement(Rating, {
|
|
55
|
-
value: 3
|
|
56
|
-
}), /*#__PURE__*/React.createElement(Rating, {
|
|
57
|
-
value: 3.5
|
|
58
|
-
}), /*#__PURE__*/React.createElement(Rating, {
|
|
59
|
-
value: 4
|
|
60
|
-
}), /*#__PURE__*/React.createElement(Rating, {
|
|
61
|
-
value: 4.5
|
|
62
|
-
}))),
|
|
63
|
-
container = _render2.container;
|
|
64
|
-
|
|
65
|
-
expect(container).toMatchSnapshot();
|
|
66
|
-
});
|
|
67
|
-
it('should match snapshot with different icon quantity', function () {
|
|
68
|
-
var _render3 = render( /*#__PURE__*/React.createElement(ThemeProvider, null, /*#__PURE__*/React.createElement(Rating, {
|
|
69
|
-
max: 3,
|
|
70
|
-
value: 0
|
|
71
|
-
}), /*#__PURE__*/React.createElement(Rating, {
|
|
72
|
-
max: 3,
|
|
73
|
-
value: 0.5
|
|
74
|
-
}), /*#__PURE__*/React.createElement(Rating, {
|
|
75
|
-
max: 3,
|
|
76
|
-
value: 1
|
|
77
|
-
}), /*#__PURE__*/React.createElement(Rating, {
|
|
78
|
-
max: 3,
|
|
79
|
-
value: 1.5
|
|
80
|
-
}), /*#__PURE__*/React.createElement(Rating, {
|
|
81
|
-
max: 3,
|
|
82
|
-
value: 2
|
|
83
|
-
}), /*#__PURE__*/React.createElement(Rating, {
|
|
84
|
-
max: 3,
|
|
85
|
-
value: 2.5
|
|
86
|
-
}), /*#__PURE__*/React.createElement(Rating, {
|
|
87
|
-
max: 3,
|
|
88
|
-
value: 3
|
|
89
|
-
}))),
|
|
90
|
-
container = _render3.container;
|
|
91
|
-
|
|
92
|
-
expect(container).toMatchSnapshot();
|
|
93
|
-
});
|
|
94
|
-
it('should match snapshot with different icon', function () {
|
|
95
|
-
var Circle = function Circle(props) {
|
|
96
|
-
return /*#__PURE__*/React.createElement("svg", props, /*#__PURE__*/React.createElement("circle", {
|
|
97
|
-
cx: "12",
|
|
98
|
-
cy: "12",
|
|
99
|
-
r: "12"
|
|
100
|
-
}));
|
|
101
|
-
};
|
|
102
|
-
|
|
103
|
-
var _render4 = render( /*#__PURE__*/React.createElement(ThemeProvider, null, /*#__PURE__*/React.createElement(Rating, {
|
|
104
|
-
icon: {
|
|
105
|
-
type: Circle
|
|
106
|
-
},
|
|
107
|
-
value: 0
|
|
108
|
-
}), /*#__PURE__*/React.createElement(Rating, {
|
|
109
|
-
icon: {
|
|
110
|
-
type: Circle
|
|
111
|
-
},
|
|
112
|
-
value: 1
|
|
113
|
-
}), /*#__PURE__*/React.createElement(Rating, {
|
|
114
|
-
icon: {
|
|
115
|
-
type: Circle
|
|
116
|
-
},
|
|
117
|
-
value: 2
|
|
118
|
-
}))),
|
|
119
|
-
container = _render4.container;
|
|
120
|
-
|
|
121
|
-
expect(container).toMatchSnapshot();
|
|
122
|
-
});
|
|
123
|
-
it('should match snapshot when mouse over', function () {
|
|
124
|
-
var _render5 = render( /*#__PURE__*/React.createElement(ThemeProvider, null, /*#__PURE__*/React.createElement(Rating, {
|
|
125
|
-
readOnly: false
|
|
126
|
-
}))),
|
|
127
|
-
container = _render5.container;
|
|
128
|
-
|
|
129
|
-
var firstChild = container.firstChild;
|
|
130
|
-
fireEvent.mouseMove(firstChild, {
|
|
131
|
-
/** Each star has 12px. Gutter is 4px.
|
|
132
|
-
* For the third star, we should set clentX > 32px and < 48px */
|
|
133
|
-
clientX: 40
|
|
134
|
-
});
|
|
135
|
-
expect(container).toMatchSnapshot();
|
|
136
|
-
});
|
|
137
|
-
});
|
|
138
|
-
describe('Events', function () {
|
|
139
|
-
it('should call onRate when clicking', function () {
|
|
140
|
-
var onRateMock = jest.fn();
|
|
141
|
-
|
|
142
|
-
var _render6 = render( /*#__PURE__*/React.createElement(ThemeProvider, null, /*#__PURE__*/React.createElement(Rating, {
|
|
143
|
-
onRate: onRateMock,
|
|
144
|
-
readOnly: false
|
|
145
|
-
}))),
|
|
146
|
-
container = _render6.container;
|
|
147
|
-
|
|
148
|
-
var firstChild = container.firstChild;
|
|
149
|
-
fireEvent.mouseMove(firstChild, {
|
|
150
|
-
clientX: 40 // third star position
|
|
151
|
-
|
|
152
|
-
});
|
|
153
|
-
fireEvent.click(firstChild);
|
|
154
|
-
expect(onRateMock).toHaveBeenCalled();
|
|
155
|
-
expect(onRateMock).toHaveBeenCalledWith(3);
|
|
156
|
-
});
|
|
157
|
-
it('should call onMouseOver callback', function () {
|
|
158
|
-
var onMouseOverMock = jest.fn();
|
|
159
|
-
|
|
160
|
-
var _render7 = render( /*#__PURE__*/React.createElement(ThemeProvider, null, /*#__PURE__*/React.createElement(Rating, {
|
|
161
|
-
onMouseOver: onMouseOverMock,
|
|
162
|
-
readOnly: false
|
|
163
|
-
}))),
|
|
164
|
-
container = _render7.container;
|
|
165
|
-
|
|
166
|
-
var firstChild = container.firstChild;
|
|
167
|
-
fireEvent.mouseOver(firstChild);
|
|
168
|
-
expect(onMouseOverMock).toHaveBeenCalled();
|
|
169
|
-
});
|
|
170
|
-
it('should call onMouseLeave callback', function () {
|
|
171
|
-
var onMouseLeaveMock = jest.fn();
|
|
172
|
-
|
|
173
|
-
var _render8 = render( /*#__PURE__*/React.createElement(ThemeProvider, null, /*#__PURE__*/React.createElement(Rating, {
|
|
174
|
-
onMouseLeave: onMouseLeaveMock,
|
|
175
|
-
readOnly: false
|
|
176
|
-
}))),
|
|
177
|
-
container = _render8.container;
|
|
178
|
-
|
|
179
|
-
var firstChild = container.firstChild;
|
|
180
|
-
fireEvent.mouseLeave(firstChild);
|
|
181
|
-
expect(onMouseLeaveMock).toHaveBeenCalled();
|
|
182
|
-
});
|
|
183
|
-
});
|
|
184
|
-
});
|