@enact/ui 4.1.2 → 4.5.0-alpha.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/AnnounceDecorator/Announce.js +9 -9
- package/AnnounceDecorator/AnnounceDecorator.js +6 -4
- 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/AnnounceDecorator/useAnnounce.js +1 -1
- package/BodyText/BodyText.d.ts +1 -1
- package/BodyText/BodyText.js +6 -4
- package/BodyText/tests/BodyText-specs.js +51 -37
- package/Button/Button.d.ts +6 -6
- package/Button/Button.js +11 -7
- package/Button/tests/Button-specs.js +104 -3
- package/CHANGELOG.md +25 -0
- package/Cancelable/Cancelable.js +12 -11
- package/Cancelable/tests/Cancelable-specs.js +133 -70
- package/Changeable/Changeable.js +9 -9
- package/Changeable/tests/Changeable-specs.js +172 -110
- package/ComponentOverride/ComponentOverride.js +6 -4
- package/FloatingLayer/FloatingLayer.js +40 -49
- package/FloatingLayer/FloatingLayer.module.css +3 -0
- package/FloatingLayer/FloatingLayerContainer.js +2 -2
- package/FloatingLayer/FloatingLayerDecorator.js +6 -4
- package/FloatingLayer/Scrim.js +9 -7
- package/FloatingLayer/index.js +1 -1
- package/FloatingLayer/tests/FloatingLayer-specs.js +83 -8
- package/FloatingLayer/tests/Scrim-specs.js +20 -11
- package/FloatingLayer/tests/useFloatingLayerDecorator-specs.js +17 -11
- package/FloatingLayer/useFloatingLayer.js +2 -2
- package/FloatingLayer/useFloatingLayerDecorator.js +1 -1
- package/ForwardRef/ForwardRef.js +3 -3
- package/GridListImageItem/GridListImageItem.d.ts +1 -1
- package/GridListImageItem/GridListImageItem.js +6 -4
- package/Group/Group.d.ts +2 -2
- package/Group/Group.js +7 -4
- package/Group/GroupItem.js +6 -4
- package/Group/tests/Group-specs.js +73 -43
- package/Heading/Heading.d.ts +2 -1
- package/Heading/Heading.js +6 -4
- package/Heading/tests/Heading-specs.js +27 -20
- package/Icon/Icon.d.ts +4 -4
- package/Icon/Icon.js +6 -4
- package/Icon/tests/Icon-specs.js +54 -33
- package/IconButton/IconButton.d.ts +4 -4
- package/IconButton/IconButton.js +6 -4
- package/IconButton/tests/IconButton-specs.js +2 -2
- package/Image/Image.js +6 -4
- package/Image/tests/Image-specs.js +41 -31
- package/ImageItem/ImageItem.js +8 -5
- package/ImageItem/tests/ImageItem-specs.js +75 -72
- package/Item/Item.js +6 -4
- package/Item/tests/Item-specs.js +59 -35
- package/LabeledIcon/LabeledIcon.d.ts +4 -4
- package/LabeledIcon/LabeledIcon.js +6 -4
- package/LabeledIcon/tests/LabeledIcon-specs.js +30 -19
- package/Layout/Cell.js +6 -4
- package/Layout/Layout.d.ts +16 -16
- package/Layout/Layout.js +6 -4
- package/Layout/tests/Layout-specs.js +42 -30
- package/Marquee/MarqueeBase.js +7 -9
- package/Marquee/MarqueeController.js +9 -9
- package/Marquee/MarqueeDecorator.js +18 -13
- package/Marquee/index.d.ts +4 -1
- package/Marquee/index.js +2 -1
- package/Marquee/tests/Marquee-specs.js +254 -122
- package/Measurable/Measurable.js +4 -4
- package/Media/Media.js +10 -10
- package/Placeholder/PlaceholderControllerDecorator.js +9 -9
- package/Placeholder/PlaceholderDecorator.js +9 -9
- package/ProgressBar/ProgressBar.js +6 -4
- package/ProgressBar/tests/ProgressBar-specs.js +60 -42
- package/README.md +1 -1
- package/RadioDecorator/RadioControllerDecorator.js +9 -9
- package/RadioDecorator/RadioDecorator.js +12 -14
- package/RadioDecorator/tests/RadioDecorator-specs.js +179 -65
- package/Repeater/Repeater.d.ts +2 -1
- package/Repeater/Repeater.js +6 -4
- package/Repeater/tests/Repeater-specs.js +90 -49
- package/Resizable/Resizable.js +10 -10
- package/Routable/Link.js +9 -7
- package/Routable/Routable.d.ts +2 -2
- package/Routable/Routable.js +10 -6
- package/Routable/Route.js +1 -1
- package/Routable/Router.js +14 -11
- package/Routable/tests/Routable-specs.js +29 -20
- package/Routable/tests/Router-specs.js +65 -41
- package/Routable/useLink.js +1 -1
- package/Routable/util.js +1 -1
- package/Scrollable/ScrollAnimator.js +2 -2
- package/Scrollable/ScrollThumb.js +3 -3
- package/Scrollable/Scrollable.js +14 -10
- package/Scrollable/ScrollableNative.js +14 -10
- package/Scrollable/Scrollbar.js +14 -8
- package/Scroller/Scroller.d.ts +2 -14
- package/Scroller/Scroller.js +8 -7
- package/Scroller/ScrollerBasic.js +18 -35
- package/Scroller/UiScrollerBase.js +9 -7
- package/Skinnable/Skinnable.js +6 -4
- package/Skinnable/tests/Skinnable-specs.js +104 -56
- package/Skinnable/tests/useSkins-specs.js +39 -44
- package/Skinnable/useSkins.js +1 -1
- package/Slider/Knob.js +6 -4
- package/Slider/PositionDecorator.js +9 -9
- package/Slider/Slider.d.ts +3 -3
- package/Slider/Slider.js +6 -4
- package/Slider/tests/Slider-specs.js +4 -4
- package/SlotItem/SlotItem.d.ts +2 -2
- package/SlotItem/SlotItem.js +6 -4
- package/SlotItem/tests/SlotItem-specs.js +4 -4
- package/Slottable/Slottable.js +3 -3
- package/Slottable/tests/Slottable-specs.js +67 -36
- package/Slottable/tests/useSlots-specs.js +68 -35
- package/Slottable/useSlots.js +6 -4
- package/Spinner/Spinner.d.ts +1 -1
- package/Spinner/Spinner.js +6 -4
- package/Spinner/tests/Spinner-specs.js +46 -31
- package/ToggleIcon/ToggleIcon.js +6 -4
- package/ToggleIcon/tests/ToggleIcon-specs.js +32 -20
- package/ToggleItem/ToggleItem.d.ts +13 -11
- package/ToggleItem/ToggleItem.js +6 -4
- package/ToggleItem/tests/ToggleItem-specs.js +54 -37
- package/Toggleable/Toggle.js +10 -10
- package/Toggleable/Toggleable.js +11 -17
- package/Toggleable/tests/Toggleable-specs.js +464 -324
- package/Toggleable/useToggle.js +4 -2
- package/Touchable/ClickAllow.js +2 -2
- package/Touchable/Drag.js +22 -22
- package/Touchable/Flick.js +22 -18
- package/Touchable/Hold.js +18 -23
- package/Touchable/Touch.js +2 -2
- package/Touchable/Touchable.d.ts +3 -3
- package/Touchable/Touchable.js +7 -4
- package/Touchable/config.js +3 -3
- package/Touchable/tests/Touchable-specs.js +225 -109
- package/Touchable/tests/useTouch-specs.js +163 -86
- package/Touchable/useTouch.js +4 -4
- package/Transition/Transition.d.ts +29 -27
- package/Transition/Transition.js +22 -17
- package/Transition/tests/Transition-specs.js +116 -36
- package/ViewManager/Arranger.js +3 -3
- package/ViewManager/TransitionGroup.js +10 -9
- package/ViewManager/View.js +7 -7
- package/ViewManager/ViewManager.d.ts +4 -4
- package/ViewManager/ViewManager.js +24 -22
- package/ViewManager/tests/View-specs.js +141 -81
- package/ViewManager/tests/ViewManager-specs.js +486 -193
- package/VirtualList/UiVirtualListBase.js +26 -35
- package/VirtualList/VirtualList.d.ts +11 -29
- package/VirtualList/VirtualList.js +10 -9
- package/VirtualList/VirtualListBase.js +1 -1
- package/VirtualList/VirtualListBasic.js +44 -61
- package/VirtualList/tests/VirtualList-specs.js +81 -95
- package/internal/IdProvider/IdProvider.js +3 -3
- package/internal/IdProvider/Provider.js +2 -2
- package/internal/IdProvider/tests/useId-specs.js +37 -20
- package/internal/Pure/Pure.js +9 -9
- package/internal/localized-fonts/localized-fonts.js +1 -1
- package/internal/validators/validators.js +1 -1
- package/package.json +11 -11
- package/resolution/ResolutionDecorator.js +9 -9
- package/resolution/index.js +2 -2
- package/resolution/resolution.js +4 -2
- package/resolution/tests/ResolutionDecorator-specs.js +17 -8
- package/styles/mixins.less +14 -2
- package/useControlledState/tests/useControlledState-specs.js +68 -43
- package/useControlledState/useControlledState.js +2 -2
- package/useScroll/ScrollAnimator.js +2 -2
- package/useScroll/Scrollbar.js +7 -4
- package/useScroll/ScrollbarTrack.js +6 -4
- package/useScroll/useScroll.js +18 -29
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
require("@testing-library/jest-dom");
|
|
4
4
|
|
|
5
|
-
var
|
|
5
|
+
var _react = require("@testing-library/react");
|
|
6
|
+
|
|
7
|
+
var _react2 = require("react");
|
|
6
8
|
|
|
7
9
|
var _ = _interopRequireDefault(require("../"));
|
|
8
10
|
|
|
@@ -12,19 +14,23 @@ var _jsxRuntime = require("react/jsx-runtime");
|
|
|
12
14
|
|
|
13
15
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
14
16
|
|
|
17
|
+
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); } }
|
|
18
|
+
|
|
19
|
+
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); }); }; }
|
|
20
|
+
|
|
15
21
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
16
22
|
|
|
17
23
|
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
|
|
18
24
|
|
|
19
|
-
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
|
|
25
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
20
26
|
|
|
21
|
-
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
|
27
|
+
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
|
22
28
|
|
|
23
29
|
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
24
30
|
|
|
25
31
|
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
26
32
|
|
|
27
|
-
function _possibleConstructorReturn(self, call) { if (call && (typeof call === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
|
|
33
|
+
function _possibleConstructorReturn(self, call) { if (call && (typeof call === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
|
|
28
34
|
|
|
29
35
|
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
30
36
|
|
|
@@ -34,152 +40,196 @@ function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.g
|
|
|
34
40
|
|
|
35
41
|
describe('ViewManager', function () {
|
|
36
42
|
// Suite-wide setup
|
|
43
|
+
beforeEach(function () {
|
|
44
|
+
jest.useFakeTimers();
|
|
45
|
+
});
|
|
46
|
+
afterEach(function () {
|
|
47
|
+
jest.useRealTimers();
|
|
48
|
+
});
|
|
37
49
|
test('should render {component} as its child - <div/> by default', function () {
|
|
38
|
-
|
|
50
|
+
(0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(_["default"], {
|
|
51
|
+
"data-testid": "component",
|
|
39
52
|
children: /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {})
|
|
40
53
|
}));
|
|
41
|
-
var expected =
|
|
42
|
-
|
|
54
|
+
var expected = 'DIV';
|
|
55
|
+
|
|
56
|
+
var actual = _react.screen.getByTestId('component').tagName;
|
|
57
|
+
|
|
43
58
|
expect(actual).toBe(expected);
|
|
44
59
|
});
|
|
45
60
|
test('should render {component} as its child', function () {
|
|
46
|
-
|
|
61
|
+
(0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(_["default"], {
|
|
47
62
|
component: "span",
|
|
63
|
+
"data-testid": "component",
|
|
48
64
|
children: /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {})
|
|
49
65
|
}));
|
|
50
|
-
var expected =
|
|
51
|
-
|
|
66
|
+
var expected = 'SPAN';
|
|
67
|
+
|
|
68
|
+
var actual = _react.screen.getByTestId('component').tagName;
|
|
69
|
+
|
|
52
70
|
expect(actual).toBe(expected);
|
|
53
71
|
});
|
|
54
72
|
test('should render only 1 child view', function () {
|
|
55
|
-
|
|
73
|
+
(0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsxs)(_["default"], {
|
|
56
74
|
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
57
|
-
className: "view",
|
|
58
75
|
children: "View 1"
|
|
59
76
|
}), /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
60
|
-
className: "view",
|
|
61
77
|
children: "View 2"
|
|
62
78
|
}), /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
63
|
-
className: "view",
|
|
64
79
|
children: "View 3"
|
|
65
80
|
}), /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
66
|
-
className: "view",
|
|
67
81
|
children: "View 4"
|
|
68
82
|
}), /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
69
|
-
className: "view",
|
|
70
83
|
children: "View 5"
|
|
71
84
|
})]
|
|
72
85
|
}));
|
|
73
86
|
var expected = 1;
|
|
74
|
-
|
|
87
|
+
|
|
88
|
+
var actual = _react.screen.getAllByText(/View/).length;
|
|
89
|
+
|
|
75
90
|
expect(actual).toBe(expected);
|
|
76
91
|
});
|
|
77
92
|
test('should render the child at {index}', function () {
|
|
78
|
-
|
|
93
|
+
(0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsxs)(_["default"], {
|
|
79
94
|
index: 3,
|
|
80
95
|
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
81
|
-
className: "view",
|
|
82
96
|
children: "View 1"
|
|
83
97
|
}), /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
84
|
-
className: "view",
|
|
85
98
|
children: "View 2"
|
|
86
99
|
}), /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
87
|
-
className: "view",
|
|
88
100
|
children: "View 3"
|
|
89
101
|
}), /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
90
|
-
className: "view",
|
|
91
102
|
children: "View 4"
|
|
92
103
|
}), /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
93
|
-
className: "view",
|
|
94
104
|
children: "View 5"
|
|
95
105
|
})]
|
|
96
106
|
}));
|
|
97
|
-
|
|
98
|
-
var actual =
|
|
99
|
-
|
|
107
|
+
|
|
108
|
+
var actual = _react.screen.getByText('View 4');
|
|
109
|
+
|
|
110
|
+
expect(actual).toBeInTheDocument();
|
|
100
111
|
});
|
|
101
112
|
test('should have 1 child immediately after setting new {index} without an {arranger}', function () {
|
|
102
|
-
var
|
|
113
|
+
var _render = (0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsxs)(_["default"], {
|
|
114
|
+
"data-testid": "viewManager",
|
|
103
115
|
index: 3,
|
|
104
116
|
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
105
|
-
className: "view",
|
|
106
117
|
children: "View 1"
|
|
107
118
|
}), /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
108
|
-
className: "view",
|
|
109
119
|
children: "View 2"
|
|
110
120
|
}), /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
111
|
-
className: "view",
|
|
112
121
|
children: "View 3"
|
|
113
122
|
}), /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
114
|
-
className: "view",
|
|
115
123
|
children: "View 4"
|
|
116
124
|
}), /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
117
|
-
|
|
125
|
+
children: "View 5"
|
|
126
|
+
})]
|
|
127
|
+
})),
|
|
128
|
+
rerender = _render.rerender;
|
|
129
|
+
|
|
130
|
+
rerender( /*#__PURE__*/(0, _jsxRuntime.jsxs)(_["default"], {
|
|
131
|
+
"data-testid": "viewManager",
|
|
132
|
+
index: 4,
|
|
133
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
134
|
+
children: "View 1"
|
|
135
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
136
|
+
children: "View 2"
|
|
137
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
138
|
+
children: "View 3"
|
|
139
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
140
|
+
children: "View 4"
|
|
141
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
118
142
|
children: "View 5"
|
|
119
143
|
})]
|
|
120
144
|
}));
|
|
121
|
-
subject.setProps({
|
|
122
|
-
index: 4
|
|
123
|
-
});
|
|
124
145
|
var expected = 1;
|
|
125
|
-
|
|
146
|
+
|
|
147
|
+
var actual = _react.screen.getByTestId('viewManager').children.length;
|
|
148
|
+
|
|
126
149
|
expect(actual).toBe(expected);
|
|
127
150
|
});
|
|
128
|
-
test('should have 1 child immediately after setting new {index} with an {arranger} and {noAnimation} is
|
|
129
|
-
var
|
|
151
|
+
test('should have 1 child immediately after setting new {index} with an {arranger} and {noAnimation} is true', function () {
|
|
152
|
+
var _render2 = (0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsxs)(_["default"], {
|
|
153
|
+
arranger: _testUtils.MockArranger,
|
|
154
|
+
"data-testid": "viewManager",
|
|
130
155
|
index: 3,
|
|
156
|
+
noAnimation: true,
|
|
157
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
158
|
+
children: "View 1"
|
|
159
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
160
|
+
children: "View 2"
|
|
161
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
162
|
+
children: "View 3"
|
|
163
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
164
|
+
children: "View 4"
|
|
165
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
166
|
+
children: "View 5"
|
|
167
|
+
})]
|
|
168
|
+
})),
|
|
169
|
+
rerender = _render2.rerender;
|
|
170
|
+
|
|
171
|
+
rerender( /*#__PURE__*/(0, _jsxRuntime.jsxs)(_["default"], {
|
|
131
172
|
arranger: _testUtils.MockArranger,
|
|
173
|
+
"data-testid": "viewManager",
|
|
174
|
+
index: 4,
|
|
132
175
|
noAnimation: true,
|
|
133
176
|
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
134
|
-
className: "view",
|
|
135
177
|
children: "View 1"
|
|
136
178
|
}), /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
137
|
-
className: "view",
|
|
138
179
|
children: "View 2"
|
|
139
180
|
}), /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
140
|
-
className: "view",
|
|
141
181
|
children: "View 3"
|
|
142
182
|
}), /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
143
|
-
className: "view",
|
|
144
183
|
children: "View 4"
|
|
145
184
|
}), /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
146
|
-
className: "view",
|
|
147
185
|
children: "View 5"
|
|
148
186
|
})]
|
|
149
187
|
}));
|
|
150
|
-
subject.setProps({
|
|
151
|
-
index: 4
|
|
152
|
-
});
|
|
153
188
|
var expected = 1;
|
|
154
|
-
|
|
189
|
+
|
|
190
|
+
var actual = _react.screen.getByTestId('viewManager').children.length;
|
|
191
|
+
|
|
155
192
|
expect(actual).toBe(expected);
|
|
156
193
|
});
|
|
157
194
|
test('should have 2 children immediately after setting new {index} with an {arranger}', function () {
|
|
158
|
-
var
|
|
195
|
+
var _render3 = (0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsxs)(_["default"], {
|
|
196
|
+
arranger: _testUtils.MockArranger,
|
|
197
|
+
"data-testid": "viewManager",
|
|
159
198
|
index: 3,
|
|
199
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
200
|
+
children: "View 1"
|
|
201
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
202
|
+
children: "View 2"
|
|
203
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
204
|
+
children: "View 3"
|
|
205
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
206
|
+
children: "View 4"
|
|
207
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
208
|
+
children: "View 5"
|
|
209
|
+
})]
|
|
210
|
+
})),
|
|
211
|
+
rerender = _render3.rerender;
|
|
212
|
+
|
|
213
|
+
rerender( /*#__PURE__*/(0, _jsxRuntime.jsxs)(_["default"], {
|
|
160
214
|
arranger: _testUtils.MockArranger,
|
|
215
|
+
"data-testid": "viewManager",
|
|
216
|
+
index: 4,
|
|
161
217
|
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
162
|
-
className: "view",
|
|
163
218
|
children: "View 1"
|
|
164
219
|
}), /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
165
|
-
className: "view",
|
|
166
220
|
children: "View 2"
|
|
167
221
|
}), /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
168
|
-
className: "view",
|
|
169
222
|
children: "View 3"
|
|
170
223
|
}), /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
171
|
-
className: "view",
|
|
172
224
|
children: "View 4"
|
|
173
225
|
}), /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
174
|
-
className: "view",
|
|
175
226
|
children: "View 5"
|
|
176
227
|
})]
|
|
177
228
|
}));
|
|
178
|
-
subject.setProps({
|
|
179
|
-
index: 4
|
|
180
|
-
});
|
|
181
229
|
var expected = 2;
|
|
182
|
-
|
|
230
|
+
|
|
231
|
+
var actual = _react.screen.getByTestId('viewManager').children.length;
|
|
232
|
+
|
|
183
233
|
expect(actual).toBe(expected);
|
|
184
234
|
});
|
|
185
235
|
test('should allow child props to update', function () {
|
|
@@ -201,7 +251,7 @@ describe('ViewManager', function () {
|
|
|
201
251
|
value: function render() {
|
|
202
252
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_["default"], {
|
|
203
253
|
children: /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
204
|
-
|
|
254
|
+
"data-testid": "view",
|
|
205
255
|
children: this.props.content
|
|
206
256
|
})
|
|
207
257
|
});
|
|
@@ -209,55 +259,99 @@ describe('ViewManager', function () {
|
|
|
209
259
|
}]);
|
|
210
260
|
|
|
211
261
|
return ViewManagerTest;
|
|
212
|
-
}(
|
|
262
|
+
}(_react2.Component);
|
|
213
263
|
|
|
214
|
-
var
|
|
264
|
+
var _render4 = (0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(ViewManagerTest, {
|
|
215
265
|
content: "original"
|
|
216
|
-
}))
|
|
217
|
-
|
|
266
|
+
})),
|
|
267
|
+
rerender = _render4.rerender;
|
|
268
|
+
|
|
269
|
+
rerender( /*#__PURE__*/(0, _jsxRuntime.jsx)(ViewManagerTest, {
|
|
218
270
|
content: content
|
|
219
|
-
});
|
|
271
|
+
}));
|
|
220
272
|
var expected = content;
|
|
221
|
-
|
|
273
|
+
|
|
274
|
+
var actual = _react.screen.getByTestId('view').textContent;
|
|
275
|
+
|
|
222
276
|
expect(actual).toBe(expected);
|
|
223
277
|
});
|
|
224
278
|
test('should have 1 child {duration}ms after setting new {index}', function (done) {
|
|
225
279
|
var duration = 50;
|
|
226
|
-
|
|
280
|
+
|
|
281
|
+
var _render5 = (0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsxs)(_["default"], {
|
|
282
|
+
"data-testid": "viewManager",
|
|
283
|
+
duration: duration,
|
|
227
284
|
index: 3,
|
|
285
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
286
|
+
children: "View 1"
|
|
287
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
288
|
+
children: "View 2"
|
|
289
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
290
|
+
children: "View 3"
|
|
291
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
292
|
+
children: "View 4"
|
|
293
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
294
|
+
children: "View 5"
|
|
295
|
+
})]
|
|
296
|
+
})),
|
|
297
|
+
rerender = _render5.rerender;
|
|
298
|
+
|
|
299
|
+
rerender( /*#__PURE__*/(0, _jsxRuntime.jsxs)(_["default"], {
|
|
300
|
+
"data-testid": "viewManager",
|
|
228
301
|
duration: duration,
|
|
302
|
+
index: 4,
|
|
229
303
|
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
230
|
-
className: "view",
|
|
231
304
|
children: "View 1"
|
|
232
305
|
}), /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
233
|
-
className: "view",
|
|
234
306
|
children: "View 2"
|
|
235
307
|
}), /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
236
|
-
className: "view",
|
|
237
308
|
children: "View 3"
|
|
238
309
|
}), /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
239
|
-
className: "view",
|
|
240
310
|
children: "View 4"
|
|
241
311
|
}), /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
242
|
-
className: "view",
|
|
243
312
|
children: "View 5"
|
|
244
313
|
})]
|
|
245
314
|
}));
|
|
246
|
-
|
|
247
|
-
|
|
315
|
+
(0, _react.act)(function () {
|
|
316
|
+
return jest.advanceTimersByTime(duration + 10);
|
|
248
317
|
});
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
318
|
+
var expected = 1;
|
|
319
|
+
|
|
320
|
+
var actual = _react.screen.getByTestId('viewManager').children.length;
|
|
321
|
+
|
|
322
|
+
expect(actual).toBe(expected);
|
|
323
|
+
done();
|
|
255
324
|
});
|
|
256
|
-
test('should have
|
|
257
|
-
|
|
258
|
-
|
|
325
|
+
test('should have 1 child when noAnimation is true', function () {
|
|
326
|
+
(0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsxs)(_["default"], {
|
|
327
|
+
"data-testid": "viewManager",
|
|
328
|
+
duration: 0,
|
|
259
329
|
index: 0,
|
|
330
|
+
noAnimation: true,
|
|
331
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
332
|
+
children: "View 1"
|
|
333
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
334
|
+
children: "View 2"
|
|
335
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
336
|
+
children: "View 3"
|
|
337
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
338
|
+
children: "View 4"
|
|
339
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
340
|
+
children: "View 5"
|
|
341
|
+
})]
|
|
342
|
+
}));
|
|
343
|
+
var expected = 1;
|
|
344
|
+
|
|
345
|
+
var actual = _react.screen.getByTestId('viewManager').children.length;
|
|
346
|
+
|
|
347
|
+
expect(actual).toBe(expected);
|
|
348
|
+
}); // TODO cannot read props of child components
|
|
349
|
+
|
|
350
|
+
test.skip('should update the View reverseTransition prop.', function () {
|
|
351
|
+
var _render6 = (0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsxs)(_["default"], {
|
|
260
352
|
duration: 0,
|
|
353
|
+
index: 0,
|
|
354
|
+
noAnimation: true,
|
|
261
355
|
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
262
356
|
className: "view",
|
|
263
357
|
children: "View 1"
|
|
@@ -274,16 +368,14 @@ describe('ViewManager', function () {
|
|
|
274
368
|
className: "view",
|
|
275
369
|
children: "View 5"
|
|
276
370
|
})]
|
|
277
|
-
}))
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
});
|
|
282
|
-
test('should update the View reverseTransition prop.', function () {
|
|
283
|
-
var subject = (0, _enzyme.mount)( /*#__PURE__*/(0, _jsxRuntime.jsxs)(_["default"], {
|
|
284
|
-
noAnimation: true,
|
|
285
|
-
index: 0,
|
|
371
|
+
})),
|
|
372
|
+
rerender = _render6.rerender;
|
|
373
|
+
|
|
374
|
+
rerender( /*#__PURE__*/(0, _jsxRuntime.jsxs)(_["default"], {
|
|
286
375
|
duration: 0,
|
|
376
|
+
index: 0,
|
|
377
|
+
noAnimation: true,
|
|
378
|
+
reverseTransition: true,
|
|
287
379
|
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
288
380
|
className: "view",
|
|
289
381
|
children: "View 1"
|
|
@@ -300,18 +392,15 @@ describe('ViewManager', function () {
|
|
|
300
392
|
className: "view",
|
|
301
393
|
children: "View 5"
|
|
302
394
|
})]
|
|
303
|
-
}));
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
});
|
|
310
|
-
test('should update the View reverseTransition prop to true if it is updated with a smaller index prop.', function () {
|
|
311
|
-
var subject = (0, _enzyme.mount)( /*#__PURE__*/(0, _jsxRuntime.jsxs)(_["default"], {
|
|
312
|
-
index: 2,
|
|
313
|
-
duration: 0,
|
|
395
|
+
})); // const actual = subject.find('View').props().reverseTransition;
|
|
396
|
+
// expect(actual).toBeTruthy();
|
|
397
|
+
}); // TODO cannot read props of child components
|
|
398
|
+
|
|
399
|
+
test.skip('should update the View reverseTransition prop to true if it is updated with a smaller index prop.', function () {
|
|
400
|
+
var _render7 = (0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsxs)(_["default"], {
|
|
314
401
|
arranger: _testUtils.MockArranger,
|
|
402
|
+
duration: 0,
|
|
403
|
+
index: 2,
|
|
315
404
|
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
316
405
|
children: "View 1"
|
|
317
406
|
}), /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
@@ -323,18 +412,33 @@ describe('ViewManager', function () {
|
|
|
323
412
|
}), /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
324
413
|
children: "View 5"
|
|
325
414
|
})]
|
|
326
|
-
}))
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
expect(actual).toBeTruthy();
|
|
332
|
-
});
|
|
333
|
-
test('should update the View reverseTransition prop to false even though it is updated with a smaller index prop.', function () {
|
|
334
|
-
var subject = (0, _enzyme.mount)( /*#__PURE__*/(0, _jsxRuntime.jsxs)(_["default"], {
|
|
335
|
-
index: 2,
|
|
415
|
+
})),
|
|
416
|
+
rerender = _render7.rerender;
|
|
417
|
+
|
|
418
|
+
rerender( /*#__PURE__*/(0, _jsxRuntime.jsxs)(_["default"], {
|
|
419
|
+
arranger: _testUtils.MockArranger,
|
|
336
420
|
duration: 0,
|
|
421
|
+
index: 1,
|
|
422
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
423
|
+
children: "View 1"
|
|
424
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
425
|
+
children: "View 2"
|
|
426
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
427
|
+
children: "View 3"
|
|
428
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
429
|
+
children: "View 4"
|
|
430
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
431
|
+
children: "View 5"
|
|
432
|
+
})]
|
|
433
|
+
})); // const actual = subject.find('View').at(0).props().reverseTransition;
|
|
434
|
+
// expect(actual).toBeTruthy();
|
|
435
|
+
}); // TODO cannot read props of child components
|
|
436
|
+
|
|
437
|
+
test.skip('should update the View reverseTransition prop to false even though it is updated with a smaller index prop.', function () {
|
|
438
|
+
var _render8 = (0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsxs)(_["default"], {
|
|
337
439
|
arranger: _testUtils.MockArranger,
|
|
440
|
+
duration: 0,
|
|
441
|
+
index: 2,
|
|
338
442
|
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
339
443
|
children: "View 1"
|
|
340
444
|
}), /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
@@ -342,53 +446,91 @@ describe('ViewManager', function () {
|
|
|
342
446
|
}), /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
343
447
|
children: "View 3"
|
|
344
448
|
})]
|
|
345
|
-
}))
|
|
346
|
-
|
|
449
|
+
})),
|
|
450
|
+
rerender = _render8.rerender;
|
|
451
|
+
|
|
452
|
+
rerender( /*#__PURE__*/(0, _jsxRuntime.jsxs)(_["default"], {
|
|
453
|
+
arranger: _testUtils.MockArranger,
|
|
454
|
+
duration: 0,
|
|
347
455
|
index: 1,
|
|
348
|
-
reverseTransition: false
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
456
|
+
reverseTransition: false,
|
|
457
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
458
|
+
children: "View 1"
|
|
459
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
460
|
+
children: "View 2"
|
|
461
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
462
|
+
children: "View 3"
|
|
463
|
+
})]
|
|
464
|
+
})); // const actual = subject.find('View').at(0).props().reverseTransition;
|
|
465
|
+
// expect(actual).toBeFalsy();
|
|
352
466
|
});
|
|
353
467
|
test('should update the view when children are reordered', function () {
|
|
354
|
-
var
|
|
468
|
+
var _render9 = (0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsxs)(_["default"], {
|
|
355
469
|
index: 1,
|
|
356
470
|
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
357
471
|
children: "View 1"
|
|
358
472
|
}, "view1"), /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
359
473
|
children: "View 2"
|
|
360
474
|
}, "view2")]
|
|
361
|
-
}))
|
|
362
|
-
|
|
363
|
-
|
|
475
|
+
})),
|
|
476
|
+
rerender = _render9.rerender;
|
|
477
|
+
|
|
478
|
+
expect(_react.screen.getByText('View 2')).toBeInTheDocument();
|
|
479
|
+
rerender( /*#__PURE__*/(0, _jsxRuntime.jsxs)(_["default"], {
|
|
480
|
+
index: 1,
|
|
364
481
|
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
365
482
|
children: "View 2"
|
|
366
483
|
}, "view2"), /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
367
484
|
children: "View 1"
|
|
368
485
|
}, "view1")]
|
|
369
|
-
});
|
|
370
|
-
expect(
|
|
486
|
+
}));
|
|
487
|
+
expect(_react.screen.getByText('View 1')).toBeInTheDocument();
|
|
371
488
|
});
|
|
372
489
|
test('should update the view when children are replaced', function () {
|
|
373
|
-
var
|
|
490
|
+
var _render10 = (0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(_["default"], {
|
|
374
491
|
index: 0,
|
|
375
492
|
children: /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
376
493
|
children: "View 1"
|
|
377
494
|
}, "view1")
|
|
378
|
-
}))
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
495
|
+
})),
|
|
496
|
+
rerender = _render10.rerender;
|
|
497
|
+
|
|
498
|
+
expect(_react.screen.getByText('View 1')).toBeInTheDocument();
|
|
499
|
+
rerender( /*#__PURE__*/(0, _jsxRuntime.jsx)(_["default"], {
|
|
500
|
+
index: 0,
|
|
501
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
382
502
|
children: "View 2"
|
|
383
|
-
}, "view2")
|
|
384
|
-
});
|
|
385
|
-
expect(
|
|
503
|
+
}, "view2")
|
|
504
|
+
}));
|
|
505
|
+
expect(_react.screen.getByText('View 2')).toBeInTheDocument();
|
|
386
506
|
});
|
|
387
507
|
test('should update the number of views when {start} updates', function () {
|
|
388
|
-
var
|
|
508
|
+
var _render11 = (0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsxs)(_["default"], {
|
|
509
|
+
"data-testid": "viewManager",
|
|
510
|
+
end: 3,
|
|
389
511
|
index: 3,
|
|
390
512
|
start: 2,
|
|
513
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
514
|
+
children: "View 1"
|
|
515
|
+
}, "view1"), /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
516
|
+
children: "View 2"
|
|
517
|
+
}, "view2"), /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
518
|
+
children: "View 3"
|
|
519
|
+
}, "view3"), /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
520
|
+
children: "View 4"
|
|
521
|
+
}, "view4")]
|
|
522
|
+
})),
|
|
523
|
+
rerender = _render11.rerender;
|
|
524
|
+
|
|
525
|
+
var children = _react.screen.getByTestId('viewManager').children;
|
|
526
|
+
|
|
527
|
+
expect(children).toHaveLength(2);
|
|
528
|
+
expect(children.item(0)).toHaveTextContent('View 3');
|
|
529
|
+
rerender( /*#__PURE__*/(0, _jsxRuntime.jsxs)(_["default"], {
|
|
530
|
+
"data-testid": "viewManager",
|
|
391
531
|
end: 3,
|
|
532
|
+
index: 3,
|
|
533
|
+
start: 1,
|
|
392
534
|
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
393
535
|
children: "View 1"
|
|
394
536
|
}, "view1"), /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
@@ -399,19 +541,15 @@ describe('ViewManager', function () {
|
|
|
399
541
|
children: "View 4"
|
|
400
542
|
}, "view4")]
|
|
401
543
|
}));
|
|
402
|
-
expect(
|
|
403
|
-
expect(
|
|
404
|
-
subject.setProps({
|
|
405
|
-
start: 1
|
|
406
|
-
});
|
|
407
|
-
expect(subject.find('View')).toHaveLength(3);
|
|
408
|
-
expect(subject.find('View div').at(0).prop('children')).toBe('View 2');
|
|
544
|
+
expect(children).toHaveLength(3);
|
|
545
|
+
expect(children.item(0)).toHaveTextContent('View 2');
|
|
409
546
|
});
|
|
410
547
|
test('should update the active view when {start}, {end}, and {index} update', function () {
|
|
411
|
-
var
|
|
548
|
+
var _render12 = (0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsxs)(_["default"], {
|
|
549
|
+
"data-testid": "viewManager",
|
|
550
|
+
end: 3,
|
|
412
551
|
index: 3,
|
|
413
552
|
start: 3,
|
|
414
|
-
end: 3,
|
|
415
553
|
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
416
554
|
children: "View 1"
|
|
417
555
|
}, "view1"), /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
@@ -421,22 +559,42 @@ describe('ViewManager', function () {
|
|
|
421
559
|
}, "view3"), /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
422
560
|
children: "View 4"
|
|
423
561
|
}, "view4")]
|
|
424
|
-
}))
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
562
|
+
})),
|
|
563
|
+
rerender = _render12.rerender;
|
|
564
|
+
|
|
565
|
+
var children = _react.screen.getByTestId('viewManager').children;
|
|
566
|
+
|
|
567
|
+
var expected = 1;
|
|
568
|
+
expect(children).toHaveLength(expected);
|
|
569
|
+
expect(_react.screen.getByTestId('viewManager')).toHaveTextContent('View 4');
|
|
570
|
+
rerender( /*#__PURE__*/(0, _jsxRuntime.jsxs)(_["default"], {
|
|
571
|
+
"data-testid": "viewManager",
|
|
429
572
|
end: 2,
|
|
430
|
-
index: 2
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
573
|
+
index: 2,
|
|
574
|
+
start: 2,
|
|
575
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
576
|
+
children: "View 1"
|
|
577
|
+
}, "view1"), /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
578
|
+
children: "View 2"
|
|
579
|
+
}, "view2"), /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
580
|
+
children: "View 3"
|
|
581
|
+
}, "view3"), /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
582
|
+
children: "View 4"
|
|
583
|
+
}, "view4")]
|
|
584
|
+
}));
|
|
585
|
+
|
|
586
|
+
var newChildren = _react.screen.getByTestId('viewManager').children;
|
|
587
|
+
|
|
588
|
+
var newExpected = 1;
|
|
589
|
+
expect(newChildren).toHaveLength(newExpected);
|
|
590
|
+
expect(_react.screen.getByTestId('viewManager')).toHaveTextContent('View 3');
|
|
434
591
|
});
|
|
435
592
|
test('should extend the view range when {index} is less than {start}', function () {
|
|
436
|
-
|
|
593
|
+
(0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsxs)(_["default"], {
|
|
594
|
+
"data-testid": "viewManager",
|
|
595
|
+
end: 3,
|
|
437
596
|
index: 1,
|
|
438
597
|
start: 2,
|
|
439
|
-
end: 3,
|
|
440
598
|
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
441
599
|
children: "View 1"
|
|
442
600
|
}, "view1"), /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
@@ -447,13 +605,17 @@ describe('ViewManager', function () {
|
|
|
447
605
|
children: "View 4"
|
|
448
606
|
}, "view4")]
|
|
449
607
|
}));
|
|
450
|
-
|
|
608
|
+
|
|
609
|
+
var children = _react.screen.getByTestId('viewManager').children;
|
|
610
|
+
|
|
611
|
+
var expected = 3;
|
|
612
|
+
expect(children).toHaveLength(expected);
|
|
451
613
|
});
|
|
452
614
|
test('should extend the view range when {index} is greater than {end}', function () {
|
|
453
|
-
|
|
615
|
+
(0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsxs)(_["default"], {
|
|
616
|
+
end: 2,
|
|
454
617
|
index: 3,
|
|
455
618
|
start: 1,
|
|
456
|
-
end: 2,
|
|
457
619
|
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
458
620
|
children: "View 1"
|
|
459
621
|
}, "view1"), /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
@@ -464,12 +626,99 @@ describe('ViewManager', function () {
|
|
|
464
626
|
children: "View 4"
|
|
465
627
|
}, "view4")]
|
|
466
628
|
}));
|
|
467
|
-
|
|
629
|
+
|
|
630
|
+
var children = _react.screen.getAllByText(/View/);
|
|
631
|
+
|
|
632
|
+
var expected = 3;
|
|
633
|
+
expect(children).toHaveLength(expected);
|
|
468
634
|
});
|
|
635
|
+
test('should fire onEnter with type once a view has entered', function () {
|
|
636
|
+
var spy = jest.fn();
|
|
637
|
+
|
|
638
|
+
var _render13 = (0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsxs)(_["default"], {
|
|
639
|
+
index: 0,
|
|
640
|
+
noAnimation: true,
|
|
641
|
+
onEnter: spy,
|
|
642
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
643
|
+
children: "View 1"
|
|
644
|
+
}, "view1"), /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
645
|
+
children: "View 2"
|
|
646
|
+
}, "view2")]
|
|
647
|
+
})),
|
|
648
|
+
rerender = _render13.rerender;
|
|
649
|
+
|
|
650
|
+
spy.mockClear();
|
|
651
|
+
rerender( /*#__PURE__*/(0, _jsxRuntime.jsxs)(_["default"], {
|
|
652
|
+
index: 1,
|
|
653
|
+
onEnter: spy,
|
|
654
|
+
noAnimation: true,
|
|
655
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
656
|
+
children: "View 1"
|
|
657
|
+
}, "view1"), /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
658
|
+
children: "View 2"
|
|
659
|
+
}, "view2")]
|
|
660
|
+
}));
|
|
661
|
+
var expected = 1;
|
|
662
|
+
var expectedType = {
|
|
663
|
+
type: 'onEnter'
|
|
664
|
+
};
|
|
665
|
+
var actual = spy.mock.calls.length && spy.mock.calls[0][0];
|
|
666
|
+
expect(spy).toHaveBeenCalledTimes(expected);
|
|
667
|
+
expect(actual).toMatchObject(expectedType);
|
|
668
|
+
});
|
|
669
|
+
test('should fire onAppear with type once a view has appeared', /*#__PURE__*/_asyncToGenerator(function* () {
|
|
670
|
+
var spy = jest.fn();
|
|
671
|
+
|
|
672
|
+
var _render14 = (0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsxs)(_["default"], {
|
|
673
|
+
index: 0,
|
|
674
|
+
noAnimation: true,
|
|
675
|
+
onAppear: spy,
|
|
676
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
677
|
+
children: "View 1"
|
|
678
|
+
}, "view1"), /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
679
|
+
children: "View 2"
|
|
680
|
+
}, "view2")]
|
|
681
|
+
})),
|
|
682
|
+
rerender = _render14.rerender;
|
|
683
|
+
|
|
684
|
+
rerender( /*#__PURE__*/(0, _jsxRuntime.jsxs)(_["default"], {
|
|
685
|
+
index: 1,
|
|
686
|
+
onAppear: spy,
|
|
687
|
+
noAnimation: true,
|
|
688
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
689
|
+
children: "View 1"
|
|
690
|
+
}, "view1"), /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
691
|
+
children: "View 2"
|
|
692
|
+
}, "view2")]
|
|
693
|
+
}));
|
|
694
|
+
yield (0, _react.waitFor)(function () {
|
|
695
|
+
var expected = 1;
|
|
696
|
+
var expectedType = {
|
|
697
|
+
type: 'onAppear'
|
|
698
|
+
};
|
|
699
|
+
var actual = spy.mock.calls.length && spy.mock.calls[0][0];
|
|
700
|
+
expect(spy).toHaveBeenCalledTimes(expected);
|
|
701
|
+
expect(actual).toMatchObject(expectedType);
|
|
702
|
+
});
|
|
703
|
+
}));
|
|
469
704
|
test('should fire onTransition once per transition', function () {
|
|
470
705
|
var spy = jest.fn();
|
|
471
|
-
|
|
706
|
+
|
|
707
|
+
var _render15 = (0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsxs)(_["default"], {
|
|
472
708
|
index: 0,
|
|
709
|
+
noAnimation: true,
|
|
710
|
+
onTransition: spy,
|
|
711
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
712
|
+
children: "View 1"
|
|
713
|
+
}, "view1"), /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
714
|
+
children: "View 2"
|
|
715
|
+
}, "view2")]
|
|
716
|
+
})),
|
|
717
|
+
rerender = _render15.rerender;
|
|
718
|
+
|
|
719
|
+
spy.mockClear();
|
|
720
|
+
rerender( /*#__PURE__*/(0, _jsxRuntime.jsxs)(_["default"], {
|
|
721
|
+
index: 1,
|
|
473
722
|
onTransition: spy,
|
|
474
723
|
noAnimation: true,
|
|
475
724
|
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
@@ -478,18 +727,15 @@ describe('ViewManager', function () {
|
|
|
478
727
|
children: "View 2"
|
|
479
728
|
}, "view2")]
|
|
480
729
|
}));
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
index: 1
|
|
484
|
-
});
|
|
485
|
-
expect(spy).toHaveBeenCalledTimes(1);
|
|
730
|
+
var expected = 1;
|
|
731
|
+
expect(spy).toHaveBeenCalledTimes(expected);
|
|
486
732
|
});
|
|
487
|
-
|
|
733
|
+
test('should not receive onTransition event on mount', function () {
|
|
488
734
|
var spy = jest.fn();
|
|
489
|
-
(0,
|
|
735
|
+
(0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsxs)(_["default"], {
|
|
490
736
|
index: 0,
|
|
491
|
-
onTransition: spy,
|
|
492
737
|
noAnimation: true,
|
|
738
|
+
onTransition: spy,
|
|
493
739
|
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
494
740
|
children: "View 1"
|
|
495
741
|
}, "view1"), /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
@@ -497,13 +743,26 @@ describe('ViewManager', function () {
|
|
|
497
743
|
}, "view2")]
|
|
498
744
|
}));
|
|
499
745
|
var expected = 0;
|
|
500
|
-
|
|
501
|
-
expect(actual).toBe(expected);
|
|
746
|
+
expect(spy).toHaveBeenCalledTimes(expected);
|
|
502
747
|
});
|
|
503
748
|
test('should include the current index and previous index in onTransition event payload', function () {
|
|
504
749
|
var spy = jest.fn();
|
|
505
|
-
|
|
750
|
+
|
|
751
|
+
var _render16 = (0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsxs)(_["default"], {
|
|
506
752
|
index: 0,
|
|
753
|
+
noAnimation: true,
|
|
754
|
+
onTransition: spy,
|
|
755
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
756
|
+
children: "View 1"
|
|
757
|
+
}, "view1"), /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
758
|
+
children: "View 2"
|
|
759
|
+
}, "view2")]
|
|
760
|
+
})),
|
|
761
|
+
rerender = _render16.rerender;
|
|
762
|
+
|
|
763
|
+
spy.mockClear();
|
|
764
|
+
rerender( /*#__PURE__*/(0, _jsxRuntime.jsxs)(_["default"], {
|
|
765
|
+
index: 1,
|
|
507
766
|
onTransition: spy,
|
|
508
767
|
noAnimation: true,
|
|
509
768
|
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
@@ -512,26 +771,44 @@ describe('ViewManager', function () {
|
|
|
512
771
|
children: "View 2"
|
|
513
772
|
}, "view2")]
|
|
514
773
|
}));
|
|
515
|
-
spy.mockClear();
|
|
516
|
-
subject.setProps({
|
|
517
|
-
index: 1
|
|
518
|
-
});
|
|
519
774
|
expect(spy).toHaveBeenLastCalledWith({
|
|
520
775
|
index: 1,
|
|
521
|
-
previousIndex: 0
|
|
522
|
-
|
|
523
|
-
subject.setProps({
|
|
524
|
-
index: 0
|
|
776
|
+
previousIndex: 0,
|
|
777
|
+
type: 'onTransition'
|
|
525
778
|
});
|
|
779
|
+
rerender( /*#__PURE__*/(0, _jsxRuntime.jsxs)(_["default"], {
|
|
780
|
+
index: 0,
|
|
781
|
+
onTransition: spy,
|
|
782
|
+
noAnimation: true,
|
|
783
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
784
|
+
children: "View 1"
|
|
785
|
+
}, "view1"), /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
786
|
+
children: "View 2"
|
|
787
|
+
}, "view2")]
|
|
788
|
+
}));
|
|
526
789
|
expect(spy).toHaveBeenLastCalledWith({
|
|
527
790
|
index: 0,
|
|
528
|
-
previousIndex: 1
|
|
791
|
+
previousIndex: 1,
|
|
792
|
+
type: 'onTransition'
|
|
529
793
|
});
|
|
530
794
|
});
|
|
531
795
|
test('should fire onWillTransition once per transition', function () {
|
|
532
796
|
var spy = jest.fn();
|
|
533
|
-
|
|
797
|
+
|
|
798
|
+
var _render17 = (0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsxs)(_["default"], {
|
|
534
799
|
index: 0,
|
|
800
|
+
noAnimation: true,
|
|
801
|
+
onWillTransition: spy,
|
|
802
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
803
|
+
children: "View 1"
|
|
804
|
+
}, "view1"), /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
805
|
+
children: "View 2"
|
|
806
|
+
}, "view2")]
|
|
807
|
+
})),
|
|
808
|
+
rerender = _render17.rerender;
|
|
809
|
+
|
|
810
|
+
rerender( /*#__PURE__*/(0, _jsxRuntime.jsxs)(_["default"], {
|
|
811
|
+
index: 1,
|
|
535
812
|
onWillTransition: spy,
|
|
536
813
|
noAnimation: true,
|
|
537
814
|
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
@@ -540,15 +817,25 @@ describe('ViewManager', function () {
|
|
|
540
817
|
children: "View 2"
|
|
541
818
|
}, "view2")]
|
|
542
819
|
}));
|
|
543
|
-
subject.setProps({
|
|
544
|
-
index: 1
|
|
545
|
-
});
|
|
546
820
|
expect(spy).toHaveBeenCalledTimes(1);
|
|
547
821
|
});
|
|
548
822
|
test('should include the current index and previous index in onWillTransition event payload', function () {
|
|
549
823
|
var spy = jest.fn();
|
|
550
|
-
|
|
824
|
+
|
|
825
|
+
var _render18 = (0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsxs)(_["default"], {
|
|
551
826
|
index: 0,
|
|
827
|
+
noAnimation: true,
|
|
828
|
+
onWillTransition: spy,
|
|
829
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
830
|
+
children: "View 1"
|
|
831
|
+
}, "view1"), /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
832
|
+
children: "View 2"
|
|
833
|
+
}, "view2")]
|
|
834
|
+
})),
|
|
835
|
+
rerender = _render18.rerender;
|
|
836
|
+
|
|
837
|
+
rerender( /*#__PURE__*/(0, _jsxRuntime.jsxs)(_["default"], {
|
|
838
|
+
index: 1,
|
|
552
839
|
onWillTransition: spy,
|
|
553
840
|
noAnimation: true,
|
|
554
841
|
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
@@ -557,24 +844,30 @@ describe('ViewManager', function () {
|
|
|
557
844
|
children: "View 2"
|
|
558
845
|
}, "view2")]
|
|
559
846
|
}));
|
|
560
|
-
subject.setProps({
|
|
561
|
-
index: 1
|
|
562
|
-
});
|
|
563
847
|
expect(spy).toHaveBeenLastCalledWith({
|
|
564
848
|
index: 1,
|
|
565
|
-
previousIndex: 0
|
|
566
|
-
|
|
567
|
-
subject.setProps({
|
|
568
|
-
index: 0
|
|
849
|
+
previousIndex: 0,
|
|
850
|
+
type: 'onWillTransition'
|
|
569
851
|
});
|
|
852
|
+
rerender( /*#__PURE__*/(0, _jsxRuntime.jsxs)(_["default"], {
|
|
853
|
+
index: 0,
|
|
854
|
+
onWillTransition: spy,
|
|
855
|
+
noAnimation: true,
|
|
856
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
857
|
+
children: "View 1"
|
|
858
|
+
}, "view1"), /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
859
|
+
children: "View 2"
|
|
860
|
+
}, "view2")]
|
|
861
|
+
}));
|
|
570
862
|
expect(spy).toHaveBeenLastCalledWith({
|
|
571
863
|
index: 0,
|
|
572
|
-
previousIndex: 1
|
|
864
|
+
previousIndex: 1,
|
|
865
|
+
type: 'onWillTransition'
|
|
573
866
|
});
|
|
574
867
|
});
|
|
575
868
|
test('should pass `rtl` prop to arranger when `true`', function () {
|
|
576
869
|
var spy = jest.spyOn(_testUtils.MockArranger, 'stay');
|
|
577
|
-
(0,
|
|
870
|
+
(0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsxs)(_["default"], {
|
|
578
871
|
arranger: _testUtils.MockArranger,
|
|
579
872
|
index: 0,
|
|
580
873
|
rtl: true,
|
|
@@ -593,7 +886,7 @@ describe('ViewManager', function () {
|
|
|
593
886
|
});
|
|
594
887
|
test('should pass `rtl` prop to arranger when unset', function () {
|
|
595
888
|
var spy = jest.spyOn(_testUtils.MockArranger, 'stay');
|
|
596
|
-
(0,
|
|
889
|
+
(0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsxs)(_["default"], {
|
|
597
890
|
arranger: _testUtils.MockArranger,
|
|
598
891
|
index: 0,
|
|
599
892
|
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|