react-native-navigation的迁移库

RNNNavigationStackManagerTest.m 2.5KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. #import <XCTest/XCTest.h>
  2. #import "RNNComponentViewController.h"
  3. #import "RNNStackController.h"
  4. @interface RNNNavigationStackManagerTest : XCTestCase
  5. @property (nonatomic, strong) RNNStackController *nvc;
  6. @property (nonatomic, strong) UIViewController *vc1;
  7. @property (nonatomic, strong) UIViewController *vc2;
  8. @property (nonatomic, strong) UIViewController *vc3;
  9. @end
  10. @implementation RNNNavigationStackManagerTest
  11. - (void)setUp {
  12. [super setUp];
  13. self.nvc = [[RNNStackController alloc] init];
  14. self.vc1 = [RNNComponentViewController new];
  15. self.vc2 = [RNNComponentViewController new];
  16. self.vc3 = [RNNComponentViewController new];
  17. NSArray *vcArray = @[self.vc1, self.vc2, self.vc3];
  18. [self.nvc setViewControllers:vcArray];
  19. }
  20. - (void)testPop_removeTopVCFromStack {
  21. XCTestExpectation *expectation = [self expectationWithDescription:@"Testing Async Method"];
  22. XCTAssertTrue([self.nvc.topViewController isEqual:self.vc3]);
  23. [_nvc popTo:self.vc2 animated:YES completion:^(NSArray *poppedViewControllers) {
  24. XCTAssertTrue([self.nvc.topViewController isEqual:self.vc2]);
  25. [expectation fulfill];
  26. } rejection:nil];
  27. [self waitForExpectationsWithTimeout:1 handler:nil];
  28. }
  29. - (void)testPopToSpecificVC_removeAllPopedVCFromStack {
  30. XCTestExpectation *expectation = [self expectationWithDescription:@"Testing Async Method"];
  31. XCTAssertFalse([self.nvc.topViewController isEqual:self.vc1]);
  32. [_nvc popTo:self.vc1 animated:NO completion:^(NSArray *poppedViewControllers) {
  33. XCTAssertTrue([self.nvc.topViewController isEqual:self.vc1]);
  34. [expectation fulfill];
  35. } rejection:nil];
  36. [self waitForExpectationsWithTimeout:1 handler:nil];
  37. }
  38. - (void)testPopToRoot_removeAllTopVCsFromStack {
  39. XCTestExpectation *expectation = [self expectationWithDescription:@"Testing Async Method"];
  40. [_nvc popToRoot:self.vc3 animated:NO completion:^(NSArray *poppedViewControllers) {
  41. XCTAssertTrue(self.nvc.childViewControllers.count == 1);
  42. XCTAssertTrue([self.nvc.topViewController isEqual:self.vc1]);
  43. [expectation fulfill];
  44. } rejection:nil];
  45. [self waitForExpectationsWithTimeout:1 handler:nil];
  46. }
  47. - (void)testStackRoot_shouldUpdateNavigationControllerChildrenViewControllers {
  48. XCTestExpectation *expectation = [self expectationWithDescription:@"Testing Async Method"];
  49. [_nvc setStackChildren:@[self.vc2] fromViewController:self.vc1 animated:NO completion:^{
  50. XCTAssertTrue(self.nvc.childViewControllers.count == 1);
  51. XCTAssertTrue([self.nvc.topViewController isEqual:self.vc2]);
  52. [expectation fulfill];
  53. } rejection:nil];
  54. [self waitForExpectationsWithTimeout:1 handler:nil];
  55. }
  56. @end