Skip to content

Commit

Permalink
introduce tests for the ASNavigationViewController (TextureGroup#627)
Browse files Browse the repository at this point in the history
  • Loading branch information
remirobert authored and bernieperez committed Apr 25, 2018
1 parent 837bd61 commit 684747f
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 0 deletions.
4 changes: 4 additions & 0 deletions AsyncDisplayKit.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,7 @@
B350625C1B010F070018CF92 /* ASLog.h in Headers */ = {isa = PBXBuildFile; fileRef = 0516FA3B1A15563400B4EBED /* ASLog.h */; settings = {ATTRIBUTES = (Public, ); }; };
B350625D1B0111740018CF92 /* Photos.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 051943141A1575670030A7D0 /* Photos.framework */; settings = {ATTRIBUTES = (Weak, ); }; };
B350625E1B0111780018CF92 /* AssetsLibrary.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 051943121A1575630030A7D0 /* AssetsLibrary.framework */; settings = {ATTRIBUTES = (Weak, ); }; };
BB5FC3CE1F9BA689007F191E /* ASNavigationControllerTests.m in Sources */ = {isa = PBXBuildFile; fileRef = BB5FC3CD1F9BA688007F191E /* ASNavigationControllerTests.m */; };
C78F7E2B1BF7809800CDEAFC /* ASTableNode.h in Headers */ = {isa = PBXBuildFile; fileRef = B0F880581BEAEC7500D17647 /* ASTableNode.h */; settings = {ATTRIBUTES = (Public, ); }; };
CC034A091E60BEB400626263 /* ASDisplayNode+Convenience.h in Headers */ = {isa = PBXBuildFile; fileRef = CC034A071E60BEB400626263 /* ASDisplayNode+Convenience.h */; settings = {ATTRIBUTES = (Public, ); }; };
CC034A0A1E60BEB400626263 /* ASDisplayNode+Convenience.m in Sources */ = {isa = PBXBuildFile; fileRef = CC034A081E60BEB400626263 /* ASDisplayNode+Convenience.m */; };
Expand Down Expand Up @@ -783,6 +784,7 @@
B30BF6501C5964B0004FCD53 /* ASLayoutManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ASLayoutManager.h; path = TextKit/ASLayoutManager.h; sourceTree = "<group>"; };
B30BF6511C5964B0004FCD53 /* ASLayoutManager.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = ASLayoutManager.m; path = TextKit/ASLayoutManager.m; sourceTree = "<group>"; };
B35061DA1B010EDF0018CF92 /* AsyncDisplayKit.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = AsyncDisplayKit.framework; sourceTree = BUILT_PRODUCTS_DIR; };
BB5FC3CD1F9BA688007F191E /* ASNavigationControllerTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ASNavigationControllerTests.m; sourceTree = "<group>"; };
BDC2D162BD55A807C1475DA5 /* Pods-AsyncDisplayKitTests.profile.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-AsyncDisplayKitTests.profile.xcconfig"; path = "Pods/Target Support Files/Pods-AsyncDisplayKitTests/Pods-AsyncDisplayKitTests.profile.xcconfig"; sourceTree = "<group>"; };
CC034A071E60BEB400626263 /* ASDisplayNode+Convenience.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "ASDisplayNode+Convenience.h"; sourceTree = "<group>"; };
CC034A081E60BEB400626263 /* ASDisplayNode+Convenience.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "ASDisplayNode+Convenience.m"; sourceTree = "<group>"; };
Expand Down Expand Up @@ -1157,6 +1159,7 @@
children = (
CC583ABF1EF9BAB400134156 /* Common */,
CCDD148A1EEDCD9D0020834E /* ASCollectionModernDataSourceTests.m */,
BB5FC3CD1F9BA688007F191E /* ASNavigationControllerTests.m */,
CC034A0F1E60C9BF00626263 /* ASRectTableTests.m */,
CC11F9791DB181180024D77B /* ASNetworkImageNodeTests.m */,
CC051F1E1D7A286A006434CB /* ASCALayerTests.m */,
Expand Down Expand Up @@ -2130,6 +2133,7 @@
CC3B208E1C3F7D0A00798563 /* ASWeakSetTests.m in Sources */,
CC034A101E60C9BF00626263 /* ASRectTableTests.m in Sources */,
F711994E1D20C21100568860 /* ASDisplayNodeExtrasTests.m in Sources */,
BB5FC3CE1F9BA689007F191E /* ASNavigationControllerTests.m in Sources */,
ACF6ED5D1B178DC700DA7C62 /* ASDimensionTests.mm in Sources */,
695BE2551DC1245C008E6EA5 /* ASWrapperSpecSnapshotTests.mm in Sources */,
CCA221D31D6FA7EF00AF6A0F /* ASViewControllerTests.m in Sources */,
Expand Down
56 changes: 56 additions & 0 deletions Tests/ASNavigationControllerTests.m
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

0 comments on commit 684747f

Please sign in to comment.