mirror of
https://github.com/tappollo/IGListKit.git
synced 2026-05-12 16:23:41 +08:00
Add missing adapter tests
Summary: Couple more unit tests missing from `IGListAdapter`. - [x] All tests pass. Demo project builds and runs. - [x] I added tests, an experiment, or detailed why my change isn't tested. - [x] I have reviewed the [contributing guide](https://github.com/Instagram/IGListKit/blob/master/.github/CONTRIBUTING.md) Closes https://github.com/Instagram/IGListKit/pull/287 Differential Revision: D4281952 Pulled By: jessesquires fbshipit-source-id: da01d22b291071e5b2a7623b263574738456b8b8
This commit is contained in:
committed by
Facebook Github Bot
parent
0a08908f7f
commit
4baf267354
@@ -850,4 +850,27 @@ XCTAssertEqual(CGPointEqualToPoint(point, p), YES); \
|
||||
XCTAssertEqual(self.collectionView.numberOfSections, 3);
|
||||
}
|
||||
|
||||
- (void)test_whenDeselectingThroughContext_thatCellDeselected {
|
||||
self.dataSource.objects = @[@1, @2, @3];
|
||||
[self.adapter reloadDataWithCompletion:nil];
|
||||
|
||||
NSIndexPath *path = [NSIndexPath indexPathForItem:0 inSection:0];
|
||||
[self.collectionView selectItemAtIndexPath:path animated:NO scrollPosition:UICollectionViewScrollPositionTop];
|
||||
XCTAssertTrue([[self.collectionView cellForItemAtIndexPath:path] isSelected]);
|
||||
|
||||
id section = [self.adapter sectionControllerForObject:@1];
|
||||
[self.adapter deselectItemAtIndex:0 sectionController:section animated:NO];
|
||||
XCTAssertFalse([[self.collectionView cellForItemAtIndexPath:path] isSelected]);
|
||||
}
|
||||
|
||||
- (void)test_whenScrollingToIndex_withSectionController_thatPositionCorrect {
|
||||
self.dataSource.objects = @[@1, @2, @3, @4, @5, @6, @7, @8, @9, @10, @11, @12, @13, @14, @15, @16, @17, @18, @19];
|
||||
[self.adapter reloadDataWithCompletion:nil];
|
||||
|
||||
IGListSectionController<IGListSectionType> *section = [self.adapter sectionControllerForObject:@8];
|
||||
[section.collectionContext scrollToSectionController:section atIndex:0 scrollPosition:UICollectionViewScrollPositionTop animated:NO];
|
||||
XCTAssertEqual(self.collectionView.contentOffset.x, 0);
|
||||
XCTAssertEqual(self.collectionView.contentOffset.y, 280);
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
Reference in New Issue
Block a user