-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
introduce tests for the ASNavigationViewController (#627)
- Loading branch information
1 parent
3b91fba
commit baf1ea2
Showing
2 changed files
with
60 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
// | ||
// ASNavigationControllerTests.m | ||
// Texture | ||
// | ||
// Copyright (c) 2017-present, Pinterest, Inc. All rights reserved. | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
|
||
#import <XCTest/XCTest.h> | ||
#import <AsyncDisplayKit/AsyncDisplayKit.h> | ||
#import "ASNavigationController.h" | ||
|
||
@interface ASNavigationControllerTests : XCTestCase | ||
@end | ||
|
||
@implementation ASNavigationControllerTests | ||
|
||
- (void)testSetViewControllers { | ||
ASViewController *firstController = [ASViewController new]; | ||
ASViewController *secondController = [ASViewController new]; | ||
NSArray *expectedViewControllerStack = @[firstController, secondController]; | ||
ASNavigationController *navigationController = [ASNavigationController new]; | ||
[navigationController setViewControllers:@[firstController, secondController]]; | ||
XCTAssertEqual(navigationController.topViewController, secondController); | ||
XCTAssertEqual(navigationController.visibleViewController, secondController); | ||
XCTAssertTrue([navigationController.viewControllers isEqualToArray:expectedViewControllerStack]); | ||
} | ||
|
||
- (void)testPopViewController { | ||
ASViewController *firstController = [ASViewController new]; | ||
ASViewController *secondController = [ASViewController new]; | ||
NSArray *expectedViewControllerStack = @[firstController]; | ||
ASNavigationController *navigationController = [ASNavigationController new]; | ||
[navigationController setViewControllers:@[firstController, secondController]]; | ||
[navigationController popViewControllerAnimated:false]; | ||
XCTAssertEqual(navigationController.topViewController, firstController); | ||
XCTAssertEqual(navigationController.visibleViewController, firstController); | ||
XCTAssertTrue([navigationController.viewControllers isEqualToArray:expectedViewControllerStack]); | ||
} | ||
|
||
- (void)testPushViewController { | ||
ASViewController *firstController = [ASViewController new]; | ||
ASViewController *secondController = [ASViewController new]; | ||
NSArray *expectedViewControllerStack = @[firstController, secondController]; | ||
ASNavigationController *navigationController = [[ASNavigationController new] initWithRootViewController:firstController]; | ||
[navigationController pushViewController:secondController animated:false]; | ||
XCTAssertEqual(navigationController.topViewController, secondController); | ||
XCTAssertEqual(navigationController.visibleViewController, secondController); | ||
XCTAssertTrue([navigationController.viewControllers isEqualToArray:expectedViewControllerStack]); | ||
} | ||
|
||
@end |