@@ -14,6 +14,7 @@ @interface FZAccordionTableViewDelegateTests : FZAccordionTableViewTestBase <FZA
1414@property (nonatomic ) BOOL didOpenSectionCalled;
1515@property (nonatomic ) BOOL willCloseSectionCalled;
1616@property (nonatomic ) BOOL didCloseSectionCalled;
17+ @property (nonatomic ) BOOL canInteractWithHeaderAtSection;
1718
1819@end
1920
@@ -29,14 +30,15 @@ - (void)setUp {
2930 self.didOpenSectionCalled = NO ;
3031 self.willCloseSectionCalled = NO ;
3132 self.didCloseSectionCalled = NO ;
33+ self.canInteractWithHeaderAtSection = YES ;
3234}
3335
3436- (void )tearDown {
3537 [super tearDown ];
3638 self.mainViewController .delegate = nil ;
3739}
3840
39- #pragma mark - Tests -
41+ #pragma mark - Test Open / Close Delegate Calls -
4042
4143- (void )testOpening {
4244 XCTAssert (!self.willOpenSectionCalled );
@@ -79,6 +81,44 @@ - (void)testClosing {
7981 [self waitForExpectationsWithTimeout: 5.0 handler: ^(NSError * _Nullable error) { }];
8082}
8183
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+
82122
83123#pragma mark - <FZAccordionTableViewDelegate> -
84124
@@ -106,4 +146,9 @@ - (void)tableView:(FZAccordionTableView * _Nonnull)tableView didCloseSection:(NS
106146 self.didCloseSectionCalled = YES ;
107147}
108148
149+ - (BOOL )tableView : (FZAccordionTableView * _Nonnull)tableView canInteractWithHeaderAtSection : (NSInteger )section
150+ {
151+ return self.canInteractWithHeaderAtSection ;
152+ }
153+
109154@end
0 commit comments