@enact/core 4.1.0 → 4.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -2,6 +2,18 @@
2
2
 
3
3
  The following is a curated list of changes in the Enact core module, newest changes on the top.
4
4
 
5
+ ## [4.1.3] - 2022-03-07
6
+
7
+ No significant changes.
8
+
9
+ ## [4.1.2] - 2021-12-22
10
+
11
+ No significant changes.
12
+
13
+ ## [4.1.1] - 2021-11-30
14
+
15
+ No significant changes.
16
+
5
17
  ## [4.1.0] - 2021-11-04
6
18
 
7
19
  No significant changes.
package/README.md CHANGED
@@ -24,7 +24,7 @@ npm test
24
24
 
25
25
  Unless otherwise specified, all content, including all source code files and documentation files in this repository are:
26
26
 
27
- Copyright (c) 2012-2021 LG Electronics
27
+ Copyright (c) 2012-2022 LG Electronics
28
28
 
29
29
  Unless otherwise specified or set forth in the NOTICE file, all content, including all source code files and documentation files in this repository are: Licensed under the Apache License, Version 2.0 (the "License"); you may not use this content except in compliance with the License. You may obtain a copy of the License at
30
30
 
@@ -9,8 +9,7 @@ describe('dispatcher', function () {
9
9
  var ev = new window.CustomEvent('localechange', {});
10
10
  window.dispatchEvent(ev);
11
11
  var expected = 1;
12
- var actual = handler.mock.calls.length;
13
- expect(actual).toBe(expected);
12
+ expect(handler).toHaveBeenCalledTimes(expected);
14
13
  });
15
14
  test('should not register duplicate handlers on target', function () {
16
15
  var handler = jest.fn();
@@ -19,8 +18,7 @@ describe('dispatcher', function () {
19
18
  var ev = new window.CustomEvent('localechange', {});
20
19
  window.dispatchEvent(ev);
21
20
  var expected = 1;
22
- var actual = handler.mock.calls.length;
23
- expect(actual).toBe(expected);
21
+ expect(handler).toHaveBeenCalledTimes(expected);
24
22
  });
25
23
  test('should unregister handlers on target', function () {
26
24
  var handler = jest.fn();
@@ -30,8 +28,7 @@ describe('dispatcher', function () {
30
28
  (0, _dispatcher.off)('localechange', handler, window);
31
29
  window.dispatchEvent(ev);
32
30
  var expected = 1;
33
- var actual = handler.mock.calls.length;
34
- expect(actual).toBe(expected);
31
+ expect(handler).toHaveBeenCalledTimes(expected);
35
32
  });
36
33
  test('should only call a "once" handler once', function () {
37
34
  var handler = jest.fn();
@@ -40,8 +37,7 @@ describe('dispatcher', function () {
40
37
  window.dispatchEvent(ev);
41
38
  window.dispatchEvent(ev);
42
39
  var expected = 1;
43
- var actual = handler.mock.calls.length;
44
- expect(actual).toBe(expected);
40
+ expect(handler).toHaveBeenCalledTimes(expected);
45
41
  });
46
42
  test('should allow unregistering a "once" before it is called', function () {
47
43
  var handler = jest.fn();
@@ -49,9 +45,7 @@ describe('dispatcher', function () {
49
45
  (0, _dispatcher.off)('localechange', onceHandler, window);
50
46
  var ev = new window.CustomEvent('localechange', {});
51
47
  window.dispatchEvent(ev);
52
- var expected = 0;
53
- var actual = handler.mock.calls.length;
54
- expect(actual).toBe(expected);
48
+ expect(handler).not.toHaveBeenCalled();
55
49
  });
56
50
  test('should not block subsequent handlers when a handler throws', function () {
57
51
  // Modify the console spy to silence error output with
@@ -69,7 +63,6 @@ describe('dispatcher', function () {
69
63
  var ev = new window.CustomEvent('localechange', {});
70
64
  window.dispatchEvent(ev);
71
65
  var expected = 1;
72
- var actual = handler.mock.calls.length;
73
- expect(actual).toBe(expected);
66
+ expect(handler).toHaveBeenCalledTimes(expected);
74
67
  });
75
68
  });
@@ -29,50 +29,48 @@ describe('handle', function () {
29
29
  var callback = (0, _handle.handle)(handler);
30
30
  callback(makeEvent());
31
31
  var expected = 1;
32
- var actual = handler.mock.calls.length;
33
- expect(actual).toBe(expected);
32
+ expect(handler).toHaveBeenCalledTimes(expected);
34
33
  });
35
34
  test('should call multiple handlers', function () {
36
35
  var handler1 = jest.fn(returnsTrue);
37
36
  var handler2 = jest.fn(returnsTrue);
38
37
  var callback = (0, _handle.handle)(handler1, handler2);
39
38
  callback(makeEvent());
40
- var expected = true;
41
- var actual = handler1.mock.calls.length === 1 && handler2.mock.calls.length === 1;
42
- expect(actual).toBe(expected);
39
+ var expected = 1;
40
+ expect(handler1).toHaveBeenCalledTimes(expected);
41
+ expect(handler2).toHaveBeenCalledTimes(expected);
43
42
  });
44
43
  test('should skip non-function handlers', function () {
45
44
  var handler = jest.fn(returnsTrue);
46
45
  var callback = (0, _handle.handle)(null, void 0, 0, 'purple', handler);
47
46
  callback(makeEvent());
48
47
  var expected = 1;
49
- var actual = handler.mock.calls.length;
50
- expect(actual).toBe(expected);
48
+ expect(handler).toHaveBeenCalledTimes(expected);
51
49
  });
52
50
  test('should not call handlers after one that returns false', function () {
53
51
  var handler1 = jest.fn(returnsTrue);
54
52
  var handler2 = jest.fn(returnsTrue);
55
53
  var callback = (0, _handle.handle)(handler1, returnsFalse, handler2);
56
54
  callback(makeEvent());
57
- var expected = 0;
58
- var actual = handler2.mock.calls.length;
59
- expect(actual).toBe(expected);
55
+ var expectedFirst = 1;
56
+ expect(handler1).toHaveBeenCalledTimes(expectedFirst);
57
+ expect(handler2).not.toHaveBeenCalled();
60
58
  });
61
59
  test('should call stopPropagation on event', function () {
62
60
  var callback = (0, _handle.handle)(_handle.stop);
63
61
  var ev = makeEvent();
64
62
  callback(ev);
65
63
  var expected = 1;
66
- var actual = ev.stopPropagation.mock.calls.length;
67
- expect(actual).toBe(expected);
64
+ var actual = ev.stopPropagation;
65
+ expect(actual).toHaveBeenCalledTimes(expected);
68
66
  });
69
67
  test('should call preventDefault on event', function () {
70
68
  var callback = (0, _handle.handle)(_handle.preventDefault);
71
69
  var ev = makeEvent();
72
70
  callback(ev);
73
71
  var expected = 1;
74
- var actual = ev.preventDefault.mock.calls.length;
75
- expect(actual).toBe(expected);
72
+ var actual = ev.preventDefault;
73
+ expect(actual).toHaveBeenCalledTimes(expected);
76
74
  });
77
75
  test('should call any method on event', function () {
78
76
  var callback = (0, _handle.handle)((0, _handle.callOnEvent)('customMethod'));
@@ -81,8 +79,8 @@ describe('handle', function () {
81
79
  });
82
80
  callback(ev);
83
81
  var expected = 1;
84
- var actual = ev.customMethod.mock.calls.length;
85
- expect(actual).toBe(expected);
82
+ var actual = ev.customMethod;
83
+ expect(actual).toHaveBeenCalledTimes(expected);
86
84
  });
87
85
  test('should only call handler for specified keyCode', function () {
88
86
  var keyCode = 13;
@@ -96,9 +94,9 @@ describe('handle', function () {
96
94
  expect(handler).toHaveBeenCalled();
97
95
  });
98
96
  test('should only call handler for specified event prop', function () {
97
+ var handler = jest.fn();
99
98
  var prop = 'index';
100
99
  var value = 0;
101
- var handler = jest.fn();
102
100
  var callback = (0, _handle.handle)((0, _handle.forEventProp)(prop, value), handler); // undefined shouldn't pass
103
101
 
104
102
  callback(makeEvent());
@@ -201,16 +199,14 @@ describe('handle', function () {
201
199
  var callback = (0, _handle.handle)(returnsTrue)["finally"](finallyCallback);
202
200
  callback(makeEvent());
203
201
  var expected = 1;
204
- var actual = finallyCallback.mock.calls.length;
205
- expect(actual).toBe(expected);
202
+ expect(finallyCallback).toHaveBeenCalledTimes(expected);
206
203
  });
207
204
  test('should call the finally callback when handle returns false', function () {
208
205
  var finallyCallback = jest.fn();
209
206
  var callback = (0, _handle.handle)(returnsFalse)["finally"](finallyCallback);
210
207
  callback(makeEvent());
211
208
  var expected = 1;
212
- var actual = finallyCallback.mock.calls.length;
213
- expect(actual).toBe(expected);
209
+ expect(finallyCallback).toHaveBeenCalledTimes(expected);
214
210
  });
215
211
  test('should call the finally callback when handle throws an error', function () {
216
212
  var finallyCallback = jest.fn();
@@ -224,8 +220,7 @@ describe('handle', function () {
224
220
  }
225
221
 
226
222
  var expected = 1;
227
- var actual = finallyCallback.mock.calls.length;
228
- expect(actual).toBe(expected);
223
+ expect(finallyCallback).toHaveBeenCalledTimes(expected);
229
224
  });
230
225
  });
231
226
  describe('#oneOf', function () {
@@ -236,16 +231,14 @@ describe('handle', function () {
236
231
  var callback = (0, _handle.oneOf)(h1, h1, h2);
237
232
  callback();
238
233
  var expected = 1;
239
- var actual = handler.mock.calls.length;
240
- expect(actual).toBe(expected);
234
+ expect(handler).toHaveBeenCalledTimes(expected);
241
235
  });
242
236
  test('should stop if the first handler passes', function () {
243
237
  var handler = jest.fn(returnsTrue);
244
238
  var callback = (0, _handle.oneOf)([returnsTrue, handler], [returnsTrue, handler], [returnsTrue, handler]);
245
239
  callback();
246
240
  var expected = 1;
247
- var actual = handler.mock.calls.length;
248
- expect(actual).toBe(expected);
241
+ expect(handler).toHaveBeenCalledTimes(expected);
249
242
  });
250
243
  test('should pass args to condition', function () {
251
244
  var handler = jest.fn(returnsTrue);
@@ -347,8 +340,7 @@ describe('handle', function () {
347
340
  var callback = (0, _handle.oneOf)([returnsFalse, returnsTrue], [returnsFalse, returnsTrue])["finally"](handler);
348
341
  callback();
349
342
  var expected = 1;
350
- var actual = handler.mock.calls.length;
351
- expect(actual).toBe(expected);
343
+ expect(handler).toHaveBeenCalledTimes(expected);
352
344
  });
353
345
  });
354
346
  describe('#adaptEvent', function () {
package/hoc/hoc.d.ts CHANGED
@@ -9,7 +9,8 @@ a factory method that accepts instance configuration parameters and a component
9
9
  returned function can accept:
10
10
  * * an instance config and a component constructor to wrap and return a renderable component, or
11
11
  * * an instance config only and return a decorator function expecting a component constructor
12
- (like the next bullet), or
12
+ *
13
+ * (like the next bullet), or
13
14
  * * a component constructor and return a renderable component
14
15
  *
15
16
  * Example:
@@ -1,6 +1,8 @@
1
1
  "use strict";
2
2
 
3
- var _enzyme = require("enzyme");
3
+ require("@testing-library/jest-dom");
4
+
5
+ var _react = require("@testing-library/react");
4
6
 
5
7
  var _hoc = _interopRequireDefault(require("../hoc"));
6
8
 
@@ -15,81 +17,116 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
15
17
  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; }
16
18
 
17
19
  describe('hoc', function () {
20
+ var data;
21
+ var testID = 'test-HoC';
18
22
  var defaultConfig = {
19
23
  color: 'blue'
20
24
  };
21
25
  var HoC = (0, _hoc["default"])(defaultConfig, function (config, Wrapped) {
26
+ data = Wrapped;
22
27
  return function (props) {
23
- return /*#__PURE__*/(0, _jsxRuntime.jsx)(Wrapped, _objectSpread(_objectSpread({}, props), config));
28
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(Wrapped, _objectSpread(_objectSpread(_objectSpread({}, props), config), {}, {
29
+ "data-testid": testID
30
+ }));
24
31
  };
25
32
  });
26
33
  var NullHoC = (0, _hoc["default"])(null, function (config, Wrapped) {
27
34
  return function () {
28
- return /*#__PURE__*/(0, _jsxRuntime.jsx)(Wrapped, _objectSpread({}, config));
35
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(Wrapped, _objectSpread(_objectSpread({}, config), {}, {
36
+ "data-testid": testID
37
+ }));
29
38
  };
30
39
  });
31
40
  test('should support HoC factory function as first argument to hoc()', function () {
32
41
  var ImplicitNullHoC = (0, _hoc["default"])(function (config, Wrapped) {
33
42
  return function () {
34
- return /*#__PURE__*/(0, _jsxRuntime.jsx)(Wrapped, _objectSpread({}, config));
43
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(Wrapped, _objectSpread(_objectSpread({}, config), {}, {
44
+ "data-testid": testID
45
+ }));
35
46
  };
36
47
  });
37
48
  var Component = ImplicitNullHoC('span');
38
- var subject = (0, _enzyme.shallow)( /*#__PURE__*/(0, _jsxRuntime.jsx)(Component, {}));
39
- var expected = 'span';
40
- var actual = subject.name();
49
+ (0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(Component, {}));
50
+
51
+ var component = _react.screen.getByTestId(testID);
52
+
53
+ var expected = 'SPAN';
54
+ var actual = component.nodeName;
41
55
  expect(actual).toBe(expected);
42
56
  });
43
57
  test('should support DOM node name as first argument to HoC', function () {
44
58
  var Component = HoC('span');
45
- var subject = (0, _enzyme.shallow)( /*#__PURE__*/(0, _jsxRuntime.jsx)(Component, {}));
46
- var expected = 'span';
47
- var actual = subject.name();
59
+ (0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(Component, {}));
60
+
61
+ var component = _react.screen.getByTestId(testID);
62
+
63
+ var expected = 'SPAN';
64
+ var actual = component.nodeName;
48
65
  expect(actual).toBe(expected);
49
66
  });
50
67
  test('should support React component as first argument to HoC', function () {
51
68
  function Thing() {
52
- return /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {});
69
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
70
+ "data-testid": testID
71
+ });
53
72
  }
54
73
 
55
74
  var Component = HoC(Thing);
56
- var subject = (0, _enzyme.shallow)( /*#__PURE__*/(0, _jsxRuntime.jsx)(Component, {}));
57
- var expected = 'Thing';
58
- var actual = subject.name();
75
+ (0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(Component, {}));
76
+
77
+ var component = _react.screen.getByTestId(testID);
78
+
79
+ var expected = 'DIV';
80
+ var actual = component.nodeName;
81
+ var actualWrapped = data;
59
82
  expect(actual).toBe(expected);
83
+ expect(actualWrapped).toBe(Thing);
60
84
  });
61
85
  test('should use default config when instance config is omitted', function () {
62
86
  var Component = HoC('span');
63
- var subject = (0, _enzyme.mount)( /*#__PURE__*/(0, _jsxRuntime.jsx)(Component, {}));
64
- var expected = defaultConfig.color;
65
- var actual = subject.find('span').prop('color');
66
- expect(actual).toBe(expected);
87
+ (0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(Component, {}));
88
+
89
+ var component = _react.screen.getByTestId(testID);
90
+
91
+ var expectedAttribute = 'color';
92
+ var expectedValue = defaultConfig.color;
93
+ expect(component).toHaveAttribute(expectedAttribute, expectedValue);
67
94
  });
68
95
  test('should overwrite default config with instance config', function () {
69
96
  var instanceConfig = {
70
97
  color: 'green'
71
98
  };
72
99
  var Component = HoC(instanceConfig, 'div');
73
- var subject = (0, _enzyme.mount)( /*#__PURE__*/(0, _jsxRuntime.jsx)(Component, {}));
74
- var expected = instanceConfig.color;
75
- var actual = subject.find('div').prop('color');
76
- expect(actual).toBe(expected);
100
+ (0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(Component, {}));
101
+
102
+ var component = _react.screen.getByTestId(testID);
103
+
104
+ var expectedAttribute = 'color';
105
+ var expectedValue = instanceConfig.color;
106
+ expect(component).toHaveAttribute(expectedAttribute, expectedValue);
77
107
  });
78
108
  test('should allow construction without default or instance configs', function () {
79
- var Component = NullHoC('div');
80
- var subject = (0, _enzyme.mount)( /*#__PURE__*/(0, _jsxRuntime.jsx)(Component, {}));
81
- var expected = 1;
82
- var actual = subject.find('div').length;
109
+ var Component = NullHoC('input');
110
+ (0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(Component, {}));
111
+
112
+ var component = _react.screen.getByTestId(testID);
113
+
114
+ var expected = 'INPUT';
115
+ var actual = component.nodeName;
83
116
  expect(actual).toBe(expected);
117
+ expect(component).toBeInTheDocument();
84
118
  });
85
119
  test('should allow construction without default config', function () {
86
120
  var instanceConfig = {
87
121
  color: 'green'
88
122
  };
89
123
  var Component = NullHoC(instanceConfig, 'div');
90
- var subject = (0, _enzyme.mount)( /*#__PURE__*/(0, _jsxRuntime.jsx)(Component, {}));
91
- var expected = instanceConfig.color;
92
- var actual = subject.find('div').prop('color');
93
- expect(actual).toBe(expected);
124
+ (0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(Component, {}));
125
+
126
+ var component = _react.screen.getByTestId(testID);
127
+
128
+ var expectedAttribute = 'color';
129
+ var expectedValue = instanceConfig.color;
130
+ expect(component).toHaveAttribute(expectedAttribute, expectedValue);
94
131
  });
95
132
  });
@@ -1,8 +1,8 @@
1
1
  "use strict";
2
2
 
3
- var _react = require("react");
3
+ var _react = require("@testing-library/react");
4
4
 
5
- var _enzyme = require("enzyme");
5
+ var _react2 = require("react");
6
6
 
7
7
  var _ApiDecorator = _interopRequireDefault(require("../ApiDecorator"));
8
8
 
@@ -33,6 +33,7 @@ function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.g
33
33
  describe('ApiDecorator', function () {
34
34
  var _class, _temp;
35
35
 
36
+ var data = [];
36
37
  var ApiProvider = (_temp = _class = /*#__PURE__*/function (_ReactComponent) {
37
38
  _inherits(ApiProvider, _ReactComponent);
38
39
 
@@ -62,47 +63,52 @@ describe('ApiDecorator', function () {
62
63
  }, {
63
64
  key: "render",
64
65
  value: function render() {
66
+ data = {
67
+ arrowFunction: this.arrowFunction,
68
+ instanceFunction: this.instanceFunction,
69
+ instanceProperty: this.instanceProperty
70
+ };
65
71
  return /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {});
66
72
  }
67
73
  }]);
68
74
 
69
75
  return ApiProvider;
70
- }(_react.Component), _class.displayName = 'ApiProvider', _temp);
76
+ }(_react2.Component), _class.displayName = 'ApiProvider', _temp);
71
77
  test('should invoke arrow function on wrapped component', function () {
72
78
  var Component = (0, _ApiDecorator["default"])({
73
79
  api: ['arrowFunction']
74
80
  }, ApiProvider);
75
- var subject = (0, _enzyme.mount)( /*#__PURE__*/(0, _jsxRuntime.jsx)(Component, {}));
81
+ (0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(Component, {}));
76
82
  var expected = 'arrow';
77
- var actual = subject.instance().arrowFunction();
83
+ var actual = data.arrowFunction();
78
84
  expect(actual).toBe(expected);
79
85
  });
80
86
  test('should invoke instance function on wrapped component', function () {
81
87
  var Component = (0, _ApiDecorator["default"])({
82
88
  api: ['instanceFunction']
83
89
  }, ApiProvider);
84
- var subject = (0, _enzyme.mount)( /*#__PURE__*/(0, _jsxRuntime.jsx)(Component, {}));
90
+ (0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(Component, {}));
85
91
  var expected = 'instance';
86
- var actual = subject.instance().instanceFunction();
92
+ var actual = data.instanceFunction();
87
93
  expect(actual).toBe(expected);
88
94
  });
89
95
  test('should get an instance property on wrapped component', function () {
90
96
  var Component = (0, _ApiDecorator["default"])({
91
97
  api: ['instanceProperty']
92
98
  }, ApiProvider);
93
- var subject = (0, _enzyme.mount)( /*#__PURE__*/(0, _jsxRuntime.jsx)(Component, {}));
99
+ (0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(Component, {}));
94
100
  var expected = 'property';
95
- var actual = subject.instance().instanceProperty;
101
+ var actual = data.instanceProperty;
96
102
  expect(actual).toBe(expected);
97
103
  });
98
104
  test('should set an instance property on wrapped component', function () {
99
105
  var Component = (0, _ApiDecorator["default"])({
100
106
  api: ['instanceProperty']
101
107
  }, ApiProvider);
102
- var subject = (0, _enzyme.mount)( /*#__PURE__*/(0, _jsxRuntime.jsx)(Component, {}));
103
- subject.instance().instanceProperty = 'updated';
108
+ (0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(Component, {}));
109
+ data.instanceProperty = 'updated';
104
110
  var expected = 'updated';
105
- var actual = subject.instance().instanceProperty;
111
+ var actual = data.instanceProperty;
106
112
  expect(actual).toBe(expected);
107
113
  });
108
114
  });
@@ -2,7 +2,11 @@
2
2
 
3
3
  var _react = require("react");
4
4
 
5
- var _enzyme = require("enzyme");
5
+ require("@testing-library/jest-dom");
6
+
7
+ var _react2 = require("@testing-library/react");
8
+
9
+ var _userEvent = _interopRequireDefault(require("@testing-library/user-event"));
6
10
 
7
11
  var _Registry = _interopRequireDefault(require("../Registry"));
8
12
 
@@ -144,75 +148,97 @@ describe('Registry', function () {
144
148
 
145
149
  HandlesNotification.contextType = SomeContext;
146
150
  test('should increment child on click', function () {
147
- var RegistryApp = (0, _enzyme.mount)( /*#__PURE__*/(0, _jsxRuntime.jsx)(NotifiesTree, {
148
- id: "a-btn",
151
+ (0, _react2.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(NotifiesTree, {
152
+ "data-testid": "a-btn",
149
153
  children: /*#__PURE__*/(0, _jsxRuntime.jsx)(HandlesNotification, {
150
- id: "a"
154
+ "data-testid": "a"
151
155
  })
152
156
  }));
153
- RegistryApp.find('button#a-btn').simulate('click');
157
+
158
+ _userEvent["default"].click(_react2.screen.getByTestId('a-btn'));
159
+
154
160
  var expected = '1';
155
- var actual = RegistryApp.find('div#a').text();
156
- expect(expected).toBe(actual);
161
+
162
+ var child = _react2.screen.getByTestId('a');
163
+
164
+ expect(child).toHaveTextContent(expected);
157
165
  });
158
166
  test('should increment both children on top click', function () {
159
- var RegistryApp = (0, _enzyme.mount)( /*#__PURE__*/(0, _jsxRuntime.jsxs)(NotifiesTree, {
160
- id: "a-btn",
167
+ (0, _react2.render)( /*#__PURE__*/(0, _jsxRuntime.jsxs)(NotifiesTree, {
168
+ "data-testid": "a-btn",
161
169
  children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(HandlesNotification, {
162
- id: "a"
170
+ "data-testid": "a"
163
171
  }), /*#__PURE__*/(0, _jsxRuntime.jsx)(NotifiesTree, {
164
- id: "b-btn",
172
+ "data-testid": "b-btn",
165
173
  children: /*#__PURE__*/(0, _jsxRuntime.jsx)(HandlesNotification, {
166
- id: "b"
174
+ "data-testid": "b"
167
175
  })
168
176
  })]
169
177
  }));
170
- RegistryApp.find('button#a-btn').simulate('click');
178
+
179
+ _userEvent["default"].click(_react2.screen.getByTestId('a-btn'));
180
+
171
181
  var expected = '1';
172
- var actualA = RegistryApp.find('div#a').text();
173
- var actualB = RegistryApp.find('div#b').text();
174
- expect(expected).toBe(actualA);
175
- expect(expected).toBe(actualB);
182
+
183
+ var childA = _react2.screen.getByTestId('a');
184
+
185
+ var childB = _react2.screen.getByTestId('b');
186
+
187
+ expect(childA).toHaveTextContent(expected);
188
+ expect(childB).toHaveTextContent(expected);
176
189
  });
177
190
  test('should increment the deepest child when we click child button', function () {
178
- var RegistryApp = (0, _enzyme.mount)( /*#__PURE__*/(0, _jsxRuntime.jsxs)(NotifiesTree, {
179
- id: "a-btn",
191
+ (0, _react2.render)( /*#__PURE__*/(0, _jsxRuntime.jsxs)(NotifiesTree, {
192
+ "data-testid": "a-btn",
180
193
  children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(HandlesNotification, {
181
- id: "a"
194
+ "data-testid": "a"
182
195
  }), /*#__PURE__*/(0, _jsxRuntime.jsx)(NotifiesTree, {
183
- id: "b-btn",
196
+ "data-testid": "b-btn",
184
197
  children: /*#__PURE__*/(0, _jsxRuntime.jsx)(HandlesNotification, {
185
- id: "b"
198
+ "data-testid": "b"
186
199
  })
187
200
  })]
188
201
  }));
189
- RegistryApp.find('button#b-btn').simulate('click');
202
+
203
+ _userEvent["default"].click(_react2.screen.getByTestId('b-btn'));
204
+
190
205
  var expectedA = '0';
191
206
  var expectedB = '1';
192
- var actualA = RegistryApp.find('div#a').text();
193
- var actualB = RegistryApp.find('div#b').text();
194
- expect(expectedA).toBe(actualA);
195
- expect(expectedB).toBe(actualB);
207
+
208
+ var childA = _react2.screen.getByTestId('a');
209
+
210
+ var childB = _react2.screen.getByTestId('b');
211
+
212
+ expect(childA).toHaveTextContent(expectedA);
213
+ expect(childB).toHaveTextContent(expectedB);
196
214
  });
197
215
  test('should support removing children without error', function () {
198
- var RegistryApp = (0, _enzyme.mount)( /*#__PURE__*/(0, _jsxRuntime.jsxs)(NotifiesTree, {
199
- id: "a-btn",
216
+ var _render = (0, _react2.render)( /*#__PURE__*/(0, _jsxRuntime.jsxs)(NotifiesTree, {
217
+ "data-testid": "a-btn",
200
218
  children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(HandlesNotification, {
201
- id: "a"
219
+ "data-testid": "a"
202
220
  }), /*#__PURE__*/(0, _jsxRuntime.jsx)(HandlesNotification, {
203
- id: "b"
221
+ "data-testid": "b"
204
222
  })]
205
- }));
206
- RegistryApp.find('button#a-btn').simulate('click'); // changing children should be safe and not throw errors when notifying instances
223
+ })),
224
+ rerender = _render.rerender;
225
+
226
+ _userEvent["default"].click(_react2.screen.getByTestId('a-btn')); // changing children should be safe and not throw errors when notifying instances
207
227
 
208
- RegistryApp.setProps({
228
+
229
+ rerender( /*#__PURE__*/(0, _jsxRuntime.jsx)(NotifiesTree, {
230
+ "data-testid": "a-btn",
209
231
  children: /*#__PURE__*/(0, _jsxRuntime.jsx)(HandlesNotification, {
210
- id: "c"
232
+ "data-testid": "c"
211
233
  })
212
- });
213
- RegistryApp.find('button#a-btn').simulate('click');
234
+ }));
235
+
236
+ _userEvent["default"].click(_react2.screen.getByTestId('a-btn'));
237
+
214
238
  var expectedC = '1';
215
- var actualC = RegistryApp.find('div#c').text();
216
- expect(expectedC).toBe(actualC);
239
+
240
+ var childC = _react2.screen.getByTestId('c');
241
+
242
+ expect(childC).toHaveTextContent(expectedC);
217
243
  });
218
244
  });
@@ -1,10 +1,14 @@
1
1
  "use strict";
2
2
 
3
- var _react = require("react");
3
+ require("@testing-library/jest-dom");
4
+
5
+ var _react = require("@testing-library/react");
6
+
7
+ var _userEvent = _interopRequireDefault(require("@testing-library/user-event"));
4
8
 
5
9
  var _propTypes = _interopRequireDefault(require("prop-types"));
6
10
 
7
- var _enzyme = require("enzyme");
11
+ var _react2 = require("react");
8
12
 
9
13
  var _kind = _interopRequireDefault(require("../kind"));
10
14
 
@@ -35,7 +39,7 @@ function _objectWithoutProperties(source, excluded) { if (source == null) return
35
39
  function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
36
40
 
37
41
  describe('kind', function () {
38
- var TestContext = /*#__PURE__*/(0, _react.createContext)({
42
+ var TestContext = /*#__PURE__*/(0, _react2.createContext)({
39
43
  value: 'initial'
40
44
  });
41
45
  var Kind = (0, _kind["default"])({
@@ -73,8 +77,8 @@ describe('kind', function () {
73
77
 
74
78
  delete rest.prop;
75
79
  return /*#__PURE__*/(0, _jsxRuntime.jsx)("div", _objectSpread(_objectSpread({}, rest), {}, {
76
- title: label,
77
80
  "data-context": contextValue,
81
+ title: label,
78
82
  children: value
79
83
  }));
80
84
  }
@@ -88,12 +92,16 @@ describe('kind', function () {
88
92
  var Minimal = (0, _kind["default"])({
89
93
  name: 'Minimal',
90
94
  render: function render() {
91
- return /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {});
95
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
96
+ "data-testid": "minimal"
97
+ });
92
98
  }
93
99
  });
94
- var subject = (0, _enzyme.mount)( /*#__PURE__*/(0, _jsxRuntime.jsx)(Minimal, {}));
95
- var actual = subject.find('div');
96
- expect(actual).toBeDefined();
100
+ (0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(Minimal, {}));
101
+
102
+ var minimalDiv = _react.screen.queryByTestId('minimal');
103
+
104
+ expect(minimalDiv).toBeInTheDocument();
97
105
  });
98
106
  test('should default {label} property', function () {
99
107
  var subject = /*#__PURE__*/(0, _jsxRuntime.jsx)(Kind, {
@@ -107,47 +115,57 @@ describe('kind', function () {
107
115
  // Explicitly testing for undefined
108
116
  // eslint-disable-next-line no-undefined
109
117
  var subject = /*#__PURE__*/(0, _jsxRuntime.jsx)(Kind, {
110
- prop: 1,
111
- label: undefined
118
+ label: undefined,
119
+ prop: 1
112
120
  });
113
121
  var expected = 'Label';
114
122
  var actual = subject.props.label;
115
123
  expect(actual).toBe(expected);
116
124
  });
117
125
  test('should add className defined in styles', function () {
118
- var subject = (0, _enzyme.mount)( /*#__PURE__*/(0, _jsxRuntime.jsx)(Kind, {
126
+ (0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(Kind, {
119
127
  prop: 1
120
128
  }));
121
129
  var expected = 'kind';
122
- var actual = subject.find('div').prop('className');
123
- expect(actual).toBe(expected);
130
+
131
+ var kindDiv = _react.screen.getByTitle('Label');
132
+
133
+ expect(kindDiv).toHaveClass(expected);
124
134
  });
125
135
  test('should compute {value} property', function () {
126
- var subject = (0, _enzyme.mount)( /*#__PURE__*/(0, _jsxRuntime.jsx)(Kind, {
136
+ (0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(Kind, {
127
137
  prop: 1
128
138
  }));
129
- var expected = 2;
130
- var actual = subject.find('div').prop('children');
131
- expect(actual).toBe(expected);
139
+ var expected = '2';
140
+
141
+ var kindDiv = _react.screen.getByTitle('Label');
142
+
143
+ expect(kindDiv).toHaveTextContent(expected);
132
144
  });
133
145
  test('should support contextType in handlers', function () {
134
146
  var onClick = jest.fn();
135
- var subject = (0, _enzyme.mount)( /*#__PURE__*/(0, _jsxRuntime.jsx)(Kind, {
136
- prop: 1,
137
- onClick: onClick
147
+ (0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(Kind, {
148
+ onClick: onClick,
149
+ prop: 1
138
150
  }));
139
- subject.find('div').invoke('onClick')();
151
+
152
+ var kindDiv = _react.screen.getByTitle('Label');
153
+
154
+ _userEvent["default"].click(kindDiv);
155
+
140
156
  var expected = 'initial';
141
157
  var actual = onClick.mock.calls[0][0];
142
158
  expect(actual).toBe(expected);
143
159
  });
144
160
  test('should support contextType in computed', function () {
145
- var subject = (0, _enzyme.mount)( /*#__PURE__*/(0, _jsxRuntime.jsx)(Kind, {
161
+ (0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(Kind, {
146
162
  prop: 1
147
163
  }));
148
164
  var expected = 'contextinitial';
149
- var actual = subject.find('div').prop('data-context');
150
- expect(actual).toBe(expected);
165
+
166
+ var kindDiv = _react.screen.getByTitle('Label');
167
+
168
+ expect(kindDiv).toHaveAttribute('data-context', expected);
151
169
  });
152
170
  test('support using hooks within kind instances', function () {
153
171
  var Comp = (0, _kind["default"])({
@@ -155,12 +173,13 @@ describe('kind', function () {
155
173
  functional: true,
156
174
  render: function render() {
157
175
  // eslint-disable-next-line react-hooks/rules-of-hooks
158
- var _useState = (0, _react.useState)(0),
176
+ var _useState = (0, _react2.useState)(0),
159
177
  _useState2 = _slicedToArray(_useState, 2),
160
178
  state = _useState2[0],
161
179
  setState = _useState2[1];
162
180
 
163
181
  return /*#__PURE__*/(0, _jsxRuntime.jsx)("button", {
182
+ "data-testid": "button",
164
183
  onClick: function onClick() {
165
184
  return setState(state + 1);
166
185
  },
@@ -168,11 +187,14 @@ describe('kind', function () {
168
187
  });
169
188
  }
170
189
  });
171
- var subject = (0, _enzyme.mount)( /*#__PURE__*/(0, _jsxRuntime.jsx)(Comp, {}));
172
- subject.find('button').invoke('onClick')();
173
- var expected = 1;
174
- var actual = subject.find('button').prop('children');
175
- expect(actual).toBe(expected);
190
+ (0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(Comp, {}));
191
+
192
+ var button = _react.screen.getByTestId('button');
193
+
194
+ _userEvent["default"].click(button);
195
+
196
+ var expected = '1';
197
+ expect(button).toHaveTextContent(expected);
176
198
  });
177
199
  describe('inline', function () {
178
200
  test('should support a minimal kind', function () {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@enact/core",
3
- "version": "4.1.0",
3
+ "version": "4.1.3",
4
4
  "description": "Enact is an open source JavaScript framework containing everything you need to create a fast, scalable mobile or web application.",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -25,13 +25,13 @@
25
25
  }
26
26
  },
27
27
  "dependencies": {
28
- "classnames": "^2.2.5",
29
- "invariant": "^2.2.2",
30
- "prop-types": "^15.7.2",
31
- "ramda": "^0.24.1",
32
- "react": "^17.0.1",
33
- "react-dom": "^17.0.1",
34
- "react-is": "^17.0.1",
28
+ "classnames": "^2.3.1",
29
+ "invariant": "^2.2.4",
30
+ "prop-types": "^15.8.0",
31
+ "ramda": "^0.27.1",
32
+ "react": "^17.0.2",
33
+ "react-dom": "^17.0.2",
34
+ "react-is": "^17.0.2",
35
35
  "warning": "^4.0.3"
36
36
  }
37
37
  }
@@ -27,7 +27,7 @@ export interface PlatformDescription {
27
27
  /**
28
28
  * `true` if the platform has a touch screen
29
29
  */;
30
- touchsreen: boolean
30
+ touchscreen: boolean
31
31
  /**
32
32
  * `true` for any unknown system
33
33
  */;
@@ -247,7 +247,7 @@ var parseUserAgent = function parseUserAgent(userAgent) {
247
247
  * @property {Boolean} node - `true` only if `window` is `undefined`
248
248
  * @property {String} [platformName] - The name of the platform, if detected
249
249
  * @property {Boolean} touch - `true` if the platform has native single-finger events
250
- * @property {Boolean} touchsreen - `true` if the platform has a touch screen
250
+ * @property {Boolean} touchscreen - `true` if the platform has a touch screen
251
251
  * @property {Boolean} unknown - `true` for any unknown system
252
252
  *
253
253
  * @memberof core/platform
@@ -16,9 +16,11 @@ and is executed in order once the window is available.
16
16
  *
17
17
  * _Important Notes_
18
18
  * * The callback should not alter the initial HTML state. If it does, it will invalidate the
19
- pre-render state and interfere with React rehydration.
19
+ *
20
+ * pre-render state and interfere with React rehydration.
20
21
  * * The callback should be limited to module-scoped actions and not component instance actions. If
21
- the action is tied to a component, it should be invoked from within the component's lifecycle
22
+ *
23
+ * the action is tied to a component, it should be invoked from within the component's lifecycle
22
24
  methods.
23
25
  */
24
26
  export function onWindowReady(callback: Function): void;
@@ -1,8 +1,10 @@
1
1
  "use strict";
2
2
 
3
- var _enzyme = require("enzyme");
3
+ require("@testing-library/jest-dom");
4
4
 
5
- var _react = require("react");
5
+ var _react = require("@testing-library/react");
6
+
7
+ var _react2 = require("react");
6
8
 
7
9
  var _useChainRefs = _interopRequireDefault(require("../useChainRefs"));
8
10
 
@@ -33,14 +35,14 @@ describe('useChainRefs', function () {
33
35
 
34
36
  test('should call a single functional ref', function () {
35
37
  var ref = jest.fn();
36
- (0, _enzyme.mount)( /*#__PURE__*/(0, _jsxRuntime.jsx)(Component, {
38
+ (0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(Component, {
37
39
  refs: [ref]
38
40
  }));
39
41
  expect(ref).toHaveBeenCalledTimes(1);
40
42
  });
41
43
  test('should call a single object ref', function () {
42
- var ref = /*#__PURE__*/(0, _react.createRef)();
43
- (0, _enzyme.mount)( /*#__PURE__*/(0, _jsxRuntime.jsx)(Component, {
44
+ var ref = /*#__PURE__*/(0, _react2.createRef)();
45
+ (0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(Component, {
44
46
  refs: [ref]
45
47
  }));
46
48
  var expected = 'DIV';
@@ -50,7 +52,7 @@ describe('useChainRefs', function () {
50
52
  test('should ignore invalid refs', function () {
51
53
  var invalid = {};
52
54
  var ref = jest.fn();
53
- (0, _enzyme.mount)( /*#__PURE__*/(0, _jsxRuntime.jsx)(Component, {
55
+ (0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(Component, {
54
56
  refs: [invalid, ref]
55
57
  }));
56
58
  expect(ref).toHaveBeenCalledTimes(1);
@@ -1,6 +1,8 @@
1
1
  "use strict";
2
2
 
3
- var _enzyme = require("enzyme");
3
+ require("@testing-library/jest-dom");
4
+
5
+ var _react = require("@testing-library/react");
4
6
 
5
7
  var _useClass = _interopRequireDefault(require("../useClass"));
6
8
 
@@ -20,32 +22,39 @@ describe('useClass', function () {
20
22
  function Component(props) {
21
23
  var instance = (0, _useClass["default"])(Class, props.arg);
22
24
  return /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
23
- fromProps: props.arg,
24
- fromClass: instance.arg
25
+ "data-testid": "div",
26
+ "data-fromclass": instance.arg,
27
+ "data-fromprops": props.arg
25
28
  });
26
29
  }
27
30
 
28
31
  test('should pass arg to Class', function () {
29
32
  var arg = 'arg';
30
- var subject = (0, _enzyme.shallow)( /*#__PURE__*/(0, _jsxRuntime.jsx)(Component, {
33
+ (0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(Component, {
31
34
  arg: arg
32
35
  }));
33
- var expected = arg;
34
- var actual = subject.prop('fromClass');
35
- expect(actual).toBe(expected);
36
+
37
+ var div = _react.screen.getByTestId('div');
38
+
39
+ expect(div).toHaveAttribute('data-fromclass', arg);
36
40
  });
37
41
  test('should use the same instance of Class across renders', function () {
38
42
  var arg = 'arg';
39
- var subject = (0, _enzyme.shallow)( /*#__PURE__*/(0, _jsxRuntime.jsx)(Component, {
43
+
44
+ var _render = (0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(Component, {
40
45
  arg: arg
41
- }));
42
- expect(subject.prop('fromProps')).toBe(arg);
43
- subject.setProps({
44
- arg: 'changed'
45
- }); // verify that the children still reflects the class value set at construction but the prop
46
+ })),
47
+ rerender = _render.rerender;
48
+
49
+ var div = _react.screen.getByTestId('div');
50
+
51
+ expect(div).toHaveAttribute('data-fromprops', arg);
52
+ rerender( /*#__PURE__*/(0, _jsxRuntime.jsx)(Component, {
53
+ arg: "changed"
54
+ })); // verify that the children still reflects the class value set at construction but the prop
46
55
  // value was updated when props were updated
47
56
 
48
- expect(subject.prop('fromClass')).toBe(arg);
49
- expect(subject.prop('fromProps')).toBe('changed');
57
+ expect(div).toHaveAttribute('data-fromclass', arg);
58
+ expect(div).toHaveAttribute('data-fromprops', 'changed');
50
59
  });
51
60
  });
@@ -1,6 +1,8 @@
1
1
  "use strict";
2
2
 
3
- var _enzyme = require("enzyme");
3
+ require("@testing-library/jest-dom");
4
+
5
+ var _react = require("@testing-library/react");
4
6
 
5
7
  var _useHandlers = _interopRequireDefault(require("../useHandlers"));
6
8
 
@@ -15,6 +17,7 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
15
17
  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; }
16
18
 
17
19
  describe('useHandlers', function () {
20
+ var data = {};
18
21
  var context = {
19
22
  value: 1
20
23
  };
@@ -25,49 +28,61 @@ describe('useHandlers', function () {
25
28
  return ev(p, c);
26
29
  }
27
30
  }, props, context);
28
- return /*#__PURE__*/(0, _jsxRuntime.jsx)("div", _objectSpread(_objectSpread({}, props), handlers));
31
+ data = {
32
+ handlers: handlers
33
+ };
34
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)("div", _objectSpread(_objectSpread({}, props), {}, {
35
+ "data-testid": "divComponent"
36
+ }));
29
37
  } // Sanity test for Component moreso than useHandlers test
30
38
 
31
39
 
32
40
  test('should include handlers in props', function () {
33
- var subject = (0, _enzyme.shallow)( /*#__PURE__*/(0, _jsxRuntime.jsx)(Component, {}));
34
- var expected = 'testEvent';
35
- var actual = subject.props();
36
- expect(actual).toHaveProperty(expected);
41
+ (0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(Component, {}));
42
+ var actual = data.handlers.testEvent;
43
+ expect(actual).toBeDefined();
37
44
  });
38
45
  test('should have the same reference across renders', function () {
39
- var subject = (0, _enzyme.shallow)( /*#__PURE__*/(0, _jsxRuntime.jsx)(Component, {}));
40
- var expected = subject.prop('testEvent');
41
- subject.setProps({});
42
- var actual = subject.prop('testEvent');
46
+ var _render = (0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(Component, {})),
47
+ rerender = _render.rerender;
48
+
49
+ var expected = data.handlers.testEvent;
50
+ rerender( /*#__PURE__*/(0, _jsxRuntime.jsx)(Component, {}));
51
+ var actual = data.handlers.testEvent;
43
52
  expect(actual).toBe(expected);
44
53
  });
45
54
  test('should receive the event', function () {
46
55
  var spy = jest.fn();
47
- var subject = (0, _enzyme.shallow)( /*#__PURE__*/(0, _jsxRuntime.jsx)(Component, {}));
48
- var props = {
56
+
57
+ var _render2 = (0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(Component, {})),
58
+ rerender = _render2.rerender;
59
+
60
+ rerender( /*#__PURE__*/(0, _jsxRuntime.jsx)(Component, {
49
61
  children: 'updated'
50
- };
51
- subject.setProps(props);
52
- subject.find('div').invoke('testEvent')(spy);
62
+ }));
63
+ data.handlers.testEvent(spy);
53
64
  expect(spy).toHaveBeenCalled();
54
65
  });
55
66
  test('should reflect the latest props', function () {
56
67
  var spy = jest.fn();
57
- var subject = (0, _enzyme.shallow)( /*#__PURE__*/(0, _jsxRuntime.jsx)(Component, {}));
58
- var props = {
68
+
69
+ var _render3 = (0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(Component, {})),
70
+ rerender = _render3.rerender;
71
+
72
+ rerender( /*#__PURE__*/(0, _jsxRuntime.jsx)(Component, {
73
+ children: 'updated'
74
+ }));
75
+ data.handlers.testEvent(spy);
76
+ var expected = {
59
77
  children: 'updated'
60
78
  };
61
- subject.setProps(props);
62
- subject.find('div').invoke('testEvent')(spy);
63
- var expected = props;
64
79
  var actual = spy.mock.calls[0][0];
65
80
  expect(actual).toMatchObject(expected);
66
81
  });
67
82
  test('should support component-driven context', function () {
68
83
  var spy = jest.fn();
69
- var subject = (0, _enzyme.shallow)( /*#__PURE__*/(0, _jsxRuntime.jsx)(Component, {}));
70
- subject.find('div').invoke('testEvent')(spy); // defined a "global" context to ease testability but this isn't representative of the
84
+ (0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(Component, {}));
85
+ data.handlers.testEvent(spy); // defined a "global" context to ease testability but this isn't representative of the
71
86
  // expected use case of this feature.
72
87
 
73
88
  var expected = context;
@@ -78,12 +93,11 @@ describe('useHandlers', function () {
78
93
  var spy = jest.fn().mockImplementation(function () {
79
94
  return 'ok';
80
95
  });
81
- var subject = (0, _enzyme.shallow)( /*#__PURE__*/(0, _jsxRuntime.jsx)(Component, {}));
82
- var returnValue = subject.find('div').invoke('testEvent')(spy); // defined a "global" context to ease testability but this isn't representative of the
96
+ (0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(Component, {}));
97
+ var returnValue = data.handlers.testEvent(spy); // defined a "global" context to ease testability but this isn't representative of the
83
98
  // expected use case of this feature.
84
99
 
85
100
  var expected = 'ok';
86
- var actual = returnValue;
87
- expect(actual).toBe(expected);
101
+ expect(returnValue).toBe(expected);
88
102
  });
89
103
  });
package/util/util.d.ts CHANGED
@@ -8,10 +8,10 @@ type Merge<M, N> = Omit<M, Extract<keyof M, keyof N>> & N;
8
8
  */
9
9
 
10
10
  export declare class Job {
11
- constructor(
12
- /**
13
- * Function to execute as the requested job.
14
- */
11
+ constructor
12
+ /**
13
+ * Function to execute as the requested job.
14
+ */(
15
15
  fn: Function
16
16
  /**
17
17
  * The number of milliseconds to wait before starting the job.