Remove XCTAssertThrow in IGListAdapterTests

Summary:
= OSS: =

It's not a good testing strategy to check against the assert, it should be checking the real expected output for a function. It limits our usage that we have to use XCTAssertThrow if there is an assertion throws.

The problem is that `IGAssert` uses the `NSCAssert` which would throw an `NSInternalInconsistentException` which affects all the code path. Another follow up is to investigate how to make IGAssert not crashable.

 ---

Reviewed By: rnystrom

Differential Revision: D7481905

fbshipit-source-id: 24af37a6e1aa389317474614cdd214c9df537291
This commit is contained in:
Zhisheng Huang 2018-04-03 17:04:12 -07:00 committed by Facebook Github Bot
parent 01770eb303
commit 5c7a0318b5

View file

@ -1337,42 +1337,6 @@
XCTAssertEqual(size.height, 0.0);
}
- (void)test_whenSectionControllerReturnsNANHeight_thatAssertionFires {
self.adapter.collectionView.collectionViewLayout = [IGListTestOffsettingLayout new];
self.dataSource.objects = @[@1];
[self.adapter reloadDataWithCompletion:nil];
IGListTestSection *section = [self.adapter sectionControllerForObject:self.dataSource.objects[0]];
section.size = CGSizeMake(NAN, 1);
NSIndexPath *indexPath = [NSIndexPath indexPathForItem:0 inSection:0];
XCTAssertThrows([self.adapter collectionView:self.collectionView layout:self.collectionView.collectionViewLayout sizeForItemAtIndexPath:indexPath]);
}
- (void)test_whenSectionControllerReturnsNANWidth_thatAssertionFires {
self.adapter.collectionView.collectionViewLayout = [IGListTestOffsettingLayout new];
self.dataSource.objects = @[@1];
[self.adapter reloadDataWithCompletion:nil];
IGListTestSection *section = [self.adapter sectionControllerForObject:self.dataSource.objects[0]];
section.size = CGSizeMake(1, NAN);
NSIndexPath *indexPath = [NSIndexPath indexPathForItem:0 inSection:0];
XCTAssertThrows([self.adapter collectionView:self.collectionView layout:self.collectionView.collectionViewLayout sizeForItemAtIndexPath:indexPath]);
}
- (void)test_whenSectionControllerReturnsNANWidthNANHeight_thatAssertionFires {
self.adapter.collectionView.collectionViewLayout = [IGListTestOffsettingLayout new];
self.dataSource.objects = @[@1];
[self.adapter reloadDataWithCompletion:nil];
IGListTestSection *section = [self.adapter sectionControllerForObject:self.dataSource.objects[0]];
section.size = CGSizeMake(NAN, NAN);
NSIndexPath *indexPath = [NSIndexPath indexPathForItem:0 inSection:0];
XCTAssertThrows([self.adapter collectionView:self.collectionView layout:self.collectionView.collectionViewLayout sizeForItemAtIndexPath:indexPath]);
}
- (void)test_whenSupplementarySourceReturnsNegativeSize_thatAdapterReturnsZero {
self.dataSource.objects = @[@1];
[self.adapter reloadDataWithCompletion:nil];
@ -1573,11 +1537,6 @@
XCTAssertEqual(collectionView1.dataSource, adapter2);
}
- (void)test_whenPassingNonUniqueIdentifiers_adapterReloadShouldThrow {
self.dataSource.objects = @[@0, @1, @2, @0];
XCTAssertThrows([self.adapter reloadDataWithCompletion:nil]);
}
- (void)test_whenPrefetchingEnabled_thatSetterDisables {
UICollectionView *collectionView = [[UICollectionView alloc] initWithFrame:CGRectZero collectionViewLayout:[UICollectionViewFlowLayout new]];
collectionView.prefetchingEnabled = YES;