mirror of
https://github.com/Instagram/IGListKit
synced 2026-05-23 09:18:29 +00:00
Summary: A quick push to fix something I noticed while studying how IGListKit works. This simply replaces "Facebook, Inc" with "Meta Platforms, Inc" in all of the source files where the company copyright notice is posted. This should help bring our external facing projects more in line with our new corporate branding. There's still a lot more references to "Facebook" as a company in the library (especially around linking to other Meta sponsored open source libraries), but this might need additional scrutiny and review on a case-by-case basis, so let's handle those ones separately. Reviewed By: lorixx Differential Revision: D41207363 fbshipit-source-id: 57cdbf5eb1023b41a5f32c0c05e01628686a19fe
82 lines
4.1 KiB
Objective-C
82 lines
4.1 KiB
Objective-C
/*
|
|
* Copyright (c) Meta Platforms, Inc. and its 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 <OCMock/OCMock.h>
|
|
|
|
#import <IGListKit/IGListKit.h>
|
|
|
|
#import "IGListAdapterProxy.h"
|
|
|
|
@interface IGListAdapterProxyTests : XCTestCase
|
|
|
|
@end
|
|
|
|
@implementation IGListAdapterProxyTests
|
|
|
|
- (void)test_whenSendingInterceptedMethod_thatAdapterReceivesMethod {
|
|
id mockAdapter = [OCMockObject mockForClass:[IGListAdapter class]];
|
|
id mockCollectionViewDelegate = [OCMockObject mockForProtocol:@protocol(UICollectionViewDelegate)];
|
|
IGListAdapterProxy *proxy = [[IGListAdapterProxy alloc] initWithCollectionViewTarget:mockCollectionViewDelegate scrollViewTarget:nil interceptor:mockAdapter];
|
|
UICollectionView *collectionView = [[UICollectionView alloc] initWithFrame:CGRectZero collectionViewLayout:[UICollectionViewFlowLayout new]];
|
|
NSIndexPath *indexPath = [NSIndexPath new];
|
|
|
|
// method is intercepted and sent to the adapter instead
|
|
[[mockAdapter expect] collectionView:collectionView didSelectItemAtIndexPath:indexPath];
|
|
[[mockCollectionViewDelegate reject] collectionView:collectionView didSelectItemAtIndexPath:indexPath];
|
|
[(id)proxy collectionView:collectionView didSelectItemAtIndexPath:indexPath];
|
|
|
|
[mockCollectionViewDelegate verify];
|
|
[mockAdapter verify];
|
|
}
|
|
|
|
- (void)test_whenSendingCollectionViewDelegateMethod_thatCollectionViewDelegateReceivesMethod {
|
|
id mockAdapter = [OCMockObject mockForClass:[IGListAdapter class]];
|
|
id mockCollectionViewDelegate = [OCMockObject mockForProtocol:@protocol(UICollectionViewDelegate)];
|
|
IGListAdapterProxy *proxy = [[IGListAdapterProxy alloc] initWithCollectionViewTarget:mockCollectionViewDelegate scrollViewTarget:nil interceptor:mockAdapter];
|
|
UICollectionView *collectionView = [[UICollectionView alloc] initWithFrame:CGRectZero collectionViewLayout:[UICollectionViewFlowLayout new]];
|
|
NSIndexPath *indexPath = [NSIndexPath new];
|
|
|
|
// method is not intercepted and should be sent to the delegate
|
|
[[mockAdapter reject] collectionView:collectionView shouldShowMenuForItemAtIndexPath:indexPath];
|
|
[[mockCollectionViewDelegate expect] collectionView:collectionView shouldShowMenuForItemAtIndexPath:indexPath];
|
|
[(id)proxy collectionView:collectionView shouldShowMenuForItemAtIndexPath:indexPath];
|
|
|
|
[mockCollectionViewDelegate verify];
|
|
[mockAdapter verify];
|
|
}
|
|
|
|
- (void)test_whenSendingScrollViewDelegateMethod_whenNoCollectionViewDelegate_thatScrollViewDelegateReceivesMethod {
|
|
id mockAdapter = [OCMockObject mockForClass:[IGListAdapter class]];
|
|
id mockCollectionViewDelegate = [OCMockObject mockForProtocol:@protocol(UICollectionViewDelegate)];
|
|
id mockScrollViewDelegate = [OCMockObject mockForProtocol:@protocol(UIScrollViewDelegate)];
|
|
IGListAdapterProxy *proxy = [[IGListAdapterProxy alloc] initWithCollectionViewTarget:mockCollectionViewDelegate scrollViewTarget:mockScrollViewDelegate interceptor:mockAdapter];
|
|
UICollectionView *collectionView = [[UICollectionView alloc] initWithFrame:CGRectZero collectionViewLayout:[UICollectionViewFlowLayout new]];
|
|
|
|
// method is not intercepted and should be sent to the appropriate delegate
|
|
[[mockAdapter reject] scrollViewDidZoom:collectionView];
|
|
[[mockCollectionViewDelegate reject] scrollViewDidZoom:collectionView];
|
|
[[mockScrollViewDelegate expect] scrollViewDidZoom:collectionView];
|
|
[(id)proxy scrollViewDidZoom:collectionView];
|
|
|
|
[mockCollectionViewDelegate verify];
|
|
[mockScrollViewDelegate verify];
|
|
[mockAdapter verify];
|
|
}
|
|
|
|
- (void)test_whenSendingUnimplementedSelector_thatNothingBreaks {
|
|
id mockAdapter = [OCMockObject mockForClass:[IGListAdapter class]];
|
|
IGListAdapterProxy *proxy = [[IGListAdapterProxy alloc] initWithCollectionViewTarget:nil scrollViewTarget:nil interceptor:mockAdapter];
|
|
|
|
// this will try to forward a method to nil since there are no targets set
|
|
// verify that this fails silently
|
|
UIScrollView *scrollView = [UIScrollView new];
|
|
[(id)proxy scrollViewDidZoom:scrollView];
|
|
}
|
|
|
|
@end
|