-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
95 additions
and
58 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
/** | ||
* Copyright (c) Facebook, Inc. and its affiliates. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
|
||
#import <objc/runtime.h> | ||
|
||
#import <XCTest/XCTest.h> | ||
|
||
#import <OCMock/OCMock.h> | ||
|
||
#import <IGListDiffKit/IGListExperiments.h> | ||
#import <IGListKit/IGListKit.h> | ||
|
||
#import "IGListTestAdapterDataSource.h" | ||
#import "IGListTestCase.h" | ||
#import "IGTestSupplementarySource.h" | ||
#import "IGListAdapterInternal.h" | ||
#import "IGTestNibSupplementaryView.h" | ||
|
||
@interface IGListAdapterTests_IB : IGListTestCase | ||
@end | ||
|
||
@implementation IGListAdapterTests_IB | ||
|
||
- (void)setUp { | ||
self.dataSource = [IGListTestAdapterDataSource new]; | ||
self.updater = [IGListReloadDataUpdater new]; | ||
|
||
[super setUp]; | ||
|
||
// test case doesn't use -setupWithObjects for more control over update events | ||
self.adapter.collectionView = self.collectionView; | ||
self.adapter.dataSource = self.dataSource; | ||
|
||
if (@available(iOS 11.0, tvOS 11.0, *)) { | ||
self.collectionView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever; | ||
} | ||
} | ||
|
||
- (void) test_withEmptySectionPlusFooter_thatVisibleSectionControllersAreCorrect { | ||
self.dataSource.objects = @[@0]; | ||
[self.adapter reloadDataWithCompletion:nil]; | ||
IGTestSupplementarySource *supplementarySource = [IGTestSupplementarySource new]; | ||
supplementarySource.dequeueFromNib = YES; | ||
supplementarySource.collectionContext = self.adapter; | ||
supplementarySource.supportedElementKinds = @[UICollectionElementKindSectionFooter]; | ||
IGListSectionController *controller = [self.adapter sectionControllerForObject:@0]; | ||
controller.supplementaryViewSource = supplementarySource; | ||
supplementarySource.sectionController = controller; | ||
[self.adapter performUpdatesAnimated:NO completion:nil]; | ||
NSArray<IGListSectionController *> *visibleSectionControllers = [self.adapter visibleSectionControllers]; | ||
|
||
XCTAssertTrue([visibleSectionControllers count] == 1); | ||
XCTAssertTrue(visibleSectionControllers.firstObject.supplementaryViewSource == supplementarySource); | ||
} | ||
|
||
- (void)test_whenSupplementarySourceSupportsFooter_withNibs_thatHeaderViewsAreNil { | ||
self.dataSource.objects = @[@1, @2]; | ||
[self.adapter reloadDataWithCompletion:nil]; | ||
|
||
IGTestSupplementarySource *supplementarySource = [IGTestSupplementarySource new]; | ||
supplementarySource.dequeueFromNib = YES; | ||
supplementarySource.collectionContext = self.adapter; | ||
supplementarySource.supportedElementKinds = @[UICollectionElementKindSectionFooter]; | ||
|
||
IGListSectionController *controller = [self.adapter sectionControllerForObject:@1]; | ||
controller.supplementaryViewSource = supplementarySource; | ||
supplementarySource.sectionController = controller; | ||
|
||
[self.adapter performUpdatesAnimated:NO completion:nil]; | ||
|
||
id view = [self.collectionView supplementaryViewForElementKind:UICollectionElementKindSectionFooter atIndexPath:[NSIndexPath indexPathForItem:0 inSection:0]]; | ||
XCTAssertTrue([view isKindOfClass:IGTestNibSupplementaryView.class]); | ||
XCTAssertEqualObjects([[(IGTestNibSupplementaryView *)view label] text], @"Foo bar baz"); | ||
|
||
XCTAssertNil([self.collectionView supplementaryViewForElementKind:UICollectionElementKindSectionHeader atIndexPath:[NSIndexPath indexPathForItem:0 inSection:0]]); | ||
XCTAssertNil([self.collectionView supplementaryViewForElementKind:UICollectionElementKindSectionHeader atIndexPath:[NSIndexPath indexPathForItem:0 inSection:1]]); | ||
XCTAssertNil([self.collectionView supplementaryViewForElementKind:UICollectionElementKindSectionFooter atIndexPath:[NSIndexPath indexPathForItem:0 inSection:1]]); | ||
} | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters