@enact/ui 5.4.2 → 5.5.0

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 (65) hide show
  1. package/AnnounceDecorator/Announce.js +9 -5
  2. package/AnnounceDecorator/AnnounceDecorator.js +5 -3
  3. package/AnnounceDecorator/tests/AnnounceDecorator-specs.js +4 -1
  4. package/AnnounceDecorator/tests/useAnnounce-specs.js +4 -1
  5. package/CHANGELOG.md +25 -0
  6. package/Cancelable/Cancelable.js +7 -0
  7. package/Cancelable/tests/Cancelable-specs.js +26 -0
  8. package/Changeable/Changeable.js +6 -0
  9. package/Changeable/tests/Changeable-specs.js +4 -1
  10. package/FloatingLayer/FloatingLayer.js +3 -0
  11. package/FloatingLayer/FloatingLayerDecorator.js +2 -0
  12. package/FloatingLayer/Scrim.js +3 -0
  13. package/Marquee/Marquee.module.css +1 -1
  14. package/Marquee/MarqueeDecorator.js +19 -3
  15. package/Marquee/tests/Marquee-specs.js +306 -1
  16. package/Marquee/useMarqueeController.js +6 -4
  17. package/Measurable/tests/Measurable-specs.js +6 -2
  18. package/Media/Media.js +5 -2
  19. package/Placeholder/tests/PlaceholderControllerDecorator-specs.js +4 -1
  20. package/Resizable/tests/Resizable-specs.js +4 -1
  21. package/Resizable/tests/useResize-specs.js +4 -1
  22. package/Routable/Route.js +5 -3
  23. package/Routable/Router.js +25 -16
  24. package/Routable/tests/Routable-specs.js +16 -0
  25. package/Scroller/Scroller.js +6 -5
  26. package/Scroller/ScrollerBasic.js +5 -5
  27. package/Skinnable/Skinnable.js +9 -7
  28. package/Skinnable/tests/Skinnable-specs.js +7 -2
  29. package/Skinnable/useSkins.js +6 -2
  30. package/Slider/PositionDecorator.js +20 -5
  31. package/Slider/Slider.d.ts +4 -0
  32. package/Slider/Slider.js +10 -0
  33. package/Slider/tests/Slider-specs.js +18 -0
  34. package/Slider/utils.js +9 -1
  35. package/Toggleable/Toggleable.js +4 -2
  36. package/Toggleable/tests/Toggleable-specs.js +4 -1
  37. package/Touchable/Touchable.js +6 -4
  38. package/Touchable/tests/Touchable-specs.js +4 -1
  39. package/Touchable/tests/useTouch-specs.js +4 -1
  40. package/Touchable/useTouch.js +7 -2
  41. package/Transition/Transition.js +2 -0
  42. package/ViewManager/TransitionGroup.js +3 -0
  43. package/ViewManager/View.js +2 -0
  44. package/ViewManager/ViewManager.js +7 -0
  45. package/VirtualList/VirtualList.js +7 -5
  46. package/VirtualList/VirtualListBasic.js +12 -7
  47. package/VirtualList/tests/VirtualList-native-specs.js +14 -0
  48. package/VirtualList/tests/VirtualList-specs.js +13 -0
  49. package/internal/IdProvider/IdProvider.js +2 -0
  50. package/internal/IdProvider/tests/IdProvider-specs.js +4 -1
  51. package/internal/Pure/tests/Pure-specs.js +7 -0
  52. package/package.json +12 -7
  53. package/resolution/ResolutionDecorator.js +21 -18
  54. package/resolution/index.d.ts +63 -4
  55. package/resolution/index.js +18 -2
  56. package/resolution/resolution.js +209 -29
  57. package/resolution/tests/ResolutionDecorator-specs.js +84 -4
  58. package/resolution/tests/resolution-specs.js +217 -599
  59. package/useControlledState/tests/useControlledState-specs.js +4 -1
  60. package/useControlledState/useControlledState.js +11 -7
  61. package/useScroll/Scrollbar.js +27 -24
  62. package/useScroll/ScrollbarTrack.js +5 -3
  63. package/useScroll/tests/useScroll-specs.js +148 -7
  64. package/useScroll/useScroll.js +94 -14
  65. package/useScroll/utilEvent.js +18 -0
@@ -1,6 +1,11 @@
1
1
  "use strict";
2
2
 
3
3
  var _resolution = require("../resolution.js");
4
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
5
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
6
+ function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
7
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
8
+ function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
4
9
  describe('Resolution Specs', function () {
5
10
  var screenTypes = [{
6
11
  name: 'vga',
@@ -129,603 +134,49 @@ describe('Resolution Specs', function () {
129
134
  expect((0, _resolution.getScreenType)(WUHD)).toBe('wuhd');
130
135
  expect((0, _resolution.getScreenType)(UHD2)).toBe('uhd2');
131
136
  });
132
- test('should select screen type whose height and width are both smaller than or same with the screen if `matchSmallerScreenType` true', function () {
133
- _resolution.config.matchSmallerScreenType = true;
134
-
135
- // if width or height of screen is smaller than the smallest screen type, select the smallest screen type
136
- expect((0, _resolution.getScreenType)({
137
- width: VGA.width - 1,
138
- height: VGA.height - 1
139
- })).toBe('vga');
140
- expect((0, _resolution.getScreenType)({
141
- width: VGA.width + 1,
142
- height: VGA.height - 1
143
- })).toBe('vga');
144
- expect((0, _resolution.getScreenType)({
145
- width: VGA.width - 1,
146
- height: VGA.height + 1
147
- })).toBe('vga');
148
-
149
- // VGA
150
- expect((0, _resolution.getScreenType)({
151
- width: VGA.width + 1,
152
- height: VGA.height + 1
153
- })).toBe('vga');
154
- expect((0, _resolution.getScreenType)({
155
- width: XGA.width - 1,
156
- height: XGA.height - 1
157
- })).toBe('vga');
158
- expect((0, _resolution.getScreenType)({
159
- width: XGA.width + 1,
160
- height: XGA.height - 1
161
- })).toBe('vga');
162
- expect((0, _resolution.getScreenType)({
163
- width: XGA.width - 1,
164
- height: XGA.height + 1
165
- })).toBe('vga');
166
- expect((0, _resolution.getScreenType)({
167
- width: HD.width - 1,
168
- height: HD.height - 1
169
- })).toBe('vga');
170
- expect((0, _resolution.getScreenType)({
171
- width: HD.width + 1,
172
- height: HD.height - 1
173
- })).toBe('vga');
174
- expect((0, _resolution.getScreenType)({
175
- width: HD.width - 1,
176
- height: HD.height + 1
177
- })).toBe('vga');
178
- expect((0, _resolution.getScreenType)({
179
- width: XGA.width,
180
- height: HD.height
181
- })).toBe('vga');
182
- expect((0, _resolution.getScreenType)({
183
- width: XGA.width - 1,
184
- height: HD.height - 1
185
- })).toBe('vga');
186
- expect((0, _resolution.getScreenType)({
187
- width: XGA.width + 1,
188
- height: HD.height - 1
189
- })).toBe('vga');
190
- expect((0, _resolution.getScreenType)({
191
- width: XGA.width - 1,
192
- height: HD.height + 1
193
- })).toBe('vga');
194
- expect((0, _resolution.getScreenType)({
195
- width: XGA.width + 1,
196
- height: HD.height + 1
197
- })).toBe('vga');
198
- expect((0, _resolution.getScreenType)({
199
- width: HD.width - 1,
200
- height: XGA.height - 1
201
- })).toBe('vga');
202
-
203
- // XGA
204
- expect((0, _resolution.getScreenType)({
205
- width: XGA.width + 1,
206
- height: XGA.height + 1
207
- })).toBe('xga');
208
- expect((0, _resolution.getScreenType)({
209
- width: HD.width - 1,
210
- height: XGA.height + 1
211
- })).toBe('xga');
212
-
213
- // HD
214
- expect((0, _resolution.getScreenType)({
215
- width: HD.width + 1,
216
- height: HD.height + 1
217
- })).toBe('hd');
218
- expect((0, _resolution.getScreenType)({
219
- width: HD.width,
220
- height: XGA.height
221
- })).toBe('hd');
222
- expect((0, _resolution.getScreenType)({
223
- width: HD.width + 1,
224
- height: XGA.height - 1
225
- })).toBe('hd');
226
- expect((0, _resolution.getScreenType)({
227
- width: HD.width + 1,
228
- height: XGA.height + 1
229
- })).toBe('hd');
230
- expect((0, _resolution.getScreenType)({
231
- width: UWHD.width - 1,
232
- height: UWHD.height - 1
233
- })).toBe('hd');
234
- expect((0, _resolution.getScreenType)({
235
- width: UWHD.width + 1,
236
- height: UWHD.height - 1
237
- })).toBe('hd');
238
- expect((0, _resolution.getScreenType)({
239
- width: UWHD.width - 1,
240
- height: UWHD.height + 1
241
- })).toBe('hd');
242
- expect((0, _resolution.getScreenType)({
243
- width: UWUXGA.width - 1,
244
- height: UWHD.height - 1
245
- })).toBe('hd');
246
- expect((0, _resolution.getScreenType)({
247
- width: UWUXGA.width + 1,
248
- height: UWHD.height - 1
249
- })).toBe('hd');
250
- expect((0, _resolution.getScreenType)({
251
- width: FHD.width - 1,
252
- height: FHD.height - 1
253
- })).toBe('hd');
254
- expect((0, _resolution.getScreenType)({
255
- width: FHD.width - 1,
256
- height: FHD.height + 1
257
- })).toBe('hd');
258
-
259
- // UWHD
260
- expect((0, _resolution.getScreenType)({
261
- width: UWHD.width + 1,
262
- height: UWHD.height + 1
263
- })).toBe('uw-hd');
264
- expect((0, _resolution.getScreenType)({
265
- width: UWUXGA.width - 1,
266
- height: UWHD.height + 1
267
- })).toBe('uw-hd');
268
- expect((0, _resolution.getScreenType)({
269
- width: UWUXGA.width + 1,
270
- height: UWHD.height + 1
271
- })).toBe('uw-hd');
272
- expect((0, _resolution.getScreenType)({
273
- width: FHD.width + 1,
274
- height: FHD.height - 1
275
- })).toBe('uw-hd');
276
- expect((0, _resolution.getScreenType)({
277
- width: UWUXGA.width - 1,
278
- height: UWUXGA.height - 1
279
- })).toBe('uw-hd');
280
- expect((0, _resolution.getScreenType)({
281
- width: UWUXGA.width + 1,
282
- height: UWUXGA.height - 1
283
- })).toBe('uw-hd');
284
-
285
- // FHD
286
- expect((0, _resolution.getScreenType)({
287
- width: FHD.width + 1,
288
- height: FHD.height + 1
289
- })).toBe('fhd');
290
- expect((0, _resolution.getScreenType)({
291
- width: UWUXGA.width - 1,
292
- height: UWUXGA.height + 1
293
- })).toBe('fhd'); // {height: FHD.height + 1, width: UWUXGA.width - 1}
294
-
295
- expect((0, _resolution.getScreenType)({
296
- width: QHD.width - 1,
297
- height: QHD.height - 1
298
- })).toBe('fhd'); // {height: QHD.height - 1, width: UWUXGA.width - 1}
299
- expect((0, _resolution.getScreenType)({
300
- width: QHD.width - 1,
301
- height: QHD.height + 1
302
- })).toBe('fhd'); // {height: QHD.height + 1, width: UWUXGA.width - 1}
303
-
304
- // UWUXGA
305
- expect((0, _resolution.getScreenType)({
306
- width: UWUXGA.width + 1,
307
- height: UWUXGA.height + 1
308
- })).toBe('uw-uxga'); // {height: FHD.height + 1, width: UWUXGA.width + 1}
309
-
310
- expect((0, _resolution.getScreenType)({
311
- width: QHD.width + 1,
312
- height: QHD.height - 1
313
- })).toBe('uw-uxga'); // {height: QHD.height - 1, width: UWUXGA.width + 1}
314
-
315
- expect((0, _resolution.getScreenType)({
316
- width: WQHD.width - 1,
317
- height: WQHD.height - 1
318
- })).toBe('uw-uxga'); // {height: QHD.height - 1, width: WQHD.width - 1}
319
- expect((0, _resolution.getScreenType)({
320
- width: WQHD.width + 1,
321
- height: WQHD.height - 1
322
- })).toBe('uw-uxga'); // {height: QHD.height - 1, width: WQHD.width + 1}
323
-
324
- // QHD
325
- expect((0, _resolution.getScreenType)({
326
- width: QHD.width + 1,
327
- height: QHD.height + 1
328
- })).toBe('qhd'); // {height: QHD.height + 1, width: UWUXGA.width + 1}
329
-
330
- expect((0, _resolution.getScreenType)({
331
- width: WQHD.width - 1,
332
- height: WQHD.height + 1
333
- })).toBe('qhd'); // {height: QHD.height + 1, width: WQHD.width - 1}
334
-
335
- // WQHD
336
- expect((0, _resolution.getScreenType)({
337
- width: WQHD.width + 1,
338
- height: WQHD.height + 1
339
- })).toBe('wqhd'); // {height: QHD.height + 1, width: WQHD.width + 1}
340
-
341
- expect((0, _resolution.getScreenType)({
342
- width: UHD.width - 1,
343
- height: UHD.height - 1
344
- })).toBe('wqhd');
345
- expect((0, _resolution.getScreenType)({
346
- width: UHD.width + 1,
347
- height: UHD.height - 1
348
- })).toBe('wqhd');
349
- expect((0, _resolution.getScreenType)({
350
- width: UHD.width - 1,
351
- height: UHD.height + 1
352
- })).toBe('wqhd');
353
- expect((0, _resolution.getScreenType)({
354
- width: WUHD.width - 1,
355
- height: WUHD.height - 1
356
- })).toBe('wqhd');
357
- expect((0, _resolution.getScreenType)({
358
- width: WUHD.width + 1,
359
- height: WUHD.height - 1
360
- })).toBe('wqhd');
361
- expect((0, _resolution.getScreenType)({
362
- width: UHD2.width - 1,
363
- height: WUHD.height - 1
364
- })).toBe('wqhd');
365
- expect((0, _resolution.getScreenType)({
366
- width: UHD2.width + 1,
367
- height: WUHD.height - 1
368
- })).toBe('wqhd');
369
-
370
- // UHD
371
- expect((0, _resolution.getScreenType)({
372
- width: UHD.width + 1,
373
- height: UHD.height + 1
374
- })).toBe('uhd');
375
- expect((0, _resolution.getScreenType)({
376
- width: WUHD.width - 1,
377
- height: WUHD.height + 1
378
- })).toBe('uhd');
379
- expect((0, _resolution.getScreenType)({
380
- width: WUHD.width - 1,
381
- height: UHD2.height - 1
382
- })).toBe('uhd');
383
- expect((0, _resolution.getScreenType)({
384
- width: WUHD.width - 1,
385
- height: UHD2.height + 1
386
- })).toBe('uhd');
387
-
388
- // WUHD
389
- expect((0, _resolution.getScreenType)({
390
- width: WUHD.width + 1,
391
- height: WUHD.height + 1
392
- })).toBe('wuhd');
393
- expect((0, _resolution.getScreenType)({
394
- width: WUHD.width + 1,
395
- height: UHD2.height - 1
396
- })).toBe('wuhd');
397
- expect((0, _resolution.getScreenType)({
398
- width: WUHD.width + 1,
399
- height: UHD2.height + 1
400
- })).toBe('wuhd');
401
- expect((0, _resolution.getScreenType)({
402
- width: UHD2.width - 1,
403
- height: WUHD.height + 1
404
- })).toBe('wuhd');
405
- expect((0, _resolution.getScreenType)({
406
- width: UHD2.width + 1,
407
- height: WUHD.height + 1
408
- })).toBe('wuhd');
409
- expect((0, _resolution.getScreenType)({
410
- width: UHD2.width - 1,
411
- height: UHD2.height - 1
412
- })).toBe('wuhd');
413
- expect((0, _resolution.getScreenType)({
414
- width: UHD2.width + 1,
415
- height: UHD2.height - 1
416
- })).toBe('wuhd');
417
- expect((0, _resolution.getScreenType)({
418
- width: UHD2.width - 1,
419
- height: UHD2.height + 1
420
- })).toBe('wuhd');
421
-
422
- // UHD2
423
- expect((0, _resolution.getScreenType)({
424
- width: UHD2.width + 1,
425
- height: UHD2.height + 1
426
- })).toBe('uhd2');
427
- });
428
- test('should select screen type whose height and width are both bigger than or same with the screen if `matchSmallerScreenType` false', function () {
429
- _resolution.config.matchSmallerScreenType = false;
430
-
431
- // VGA
432
- expect((0, _resolution.getScreenType)({
433
- width: VGA.width - 1,
434
- height: VGA.height - 1
435
- })).toBe('vga');
436
-
437
- // XGA
438
- expect((0, _resolution.getScreenType)({
439
- width: VGA.width + 1,
440
- height: VGA.height - 1
441
- })).toBe('xga');
442
- expect((0, _resolution.getScreenType)({
443
- width: VGA.width - 1,
444
- height: VGA.height + 1
445
- })).toBe('xga');
446
- expect((0, _resolution.getScreenType)({
447
- width: VGA.width + 1,
448
- height: VGA.height + 1
449
- })).toBe('xga');
450
- expect((0, _resolution.getScreenType)({
451
- width: XGA.width - 1,
452
- height: XGA.height - 1
453
- })).toBe('xga');
454
- expect((0, _resolution.getScreenType)({
455
- width: XGA.width,
456
- height: HD.height
457
- })).toBe('xga');
458
- expect((0, _resolution.getScreenType)({
459
- width: XGA.width - 1,
460
- height: HD.height - 1
461
- })).toBe('xga');
462
- expect((0, _resolution.getScreenType)({
463
- width: XGA.width - 1,
464
- height: HD.height + 1
465
- })).toBe('xga');
466
-
467
- // HD
468
- expect((0, _resolution.getScreenType)({
469
- width: XGA.width + 1,
470
- height: HD.height - 1
471
- })).toBe('hd');
472
- expect((0, _resolution.getScreenType)({
473
- width: HD.width - 1,
474
- height: HD.height - 1
475
- })).toBe('hd');
476
-
477
- // UWHD
478
- expect((0, _resolution.getScreenType)({
479
- width: UWHD.width - 1,
480
- height: UWHD.height - 1
481
- })).toBe('uw-hd');
482
- expect((0, _resolution.getScreenType)({
483
- width: XGA.width + 1,
484
- height: XGA.height - 1
485
- })).toBe('uw-hd');
486
- expect((0, _resolution.getScreenType)({
487
- width: XGA.width - 1,
488
- height: XGA.height + 1
489
- })).toBe('uw-hd');
490
- expect((0, _resolution.getScreenType)({
491
- width: XGA.width + 1,
492
- height: XGA.height + 1
493
- })).toBe('uw-hd');
494
- expect((0, _resolution.getScreenType)({
495
- width: HD.width,
496
- height: XGA.height
497
- })).toBe('uw-hd');
498
- expect((0, _resolution.getScreenType)({
499
- width: HD.width - 1,
500
- height: XGA.height - 1
501
- })).toBe('uw-hd');
502
- expect((0, _resolution.getScreenType)({
503
- width: HD.width + 1,
504
- height: XGA.height - 1
505
- })).toBe('uw-hd');
506
- expect((0, _resolution.getScreenType)({
507
- width: HD.width - 1,
508
- height: XGA.height + 1
509
- })).toBe('uw-hd');
510
- expect((0, _resolution.getScreenType)({
511
- width: HD.width + 1,
512
- height: XGA.height + 1
513
- })).toBe('uw-hd');
514
- expect((0, _resolution.getScreenType)({
515
- width: XGA.width + 1,
516
- height: HD.height + 1
517
- })).toBe('uw-hd');
518
- expect((0, _resolution.getScreenType)({
519
- width: HD.width + 1,
520
- height: HD.height - 1
521
- })).toBe('uw-hd');
522
- expect((0, _resolution.getScreenType)({
523
- width: HD.width - 1,
524
- height: HD.height + 1
525
- })).toBe('uw-hd');
526
- expect((0, _resolution.getScreenType)({
527
- width: HD.width + 1,
528
- height: HD.height + 1
529
- })).toBe('uw-hd');
530
- expect((0, _resolution.getScreenType)({
531
- width: HD.width + 1,
532
- height: UWHD.height - 1
533
- })).toBe('uw-hd');
534
-
535
- // FHD
536
- expect((0, _resolution.getScreenType)({
537
- width: UWHD.width - 1,
538
- height: UWHD.height + 1
539
- })).toBe('fhd');
540
- expect((0, _resolution.getScreenType)({
541
- width: FHD.width - 1,
542
- height: FHD.height - 1
543
- })).toBe('fhd');
544
-
545
- // UWUXGA
546
- expect((0, _resolution.getScreenType)({
547
- width: UWHD.width + 1,
548
- height: UWHD.height - 1
549
- })).toBe('uw-uxga');
550
- expect((0, _resolution.getScreenType)({
551
- width: UWHD.width + 1,
552
- height: UWHD.height + 1
553
- })).toBe('uw-uxga');
554
- expect((0, _resolution.getScreenType)({
555
- width: UWUXGA.width - 1,
556
- height: UWHD.height - 1
557
- })).toBe('uw-uxga');
558
- expect((0, _resolution.getScreenType)({
559
- width: UWUXGA.width - 1,
560
- height: UWHD.height + 1
561
- })).toBe('uw-uxga');
562
- expect((0, _resolution.getScreenType)({
563
- width: UWUXGA.width - 1,
564
- height: UWUXGA.height - 1
565
- })).toBe('uw-uxga'); // {height: FHD.height - 1, width: UWUXGA.width - 1}
566
-
567
- expect((0, _resolution.getScreenType)({
568
- width: FHD.width + 1,
569
- height: FHD.height - 1
570
- })).toBe('uw-uxga');
571
-
572
- // QHD
573
- expect((0, _resolution.getScreenType)({
574
- width: UWUXGA.width - 1,
575
- height: UWUXGA.height + 1
576
- })).toBe('qhd'); // {height: FHD.height + 1, width: UWUXGA.width - 1}
577
-
578
- expect((0, _resolution.getScreenType)({
579
- width: QHD.width - 1,
580
- height: QHD.height - 1
581
- })).toBe('qhd'); // {height: QHD.height - 1, width: UWUXGA.width - 1}
582
-
583
- expect((0, _resolution.getScreenType)({
584
- width: FHD.width - 1,
585
- height: FHD.height + 1
586
- })).toBe('qhd');
587
- expect((0, _resolution.getScreenType)({
588
- width: FHD.width + 1,
589
- height: FHD.height + 1
590
- })).toBe('qhd');
591
-
592
- // WQHD
593
- expect((0, _resolution.getScreenType)({
594
- width: UWUXGA.width + 1,
595
- height: UWHD.height - 1
596
- })).toBe('wqhd');
597
- expect((0, _resolution.getScreenType)({
598
- width: UWUXGA.width + 1,
599
- height: UWHD.height + 1
600
- })).toBe('wqhd');
601
- expect((0, _resolution.getScreenType)({
602
- width: UWUXGA.width + 1,
603
- height: UWUXGA.height - 1
604
- })).toBe('wqhd'); // {height: FHD.height - 1, width: UWUXGA.width + 1}
605
- expect((0, _resolution.getScreenType)({
606
- width: UWUXGA.width + 1,
607
- height: UWUXGA.height + 1
608
- })).toBe('wqhd'); // {height: FHD.height + 1, width: UWUXGA.width + 1}
609
-
610
- expect((0, _resolution.getScreenType)({
611
- width: QHD.width + 1,
612
- height: QHD.height - 1
613
- })).toBe('wqhd'); // {height: QHD.height - 1, width: UWUXGA.width + 1}
614
-
615
- expect((0, _resolution.getScreenType)({
616
- width: WQHD.width - 1,
617
- height: WQHD.height - 1
618
- })).toBe('wqhd'); // {height: QHD.height - 1, width: WQHD.width - 1}
619
-
620
- // UHD
621
- expect((0, _resolution.getScreenType)({
622
- width: QHD.width - 1,
623
- height: QHD.height + 1
624
- })).toBe('uhd'); // {height: QHD.height + 1, width: UWUXGA.width - 1}
625
- expect((0, _resolution.getScreenType)({
626
- width: QHD.width + 1,
627
- height: QHD.height + 1
628
- })).toBe('uhd'); // {height: QHD.height + 1, width: UWUXGA.width + 1}
629
-
630
- expect((0, _resolution.getScreenType)({
631
- width: WQHD.width + 1,
632
- height: WQHD.height - 1
633
- })).toBe('uhd'); // {height: QHD.height - 1, width: WQHD.width + 1}
634
- expect((0, _resolution.getScreenType)({
635
- width: WQHD.width - 1,
636
- height: WQHD.height + 1
637
- })).toBe('uhd'); // {height: QHD.height + 1, width: WQHD.width - 1}
638
- expect((0, _resolution.getScreenType)({
639
- width: WQHD.width + 1,
640
- height: WQHD.height + 1
641
- })).toBe('uhd'); // {height: QHD.height + 1, width: WQHD.width + 1}
642
-
643
- expect((0, _resolution.getScreenType)({
644
- width: UHD.width - 1,
645
- height: UHD.height - 1
646
- })).toBe('uhd');
647
-
648
- // WUHD
649
- expect((0, _resolution.getScreenType)({
650
- width: UHD.width + 1,
651
- height: UHD.height - 1
652
- })).toBe('wuhd');
653
- expect((0, _resolution.getScreenType)({
654
- width: WUHD.width - 1,
655
- height: WUHD.height - 1
656
- })).toBe('wuhd');
657
-
658
- // UHD2
659
- expect((0, _resolution.getScreenType)({
660
- width: UHD.width - 1,
661
- height: UHD.height + 1
662
- })).toBe('uhd2');
663
- expect((0, _resolution.getScreenType)({
664
- width: UHD.width + 1,
665
- height: UHD.height + 1
666
- })).toBe('uhd2');
667
- expect((0, _resolution.getScreenType)({
668
- width: WUHD.width + 1,
669
- height: WUHD.height - 1
670
- })).toBe('uhd2');
671
- expect((0, _resolution.getScreenType)({
672
- width: WUHD.width - 1,
673
- height: WUHD.height + 1
674
- })).toBe('uhd2');
675
- expect((0, _resolution.getScreenType)({
676
- width: WUHD.width + 1,
677
- height: WUHD.height + 1
678
- })).toBe('uhd2');
679
- expect((0, _resolution.getScreenType)({
680
- width: WUHD.width - 1,
681
- height: UHD2.height - 1
682
- })).toBe('uhd2');
683
- expect((0, _resolution.getScreenType)({
684
- width: WUHD.width + 1,
685
- height: UHD2.height - 1
686
- })).toBe('uhd2');
687
- expect((0, _resolution.getScreenType)({
688
- width: UHD2.width - 1,
689
- height: WUHD.height - 1
690
- })).toBe('uhd2');
691
- expect((0, _resolution.getScreenType)({
692
- width: UHD2.width - 1,
693
- height: WUHD.height + 1
694
- })).toBe('uhd2');
695
- expect((0, _resolution.getScreenType)({
696
- width: UHD2.width - 1,
697
- height: UHD2.height - 1
698
- })).toBe('uhd2');
699
-
700
- // if width or height of screen is bigger than the biggest screen type, select the biggest screen type
701
- expect((0, _resolution.getScreenType)({
702
- width: WUHD.width - 1,
703
- height: UHD2.height + 1
704
- })).toBe('uhd2');
705
- expect((0, _resolution.getScreenType)({
706
- width: WUHD.width + 1,
707
- height: UHD2.height + 1
708
- })).toBe('uhd2');
709
- expect((0, _resolution.getScreenType)({
710
- width: UHD2.width + 1,
711
- height: WUHD.height - 1
712
- })).toBe('uhd2');
713
- expect((0, _resolution.getScreenType)({
714
- width: UHD2.width + 1,
715
- height: WUHD.height + 1
716
- })).toBe('uhd2');
717
- expect((0, _resolution.getScreenType)({
718
- width: UHD2.width + 1,
719
- height: UHD2.height - 1
720
- })).toBe('uhd2');
721
- expect((0, _resolution.getScreenType)({
722
- width: UHD2.width - 1,
723
- height: UHD2.height + 1
724
- })).toBe('uhd2');
725
- expect((0, _resolution.getScreenType)({
726
- width: UHD2.width + 1,
727
- height: UHD2.height + 1
728
- })).toBe('uhd2');
137
+ test('should select screen type whose height and width are the closest to the screen', function () {
138
+ screenTypes.forEach(function (type) {
139
+ expect((0, _resolution.getScreenType)({
140
+ width: type.width,
141
+ height: type.height
142
+ })).toBe(type.name);
143
+ expect((0, _resolution.getScreenType)({
144
+ width: type.width - 1,
145
+ height: type.height - 1
146
+ })).toBe(type.name);
147
+ expect((0, _resolution.getScreenType)({
148
+ width: type.width + 1,
149
+ height: type.height + 1
150
+ })).toBe(type.name);
151
+ });
152
+ for (var i = 0; i < screenTypes.length - 1; i++) {
153
+ var current = screenTypes[i];
154
+ var next = screenTypes[i + 1];
155
+ var midPoint = {
156
+ width: (current.width + next.width) / 2,
157
+ height: (current.height + next.height) / 2
158
+ };
159
+ var justBeforeMid = {
160
+ width: Math.floor(midPoint.width - 0.1),
161
+ height: Math.floor(midPoint.height - 0.1)
162
+ };
163
+ var justAfterMid = {
164
+ width: Math.ceil(midPoint.width + 0.1),
165
+ height: Math.ceil(midPoint.height + 0.1)
166
+ };
167
+ expect((0, _resolution.getScreenType)(justBeforeMid)).toBe(current.name);
168
+ expect((0, _resolution.getScreenType)(justAfterMid)).toBe(next.name);
169
+ }
170
+ var firstScreenType = screenTypes.at(0);
171
+ expect((0, _resolution.getScreenType)({
172
+ width: 1,
173
+ height: 1
174
+ })).toBe(firstScreenType.name);
175
+ var lastType = screenTypes.at(-1);
176
+ expect((0, _resolution.getScreenType)({
177
+ width: lastType.width + 1000,
178
+ height: lastType.height + 1000
179
+ })).toBe(lastType.name);
729
180
  });
730
181
  });
731
182
  test('should detect portrait orientation', function () {
@@ -768,7 +219,174 @@ describe('Resolution Specs', function () {
768
219
  expect(actualFHD).toBe(expectedFHD);
769
220
  expect(actualHD).toBe(expectedHD);
770
221
  });
222
+ test('should convert pixels to units in landscape and fontSizeHandling is "scale"', function () {
223
+ var closestResolution = _objectSpread({}, XGA);
224
+ var wideResolution = {
225
+ innerWidth: 1024,
226
+ innerHeight: 480
227
+ };
228
+ (0, _resolution.init)({
229
+ measurementNode: wideResolution
230
+ });
231
+ var expectedFHD = 3 / (wideResolution.innerHeight / closestResolution.height) + 'rem';
232
+ var actualFHD = (0, _resolution.unit)(48, 'rem');
233
+ var expectedHD = 2 / (wideResolution.innerHeight / closestResolution.height) + 'rem';
234
+ var actualHD = (0, _resolution.unit)(32, 'rem');
235
+ expect(actualFHD).toBe(expectedFHD);
236
+ expect(actualHD).toBe(expectedHD);
237
+ });
238
+ test('should select source for the current screen type', function () {
239
+ var measurementNode;
240
+ var src = {
241
+ vga: 'VGA',
242
+ hd: 'HD',
243
+ fhd: 'FHD',
244
+ uhd: 'UHD'
245
+ };
246
+ var stringSrc = 'src/to/image';
247
+
248
+ // String src
249
+ expect((0, _resolution.selectSrc)(stringSrc)).toBe(stringSrc);
250
+
251
+ // VGA
252
+ measurementNode = {
253
+ innerWidth: VGA.width,
254
+ innerHeight: VGA.height
255
+ };
256
+ (0, _resolution.init)({
257
+ measurementNode: measurementNode
258
+ });
259
+ expect((0, _resolution.selectSrc)(src)).toBe(src.vga);
260
+
261
+ // XGA
262
+ measurementNode = {
263
+ innerWidth: XGA.width,
264
+ innerHeight: XGA.height
265
+ };
266
+ (0, _resolution.init)({
267
+ measurementNode: measurementNode
268
+ });
269
+ expect((0, _resolution.selectSrc)(src)).toBe(src.hd);
270
+
271
+ // HD
272
+ measurementNode = {
273
+ innerWidth: HD.width,
274
+ innerHeight: HD.height
275
+ };
276
+ (0, _resolution.init)({
277
+ measurementNode: measurementNode
278
+ });
279
+ expect((0, _resolution.selectSrc)(src)).toBe(src.hd);
771
280
 
772
- // NOTE: Currently tough to test selectSrc because it relies on a global variable for screenType
773
- test.skip('should select source for the current screen type', function () {});
281
+ // UWHD
282
+ measurementNode = {
283
+ innerWidth: UWHD.width,
284
+ innerHeight: UWHD.height
285
+ };
286
+ (0, _resolution.init)({
287
+ measurementNode: measurementNode
288
+ });
289
+ expect((0, _resolution.selectSrc)(src)).toBe(src.fhd);
290
+
291
+ // FHD
292
+ measurementNode = {
293
+ innerWidth: FHD.width,
294
+ innerHeight: FHD.height
295
+ };
296
+ (0, _resolution.init)({
297
+ measurementNode: measurementNode
298
+ });
299
+ expect((0, _resolution.selectSrc)(src)).toBe(src.fhd);
300
+
301
+ // UWUXGA
302
+ measurementNode = {
303
+ innerWidth: UWUXGA.width,
304
+ innerHeight: UWUXGA.height
305
+ };
306
+ (0, _resolution.init)({
307
+ measurementNode: measurementNode
308
+ });
309
+ expect((0, _resolution.selectSrc)(src)).toBe(src.fhd);
310
+
311
+ // QHD
312
+ measurementNode = {
313
+ innerWidth: QHD.width,
314
+ innerHeight: QHD.height
315
+ };
316
+ (0, _resolution.init)({
317
+ measurementNode: measurementNode
318
+ });
319
+ expect((0, _resolution.selectSrc)(src)).toBe(src.fhd);
320
+
321
+ // WQHD
322
+ measurementNode = {
323
+ innerWidth: WQHD.width,
324
+ innerHeight: WQHD.height
325
+ };
326
+ (0, _resolution.init)({
327
+ measurementNode: measurementNode
328
+ });
329
+ expect((0, _resolution.selectSrc)(src)).toBe(src.uhd);
330
+
331
+ // UHD
332
+ measurementNode = {
333
+ innerWidth: UHD.width,
334
+ innerHeight: UHD.height
335
+ };
336
+ (0, _resolution.init)({
337
+ measurementNode: measurementNode
338
+ });
339
+ expect((0, _resolution.selectSrc)(src)).toBe(src.uhd);
340
+
341
+ // WUHD
342
+ measurementNode = {
343
+ innerWidth: WUHD.width,
344
+ innerHeight: WUHD.height
345
+ };
346
+ (0, _resolution.init)({
347
+ measurementNode: measurementNode
348
+ });
349
+ expect((0, _resolution.selectSrc)(src)).toBe(src.uhd);
350
+
351
+ // UHD2
352
+ measurementNode = {
353
+ innerWidth: UHD2.width,
354
+ innerHeight: UHD2.height
355
+ };
356
+ (0, _resolution.init)({
357
+ measurementNode: measurementNode
358
+ });
359
+ expect((0, _resolution.selectSrc)(src)).toBe(src.uhd);
360
+ });
361
+ test('should calculate linearly scaled font size based on workspace bounds and current screen', function () {
362
+ _resolution.config.linearScaling.active = true;
363
+ screenTypes.forEach(function (type, index, arr) {
364
+ (0, _resolution.init)({
365
+ measurementNode: {
366
+ innerWidth: type.width,
367
+ innerHeight: type.height
368
+ }
369
+ });
370
+ var actual = (0, _resolution.calculateFontSize)();
371
+ expect(actual).toBe(type.pxPerRem + 'px');
372
+ (0, _resolution.init)({
373
+ measurementNode: {
374
+ innerWidth: type.width - 10,
375
+ innerHeight: type.height - 10
376
+ }
377
+ });
378
+ actual = Number((0, _resolution.calculateFontSize)().split('px').at(0));
379
+ expect(actual).toBeLessThan(type.pxPerRem);
380
+ (0, _resolution.init)({
381
+ measurementNode: {
382
+ innerWidth: type.width + 10,
383
+ innerHeight: type.height + 10
384
+ }
385
+ });
386
+ actual = Number((0, _resolution.calculateFontSize)().split('px').at(0));
387
+ var expectCondition = arr.length - 1 === index ? 'toEqual' : 'toBeGreaterThan';
388
+ expect(actual)[expectCondition](type.pxPerRem);
389
+ });
390
+ _resolution.config.linearScaling.active = false;
391
+ });
774
392
  });