Skip to content

Commit

Permalink
add test to move without batch updates
Browse files Browse the repository at this point in the history
  • Loading branch information
Ryan Nystrom committed Feb 6, 2017
1 parent 374cf1c commit 03d5f78
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
2 changes: 0 additions & 2 deletions Source/IGListAdapter.m
Original file line number Diff line number Diff line change
Expand Up @@ -571,8 +571,6 @@ - (IGListSectionMap *)sectionMapAdjustForUpdateBlock:(BOOL)usePreviousSection {
usePreviousSection:(BOOL)usePreviousSection {
NSMutableArray<NSIndexPath *> *indexPaths = [[NSMutableArray alloc] init];

IGListSectionMap *map = [self sectionMapAdjustForUpdateBlock:adjustForUpdateBlock];

IGListSectionMap *map = [self sectionMapAdjustForUpdateBlock:usePreviousSection];
const NSInteger section = [map sectionForSectionController:sectionController];
if (section != NSNotFound) {
Expand Down
19 changes: 19 additions & 0 deletions Tests/IGListAdapterE2ETests.m
Original file line number Diff line number Diff line change
Expand Up @@ -1318,4 +1318,23 @@ - (void)test_whenMovingItems_thatCollectionViewWorks {
[self waitForExpectationsWithTimeout:15 handler:nil];
}

- (void)test_whenMovingItems_withNoBatchUpdate_thatCollectionViewWorks {
[self setupWithObjects:@[
genTestObject(@1, @2),
]];

IGTestCell *cell1 = (IGTestCell*)[self.collectionView cellForItemAtIndexPath:[NSIndexPath indexPathForItem:0 inSection:0]];
IGTestCell *cell2 = (IGTestCell*)[self.collectionView cellForItemAtIndexPath:[NSIndexPath indexPathForItem:1 inSection:0]];
cell1.label.text = @"foo";
cell2.label.text = @"bar";

IGListSectionController<IGListSectionType> *section = [self.adapter sectionControllerForObject:self.dataSource.objects.lastObject];
[section.collectionContext moveInSectionController:section fromIndex:0 toIndex:1];

IGTestCell *movedCell1 = (IGTestCell*)[self.collectionView cellForItemAtIndexPath:[NSIndexPath indexPathForItem:0 inSection:0]];
IGTestCell *movedCell2 = (IGTestCell*)[self.collectionView cellForItemAtIndexPath:[NSIndexPath indexPathForItem:1 inSection:0]];
XCTAssertEqualObjects(movedCell1.label.text, @"bar");
XCTAssertEqualObjects(movedCell2.label.text, @"foo");
}

@end

0 comments on commit 03d5f78

Please sign in to comment.