mirror of
https://github.com/Instagram/IGListKit
synced 2026-05-22 16:58:23 +00:00
Issue #299 Unit tests for IGListCollectionView
Summary: Add 2 new unit test files for IGListCollectionView. One is for storyboards and the other for when creating the IGListCollectionView in code. - [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/303 Differential Revision: D4304615 Pulled By: rnystrom fbshipit-source-id: c6edbcd493fe4ee087ce3d0aee80db484207859d
This commit is contained in:
parent
8bfe2fefdd
commit
b9ede32f5b
2 changed files with 85 additions and 0 deletions
|
|
@ -10,6 +10,7 @@
|
|||
01E12EE2D2F55E9DE8928E1E /* Pods_IGListKit_tvOSTests.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 529C388FDB3DF79737F3496A /* Pods_IGListKit_tvOSTests.framework */; };
|
||||
0BBFB66D1DE3B5A50091290F /* IGListGridCollectionViewLayout.h in Headers */ = {isa = PBXBuildFile; fileRef = 828540431DDFF59C00118B94 /* IGListGridCollectionViewLayout.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
||||
0BBFB66E1DE3B5AB0091290F /* IGListGridCollectionViewLayout.m in Sources */ = {isa = PBXBuildFile; fileRef = 828540441DDFF59C00118B94 /* IGListGridCollectionViewLayout.m */; };
|
||||
1F0A68C51DF8D5B9009E8ADE /* IGListCollectionViewTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 1F0A68C41DF8D5B9009E8ADE /* IGListCollectionViewTests.m */; };
|
||||
26271C8A1DAE94E40073E116 /* IGTestSingleNibItemDataSource.m in Sources */ = {isa = PBXBuildFile; fileRef = 26271C891DAE94E40073E116 /* IGTestSingleNibItemDataSource.m */; };
|
||||
26271C8C1DAE96740073E116 /* IGListSingleNibItemControllerTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 26271C8B1DAE96740073E116 /* IGListSingleNibItemControllerTests.m */; };
|
||||
2914BEE91DCD15F400C96401 /* IGTestNibSupplementaryView.xib in Resources */ = {isa = PBXBuildFile; fileRef = 2904861C1DCD02140007F41D /* IGTestNibSupplementaryView.xib */; };
|
||||
|
|
@ -247,6 +248,7 @@
|
|||
|
||||
/* Begin PBXFileReference section */
|
||||
0759F18B564FBC80527DE9E3 /* Pods-IGListKit-tvOSTests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-IGListKit-tvOSTests.release.xcconfig"; path = "Pods/Target Support Files/Pods-IGListKit-tvOSTests/Pods-IGListKit-tvOSTests.release.xcconfig"; sourceTree = "<group>"; };
|
||||
1F0A68C41DF8D5B9009E8ADE /* IGListCollectionViewTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = IGListCollectionViewTests.m; sourceTree = "<group>"; };
|
||||
26271C881DAE94E40073E116 /* IGTestSingleNibItemDataSource.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = IGTestSingleNibItemDataSource.h; sourceTree = "<group>"; };
|
||||
26271C891DAE94E40073E116 /* IGTestSingleNibItemDataSource.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = IGTestSingleNibItemDataSource.m; sourceTree = "<group>"; };
|
||||
26271C8B1DAE96740073E116 /* IGListSingleNibItemControllerTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = IGListSingleNibItemControllerTests.m; sourceTree = "<group>"; };
|
||||
|
|
@ -625,6 +627,7 @@
|
|||
821BC4BE1DB8C95300172ED0 /* IGListSingleStoryboardItemControllerTests.m */,
|
||||
88144EEE1D870EDC007C7F66 /* IGListStackSectionControllerTests.m */,
|
||||
88144EEF1D870EDC007C7F66 /* IGListWorkingRangeHandlerTests.m */,
|
||||
1F0A68C41DF8D5B9009E8ADE /* IGListCollectionViewTests.m */,
|
||||
887D0B571D870E1E009E01F7 /* Info.plist */,
|
||||
88144EF01D870EDC007C7F66 /* Objects */,
|
||||
);
|
||||
|
|
@ -1116,6 +1119,7 @@
|
|||
files = (
|
||||
88144F1C1D870EDC007C7F66 /* IGTestStackedDataSource.m in Sources */,
|
||||
88144F181D870EDC007C7F66 /* IGTestDelegateController.m in Sources */,
|
||||
1F0A68C51DF8D5B9009E8ADE /* IGListCollectionViewTests.m in Sources */,
|
||||
828540481DDFF5D400118B94 /* IGListGridCollectionViewLayoutTests.m in Sources */,
|
||||
88144F0D1D870EDC007C7F66 /* IGListDisplayHandlerTests.m in Sources */,
|
||||
8240C7F51DC2D99300B3AAE7 /* IGTestStoryboardSupplementarySource.m in Sources */,
|
||||
|
|
|
|||
81
Tests/IGListCollectionViewTests.m
Normal file
81
Tests/IGListCollectionViewTests.m
Normal file
|
|
@ -0,0 +1,81 @@
|
|||
/**
|
||||
* Copyright (c) 2016-present, Facebook, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This source code is licensed under the BSD-style license found in the
|
||||
* LICENSE file in the root directory of this source tree. An additional grant
|
||||
* of patent rights can be found in the PATENTS file in the same directory.
|
||||
*/
|
||||
|
||||
#import <XCTest/XCTest.h>
|
||||
|
||||
#import <IGListKit/IGListKit.h>
|
||||
#import "IGTestStoryboardViewController.h"
|
||||
|
||||
static const CGRect kIGListCollectionViewTestFrame = (CGRect){{0.0, 0.0}, {100.0, 100.0}};
|
||||
|
||||
@interface IGListCollectionViewTests : XCTestCase
|
||||
|
||||
@end
|
||||
|
||||
@implementation IGListCollectionViewTests
|
||||
|
||||
- (void)setUp {
|
||||
[super setUp];
|
||||
}
|
||||
|
||||
- (void)tearDown {
|
||||
[super tearDown];
|
||||
|
||||
[[IGListCollectionView appearance] setBackgroundColor:nil];
|
||||
}
|
||||
|
||||
-(void)test_whenUsingUIAppearance_thatIGListCollectionViewUsesAppearanceBackgroundColor {
|
||||
UIColor *appearanceColor = [UIColor redColor];
|
||||
[[IGListCollectionView appearance] setBackgroundColor:appearanceColor];
|
||||
|
||||
IGListCollectionView *collectionView = [self setupIGListCollectionView];
|
||||
|
||||
XCTAssertEqualObjects(collectionView.backgroundColor, appearanceColor);
|
||||
}
|
||||
|
||||
-(void)test_whenNotUsingUIAppearance_thatIGListCollectionViewUsesDefaultBackgroundColor {
|
||||
|
||||
IGListCollectionView *collectionView = [self setupIGListCollectionView];
|
||||
|
||||
XCTAssertEqualObjects(collectionView.backgroundColor, [UIColor whiteColor]);
|
||||
}
|
||||
|
||||
-(void)test_thatIGListCollectionViewHasCorrectDefaults {
|
||||
IGListCollectionView *collectionView = [[IGListCollectionView alloc] initWithFrame: kIGListCollectionViewTestFrame collectionViewLayout:[UICollectionViewFlowLayout new]];
|
||||
|
||||
XCTAssertTrue(collectionView.alwaysBounceVertical);
|
||||
}
|
||||
|
||||
-(void)test_whenUsingUIAppearance_thatStoryboardIGListCollectionViewUsesAppearanceBackgroundColor {
|
||||
UIColor *appearanceColor = [UIColor redColor];
|
||||
[[IGListCollectionView appearance] setBackgroundColor:appearanceColor];
|
||||
|
||||
UIWindow *window = [[UIWindow alloc] initWithFrame:kIGListCollectionViewTestFrame];
|
||||
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"IGTestStoryboard" bundle:[NSBundle bundleForClass:self.class]];
|
||||
IGTestStoryboardViewController *viewController = [storyboard instantiateViewControllerWithIdentifier:@"testVC"];
|
||||
[window addSubview:viewController.view];
|
||||
[viewController performSelectorOnMainThread:@selector(loadView) withObject:nil waitUntilDone:YES];
|
||||
|
||||
XCTAssertEqualObjects(viewController.collectionView.backgroundColor, appearanceColor);
|
||||
}
|
||||
|
||||
#pragma mark - Helper Methods
|
||||
|
||||
-(IGListCollectionView *)setupIGListCollectionView {
|
||||
UIWindow *window = [[UIWindow alloc] initWithFrame:kIGListCollectionViewTestFrame];
|
||||
IGListCollectionView *collectionView = [[IGListCollectionView alloc] initWithFrame: kIGListCollectionViewTestFrame collectionViewLayout:[UICollectionViewFlowLayout new]];
|
||||
UIViewController *viewController = [UIViewController new];
|
||||
[viewController.view addSubview:collectionView];
|
||||
[window addSubview:viewController.view];
|
||||
[viewController performSelectorOnMainThread:@selector(loadView) withObject:nil waitUntilDone:YES];
|
||||
|
||||
return collectionView;
|
||||
}
|
||||
|
||||
@end
|
||||
Loading…
Reference in a new issue