From 1c73ecb4e7b024bc90f078168a5bd143fc6883e2 Mon Sep 17 00:00:00 2001 From: Tim Oliver Date: Wed, 11 Oct 2023 22:30:36 -0700 Subject: [PATCH] Add coverage for minium invalidated section in IGListCollectionViewLayout Summary: Added a test to properly cover the `if (lastValidSection >= 0 && lastValidSection < sectionCount)` check in the `_calculateLayoutIfNeeded` pass inside `IGListCollectionViewLayout`. Reviewed By: fabiomassimo Differential Revision: D50000785 fbshipit-source-id: fe6b99f9592a1ae08299c599dadb03d7b8a958dc --- Tests/IGListCollectionViewLayoutTests.m | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/Tests/IGListCollectionViewLayoutTests.m b/Tests/IGListCollectionViewLayoutTests.m index 7a9896139..d687820dc 100644 --- a/Tests/IGListCollectionViewLayoutTests.m +++ b/Tests/IGListCollectionViewLayoutTests.m @@ -1248,6 +1248,30 @@ - (void)test_whenUpdatingSizes_thatLayoutUpdates { IGAssertEqualFrame([self cellForSection:0 item:2].frame, 40, 0, 20, 20); } +- (void)test_whenMarkingASectionAsUpdated_thatLayoutUpdates { + [self setUpWithStickyHeaders:NO topInset:0]; + [self prepareWithData:@[ + [[IGLayoutTestSection alloc] initWithInsets:UIEdgeInsetsZero + lineSpacing:0 + interitemSpacing:0 + headerHeight:0 + footerHeight:0 + items:@[ + [[IGLayoutTestItem alloc] initWithSize:CGSizeMake(10, 10)], + [[IGLayoutTestItem alloc] initWithSize:CGSizeMake(10, 10)], + ]], + ]]; + + IGAssertEqualFrame([self cellForSection:0 item:0].frame, 0, 0, 10, 10); + IGAssertEqualFrame([self cellForSection:0 item:1].frame, 10, 0, 10, 10); + + [self.layout didModifySection:1]; + [self.layout prepareLayout]; + + IGAssertEqualFrame([self cellForSection:0 item:0].frame, 0, 0, 10, 10); + IGAssertEqualFrame([self cellForSection:0 item:1].frame, 10, 0, 10, 10); +} + #pragma mark - Internal debugging - (void)test_withDelegateNameDebugger_thatReturnedNamesAreValid {