@@ -7,7 +7,7 @@ describe('indexForPositionOnList', () => {
7
7
expect ( indexForPositionOnList ( { x : 0 , y : 0 } , [ ] ) ) . toEqual ( null ) ;
8
8
} ) ;
9
9
10
- test ( 'wrapped list with incomplete last row' , ( ) => {
10
+ test ( 'wrapped list with incomplete last row LTR ' , ( ) => {
11
11
const boxes = [
12
12
box ( 0 , 100 , 100 , 0 ) , // index: 0
13
13
box ( 0 , 200 , 100 , 100 ) , // index: 1
@@ -17,25 +17,58 @@ describe('indexForPositionOnList', () => {
17
17
] ;
18
18
19
19
// Inside the second box.
20
- expect ( indexForPositionOnList ( { x : 150 , y : 50 } , boxes ) ) . toEqual ( 1 ) ;
20
+ expect ( indexForPositionOnList ( { x : 150 , y : 50 } , boxes , false ) ) . toEqual ( 1 ) ;
21
21
22
22
// On the border edge of the first and second box. Given to the first box.
23
- expect ( indexForPositionOnList ( { x : 100 , y : 50 } , boxes ) ) . toEqual ( 0 ) ;
23
+ expect ( indexForPositionOnList ( { x : 100 , y : 50 } , boxes , false ) ) . toEqual ( 0 ) ;
24
24
25
25
// Off the top/left edge.
26
- expect ( indexForPositionOnList ( { x : - 100 , y : - 100 } , boxes ) ) . toEqual ( 0 ) ;
26
+ expect ( indexForPositionOnList ( { x : - 100 , y : - 100 } , boxes , false ) ) . toEqual ( 0 ) ;
27
27
28
28
// Off the left edge, in the second row.
29
- expect ( indexForPositionOnList ( { x : - 100 , y : 175 } , boxes ) ) . toEqual ( 3 ) ;
29
+ expect ( indexForPositionOnList ( { x : - 100 , y : 175 } , boxes , false ) ) . toEqual ( 3 ) ;
30
30
31
31
// Off the right edge, in the first row.
32
- expect ( indexForPositionOnList ( { x : 400 , y : 75 } , boxes ) ) . toEqual ( 2 ) ;
32
+ expect ( indexForPositionOnList ( { x : 400 , y : 75 } , boxes , false ) ) . toEqual ( 2 ) ;
33
33
34
34
// Off the top edge, middle of second item.
35
- expect ( indexForPositionOnList ( { x : 150 , y : - 75 } , boxes ) ) . toEqual ( 1 ) ;
35
+ expect ( indexForPositionOnList ( { x : 150 , y : - 75 } , boxes , false ) ) . toEqual ( 1 ) ;
36
36
37
37
// Within the right edge bounds, but on the second (incomplete) row.
38
38
// This tests that wrapped lists with incomplete final rows work correctly.
39
- expect ( indexForPositionOnList ( { x : 375 , y : 175 } , boxes ) ) . toEqual ( 4 ) ;
39
+ expect ( indexForPositionOnList ( { x : 375 , y : 175 } , boxes , false ) ) . toEqual ( 4 ) ;
40
40
} ) ;
41
+
42
+ test ( 'wrapped list with incomplete last row RTL' , ( ) => {
43
+ const boxes = [
44
+ box ( 0 , 0 , 100 , - 100 ) , // index: 0
45
+ box ( 0 , - 100 , 100 , - 200 ) , // index: 1
46
+ box ( 0 , - 200 , 100 , - 300 ) , // index: 2
47
+ box ( 100 , 0 , 200 , - 100 ) , // index: 3 (second row)
48
+ box ( 100 , - 100 , 200 , - 200 ) // index: 4 (second row, left incomplete intentionally)
49
+ ] ;
50
+
51
+ // Inside the second box.
52
+ expect ( indexForPositionOnList ( { x : - 150 , y : 50 } , boxes , true ) ) . toEqual ( 1 ) ;
53
+
54
+ // On the border edge of the first and second box. Given to the first box.
55
+ expect ( indexForPositionOnList ( { x : - 100 , y : 50 } , boxes , true ) ) . toEqual ( 0 ) ;
56
+
57
+ // Off the top/right edge.
58
+ expect ( indexForPositionOnList ( { x : 100 , y : - 100 } , boxes , true ) ) . toEqual ( 0 ) ;
59
+
60
+ // Off the right edge, in the second row.
61
+ expect ( indexForPositionOnList ( { x : 100 , y : 175 } , boxes , true ) ) . toEqual ( 3 ) ;
62
+
63
+ // Off the left edge, in the first row.
64
+ expect ( indexForPositionOnList ( { x : - 400 , y : 75 } , boxes , true ) ) . toEqual ( 2 ) ;
65
+
66
+ // Off the top edge, middle of second item.
67
+ expect ( indexForPositionOnList ( { x : - 150 , y : - 75 } , boxes , true ) ) . toEqual ( 1 ) ;
68
+
69
+ // Within the left edge bounds, but on the second (incomplete) row.
70
+ // This tests that wrapped lists with incomplete final rows work correctly.
71
+ expect ( indexForPositionOnList ( { x : - 375 , y : 175 } , boxes , true ) ) . toEqual ( 4 ) ;
72
+ } ) ;
73
+
41
74
} ) ;
0 commit comments