@enact/core 3.4.9-experimental-3 → 3.4.9-experimental-7

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 (113) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/{build/dispatcher → dispatcher}/dispatcher.d.ts +0 -0
  3. package/dispatcher/dispatcher.js +76 -57
  4. package/dispatcher/listeners.js +31 -19
  5. package/dispatcher/tests/dispatcher-specs.js +75 -100
  6. package/{build/handle → handle}/handle.d.ts +0 -0
  7. package/handle/handle.js +260 -212
  8. package/handle/tests/handle-specs.js +476 -601
  9. package/{build/hoc → hoc}/hoc.d.ts +0 -0
  10. package/hoc/hoc.js +47 -33
  11. package/hoc/tests/hoc-specs.js +85 -126
  12. package/{build/index.d.ts → index.d.ts} +0 -0
  13. package/index.js +1 -0
  14. package/{build/internal → internal}/ApiDecorator/ApiDecorator.d.ts +0 -0
  15. package/internal/ApiDecorator/ApiDecorator.js +107 -61
  16. package/internal/ApiDecorator/tests/ApiDecorator-specs.js +106 -97
  17. package/{build/internal → internal}/Registry/Registry.d.ts +0 -0
  18. package/internal/Registry/Registry.js +68 -51
  19. package/internal/Registry/tests/Registry-specs.js +201 -143
  20. package/{build/internal → internal}/deprecate/deprecate.d.ts +0 -0
  21. package/internal/deprecate/deprecate.js +85 -60
  22. package/{build/internal → internal}/prop-types/prop-types.d.ts +0 -0
  23. package/internal/prop-types/prop-types.js +68 -61
  24. package/{build/keymap → keymap}/index.d.ts +0 -0
  25. package/keymap/index.js +27 -15
  26. package/keymap/keymap.js +67 -52
  27. package/keymap/tests/keymap-specs.js +75 -104
  28. package/kind/computed.js +29 -16
  29. package/{build/kind → kind}/kind.d.ts +0 -0
  30. package/kind/kind.js +150 -114
  31. package/kind/styles.js +62 -47
  32. package/kind/tests/computed-specs.js +87 -86
  33. package/kind/tests/kind-specs.js +216 -214
  34. package/kind/tests/styles-specs.js +170 -223
  35. package/kind/util.js +15 -7
  36. package/package.json +1 -1
  37. package/{build/platform → platform}/platform.d.ts +0 -0
  38. package/platform/platform.js +263 -169
  39. package/platform/tests/platform-specs.js +92 -90
  40. package/{build/snapshot → snapshot}/snapshot.d.ts +0 -0
  41. package/snapshot/snapshot.js +34 -27
  42. package/useChainRefs/tests/useChainRefs-specs.js +46 -30
  43. package/{build/useChainRefs → useChainRefs}/useChainRefs.d.ts +0 -0
  44. package/useChainRefs/useChainRefs.js +49 -29
  45. package/useClass/tests/useClass-specs.js +51 -46
  46. package/{build/useClass → useClass}/useClass.d.ts +0 -0
  47. package/useClass/useClass.js +27 -9
  48. package/useHandlers/Handlers.js +55 -30
  49. package/useHandlers/tests/useHandlers-specs.js +79 -95
  50. package/{build/useHandlers → useHandlers}/useHandlers.d.ts +0 -0
  51. package/useHandlers/useHandlers.js +18 -11
  52. package/util/Job.js +203 -241
  53. package/util/tests/Job-specs.js +216 -204
  54. package/util/tests/util-specs.js +123 -146
  55. package/{build/util → util}/util.d.ts +0 -0
  56. package/util/util.js +146 -103
  57. package/build/CHANGELOG.md +0 -699
  58. package/build/README.md +0 -33
  59. package/build/dispatcher/dispatcher.js +0 -160
  60. package/build/dispatcher/listeners.js +0 -37
  61. package/build/dispatcher/package.json +0 -3
  62. package/build/dispatcher/tests/dispatcher-specs.js +0 -75
  63. package/build/handle/handle.js +0 -846
  64. package/build/handle/package.json +0 -3
  65. package/build/handle/tests/handle-specs.js +0 -476
  66. package/build/hoc/hoc.js +0 -102
  67. package/build/hoc/package.json +0 -3
  68. package/build/hoc/tests/hoc-specs.js +0 -90
  69. package/build/index.js +0 -2
  70. package/build/internal/ApiDecorator/ApiDecorator.js +0 -143
  71. package/build/internal/ApiDecorator/package.json +0 -3
  72. package/build/internal/ApiDecorator/tests/ApiDecorator-specs.js +0 -106
  73. package/build/internal/Registry/Registry.js +0 -76
  74. package/build/internal/Registry/package.json +0 -3
  75. package/build/internal/Registry/tests/Registry-specs.js +0 -201
  76. package/build/internal/deprecate/deprecate.js +0 -116
  77. package/build/internal/deprecate/package.json +0 -3
  78. package/build/internal/prop-types/package.json +0 -3
  79. package/build/internal/prop-types/prop-types.js +0 -90
  80. package/build/keymap/index.js +0 -54
  81. package/build/keymap/keymap.js +0 -201
  82. package/build/keymap/package.json +0 -3
  83. package/build/keymap/tests/keymap-specs.js +0 -75
  84. package/build/kind/computed.js +0 -60
  85. package/build/kind/kind.js +0 -266
  86. package/build/kind/package.json +0 -3
  87. package/build/kind/styles.js +0 -105
  88. package/build/kind/tests/computed-specs.js +0 -87
  89. package/build/kind/tests/kind-specs.js +0 -216
  90. package/build/kind/tests/styles-specs.js +0 -170
  91. package/build/kind/util.js +0 -17
  92. package/build/package-lock.json +0 -206
  93. package/build/package.json +0 -38
  94. package/build/platform/package.json +0 -3
  95. package/build/platform/platform.js +0 -306
  96. package/build/platform/tests/platform-specs.js +0 -92
  97. package/build/snapshot/package.json +0 -3
  98. package/build/snapshot/snapshot.js +0 -89
  99. package/build/useChainRefs/package.json +0 -3
  100. package/build/useChainRefs/tests/useChainRefs-specs.js +0 -57
  101. package/build/useChainRefs/useChainRefs.js +0 -78
  102. package/build/useClass/package.json +0 -3
  103. package/build/useClass/tests/useClass-specs.js +0 -51
  104. package/build/useClass/useClass.js +0 -59
  105. package/build/useHandlers/Handlers.js +0 -55
  106. package/build/useHandlers/package.json +0 -3
  107. package/build/useHandlers/tests/useHandlers-specs.js +0 -84
  108. package/build/useHandlers/useHandlers.js +0 -36
  109. package/build/util/Job.js +0 -211
  110. package/build/util/package.json +0 -3
  111. package/build/util/tests/Job-specs.js +0 -216
  112. package/build/util/tests/util-specs.js +0 -123
  113. package/build/util/util.js +0 -322
@@ -1,204 +1,216 @@
1
- import Job from '../Job';
2
-
3
- describe('Job', () => {
4
- describe('#start', () => {
5
- test('should start job', done => {
6
- const j = new Job(done, 10);
7
- j.start();
8
- });
9
-
10
- test('should pass args to fn', done => {
11
- const value = 'argument';
12
- const fn = function (arg) {
13
- if (arg === value) {
14
- done();
15
- } else {
16
- done(new Error('fn did not receive argument'));
17
- }
18
- };
19
-
20
- const j = new Job(fn, 10);
21
- j.start(value);
22
- });
23
- });
24
-
25
- describe('#stop', () => {
26
- test('should stop job', done => {
27
- let ran = false;
28
- const j = new Job(function () {
29
- ran = true;
30
- done(new Error('job wasn\'t stopped'));
31
- }, 10);
32
-
33
- j.start();
34
- j.stop();
35
-
36
- window.setTimeout(function () {
37
- if (!ran) done();
38
- }, 30);
39
- });
40
- });
41
-
42
- describe('#throttle', () => {
43
- test('should throttle job', done => {
44
- let number = 0;
45
- const j = new Job(function () {
46
- number++;
47
- }, 20);
48
-
49
- j.throttle();
50
- window.setTimeout(function () {
51
- j.throttle();
52
- }, 5);
53
- window.setTimeout(function () {
54
- j.throttle();
55
- }, 15);
56
- window.setTimeout(function () {
57
- j.throttle();
58
- }, 25);
59
- window.setTimeout(function () {
60
- if (number === 2) {
61
- done();
62
- } else {
63
- done(new Error('too many or too few calls' + number));
64
- }
65
- }, 30);
66
- });
67
-
68
- test('should pass args to fn', done => {
69
- const value = 'argument';
70
- const fn = function (arg) {
71
- if (arg === value) {
72
- done();
73
- } else {
74
- done(new Error('fn did not receive argument'));
75
- }
76
- };
77
-
78
- const j = new Job(fn, 10);
79
- j.throttle(value);
80
- });
81
- });
82
-
83
- describe('#idle', () => {
84
- // polyfill for PhantomJS to verify expected idle behavior as much as possible
85
- const windowRequest = window.requestIdleCallback;
86
- const windowCancel = window.cancelIdleCallback;
87
-
88
- beforeAll(() => {
89
- window.requestIdleCallback = windowRequest || function (fn) {
90
- return setTimeout(fn, 0);
91
- };
92
- window.cancelIdleCallback = windowCancel || function (id) {
93
- clearTimeout(id);
94
- };
95
- });
96
-
97
- afterAll(() => {
98
- window.requestIdleCallback = windowRequest;
99
- window.cancelIdleCallback = windowCancel;
100
- });
101
-
102
- test('should start job', done => {
103
- const j = new Job(done, 10);
104
- j.idle();
105
- });
106
-
107
- test('should pass args to fn', done => {
108
- const value = 'argument';
109
- const fn = function (arg) {
110
- if (arg === value) {
111
- done();
112
- } else {
113
- done(new Error('fn did not receive argument'));
114
- }
115
- };
116
-
117
- const j = new Job(fn, 10);
118
- j.idle(value);
119
- });
120
-
121
- test('should clear an existing job id before starting job', done => {
122
- const fn = function (arg) {
123
- if (arg === 'first') {
124
- done(new Error('First job ran'));
125
- } else {
126
- done();
127
- }
128
- };
129
- const j = new Job(fn);
130
- j.idle('first');
131
- j.idle('second');
132
- });
133
- });
134
-
135
- describe('#promise', function () {
136
- test('should throw when passed a non-thenable argument', done => {
137
- const j = new Job(() => done(new Error('Unexpected job execution')));
138
- try {
139
- j.promise({});
140
- } catch (msg) {
141
- done();
142
- }
143
- });
144
-
145
- test('should support a non-Promise, thenable argument', done => {
146
- const j = new Job(() => done());
147
- try {
148
- j.promise({
149
- then: (fn) => fn(true)
150
- });
151
- } catch (msg) {
152
- done(msg);
153
- }
154
- });
155
-
156
- test('should start job for a resolved promise', done => {
157
- const j = new Job(() => done());
158
- j.promise(Promise.resolve(true));
159
- });
160
-
161
- test('should not start job for a rejected promise', done => {
162
- const j = new Job(() => {
163
- done(new Error('Job ran for rejected promise'));
164
- });
165
- j.promise(Promise.reject(true)).catch(() => {});
166
- setTimeout(done, 10);
167
- });
168
-
169
- test('should not start job when stopped before promise resolves', done => {
170
- const j = new Job(() => {
171
- done(new Error('Job ran for stopped promise'));
172
- });
173
- j.promise(new Promise(resolve => setTimeout(resolve, 20)));
174
- setTimeout(() => j.stop(), 10);
175
- setTimeout(done, 30);
176
- });
177
-
178
- test('should not start job when another is started', done => {
179
- const j = new Job((value) => {
180
- expect(value).toBe(2);
181
- done();
182
- });
183
- j.promise(new Promise(resolve => resolve(1)));
184
- j.promise(new Promise(resolve => resolve(2)));
185
- });
186
-
187
- test('should return the value from the job to the resolved promise', done => {
188
- const j = new Job(() => 'job value');
189
- j.promise(Promise.resolve(true)).then(value => {
190
- expect(value).toBe('job value');
191
- done();
192
- });
193
- });
194
-
195
- test('should not return the value from the job to the replaced promise', done => {
196
- const j = new Job(() => 'job value');
197
- j.promise(Promise.resolve(true)).then(value => {
198
- expect(value).toBeUndefined();
199
- done();
200
- });
201
- j.promise(Promise.resolve(true)).then(() => done());
202
- });
203
- });
204
- });
1
+ "use strict";
2
+
3
+ var _Job = _interopRequireDefault(require("../Job"));
4
+
5
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
6
+
7
+ describe('Job', function () {
8
+ describe('#start', function () {
9
+ test('should start job', function (done) {
10
+ var j = new _Job["default"](done, 10);
11
+ j.start();
12
+ });
13
+ test('should pass args to fn', function (done) {
14
+ var value = 'argument';
15
+
16
+ var fn = function fn(arg) {
17
+ if (arg === value) {
18
+ done();
19
+ } else {
20
+ done(new Error('fn did not receive argument'));
21
+ }
22
+ };
23
+
24
+ var j = new _Job["default"](fn, 10);
25
+ j.start(value);
26
+ });
27
+ });
28
+ describe('#stop', function () {
29
+ test('should stop job', function (done) {
30
+ var ran = false;
31
+ var j = new _Job["default"](function () {
32
+ ran = true;
33
+ done(new Error('job wasn\'t stopped'));
34
+ }, 10);
35
+ j.start();
36
+ j.stop();
37
+ window.setTimeout(function () {
38
+ if (!ran) done();
39
+ }, 30);
40
+ });
41
+ });
42
+ describe('#throttle', function () {
43
+ test('should throttle job', function (done) {
44
+ var number = 0;
45
+ var j = new _Job["default"](function () {
46
+ number++;
47
+ }, 20);
48
+ 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);
65
+ });
66
+ test('should pass args to fn', function (done) {
67
+ var value = 'argument';
68
+
69
+ var fn = function fn(arg) {
70
+ if (arg === value) {
71
+ done();
72
+ } else {
73
+ done(new Error('fn did not receive argument'));
74
+ }
75
+ };
76
+
77
+ var j = new _Job["default"](fn, 10);
78
+ j.throttle(value);
79
+ });
80
+ });
81
+ describe('#idle', function () {
82
+ // polyfill for PhantomJS to verify expected idle behavior as much as possible
83
+ var windowRequest = window.requestIdleCallback;
84
+ var windowCancel = window.cancelIdleCallback;
85
+ beforeAll(function () {
86
+ window.requestIdleCallback = windowRequest || function (fn) {
87
+ return setTimeout(fn, 0);
88
+ };
89
+
90
+ window.cancelIdleCallback = windowCancel || function (id) {
91
+ clearTimeout(id);
92
+ };
93
+ });
94
+ afterAll(function () {
95
+ window.requestIdleCallback = windowRequest;
96
+ window.cancelIdleCallback = windowCancel;
97
+ });
98
+ test('should start job', function (done) {
99
+ var j = new _Job["default"](done, 10);
100
+ j.idle();
101
+ });
102
+ test('should pass args to fn', function (done) {
103
+ var value = 'argument';
104
+
105
+ var fn = function fn(arg) {
106
+ if (arg === value) {
107
+ done();
108
+ } else {
109
+ done(new Error('fn did not receive argument'));
110
+ }
111
+ };
112
+
113
+ var j = new _Job["default"](fn, 10);
114
+ j.idle(value);
115
+ });
116
+ test('should clear an existing job id before starting job', function (done) {
117
+ var fn = function fn(arg) {
118
+ if (arg === 'first') {
119
+ done(new Error('First job ran'));
120
+ } else {
121
+ done();
122
+ }
123
+ };
124
+
125
+ var j = new _Job["default"](fn);
126
+ j.idle('first');
127
+ j.idle('second');
128
+ });
129
+ });
130
+ describe('#promise', function () {
131
+ test('should throw when passed a non-thenable argument', function (done) {
132
+ var j = new _Job["default"](function () {
133
+ return done(new Error('Unexpected job execution'));
134
+ });
135
+
136
+ try {
137
+ j.promise({});
138
+ } catch (msg) {
139
+ done();
140
+ }
141
+ });
142
+ test('should support a non-Promise, thenable argument', function (done) {
143
+ var j = new _Job["default"](function () {
144
+ return done();
145
+ });
146
+
147
+ try {
148
+ j.promise({
149
+ then: function then(fn) {
150
+ return fn(true);
151
+ }
152
+ });
153
+ } catch (msg) {
154
+ done(msg);
155
+ }
156
+ });
157
+ test('should start job for a resolved promise', function (done) {
158
+ var j = new _Job["default"](function () {
159
+ return done();
160
+ });
161
+ j.promise(Promise.resolve(true));
162
+ });
163
+ test('should not start job for a rejected promise', function (done) {
164
+ var j = new _Job["default"](function () {
165
+ done(new Error('Job ran for rejected promise'));
166
+ });
167
+ j.promise(Promise.reject(true))["catch"](function () {});
168
+ setTimeout(done, 10);
169
+ });
170
+ test('should not start job when stopped before promise resolves', function (done) {
171
+ var j = new _Job["default"](function () {
172
+ done(new Error('Job ran for stopped promise'));
173
+ });
174
+ j.promise(new Promise(function (resolve) {
175
+ return setTimeout(resolve, 20);
176
+ }));
177
+ setTimeout(function () {
178
+ return j.stop();
179
+ }, 10);
180
+ setTimeout(done, 30);
181
+ });
182
+ test('should not start job when another is started', function (done) {
183
+ var j = new _Job["default"](function (value) {
184
+ expect(value).toBe(2);
185
+ done();
186
+ });
187
+ j.promise(new Promise(function (resolve) {
188
+ return resolve(1);
189
+ }));
190
+ j.promise(new Promise(function (resolve) {
191
+ return resolve(2);
192
+ }));
193
+ });
194
+ test('should return the value from the job to the resolved promise', function (done) {
195
+ var j = new _Job["default"](function () {
196
+ return 'job value';
197
+ });
198
+ j.promise(Promise.resolve(true)).then(function (value) {
199
+ expect(value).toBe('job value');
200
+ done();
201
+ });
202
+ });
203
+ test('should not return the value from the job to the replaced promise', function (done) {
204
+ var j = new _Job["default"](function () {
205
+ return 'job value';
206
+ });
207
+ j.promise(Promise.resolve(true)).then(function (value) {
208
+ expect(value).toBeUndefined();
209
+ done();
210
+ });
211
+ j.promise(Promise.resolve(true)).then(function () {
212
+ return done();
213
+ });
214
+ });
215
+ });
216
+ });