@enact/core 4.5.0-alpha.2 → 4.5.0-rc.2

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,20 @@
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.5.0-rc.2] - 2022-07-06
6
+
7
+ ### Changed
8
+
9
+ - `core/handle.forwardCustom` handler to include `preventDefault` and `stopPropagation` methods in the forwarded event payload
10
+
11
+ ## [4.5.0-rc.1] - 2022-06-23
12
+
13
+ No significant changes.
14
+
15
+ ## [4.5.0-beta.1] - 2022-05-31
16
+
17
+ No significant changes.
18
+
5
19
  ## [4.5.0-alpha.2] - 2022-05-09
6
20
 
7
21
  No significant changes.
package/handle/handle.js CHANGED
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.stopImmediate = exports.stop = exports.returnsTrue = exports.preventDefault = exports.oneOf = exports.not = exports.log = exports.handle = exports.forwardWithPrevent = exports.forwardCustom = exports.forward = exports.forProp = exports.forKeyCode = exports.forKey = exports.forEventProp = exports["default"] = exports.callOnEvent = exports.call = exports.adaptEvent = void 0;
6
+ exports.stopImmediate = exports.stop = exports.returnsTrue = exports.preventDefault = exports.oneOf = exports.not = exports.log = exports.handle = exports.forwardWithPrevent = exports.forwardCustomWithPrevent = exports.forwardCustom = exports.forward = exports.forProp = exports.forKeyCode = exports.forKey = exports.forEventProp = exports["default"] = exports.callOnEvent = exports.call = exports.adaptEvent = void 0;
7
7
 
8
8
  var _cond = _interopRequireDefault(require("ramda/src/cond"));
9
9
 
@@ -475,7 +475,7 @@ var _preventDefault = handle.preventDefault = callOnEvent('preventDefault');
475
475
  * @param {Object} ev Event payload
476
476
  * @param {Object} props Props object
477
477
  *
478
- * @returns {Boolean} Returns `true` if default action is prevented
478
+ * @returns {Boolean} Returns `false` if default action is prevented
479
479
  * @curried
480
480
  * @memberof core/handle
481
481
  * @private
@@ -795,17 +795,110 @@ var adaptEvent = handle.adaptEvent = (0, _curry["default"])(function (adapter, h
795
795
  exports.adaptEvent = adaptEvent;
796
796
 
797
797
  var forwardCustom = handle.forwardCustom = function (name, adapter) {
798
- return handle(adaptEvent(function () {
799
- var ev = adapter ? adapter.apply(void 0, arguments) : null; // Handle either no adapter or a non-object return from the adapter
798
+ return handle(adaptEvent(function (ev) {
799
+ for (var _len7 = arguments.length, args = new Array(_len7 > 1 ? _len7 - 1 : 0), _key7 = 1; _key7 < _len7; _key7++) {
800
+ args[_key7 - 1] = arguments[_key7];
801
+ }
802
+
803
+ var customEventPayload = adapter ? adapter.apply(void 0, [ev].concat(args)) : null; // Handle either no adapter or a non-object return from the adapter
804
+
805
+ if (!customEventPayload || typeof customEventPayload !== 'object') {
806
+ customEventPayload = {};
807
+ }
800
808
 
801
- if (!ev || typeof ev !== 'object') {
802
- ev = {};
809
+ customEventPayload.type = name;
810
+
811
+ if (typeof customEventPayload.preventDefault !== 'function' && typeof (ev === null || ev === void 0 ? void 0 : ev.preventDefault) === 'function') {
812
+ customEventPayload.preventDefault = ev.preventDefault.bind(ev);
813
+ }
814
+
815
+ if (typeof customEventPayload.stopPropagation !== 'function' && typeof (ev === null || ev === void 0 ? void 0 : ev.stopPropagation) === 'function') {
816
+ customEventPayload.stopPropagation = ev.stopPropagation.bind(ev);
803
817
  }
804
818
 
805
- ev.type = name;
806
- return ev;
819
+ return customEventPayload;
807
820
  }, forward(name))).named('forwardCustom');
808
821
  };
822
+ /**
823
+ * Creates a handler that will forward the event to a function at `name` on `props` with capability
824
+ * to prevent default behavior. If the specified prop is `undefined` or is not a function, it is
825
+ * ignored. The created handler returns `false` when `event.preventDefault()` has been called in a handler.
826
+ *
827
+ * If `adapter` is not specified, a new event payload will be generated with a `type` member with
828
+ * the `name` of the custom event. If `adapter` is specified, the `type` member is added to the
829
+ * value returned by `adapter`.
830
+ *
831
+ * The `adapter` function receives the same arguments as any handler. The value returned from
832
+ * `adapter` is passed as the first argument to `handler` with the remaining arguments kept the
833
+ * same. This is often useful to generate a custom event payload before forwarding on to a callback.
834
+ *
835
+ * Example:
836
+ * ```
837
+ * import {forwardCustomWithPrevent, handle} from '@enact/core/handle';
838
+ *
839
+ * // calls the onChange callback with the event: {type: 'onChange'}
840
+ * const forwardChangePreventDefault = handle(
841
+ * forwardCustomWithPrevent('onChange'),
842
+ * (ev) => console.log('default action', ev)
843
+ * );
844
+ *
845
+ * // calls the onChange callback with the event: {type: 'onChange', index}
846
+ * const forwardChangeWithIndexPreventDefault = handle(
847
+ * forwardCustomWithPrevent('onChange', (ev, {index}) => ({index})),
848
+ * (ev) => console.log('default action', ev)
849
+ * );
850
+ * ```
851
+ *
852
+ * @method forwardCustomWithPrevent
853
+ * @param {String} name Name of method on the `props`
854
+ * @param {EventAdapter} [adapter] Function to adapt the event payload
855
+ *
856
+ * @returns {HandlerFunction} Returns an [event handler]{@link core/handle.EventHandler}
857
+ * (suitable for passing to handle or used directly within
858
+ * `handlers` in [kind]{@link core/kind}) that will forward the
859
+ * custom event and will return `false` if default action is prevented
860
+ * @memberof core/handle
861
+ * @private
862
+ */
863
+
864
+
865
+ exports.forwardCustom = forwardCustom;
866
+ var forwardCustomWithPrevent = handle.forwardCustomWithPrevent = named(function (name, adapter) {
867
+ var prevented = false;
868
+
869
+ var adapterWithPrevent = function adapterWithPrevent(ev) {
870
+ for (var _len8 = arguments.length, args = new Array(_len8 > 1 ? _len8 - 1 : 0), _key8 = 1; _key8 < _len8; _key8++) {
871
+ args[_key8 - 1] = arguments[_key8];
872
+ }
873
+
874
+ var customEventPayload = adapter ? adapter.apply(void 0, [ev].concat(args)) : null;
875
+ var existingPreventDefault = null; // Handle either no adapter or a non-object return from the adapter
876
+
877
+ if (!customEventPayload || typeof customEventPayload !== 'object') {
878
+ customEventPayload = {};
879
+ }
880
+
881
+ if (typeof customEventPayload.preventDefault === 'function') {
882
+ existingPreventDefault = customEventPayload.preventDefault;
883
+ } else if (typeof ev.preventDefault === 'function') {
884
+ existingPreventDefault = ev.preventDefault.bind(ev);
885
+ }
886
+
887
+ customEventPayload.preventDefault = function () {
888
+ prevented = true;
889
+
890
+ if (typeof existingPreventDefault === 'function') {
891
+ existingPreventDefault();
892
+ }
893
+ };
894
+
895
+ return customEventPayload;
896
+ };
897
+
898
+ return handle(forwardCustom(name, adapterWithPrevent), function () {
899
+ return !prevented;
900
+ });
901
+ }, 'forwardCustomWithPrevent');
809
902
  /**
810
903
  * Accepts a handler and returns the logical complement of the value returned from the handler.
811
904
  *
@@ -832,8 +925,7 @@ var forwardCustom = handle.forwardCustom = function (name, adapter) {
832
925
  * @public
833
926
  */
834
927
 
835
-
836
- exports.forwardCustom = forwardCustom;
928
+ exports.forwardCustomWithPrevent = forwardCustomWithPrevent;
837
929
 
838
930
  var not = handle.not = function (handler) {
839
931
  return function () {
@@ -29,7 +29,7 @@ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _d
29
29
 
30
30
  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); }
31
31
 
32
- function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
32
+ function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
33
33
 
34
34
  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); }; }
35
35
 
@@ -39,7 +39,7 @@ function _assertThisInitialized(self) { if (self === void 0) { throw new Referen
39
39
 
40
40
  function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
41
41
 
42
- function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
42
+ function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
43
43
 
44
44
  // Gets a property from `provider`
45
45
  var get = function get(provider, name) {
@@ -18,7 +18,7 @@ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _d
18
18
 
19
19
  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); }
20
20
 
21
- function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
21
+ function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
22
22
 
23
23
  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); }; }
24
24
 
@@ -28,7 +28,7 @@ function _assertThisInitialized(self) { if (self === void 0) { throw new Referen
28
28
 
29
29
  function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
30
30
 
31
- function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
31
+ function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
32
32
 
33
33
  describe('ApiDecorator', function () {
34
34
  var _class;
@@ -28,7 +28,7 @@ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _d
28
28
 
29
29
  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); }
30
30
 
31
- function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
31
+ function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
32
32
 
33
33
  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); }; }
34
34
 
@@ -38,7 +38,7 @@ function _assertThisInitialized(self) { if (self === void 0) { throw new Referen
38
38
 
39
39
  function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
40
40
 
41
- function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
41
+ function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
42
42
 
43
43
  var SomeContext = /*#__PURE__*/(0, _react.createContext)();
44
44
  describe('Registry', function () {
package/kind/kind.js CHANGED
@@ -25,7 +25,7 @@ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _d
25
25
 
26
26
  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); }
27
27
 
28
- function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
28
+ function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
29
29
 
30
30
  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); }; }
31
31
 
@@ -35,7 +35,7 @@ function _assertThisInitialized(self) { if (self === void 0) { throw new Referen
35
35
 
36
36
  function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
37
37
 
38
- function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
38
+ function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
39
39
 
40
40
  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; }
41
41
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@enact/core",
3
- "version": "4.5.0-alpha.2",
3
+ "version": "4.5.0-rc.2",
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": {
@@ -8,11 +8,11 @@ exports.useClass = useClass;
8
8
 
9
9
  var _react = require("react");
10
10
 
11
- function _construct(Parent, args, Class) { if (_isNativeReflectConstruct()) { _construct = Reflect.construct; } else { _construct = function _construct(Parent, args, Class) { var a = [null]; a.push.apply(a, args); var Constructor = Function.bind.apply(Parent, a); var instance = new Constructor(); if (Class) _setPrototypeOf(instance, Class.prototype); return instance; }; } return _construct.apply(null, arguments); }
11
+ function _construct(Parent, args, Class) { if (_isNativeReflectConstruct()) { _construct = Reflect.construct.bind(); } else { _construct = function _construct(Parent, args, Class) { var a = [null]; a.push.apply(a, args); var Constructor = Function.bind.apply(Parent, a); var instance = new Constructor(); if (Class) _setPrototypeOf(instance, Class.prototype); return instance; }; } return _construct.apply(null, arguments); }
12
12
 
13
13
  function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
14
14
 
15
- function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
15
+ function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
16
16
 
17
17
  /**
18
18
  * Creates one instance of the class, `Ctor` with the provided `args`, for the life of the
@@ -1,14 +1,23 @@
1
1
  "use strict";
2
2
 
3
+ var _react = require("@testing-library/react");
4
+
3
5
  var _Job = _interopRequireDefault(require("../Job"));
4
6
 
5
7
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
6
8
 
7
9
  describe('Job', function () {
10
+ beforeEach(function () {
11
+ jest.useFakeTimers();
12
+ });
13
+ afterEach(function () {
14
+ jest.useRealTimers();
15
+ });
8
16
  describe('#start', function () {
9
17
  test('should start job', function (done) {
10
18
  var j = new _Job["default"](done, 10);
11
19
  j.start();
20
+ jest.runAllTimers();
12
21
  });
13
22
  test('should pass args to fn', function (done) {
14
23
  var value = 'argument';
@@ -23,6 +32,7 @@ describe('Job', function () {
23
32
 
24
33
  var j = new _Job["default"](fn, 10);
25
34
  j.start(value);
35
+ jest.runAllTimers();
26
36
  });
27
37
  });
28
38
  describe('#stop', function () {
@@ -34,9 +44,10 @@ describe('Job', function () {
34
44
  }, 10);
35
45
  j.start();
36
46
  j.stop();
37
- window.setTimeout(function () {
38
- if (!ran) done();
39
- }, 30);
47
+ (0, _react.act)(function () {
48
+ return jest.advanceTimersByTime(30);
49
+ });
50
+ if (!ran) done();
40
51
  });
41
52
  });
42
53
  describe('#throttle', function () {
@@ -46,22 +57,27 @@ describe('Job', function () {
46
57
  number++;
47
58
  }, 20);
48
59
  j.throttle();
49
- window.setTimeout(function () {
50
- j.throttle();
51
- }, 5);
52
- window.setTimeout(function () {
53
- j.throttle();
54
- }, 15);
55
- window.setTimeout(function () {
56
- j.throttle();
57
- }, 25);
58
- window.setTimeout(function () {
59
- if (number === 2) {
60
- done();
61
- } else {
62
- done(new Error('too many or too few calls' + number));
63
- }
64
- }, 30);
60
+ (0, _react.act)(function () {
61
+ return jest.advanceTimersByTime(5);
62
+ });
63
+ j.throttle();
64
+ (0, _react.act)(function () {
65
+ return jest.advanceTimersByTime(10);
66
+ });
67
+ j.throttle();
68
+ (0, _react.act)(function () {
69
+ return jest.advanceTimersByTime(10);
70
+ });
71
+ j.throttle();
72
+ (0, _react.act)(function () {
73
+ return jest.advanceTimersByTime(5);
74
+ });
75
+
76
+ if (number === 2) {
77
+ done();
78
+ } else {
79
+ done(new Error('too many or too few calls' + number));
80
+ }
65
81
  });
66
82
  test('should pass args to fn', function (done) {
67
83
  var value = 'argument';
@@ -98,6 +114,7 @@ describe('Job', function () {
98
114
  test('should start job', function (done) {
99
115
  var j = new _Job["default"](done, 10);
100
116
  j.idle();
117
+ jest.runAllTimers();
101
118
  });
102
119
  test('should pass args to fn', function (done) {
103
120
  var value = 'argument';
@@ -112,6 +129,7 @@ describe('Job', function () {
112
129
 
113
130
  var j = new _Job["default"](fn, 10);
114
131
  j.idle(value);
132
+ jest.runAllTimers();
115
133
  });
116
134
  test('should clear an existing job id before starting job', function (done) {
117
135
  var fn = function fn(arg) {
@@ -125,6 +143,7 @@ describe('Job', function () {
125
143
  var j = new _Job["default"](fn);
126
144
  j.idle('first');
127
145
  j.idle('second');
146
+ jest.runAllTimers();
128
147
  });
129
148
  });
130
149
  describe('#promise', function () {
@@ -165,7 +184,10 @@ describe('Job', function () {
165
184
  done(new Error('Job ran for rejected promise'));
166
185
  });
167
186
  j.promise(Promise.reject(true))["catch"](function () {});
168
- setTimeout(done, 10);
187
+ (0, _react.act)(function () {
188
+ return jest.advanceTimersByTime(10);
189
+ });
190
+ done();
169
191
  });
170
192
  test('should not start job when stopped before promise resolves', function (done) {
171
193
  var j = new _Job["default"](function () {
@@ -174,10 +196,14 @@ describe('Job', function () {
174
196
  j.promise(new Promise(function (resolve) {
175
197
  return setTimeout(resolve, 20);
176
198
  }));
177
- setTimeout(function () {
178
- return j.stop();
179
- }, 10);
180
- setTimeout(done, 30);
199
+ (0, _react.act)(function () {
200
+ return jest.advanceTimersByTime(10);
201
+ });
202
+ j.stop();
203
+ (0, _react.act)(function () {
204
+ return jest.advanceTimersByTime(20);
205
+ });
206
+ done();
181
207
  });
182
208
  test('should not start job when another is started', function (done) {
183
209
  var j = new _Job["default"](function (value) {
@@ -8,28 +8,28 @@ describe('util', function () {
8
8
  describe('isRenderable', function () {
9
9
  test('should return {true} for function', function () {
10
10
  var expected = true;
11
- var actual = (0, _util.isRenderable)(function () {});
12
- expect(actual).toEqual(expected);
11
+ var view = (0, _util.isRenderable)(function () {});
12
+ expect(view).toEqual(expected);
13
13
  });
14
14
  test('should return {true} for string', function () {
15
15
  var expected = true;
16
- var actual = (0, _util.isRenderable)('div');
17
- expect(actual).toEqual(expected);
16
+ var view = (0, _util.isRenderable)('div');
17
+ expect(view).toEqual(expected);
18
18
  });
19
19
  test('should return {true} for React.forwardRef', function () {
20
20
  var expected = true;
21
- var actual = (0, _util.isRenderable)( /*#__PURE__*/(0, _react.forwardRef)(function () {}));
22
- expect(actual).toEqual(expected);
21
+ var view = (0, _util.isRenderable)( /*#__PURE__*/(0, _react.forwardRef)(function () {}));
22
+ expect(view).toEqual(expected);
23
23
  });
24
24
  test('should return {true} for React.memo', function () {
25
25
  var expected = true;
26
- var actual = (0, _util.isRenderable)( /*#__PURE__*/(0, _react.memo)(function () {}));
27
- expect(actual).toEqual(expected);
26
+ var view = (0, _util.isRenderable)( /*#__PURE__*/(0, _react.memo)(function () {}));
27
+ expect(view).toEqual(expected);
28
28
  });
29
29
  test('should return {true} for React.lazy', function () {
30
30
  var expected = true;
31
- var actual = (0, _util.isRenderable)( /*#__PURE__*/(0, _react.lazy)(function () {}));
32
- expect(actual).toEqual(expected);
31
+ var view = (0, _util.isRenderable)( /*#__PURE__*/(0, _react.lazy)(function () {}));
32
+ expect(view).toEqual(expected);
33
33
  });
34
34
  });
35
35
  describe('memoize', function () {