Add test for IGListAdapter dequeue method

Summary: Adding a test to catch the bug that caused the crash in T33376364. In that bug, dequeueing two cells of the same class, but with different reuse identifiers, would cause a crash. Here in the test, if the same bug were to occur the dequeuing of the second cell would throw an exception and the test would fail.

Differential Revision: D9560911

fbshipit-source-id: 9310839aaf441e919b5d443feaa44c71e991d146
This commit is contained in:
Jeremy Lawrence 2018-08-29 14:21:10 -07:00 committed by Facebook Github Bot
parent 3b19cfb9d7
commit 3cf7e3e95c

View file

@ -157,6 +157,21 @@
XCTAssertEqualObjects(identifier, @"IGNibNameUICollectionViewCell");
}
- (void)test_whenDequeueingTwoCellsOfTheSameClassWithDifferentReuseIdentifiers_thatBothReuseIdentifiersReturnCells {
self.dataSource.objects = @[@1, @2];
[self.adapter reloadDataWithCompletion:nil];
UICollectionViewCell *cell1 = [self.adapter dequeueReusableCellOfClass:[UICollectionViewCell class]
withReuseIdentifier:@"reuse-1"
forSectionController:[self.adapter sectionControllerForObject:@1]
atIndex:0];
UICollectionViewCell *cell2 = [self.adapter dequeueReusableCellOfClass:[UICollectionViewCell class]
withReuseIdentifier:@"reuse-2"
forSectionController:[self.adapter sectionControllerForObject:@1]
atIndex:0];
XCTAssertNotNil(cell1);
XCTAssertNotNil(cell2);
}
- (void)test_whenDataSourceChanges_thatBackgroundViewVisibilityChanges {
self.dataSource.objects = @[@1];
UIView *background = [[UIView alloc] init];