@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
|
@@ -8,7 +8,7 @@ var _exportNames = {
|
|
|
8
8
|
ViewManagerBase: true,
|
|
9
9
|
ViewManagerDecorator: true
|
|
10
10
|
};
|
|
11
|
-
exports.ViewManagerDecorator = exports.ViewManagerBase = exports.ViewManager =
|
|
11
|
+
exports["default"] = exports.ViewManagerDecorator = exports.ViewManagerBase = exports.ViewManager = void 0;
|
|
12
12
|
|
|
13
13
|
var _propTypes = _interopRequireDefault(require("@enact/core/internal/prop-types"));
|
|
14
14
|
|
|
@@ -40,17 +40,19 @@ var _View = require("./View");
|
|
|
40
40
|
|
|
41
41
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
42
42
|
|
|
43
|
-
var
|
|
43
|
+
var _excluded = ["arranger", "childProps", "children", "duration", "index", "noAnimation", "enteringDelay", "enteringProp", "rtl"];
|
|
44
44
|
|
|
45
|
-
|
|
45
|
+
var _class;
|
|
46
46
|
|
|
47
|
-
function
|
|
47
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
48
|
+
|
|
49
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && 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; }
|
|
48
50
|
|
|
49
51
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
50
52
|
|
|
51
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object);
|
|
53
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
52
54
|
|
|
53
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]
|
|
55
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
54
56
|
|
|
55
57
|
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
56
58
|
|
|
@@ -62,15 +64,15 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
|
|
|
62
64
|
|
|
63
65
|
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); } }
|
|
64
66
|
|
|
65
|
-
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
|
|
67
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
66
68
|
|
|
67
|
-
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); }
|
|
69
|
+
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); }
|
|
68
70
|
|
|
69
71
|
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
70
72
|
|
|
71
73
|
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); }; }
|
|
72
74
|
|
|
73
|
-
function _possibleConstructorReturn(self, call) { if (call && (typeof call === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
|
|
75
|
+
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); }
|
|
74
76
|
|
|
75
77
|
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
76
78
|
|
|
@@ -87,7 +89,7 @@ function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.g
|
|
|
87
89
|
* @ui
|
|
88
90
|
* @public
|
|
89
91
|
*/
|
|
90
|
-
var ViewManagerBase = (
|
|
92
|
+
var ViewManagerBase = (_class = /*#__PURE__*/function (_Component) {
|
|
91
93
|
_inherits(ViewManagerBase, _Component);
|
|
92
94
|
|
|
93
95
|
var _super = _createSuper(ViewManagerBase);
|
|
@@ -98,8 +100,16 @@ var ViewManagerBase = (_temp = _class = /*#__PURE__*/function (_Component) {
|
|
|
98
100
|
_classCallCheck(this, ViewManagerBase);
|
|
99
101
|
|
|
100
102
|
_this = _super.call(this, props);
|
|
101
|
-
|
|
102
|
-
_this.
|
|
103
|
+
|
|
104
|
+
_this.makeTransitionEvent = function () {
|
|
105
|
+
return {
|
|
106
|
+
index: _this.props.index,
|
|
107
|
+
previousIndex: _this.state.prevIndex
|
|
108
|
+
};
|
|
109
|
+
};
|
|
110
|
+
|
|
111
|
+
_this.handleTransition = (0, _handle["default"])((0, _handle.forwardCustom)('onTransition', _this.makeTransitionEvent)).bindAs(_assertThisInitialized(_this), 'handleTransition');
|
|
112
|
+
_this.handleWillTransition = (0, _handle["default"])((0, _handle.forwardCustom)('onWillTransition', _this.makeTransitionEvent)).bindAs(_assertThisInitialized(_this), 'handleWillTransition');
|
|
103
113
|
_this.state = {
|
|
104
114
|
prevIndex: null,
|
|
105
115
|
reverseTransition: null
|
|
@@ -108,14 +118,6 @@ var ViewManagerBase = (_temp = _class = /*#__PURE__*/function (_Component) {
|
|
|
108
118
|
}
|
|
109
119
|
|
|
110
120
|
_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
121
|
key: "render",
|
|
120
122
|
value: function render() {
|
|
121
123
|
var _this$props = this.props,
|
|
@@ -128,7 +130,7 @@ var ViewManagerBase = (_temp = _class = /*#__PURE__*/function (_Component) {
|
|
|
128
130
|
enteringDelay = _this$props.enteringDelay,
|
|
129
131
|
enteringProp = _this$props.enteringProp,
|
|
130
132
|
rtl = _this$props.rtl,
|
|
131
|
-
rest = _objectWithoutProperties(_this$props,
|
|
133
|
+
rest = _objectWithoutProperties(_this$props, _excluded);
|
|
132
134
|
|
|
133
135
|
var _this$props2 = this.props,
|
|
134
136
|
_this$props2$end = _this$props2.end,
|
|
@@ -366,7 +368,7 @@ var ViewManagerBase = (_temp = _class = /*#__PURE__*/function (_Component) {
|
|
|
366
368
|
component: 'div',
|
|
367
369
|
duration: 300,
|
|
368
370
|
index: 0
|
|
369
|
-
},
|
|
371
|
+
}, _class);
|
|
370
372
|
/**
|
|
371
373
|
* Applies ViewManager behaviors.
|
|
372
374
|
*
|
|
@@ -1,170 +1,226 @@
|
|
|
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
|
-
|
|
55
|
-
|
|
56
|
-
|
|
69
|
+
(0, _react.act)(function () {
|
|
70
|
+
return ref.current.componentWillStay(spy);
|
|
71
|
+
});
|
|
72
|
+
var expected = 1;
|
|
73
|
+
expect(spy).toHaveBeenCalledTimes(expected);
|
|
57
74
|
});
|
|
58
75
|
test('should call callback immediately for "enter"', function () {
|
|
59
76
|
var spy = jest.fn();
|
|
60
|
-
var
|
|
77
|
+
var ref = /*#__PURE__*/(0, _react2.createRef)();
|
|
78
|
+
(0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(_View["default"], {
|
|
61
79
|
duration: 16,
|
|
80
|
+
ref: ref,
|
|
62
81
|
children: /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {})
|
|
63
82
|
}));
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
83
|
+
(0, _react.act)(function () {
|
|
84
|
+
return ref.current.componentWillEnter(spy);
|
|
85
|
+
});
|
|
86
|
+
var expected = 1;
|
|
87
|
+
expect(spy).toHaveBeenCalledTimes(expected);
|
|
68
88
|
});
|
|
69
89
|
test('should call callback immediately for "leave"', function () {
|
|
70
90
|
var spy = jest.fn();
|
|
71
|
-
var
|
|
91
|
+
var ref = /*#__PURE__*/(0, _react2.createRef)();
|
|
92
|
+
(0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(_View["default"], {
|
|
72
93
|
duration: 16,
|
|
94
|
+
ref: ref,
|
|
73
95
|
children: /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {})
|
|
74
96
|
}));
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
97
|
+
(0, _react.act)(function () {
|
|
98
|
+
return ref.current.componentWillLeave(spy);
|
|
99
|
+
});
|
|
100
|
+
var expected = 1;
|
|
101
|
+
expect(spy).toHaveBeenCalledTimes(expected);
|
|
79
102
|
});
|
|
80
103
|
test('should reset entering if a rendered panel re-enters', function () {
|
|
104
|
+
jest.useFakeTimers();
|
|
81
105
|
var spy = jest.fn();
|
|
82
|
-
var
|
|
106
|
+
var ref = /*#__PURE__*/(0, _react2.createRef)();
|
|
107
|
+
(0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(_View["default"], {
|
|
83
108
|
duration: 16,
|
|
84
109
|
enteringProp: "data-entering",
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
110
|
+
ref: ref,
|
|
111
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
|
|
112
|
+
"data-testid": "span"
|
|
113
|
+
})
|
|
114
|
+
}));
|
|
115
|
+
(0, _react.act)(function () {
|
|
116
|
+
return ref.current.componentDidAppear(spy);
|
|
117
|
+
});
|
|
118
|
+
var firstExpected = 'false';
|
|
119
|
+
|
|
120
|
+
var firstSpan = _react.screen.getByTestId('span');
|
|
121
|
+
|
|
122
|
+
expect(firstSpan).toHaveAttribute('data-entering', firstExpected);
|
|
123
|
+
(0, _react.act)(function () {
|
|
124
|
+
return ref.current.componentWillEnter(spy);
|
|
125
|
+
});
|
|
126
|
+
var secondExpected = 'true';
|
|
127
|
+
|
|
128
|
+
var secondSpan = _react.screen.getByTestId('span');
|
|
129
|
+
|
|
130
|
+
expect(secondSpan).toHaveAttribute('data-entering', secondExpected);
|
|
99
131
|
});
|
|
100
132
|
});
|
|
101
133
|
describe('imperative API with arranger', function () {
|
|
134
|
+
beforeEach(function () {
|
|
135
|
+
jest.useFakeTimers();
|
|
136
|
+
});
|
|
137
|
+
afterEach(function () {
|
|
138
|
+
jest.useRealTimers();
|
|
139
|
+
});
|
|
102
140
|
test('should call callback for "stay"', function (done) {
|
|
103
|
-
var
|
|
104
|
-
|
|
141
|
+
var ref = /*#__PURE__*/(0, _react2.createRef)();
|
|
142
|
+
(0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(_View["default"], {
|
|
105
143
|
arranger: _testUtils.MockArranger,
|
|
144
|
+
duration: 16,
|
|
145
|
+
ref: ref,
|
|
106
146
|
children: /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {})
|
|
107
147
|
}));
|
|
108
148
|
var spy = jest.fn(function () {
|
|
109
|
-
var expected =
|
|
110
|
-
|
|
111
|
-
expect(actual).toBe(expected);
|
|
149
|
+
var expected = 1;
|
|
150
|
+
expect(spy).toHaveBeenCalledTimes(expected);
|
|
112
151
|
done();
|
|
113
152
|
});
|
|
114
|
-
|
|
153
|
+
(0, _react.act)(function () {
|
|
154
|
+
return ref.current.componentWillStay(spy);
|
|
155
|
+
});
|
|
156
|
+
jest.runAllTimers();
|
|
115
157
|
});
|
|
116
158
|
test('should call callback for "enter"', function (done) {
|
|
117
|
-
var
|
|
118
|
-
|
|
159
|
+
var ref = /*#__PURE__*/(0, _react2.createRef)();
|
|
160
|
+
(0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(_View["default"], {
|
|
119
161
|
arranger: _testUtils.MockArranger,
|
|
162
|
+
duration: 16,
|
|
163
|
+
ref: ref,
|
|
120
164
|
children: /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {})
|
|
121
165
|
}));
|
|
122
166
|
var spy = jest.fn(function () {
|
|
123
|
-
var expected =
|
|
124
|
-
|
|
125
|
-
expect(actual).toBe(expected);
|
|
167
|
+
var expected = 1;
|
|
168
|
+
expect(spy).toHaveBeenCalledTimes(expected);
|
|
126
169
|
done();
|
|
127
170
|
});
|
|
128
|
-
|
|
171
|
+
(0, _react.act)(function () {
|
|
172
|
+
return ref.current.componentWillEnter(spy);
|
|
173
|
+
});
|
|
174
|
+
jest.runAllTimers();
|
|
129
175
|
});
|
|
130
176
|
test('should call callback for "leave"', function (done) {
|
|
131
|
-
var
|
|
132
|
-
|
|
177
|
+
var ref = /*#__PURE__*/(0, _react2.createRef)();
|
|
178
|
+
(0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(_View["default"], {
|
|
133
179
|
arranger: _testUtils.MockArranger,
|
|
180
|
+
duration: 16,
|
|
181
|
+
ref: ref,
|
|
134
182
|
children: /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {})
|
|
135
183
|
}));
|
|
136
184
|
var spy = jest.fn(function () {
|
|
137
|
-
var expected =
|
|
138
|
-
|
|
139
|
-
expect(actual).toBe(expected);
|
|
185
|
+
var expected = 1;
|
|
186
|
+
expect(spy).toHaveBeenCalledTimes(expected);
|
|
140
187
|
done();
|
|
141
188
|
});
|
|
142
|
-
|
|
189
|
+
(0, _react.act)(function () {
|
|
190
|
+
return ref.current.componentWillLeave(spy);
|
|
191
|
+
});
|
|
192
|
+
jest.runAllTimers();
|
|
143
193
|
});
|
|
144
194
|
test('should call callback immediately when {noAnimation}', function () {
|
|
145
195
|
var spy = jest.fn();
|
|
146
|
-
var
|
|
147
|
-
|
|
196
|
+
var ref = /*#__PURE__*/(0, _react2.createRef)();
|
|
197
|
+
(0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(_View["default"], {
|
|
148
198
|
arranger: _testUtils.MockArranger,
|
|
199
|
+
duration: 16,
|
|
149
200
|
noAnimation: true,
|
|
201
|
+
ref: ref,
|
|
150
202
|
children: /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {})
|
|
151
203
|
}));
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
204
|
+
(0, _react.act)(function () {
|
|
205
|
+
return ref.current.componentWillEnter(spy);
|
|
206
|
+
});
|
|
207
|
+
var expected = 1;
|
|
208
|
+
expect(spy).toHaveBeenCalledTimes(expected);
|
|
156
209
|
});
|
|
157
210
|
test('should call callback immediately for "appear"', function () {
|
|
158
211
|
var spy = jest.fn();
|
|
159
|
-
var
|
|
160
|
-
|
|
212
|
+
var ref = /*#__PURE__*/(0, _react2.createRef)();
|
|
213
|
+
(0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(_View["default"], {
|
|
161
214
|
arranger: _testUtils.MockArranger,
|
|
215
|
+
duration: 16,
|
|
216
|
+
ref: ref,
|
|
162
217
|
children: /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {})
|
|
163
218
|
}));
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
219
|
+
(0, _react.act)(function () {
|
|
220
|
+
return ref.current.componentWillAppear(spy);
|
|
221
|
+
});
|
|
222
|
+
var expected = 1;
|
|
223
|
+
expect(spy).toHaveBeenCalledTimes(expected);
|
|
168
224
|
});
|
|
169
225
|
});
|
|
170
226
|
describe('arranger API', function () {
|
|
@@ -182,12 +238,16 @@ describe('View', function () {
|
|
|
182
238
|
return {};
|
|
183
239
|
})
|
|
184
240
|
};
|
|
185
|
-
var
|
|
186
|
-
|
|
241
|
+
var ref = /*#__PURE__*/(0, _react2.createRef)();
|
|
242
|
+
(0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(_View["default"], {
|
|
187
243
|
arranger: arranger,
|
|
244
|
+
duration: 1000,
|
|
245
|
+
ref: ref,
|
|
188
246
|
children: /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {})
|
|
189
247
|
}));
|
|
190
|
-
|
|
248
|
+
(0, _react.act)(function () {
|
|
249
|
+
return ref.current.componentWillEnter();
|
|
250
|
+
});
|
|
191
251
|
expect(arranger.enter).toBeCalledWith(arrangerStruct);
|
|
192
252
|
});
|
|
193
253
|
});
|