@enact/spotlight 5.3.2 → 5.4.1

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.
@@ -314,23 +314,133 @@ describe('target', function () {
314
314
  })).toBe('middle-right');
315
315
  }));
316
316
  test('should find target within container from floating element', (0, _utils.testScenario)(scenarios.overlap, function (root) {
317
- (0, _container10.configureContainer)('grid');
317
+ (0, _container10.configureContainer)('grid', {
318
+ enterTo: 'default-element',
319
+ defaultElement: '#middle-center'
320
+ });
321
+ var gridContainer = root.querySelector('[data-spotlight-id="grid"]');
318
322
  var overlap = root.querySelector('#over-middle-center');
319
323
  var center = root.querySelector('#middle-center');
320
- center.getBoundingClientRect = function () {
324
+ var topLeft = root.querySelector('#top-left');
325
+ var topCenter = root.querySelector('#top-center');
326
+ var topRight = root.querySelector('#top-right');
327
+ var middleLeft = root.querySelector('#middle-left');
328
+ var middleRight = root.querySelector('#middle-right');
329
+ var bottomLeft = root.querySelector('#bottom-left');
330
+ var bottomCenter = root.querySelector('#bottom-center');
331
+ var bottomRight = root.querySelector('#bottom-right');
332
+
333
+ // Mock getBoundingClientRect for all elements
334
+ gridContainer.getBoundingClientRect = function () {
335
+ return {
336
+ top: 10,
337
+ left: 10,
338
+ width: 30,
339
+ height: 30,
340
+ right: 40,
341
+ bottom: 40
342
+ };
343
+ };
344
+ topLeft.getBoundingClientRect = function () {
321
345
  return {
322
346
  top: 10,
323
347
  left: 10,
324
348
  width: 10,
325
- height: 10
349
+ height: 10,
350
+ right: 20,
351
+ bottom: 20
352
+ };
353
+ };
354
+ topCenter.getBoundingClientRect = function () {
355
+ return {
356
+ top: 10,
357
+ left: 20,
358
+ width: 10,
359
+ height: 10,
360
+ right: 30,
361
+ bottom: 20
362
+ };
363
+ };
364
+ topRight.getBoundingClientRect = function () {
365
+ return {
366
+ top: 10,
367
+ left: 30,
368
+ width: 10,
369
+ height: 10,
370
+ right: 40,
371
+ bottom: 20
372
+ };
373
+ };
374
+ middleLeft.getBoundingClientRect = function () {
375
+ return {
376
+ top: 20,
377
+ left: 10,
378
+ width: 10,
379
+ height: 10,
380
+ right: 20,
381
+ bottom: 30
382
+ };
383
+ };
384
+ center.getBoundingClientRect = function () {
385
+ return {
386
+ top: 20,
387
+ left: 20,
388
+ width: 10,
389
+ height: 10,
390
+ right: 30,
391
+ bottom: 30
392
+ };
393
+ };
394
+ middleRight.getBoundingClientRect = function () {
395
+ return {
396
+ top: 20,
397
+ left: 30,
398
+ width: 10,
399
+ height: 10,
400
+ right: 40,
401
+ bottom: 30
402
+ };
403
+ };
404
+ bottomLeft.getBoundingClientRect = function () {
405
+ return {
406
+ top: 30,
407
+ left: 10,
408
+ width: 10,
409
+ height: 10,
410
+ right: 20,
411
+ bottom: 40
412
+ };
413
+ };
414
+ bottomCenter.getBoundingClientRect = function () {
415
+ return {
416
+ top: 30,
417
+ left: 20,
418
+ width: 10,
419
+ height: 10,
420
+ right: 30,
421
+ bottom: 40
422
+ };
423
+ };
424
+ bottomRight.getBoundingClientRect = function () {
425
+ return {
426
+ top: 30,
427
+ left: 30,
428
+ width: 10,
429
+ height: 10,
430
+ right: 40,
431
+ bottom: 40
326
432
  };
327
433
  };
434
+
435
+ // Overlap is a small element floating over middle-center
328
436
  overlap.getBoundingClientRect = function () {
329
437
  return {
330
- top: 11,
331
- left: 11,
332
- width: 3,
333
- height: 3
438
+ top: 22,
439
+ left: 25,
440
+ width: 1,
441
+ height: 1,
442
+ right: 26,
443
+ bottom: 23
334
444
  };
335
445
  };
336
446
  expect(safeTarget((0, _target.getTargetByDirectionFromElement)('down', overlap), function (t) {
@@ -341,276 +451,1625 @@ describe('target', function () {
341
451
  (0, _container10.configureContainer)('overflow-container', {
342
452
  overflow: true
343
453
  });
454
+ var overflowContainer = root.querySelector('[data-spotlight-id="overflow-container"]');
344
455
  var element = root.querySelector('#outside-overflow');
456
+ var overflowAbove = root.querySelector('#overflow-above');
457
+ var overflowBelow = root.querySelector('#overflow-below');
345
458
  var overflowWithin = root.querySelector('#overflow-within');
459
+
460
+ // Mock all bounding rects
461
+ overflowContainer.getBoundingClientRect = function () {
462
+ return {
463
+ top: 110,
464
+ left: 10,
465
+ width: 30,
466
+ height: 30,
467
+ right: 40,
468
+ bottom: 140
469
+ };
470
+ };
346
471
  element.getBoundingClientRect = function () {
347
472
  return {
348
473
  top: 10,
349
474
  left: 10,
350
- width: 0,
351
- height: 0
475
+ width: 10,
476
+ height: 10,
477
+ right: 20,
478
+ bottom: 20
479
+ };
480
+ };
481
+ overflowAbove.getBoundingClientRect = function () {
482
+ return {
483
+ top: 0,
484
+ left: 10,
485
+ width: 10,
486
+ height: 10,
487
+ right: 20,
488
+ bottom: 110
352
489
  };
353
490
  };
354
491
  overflowWithin.getBoundingClientRect = function () {
355
492
  return {
356
- top: 100,
357
- left: 0,
493
+ top: 110,
494
+ left: 10,
358
495
  width: 10,
359
- height: 10
496
+ height: 10,
497
+ right: 20,
498
+ bottom: 120
499
+ };
500
+ };
501
+ overflowBelow.getBoundingClientRect = function () {
502
+ return {
503
+ top: 140,
504
+ left: 10,
505
+ width: 10,
506
+ height: 10,
507
+ right: 20,
508
+ bottom: 150
360
509
  };
361
510
  };
362
511
  expect(safeTarget((0, _target.getTargetByDirectionFromElement)('down', element), function (t) {
363
512
  return t.id;
364
513
  })).toBe('overflow-within');
365
514
  }));
366
- test.skip('should find target within container larger than overflow container', (0, _utils.testScenario)(scenarios.overflowLargeSubContainer, function (root) {
515
+ test('should find target within container larger than overflow container', (0, _utils.testScenario)(scenarios.overflowLargeSubContainer, function (root) {
367
516
  (0, _container10.configureContainer)('overflow-container', {
368
517
  overflow: true
369
518
  });
370
519
  (0, _container10.configureContainer)('inside', {
371
520
  enterTo: null
372
521
  });
522
+ var overflowContainer = root.querySelector('[data-spotlight-id="overflow-container"]');
523
+ var insideContainer = root.querySelector('[data-spotlight-id="inside"]');
373
524
  var element = root.querySelector('#outside-overflow');
525
+ var inLargeContainer = root.querySelector('#in-large-container');
526
+ var belowLargeContainer = root.querySelector('#below-large-container');
527
+
528
+ // Mock all bounding rects
529
+ overflowContainer.getBoundingClientRect = function () {
530
+ return {
531
+ top: 110,
532
+ left: 10,
533
+ width: 30,
534
+ height: 30,
535
+ right: 40,
536
+ bottom: 140
537
+ };
538
+ };
539
+ insideContainer.getBoundingClientRect = function () {
540
+ return {
541
+ top: 100,
542
+ left: 10,
543
+ width: 10,
544
+ height: 50,
545
+ right: 20,
546
+ bottom: 150
547
+ };
548
+ };
549
+ element.getBoundingClientRect = function () {
550
+ return {
551
+ top: 10,
552
+ left: 10,
553
+ width: 10,
554
+ height: 10,
555
+ right: 20,
556
+ bottom: 20
557
+ };
558
+ };
559
+ inLargeContainer.getBoundingClientRect = function () {
560
+ return {
561
+ top: 110,
562
+ left: 10,
563
+ width: 10,
564
+ height: 10,
565
+ right: 20,
566
+ bottom: 120
567
+ };
568
+ };
569
+ belowLargeContainer.getBoundingClientRect = function () {
570
+ return {
571
+ top: 150,
572
+ left: 10,
573
+ width: 10,
574
+ height: 10,
575
+ right: 20,
576
+ bottom: 160
577
+ };
578
+ };
374
579
  expect(safeTarget((0, _target.getTargetByDirectionFromElement)('down', element), function (t) {
375
580
  return t.id;
376
581
  })).toBe('in-large-container');
377
582
  }));
378
- test.skip('should find target out of bounds of overflow container from within container', (0, _utils.testScenario)(scenarios.overflow, function (root) {
583
+ test('should find target out of bounds of overflow container from within container', (0, _utils.testScenario)(scenarios.overflow, function (root) {
379
584
  (0, _container10.configureContainer)('overflow-container', {
380
585
  overflow: true
381
586
  });
382
- var element = root.querySelector('#overflow-within');
383
- expect(safeTarget((0, _target.getTargetByDirectionFromElement)('down', element), function (t) {
587
+ var overflowContainer = root.querySelector('[data-spotlight-id="overflow-container"]');
588
+ var overflowAbove = root.querySelector('#overflow-above');
589
+ var overflowBelow = root.querySelector('#overflow-below');
590
+ var overflowWithin = root.querySelector('#overflow-within');
591
+
592
+ // Mock all bounding rects
593
+ overflowContainer.getBoundingClientRect = function () {
594
+ return {
595
+ top: 110,
596
+ left: 10,
597
+ width: 30,
598
+ height: 30,
599
+ right: 40,
600
+ bottom: 140
601
+ };
602
+ };
603
+ overflowAbove.getBoundingClientRect = function () {
604
+ return {
605
+ top: 100,
606
+ left: 10,
607
+ width: 10,
608
+ height: 10,
609
+ right: 20,
610
+ bottom: 110
611
+ };
612
+ };
613
+ overflowWithin.getBoundingClientRect = function () {
614
+ return {
615
+ top: 110,
616
+ left: 10,
617
+ width: 10,
618
+ height: 10,
619
+ right: 20,
620
+ bottom: 120
621
+ };
622
+ };
623
+ overflowBelow.getBoundingClientRect = function () {
624
+ return {
625
+ top: 140,
626
+ left: 10,
627
+ width: 10,
628
+ height: 10,
629
+ right: 20,
630
+ bottom: 150
631
+ };
632
+ };
633
+ expect(safeTarget((0, _target.getTargetByDirectionFromElement)('down', overflowWithin), function (t) {
384
634
  return t.id;
385
635
  })).toBe('overflow-below');
386
- expect(safeTarget((0, _target.getTargetByDirectionFromElement)('up', element), function (t) {
636
+ expect(safeTarget((0, _target.getTargetByDirectionFromElement)('up', overflowWithin), function (t) {
387
637
  return t.id;
388
638
  })).toBe('overflow-above');
389
639
  }));
390
- test('should stop at restrict="self-only" boundaries', (0, _utils.testScenario)(scenarios.complexTree, function (root) {
391
- (0, _container10.configureContainer)('first-container', {
392
- restrict: 'none'
393
- });
394
- (0, _container10.configureContainer)('second-container', {
395
- restrict: 'self-only'
396
- });
397
- var element = root.querySelector("[".concat(_container10.containerAttribute, "=\"second-container\"] .spottable"));
398
- expect(safeTarget((0, _target.getTargetByDirectionFromElement)('up', element), function (t) {
399
- return t.id;
400
- })).toBe('NOT FOUND');
401
- }));
402
- test.skip('should respect enterTo="default-element" containers', (0, _utils.testScenario)(scenarios.grid, function (root) {
640
+ test('should respect enterTo="default-element" containers', (0, _utils.testScenario)(scenarios.grid, function (root) {
403
641
  (0, _container10.configureContainer)('grid', {
404
642
  restrict: 'none',
405
643
  enterTo: 'default-element',
406
644
  defaultElement: '#bottom-right'
407
645
  });
408
- var element = root.querySelector('#before-grid');
409
- expect(safeTarget((0, _target.getTargetByDirectionFromElement)('down', element), function (t) {
646
+ var gridContainer = root.querySelector('[data-spotlight-id="grid"]');
647
+ var beforeGrid = root.querySelector('#before-grid');
648
+ var afterGrid = root.querySelector('#after-grid');
649
+ var topLeft = root.querySelector('#top-left');
650
+ var topCenter = root.querySelector('#top-center');
651
+ var topRight = root.querySelector('#top-right');
652
+ var middleLeft = root.querySelector('#middle-left');
653
+ var middleCenter = root.querySelector('#middle-center');
654
+ var middleRight = root.querySelector('#middle-right');
655
+ var bottomLeft = root.querySelector('#bottom-left');
656
+ var bottomCenter = root.querySelector('#bottom-center');
657
+ var bottomRight = root.querySelector('#bottom-right');
658
+
659
+ // Mock all bounding rects
660
+ beforeGrid.getBoundingClientRect = function () {
661
+ return {
662
+ top: 0,
663
+ left: 10,
664
+ width: 30,
665
+ height: 10,
666
+ right: 40,
667
+ bottom: 10
668
+ };
669
+ };
670
+ gridContainer.getBoundingClientRect = function () {
671
+ return {
672
+ top: 10,
673
+ left: 10,
674
+ width: 30,
675
+ height: 30,
676
+ right: 40,
677
+ bottom: 40
678
+ };
679
+ };
680
+ afterGrid.getBoundingClientRect = function () {
681
+ return {
682
+ top: 40,
683
+ left: 10,
684
+ width: 30,
685
+ height: 10,
686
+ right: 40,
687
+ bottom: 50
688
+ };
689
+ };
690
+ topLeft.getBoundingClientRect = function () {
691
+ return {
692
+ top: 10,
693
+ left: 10,
694
+ width: 10,
695
+ height: 10,
696
+ right: 20,
697
+ bottom: 20
698
+ };
699
+ };
700
+ topCenter.getBoundingClientRect = function () {
701
+ return {
702
+ top: 10,
703
+ left: 20,
704
+ width: 10,
705
+ height: 10,
706
+ right: 30,
707
+ bottom: 20
708
+ };
709
+ };
710
+ topRight.getBoundingClientRect = function () {
711
+ return {
712
+ top: 10,
713
+ left: 30,
714
+ width: 10,
715
+ height: 10,
716
+ right: 40,
717
+ bottom: 20
718
+ };
719
+ };
720
+ middleLeft.getBoundingClientRect = function () {
721
+ return {
722
+ top: 20,
723
+ left: 10,
724
+ width: 10,
725
+ height: 10,
726
+ right: 20,
727
+ bottom: 30
728
+ };
729
+ };
730
+ middleCenter.getBoundingClientRect = function () {
731
+ return {
732
+ top: 20,
733
+ left: 20,
734
+ width: 10,
735
+ height: 10,
736
+ right: 30,
737
+ bottom: 30
738
+ };
739
+ };
740
+ middleRight.getBoundingClientRect = function () {
741
+ return {
742
+ top: 20,
743
+ left: 30,
744
+ width: 10,
745
+ height: 10,
746
+ right: 40,
747
+ bottom: 30
748
+ };
749
+ };
750
+ bottomLeft.getBoundingClientRect = function () {
751
+ return {
752
+ top: 30,
753
+ left: 10,
754
+ width: 10,
755
+ height: 10,
756
+ right: 20,
757
+ bottom: 40
758
+ };
759
+ };
760
+ bottomCenter.getBoundingClientRect = function () {
761
+ return {
762
+ top: 30,
763
+ left: 20,
764
+ width: 10,
765
+ height: 10,
766
+ right: 30,
767
+ bottom: 40
768
+ };
769
+ };
770
+ bottomRight.getBoundingClientRect = function () {
771
+ return {
772
+ top: 30,
773
+ left: 30,
774
+ width: 10,
775
+ height: 10,
776
+ right: 40,
777
+ bottom: 40
778
+ };
779
+ };
780
+ expect(safeTarget((0, _target.getTargetByDirectionFromElement)('down', beforeGrid), function (t) {
410
781
  return t.id;
411
782
  })).toBe('bottom-right');
412
783
  }));
413
- test.skip('should respect enterTo="last-focused" containers', (0, _utils.testScenario)(scenarios.grid, function (root) {
784
+ test('should respect enterTo="last-focused" containers', (0, _utils.testScenario)(scenarios.grid, function (root) {
414
785
  (0, _container10.configureContainer)('grid', {
415
786
  restrict: 'none',
416
787
  enterTo: 'last-focused',
417
- lastFocusedKey: {
418
- container: false,
419
- element: true,
420
- key: 8
421
- }
422
- });
423
- var element = root.querySelector('#before-grid');
424
- expect(safeTarget((0, _target.getTargetByDirectionFromElement)('down', element), function (t) {
425
- return t.id;
426
- })).toBe('bottom-right');
427
- }));
428
- test.skip('should follow the leaveFor config when no target is found within the container in the given direction', (0, _utils.testScenario)(scenarios.grid, function (root) {
429
- (0, _container10.configureContainer)('grid', {
430
- restrict: 'none',
431
- leaveFor: {
432
- up: '#after-grid'
433
- }
788
+ lastFocusedElement: root.querySelector('#bottom-right')
434
789
  });
435
- var element = root.querySelector('#top-center');
436
- expect(safeTarget((0, _target.getTargetByDirectionFromElement)('up', element), function (t) {
437
- return t.id;
438
- })).toBe('after-grid');
439
- }));
440
- test.skip('should not follow the leaveFor config when a target is found within the container in the given direction', (0, _utils.testScenario)(scenarios.grid, function (root) {
441
- (0, _container10.configureContainer)('grid', {
442
- restrict: 'none',
790
+ var gridContainer = root.querySelector('[data-spotlight-id="grid"]');
791
+ var beforeGrid = root.querySelector('#before-grid');
792
+ var afterGrid = root.querySelector('#after-grid');
793
+ var topLeft = root.querySelector('#top-left');
794
+ var topCenter = root.querySelector('#top-center');
795
+ var topRight = root.querySelector('#top-right');
796
+ var middleLeft = root.querySelector('#middle-left');
797
+ var middleCenter = root.querySelector('#middle-center');
798
+ var middleRight = root.querySelector('#middle-right');
799
+ var bottomLeft = root.querySelector('#bottom-left');
800
+ var bottomCenter = root.querySelector('#bottom-center');
801
+ var bottomRight = root.querySelector('#bottom-right');
802
+
803
+ // Mock all bounding rects
804
+ beforeGrid.getBoundingClientRect = function () {
805
+ return {
806
+ top: 0,
807
+ left: 10,
808
+ width: 30,
809
+ height: 10,
810
+ right: 40,
811
+ bottom: 10
812
+ };
813
+ };
814
+ gridContainer.getBoundingClientRect = function () {
815
+ return {
816
+ top: 10,
817
+ left: 10,
818
+ width: 30,
819
+ height: 30,
820
+ right: 40,
821
+ bottom: 40
822
+ };
823
+ };
824
+ afterGrid.getBoundingClientRect = function () {
825
+ return {
826
+ top: 40,
827
+ left: 10,
828
+ width: 30,
829
+ height: 10,
830
+ right: 40,
831
+ bottom: 50
832
+ };
833
+ };
834
+ topLeft.getBoundingClientRect = function () {
835
+ return {
836
+ top: 10,
837
+ left: 10,
838
+ width: 10,
839
+ height: 10,
840
+ right: 20,
841
+ bottom: 20
842
+ };
843
+ };
844
+ topCenter.getBoundingClientRect = function () {
845
+ return {
846
+ top: 10,
847
+ left: 20,
848
+ width: 10,
849
+ height: 10,
850
+ right: 30,
851
+ bottom: 20
852
+ };
853
+ };
854
+ topRight.getBoundingClientRect = function () {
855
+ return {
856
+ top: 10,
857
+ left: 30,
858
+ width: 10,
859
+ height: 10,
860
+ right: 40,
861
+ bottom: 20
862
+ };
863
+ };
864
+ middleLeft.getBoundingClientRect = function () {
865
+ return {
866
+ top: 20,
867
+ left: 10,
868
+ width: 10,
869
+ height: 10,
870
+ right: 20,
871
+ bottom: 30
872
+ };
873
+ };
874
+ middleCenter.getBoundingClientRect = function () {
875
+ return {
876
+ top: 20,
877
+ left: 20,
878
+ width: 10,
879
+ height: 10,
880
+ right: 30,
881
+ bottom: 30
882
+ };
883
+ };
884
+ middleRight.getBoundingClientRect = function () {
885
+ return {
886
+ top: 20,
887
+ left: 30,
888
+ width: 10,
889
+ height: 10,
890
+ right: 40,
891
+ bottom: 30
892
+ };
893
+ };
894
+ bottomLeft.getBoundingClientRect = function () {
895
+ return {
896
+ top: 30,
897
+ left: 10,
898
+ width: 10,
899
+ height: 10,
900
+ right: 20,
901
+ bottom: 40
902
+ };
903
+ };
904
+ bottomCenter.getBoundingClientRect = function () {
905
+ return {
906
+ top: 30,
907
+ left: 20,
908
+ width: 10,
909
+ height: 10,
910
+ right: 30,
911
+ bottom: 40
912
+ };
913
+ };
914
+ bottomRight.getBoundingClientRect = function () {
915
+ return {
916
+ top: 30,
917
+ left: 30,
918
+ width: 10,
919
+ height: 10,
920
+ right: 40,
921
+ bottom: 40
922
+ };
923
+ };
924
+ expect(safeTarget((0, _target.getTargetByDirectionFromElement)('down', beforeGrid), function (t) {
925
+ return t.id;
926
+ })).toBe('bottom-right');
927
+ }));
928
+ test('should follow the leaveFor config when no target is found within the container in the given direction', (0, _utils.testScenario)(scenarios.grid, function (root) {
929
+ (0, _container10.configureContainer)('grid', {
930
+ restrict: 'none',
443
931
  leaveFor: {
444
932
  up: '#after-grid'
445
933
  }
446
934
  });
447
- var element = root.querySelector('#middle-center');
448
- expect(safeTarget((0, _target.getTargetByDirectionFromElement)('up', element), function (t) {
935
+ var gridContainer = root.querySelector('[data-spotlight-id="grid"]');
936
+ var beforeGrid = root.querySelector('#before-grid');
937
+ var afterGrid = root.querySelector('#after-grid');
938
+ var topLeft = root.querySelector('#top-left');
939
+ var topCenter = root.querySelector('#top-center');
940
+ var topRight = root.querySelector('#top-right');
941
+ var middleLeft = root.querySelector('#middle-left');
942
+ var middleCenter = root.querySelector('#middle-center');
943
+ var middleRight = root.querySelector('#middle-right');
944
+ var bottomLeft = root.querySelector('#bottom-left');
945
+ var bottomCenter = root.querySelector('#bottom-center');
946
+ var bottomRight = root.querySelector('#bottom-right');
947
+
948
+ // Mock all bounding rects
949
+ beforeGrid.getBoundingClientRect = function () {
950
+ return {
951
+ top: 0,
952
+ left: 10,
953
+ width: 30,
954
+ height: 10,
955
+ right: 40,
956
+ bottom: 10
957
+ };
958
+ };
959
+ gridContainer.getBoundingClientRect = function () {
960
+ return {
961
+ top: 10,
962
+ left: 10,
963
+ width: 30,
964
+ height: 30,
965
+ right: 40,
966
+ bottom: 40
967
+ };
968
+ };
969
+ afterGrid.getBoundingClientRect = function () {
970
+ return {
971
+ top: 40,
972
+ left: 10,
973
+ width: 30,
974
+ height: 10,
975
+ right: 40,
976
+ bottom: 50
977
+ };
978
+ };
979
+ topLeft.getBoundingClientRect = function () {
980
+ return {
981
+ top: 10,
982
+ left: 10,
983
+ width: 10,
984
+ height: 10,
985
+ right: 20,
986
+ bottom: 20
987
+ };
988
+ };
989
+ topCenter.getBoundingClientRect = function () {
990
+ return {
991
+ top: 10,
992
+ left: 20,
993
+ width: 10,
994
+ height: 10,
995
+ right: 30,
996
+ bottom: 20
997
+ };
998
+ };
999
+ topRight.getBoundingClientRect = function () {
1000
+ return {
1001
+ top: 10,
1002
+ left: 30,
1003
+ width: 10,
1004
+ height: 10,
1005
+ right: 40,
1006
+ bottom: 20
1007
+ };
1008
+ };
1009
+ middleLeft.getBoundingClientRect = function () {
1010
+ return {
1011
+ top: 20,
1012
+ left: 10,
1013
+ width: 10,
1014
+ height: 10,
1015
+ right: 20,
1016
+ bottom: 30
1017
+ };
1018
+ };
1019
+ middleCenter.getBoundingClientRect = function () {
1020
+ return {
1021
+ top: 20,
1022
+ left: 20,
1023
+ width: 10,
1024
+ height: 10,
1025
+ right: 30,
1026
+ bottom: 30
1027
+ };
1028
+ };
1029
+ middleRight.getBoundingClientRect = function () {
1030
+ return {
1031
+ top: 20,
1032
+ left: 30,
1033
+ width: 10,
1034
+ height: 10,
1035
+ right: 40,
1036
+ bottom: 30
1037
+ };
1038
+ };
1039
+ bottomLeft.getBoundingClientRect = function () {
1040
+ return {
1041
+ top: 30,
1042
+ left: 10,
1043
+ width: 10,
1044
+ height: 10,
1045
+ right: 20,
1046
+ bottom: 40
1047
+ };
1048
+ };
1049
+ bottomCenter.getBoundingClientRect = function () {
1050
+ return {
1051
+ top: 30,
1052
+ left: 20,
1053
+ width: 10,
1054
+ height: 10,
1055
+ right: 30,
1056
+ bottom: 40
1057
+ };
1058
+ };
1059
+ bottomRight.getBoundingClientRect = function () {
1060
+ return {
1061
+ top: 30,
1062
+ left: 30,
1063
+ width: 10,
1064
+ height: 10,
1065
+ right: 40,
1066
+ bottom: 40
1067
+ };
1068
+ };
1069
+ expect(safeTarget((0, _target.getTargetByDirectionFromElement)('up', topCenter), function (t) {
449
1070
  return t.id;
450
- })).toBe('top-center');
1071
+ })).toBe('after-grid');
451
1072
  }));
452
- test.skip('should not follow the leaveFor config when the selector does not match an element', (0, _utils.testScenario)(scenarios.grid, function (root) {
1073
+ test('should not follow the leaveFor config when a target is found within the container in the given direction', (0, _utils.testScenario)(scenarios.grid, function (root) {
453
1074
  (0, _container10.configureContainer)('grid', {
454
1075
  restrict: 'none',
455
1076
  leaveFor: {
456
- up: '#does-not-exist'
1077
+ up: '#after-grid'
457
1078
  }
458
1079
  });
459
- var element = root.querySelector('#top-center');
460
- expect(safeTarget((0, _target.getTargetByDirectionFromElement)('up', element), function (t) {
461
- return t.id;
462
- })).toBe('before-grid');
463
- }));
464
- test.skip('should ignore empty containers', (0, _utils.testScenario)(scenarios.emptyContainer, function (root) {
465
- (0, _container10.configureContainer)('empty-container');
466
- var element = root.querySelector('#above');
467
- expect(safeTarget((0, _target.getTargetByDirectionFromElement)('down', element), function (t) {
468
- return t.id;
469
- })).toBe('below');
470
- }));
471
- test.skip('should ignore overlapping empty containers', (0, _utils.testScenario)(scenarios.emptyContainerOverlap, function (root) {
472
- (0, _container10.configureContainer)('empty-container');
473
- var element = root.querySelector('#above');
474
- expect(safeTarget((0, _target.getTargetByDirectionFromElement)('down', element), function (t) {
475
- return t.id;
476
- })).toBe('below');
477
- }));
478
- });
479
- describe('#getTargetByDirectionFromPosition', function () {
480
- test('should find target within container', (0, _utils.testScenario)(scenarios.grid, function (root) {
481
- (0, _container10.configureContainer)('grid');
482
- var middleCenter = root.querySelector('#middle-center');
1080
+ var gridContainer = root.querySelector('[data-spotlight-id="grid"]');
1081
+ var beforeGrid = root.querySelector('#before-grid');
1082
+ var afterGrid = root.querySelector('#after-grid');
1083
+ var topLeft = root.querySelector('#top-left');
483
1084
  var topCenter = root.querySelector('#top-center');
484
- var bottomCenter = root.querySelector('#bottom-center');
1085
+ var topRight = root.querySelector('#top-right');
485
1086
  var middleLeft = root.querySelector('#middle-left');
1087
+ var middleCenter = root.querySelector('#middle-center');
486
1088
  var middleRight = root.querySelector('#middle-right');
1089
+ var bottomLeft = root.querySelector('#bottom-left');
1090
+ var bottomCenter = root.querySelector('#bottom-center');
1091
+ var bottomRight = root.querySelector('#bottom-right');
1092
+
1093
+ // Mock all bounding rects
1094
+ beforeGrid.getBoundingClientRect = function () {
1095
+ return {
1096
+ top: 0,
1097
+ left: 10,
1098
+ width: 30,
1099
+ height: 10,
1100
+ right: 40,
1101
+ bottom: 10
1102
+ };
1103
+ };
1104
+ gridContainer.getBoundingClientRect = function () {
1105
+ return {
1106
+ top: 10,
1107
+ left: 10,
1108
+ width: 30,
1109
+ height: 30,
1110
+ right: 40,
1111
+ bottom: 40
1112
+ };
1113
+ };
1114
+ afterGrid.getBoundingClientRect = function () {
1115
+ return {
1116
+ top: 40,
1117
+ left: 10,
1118
+ width: 30,
1119
+ height: 10,
1120
+ right: 40,
1121
+ bottom: 50
1122
+ };
1123
+ };
1124
+ topLeft.getBoundingClientRect = function () {
1125
+ return {
1126
+ top: 10,
1127
+ left: 10,
1128
+ width: 10,
1129
+ height: 10,
1130
+ right: 20,
1131
+ bottom: 20
1132
+ };
1133
+ };
1134
+ topCenter.getBoundingClientRect = function () {
1135
+ return {
1136
+ top: 10,
1137
+ left: 20,
1138
+ width: 10,
1139
+ height: 10,
1140
+ right: 30,
1141
+ bottom: 20
1142
+ };
1143
+ };
1144
+ topRight.getBoundingClientRect = function () {
1145
+ return {
1146
+ top: 10,
1147
+ left: 30,
1148
+ width: 10,
1149
+ height: 10,
1150
+ right: 40,
1151
+ bottom: 20
1152
+ };
1153
+ };
1154
+ middleLeft.getBoundingClientRect = function () {
1155
+ return {
1156
+ top: 20,
1157
+ left: 10,
1158
+ width: 10,
1159
+ height: 10,
1160
+ right: 20,
1161
+ bottom: 30
1162
+ };
1163
+ };
487
1164
  middleCenter.getBoundingClientRect = function () {
1165
+ return {
1166
+ top: 20,
1167
+ left: 20,
1168
+ width: 10,
1169
+ height: 10,
1170
+ right: 30,
1171
+ bottom: 30
1172
+ };
1173
+ };
1174
+ middleRight.getBoundingClientRect = function () {
1175
+ return {
1176
+ top: 20,
1177
+ left: 30,
1178
+ width: 10,
1179
+ height: 10,
1180
+ right: 40,
1181
+ bottom: 30
1182
+ };
1183
+ };
1184
+ bottomLeft.getBoundingClientRect = function () {
1185
+ return {
1186
+ top: 30,
1187
+ left: 10,
1188
+ width: 10,
1189
+ height: 10,
1190
+ right: 20,
1191
+ bottom: 40
1192
+ };
1193
+ };
1194
+ bottomCenter.getBoundingClientRect = function () {
1195
+ return {
1196
+ top: 30,
1197
+ left: 20,
1198
+ width: 10,
1199
+ height: 10,
1200
+ right: 30,
1201
+ bottom: 40
1202
+ };
1203
+ };
1204
+ bottomRight.getBoundingClientRect = function () {
1205
+ return {
1206
+ top: 30,
1207
+ left: 30,
1208
+ width: 10,
1209
+ height: 10,
1210
+ right: 40,
1211
+ bottom: 40
1212
+ };
1213
+ };
1214
+ expect(safeTarget((0, _target.getTargetByDirectionFromElement)('up', middleCenter), function (t) {
1215
+ return t.id;
1216
+ })).toBe('top-center');
1217
+ }));
1218
+ test('should not follow the leaveFor config when the selector does not match an element', (0, _utils.testScenario)(scenarios.grid, function (root) {
1219
+ (0, _container10.configureContainer)('grid', {
1220
+ restrict: 'none',
1221
+ leaveFor: {
1222
+ up: '#does-not-exist'
1223
+ }
1224
+ });
1225
+ var gridContainer = root.querySelector('[data-spotlight-id="grid"]');
1226
+ var beforeGrid = root.querySelector('#before-grid');
1227
+ var afterGrid = root.querySelector('#after-grid');
1228
+ var topLeft = root.querySelector('#top-left');
1229
+ var topCenter = root.querySelector('#top-center');
1230
+ var topRight = root.querySelector('#top-right');
1231
+ var middleLeft = root.querySelector('#middle-left');
1232
+ var middleCenter = root.querySelector('#middle-center');
1233
+ var middleRight = root.querySelector('#middle-right');
1234
+ var bottomLeft = root.querySelector('#bottom-left');
1235
+ var bottomCenter = root.querySelector('#bottom-center');
1236
+ var bottomRight = root.querySelector('#bottom-right');
1237
+
1238
+ // Mock all bounding rects
1239
+ beforeGrid.getBoundingClientRect = function () {
1240
+ return {
1241
+ top: 0,
1242
+ left: 10,
1243
+ width: 30,
1244
+ height: 10,
1245
+ right: 40,
1246
+ bottom: 10
1247
+ };
1248
+ };
1249
+ gridContainer.getBoundingClientRect = function () {
1250
+ return {
1251
+ top: 10,
1252
+ left: 10,
1253
+ width: 30,
1254
+ height: 30,
1255
+ right: 40,
1256
+ bottom: 40
1257
+ };
1258
+ };
1259
+ afterGrid.getBoundingClientRect = function () {
1260
+ return {
1261
+ top: 40,
1262
+ left: 10,
1263
+ width: 30,
1264
+ height: 10,
1265
+ right: 40,
1266
+ bottom: 50
1267
+ };
1268
+ };
1269
+ topLeft.getBoundingClientRect = function () {
1270
+ return {
1271
+ top: 10,
1272
+ left: 10,
1273
+ width: 10,
1274
+ height: 10,
1275
+ right: 20,
1276
+ bottom: 20
1277
+ };
1278
+ };
1279
+ topCenter.getBoundingClientRect = function () {
1280
+ return {
1281
+ top: 10,
1282
+ left: 20,
1283
+ width: 10,
1284
+ height: 10,
1285
+ right: 30,
1286
+ bottom: 20
1287
+ };
1288
+ };
1289
+ topRight.getBoundingClientRect = function () {
1290
+ return {
1291
+ top: 10,
1292
+ left: 30,
1293
+ width: 10,
1294
+ height: 10,
1295
+ right: 40,
1296
+ bottom: 20
1297
+ };
1298
+ };
1299
+ middleLeft.getBoundingClientRect = function () {
1300
+ return {
1301
+ top: 20,
1302
+ left: 10,
1303
+ width: 10,
1304
+ height: 10,
1305
+ right: 20,
1306
+ bottom: 30
1307
+ };
1308
+ };
1309
+ middleCenter.getBoundingClientRect = function () {
1310
+ return {
1311
+ top: 20,
1312
+ left: 20,
1313
+ width: 10,
1314
+ height: 10,
1315
+ right: 30,
1316
+ bottom: 30
1317
+ };
1318
+ };
1319
+ middleRight.getBoundingClientRect = function () {
1320
+ return {
1321
+ top: 20,
1322
+ left: 30,
1323
+ width: 10,
1324
+ height: 10,
1325
+ right: 40,
1326
+ bottom: 30
1327
+ };
1328
+ };
1329
+ bottomLeft.getBoundingClientRect = function () {
1330
+ return {
1331
+ top: 30,
1332
+ left: 10,
1333
+ width: 10,
1334
+ height: 10,
1335
+ right: 20,
1336
+ bottom: 40
1337
+ };
1338
+ };
1339
+ bottomCenter.getBoundingClientRect = function () {
1340
+ return {
1341
+ top: 30,
1342
+ left: 20,
1343
+ width: 10,
1344
+ height: 10,
1345
+ right: 30,
1346
+ bottom: 40
1347
+ };
1348
+ };
1349
+ bottomRight.getBoundingClientRect = function () {
1350
+ return {
1351
+ top: 30,
1352
+ left: 30,
1353
+ width: 10,
1354
+ height: 10,
1355
+ right: 40,
1356
+ bottom: 40
1357
+ };
1358
+ };
1359
+ expect(safeTarget((0, _target.getTargetByDirectionFromElement)('up', topCenter), function (t) {
1360
+ return t.id;
1361
+ })).toBe('before-grid');
1362
+ }));
1363
+ test('should ignore empty containers', (0, _utils.testScenario)(scenarios.emptyContainer, function (root) {
1364
+ (0, _container10.configureContainer)('empty-container');
1365
+ var emptyContainer = root.querySelector('[data-spotlight-id="empty-container"]');
1366
+ var above = root.querySelector('#above');
1367
+ var below = root.querySelector('#below');
1368
+
1369
+ // Mock all bounding rects
1370
+ above.getBoundingClientRect = function () {
1371
+ return {
1372
+ top: 0,
1373
+ left: 10,
1374
+ width: 10,
1375
+ height: 10,
1376
+ right: 20,
1377
+ bottom: 10
1378
+ };
1379
+ };
1380
+ emptyContainer.getBoundingClientRect = function () {
1381
+ return {
1382
+ top: 10,
1383
+ left: 10,
1384
+ width: 10,
1385
+ height: 10,
1386
+ right: 20,
1387
+ bottom: 20
1388
+ };
1389
+ };
1390
+ below.getBoundingClientRect = function () {
1391
+ return {
1392
+ top: 30,
1393
+ left: 0,
1394
+ width: 10,
1395
+ height: 10,
1396
+ right: 10,
1397
+ bottom: 40
1398
+ };
1399
+ };
1400
+ expect(safeTarget((0, _target.getTargetByDirectionFromElement)('down', above), function (t) {
1401
+ return t.id;
1402
+ })).toBe('below');
1403
+ }));
1404
+ test('should ignore overlapping empty containers', (0, _utils.testScenario)(scenarios.emptyContainerOverlap, function (root) {
1405
+ (0, _container10.configureContainer)('empty-container');
1406
+ var emptyContainer = root.querySelector('[data-spotlight-id="empty-container"]');
1407
+ var above = root.querySelector('#above');
1408
+ var below = root.querySelector('#below');
1409
+
1410
+ // Mock all bounding rects
1411
+ above.getBoundingClientRect = function () {
1412
+ return {
1413
+ top: 5,
1414
+ left: 10,
1415
+ width: 10,
1416
+ height: 10,
1417
+ right: 20,
1418
+ bottom: 15
1419
+ };
1420
+ };
1421
+ emptyContainer.getBoundingClientRect = function () {
1422
+ return {
1423
+ top: 10,
1424
+ left: 10,
1425
+ width: 10,
1426
+ height: 10,
1427
+ right: 20,
1428
+ bottom: 20
1429
+ };
1430
+ };
1431
+ below.getBoundingClientRect = function () {
1432
+ return {
1433
+ top: 30,
1434
+ left: 0,
1435
+ width: 10,
1436
+ height: 10,
1437
+ right: 10,
1438
+ bottom: 40
1439
+ };
1440
+ };
1441
+ expect(safeTarget((0, _target.getTargetByDirectionFromElement)('down', above), function (t) {
1442
+ return t.id;
1443
+ })).toBe('below');
1444
+ }));
1445
+ });
1446
+ describe('#getTargetByDirectionFromPosition', function () {
1447
+ test('should find target within container', (0, _utils.testScenario)(scenarios.grid, function (root) {
1448
+ (0, _container10.configureContainer)('grid');
1449
+ var middleCenter = root.querySelector('#middle-center');
1450
+ var topCenter = root.querySelector('#top-center');
1451
+ var bottomCenter = root.querySelector('#bottom-center');
1452
+ var middleLeft = root.querySelector('#middle-left');
1453
+ var middleRight = root.querySelector('#middle-right');
1454
+ middleCenter.getBoundingClientRect = function () {
1455
+ return {
1456
+ top: 10,
1457
+ left: 10,
1458
+ width: 10,
1459
+ height: 10
1460
+ };
1461
+ };
1462
+ topCenter.getBoundingClientRect = function () {
1463
+ return {
1464
+ top: 0,
1465
+ left: 10,
1466
+ width: 10,
1467
+ height: 10
1468
+ };
1469
+ };
1470
+ bottomCenter.getBoundingClientRect = function () {
1471
+ return {
1472
+ top: 20,
1473
+ left: 10,
1474
+ width: 10,
1475
+ height: 10
1476
+ };
1477
+ };
1478
+ middleLeft.getBoundingClientRect = function () {
1479
+ return {
1480
+ top: 10,
1481
+ left: 0,
1482
+ width: 10,
1483
+ height: 10
1484
+ };
1485
+ };
1486
+ middleRight.getBoundingClientRect = function () {
1487
+ return {
1488
+ top: 10,
1489
+ left: 20,
1490
+ width: 10,
1491
+ height: 10
1492
+ };
1493
+ };
1494
+ var centerRect = root.querySelector('#middle-center').getBoundingClientRect();
1495
+ var center = {
1496
+ x: centerRect.left + centerRect.width / 2,
1497
+ y: centerRect.top + centerRect.height / 2
1498
+ };
1499
+ expect(safeTarget((0, _target.getTargetByDirectionFromPosition)('up', center, 'grid'), function (t) {
1500
+ return t.id;
1501
+ })).toBe('top-center');
1502
+ expect(safeTarget((0, _target.getTargetByDirectionFromPosition)('down', center, 'grid'), function (t) {
1503
+ return t.id;
1504
+ })).toBe('bottom-center');
1505
+ expect(safeTarget((0, _target.getTargetByDirectionFromPosition)('left', center, 'grid'), function (t) {
1506
+ return t.id;
1507
+ })).toBe('middle-left');
1508
+ expect(safeTarget((0, _target.getTargetByDirectionFromPosition)('right', center, 'grid'), function (t) {
1509
+ return t.id;
1510
+ })).toBe('middle-right');
1511
+ }));
1512
+ test('should keep the same target when at bounds of container with restrict="self-only"', (0, _utils.testScenario)(scenarios.grid, function (root) {
1513
+ (0, _container10.configureContainer)('grid', {
1514
+ restrict: 'self-only'
1515
+ });
1516
+ var topCenter = root.querySelector('#top-center');
1517
+ topCenter.getBoundingClientRect = function () {
1518
+ return {
1519
+ top: 0,
1520
+ left: 10,
1521
+ width: 10,
1522
+ height: 10
1523
+ };
1524
+ };
1525
+ var rect = root.querySelector('#top-center').getBoundingClientRect();
1526
+ var topCenterOfGrid = {
1527
+ x: rect.left + rect.width / 2,
1528
+ y: rect.top
1529
+ };
1530
+ expect(safeTarget((0, _target.getTargetByDirectionFromPosition)('up', topCenterOfGrid, 'grid'), function (t) {
1531
+ return t.id;
1532
+ })).toBe('top-left');
1533
+ }));
1534
+ test('should not find a target outside of container when restrict is not set', (0, _utils.testScenario)(scenarios.grid, function (root) {
1535
+ (0, _container10.configureContainer)('grid', {
1536
+ restrict: 'none'
1537
+ });
1538
+ var gridContainer = root.querySelector('[data-spotlight-id="grid"]');
1539
+ var beforeGrid = root.querySelector('#before-grid');
1540
+ var topLeft = root.querySelector('#top-left');
1541
+ var topCenter = root.querySelector('#top-center');
1542
+ var topRight = root.querySelector('#top-right');
1543
+ var middleLeft = root.querySelector('#middle-left');
1544
+ var middleCenter = root.querySelector('#middle-center');
1545
+ var middleRight = root.querySelector('#middle-right');
1546
+ var bottomLeft = root.querySelector('#bottom-left');
1547
+ var bottomCenter = root.querySelector('#bottom-center');
1548
+ var bottomRight = root.querySelector('#bottom-right');
1549
+
1550
+ // Mock all bounding rects
1551
+ beforeGrid.getBoundingClientRect = function () {
1552
+ return {
1553
+ top: 0,
1554
+ left: 10,
1555
+ width: 30,
1556
+ height: 10,
1557
+ right: 40,
1558
+ bottom: 10
1559
+ };
1560
+ };
1561
+ gridContainer.getBoundingClientRect = function () {
1562
+ return {
1563
+ top: 10,
1564
+ left: 10,
1565
+ width: 30,
1566
+ height: 30,
1567
+ right: 40,
1568
+ bottom: 40
1569
+ };
1570
+ };
1571
+ topLeft.getBoundingClientRect = function () {
1572
+ return {
1573
+ top: 10,
1574
+ left: 10,
1575
+ width: 10,
1576
+ height: 10,
1577
+ right: 20,
1578
+ bottom: 20
1579
+ };
1580
+ };
1581
+ topCenter.getBoundingClientRect = function () {
1582
+ return {
1583
+ top: 10,
1584
+ left: 20,
1585
+ width: 10,
1586
+ height: 10,
1587
+ right: 30,
1588
+ bottom: 20
1589
+ };
1590
+ };
1591
+ topRight.getBoundingClientRect = function () {
1592
+ return {
1593
+ top: 10,
1594
+ left: 30,
1595
+ width: 10,
1596
+ height: 10,
1597
+ right: 40,
1598
+ bottom: 20
1599
+ };
1600
+ };
1601
+ middleLeft.getBoundingClientRect = function () {
1602
+ return {
1603
+ top: 20,
1604
+ left: 10,
1605
+ width: 10,
1606
+ height: 10,
1607
+ right: 20,
1608
+ bottom: 30
1609
+ };
1610
+ };
1611
+ middleCenter.getBoundingClientRect = function () {
1612
+ return {
1613
+ top: 20,
1614
+ left: 20,
1615
+ width: 10,
1616
+ height: 10,
1617
+ right: 30,
1618
+ bottom: 30
1619
+ };
1620
+ };
1621
+ middleRight.getBoundingClientRect = function () {
1622
+ return {
1623
+ top: 20,
1624
+ left: 30,
1625
+ width: 10,
1626
+ height: 10,
1627
+ right: 40,
1628
+ bottom: 30
1629
+ };
1630
+ };
1631
+ bottomLeft.getBoundingClientRect = function () {
1632
+ return {
1633
+ top: 30,
1634
+ left: 10,
1635
+ width: 10,
1636
+ height: 10,
1637
+ right: 20,
1638
+ bottom: 40
1639
+ };
1640
+ };
1641
+ bottomCenter.getBoundingClientRect = function () {
1642
+ return {
1643
+ top: 30,
1644
+ left: 20,
1645
+ width: 10,
1646
+ height: 10,
1647
+ right: 30,
1648
+ bottom: 40
1649
+ };
1650
+ };
1651
+ bottomRight.getBoundingClientRect = function () {
1652
+ return {
1653
+ top: 30,
1654
+ left: 30,
1655
+ width: 10,
1656
+ height: 10,
1657
+ right: 40,
1658
+ bottom: 40
1659
+ };
1660
+ };
1661
+ var rect = topCenter.getBoundingClientRect();
1662
+ var topCenterOfGrid = {
1663
+ x: rect.left + rect.width / 2,
1664
+ y: rect.top
1665
+ };
1666
+ expect(safeTarget((0, _target.getTargetByDirectionFromPosition)('up', topCenterOfGrid, 'grid'), function (t) {
1667
+ return t.id;
1668
+ })).toBe('before-grid');
1669
+ }));
1670
+ test('should cascade into unrestricted subcontainers', (0, _utils.testScenario)(scenarios.grid, function (root) {
1671
+ (0, _container10.configureContainer)('grid', {
1672
+ restrict: 'none'
1673
+ });
1674
+ var gridContainer = root.querySelector('[data-spotlight-id="grid"]');
1675
+ var beforeGrid = root.querySelector('#before-grid');
1676
+ var topLeft = root.querySelector('#top-left');
1677
+ var topCenter = root.querySelector('#top-center');
1678
+ var topRight = root.querySelector('#top-right');
1679
+ var middleLeft = root.querySelector('#middle-left');
1680
+ var middleCenter = root.querySelector('#middle-center');
1681
+ var middleRight = root.querySelector('#middle-right');
1682
+ var bottomLeft = root.querySelector('#bottom-left');
1683
+ var bottomCenter = root.querySelector('#bottom-center');
1684
+ var bottomRight = root.querySelector('#bottom-right');
1685
+
1686
+ // Mock all bounding rects
1687
+ beforeGrid.getBoundingClientRect = function () {
1688
+ return {
1689
+ top: 0,
1690
+ left: 10,
1691
+ width: 30,
1692
+ height: 10,
1693
+ right: 40,
1694
+ bottom: 10
1695
+ };
1696
+ };
1697
+ gridContainer.getBoundingClientRect = function () {
1698
+ return {
1699
+ top: 10,
1700
+ left: 10,
1701
+ width: 30,
1702
+ height: 30,
1703
+ right: 40,
1704
+ bottom: 40
1705
+ };
1706
+ };
1707
+ topLeft.getBoundingClientRect = function () {
1708
+ return {
1709
+ top: 10,
1710
+ left: 10,
1711
+ width: 10,
1712
+ height: 10,
1713
+ right: 20,
1714
+ bottom: 20
1715
+ };
1716
+ };
1717
+ topCenter.getBoundingClientRect = function () {
1718
+ return {
1719
+ top: 10,
1720
+ left: 20,
1721
+ width: 10,
1722
+ height: 10,
1723
+ right: 30,
1724
+ bottom: 20
1725
+ };
1726
+ };
1727
+ topRight.getBoundingClientRect = function () {
1728
+ return {
1729
+ top: 10,
1730
+ left: 30,
1731
+ width: 10,
1732
+ height: 10,
1733
+ right: 40,
1734
+ bottom: 20
1735
+ };
1736
+ };
1737
+ middleLeft.getBoundingClientRect = function () {
1738
+ return {
1739
+ top: 20,
1740
+ left: 10,
1741
+ width: 10,
1742
+ height: 10,
1743
+ right: 20,
1744
+ bottom: 30
1745
+ };
1746
+ };
1747
+ middleCenter.getBoundingClientRect = function () {
1748
+ return {
1749
+ top: 20,
1750
+ left: 20,
1751
+ width: 10,
1752
+ height: 10,
1753
+ right: 30,
1754
+ bottom: 30
1755
+ };
1756
+ };
1757
+ middleRight.getBoundingClientRect = function () {
1758
+ return {
1759
+ top: 20,
1760
+ left: 30,
1761
+ width: 10,
1762
+ height: 10,
1763
+ right: 40,
1764
+ bottom: 30
1765
+ };
1766
+ };
1767
+ bottomLeft.getBoundingClientRect = function () {
1768
+ return {
1769
+ top: 30,
1770
+ left: 10,
1771
+ width: 10,
1772
+ height: 10,
1773
+ right: 20,
1774
+ bottom: 40
1775
+ };
1776
+ };
1777
+ bottomCenter.getBoundingClientRect = function () {
1778
+ return {
1779
+ top: 30,
1780
+ left: 20,
1781
+ width: 10,
1782
+ height: 10,
1783
+ right: 30,
1784
+ bottom: 40
1785
+ };
1786
+ };
1787
+ bottomRight.getBoundingClientRect = function () {
1788
+ return {
1789
+ top: 30,
1790
+ left: 30,
1791
+ width: 10,
1792
+ height: 10,
1793
+ right: 40,
1794
+ bottom: 40
1795
+ };
1796
+ };
1797
+ var rect = topCenter.getBoundingClientRect();
1798
+ var aboveCenterOfGrid = {
1799
+ x: rect.left + rect.width / 2,
1800
+ y: rect.top - 1
1801
+ };
1802
+ expect(safeTarget((0, _target.getTargetByDirectionFromPosition)('down', aboveCenterOfGrid, _container10.rootContainerId), function (t) {
1803
+ return t.id;
1804
+ })).toBe('top-center');
1805
+ }));
1806
+ test('should ignore enterTo config of restricted subcontainers', (0, _utils.testScenario)(scenarios.grid, function (root) {
1807
+ (0, _container10.configureContainer)('grid', {
1808
+ restrict: 'none',
1809
+ enterTo: 'default-element',
1810
+ defaultElement: '#bottom-right'
1811
+ });
1812
+ var gridContainer = root.querySelector('[data-spotlight-id="grid"]');
1813
+ var beforeGrid = root.querySelector('#before-grid');
1814
+ var topLeft = root.querySelector('#top-left');
1815
+ var topCenter = root.querySelector('#top-center');
1816
+ var topRight = root.querySelector('#top-right');
1817
+ var middleLeft = root.querySelector('#middle-left');
1818
+ var middleCenter = root.querySelector('#middle-center');
1819
+ var middleRight = root.querySelector('#middle-right');
1820
+ var bottomLeft = root.querySelector('#bottom-left');
1821
+ var bottomCenter = root.querySelector('#bottom-center');
1822
+ var bottomRight = root.querySelector('#bottom-right');
1823
+
1824
+ // Mock all bounding rects
1825
+ beforeGrid.getBoundingClientRect = function () {
1826
+ return {
1827
+ top: 0,
1828
+ left: 10,
1829
+ width: 30,
1830
+ height: 10,
1831
+ right: 40,
1832
+ bottom: 10
1833
+ };
1834
+ };
1835
+ gridContainer.getBoundingClientRect = function () {
1836
+ return {
1837
+ top: 10,
1838
+ left: 10,
1839
+ width: 30,
1840
+ height: 30,
1841
+ right: 40,
1842
+ bottom: 40
1843
+ };
1844
+ };
1845
+ topLeft.getBoundingClientRect = function () {
1846
+ return {
1847
+ top: 10,
1848
+ left: 10,
1849
+ width: 10,
1850
+ height: 10,
1851
+ right: 20,
1852
+ bottom: 20
1853
+ };
1854
+ };
1855
+ topCenter.getBoundingClientRect = function () {
1856
+ return {
1857
+ top: 10,
1858
+ left: 20,
1859
+ width: 10,
1860
+ height: 10,
1861
+ right: 30,
1862
+ bottom: 20
1863
+ };
1864
+ };
1865
+ topRight.getBoundingClientRect = function () {
1866
+ return {
1867
+ top: 10,
1868
+ left: 30,
1869
+ width: 10,
1870
+ height: 10,
1871
+ right: 40,
1872
+ bottom: 20
1873
+ };
1874
+ };
1875
+ middleLeft.getBoundingClientRect = function () {
1876
+ return {
1877
+ top: 20,
1878
+ left: 10,
1879
+ width: 10,
1880
+ height: 10,
1881
+ right: 20,
1882
+ bottom: 30
1883
+ };
1884
+ };
1885
+ middleCenter.getBoundingClientRect = function () {
1886
+ return {
1887
+ top: 20,
1888
+ left: 20,
1889
+ width: 10,
1890
+ height: 10,
1891
+ right: 30,
1892
+ bottom: 30
1893
+ };
1894
+ };
1895
+ middleRight.getBoundingClientRect = function () {
1896
+ return {
1897
+ top: 20,
1898
+ left: 30,
1899
+ width: 10,
1900
+ height: 10,
1901
+ right: 40,
1902
+ bottom: 30
1903
+ };
1904
+ };
1905
+ bottomLeft.getBoundingClientRect = function () {
1906
+ return {
1907
+ top: 30,
1908
+ left: 10,
1909
+ width: 10,
1910
+ height: 10,
1911
+ right: 20,
1912
+ bottom: 40
1913
+ };
1914
+ };
1915
+ bottomCenter.getBoundingClientRect = function () {
1916
+ return {
1917
+ top: 30,
1918
+ left: 20,
1919
+ width: 10,
1920
+ height: 10,
1921
+ right: 30,
1922
+ bottom: 40
1923
+ };
1924
+ };
1925
+ bottomRight.getBoundingClientRect = function () {
1926
+ return {
1927
+ top: 30,
1928
+ left: 30,
1929
+ width: 10,
1930
+ height: 10,
1931
+ right: 40,
1932
+ bottom: 40
1933
+ };
1934
+ };
1935
+ var rect = topCenter.getBoundingClientRect();
1936
+ var aboveCenterOfGrid = {
1937
+ x: rect.left + rect.width / 2,
1938
+ y: rect.top - 1
1939
+ };
1940
+ expect(safeTarget((0, _target.getTargetByDirectionFromPosition)('down', aboveCenterOfGrid, _container10.rootContainerId), function (t) {
1941
+ return t.id;
1942
+ })).toBe('top-center');
1943
+ }));
1944
+ test('should find target within container from floating element', (0, _utils.testScenario)(scenarios.overlap, function (root) {
1945
+ (0, _container10.configureContainer)('grid', {
1946
+ enterTo: 'default-element',
1947
+ defaultElement: '#bottom-right'
1948
+ });
1949
+ var gridContainer = root.querySelector('[data-spotlight-id="grid"]');
1950
+ var overlap = root.querySelector('#over-middle-center');
1951
+ var topLeft = root.querySelector('#top-left');
1952
+ var topCenter = root.querySelector('#top-center');
1953
+ var topRight = root.querySelector('#top-right');
1954
+ var middleLeft = root.querySelector('#middle-left');
1955
+ var middleCenter = root.querySelector('#middle-center');
1956
+ var middleRight = root.querySelector('#middle-right');
1957
+ var bottomLeft = root.querySelector('#bottom-left');
1958
+ var bottomCenter = root.querySelector('#bottom-center');
1959
+ var bottomRight = root.querySelector('#bottom-right');
1960
+
1961
+ // Mock all bounding rects
1962
+ gridContainer.getBoundingClientRect = function () {
1963
+ return {
1964
+ top: 10,
1965
+ left: 10,
1966
+ width: 30,
1967
+ height: 30,
1968
+ right: 40,
1969
+ bottom: 40
1970
+ };
1971
+ };
1972
+ topLeft.getBoundingClientRect = function () {
488
1973
  return {
489
1974
  top: 10,
490
1975
  left: 10,
491
1976
  width: 10,
492
- height: 10
1977
+ height: 10,
1978
+ right: 20,
1979
+ bottom: 20
493
1980
  };
494
1981
  };
495
1982
  topCenter.getBoundingClientRect = function () {
496
1983
  return {
497
- top: 0,
498
- left: 10,
1984
+ top: 10,
1985
+ left: 20,
499
1986
  width: 10,
500
- height: 10
1987
+ height: 10,
1988
+ right: 30,
1989
+ bottom: 20
501
1990
  };
502
1991
  };
503
- bottomCenter.getBoundingClientRect = function () {
1992
+ topRight.getBoundingClientRect = function () {
504
1993
  return {
505
- top: 20,
506
- left: 10,
1994
+ top: 10,
1995
+ left: 30,
507
1996
  width: 10,
508
- height: 10
1997
+ height: 10,
1998
+ right: 40,
1999
+ bottom: 20
509
2000
  };
510
2001
  };
511
2002
  middleLeft.getBoundingClientRect = function () {
512
2003
  return {
513
- top: 10,
514
- left: 0,
2004
+ top: 20,
2005
+ left: 10,
515
2006
  width: 10,
516
- height: 10
2007
+ height: 10,
2008
+ right: 20,
2009
+ bottom: 30
517
2010
  };
518
2011
  };
519
- middleRight.getBoundingClientRect = function () {
2012
+ middleCenter.getBoundingClientRect = function () {
520
2013
  return {
521
- top: 10,
2014
+ top: 20,
522
2015
  left: 20,
523
2016
  width: 10,
524
- height: 10
2017
+ height: 10,
2018
+ right: 30,
2019
+ bottom: 30
525
2020
  };
526
2021
  };
527
- var centerRect = root.querySelector('#middle-center').getBoundingClientRect();
528
- var center = {
529
- x: centerRect.left + centerRect.width / 2,
530
- y: centerRect.top + centerRect.height / 2
2022
+ middleRight.getBoundingClientRect = function () {
2023
+ return {
2024
+ top: 20,
2025
+ left: 30,
2026
+ width: 10,
2027
+ height: 10,
2028
+ right: 40,
2029
+ bottom: 30
2030
+ };
531
2031
  };
532
- expect(safeTarget((0, _target.getTargetByDirectionFromPosition)('up', center, 'grid'), function (t) {
533
- return t.id;
534
- })).toBe('top-center');
535
- expect(safeTarget((0, _target.getTargetByDirectionFromPosition)('down', center, 'grid'), function (t) {
536
- return t.id;
537
- })).toBe('bottom-center');
538
- expect(safeTarget((0, _target.getTargetByDirectionFromPosition)('left', center, 'grid'), function (t) {
539
- return t.id;
540
- })).toBe('middle-left');
541
- expect(safeTarget((0, _target.getTargetByDirectionFromPosition)('right', center, 'grid'), function (t) {
542
- return t.id;
543
- })).toBe('middle-right');
544
- }));
545
- test('should keep the same target when at bounds of container with restrict="self-only"', (0, _utils.testScenario)(scenarios.grid, function (root) {
546
- (0, _container10.configureContainer)('grid', {
547
- restrict: 'self-only'
548
- });
549
- var topCenter = root.querySelector('#top-center');
550
- topCenter.getBoundingClientRect = function () {
2032
+ bottomLeft.getBoundingClientRect = function () {
551
2033
  return {
552
- top: 0,
2034
+ top: 30,
553
2035
  left: 10,
554
2036
  width: 10,
555
- height: 10
2037
+ height: 10,
2038
+ right: 20,
2039
+ bottom: 40
556
2040
  };
557
2041
  };
558
- var rect = root.querySelector('#top-center').getBoundingClientRect();
559
- var topCenterOfGrid = {
560
- x: rect.left + rect.width / 2,
561
- y: rect.top
562
- };
563
- expect(safeTarget((0, _target.getTargetByDirectionFromPosition)('up', topCenterOfGrid, 'grid'), function (t) {
564
- return t.id;
565
- })).toBe('top-left');
566
- }));
567
- test.skip('should not find a target outside of container when restrict is not set', (0, _utils.testScenario)(scenarios.grid, function (root) {
568
- (0, _container10.configureContainer)('grid', {
569
- restrict: 'none'
570
- });
571
- var rect = root.querySelector('#top-center').getBoundingClientRect();
572
- var topCenterOfGrid = {
573
- x: rect.left + rect.width / 2,
574
- y: rect.top
2042
+ bottomCenter.getBoundingClientRect = function () {
2043
+ return {
2044
+ top: 30,
2045
+ left: 20,
2046
+ width: 10,
2047
+ height: 10,
2048
+ right: 30,
2049
+ bottom: 40
2050
+ };
575
2051
  };
576
- expect(safeTarget((0, _target.getTargetByDirectionFromPosition)('up', topCenterOfGrid, 'grid'), function (t) {
577
- return t.id;
578
- })).toBe('before-grid');
579
- }));
580
- test.skip('should cascade into unrestricted subcontainers', (0, _utils.testScenario)(scenarios.grid, function (root) {
581
- (0, _container10.configureContainer)('grid', {
582
- restrict: 'none'
583
- });
584
- var rect = root.querySelector('#top-center').getBoundingClientRect();
585
- var aboveCenterOfGrid = {
586
- x: rect.left + rect.width / 2,
587
- y: rect.top - 1
2052
+ bottomRight.getBoundingClientRect = function () {
2053
+ return {
2054
+ top: 30,
2055
+ left: 30,
2056
+ width: 10,
2057
+ height: 10,
2058
+ right: 40,
2059
+ bottom: 40
2060
+ };
588
2061
  };
589
- expect(safeTarget((0, _target.getTargetByDirectionFromPosition)('down', aboveCenterOfGrid, _container10.rootContainerId), function (t) {
590
- return t.id;
591
- })).toBe('top-center');
592
- }));
593
- test.skip('should ignore enterTo config of restricted subcontainers', (0, _utils.testScenario)(scenarios.grid, function (root) {
594
- (0, _container10.configureContainer)('grid', {
595
- restrict: 'none',
596
- enterTo: 'default-element',
597
- defaultElement: '#bottom-right'
598
- });
599
- var rect = root.querySelector('#top-center').getBoundingClientRect();
600
- var aboveCenterOfGrid = {
601
- x: rect.left + rect.width / 2,
602
- y: rect.top - 1
2062
+ // Overlap is floating over middle-center
2063
+ overlap.getBoundingClientRect = function () {
2064
+ return {
2065
+ top: 22,
2066
+ left: 25,
2067
+ width: 1,
2068
+ height: 1,
2069
+ right: 26,
2070
+ bottom: 23
2071
+ };
603
2072
  };
604
- expect(safeTarget((0, _target.getTargetByDirectionFromPosition)('down', aboveCenterOfGrid, _container10.rootContainerId), function (t) {
605
- return t.id;
606
- })).toBe('top-center');
607
- }));
608
- test.skip('should find target within container from floating element', (0, _utils.testScenario)(scenarios.overlap, function (root) {
609
- (0, _container10.configureContainer)('grid', {
610
- enterTo: 'default-element',
611
- defaultElement: '#bottom-right'
612
- });
613
- var overlap = root.querySelector('#over-middle-center');
614
2073
  var _overlap$getBoundingC = overlap.getBoundingClientRect(),
615
2074
  x = _overlap$getBoundingC.left,
616
2075
  y = _overlap$getBoundingC.top;
@@ -621,49 +2080,210 @@ describe('target', function () {
621
2080
  return t.id;
622
2081
  })).toBe('middle-center');
623
2082
  }));
624
- test.skip('should ignore targets outside the bounds of an overflow container', (0, _utils.testScenario)(scenarios.overflow, function (root) {
2083
+ test('should ignore targets outside the bounds of an overflow container', (0, _utils.testScenario)(scenarios.overflow, function (root) {
625
2084
  (0, _container10.configureContainer)('overflow-container', {
626
2085
  overflow: true
627
2086
  });
2087
+ var overflowContainer = root.querySelector('[data-spotlight-id="overflow-container"]');
628
2088
  var element = root.querySelector('#outside-overflow');
2089
+ var overflowAbove = root.querySelector('#overflow-above');
2090
+ var overflowBelow = root.querySelector('#overflow-below');
2091
+ var overflowWithin = root.querySelector('#overflow-within');
2092
+
2093
+ // Mock all bounding rects
2094
+ overflowContainer.getBoundingClientRect = function () {
2095
+ return {
2096
+ top: 50,
2097
+ left: 10,
2098
+ width: 30,
2099
+ height: 30,
2100
+ right: 40,
2101
+ bottom: 80
2102
+ };
2103
+ };
2104
+ element.getBoundingClientRect = function () {
2105
+ return {
2106
+ top: 10,
2107
+ left: 10,
2108
+ width: 10,
2109
+ height: 10,
2110
+ right: 20,
2111
+ bottom: 20
2112
+ };
2113
+ };
2114
+ overflowAbove.getBoundingClientRect = function () {
2115
+ return {
2116
+ top: 30,
2117
+ left: 10,
2118
+ width: 10,
2119
+ height: 10,
2120
+ right: 20,
2121
+ bottom: 40
2122
+ };
2123
+ };
2124
+ overflowWithin.getBoundingClientRect = function () {
2125
+ return {
2126
+ top: 55,
2127
+ left: 10,
2128
+ width: 10,
2129
+ height: 10,
2130
+ right: 20,
2131
+ bottom: 65
2132
+ };
2133
+ };
2134
+ overflowBelow.getBoundingClientRect = function () {
2135
+ return {
2136
+ top: 85,
2137
+ left: 10,
2138
+ width: 10,
2139
+ height: 10,
2140
+ right: 20,
2141
+ bottom: 95
2142
+ };
2143
+ };
629
2144
  var _element$getBoundingC = element.getBoundingClientRect(),
630
2145
  x = _element$getBoundingC.left,
631
2146
  y = _element$getBoundingC.top;
632
2147
  expect(safeTarget((0, _target.getTargetByDirectionFromPosition)('down', {
633
- x: x,
634
- y: y
635
- }, _container10.rootContainerId), function (t) {
2148
+ x: x + 15,
2149
+ y: y + 35
2150
+ }, _container10.rootContainerId),
2151
+ // position is inside #outside-overflow
2152
+ function (t) {
636
2153
  return t.id;
637
2154
  })).toBe('overflow-within');
638
2155
  }));
639
- test.skip('should find target within container larger than overflow container', (0, _utils.testScenario)(scenarios.overflowLargeSubContainer, function (root) {
2156
+ test('should find target within container larger than overflow container', (0, _utils.testScenario)(scenarios.overflowLargeSubContainer, function (root) {
640
2157
  (0, _container10.configureContainer)('overflow-container', {
641
2158
  overflow: true
642
2159
  });
643
2160
  (0, _container10.configureContainer)('inside', {
644
2161
  enterTo: null
645
2162
  });
2163
+ var overflowContainer = root.querySelector('[data-spotlight-id="overflow-container"]');
2164
+ var insideContainer = root.querySelector('[data-spotlight-id="inside"]');
646
2165
  var element = root.querySelector('#outside-overflow');
2166
+ var inLargeContainer = root.querySelector('#in-large-container');
2167
+ var belowLargeContainer = root.querySelector('#below-large-container');
2168
+
2169
+ // Mock all bounding rects
2170
+ overflowContainer.getBoundingClientRect = function () {
2171
+ return {
2172
+ top: 50,
2173
+ left: 10,
2174
+ width: 40,
2175
+ height: 40,
2176
+ right: 50,
2177
+ bottom: 90
2178
+ };
2179
+ };
2180
+ insideContainer.getBoundingClientRect = function () {
2181
+ return {
2182
+ top: 40,
2183
+ left: 15,
2184
+ width: 30,
2185
+ height: 60,
2186
+ right: 45,
2187
+ bottom: 100
2188
+ };
2189
+ };
2190
+ element.getBoundingClientRect = function () {
2191
+ return {
2192
+ top: 10,
2193
+ left: 10,
2194
+ width: 10,
2195
+ height: 10,
2196
+ right: 20,
2197
+ bottom: 20
2198
+ };
2199
+ };
2200
+ inLargeContainer.getBoundingClientRect = function () {
2201
+ return {
2202
+ top: 60,
2203
+ left: 20,
2204
+ width: 10,
2205
+ height: 10,
2206
+ right: 30,
2207
+ bottom: 70
2208
+ };
2209
+ };
2210
+ belowLargeContainer.getBoundingClientRect = function () {
2211
+ return {
2212
+ top: 110,
2213
+ left: 10,
2214
+ width: 10,
2215
+ height: 10,
2216
+ right: 20,
2217
+ bottom: 120
2218
+ };
2219
+ };
647
2220
  var _element$getBoundingC2 = element.getBoundingClientRect(),
648
2221
  x = _element$getBoundingC2.left,
649
2222
  y = _element$getBoundingC2.top;
650
2223
  expect(safeTarget((0, _target.getTargetByDirectionFromPosition)('down', {
651
- x: x,
652
- y: y
653
- }, _container10.rootContainerId), function (t) {
2224
+ x: x + 5,
2225
+ y: y + 5
2226
+ }, _container10.rootContainerId),
2227
+ // position is inside #outside-overflow
2228
+ function (t) {
654
2229
  return t.id;
655
2230
  })).toBe('in-large-container');
656
2231
  }));
657
- test.skip('should find target out of bounds of overflow container from within container', (0, _utils.testScenario)(scenarios.overflow, function (root) {
2232
+ test('should find target out of bounds of overflow container from within container', (0, _utils.testScenario)(scenarios.overflow, function (root) {
658
2233
  (0, _container10.configureContainer)('overflow-container', {
659
2234
  overflow: true
660
2235
  });
661
- var element = root.querySelector('#overflow-within');
662
- var _element$getBoundingC3 = element.getBoundingClientRect(),
663
- left = _element$getBoundingC3.left,
664
- width = _element$getBoundingC3.width,
665
- top = _element$getBoundingC3.top,
666
- height = _element$getBoundingC3.height;
2236
+ var overflowContainer = root.querySelector('[data-spotlight-id="overflow-container"]');
2237
+ var overflowAbove = root.querySelector('#overflow-above');
2238
+ var overflowBelow = root.querySelector('#overflow-below');
2239
+ var overflowWithin = root.querySelector('#overflow-within');
2240
+
2241
+ // Mock all bounding rects
2242
+ overflowContainer.getBoundingClientRect = function () {
2243
+ return {
2244
+ top: 110,
2245
+ left: 10,
2246
+ width: 30,
2247
+ height: 30,
2248
+ right: 40,
2249
+ bottom: 140
2250
+ };
2251
+ };
2252
+ overflowAbove.getBoundingClientRect = function () {
2253
+ return {
2254
+ top: 100,
2255
+ left: 10,
2256
+ width: 10,
2257
+ height: 10,
2258
+ right: 20,
2259
+ bottom: 110
2260
+ };
2261
+ };
2262
+ overflowWithin.getBoundingClientRect = function () {
2263
+ return {
2264
+ top: 110,
2265
+ left: 10,
2266
+ width: 10,
2267
+ height: 10,
2268
+ right: 20,
2269
+ bottom: 120
2270
+ };
2271
+ };
2272
+ overflowBelow.getBoundingClientRect = function () {
2273
+ return {
2274
+ top: 140,
2275
+ left: 10,
2276
+ width: 10,
2277
+ height: 10,
2278
+ right: 20,
2279
+ bottom: 150
2280
+ };
2281
+ };
2282
+ var _overflowWithin$getBo = overflowWithin.getBoundingClientRect(),
2283
+ left = _overflowWithin$getBo.left,
2284
+ width = _overflowWithin$getBo.width,
2285
+ top = _overflowWithin$getBo.top,
2286
+ height = _overflowWithin$getBo.height;
667
2287
  var x = left + width / 2;
668
2288
  var y = top + height / 2;
669
2289
  expect(safeTarget((0, _target.getTargetByDirectionFromPosition)('down', {
@@ -679,14 +2299,48 @@ describe('target', function () {
679
2299
  return t.id;
680
2300
  })).toBe('overflow-above');
681
2301
  }));
682
- test.skip('should ignore empty containers', (0, _utils.testScenario)(scenarios.emptyContainer, function (root) {
2302
+ test('should ignore empty containers', (0, _utils.testScenario)(scenarios.emptyContainer, function (root) {
683
2303
  (0, _container10.configureContainer)('empty-container');
684
- var element = root.querySelector('#above');
685
- var _element$getBoundingC4 = element.getBoundingClientRect(),
686
- left = _element$getBoundingC4.left,
687
- width = _element$getBoundingC4.width,
688
- top = _element$getBoundingC4.top,
689
- height = _element$getBoundingC4.height;
2304
+ var emptyContainer = root.querySelector('[data-spotlight-id="empty-container"]');
2305
+ var above = root.querySelector('#above');
2306
+ var below = root.querySelector('#below');
2307
+
2308
+ // Mock all bounding rects
2309
+ above.getBoundingClientRect = function () {
2310
+ return {
2311
+ top: 0,
2312
+ left: 10,
2313
+ width: 10,
2314
+ height: 10,
2315
+ right: 20,
2316
+ bottom: 10
2317
+ };
2318
+ };
2319
+ emptyContainer.getBoundingClientRect = function () {
2320
+ return {
2321
+ top: 10,
2322
+ left: 10,
2323
+ width: 10,
2324
+ height: 10,
2325
+ right: 20,
2326
+ bottom: 20
2327
+ };
2328
+ };
2329
+ below.getBoundingClientRect = function () {
2330
+ return {
2331
+ top: 30,
2332
+ left: 0,
2333
+ width: 10,
2334
+ height: 10,
2335
+ right: 10,
2336
+ bottom: 40
2337
+ };
2338
+ };
2339
+ var _above$getBoundingCli = above.getBoundingClientRect(),
2340
+ left = _above$getBoundingCli.left,
2341
+ width = _above$getBoundingCli.width,
2342
+ top = _above$getBoundingCli.top,
2343
+ height = _above$getBoundingCli.height;
690
2344
  var x = left + width / 2;
691
2345
  var y = top + height - 1; // just inside the bottom of 'above'
692
2346
 
@@ -697,14 +2351,48 @@ describe('target', function () {
697
2351
  return t.id;
698
2352
  })).toBe('below');
699
2353
  }));
700
- test.skip('should ignore overlapping empty containers', (0, _utils.testScenario)(scenarios.emptyContainer, function (root) {
2354
+ test('should ignore overlapping empty containers', (0, _utils.testScenario)(scenarios.emptyContainer, function (root) {
701
2355
  (0, _container10.configureContainer)('empty-container');
702
- var element = root.querySelector('#above');
703
- var _element$getBoundingC5 = element.getBoundingClientRect(),
704
- left = _element$getBoundingC5.left,
705
- width = _element$getBoundingC5.width,
706
- top = _element$getBoundingC5.top,
707
- height = _element$getBoundingC5.height;
2356
+ var emptyContainer = root.querySelector('[data-spotlight-id="empty-container"]');
2357
+ var above = root.querySelector('#above');
2358
+ var below = root.querySelector('#below');
2359
+
2360
+ // Mock all bounding rects
2361
+ above.getBoundingClientRect = function () {
2362
+ return {
2363
+ top: 0,
2364
+ left: 10,
2365
+ width: 10,
2366
+ height: 10,
2367
+ right: 20,
2368
+ bottom: 10
2369
+ };
2370
+ };
2371
+ emptyContainer.getBoundingClientRect = function () {
2372
+ return {
2373
+ top: 10,
2374
+ left: 10,
2375
+ width: 10,
2376
+ height: 10,
2377
+ right: 20,
2378
+ bottom: 20
2379
+ };
2380
+ };
2381
+ below.getBoundingClientRect = function () {
2382
+ return {
2383
+ top: 30,
2384
+ left: 0,
2385
+ width: 10,
2386
+ height: 10,
2387
+ right: 10,
2388
+ bottom: 40
2389
+ };
2390
+ };
2391
+ var _above$getBoundingCli2 = above.getBoundingClientRect(),
2392
+ left = _above$getBoundingCli2.left,
2393
+ width = _above$getBoundingCli2.width,
2394
+ top = _above$getBoundingCli2.top,
2395
+ height = _above$getBoundingCli2.height;
708
2396
  var x = left + width / 2;
709
2397
  var y = top + height + 1; // just inside the empty container
710
2398
 
@@ -790,15 +2478,11 @@ describe('target', function () {
790
2478
  }, _container10.rootContainerId), function (t) {
791
2479
  return t.id;
792
2480
  });
793
- // TODO: recheck
794
- // const actualFromElement = safeTarget(
795
- // getTargetByDirectionFromElement('down', outside),
796
- // t => t.id
797
- // );
798
-
2481
+ var actualFromElement = safeTarget((0, _target.getTargetByDirectionFromElement)('down', outside), function (t) {
2482
+ return t.id;
2483
+ });
799
2484
  expect(actualFromPosition).toBe(expected);
800
- // TODO: recheck
801
- // expect(actualFromElement).toBe(expected);
2485
+ expect(actualFromElement).toBe(expected);
802
2486
  }));
803
2487
  });
804
2488
  });