@enact/core 4.5.2 → 4.5.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.
Files changed (41) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/dispatcher/dispatcher.js +8 -27
  3. package/dispatcher/listeners.js +0 -8
  4. package/dispatcher/tests/dispatcher-specs.js +0 -3
  5. package/handle/handle.js +33 -90
  6. package/handle/tests/handle-specs.js +21 -42
  7. package/hoc/hoc.js +2 -13
  8. package/hoc/tests/hoc-specs.js +0 -23
  9. package/internal/ApiDecorator/ApiDecorator.js +4 -34
  10. package/internal/ApiDecorator/tests/ApiDecorator-specs.js +0 -24
  11. package/internal/Registry/Registry.js +0 -7
  12. package/internal/Registry/tests/Registry-specs.js +10 -70
  13. package/internal/deprecate/deprecate.js +8 -22
  14. package/internal/prop-types/prop-types.js +3 -20
  15. package/keymap/index.js +2 -3
  16. package/keymap/keymap.js +10 -18
  17. package/keymap/tests/keymap-specs.js +0 -3
  18. package/kind/computed.js +2 -9
  19. package/kind/kind.js +14 -53
  20. package/kind/styles.js +6 -19
  21. package/kind/tests/computed-specs.js +4 -6
  22. package/kind/tests/kind-specs.js +9 -44
  23. package/kind/tests/styles-specs.js +12 -7
  24. package/kind/util.js +0 -2
  25. package/package.json +7 -1
  26. package/platform/platform.js +51 -57
  27. package/platform/tests/platform-specs.js +2 -2
  28. package/snapshot/snapshot.js +4 -9
  29. package/useChainRefs/tests/useChainRefs-specs.js +0 -14
  30. package/useChainRefs/useChainRefs.js +3 -11
  31. package/useClass/tests/useClass-specs.js +6 -21
  32. package/useClass/useClass.js +0 -8
  33. package/useHandlers/Handlers.js +0 -11
  34. package/useHandlers/tests/useHandlers-specs.js +11 -23
  35. package/useHandlers/useHandlers.js +0 -5
  36. package/usePublicClassNames/tests/usePublicClassNames-specs.js +21 -28
  37. package/usePublicClassNames/usePublicClassNames.js +4 -10
  38. package/util/Job.js +1 -43
  39. package/util/tests/Job-specs.js +0 -14
  40. package/util/tests/util-specs.js +9 -10
  41. package/util/util.js +14 -54
@@ -1,27 +1,18 @@
1
1
  "use strict";
2
2
 
3
3
  require("@testing-library/jest-dom");
4
-
5
4
  var _react = require("@testing-library/react");
6
-
7
5
  var _useHandlers = _interopRequireDefault(require("../useHandlers"));
8
-
9
6
  var _jsxRuntime = require("react/jsx-runtime");
10
-
11
7
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
12
-
13
8
  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; }
14
-
15
9
  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; }
16
-
17
10
  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; }
18
-
19
11
  describe('useHandlers', function () {
20
12
  var data = {};
21
13
  var context = {
22
14
  value: 1
23
15
  };
24
-
25
16
  function Component(props) {
26
17
  var handlers = (0, _useHandlers["default"])({
27
18
  testEvent: function testEvent(ev, p, c) {
@@ -34,9 +25,9 @@ describe('useHandlers', function () {
34
25
  return /*#__PURE__*/(0, _jsxRuntime.jsx)("div", _objectSpread(_objectSpread({}, props), {}, {
35
26
  "data-testid": "divComponent"
36
27
  }));
37
- } // Sanity test for Component moreso than useHandlers test
38
-
28
+ }
39
29
 
30
+ // Sanity test for Component moreso than useHandlers test
40
31
  test('should include handlers in props', function () {
41
32
  (0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(Component, {}));
42
33
  var actual = data.handlers.testEvent;
@@ -44,8 +35,7 @@ describe('useHandlers', function () {
44
35
  });
45
36
  test('should have the same reference across renders', function () {
46
37
  var _render = (0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(Component, {})),
47
- rerender = _render.rerender;
48
-
38
+ rerender = _render.rerender;
49
39
  var expected = data.handlers.testEvent;
50
40
  rerender( /*#__PURE__*/(0, _jsxRuntime.jsx)(Component, {}));
51
41
  var actual = data.handlers.testEvent;
@@ -53,10 +43,8 @@ describe('useHandlers', function () {
53
43
  });
54
44
  test('should receive the event', function () {
55
45
  var spy = jest.fn();
56
-
57
46
  var _render2 = (0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(Component, {})),
58
- rerender = _render2.rerender;
59
-
47
+ rerender = _render2.rerender;
60
48
  rerender( /*#__PURE__*/(0, _jsxRuntime.jsx)(Component, {
61
49
  children: 'updated'
62
50
  }));
@@ -65,10 +53,8 @@ describe('useHandlers', function () {
65
53
  });
66
54
  test('should reflect the latest props', function () {
67
55
  var spy = jest.fn();
68
-
69
56
  var _render3 = (0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(Component, {})),
70
- rerender = _render3.rerender;
71
-
57
+ rerender = _render3.rerender;
72
58
  rerender( /*#__PURE__*/(0, _jsxRuntime.jsx)(Component, {
73
59
  children: 'updated'
74
60
  }));
@@ -82,9 +68,10 @@ describe('useHandlers', function () {
82
68
  test('should support component-driven context', function () {
83
69
  var spy = jest.fn();
84
70
  (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
86
- // expected use case of this feature.
71
+ data.handlers.testEvent(spy);
87
72
 
73
+ // defined a "global" context to ease testability but this isn't representative of the
74
+ // expected use case of this feature.
88
75
  var expected = context;
89
76
  var actual = spy.mock.calls[0][1];
90
77
  expect(actual).toMatchObject(expected);
@@ -94,9 +81,10 @@ describe('useHandlers', function () {
94
81
  return 'ok';
95
82
  });
96
83
  (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
98
- // expected use case of this feature.
84
+ var returnValue = data.handlers.testEvent(spy);
99
85
 
86
+ // defined a "global" context to ease testability but this isn't representative of the
87
+ // expected use case of this feature.
100
88
  var expected = 'ok';
101
89
  expect(returnValue).toBe(expected);
102
90
  });
@@ -5,13 +5,9 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports["default"] = void 0;
7
7
  exports.useHandlers = useHandlers;
8
-
9
8
  var _useClass = _interopRequireDefault(require("../useClass"));
10
-
11
9
  var _Handlers = _interopRequireDefault(require("./Handlers"));
12
-
13
10
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
14
-
15
11
  /**
16
12
  * Creates a map of event handlers with consistent references across renders.
17
13
  *
@@ -31,6 +27,5 @@ function useHandlers(handlers, props, context) {
31
27
  h.setContext(props, context);
32
28
  return h.handlers;
33
29
  }
34
-
35
30
  var _default = useHandlers;
36
31
  exports["default"] = _default;
@@ -1,11 +1,8 @@
1
1
  "use strict";
2
2
 
3
3
  var _react = require("@testing-library/react");
4
-
5
4
  var _usePublicClassNames = _interopRequireDefault(require("../usePublicClassNames"));
6
-
7
5
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
8
-
9
6
  describe('usePublicClassNames', function () {
10
7
  var componentCss = {
11
8
  test: 'test-class',
@@ -22,28 +19,25 @@ describe('usePublicClassNames', function () {
22
19
  var testComponentCss = {
23
20
  test: 'test-class'
24
21
  };
25
-
26
22
  var _renderHook = (0, _react.renderHook)(function () {
27
- return (0, _usePublicClassNames["default"])({
28
- componentCss: testComponentCss,
29
- customCss: null,
30
- publicClassNames: true
31
- });
32
- }),
33
- result = _renderHook.result;
34
-
23
+ return (0, _usePublicClassNames["default"])({
24
+ componentCss: testComponentCss,
25
+ customCss: null,
26
+ publicClassNames: true
27
+ });
28
+ }),
29
+ result = _renderHook.result;
35
30
  expect(result.current).toEqual(testComponentCss);
36
31
  });
37
32
  test('should return a merged css has all keys from `componentCss` and merged values when `publicClassNames` is true', function () {
38
33
  var _renderHook2 = (0, _react.renderHook)(function () {
39
- return (0, _usePublicClassNames["default"])({
40
- componentCss: componentCss,
41
- customCss: customCss,
42
- publicClassNames: true
43
- });
44
- }),
45
- result = _renderHook2.result;
46
-
34
+ return (0, _usePublicClassNames["default"])({
35
+ componentCss: componentCss,
36
+ customCss: customCss,
37
+ publicClassNames: true
38
+ });
39
+ }),
40
+ result = _renderHook2.result;
47
41
  var expected = {
48
42
  test: 'test-class test-class-custom',
49
43
  a: 'a-class a-class-custom',
@@ -55,14 +49,13 @@ describe('usePublicClassNames', function () {
55
49
  });
56
50
  test('should return a merged css has the keys from `publicClassNames` array and merged values when `publicClassNames` is an array of strings', function () {
57
51
  var _renderHook3 = (0, _react.renderHook)(function () {
58
- return (0, _usePublicClassNames["default"])({
59
- componentCss: componentCss,
60
- customCss: customCss,
61
- publicClassNames: ['a', 'b']
62
- });
63
- }),
64
- result = _renderHook3.result;
65
-
52
+ return (0, _usePublicClassNames["default"])({
53
+ componentCss: componentCss,
54
+ customCss: customCss,
55
+ publicClassNames: ['a', 'b']
56
+ });
57
+ }),
58
+ result = _renderHook3.result;
66
59
  var expected = {
67
60
  a: 'a-class a-class-custom',
68
61
  b: 'b-class b-class-custom'
@@ -5,9 +5,7 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports["default"] = void 0;
7
7
  exports.usePublicClassNames = usePublicClassNames;
8
-
9
8
  var _util = require("../util");
10
-
11
9
  /**
12
10
  * A hook for supporting `publicClassNames` to functional components.
13
11
  * It returns merged CSS of given two CSS objects according to `publicClassNames` option.
@@ -23,28 +21,24 @@ var _util = require("../util");
23
21
  */
24
22
  function usePublicClassNames(_ref) {
25
23
  var componentCss = _ref.componentCss,
26
- customCss = _ref.customCss,
27
- publicClassNames = _ref.publicClassNames;
24
+ customCss = _ref.customCss,
25
+ publicClassNames = _ref.publicClassNames;
28
26
  var allowedClassNames = publicClassNames;
29
27
  var mergedCss = componentCss;
30
-
31
28
  if (!componentCss || !customCss) {
32
29
  return mergedCss;
33
30
  }
34
-
35
31
  if (allowedClassNames === true) {
36
32
  allowedClassNames = Object.keys(componentCss);
37
33
  } else if (typeof allowedClassNames === 'string') {
38
34
  allowedClassNames = allowedClassNames.split(/\s+/);
39
- } // if the config includes a css map, merge them together now
40
-
35
+ }
41
36
 
37
+ // if the config includes a css map, merge them together now
42
38
  if (allowedClassNames) {
43
39
  mergedCss = (0, _util.mergeClassNameMaps)(componentCss, customCss, allowedClassNames);
44
40
  }
45
-
46
41
  return mergedCss;
47
42
  }
48
-
49
43
  var _default = usePublicClassNames;
50
44
  exports["default"] = _default;
package/util/Job.js CHANGED
@@ -4,17 +4,11 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports["default"] = exports.Job = void 0;
7
-
8
7
  var _invariant = _interopRequireDefault(require("invariant"));
9
-
10
8
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
11
-
12
9
  function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
13
-
14
10
  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); } }
15
-
16
11
  function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
17
-
18
12
  /**
19
13
  * Provides a convenient way to manage timed execution of functions.
20
14
  *
@@ -32,35 +26,27 @@ var Job = /*#__PURE__*/function () {
32
26
  */
33
27
  function Job(fn, _timeout) {
34
28
  var _this = this;
35
-
36
29
  _classCallCheck(this, Job);
37
-
38
30
  this.id = null;
39
31
  this.fn = null;
40
32
  this.timeout = null;
41
33
  this.type = null;
42
-
43
34
  this.start = function () {
44
35
  for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
45
36
  args[_key] = arguments[_key];
46
37
  }
47
-
48
38
  _this.startAfter.apply(_this, [_this.timeout].concat(args));
49
39
  };
50
-
51
40
  this.startAfter = function (timeout) {
52
41
  for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
53
42
  args[_key2 - 1] = arguments[_key2];
54
43
  }
55
-
56
44
  _this.stop();
57
-
58
45
  _this.type = 'timeout';
59
46
  _this.id = setTimeout(function () {
60
47
  return _this.run(args);
61
48
  }, timeout);
62
49
  };
63
-
64
50
  this.stop = function () {
65
51
  if (_this.id) {
66
52
  if (_this.type === 'idle') {
@@ -70,49 +56,37 @@ var Job = /*#__PURE__*/function () {
70
56
  } else if (_this.type === 'timeout') {
71
57
  clearTimeout(_this.id);
72
58
  }
73
-
74
59
  _this.id = _this.type = null;
75
60
  }
76
61
  };
77
-
78
62
  this.throttle = function () {
79
63
  for (var _len3 = arguments.length, args = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
80
64
  args[_key3] = arguments[_key3];
81
65
  }
82
-
83
66
  _this.throttleUntil.apply(_this, [_this.timeout].concat(args));
84
67
  };
85
-
86
68
  this.throttleUntil = function (timeout) {
87
69
  if (!_this.id) {
88
70
  _this.type = 'timeout';
89
-
90
71
  for (var _len4 = arguments.length, args = new Array(_len4 > 1 ? _len4 - 1 : 0), _key4 = 1; _key4 < _len4; _key4++) {
91
72
  args[_key4 - 1] = arguments[_key4];
92
73
  }
93
-
94
74
  _this.run(args);
95
-
96
75
  _this.id = setTimeout(_this.stop, timeout);
97
76
  }
98
77
  };
99
-
100
78
  this.idle = function () {
101
79
  for (var _len5 = arguments.length, args = new Array(_len5), _key5 = 0; _key5 < _len5; _key5++) {
102
80
  args[_key5] = arguments[_key5];
103
81
  }
104
-
105
82
  _this.idleUntil.apply(_this, [null].concat(args));
106
83
  };
107
-
108
84
  this.idleUntil = function (timeout) {
109
85
  for (var _len6 = arguments.length, args = new Array(_len6 > 1 ? _len6 - 1 : 0), _key6 = 1; _key6 < _len6; _key6++) {
110
86
  args[_key6 - 1] = arguments[_key6];
111
87
  }
112
-
113
88
  if (typeof window !== 'undefined' && window.requestIdleCallback) {
114
89
  _this.stop();
115
-
116
90
  _this.type = 'idle';
117
91
  _this.id = window.requestIdleCallback(function () {
118
92
  return _this.run(args);
@@ -124,49 +98,38 @@ var Job = /*#__PURE__*/function () {
124
98
  _this.startAfter.apply(_this, [timeout].concat(args));
125
99
  }
126
100
  };
127
-
128
101
  this.startRaf = function () {
129
102
  for (var _len7 = arguments.length, args = new Array(_len7), _key7 = 0; _key7 < _len7; _key7++) {
130
103
  args[_key7] = arguments[_key7];
131
104
  }
132
-
133
105
  _this.startRafAfter.apply(_this, [_this.timeout].concat(args));
134
106
  };
135
-
136
107
  this.startRafAfter = function (timeout) {
137
108
  for (var _len8 = arguments.length, args = new Array(_len8 > 1 ? _len8 - 1 : 0), _key8 = 1; _key8 < _len8; _key8++) {
138
109
  args[_key8 - 1] = arguments[_key8];
139
110
  }
140
-
141
111
  _this.type = 'raf';
142
-
143
112
  if (typeof window !== 'undefined') {
144
113
  var time = null;
145
-
146
114
  var callback = function callback(timestamp) {
147
115
  if (time === null) {
148
116
  time = timestamp;
149
117
  }
150
-
151
118
  if (timeout && timestamp - time < timeout) {
152
119
  _this.id = window.requestAnimationFrame(callback);
153
120
  } else {
154
121
  time = null;
155
-
156
122
  _this.run(args);
157
-
158
123
  window.cancelAnimationFrame(_this.id);
159
124
  _this.id = null;
160
125
  }
161
126
  };
162
-
163
127
  _this.id = window.requestAnimationFrame(callback);
164
128
  } else {
165
129
  // If requestAnimationFrame is not supported just run the function immediately
166
130
  _this.run(args);
167
131
  }
168
132
  };
169
-
170
133
  this.promise = function (promise) {
171
134
  !(promise && typeof promise.then === 'function') ? process.env.NODE_ENV !== "production" ? (0, _invariant["default"])(false, 'promise expects a thenable') : (0, _invariant["default"])(false) : void 0;
172
135
  _this.type = 'promise';
@@ -174,22 +137,20 @@ var Job = /*#__PURE__*/function () {
174
137
  return promise.then(function (result) {
175
138
  if (_this.id === promise) {
176
139
  _this.stop();
177
-
178
140
  return _this.run([result]);
179
141
  }
180
142
  });
181
143
  };
182
-
183
144
  this.fn = fn;
184
145
  this.timeout = _timeout;
185
146
  }
186
-
187
147
  _createClass(Job, [{
188
148
  key: "run",
189
149
  value: function run(args) {
190
150
  // don't want to inadvertently apply Job's context on `fn`
191
151
  return this.fn.apply(null, args);
192
152
  }
153
+
193
154
  /**
194
155
  * Starts the job.
195
156
  *
@@ -200,12 +161,9 @@ var Job = /*#__PURE__*/function () {
200
161
  * @memberof core/util.Job.prototype
201
162
  * @public
202
163
  */
203
-
204
164
  }]);
205
-
206
165
  return Job;
207
166
  }();
208
-
209
167
  exports.Job = Job;
210
168
  var _default = Job;
211
169
  exports["default"] = _default;
@@ -1,11 +1,8 @@
1
1
  "use strict";
2
2
 
3
3
  var _react = require("@testing-library/react");
4
-
5
4
  var _Job = _interopRequireDefault(require("../Job"));
6
-
7
5
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
8
-
9
6
  describe('Job', function () {
10
7
  beforeEach(function () {
11
8
  jest.useFakeTimers();
@@ -21,7 +18,6 @@ describe('Job', function () {
21
18
  });
22
19
  test('should pass args to fn', function (done) {
23
20
  var value = 'argument';
24
-
25
21
  var fn = function fn(arg) {
26
22
  if (arg === value) {
27
23
  done();
@@ -29,7 +25,6 @@ describe('Job', function () {
29
25
  done(new Error('fn did not receive argument'));
30
26
  }
31
27
  };
32
-
33
28
  var j = new _Job["default"](fn, 10);
34
29
  j.start(value);
35
30
  jest.runAllTimers();
@@ -72,7 +67,6 @@ describe('Job', function () {
72
67
  (0, _react.act)(function () {
73
68
  return jest.advanceTimersByTime(5);
74
69
  });
75
-
76
70
  if (number === 2) {
77
71
  done();
78
72
  } else {
@@ -81,7 +75,6 @@ describe('Job', function () {
81
75
  });
82
76
  test('should pass args to fn', function (done) {
83
77
  var value = 'argument';
84
-
85
78
  var fn = function fn(arg) {
86
79
  if (arg === value) {
87
80
  done();
@@ -89,7 +82,6 @@ describe('Job', function () {
89
82
  done(new Error('fn did not receive argument'));
90
83
  }
91
84
  };
92
-
93
85
  var j = new _Job["default"](fn, 10);
94
86
  j.throttle(value);
95
87
  });
@@ -102,7 +94,6 @@ describe('Job', function () {
102
94
  window.requestIdleCallback = windowRequest || function (fn) {
103
95
  return setTimeout(fn, 0);
104
96
  };
105
-
106
97
  window.cancelIdleCallback = windowCancel || function (id) {
107
98
  clearTimeout(id);
108
99
  };
@@ -118,7 +109,6 @@ describe('Job', function () {
118
109
  });
119
110
  test('should pass args to fn', function (done) {
120
111
  var value = 'argument';
121
-
122
112
  var fn = function fn(arg) {
123
113
  if (arg === value) {
124
114
  done();
@@ -126,7 +116,6 @@ describe('Job', function () {
126
116
  done(new Error('fn did not receive argument'));
127
117
  }
128
118
  };
129
-
130
119
  var j = new _Job["default"](fn, 10);
131
120
  j.idle(value);
132
121
  jest.runAllTimers();
@@ -139,7 +128,6 @@ describe('Job', function () {
139
128
  done();
140
129
  }
141
130
  };
142
-
143
131
  var j = new _Job["default"](fn);
144
132
  j.idle('first');
145
133
  j.idle('second');
@@ -151,7 +139,6 @@ describe('Job', function () {
151
139
  var j = new _Job["default"](function () {
152
140
  return done(new Error('Unexpected job execution'));
153
141
  });
154
-
155
142
  try {
156
143
  j.promise({});
157
144
  } catch (msg) {
@@ -162,7 +149,6 @@ describe('Job', function () {
162
149
  var j = new _Job["default"](function () {
163
150
  return done();
164
151
  });
165
-
166
152
  try {
167
153
  j.promise({
168
154
  then: function then(fn) {
@@ -1,9 +1,7 @@
1
1
  "use strict";
2
2
 
3
3
  var _react = require("react");
4
-
5
4
  var _util = require("../util");
6
-
7
5
  describe('util', function () {
8
6
  describe('isRenderable', function () {
9
7
  test('should return {true} for function', function () {
@@ -35,11 +33,10 @@ describe('util', function () {
35
33
  describe('memoize', function () {
36
34
  test('should memoize function', function () {
37
35
  var obj = {},
38
- testMethod = function testMethod(key) {
39
- obj[key] = (obj[key] || 0) + 1;
40
- },
41
- memoizedTest = (0, _util.memoize)(testMethod);
42
-
36
+ testMethod = function testMethod(key) {
37
+ obj[key] = (obj[key] || 0) + 1;
38
+ },
39
+ memoizedTest = (0, _util.memoize)(testMethod);
43
40
  expect(obj).not.toHaveProperty('a');
44
41
  memoizedTest('a');
45
42
  expect(obj).toHaveProperty('a', 1);
@@ -82,8 +79,8 @@ describe('util', function () {
82
79
  expect(actual).toEqual(expected);
83
80
  });
84
81
  test('Does not call filter with nullish or false entries', function () {
85
- var spy = jest.fn(); // eslint-disable-next-line no-undefined
86
-
82
+ var spy = jest.fn();
83
+ // eslint-disable-next-line no-undefined
87
84
  var children = [1, 2, null, 3, undefined, false];
88
85
  (0, _util.mapAndFilterChildren)(children, spy);
89
86
  var expected = 3;
@@ -111,9 +108,11 @@ describe('util', function () {
111
108
  test('should forward value and index to callback', function () {
112
109
  var spy = jest.fn();
113
110
  (0, _util.mapAndFilterChildren)([1], spy);
114
- var expected = [1, // value
111
+ var expected = [1,
112
+ // value
115
113
  0 // index
116
114
  ];
115
+
117
116
  var actual = spy.mock.calls[0];
118
117
  expect(expected).toEqual(actual);
119
118
  });