IGListKit/Tests/IGListDebuggerTests.m
Tim Oliver d7574152d3 Add test coverage for list adapter debugger class
Summary: Adds additional functionality and coverage testing to the adapter debugger class

Reviewed By: candance

Differential Revision: D45004651

fbshipit-source-id: 40330f5f2fed2946cc5ead89b30cf4030b596b65
2023-04-17 20:41:49 -07:00

51 lines
1.8 KiB
Objective-C

/*
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
#import <XCTest/XCTest.h>
#import <IGListKit/IGListKit.h>
#import "IGListDebugger.h"
#import "IGListTestAdapterDataSource.h"
@interface IGListDebuggerTests : XCTestCase
@end
@implementation IGListDebuggerTests
- (void)test_whenSearchingAdapterInstances_thatCorrectCountReturned {
// purge any leftover tracking
[IGListDebugger clear];
UIViewController *controller = [UIViewController new];
UICollectionView *collectionView = [[UICollectionView alloc] initWithFrame:CGRectMake(0, 0, 320, 480)
collectionViewLayout:[UICollectionViewFlowLayout new]];
IGListTestAdapterDataSource *dataSource = [IGListTestAdapterDataSource new];
dataSource.objects = @[@1, @2, @3];
IGListAdapter *adapter1 = [[IGListAdapter alloc] initWithUpdater:[IGListAdapterUpdater new] viewController:nil workingRangeSize:0];
adapter1.collectionView = collectionView;
adapter1.dataSource = dataSource;
IGListAdapter *adapter2 = [[IGListAdapter alloc] initWithUpdater:[IGListAdapterUpdater new] viewController:controller workingRangeSize:2];
adapter2.collectionView = collectionView;
adapter2.dataSource = dataSource;
IGListAdapter *adapter3 = [[IGListAdapter alloc] initWithUpdater:[IGListAdapterUpdater new] viewController:controller workingRangeSize:2];
adapter3.collectionView = collectionView;
adapter3.dataSource = dataSource;
[collectionView setNeedsLayout];
[collectionView layoutIfNeeded];
NSArray *descriptions = [IGListDebugger adapterDescriptions];
XCTAssertEqual(descriptions.count, 3);
XCTAssertTrue([[IGListDebugger dump] length] > 0);
}
@end