@@ -40,8 +40,9 @@ final class LayoutStateTargetContentOffsetTests: XCTestCase {
4040 contentInset: UIEdgeInsets ( top: 50 , left: 0 , bottom: 30 , right: 0 ) ,
4141 scale: 1 ,
4242 verticalLayoutDirection: . topToBottom)
43- let id = layoutState. modelState. idForItemModel ( at: IndexPath ( item: 6 , section: 0 ) ) !
44- XCTAssert ( layoutState. targetContentOffsetAnchor == . topItem( id: id, distanceFromTop: - 25 ) )
43+ let indexPath = IndexPath ( item: 6 , section: 0 )
44+ let id = layoutState. modelState. idForItemModel ( at: indexPath) !
45+ XCTAssert ( layoutState. targetContentOffsetAnchor == . topItem( id: id, elementLocation: ElementLocation ( indexPath: indexPath) , distanceFromTop: - 25 ) )
4546 }
4647
4748 func testAnchor_TopToBottom_ScrolledToBottom( ) throws {
@@ -61,8 +62,9 @@ final class LayoutStateTargetContentOffsetTests: XCTestCase {
6162 contentInset: measurementLayoutState. contentInset,
6263 scale: measurementLayoutState. scale,
6364 verticalLayoutDirection: measurementLayoutState. verticalLayoutDirection)
64- let id = layoutState. modelState. idForItemModel ( at: IndexPath ( item: 9 , section: 0 ) ) !
65- XCTAssert ( layoutState. targetContentOffsetAnchor == . topItem( id: id, distanceFromTop: 25 ) )
65+ let indexPath = IndexPath ( item: 9 , section: 0 )
66+ let id = layoutState. modelState. idForItemModel ( at: indexPath) !
67+ XCTAssert ( layoutState. targetContentOffsetAnchor == . topItem( id: id, elementLocation: ElementLocation ( indexPath: indexPath) , distanceFromTop: 25 ) )
6668 }
6769
6870 func testAnchor_TopToBottom_NoFullyVisibleCells_UsesFallback( ) throws {
@@ -78,8 +80,9 @@ final class LayoutStateTargetContentOffsetTests: XCTestCase {
7880
7981 // Since no items are fully visible, the fallback should use the first partially visible item
8082 // instead of returning .top or .bottom
81- let id = layoutState. modelState. idForItemModel ( at: IndexPath ( item: 0 , section: 0 ) ) !
82- XCTAssert ( layoutState. targetContentOffsetAnchor == . topItem( id: id, distanceFromTop: - 300 ) )
83+ let indexPath = IndexPath ( item: 0 , section: 0 )
84+ let id = layoutState. modelState. idForItemModel ( at: indexPath) !
85+ XCTAssert ( layoutState. targetContentOffsetAnchor == . topItem( id: id, elementLocation: ElementLocation ( indexPath: indexPath) , distanceFromTop: - 300 ) )
8386 }
8487
8588 // MARK: Bottom-to-Top Anchor Tests
@@ -92,8 +95,9 @@ final class LayoutStateTargetContentOffsetTests: XCTestCase {
9295 contentInset: UIEdgeInsets ( top: 50 , left: 0 , bottom: 30 , right: 0 ) ,
9396 scale: 1 ,
9497 verticalLayoutDirection: . bottomToTop)
95- let id = layoutState. modelState. idForItemModel ( at: IndexPath ( item: 3 , section: 0 ) ) !
96- XCTAssert ( layoutState. targetContentOffsetAnchor == . bottomItem( id: id, distanceFromBottom: - 90 ) )
98+ let indexPath = IndexPath ( item: 3 , section: 0 )
99+ let id = layoutState. modelState. idForItemModel ( at: indexPath) !
100+ XCTAssert ( layoutState. targetContentOffsetAnchor == . bottomItem( id: id, elementLocation: ElementLocation ( indexPath: indexPath) , distanceFromBottom: - 90 ) )
97101 }
98102
99103 func testAnchor_BottomToTop_ScrolledToMiddle( ) throws {
@@ -104,8 +108,9 @@ final class LayoutStateTargetContentOffsetTests: XCTestCase {
104108 contentInset: UIEdgeInsets ( top: 50 , left: 0 , bottom: 30 , right: 0 ) ,
105109 scale: 1 ,
106110 verticalLayoutDirection: . bottomToTop)
107- let id = layoutState. modelState. idForItemModel ( at: IndexPath ( item: 10 , section: 0 ) ) !
108- XCTAssert ( layoutState. targetContentOffsetAnchor == . bottomItem( id: id, distanceFromBottom: - 10 ) )
111+ let indexPath = IndexPath ( item: 10 , section: 0 )
112+ let id = layoutState. modelState. idForItemModel ( at: indexPath) !
113+ XCTAssert ( layoutState. targetContentOffsetAnchor == . bottomItem( id: id, elementLocation: ElementLocation ( indexPath: indexPath) , distanceFromBottom: - 10 ) )
109114 }
110115
111116 func testAnchor_BottomToTop_ScrolledToBottom( ) throws {
@@ -139,7 +144,7 @@ final class LayoutStateTargetContentOffsetTests: XCTestCase {
139144 scale: 1 ,
140145 verticalLayoutDirection: . topToBottom)
141146 let targetContentOffsetAnchor = layoutState. targetContentOffsetAnchor
142- XCTAssert ( layoutState. yOffset ( for: targetContentOffsetAnchor) == - 50 )
147+ XCTAssert ( layoutState. yOffset ( for: targetContentOffsetAnchor, isPerformingBatchUpdates : false ) == - 50 )
143148 }
144149
145150 func testOffset_TopToBottom_ScrolledToMiddle( ) {
@@ -151,7 +156,7 @@ final class LayoutStateTargetContentOffsetTests: XCTestCase {
151156 scale: 1 ,
152157 verticalLayoutDirection: . topToBottom)
153158 let targetContentOffsetAnchor = layoutState. targetContentOffsetAnchor
154- XCTAssert ( layoutState. yOffset ( for: targetContentOffsetAnchor) == 500 )
159+ XCTAssert ( layoutState. yOffset ( for: targetContentOffsetAnchor, isPerformingBatchUpdates : false ) == 500 )
155160 }
156161
157162 func testOffset_TopToBottom_ScrolledToBottom( ) {
@@ -172,7 +177,7 @@ final class LayoutStateTargetContentOffsetTests: XCTestCase {
172177 scale: measurementLayoutState. scale,
173178 verticalLayoutDirection: measurementLayoutState. verticalLayoutDirection)
174179 let targetContentOffsetAnchor = layoutState. targetContentOffsetAnchor
175- XCTAssert ( layoutState. yOffset ( for: targetContentOffsetAnchor) == 690 )
180+ XCTAssert ( layoutState. yOffset ( for: targetContentOffsetAnchor, isPerformingBatchUpdates : false ) == 690 )
176181 }
177182
178183 // MARK: Bottom-to-Top Target Content Offset Tests
@@ -186,7 +191,7 @@ final class LayoutStateTargetContentOffsetTests: XCTestCase {
186191 scale: 1 ,
187192 verticalLayoutDirection: . bottomToTop)
188193 let targetContentOffsetAnchor = layoutState. targetContentOffsetAnchor
189- XCTAssert ( layoutState. yOffset ( for: targetContentOffsetAnchor) == - 50 )
194+ XCTAssert ( layoutState. yOffset ( for: targetContentOffsetAnchor, isPerformingBatchUpdates : false ) == - 50 )
190195 }
191196
192197 func testOffset_BottomToTop_ScrolledToMiddle( ) {
@@ -198,7 +203,7 @@ final class LayoutStateTargetContentOffsetTests: XCTestCase {
198203 scale: 1 ,
199204 verticalLayoutDirection: . bottomToTop)
200205 let targetContentOffsetAnchor = layoutState. targetContentOffsetAnchor
201- XCTAssert ( layoutState. yOffset ( for: targetContentOffsetAnchor) == 500 )
206+ XCTAssert ( layoutState. yOffset ( for: targetContentOffsetAnchor, isPerformingBatchUpdates : false ) == 500 )
202207 }
203208
204209 func testOffset_BottomToTop_ScrolledToBottom( ) {
@@ -219,7 +224,7 @@ final class LayoutStateTargetContentOffsetTests: XCTestCase {
219224 scale: measurementLayoutState. scale,
220225 verticalLayoutDirection: measurementLayoutState. verticalLayoutDirection)
221226 let targetContentOffsetAnchor = layoutState. targetContentOffsetAnchor
222- XCTAssert ( layoutState. yOffset ( for: targetContentOffsetAnchor) == 690 )
227+ XCTAssert ( layoutState. yOffset ( for: targetContentOffsetAnchor, isPerformingBatchUpdates : false ) == 690 )
223228 }
224229
225230 // MARK: Private
0 commit comments