@@ -14,6 +14,7 @@ @interface FZAccordionTableViewDelegateTests : FZAccordionTableViewTestBase <FZA
14
14
@property (nonatomic ) BOOL didOpenSectionCalled;
15
15
@property (nonatomic ) BOOL willCloseSectionCalled;
16
16
@property (nonatomic ) BOOL didCloseSectionCalled;
17
+ @property (nonatomic ) BOOL canInteractWithHeaderAtSection;
17
18
18
19
@end
19
20
@@ -29,14 +30,15 @@ - (void)setUp {
29
30
self.didOpenSectionCalled = NO ;
30
31
self.willCloseSectionCalled = NO ;
31
32
self.didCloseSectionCalled = NO ;
33
+ self.canInteractWithHeaderAtSection = YES ;
32
34
}
33
35
34
36
- (void )tearDown {
35
37
[super tearDown ];
36
38
self.mainViewController .delegate = nil ;
37
39
}
38
40
39
- #pragma mark - Tests -
41
+ #pragma mark - Test Open / Close Delegate Calls -
40
42
41
43
- (void )testOpening {
42
44
XCTAssert (!self.willOpenSectionCalled );
@@ -79,6 +81,44 @@ - (void)testClosing {
79
81
[self waitForExpectationsWithTimeout: 5.0 handler: ^(NSError * _Nullable error) { }];
80
82
}
81
83
84
+ #pragma mark - Test Interaction Delegate Call -
85
+
86
+ - (void )testOpeningInteraction
87
+ {
88
+ NSInteger section = 0 ;
89
+
90
+ // Open section
91
+ [self waitForHeaderViewInSection: section];
92
+ [self .tableView toggleSection: section];
93
+ XCTAssert ([self .tableView isSectionOpen: section], @" Section must be open after opening it." );
94
+
95
+ // Close it
96
+ [self .tableView toggleSection: section];
97
+
98
+ // Now try opening again
99
+ self.canInteractWithHeaderAtSection = NO ;
100
+ [self .tableView toggleSection: section];
101
+ XCTAssert (![self .tableView isSectionOpen: section], @" Section must be still closed after turning off interaction." );
102
+ }
103
+
104
+ - (void )testClosingInteraction
105
+ {
106
+ NSInteger section = 0 ;
107
+
108
+ // Test if section is closed
109
+ [self waitForHeaderViewInSection: section];
110
+ XCTAssert (![self .tableView isSectionOpen: section], @" Section must be closed at the start" );
111
+
112
+ // Open it
113
+ [self .tableView toggleSection: section];
114
+ XCTAssert ([self .tableView isSectionOpen: section], @" Section must be open." );
115
+
116
+ // Now try closing
117
+ self.canInteractWithHeaderAtSection = NO ;
118
+ [self .tableView toggleSection: section];
119
+ XCTAssert ([self .tableView isSectionOpen: section], @" Section must be be open after turning off interaction." );
120
+ }
121
+
82
122
83
123
#pragma mark - <FZAccordionTableViewDelegate> -
84
124
@@ -106,4 +146,9 @@ - (void)tableView:(FZAccordionTableView * _Nonnull)tableView didCloseSection:(NS
106
146
self.didCloseSectionCalled = YES ;
107
147
}
108
148
149
+ - (BOOL )tableView : (FZAccordionTableView * _Nonnull)tableView canInteractWithHeaderAtSection : (NSInteger )section
150
+ {
151
+ return self.canInteractWithHeaderAtSection ;
152
+ }
153
+
109
154
@end
0 commit comments