@enact/ui 4.1.0 → 4.1.3
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/AnnounceDecorator/tests/Announce-specs.js +13 -5
- package/AnnounceDecorator/tests/AnnounceDecorator-specs.js +9 -7
- package/AnnounceDecorator/tests/useAnnounce-specs.js +25 -17
- package/BodyText/BodyText.d.ts +1 -1
- package/BodyText/tests/BodyText-specs.js +49 -35
- package/Button/Button.d.ts +6 -6
- package/Button/tests/Button-specs.js +104 -3
- package/CHANGELOG.md +15 -0
- package/Cancelable/Cancelable.js +1 -1
- package/Cancelable/tests/Cancelable-specs.js +131 -70
- package/Changeable/tests/Changeable-specs.js +162 -110
- package/FloatingLayer/FloatingLayer.js +5 -17
- package/FloatingLayer/tests/FloatingLayer-specs.js +83 -8
- package/FloatingLayer/tests/Scrim-specs.js +20 -11
- package/FloatingLayer/tests/useFloatingLayerDecorator-specs.js +15 -9
- package/GridListImageItem/GridListImageItem.d.ts +1 -1
- package/Group/Group.d.ts +2 -2
- package/Group/tests/Group-specs.js +71 -41
- package/Heading/Heading.d.ts +2 -1
- package/Heading/tests/Heading-specs.js +27 -20
- package/Icon/Icon.d.ts +4 -4
- package/Icon/tests/Icon-specs.js +52 -31
- package/IconButton/IconButton.d.ts +4 -4
- package/IconButton/tests/IconButton-specs.js +2 -2
- package/Image/tests/Image-specs.js +39 -29
- package/ImageItem/tests/ImageItem-specs.js +71 -68
- package/Item/tests/Item-specs.js +59 -35
- package/LabeledIcon/LabeledIcon.d.ts +4 -4
- package/LabeledIcon/tests/LabeledIcon-specs.js +30 -19
- package/Layout/Layout.d.ts +16 -16
- package/Layout/tests/Layout-specs.js +37 -25
- package/Marquee/MarqueeBase.js +1 -5
- package/Marquee/tests/Marquee-specs.js +221 -116
- package/Media/Media.js +1 -3
- package/ProgressBar/tests/ProgressBar-specs.js +60 -42
- package/README.md +1 -1
- package/RadioDecorator/RadioDecorator.js +3 -5
- package/RadioDecorator/tests/RadioDecorator-specs.js +179 -65
- package/Repeater/Repeater.d.ts +2 -1
- package/Repeater/tests/Repeater-specs.js +86 -45
- package/Routable/Routable.d.ts +2 -2
- package/Routable/tests/Routable-specs.js +26 -17
- package/Routable/tests/Router-specs.js +65 -41
- package/Scrollable/Scrollable.js +2 -1
- package/Scrollable/ScrollableNative.js +2 -1
- package/Scroller/Scroller.d.ts +2 -2
- package/Scroller/ScrollerBasic.js +1 -1
- package/Scroller/UiScrollerBase.js +1 -1
- package/Skinnable/tests/Skinnable-specs.js +102 -54
- package/Skinnable/tests/useSkins-specs.js +37 -42
- package/Slider/Slider.d.ts +3 -3
- package/Slider/tests/Slider-specs.js +4 -4
- package/SlotItem/SlotItem.d.ts +2 -2
- package/SlotItem/tests/SlotItem-specs.js +4 -4
- package/Slottable/tests/Slottable-specs.js +67 -36
- package/Slottable/tests/useSlots-specs.js +68 -35
- package/Spinner/Spinner.d.ts +1 -1
- package/Spinner/tests/Spinner-specs.js +46 -31
- package/ToggleIcon/tests/ToggleIcon-specs.js +32 -20
- package/ToggleItem/ToggleItem.d.ts +13 -11
- package/ToggleItem/tests/ToggleItem-specs.js +51 -34
- package/Toggleable/Toggle.js +6 -6
- package/Toggleable/Toggleable.js +6 -12
- package/Toggleable/tests/Toggleable-specs.js +428 -324
- package/Touchable/Drag.js +13 -17
- package/Touchable/Flick.js +20 -16
- package/Touchable/Hold.js +14 -19
- package/Touchable/Touchable.d.ts +3 -3
- package/Touchable/tests/Touchable-specs.js +223 -109
- package/Touchable/tests/useTouch-specs.js +159 -84
- package/Transition/Transition.d.ts +29 -27
- package/Transition/Transition.js +5 -9
- package/Transition/tests/Transition-specs.js +135 -31
- package/ViewManager/TransitionGroup.js +6 -5
- package/ViewManager/View.js +1 -1
- package/ViewManager/ViewManager.d.ts +4 -4
- package/ViewManager/ViewManager.js +10 -10
- package/ViewManager/tests/View-specs.js +109 -81
- package/ViewManager/tests/ViewManager-specs.js +471 -185
- package/VirtualList/UiVirtualListBase.js +1 -1
- package/VirtualList/VirtualList.d.ts +11 -9
- package/VirtualList/VirtualListBasic.js +1 -1
- package/VirtualList/tests/VirtualList-specs.js +44 -31
- package/internal/IdProvider/tests/useId-specs.js +35 -18
- package/package.json +11 -11
- package/resolution/tests/ResolutionDecorator-specs.js +17 -8
- package/styles/mixins.less +14 -2
- package/useControlledState/tests/useControlledState-specs.js +67 -42
- package/useScroll/useScroll.js +2 -2
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
require("@testing-library/jest-dom");
|
|
4
|
+
|
|
5
|
+
var _react = require("@testing-library/react");
|
|
4
6
|
|
|
5
7
|
var _Repeater = _interopRequireWildcard(require("../Repeater"));
|
|
6
8
|
|
|
@@ -36,134 +38,173 @@ describe('Repeater Specs', function () {
|
|
|
36
38
|
};
|
|
37
39
|
|
|
38
40
|
test('should have a root span element', function () {
|
|
39
|
-
|
|
41
|
+
(0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(_Repeater.RepeaterBase, {
|
|
40
42
|
childComponent: "div",
|
|
43
|
+
"data-testid": "repeater",
|
|
41
44
|
children: stringItems
|
|
42
45
|
}));
|
|
43
|
-
var expected = '
|
|
44
|
-
|
|
45
|
-
|
|
46
|
+
var expected = 'SPAN';
|
|
47
|
+
|
|
48
|
+
var rootElementName = _react.screen.getByTestId('repeater').nodeName;
|
|
49
|
+
|
|
50
|
+
expect(rootElementName).toBe(expected);
|
|
46
51
|
});
|
|
47
52
|
test('should accept a nodeName as root element', function () {
|
|
48
|
-
|
|
49
|
-
component: "div",
|
|
53
|
+
(0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(_Repeater.RepeaterBase, {
|
|
50
54
|
childComponent: "div",
|
|
55
|
+
component: "div",
|
|
56
|
+
"data-testid": "repeater",
|
|
51
57
|
children: stringItems
|
|
52
58
|
}));
|
|
53
|
-
var expected = '
|
|
54
|
-
|
|
55
|
-
|
|
59
|
+
var expected = 'DIV';
|
|
60
|
+
|
|
61
|
+
var rootElementName = _react.screen.getByTestId('repeater').nodeName;
|
|
62
|
+
|
|
63
|
+
expect(rootElementName).toBe(expected);
|
|
56
64
|
});
|
|
57
65
|
test('should accept a function as root element', function () {
|
|
58
|
-
|
|
59
|
-
component: CustomRootType,
|
|
66
|
+
(0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(_Repeater.RepeaterBase, {
|
|
60
67
|
childComponent: "div",
|
|
68
|
+
component: CustomRootType,
|
|
69
|
+
"data-testid": "repeater",
|
|
61
70
|
children: stringItems
|
|
62
71
|
}));
|
|
63
|
-
var expected = '
|
|
64
|
-
|
|
65
|
-
|
|
72
|
+
var expected = 'DIV';
|
|
73
|
+
|
|
74
|
+
var rootElementName = _react.screen.getByTestId('repeater').nodeName;
|
|
75
|
+
|
|
76
|
+
expect(rootElementName).toBe(expected);
|
|
66
77
|
});
|
|
67
78
|
test('should accept a nodeName as childComponent', function () {
|
|
68
|
-
|
|
79
|
+
(0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(_Repeater.RepeaterBase, {
|
|
69
80
|
childComponent: "div",
|
|
81
|
+
"data-testid": "repeater",
|
|
70
82
|
children: stringItems
|
|
71
83
|
}));
|
|
72
84
|
var expected = 3;
|
|
73
|
-
|
|
85
|
+
|
|
86
|
+
var actual = _react.screen.getByTestId('repeater').children.length;
|
|
87
|
+
|
|
74
88
|
expect(actual).toBe(expected);
|
|
75
89
|
});
|
|
76
90
|
test('should accept a function as childComponent', function () {
|
|
77
|
-
|
|
91
|
+
(0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(_Repeater.RepeaterBase, {
|
|
78
92
|
childComponent: CustomType,
|
|
93
|
+
"data-testid": "repeater",
|
|
79
94
|
children: stringItems
|
|
80
95
|
}));
|
|
81
96
|
var expected = 3;
|
|
82
|
-
|
|
97
|
+
|
|
98
|
+
var actual = _react.screen.getByTestId('repeater').children.length;
|
|
99
|
+
|
|
83
100
|
expect(actual).toBe(expected);
|
|
84
101
|
});
|
|
85
102
|
test('should create a number of children matching the length of items', function () {
|
|
86
|
-
|
|
103
|
+
(0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(_Repeater.RepeaterBase, {
|
|
87
104
|
childComponent: "div",
|
|
105
|
+
"data-testid": "repeater",
|
|
88
106
|
children: stringItems
|
|
89
107
|
}));
|
|
90
108
|
var expected = stringItems.length;
|
|
91
|
-
|
|
109
|
+
|
|
110
|
+
var actual = _react.screen.getByTestId('repeater').children.length;
|
|
111
|
+
|
|
92
112
|
expect(actual).toBe(expected);
|
|
93
113
|
});
|
|
94
114
|
test('should support an array of objects as items', function () {
|
|
95
|
-
|
|
115
|
+
(0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(_Repeater.RepeaterBase, {
|
|
96
116
|
childComponent: CustomType,
|
|
117
|
+
"data-testid": "repeater",
|
|
97
118
|
children: objItems
|
|
98
119
|
}));
|
|
99
120
|
var expected = objItems.length;
|
|
100
|
-
|
|
121
|
+
|
|
122
|
+
var actual = _react.screen.getByTestId('repeater').children.length;
|
|
123
|
+
|
|
101
124
|
expect(actual).toBe(expected);
|
|
102
125
|
});
|
|
103
126
|
test('should support passing itemProps to children', function () {
|
|
104
|
-
|
|
127
|
+
(0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(_Repeater.RepeaterBase, {
|
|
105
128
|
childComponent: "div",
|
|
129
|
+
"data-testid": "repeater",
|
|
106
130
|
itemProps: {
|
|
107
131
|
title: 'test'
|
|
108
132
|
},
|
|
109
133
|
children: stringItems
|
|
110
134
|
}));
|
|
111
135
|
var expected = 'test';
|
|
112
|
-
|
|
113
|
-
|
|
136
|
+
|
|
137
|
+
var actual = _react.screen.getByTestId('repeater').children.item(0);
|
|
138
|
+
|
|
139
|
+
expect(actual).toHaveAttribute('title', expected);
|
|
114
140
|
});
|
|
115
141
|
test('should pass index to each child', function () {
|
|
116
|
-
|
|
142
|
+
(0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(_Repeater.RepeaterBase, {
|
|
117
143
|
childComponent: "div",
|
|
144
|
+
"data-testid": "repeater",
|
|
118
145
|
children: stringItems
|
|
119
146
|
}));
|
|
120
|
-
var expected = 0;
|
|
121
|
-
|
|
122
|
-
|
|
147
|
+
var expected = '0';
|
|
148
|
+
|
|
149
|
+
var actual = _react.screen.getByTestId('repeater').children.item(0);
|
|
150
|
+
|
|
151
|
+
expect(actual).toHaveAttribute('data-index', expected);
|
|
123
152
|
});
|
|
124
153
|
test('should pass data to each child', function () {
|
|
125
|
-
|
|
154
|
+
(0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(_Repeater.RepeaterBase, {
|
|
126
155
|
childComponent: "div",
|
|
127
156
|
childProp: "data-str",
|
|
157
|
+
"data-testid": "repeater",
|
|
128
158
|
children: stringItems
|
|
129
159
|
}));
|
|
130
160
|
var expected = stringItems[0];
|
|
131
|
-
|
|
132
|
-
|
|
161
|
+
|
|
162
|
+
var actual = _react.screen.getByTestId('repeater').children.item(0);
|
|
163
|
+
|
|
164
|
+
expect(actual).toHaveAttribute('data-str', expected);
|
|
133
165
|
});
|
|
134
166
|
test('should pass item as children to each child', function () {
|
|
135
|
-
|
|
167
|
+
(0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(_Repeater.RepeaterBase, {
|
|
136
168
|
childComponent: "div",
|
|
169
|
+
"data-testid": "repeater",
|
|
137
170
|
children: stringItems
|
|
138
171
|
}));
|
|
139
172
|
var expected = stringItems[0];
|
|
140
|
-
|
|
141
|
-
|
|
173
|
+
|
|
174
|
+
var actual = _react.screen.getByTestId('repeater').children.item(0);
|
|
175
|
+
|
|
176
|
+
expect(actual).toHaveTextContent(expected);
|
|
142
177
|
});
|
|
143
178
|
test('should set role to list by default', function () {
|
|
144
|
-
|
|
179
|
+
(0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(_Repeater.RepeaterBase, {
|
|
145
180
|
childComponent: "div",
|
|
181
|
+
"data-testid": "repeater",
|
|
146
182
|
children: stringItems
|
|
147
183
|
}));
|
|
148
184
|
var expected = 'list';
|
|
149
|
-
|
|
150
|
-
|
|
185
|
+
|
|
186
|
+
var listElement = _react.screen.getByTestId('repeater');
|
|
187
|
+
|
|
188
|
+
expect(listElement).toHaveAttribute('role', expected);
|
|
151
189
|
});
|
|
152
190
|
test('should allow role to be overridden', function () {
|
|
153
|
-
|
|
191
|
+
(0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(_Repeater.RepeaterBase, {
|
|
154
192
|
childComponent: "div",
|
|
193
|
+
"data-testid": "repeater",
|
|
155
194
|
role: "listbox",
|
|
156
195
|
children: stringItems
|
|
157
196
|
}));
|
|
158
197
|
var expected = 'listbox';
|
|
159
|
-
|
|
160
|
-
|
|
198
|
+
|
|
199
|
+
var listElement = _react.screen.getByTestId('repeater');
|
|
200
|
+
|
|
201
|
+
expect(listElement).toHaveAttribute('role', expected);
|
|
161
202
|
});
|
|
162
|
-
test('should return a DOM node reference for `componentRef
|
|
203
|
+
test('should return a DOM node reference for `componentRef`', function () {
|
|
163
204
|
var ref = jest.fn();
|
|
164
|
-
(0,
|
|
165
|
-
component: "div",
|
|
205
|
+
(0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(_Repeater["default"], {
|
|
166
206
|
childComponent: "div",
|
|
207
|
+
component: "div",
|
|
167
208
|
ref: ref,
|
|
168
209
|
children: stringItems
|
|
169
210
|
}));
|
package/Routable/Routable.d.ts
CHANGED
|
@@ -18,7 +18,7 @@ export interface RoutableConfig extends Object {
|
|
|
18
18
|
/**
|
|
19
19
|
* The event to listen to for path changes.
|
|
20
20
|
*
|
|
21
|
-
* This defines the actual name of the
|
|
21
|
+
* This defines the actual name of the [navigate]
|
|
22
22
|
property.
|
|
23
23
|
*/
|
|
24
24
|
navigate: string;
|
|
@@ -60,7 +60,7 @@ export interface LinkProps extends Merge<LinkBaseProps, LinkableProps> {
|
|
|
60
60
|
disabled?: boolean;
|
|
61
61
|
}
|
|
62
62
|
/**
|
|
63
|
-
* A component that is used to make a link to navigate among
|
|
63
|
+
* A component that is used to make a link to navigate among [ `Route` ] components.
|
|
64
64
|
*
|
|
65
65
|
* In the following example, `Sample` would render `Main` with two Links for `About` and `FAQ` .
|
|
66
66
|
If `About` is clicked, the content of `About` would be displayed under `Main` .
|
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
require("@testing-library/jest-dom");
|
|
4
4
|
|
|
5
|
-
var _react = require("react");
|
|
5
|
+
var _react = require("@testing-library/react");
|
|
6
|
+
|
|
7
|
+
var _userEvent = _interopRequireDefault(require("@testing-library/user-event"));
|
|
8
|
+
|
|
9
|
+
var _react2 = require("react");
|
|
6
10
|
|
|
7
11
|
var _Link = _interopRequireDefault(require("../Link"));
|
|
8
12
|
|
|
@@ -34,20 +38,20 @@ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
|
34
38
|
|
|
35
39
|
describe('Routable', function () {
|
|
36
40
|
test('should render nothing for a partially valid path', function () {
|
|
37
|
-
function App() {
|
|
41
|
+
var App = function App() {
|
|
38
42
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
39
43
|
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_Link["default"], {
|
|
40
44
|
path: "./page2",
|
|
41
45
|
children: "Page 2"
|
|
42
46
|
})
|
|
43
47
|
});
|
|
44
|
-
}
|
|
48
|
+
};
|
|
45
49
|
|
|
46
|
-
function Page2() {
|
|
50
|
+
var Page2 = function Page2() {
|
|
47
51
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
48
|
-
|
|
52
|
+
"data-testid": "page2"
|
|
49
53
|
});
|
|
50
|
-
}
|
|
54
|
+
};
|
|
51
55
|
|
|
52
56
|
var Views = (0, _Routable["default"])({
|
|
53
57
|
navigate: 'onNavigate'
|
|
@@ -59,12 +63,12 @@ describe('Routable', function () {
|
|
|
59
63
|
});
|
|
60
64
|
|
|
61
65
|
function Sample(props) {
|
|
62
|
-
var _useState = (0,
|
|
66
|
+
var _useState = (0, _react2.useState)('/app'),
|
|
63
67
|
_useState2 = _slicedToArray(_useState, 2),
|
|
64
68
|
path = _useState2[0],
|
|
65
69
|
nav = _useState2[1];
|
|
66
70
|
|
|
67
|
-
var handleNavigate = (0,
|
|
71
|
+
var handleNavigate = (0, _react2.useCallback)(function (ev) {
|
|
68
72
|
return nav(ev.path);
|
|
69
73
|
}, [nav]);
|
|
70
74
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(Views, _objectSpread(_objectSpread({}, props), {}, {
|
|
@@ -81,15 +85,20 @@ describe('Routable', function () {
|
|
|
81
85
|
}));
|
|
82
86
|
}
|
|
83
87
|
|
|
84
|
-
|
|
85
|
-
|
|
88
|
+
(0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(Sample, {}));
|
|
89
|
+
|
|
90
|
+
var linkToSecondPage = _react.screen.getByText('Page 2'); // click once to navigate to new path
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
_userEvent["default"].click(linkToSecondPage);
|
|
94
|
+
|
|
95
|
+
var secondPage = _react.screen.getByTestId('page2');
|
|
96
|
+
|
|
97
|
+
expect(secondPage).toBeInTheDocument(); // clicking again should use the same base path "/app" for the same result
|
|
86
98
|
|
|
87
|
-
|
|
88
|
-
var actual = subject.find('#page2').length;
|
|
89
|
-
expect(actual).toBe(expected); // clicking again should use the same base path "/app" for the same result
|
|
99
|
+
_userEvent["default"].click(linkToSecondPage);
|
|
90
100
|
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
expect(actual).toBe(expected);
|
|
101
|
+
secondPage = _react.screen.getByTestId('page2');
|
|
102
|
+
expect(secondPage).toBeInTheDocument();
|
|
94
103
|
});
|
|
95
104
|
});
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
require("@testing-library/jest-dom");
|
|
4
|
+
|
|
5
|
+
var _react = require("@testing-library/react");
|
|
4
6
|
|
|
5
7
|
var _Route = _interopRequireDefault(require("../Route"));
|
|
6
8
|
|
|
@@ -43,66 +45,75 @@ describe('Router', function () {
|
|
|
43
45
|
}
|
|
44
46
|
};
|
|
45
47
|
test('should render a single component matching the {path}', function () {
|
|
46
|
-
|
|
48
|
+
(0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(_Router.RouterBase, {
|
|
47
49
|
routes: routes,
|
|
48
50
|
path: "/app"
|
|
49
51
|
}));
|
|
50
|
-
|
|
51
|
-
var
|
|
52
|
-
|
|
52
|
+
|
|
53
|
+
var view = _react.screen.getByRole('button');
|
|
54
|
+
|
|
55
|
+
expect(view).toBeInTheDocument();
|
|
53
56
|
});
|
|
54
57
|
test('should render an array of components matching the {path}', function () {
|
|
55
|
-
|
|
58
|
+
(0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(_Router.RouterBase, {
|
|
56
59
|
routes: routes,
|
|
57
60
|
path: "/app/home"
|
|
58
61
|
}));
|
|
62
|
+
|
|
63
|
+
var view = _react.screen.getAllByRole('button');
|
|
64
|
+
|
|
59
65
|
var expected = 2;
|
|
60
|
-
|
|
61
|
-
expect(actual).toBe(expected);
|
|
66
|
+
expect(view.length).toBe(expected);
|
|
62
67
|
});
|
|
63
68
|
test('should render an array of components matching the {path} as an array', function () {
|
|
64
|
-
|
|
69
|
+
(0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(_Router.RouterBase, {
|
|
65
70
|
routes: routes,
|
|
66
71
|
path: ['app', 'home']
|
|
67
72
|
}));
|
|
73
|
+
|
|
74
|
+
var view = _react.screen.getAllByRole('button');
|
|
75
|
+
|
|
68
76
|
var expected = 2;
|
|
69
|
-
|
|
70
|
-
expect(actual).toBe(expected);
|
|
77
|
+
expect(view.length).toBe(expected);
|
|
71
78
|
});
|
|
72
79
|
test('should render no children if {path} does not exist in {routes}', function () {
|
|
73
80
|
// Modify the console spy to silence error output with
|
|
74
81
|
// an empty mock implementation
|
|
75
82
|
console.error.mockImplementation();
|
|
76
|
-
|
|
83
|
+
(0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(_Router.RouterBase, {
|
|
77
84
|
routes: routes,
|
|
78
85
|
path: "/help"
|
|
79
86
|
}));
|
|
80
|
-
|
|
81
|
-
var
|
|
82
|
-
|
|
87
|
+
|
|
88
|
+
var view = _react.screen.queryByRole('button');
|
|
89
|
+
|
|
90
|
+
expect(view).toBeNull();
|
|
83
91
|
});
|
|
84
92
|
test('should render children into {component}', function () {
|
|
85
93
|
var component = function component(props) {
|
|
86
94
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
87
|
-
|
|
95
|
+
"data-testid": "div1",
|
|
88
96
|
children: /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
89
|
-
|
|
97
|
+
"data-testid": "div2",
|
|
90
98
|
children: props.children
|
|
91
99
|
})
|
|
92
100
|
});
|
|
93
101
|
};
|
|
94
102
|
|
|
95
|
-
|
|
103
|
+
(0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(_Router.Router, {
|
|
96
104
|
routes: routes,
|
|
97
105
|
path: "/app/settings",
|
|
98
106
|
component: component
|
|
99
107
|
}));
|
|
108
|
+
|
|
109
|
+
var secondDiv = _react.screen.getByTestId('div2');
|
|
110
|
+
|
|
100
111
|
var expected = 2;
|
|
101
|
-
var actual =
|
|
112
|
+
var actual = secondDiv.childElementCount;
|
|
102
113
|
expect(actual).toBe(expected);
|
|
103
114
|
});
|
|
104
115
|
test('should render an array of components matching the {path} using JSX routes', function () {
|
|
105
|
-
|
|
116
|
+
(0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsxs)(_Router.Router, {
|
|
106
117
|
path: "/app/home",
|
|
107
118
|
children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)(_Route["default"], {
|
|
108
119
|
path: "app",
|
|
@@ -119,12 +130,15 @@ describe('Router', function () {
|
|
|
119
130
|
component: View
|
|
120
131
|
})]
|
|
121
132
|
}));
|
|
133
|
+
|
|
134
|
+
var view = _react.screen.getAllByRole('button');
|
|
135
|
+
|
|
122
136
|
var expected = 2;
|
|
123
|
-
var actual =
|
|
137
|
+
var actual = view.length;
|
|
124
138
|
expect(actual).toBe(expected);
|
|
125
139
|
});
|
|
126
140
|
test('should render a different component when the routes change for the same {path}', function () {
|
|
127
|
-
var
|
|
141
|
+
var _render = (0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsxs)(_Router.Router, {
|
|
128
142
|
path: "/app",
|
|
129
143
|
children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)(_Route["default"], {
|
|
130
144
|
path: "app",
|
|
@@ -140,28 +154,36 @@ describe('Router', function () {
|
|
|
140
154
|
path: "admin",
|
|
141
155
|
component: View
|
|
142
156
|
})]
|
|
143
|
-
}))
|
|
157
|
+
})),
|
|
158
|
+
rerender = _render.rerender;
|
|
144
159
|
|
|
145
160
|
var NewView = function NewView() {
|
|
146
|
-
return /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
|
|
161
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
|
|
162
|
+
"data-testid": "span"
|
|
163
|
+
});
|
|
147
164
|
};
|
|
148
165
|
|
|
149
|
-
|
|
150
|
-
path:
|
|
151
|
-
children:
|
|
166
|
+
rerender( /*#__PURE__*/(0, _jsxRuntime.jsx)(_Router.Router, {
|
|
167
|
+
path: "/app",
|
|
168
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_Route["default"], {
|
|
152
169
|
path: "app",
|
|
153
|
-
component: NewView
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
170
|
+
component: NewView,
|
|
171
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_Route["default"], {
|
|
172
|
+
path: "app",
|
|
173
|
+
component: NewView
|
|
174
|
+
})
|
|
175
|
+
})
|
|
176
|
+
}));
|
|
177
|
+
|
|
178
|
+
var view = _react.screen.getByTestId('span');
|
|
179
|
+
|
|
180
|
+
expect(view).toBeInTheDocument();
|
|
159
181
|
});
|
|
160
182
|
test('should render nothing for an invalid path', function () {
|
|
161
183
|
// Modify the console spy to silence error output with
|
|
162
184
|
// an empty mock implementation
|
|
163
185
|
console.error.mockImplementation();
|
|
164
|
-
|
|
186
|
+
(0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsxs)(_Router.Router, {
|
|
165
187
|
path: "/does/not/exist",
|
|
166
188
|
children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)(_Route["default"], {
|
|
167
189
|
path: "app",
|
|
@@ -178,15 +200,16 @@ describe('Router', function () {
|
|
|
178
200
|
component: View
|
|
179
201
|
})]
|
|
180
202
|
}));
|
|
181
|
-
|
|
182
|
-
var
|
|
183
|
-
|
|
203
|
+
|
|
204
|
+
var view = _react.screen.queryByRole('button');
|
|
205
|
+
|
|
206
|
+
expect(view).toBeNull();
|
|
184
207
|
});
|
|
185
208
|
test('should render nothing for a partially valid path', function () {
|
|
186
209
|
// Modify the console spy to silence error output with
|
|
187
210
|
// an empty mock implementation
|
|
188
211
|
console.error.mockImplementation();
|
|
189
|
-
|
|
212
|
+
(0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsxs)(_Router.Router, {
|
|
190
213
|
path: "/app/home/other",
|
|
191
214
|
children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)(_Route["default"], {
|
|
192
215
|
path: "app",
|
|
@@ -203,8 +226,9 @@ describe('Router', function () {
|
|
|
203
226
|
component: View
|
|
204
227
|
})]
|
|
205
228
|
}));
|
|
206
|
-
|
|
207
|
-
var
|
|
208
|
-
|
|
229
|
+
|
|
230
|
+
var view = _react.screen.queryByRole('button');
|
|
231
|
+
|
|
232
|
+
expect(view).toBeNull();
|
|
209
233
|
});
|
|
210
234
|
});
|
package/Scrollable/Scrollable.js
CHANGED
|
@@ -761,7 +761,7 @@ var ScrollableBase = /*#__PURE__*/function (_Component) {
|
|
|
761
761
|
// VirtualList and VirtualGridList DO NOT receive `onscroll` event.
|
|
762
762
|
// Only Scroller could get `onscroll` event.
|
|
763
763
|
|
|
764
|
-
if (!_this.animator.isAnimating() && childRefCurrent && childRefCurrent.containerRef.current && childRefCurrent.getRtlPositionX) {
|
|
764
|
+
if (!_this.animator.isAnimating() && childRefCurrent && childRefCurrent.containerRef.current && childRefCurrent.getRtlPositionX && !_this.isDragging) {
|
|
765
765
|
// For Scroller
|
|
766
766
|
childRefCurrent.containerRef.current.scrollTop = _this.scrollTop;
|
|
767
767
|
childRefCurrent.containerRef.current.scrollLeft = childRefCurrent.getRtlPositionX(_this.scrollLeft);
|
|
@@ -907,6 +907,7 @@ var ScrollableBase = /*#__PURE__*/function (_Component) {
|
|
|
907
907
|
value: // call scroll callbacks
|
|
908
908
|
function forwardScrollEvent(type, reachedEdgeInfo) {
|
|
909
909
|
(0, _handle.forward)(type, {
|
|
910
|
+
type: type,
|
|
910
911
|
scrollLeft: this.scrollLeft,
|
|
911
912
|
scrollTop: this.scrollTop,
|
|
912
913
|
moreInfo: this.getMoreInfo(),
|
|
@@ -389,7 +389,7 @@ var ScrollableBaseNative = /*#__PURE__*/function (_Component) {
|
|
|
389
389
|
}
|
|
390
390
|
|
|
391
391
|
if (_this.props.rtl && canScrollHorizontally) {
|
|
392
|
-
scrollLeft = _platform.platform.ios || _platform.platform.safari || _platform.platform.chrome >= 85 ? -scrollLeft : bounds.maxLeft - scrollLeft;
|
|
392
|
+
scrollLeft = _platform.platform.ios || _platform.platform.safari || _platform.platform.chrome >= 85 || _platform.platform.androidChrome >= 85 ? -scrollLeft : bounds.maxLeft - scrollLeft;
|
|
393
393
|
}
|
|
394
394
|
|
|
395
395
|
if (scrollLeft !== _this.scrollLeft) {
|
|
@@ -929,6 +929,7 @@ var ScrollableBaseNative = /*#__PURE__*/function (_Component) {
|
|
|
929
929
|
value: // call scroll callbacks
|
|
930
930
|
function forwardScrollEvent(type, reachedEdgeInfo) {
|
|
931
931
|
(0, _handle.forward)(type, {
|
|
932
|
+
type: type,
|
|
932
933
|
scrollLeft: this.scrollLeft,
|
|
933
934
|
scrollTop: this.scrollTop,
|
|
934
935
|
moreInfo: this.getMoreInfo(),
|
package/Scroller/Scroller.d.ts
CHANGED
|
@@ -51,7 +51,7 @@ export interface ScrollerBaseProps {
|
|
|
51
51
|
* * {animate} - When `true` , scroll occurs with animation. When `false` , no
|
|
52
52
|
animation occurs.
|
|
53
53
|
* * {focus} - When `true` , attempts to focus item after scroll. Only valid when scrolling
|
|
54
|
-
|
|
54
|
+
by `index` or `node` .
|
|
55
55
|
*
|
|
56
56
|
* Note: Only specify one of: `position` , `align` , `index` or `node`
|
|
57
57
|
*
|
|
@@ -169,7 +169,7 @@ export interface ScrollerProps extends ScrollerBasicProps {
|
|
|
169
169
|
* * {animate} - When `true` , scroll occurs with animation. When `false` , no
|
|
170
170
|
animation occurs.
|
|
171
171
|
* * {focus} - When `true` , attempts to focus item after scroll. Only valid when scrolling
|
|
172
|
-
|
|
172
|
+
by `node` .
|
|
173
173
|
*
|
|
174
174
|
* Note: Only specify one of: `position` , `align` , `node`
|
|
175
175
|
*
|
|
@@ -93,7 +93,7 @@ var ScrollerBasic = /*#__PURE__*/function (_Component) {
|
|
|
93
93
|
|
|
94
94
|
_this.getRtlPositionX = function (x) {
|
|
95
95
|
if (_this.props.rtl) {
|
|
96
|
-
return _platform.platform.ios || _platform.platform.safari || _platform.platform.chrome >= 85 ? -x : _this.scrollBounds.maxLeft - x;
|
|
96
|
+
return _platform.platform.ios || _platform.platform.safari || _platform.platform.chrome >= 85 || _platform.platform.androidChrome >= 85 ? -x : _this.scrollBounds.maxLeft - x;
|
|
97
97
|
}
|
|
98
98
|
|
|
99
99
|
return x;
|
|
@@ -89,7 +89,7 @@ var ScrollerBase = /*#__PURE__*/function (_Component) {
|
|
|
89
89
|
|
|
90
90
|
_this.getRtlPositionX = function (x) {
|
|
91
91
|
if (_this.props.rtl) {
|
|
92
|
-
return _platform.platform.ios || _platform.platform.safari || _platform.platform.chrome >= 85 ? -x : _this.scrollBounds.maxLeft - x;
|
|
92
|
+
return _platform.platform.ios || _platform.platform.safari || _platform.platform.chrome >= 85 || _platform.platform.androidChrome >= 85 ? -x : _this.scrollBounds.maxLeft - x;
|
|
93
93
|
}
|
|
94
94
|
|
|
95
95
|
return x;
|