Added remaining test coverage to IGListBindingSectionController

Summary: Added remaining test cases to cover `IGListBindingSectionController`

Reviewed By: candance

Differential Revision: D45004640

fbshipit-source-id: 2dd1662af849841ab5dccc1f6731ddac800657a0
This commit is contained in:
Tim Oliver 2023-04-17 20:41:49 -07:00 committed by Facebook GitHub Bot
parent 2b0ca81c0b
commit 97120d288d

View file

@ -24,6 +24,12 @@
#import "IGTestObject.h"
#import "IGTestStringBindableCell.h"
@interface IGListBindingSectionController (Tests)
- (void)setState:(NSInteger)state;
@end
@interface IGListBindingSectionControllerTests : IGListTestCase
@end
@ -481,4 +487,25 @@
XCTAssertEqual([section.viewModels lastObject], @20);
}
#pragma mark - Illegal state validation
- (void)test_whenAdapterReloadsObjects_andStateIsInconsistent_thatExecutionCompletes {
[self setupWithObjects:@[
[[IGTestDiffingObject alloc] initWithKey:@1 objects:@[@7, @"seven"]],
]];
[self.adapter reloadObjects:@[[[IGTestDiffingObject alloc] initWithKey:@1 objects:@[@"four", @4, @"seven", @7]]]];
// Queue up the batch operation which will be called on the next main run loop
XCTestExpectation *expectation = [self expectationWithDescription:NSStringFromSelector(_cmd)];
[self.adapter performBatchAnimated:YES updates:^(id<IGListBatchContext> batchContext){} completion:^(BOOL finished) {
[expectation fulfill];
}];
// Before the next run loop triggers, set the state back to idle
IGListBindingSectionController *controller = (IGListBindingSectionController *)[self.adapter sectionControllerForSection:0];
[controller setState:0];
[self waitForExpectationsWithTimeout:30 handler:nil];
}
@end