|
7 | 7 | //
|
8 | 8 |
|
9 | 9 | #import <XCTest/XCTest.h>
|
10 |
| -#import "FZAccordionTableViewTestHelpers.h" |
11 |
| -#import "MainViewController.h" |
| 10 | +#import "FZAccordionTableViewTestBase.h" |
12 | 11 | #include <stdlib.h>
|
13 | 12 |
|
14 |
| -@interface FZAccordionTableViewUnitTests : XCTestCase |
15 |
| - |
16 |
| -@property (strong, nonatomic) MainViewController *mainViewController; |
17 |
| -@property (weak, nonatomic) FZAccordionTableView *tableView; |
| 13 | +@interface FZAccordionTableViewGeneralTests : FZAccordionTableViewTestBase |
18 | 14 |
|
19 | 15 | @end
|
20 | 16 |
|
21 |
| -@implementation FZAccordionTableViewUnitTests |
| 17 | +@implementation FZAccordionTableViewGeneralTests |
22 | 18 |
|
23 | 19 | #pragma mark - Setup
|
24 | 20 |
|
25 | 21 | - (void)setUp {
|
26 | 22 | [super setUp];
|
27 |
| - self.mainViewController = [FZAccordionTableViewTestHelpers setupMainViewController]; |
28 |
| - self.tableView = self.mainViewController.tableView; |
29 |
| - |
30 |
| - XCTAssertNotNil(self.mainViewController); |
31 |
| - XCTAssertNotNil(self.tableView); |
32 |
| - |
33 | 23 | [self.mainViewController connectTableView];
|
34 | 24 | }
|
35 | 25 |
|
36 | 26 | - (void)tearDown {
|
37 |
| - [FZAccordionTableViewTestHelpers tearDownMainViewController]; |
38 |
| - self.mainViewController = nil; |
39 |
| - self.tableView = nil; |
40 | 27 | [super tearDown];
|
41 | 28 | }
|
42 | 29 |
|
43 |
| -#pragma mark - Helpers |
44 |
| - |
45 |
| -- (void)waitForHeaderViewInSection:(NSInteger)section |
46 |
| -{ |
47 |
| - [FZAccordionTableViewTestHelpers waitForHeaderViewInSection:section tableView:self.tableView]; |
48 |
| -} |
49 |
| - |
50 | 30 | #pragma mark - Method 'isSectionOpen' Tests -
|
51 | 31 |
|
52 | 32 | - (void)testClosedSections {
|
53 |
| - for (NSInteger i = 0; i < [self tableView].numberOfSections; i++) { |
| 33 | + for (NSInteger i = 0; i < self.tableView.numberOfSections; i++) { |
54 | 34 | [self waitForHeaderViewInSection:i];
|
55 | 35 |
|
56 |
| - XCTAssert(![[self tableView] isSectionOpen:i], @"All sections should be initially closed."); |
| 36 | + XCTAssert(![self.tableView isSectionOpen:i], @"All sections should be initially closed."); |
57 | 37 | }
|
58 | 38 | }
|
59 | 39 |
|
60 | 40 | #pragma mark - Metohod 'toggleSection' Tests -
|
61 | 41 |
|
62 |
| - |
63 | 42 | - (void)testSectionToggling {
|
64 |
| - [self tableView].allowMultipleSectionsOpen = YES; |
65 |
| - [self tableView].keepOneSectionOpen = NO; |
| 43 | + self.tableView.allowMultipleSectionsOpen = YES; |
| 44 | + self.tableView.keepOneSectionOpen = NO; |
66 | 45 |
|
67 | 46 | // First, open all of the sections
|
68 |
| - for (NSInteger i = 0; i < [[self tableView] numberOfSections]-1; i++) { |
| 47 | + for (NSInteger i = 0; i < [self.tableView numberOfSections]-1; i++) { |
69 | 48 | [self waitForHeaderViewInSection:i];
|
70 |
| - [[self tableView] toggleSection:i]; |
| 49 | + [self.tableView toggleSection:i]; |
71 | 50 |
|
72 |
| - XCTAssert([[self tableView] isSectionOpen:i], @"Section %d should be open.", (int)i); |
| 51 | + XCTAssert([self.tableView isSectionOpen:i], @"Section %d should be open.", (int)i); |
73 | 52 | }
|
74 | 53 |
|
75 | 54 | // Second, close all of the section
|
76 |
| - for (NSInteger i = 0; i < [[self tableView] numberOfSections]-1; i++) { |
| 55 | + for (NSInteger i = 0; i < [self.tableView numberOfSections]-1; i++) { |
77 | 56 | [self waitForHeaderViewInSection:i];
|
78 |
| - [[self tableView] toggleSection:i]; |
| 57 | + [self.tableView toggleSection:i]; |
79 | 58 |
|
80 |
| - XCTAssert(![[self tableView] isSectionOpen:i], @"Section %d should be closed.", (int)i); |
| 59 | + XCTAssert(![self.tableView isSectionOpen:i], @"Section %d should be closed.", (int)i); |
81 | 60 | }
|
82 | 61 | }
|
83 | 62 |
|
84 | 63 | #pragma mark - Property 'allowMultipleSectionsOpen' Tests -
|
85 | 64 |
|
86 | 65 | - (void)testAllowMultipleSectionsOpenAsTrue {
|
87 |
| - [self tableView].allowMultipleSectionsOpen = YES; |
| 66 | + self.tableView.allowMultipleSectionsOpen = YES; |
88 | 67 |
|
89 | 68 | [self waitForHeaderViewInSection:0];
|
90 |
| - [[self tableView] toggleSection:0]; |
| 69 | + [self.tableView toggleSection:0]; |
91 | 70 |
|
92 | 71 | [self waitForHeaderViewInSection:1];
|
93 |
| - [[self tableView] toggleSection:1]; |
| 72 | + [self.tableView toggleSection:1]; |
94 | 73 |
|
95 |
| - XCTAssert([[self tableView] isSectionOpen:0] && [[self tableView] isSectionOpen:1], @"Both sections should be open."); |
| 74 | + XCTAssert([self.tableView isSectionOpen:0] && [self.tableView isSectionOpen:1], @"Both sections should be open."); |
96 | 75 | }
|
97 | 76 |
|
98 | 77 | - (void)testAllowMultipleSectionsOpenAsFalse {
|
99 |
| - [self tableView].allowMultipleSectionsOpen = NO; |
| 78 | + self.tableView.allowMultipleSectionsOpen = NO; |
100 | 79 |
|
101 | 80 | [self waitForHeaderViewInSection:0];
|
102 |
| - [[self tableView] toggleSection:0]; |
| 81 | + [self.tableView toggleSection:0]; |
103 | 82 |
|
104 | 83 | [self waitForHeaderViewInSection:1];
|
105 |
| - [[self tableView] toggleSection:1]; |
| 84 | + [self.tableView toggleSection:1]; |
106 | 85 |
|
107 |
| - XCTAssert(![[self tableView] isSectionOpen:0] && [[self tableView] isSectionOpen:1], @"Section 0 should be closed when Section 1 was being forced to be open."); |
| 86 | + XCTAssert(![self.tableView isSectionOpen:0] && [self.tableView isSectionOpen:1], @"Section 0 should be closed when Section 1 was being forced to be open."); |
108 | 87 | }
|
109 | 88 |
|
110 |
| - |
111 |
| -// |
112 |
| -//#pragma mark - Property 'sectionsAlwaysOpen' Tests - |
113 |
| -// |
114 |
| -//- (void)testSectionsAlwaysOpen { |
115 |
| -// NSMutableArray *sectionsAlwaysOpen = [NSMutableArray new]; |
116 |
| -// for (NSInteger i = 0; i < self.tableView.numberOfSections; i++) { |
117 |
| -// [sectionsAlwaysOpen addObject:@(i)]; |
118 |
| -// } |
119 |
| -// self.tableView.sectionsAlwaysOpen = [NSSet setWithArray:sectionsAlwaysOpen]; |
120 |
| -// |
121 |
| -// // Test that no matter which way you toggle the section, the section remains open. |
122 |
| -// for (NSInteger i = 0; i < self.tableView.numberOfSections; i++) { |
123 |
| -// [self waitForHeaderViewInSection:i]; |
124 |
| -// [self.tableView toggleSection:i]; |
125 |
| -// |
126 |
| -// XCTAssert([self.tableView isSectionOpen:i], @"Section %d should be open.", (int)i); |
127 |
| -// } |
128 |
| -// |
129 |
| -// for (NSInteger i = 0; i < self.tableView.numberOfSections; i++) { |
130 |
| -// [self waitForHeaderViewInSection:i]; |
131 |
| -// [self.tableView toggleSection:i]; |
132 |
| -// |
133 |
| -// XCTAssert([self.tableView isSectionOpen:i], @"Section %d should be open.", (int)i); |
134 |
| -// } |
135 |
| -//} |
136 |
| - |
137 | 89 | //#pragma mark - Deletion Tests -
|
138 | 90 | //
|
139 | 91 | //- (void)testDeletingRowWithOpenSection {
|
@@ -181,19 +133,4 @@ - (void)testAllowMultipleSectionsOpenAsFalse {
|
181 | 133 | // XCTAssert([self.mainViewController.sections[section] integerValue] == [self.mainViewController.tableView.numOfRowsForSection[@(section)] integerValue], @"The number of rows in section %d of our data source should match those of the FZAccordionTableView 'numOfRowsForSection' after deletion.", (int)section);
|
182 | 134 | //}
|
183 | 135 |
|
184 |
| -#pragma mark - Duds |
185 |
| - |
186 |
| -//- (void)testExample { |
187 |
| -// // This is an example of a functional test case. |
188 |
| -// // Use XCTAssert and related functions to verify your tests produce the correct results. |
189 |
| -// [self mainViewController]; |
190 |
| -//} |
191 |
| -// |
192 |
| -//- (void)testPerformanceExample { |
193 |
| -// // This is an example of a performance test case. |
194 |
| -// [self measureBlock:^{ |
195 |
| -// // Put the code you want to measure the time of here. |
196 |
| -// }]; |
197 |
| -//} |
198 |
| - |
199 | 136 | @end
|
0 commit comments