Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Tests] Add test scrollToPageAtIndex ASPagerNode #629

Merged
merged 2 commits into from
Oct 24, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 17 additions & 4 deletions Tests/ASPagerNodeTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ @interface ASPagerNodeTestController: UIViewController

@implementation ASPagerNodeTestController

- (instancetype)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
- (instancetype)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Populate these immediately so that they're not unexpectedly nil during tests.
Expand All @@ -74,23 +75,35 @@ @interface ASPagerNodeTests : XCTestCase

@implementation ASPagerNodeTests

- (void)testPagerReturnsIndexOfPages {
- (void)testPagerReturnsIndexOfPages
{
ASPagerNodeTestController *testController = [self testController];

ASCellNode *cellNode = [testController.pagerNode nodeForPageAtIndex:0];

XCTAssertEqual([testController.pagerNode indexOfPageWithNode:cellNode], 0);
}

- (void)testPagerReturnsNotFoundForCellThatDontExistInPager {
- (void)testPagerReturnsNotFoundForCellThatDontExistInPager
{
ASPagerNodeTestController *testController = [self testController];

ASCellNode *badNode = [[ASCellNode alloc] init];

XCTAssertEqual([testController.pagerNode indexOfPageWithNode:badNode], NSNotFound);
}

- (ASPagerNodeTestController *)testController {
- (void)testScrollPageToIndex
{
ASPagerNodeTestController *testController = [self testController];
testController.pagerNode.frame = CGRectMake(0, 0, 500, 500);
[testController.pagerNode scrollToPageAtIndex:1 animated:false];

XCTAssertEqual(testController.pagerNode.currentPageIndex, 1);
}

- (ASPagerNodeTestController *)testController
{
ASPagerNodeTestController *testController = [[ASPagerNodeTestController alloc] initWithNibName:nil bundle:nil];
UIWindow *window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
[window makeKeyAndVisible];
Expand Down