mirror of
https://github.com/Instagram/IGListKit
synced 2026-05-05 22:48:21 +00:00
Add coverage to catch inconsistency exception
Summary: Added a unit test to cover the inconsistency exception catch we added to capture the crashes caused by the new collection view behaviour in iOS 16.4. The test deliberately puts the collection view state and the model state out of alignment, and then tests that the exception correctly occurs as expected. Reviewed By: fabiomassimo Differential Revision: D50072956 fbshipit-source-id: 4097cc0451d55d1a148156c783fe42654821113c
This commit is contained in:
parent
2bdbc1201a
commit
a18565b8b2
1 changed files with 17 additions and 0 deletions
|
|
@ -167,4 +167,21 @@
|
|||
[transaction reloadSections:[NSIndexSet indexSet]];
|
||||
}
|
||||
|
||||
- (void)test_withIncorrectUpdatesState_thatInconsistencyExceptionIsCaught {
|
||||
_config.allowsBackgroundDiffing = NO;
|
||||
__weak __typeof__(self) weakSelf = self;
|
||||
self.applySectionDataBlock = ^(IGListTransitionData *data) {
|
||||
[weakSelf.collectionView deleteItemsAtIndexPaths:@[[NSIndexPath indexPathWithIndex:0]]];
|
||||
};
|
||||
BOOL exceptionWasHandled = NO;
|
||||
IGListBatchUpdateTransaction *batchUpdateTransaction = [self makeBatchUpdateTransaction];
|
||||
@try {
|
||||
[batchUpdateTransaction begin];
|
||||
} @catch (NSException *exception) {
|
||||
exceptionWasHandled = YES;
|
||||
XCTAssertTrue([exception.name isEqualToString:@"NSInternalInconsistencyException"]);
|
||||
}
|
||||
XCTAssertTrue(exceptionWasHandled);
|
||||
}
|
||||
|
||||
@end
|
||||
|
|
|
|||
Loading…
Reference in a new issue