Skip to content

Commit

Permalink
[Tests] Add test scrollToPageAtIndex ASPagerNode (TextureGroup#629)
Browse files Browse the repository at this point in the history
* add scrollToPageAtIndex for the ASPagerNode

* update convention code
  • Loading branch information
remirobert authored and bernieperez committed Apr 25, 2018
1 parent 684747f commit cf4e028
Showing 1 changed file with 17 additions and 4 deletions.
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

0 comments on commit cf4e028

Please sign in to comment.