@enact/ui 4.1.1 → 4.1.4
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/Button.js +5 -3
- package/Button/tests/Button-specs.js +104 -3
- package/CHANGELOG.md +26 -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/MarqueeDecorator.js +6 -3
- package/Marquee/index.d.ts +4 -1
- package/Marquee/tests/Marquee-specs.js +242 -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 -14
- package/Scroller/ScrollerBasic.js +10 -29
- 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 +11 -9
- package/Transition/tests/Transition-specs.js +111 -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 +11 -21
- package/VirtualList/VirtualList.d.ts +11 -29
- package/VirtualList/VirtualListBasic.js +33 -49
- package/VirtualList/tests/VirtualList-specs.js +29 -61
- 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 +12 -26
|
@@ -1,15 +1,13 @@
|
|
|
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
6
|
|
|
7
|
-
var
|
|
7
|
+
var _Transition = _interopRequireWildcard(require("../Transition"));
|
|
8
8
|
|
|
9
9
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
10
10
|
|
|
11
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
12
|
-
|
|
13
11
|
function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function _getRequireWildcardCache() { return cache; }; return cache; }
|
|
14
12
|
|
|
15
13
|
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
@@ -43,13 +41,15 @@ describe('Transition Specs', function () {
|
|
|
43
41
|
}));
|
|
44
42
|
};
|
|
45
43
|
|
|
46
|
-
|
|
44
|
+
(0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(_Transition["default"], {
|
|
47
45
|
className: className,
|
|
48
46
|
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(ChildNode, {})
|
|
49
47
|
}));
|
|
50
48
|
var expected = className;
|
|
51
|
-
|
|
52
|
-
|
|
49
|
+
|
|
50
|
+
var actual = _react.screen.getByText('Body');
|
|
51
|
+
|
|
52
|
+
expect(actual).toHaveClass(expected);
|
|
53
53
|
}); // NOTE: Feature not yet implemented
|
|
54
54
|
|
|
55
55
|
test.skip('should apply author styles', function () {
|
|
@@ -64,49 +64,126 @@ describe('Transition Specs', function () {
|
|
|
64
64
|
}));
|
|
65
65
|
};
|
|
66
66
|
|
|
67
|
-
|
|
67
|
+
(0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(_Transition["default"], {
|
|
68
68
|
style: styles,
|
|
69
69
|
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(ChildNode, {})
|
|
70
70
|
}));
|
|
71
71
|
var expected = styles;
|
|
72
|
-
|
|
73
|
-
|
|
72
|
+
|
|
73
|
+
var actual = _react.screen.getByText('Body');
|
|
74
|
+
|
|
75
|
+
expect(actual).toHaveStyle(expected);
|
|
74
76
|
});
|
|
75
77
|
test('should apply \'shown\' class when visible', function () {
|
|
76
|
-
|
|
78
|
+
(0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(_Transition.TransitionBase, {
|
|
79
|
+
"data-testid": "transition"
|
|
80
|
+
}));
|
|
77
81
|
var expected = 'shown';
|
|
78
|
-
|
|
79
|
-
|
|
82
|
+
|
|
83
|
+
var actual = _react.screen.getByTestId('transition');
|
|
84
|
+
|
|
85
|
+
expect(actual).toHaveClass(expected);
|
|
80
86
|
});
|
|
81
87
|
test('should apply \'hidden\' class when not visible', function () {
|
|
82
|
-
|
|
88
|
+
(0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(_Transition.TransitionBase, {
|
|
89
|
+
"data-testid": "transition",
|
|
83
90
|
visible: false
|
|
84
91
|
}));
|
|
85
92
|
var expected = 'hidden';
|
|
86
|
-
|
|
87
|
-
|
|
93
|
+
|
|
94
|
+
var actual = _react.screen.getByTestId('transition');
|
|
95
|
+
|
|
96
|
+
expect(actual).toHaveClass(expected);
|
|
88
97
|
});
|
|
89
98
|
test('should apply \'shown\' class when visible with noAnimation', function () {
|
|
90
|
-
|
|
99
|
+
(0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(_Transition.TransitionBase, {
|
|
100
|
+
"data-testid": "transition",
|
|
91
101
|
noAnimation: true
|
|
92
102
|
}));
|
|
93
103
|
var expected = 'shown';
|
|
94
|
-
|
|
95
|
-
|
|
104
|
+
|
|
105
|
+
var actual = _react.screen.getByTestId('transition');
|
|
106
|
+
|
|
107
|
+
expect(actual).toHaveClass(expected);
|
|
96
108
|
});
|
|
97
109
|
test('should apply \'hidden\' class when not visible with noAnimation', function () {
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
noAnimation: true
|
|
110
|
+
(0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(_Transition.TransitionBase, {
|
|
111
|
+
"data-testid": "transition",
|
|
112
|
+
noAnimation: true,
|
|
113
|
+
visible: false
|
|
101
114
|
}));
|
|
102
115
|
var expected = 'hidden';
|
|
103
|
-
|
|
104
|
-
|
|
116
|
+
|
|
117
|
+
var actual = _react.screen.getByTestId('transition');
|
|
118
|
+
|
|
119
|
+
expect(actual).toHaveClass(expected);
|
|
120
|
+
});
|
|
121
|
+
test('should fire \'onShow\' event with type when \'visible\' prop bacomes true ', function () {
|
|
122
|
+
var handleShow = jest.fn();
|
|
123
|
+
|
|
124
|
+
var ChildNode = function ChildNode(props) {
|
|
125
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)("div", _objectSpread(_objectSpread({}, props), {}, {
|
|
126
|
+
children: "Body"
|
|
127
|
+
}));
|
|
128
|
+
};
|
|
129
|
+
|
|
130
|
+
var _render = (0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(_Transition["default"], {
|
|
131
|
+
noAnimation: true,
|
|
132
|
+
onShow: handleShow,
|
|
133
|
+
visible: false,
|
|
134
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(ChildNode, {})
|
|
135
|
+
})),
|
|
136
|
+
rerender = _render.rerender;
|
|
137
|
+
|
|
138
|
+
rerender( /*#__PURE__*/(0, _jsxRuntime.jsx)(_Transition["default"], {
|
|
139
|
+
noAnimation: true,
|
|
140
|
+
onShow: handleShow,
|
|
141
|
+
visible: true,
|
|
142
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(ChildNode, {})
|
|
143
|
+
}));
|
|
144
|
+
var expected = 1;
|
|
145
|
+
var expectedType = {
|
|
146
|
+
type: 'onShow'
|
|
147
|
+
};
|
|
148
|
+
var actual = handleShow.mock.calls.length && handleShow.mock.calls[0][0];
|
|
149
|
+
expect(handleShow).toBeCalledTimes(expected);
|
|
150
|
+
expect(actual).toMatchObject(expectedType);
|
|
151
|
+
});
|
|
152
|
+
test('should fire \'onHide\' event with type when \'visible\' prop bacomes false ', function () {
|
|
153
|
+
var handleHide = jest.fn();
|
|
154
|
+
|
|
155
|
+
var ChildNode = function ChildNode(props) {
|
|
156
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)("div", _objectSpread(_objectSpread({}, props), {}, {
|
|
157
|
+
children: "Body"
|
|
158
|
+
}));
|
|
159
|
+
};
|
|
160
|
+
|
|
161
|
+
var _render2 = (0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(_Transition["default"], {
|
|
162
|
+
noAnimation: true,
|
|
163
|
+
onHide: handleHide,
|
|
164
|
+
visible: true,
|
|
165
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(ChildNode, {})
|
|
166
|
+
})),
|
|
167
|
+
rerender = _render2.rerender;
|
|
168
|
+
|
|
169
|
+
rerender( /*#__PURE__*/(0, _jsxRuntime.jsx)(_Transition["default"], {
|
|
170
|
+
noAnimation: true,
|
|
171
|
+
onHide: handleHide,
|
|
172
|
+
visible: false,
|
|
173
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(ChildNode, {})
|
|
174
|
+
}));
|
|
175
|
+
var expected = 1;
|
|
176
|
+
var expectedType = {
|
|
177
|
+
type: 'onHide'
|
|
178
|
+
};
|
|
179
|
+
var actual = handleHide.mock.calls.length && handleHide.mock.calls[0][0];
|
|
180
|
+
expect(handleHide).toBeCalledTimes(expected);
|
|
181
|
+
expect(actual).toMatchObject(expectedType);
|
|
105
182
|
}); // Tests for prop and className combinations
|
|
106
183
|
|
|
107
|
-
var directionCombination = [[
|
|
108
|
-
var durationCombination = [[
|
|
109
|
-
var timingFunctionCombination = [[
|
|
184
|
+
var directionCombination = [['up', 'up'], ['right', 'right'], ['down', 'down'], ['left', 'left']];
|
|
185
|
+
var durationCombination = [['short', 'short'], ['medium', 'medium'], ['long', 'long']];
|
|
186
|
+
var timingFunctionCombination = [['ease', 'ease'], ['ease-in', 'ease-in'], ['ease-out', 'ease-out'], ['ease-in-out', 'ease-in-out'], ['ease-in-quart', 'ease-in-quart'], ['ease-out-quart', 'ease-out-quart'], ['linear', 'linear']];
|
|
110
187
|
var propStyleCombination = [['duration', durationCombination], ['direction', directionCombination], ['timingFunction', timingFunctionCombination]];
|
|
111
188
|
propStyleCombination.forEach(function (_ref) {
|
|
112
189
|
var _ref2 = _slicedToArray(_ref, 2),
|
|
@@ -121,13 +198,16 @@ describe('Transition Specs', function () {
|
|
|
121
198
|
test("should apply classes for ".concat(prop, "=\"").concat(value, "\""), function () {
|
|
122
199
|
var propValue = _defineProperty({}, prop, value);
|
|
123
200
|
|
|
124
|
-
|
|
201
|
+
(0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(_Transition["default"], _objectSpread(_objectSpread({}, propValue), {}, {
|
|
202
|
+
"data-testid": "transition",
|
|
125
203
|
visible: true,
|
|
126
204
|
children: "Body"
|
|
127
205
|
})));
|
|
128
206
|
var expected = key;
|
|
129
|
-
|
|
130
|
-
|
|
207
|
+
|
|
208
|
+
var actual = _react.screen.getByTestId('transition');
|
|
209
|
+
|
|
210
|
+
expect(actual).toHaveClass(expected);
|
|
131
211
|
});
|
|
132
212
|
});
|
|
133
213
|
});
|
|
@@ -95,8 +95,6 @@ var forwardOnAppear = (0, _handle.forward)('onAppear');
|
|
|
95
95
|
var forwardOnEnter = (0, _handle.forward)('onEnter');
|
|
96
96
|
var forwardOnLeave = (0, _handle.forward)('onLeave');
|
|
97
97
|
var forwardOnStay = (0, _handle.forward)('onStay');
|
|
98
|
-
var forwardOnTransition = (0, _handle.forward)('onTransition');
|
|
99
|
-
var forwardOnWillTransition = (0, _handle.forward)('onWillTransition');
|
|
100
98
|
/**
|
|
101
99
|
* Manages the transition of added and removed child components. Children that are added are
|
|
102
100
|
* transitioned in and those removed are transition out via optional callbacks on the child.
|
|
@@ -141,6 +139,7 @@ var TransitionGroup = /*#__PURE__*/function (_Component) {
|
|
|
141
139
|
}
|
|
142
140
|
|
|
143
141
|
forwardOnAppear({
|
|
142
|
+
type: 'onAppear',
|
|
144
143
|
view: component
|
|
145
144
|
}, _this.props);
|
|
146
145
|
|
|
@@ -178,6 +177,7 @@ var TransitionGroup = /*#__PURE__*/function (_Component) {
|
|
|
178
177
|
}
|
|
179
178
|
|
|
180
179
|
forwardOnEnter({
|
|
180
|
+
type: 'onEnter',
|
|
181
181
|
view: component
|
|
182
182
|
}, _this.props);
|
|
183
183
|
|
|
@@ -204,6 +204,7 @@ var TransitionGroup = /*#__PURE__*/function (_Component) {
|
|
|
204
204
|
}
|
|
205
205
|
|
|
206
206
|
forwardOnStay({
|
|
207
|
+
type: 'onStay',
|
|
207
208
|
view: component
|
|
208
209
|
}, _this.props);
|
|
209
210
|
};
|
|
@@ -230,6 +231,7 @@ var TransitionGroup = /*#__PURE__*/function (_Component) {
|
|
|
230
231
|
}
|
|
231
232
|
|
|
232
233
|
forwardOnLeave({
|
|
234
|
+
type: 'onLeave',
|
|
233
235
|
view: component
|
|
234
236
|
}, _this.props);
|
|
235
237
|
|
|
@@ -358,7 +360,7 @@ var TransitionGroup = /*#__PURE__*/function (_Component) {
|
|
|
358
360
|
});
|
|
359
361
|
|
|
360
362
|
if (this.keysToEnter.length || this.keysToLeave.length) {
|
|
361
|
-
|
|
363
|
+
(0, _handle.forwardCustom)('onWillTransition')(null, this.props);
|
|
362
364
|
} // once the component has been updated, start the enter transition for new children,
|
|
363
365
|
|
|
364
366
|
|
|
@@ -385,7 +387,7 @@ var TransitionGroup = /*#__PURE__*/function (_Component) {
|
|
|
385
387
|
delete this.currentlyTransitioningKeys[key];
|
|
386
388
|
|
|
387
389
|
if (!noForwarding && Object.keys(this.currentlyTransitioningKeys).length === 0) {
|
|
388
|
-
|
|
390
|
+
(0, _handle.forwardCustom)('onTransition')(null, this.props);
|
|
389
391
|
}
|
|
390
392
|
}
|
|
391
393
|
}
|
|
@@ -413,7 +415,6 @@ var TransitionGroup = /*#__PURE__*/function (_Component) {
|
|
|
413
415
|
delete props.componentRef;
|
|
414
416
|
delete props.currentIndex;
|
|
415
417
|
delete props.onAppear;
|
|
416
|
-
delete props.onAppear;
|
|
417
418
|
delete props.onEnter;
|
|
418
419
|
delete props.onLeave;
|
|
419
420
|
delete props.onStay;
|
package/ViewManager/View.js
CHANGED
|
@@ -111,7 +111,7 @@ horizontal direction).
|
|
|
111
111
|
}
|
|
112
112
|
/**
|
|
113
113
|
* The base `ViewManager` component, without
|
|
114
|
-
|
|
114
|
+
[ViewManagerDecorator] applied.
|
|
115
115
|
*/
|
|
116
116
|
|
|
117
117
|
export class ViewManagerBase extends React.Component<
|
|
@@ -135,15 +135,15 @@ export interface ArrangerCallback {
|
|
|
135
135
|
export interface Arranger {
|
|
136
136
|
/**
|
|
137
137
|
* Returns an array of keyframes describing the animation when
|
|
138
|
-
|
|
138
|
+
a view is entering the viewport.
|
|
139
139
|
*/
|
|
140
140
|
enter: ArrangerCallback /**
|
|
141
141
|
* Returns an array of keyframes describing the animation when
|
|
142
|
-
|
|
142
|
+
a view is leaving the viewport.
|
|
143
143
|
*/;
|
|
144
144
|
leave: ArrangerCallback /**
|
|
145
145
|
* Returns an array of keyframes describing the animation when
|
|
146
|
-
|
|
146
|
+
a view is remaining in the viewport.
|
|
147
147
|
*/;
|
|
148
148
|
stay?: ArrangerCallback;
|
|
149
149
|
}
|
|
@@ -98,8 +98,16 @@ var ViewManagerBase = (_temp = _class = /*#__PURE__*/function (_Component) {
|
|
|
98
98
|
_classCallCheck(this, ViewManagerBase);
|
|
99
99
|
|
|
100
100
|
_this = _super.call(this, props);
|
|
101
|
-
|
|
102
|
-
_this.
|
|
101
|
+
|
|
102
|
+
_this.makeTransitionEvent = function () {
|
|
103
|
+
return {
|
|
104
|
+
index: _this.props.index,
|
|
105
|
+
previousIndex: _this.state.prevIndex
|
|
106
|
+
};
|
|
107
|
+
};
|
|
108
|
+
|
|
109
|
+
_this.handleTransition = (0, _handle["default"])((0, _handle.forwardCustom)('onTransition', _this.makeTransitionEvent)).bindAs(_assertThisInitialized(_this), 'handleTransition');
|
|
110
|
+
_this.handleWillTransition = (0, _handle["default"])((0, _handle.forwardCustom)('onWillTransition', _this.makeTransitionEvent)).bindAs(_assertThisInitialized(_this), 'handleWillTransition');
|
|
103
111
|
_this.state = {
|
|
104
112
|
prevIndex: null,
|
|
105
113
|
reverseTransition: null
|
|
@@ -108,14 +116,6 @@ var ViewManagerBase = (_temp = _class = /*#__PURE__*/function (_Component) {
|
|
|
108
116
|
}
|
|
109
117
|
|
|
110
118
|
_createClass(ViewManagerBase, [{
|
|
111
|
-
key: "makeTransitionEvent",
|
|
112
|
-
value: function makeTransitionEvent() {
|
|
113
|
-
return {
|
|
114
|
-
index: this.props.index,
|
|
115
|
-
previousIndex: this.state.prevIndex
|
|
116
|
-
};
|
|
117
|
-
}
|
|
118
|
-
}, {
|
|
119
119
|
key: "render",
|
|
120
120
|
value: function render() {
|
|
121
121
|
var _this$props = this.props,
|
|
@@ -1,170 +1,196 @@
|
|
|
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 _testUtils = require("./test-utils");
|
|
8
10
|
|
|
11
|
+
var _View = _interopRequireDefault(require("../View"));
|
|
12
|
+
|
|
9
13
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
10
14
|
|
|
11
15
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
12
16
|
|
|
13
17
|
describe('View', function () {
|
|
14
18
|
test('should render its child when neither enteringProp or childProps is specified', function () {
|
|
15
|
-
|
|
19
|
+
(0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(_View["default"], {
|
|
16
20
|
duration: 1000,
|
|
17
|
-
children: /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
|
|
21
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
|
|
22
|
+
"data-testid": "span"
|
|
23
|
+
})
|
|
18
24
|
}));
|
|
19
|
-
|
|
20
|
-
var actual =
|
|
21
|
-
|
|
25
|
+
|
|
26
|
+
var actual = _react.screen.getByTestId('span');
|
|
27
|
+
|
|
28
|
+
expect(actual).toBeInTheDocument();
|
|
22
29
|
});
|
|
23
30
|
test('should pass the value of entering to its child in enteringProp', function () {
|
|
24
|
-
|
|
31
|
+
(0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(_View["default"], {
|
|
25
32
|
duration: 1000,
|
|
26
33
|
enteringProp: "data-entering",
|
|
27
|
-
children: /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
|
|
34
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
|
|
35
|
+
"data-testid": "span"
|
|
36
|
+
})
|
|
28
37
|
}));
|
|
29
|
-
var expected = true;
|
|
30
|
-
|
|
31
|
-
|
|
38
|
+
var expected = 'true';
|
|
39
|
+
|
|
40
|
+
var actual = _react.screen.getByTestId('span');
|
|
41
|
+
|
|
42
|
+
expect(actual).toHaveAttribute('data-entering', expected);
|
|
32
43
|
});
|
|
33
44
|
test('should pass enteringProp as false for an appearing view', function () {
|
|
34
45
|
// Views visible on mount are "appearing" and shouldn't perform "entering" logic like
|
|
35
46
|
// deferring children rendering
|
|
36
|
-
|
|
47
|
+
(0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(_View["default"], {
|
|
48
|
+
appearing: true,
|
|
37
49
|
duration: 1000,
|
|
38
50
|
enteringProp: "data-entering",
|
|
39
|
-
|
|
40
|
-
|
|
51
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
|
|
52
|
+
"data-testid": "span"
|
|
53
|
+
})
|
|
41
54
|
}));
|
|
42
|
-
|
|
43
|
-
var actual =
|
|
44
|
-
|
|
55
|
+
|
|
56
|
+
var actual = _react.screen.getByTestId('span');
|
|
57
|
+
|
|
58
|
+
expect(actual).toHaveAttribute('data-entering', 'false');
|
|
45
59
|
});
|
|
46
60
|
describe('imperative API without arranger', function () {
|
|
47
61
|
test('should call callback immediately for "stay"', function () {
|
|
48
62
|
var spy = jest.fn();
|
|
49
|
-
var
|
|
63
|
+
var ref = /*#__PURE__*/(0, _react2.createRef)();
|
|
64
|
+
(0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(_View["default"], {
|
|
50
65
|
duration: 16,
|
|
66
|
+
ref: ref,
|
|
51
67
|
children: /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {})
|
|
52
68
|
}));
|
|
53
|
-
|
|
54
|
-
var expected =
|
|
55
|
-
|
|
56
|
-
expect(actual).toBe(expected);
|
|
69
|
+
ref.current.componentWillStay(spy);
|
|
70
|
+
var expected = 1;
|
|
71
|
+
expect(spy).toHaveBeenCalledTimes(expected);
|
|
57
72
|
});
|
|
58
73
|
test('should call callback immediately for "enter"', function () {
|
|
59
74
|
var spy = jest.fn();
|
|
60
|
-
var
|
|
75
|
+
var ref = /*#__PURE__*/(0, _react2.createRef)();
|
|
76
|
+
(0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(_View["default"], {
|
|
61
77
|
duration: 16,
|
|
78
|
+
ref: ref,
|
|
62
79
|
children: /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {})
|
|
63
80
|
}));
|
|
64
|
-
|
|
65
|
-
var expected =
|
|
66
|
-
|
|
67
|
-
expect(actual).toBe(expected);
|
|
81
|
+
ref.current.componentWillEnter(spy);
|
|
82
|
+
var expected = 1;
|
|
83
|
+
expect(spy).toHaveBeenCalledTimes(expected);
|
|
68
84
|
});
|
|
69
85
|
test('should call callback immediately for "leave"', function () {
|
|
70
86
|
var spy = jest.fn();
|
|
71
|
-
var
|
|
87
|
+
var ref = /*#__PURE__*/(0, _react2.createRef)();
|
|
88
|
+
(0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(_View["default"], {
|
|
72
89
|
duration: 16,
|
|
90
|
+
ref: ref,
|
|
73
91
|
children: /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {})
|
|
74
92
|
}));
|
|
75
|
-
|
|
76
|
-
var expected =
|
|
77
|
-
|
|
78
|
-
expect(actual).toBe(expected);
|
|
93
|
+
ref.current.componentWillLeave(spy);
|
|
94
|
+
var expected = 1;
|
|
95
|
+
expect(spy).toHaveBeenCalledTimes(expected);
|
|
79
96
|
});
|
|
80
97
|
test('should reset entering if a rendered panel re-enters', function () {
|
|
81
98
|
var spy = jest.fn();
|
|
82
|
-
var
|
|
99
|
+
var ref = /*#__PURE__*/(0, _react2.createRef)();
|
|
100
|
+
(0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(_View["default"], {
|
|
83
101
|
duration: 16,
|
|
84
102
|
enteringProp: "data-entering",
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
var firstExpected = false;
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
var
|
|
98
|
-
|
|
103
|
+
ref: ref,
|
|
104
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
|
|
105
|
+
"data-testid": "span"
|
|
106
|
+
})
|
|
107
|
+
}));
|
|
108
|
+
ref.current.componentDidAppear(spy);
|
|
109
|
+
var firstExpected = 'false';
|
|
110
|
+
|
|
111
|
+
var firstSpan = _react.screen.getByTestId('span');
|
|
112
|
+
|
|
113
|
+
expect(firstSpan).toHaveAttribute('data-entering', firstExpected);
|
|
114
|
+
ref.current.componentWillEnter(spy);
|
|
115
|
+
var secondExpected = 'true';
|
|
116
|
+
|
|
117
|
+
var secondSpan = _react.screen.getByTestId('span');
|
|
118
|
+
|
|
119
|
+
expect(secondSpan).toHaveAttribute('data-entering', secondExpected);
|
|
99
120
|
});
|
|
100
121
|
});
|
|
101
122
|
describe('imperative API with arranger', function () {
|
|
102
123
|
test('should call callback for "stay"', function (done) {
|
|
103
|
-
var
|
|
104
|
-
|
|
124
|
+
var ref = /*#__PURE__*/(0, _react2.createRef)();
|
|
125
|
+
(0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(_View["default"], {
|
|
105
126
|
arranger: _testUtils.MockArranger,
|
|
127
|
+
duration: 16,
|
|
128
|
+
ref: ref,
|
|
106
129
|
children: /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {})
|
|
107
130
|
}));
|
|
108
131
|
var spy = jest.fn(function () {
|
|
109
|
-
var expected =
|
|
110
|
-
|
|
111
|
-
expect(actual).toBe(expected);
|
|
132
|
+
var expected = 1;
|
|
133
|
+
expect(spy).toHaveBeenCalledTimes(expected);
|
|
112
134
|
done();
|
|
113
135
|
});
|
|
114
|
-
|
|
136
|
+
ref.current.componentWillStay(spy);
|
|
115
137
|
});
|
|
116
138
|
test('should call callback for "enter"', function (done) {
|
|
117
|
-
var
|
|
118
|
-
|
|
139
|
+
var ref = /*#__PURE__*/(0, _react2.createRef)();
|
|
140
|
+
(0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(_View["default"], {
|
|
119
141
|
arranger: _testUtils.MockArranger,
|
|
142
|
+
duration: 16,
|
|
143
|
+
ref: ref,
|
|
120
144
|
children: /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {})
|
|
121
145
|
}));
|
|
122
146
|
var spy = jest.fn(function () {
|
|
123
|
-
var expected =
|
|
124
|
-
|
|
125
|
-
expect(actual).toBe(expected);
|
|
147
|
+
var expected = 1;
|
|
148
|
+
expect(spy).toHaveBeenCalledTimes(expected);
|
|
126
149
|
done();
|
|
127
150
|
});
|
|
128
|
-
|
|
151
|
+
ref.current.componentWillEnter(spy);
|
|
129
152
|
});
|
|
130
153
|
test('should call callback for "leave"', function (done) {
|
|
131
|
-
var
|
|
132
|
-
|
|
154
|
+
var ref = /*#__PURE__*/(0, _react2.createRef)();
|
|
155
|
+
(0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(_View["default"], {
|
|
133
156
|
arranger: _testUtils.MockArranger,
|
|
157
|
+
duration: 16,
|
|
158
|
+
ref: ref,
|
|
134
159
|
children: /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {})
|
|
135
160
|
}));
|
|
136
161
|
var spy = jest.fn(function () {
|
|
137
|
-
var expected =
|
|
138
|
-
|
|
139
|
-
expect(actual).toBe(expected);
|
|
162
|
+
var expected = 1;
|
|
163
|
+
expect(spy).toHaveBeenCalledTimes(expected);
|
|
140
164
|
done();
|
|
141
165
|
});
|
|
142
|
-
|
|
166
|
+
ref.current.componentWillLeave(spy);
|
|
143
167
|
});
|
|
144
168
|
test('should call callback immediately when {noAnimation}', function () {
|
|
145
169
|
var spy = jest.fn();
|
|
146
|
-
var
|
|
147
|
-
|
|
170
|
+
var ref = /*#__PURE__*/(0, _react2.createRef)();
|
|
171
|
+
(0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(_View["default"], {
|
|
148
172
|
arranger: _testUtils.MockArranger,
|
|
173
|
+
duration: 16,
|
|
149
174
|
noAnimation: true,
|
|
175
|
+
ref: ref,
|
|
150
176
|
children: /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {})
|
|
151
177
|
}));
|
|
152
|
-
|
|
153
|
-
var expected =
|
|
154
|
-
|
|
155
|
-
expect(actual).toBe(expected);
|
|
178
|
+
ref.current.componentWillEnter(spy);
|
|
179
|
+
var expected = 1;
|
|
180
|
+
expect(spy).toHaveBeenCalledTimes(expected);
|
|
156
181
|
});
|
|
157
182
|
test('should call callback immediately for "appear"', function () {
|
|
158
183
|
var spy = jest.fn();
|
|
159
|
-
var
|
|
160
|
-
|
|
184
|
+
var ref = /*#__PURE__*/(0, _react2.createRef)();
|
|
185
|
+
(0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(_View["default"], {
|
|
161
186
|
arranger: _testUtils.MockArranger,
|
|
187
|
+
duration: 16,
|
|
188
|
+
ref: ref,
|
|
162
189
|
children: /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {})
|
|
163
190
|
}));
|
|
164
|
-
|
|
165
|
-
var expected =
|
|
166
|
-
|
|
167
|
-
expect(actual).toBe(expected);
|
|
191
|
+
ref.current.componentWillAppear(spy);
|
|
192
|
+
var expected = 1;
|
|
193
|
+
expect(spy).toHaveBeenCalledTimes(expected);
|
|
168
194
|
});
|
|
169
195
|
});
|
|
170
196
|
describe('arranger API', function () {
|
|
@@ -182,12 +208,14 @@ describe('View', function () {
|
|
|
182
208
|
return {};
|
|
183
209
|
})
|
|
184
210
|
};
|
|
185
|
-
var
|
|
186
|
-
|
|
211
|
+
var ref = /*#__PURE__*/(0, _react2.createRef)();
|
|
212
|
+
(0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(_View["default"], {
|
|
187
213
|
arranger: arranger,
|
|
214
|
+
duration: 1000,
|
|
215
|
+
ref: ref,
|
|
188
216
|
children: /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {})
|
|
189
217
|
}));
|
|
190
|
-
|
|
218
|
+
ref.current.componentWillEnter();
|
|
191
219
|
expect(arranger.enter).toBeCalledWith(arrangerStruct);
|
|
192
220
|
});
|
|
193
221
|
});
|