2023-04-06 09:44:16 +00:00
|
|
|
# Copyright (c) Meta Platforms, Inc. and affiliates. All Rights Reserved.
|
2019-06-12 15:46:09 +00:00
|
|
|
|
2018-02-09 17:50:18 +00:00
|
|
|
Feature: Outputting Value Objects implementing IGListDiffable
|
|
|
|
|
|
|
|
|
|
@announce
|
|
|
|
|
Scenario: Generating a value object, which correctly implements IGListDiffable using the specified diffIdentifier
|
2019-08-14 19:20:36 +00:00
|
|
|
Given a file named "project/values/IGListDiffableTest.value" with:
|
2018-02-09 17:50:18 +00:00
|
|
|
"""
|
2019-08-14 19:20:36 +00:00
|
|
|
IGListDiffableTest includes(IGListDiffable) {
|
2018-02-09 17:50:18 +00:00
|
|
|
CGRect someRect
|
2019-08-14 19:20:36 +00:00
|
|
|
%diffIdentifier NSString *stringOne
|
2018-02-09 17:50:18 +00:00
|
|
|
}
|
|
|
|
|
"""
|
|
|
|
|
When I run `../../bin/generate project`
|
2019-08-14 19:20:36 +00:00
|
|
|
Then the file "project/values/IGListDiffableTest.h" should contain:
|
2018-02-09 17:50:18 +00:00
|
|
|
"""
|
2019-08-14 19:20:36 +00:00
|
|
|
|
2018-02-09 17:50:18 +00:00
|
|
|
#import <Foundation/Foundation.h>
|
|
|
|
|
#import <CoreGraphics/CGGeometry.h>
|
2018-02-27 07:00:41 +00:00
|
|
|
#import <IGListKit/IGListDiffable.h>
|
2018-02-09 17:50:18 +00:00
|
|
|
|
2019-08-14 19:20:36 +00:00
|
|
|
@interface IGListDiffableTest : NSObject <IGListDiffable, NSCopying>
|
2018-02-09 17:50:18 +00:00
|
|
|
|
|
|
|
|
@property (nonatomic, readonly) CGRect someRect;
|
|
|
|
|
@property (nonatomic, readonly, copy) NSString *stringOne;
|
|
|
|
|
|
|
|
|
|
+ (instancetype)new NS_UNAVAILABLE;
|
|
|
|
|
|
|
|
|
|
- (instancetype)init NS_UNAVAILABLE;
|
|
|
|
|
|
|
|
|
|
- (instancetype)initWithSomeRect:(CGRect)someRect stringOne:(NSString *)stringOne NS_DESIGNATED_INITIALIZER;
|
|
|
|
|
|
|
|
|
|
@end
|
|
|
|
|
|
|
|
|
|
"""
|
2019-08-14 19:20:36 +00:00
|
|
|
And the file "project/values/IGListDiffableTest.m" should contain:
|
2018-02-09 17:50:18 +00:00
|
|
|
"""
|
|
|
|
|
- (id<NSObject>)diffIdentifier
|
|
|
|
|
{
|
|
|
|
|
return _stringOne;
|
|
|
|
|
}
|
2019-08-14 19:20:36 +00:00
|
|
|
"""
|
|
|
|
|
And the file "project/values/IGListDiffableTest.m" should contain:
|
|
|
|
|
"""
|
2021-03-18 09:19:18 +00:00
|
|
|
- (BOOL)isEqualToDiffableObject:(nullable id<IGListDiffable>)object
|
2018-02-09 17:50:18 +00:00
|
|
|
{
|
|
|
|
|
return [self isEqual:object];
|
|
|
|
|
}
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
Scenario: Generating a value object, which correctly implements IGListDiffable using a CGRect property
|
2019-08-14 19:20:36 +00:00
|
|
|
Given a file named "project/values/IGListDiffableTest2.value" with:
|
2018-02-09 17:50:18 +00:00
|
|
|
"""
|
2019-08-14 19:20:36 +00:00
|
|
|
IGListDiffableTest2 includes(IGListDiffable) {
|
|
|
|
|
%diffIdentifier CGRect someRect
|
2018-02-09 17:50:18 +00:00
|
|
|
}
|
|
|
|
|
"""
|
|
|
|
|
When I run `../../bin/generate project`
|
2019-08-14 19:20:36 +00:00
|
|
|
Then the file "project/values/IGListDiffableTest2.h" should contain:
|
2018-02-09 17:50:18 +00:00
|
|
|
"""
|
2019-08-14 19:20:36 +00:00
|
|
|
|
2018-02-09 17:50:18 +00:00
|
|
|
#import <Foundation/Foundation.h>
|
|
|
|
|
#import <CoreGraphics/CGGeometry.h>
|
2018-02-27 07:00:41 +00:00
|
|
|
#import <IGListKit/IGListDiffable.h>
|
2018-02-09 17:50:18 +00:00
|
|
|
|
2019-08-14 19:20:36 +00:00
|
|
|
@interface IGListDiffableTest2 : NSObject <IGListDiffable, NSCopying>
|
2018-02-09 17:50:18 +00:00
|
|
|
|
|
|
|
|
@property (nonatomic, readonly) CGRect someRect;
|
|
|
|
|
|
|
|
|
|
+ (instancetype)new NS_UNAVAILABLE;
|
|
|
|
|
|
|
|
|
|
- (instancetype)init NS_UNAVAILABLE;
|
|
|
|
|
|
|
|
|
|
- (instancetype)initWithSomeRect:(CGRect)someRect NS_DESIGNATED_INITIALIZER;
|
|
|
|
|
|
|
|
|
|
@end
|
|
|
|
|
"""
|
2019-08-14 19:20:36 +00:00
|
|
|
And the file "project/values/IGListDiffableTest2.m" should contain:
|
2018-02-09 17:50:18 +00:00
|
|
|
"""
|
|
|
|
|
- (id<NSObject>)diffIdentifier
|
|
|
|
|
{
|
2018-10-23 23:45:22 +00:00
|
|
|
return [NSValue valueWithCGRect:_someRect];
|
2018-02-09 17:50:18 +00:00
|
|
|
}
|
2019-08-14 19:20:36 +00:00
|
|
|
"""
|
|
|
|
|
And the file "project/values/IGListDiffableTest2.m" should contain:
|
|
|
|
|
"""
|
2021-03-18 09:19:18 +00:00
|
|
|
- (BOOL)isEqualToDiffableObject:(nullable id<IGListDiffable>)object
|
2018-02-09 17:50:18 +00:00
|
|
|
{
|
|
|
|
|
return [self isEqual:object];
|
|
|
|
|
}
|
|
|
|
|
"""
|
|
|
|
|
|
2018-10-23 23:45:22 +00:00
|
|
|
Scenario: Generating a value object, which correctly implements IGListDiffable using an NSInteger property
|
2019-08-14 19:20:36 +00:00
|
|
|
Given a file named "project/values/IGListDiffableTest3.value" with:
|
2018-10-23 23:45:22 +00:00
|
|
|
"""
|
2019-08-14 19:20:36 +00:00
|
|
|
IGListDiffableTest3 includes(IGListDiffable) {
|
|
|
|
|
%diffIdentifier NSInteger count
|
2018-10-23 23:45:22 +00:00
|
|
|
}
|
|
|
|
|
"""
|
|
|
|
|
When I run `../../bin/generate project`
|
2019-08-14 19:20:36 +00:00
|
|
|
Then the file "project/values/IGListDiffableTest3.m" should contain:
|
2018-10-23 23:45:22 +00:00
|
|
|
"""
|
|
|
|
|
- (id<NSObject>)diffIdentifier
|
|
|
|
|
{
|
|
|
|
|
return @(_count);
|
|
|
|
|
}
|
2019-08-14 19:20:36 +00:00
|
|
|
"""
|
|
|
|
|
And the file "project/values/IGListDiffableTest3.m" should contain:
|
|
|
|
|
"""
|
2021-03-18 09:19:18 +00:00
|
|
|
- (BOOL)isEqualToDiffableObject:(nullable id<IGListDiffable>)object
|
2019-08-14 19:20:36 +00:00
|
|
|
{
|
|
|
|
|
return [self isEqual:object];
|
|
|
|
|
}
|
2018-10-23 23:45:22 +00:00
|
|
|
"""
|
|
|
|
|
|
2018-02-09 17:50:18 +00:00
|
|
|
Scenario: Generating a value object, which correctly implements IGListDiffable defaulting to self as diffIdentifier
|
2019-08-14 19:20:36 +00:00
|
|
|
Given a file named "project/values/IGListDiffableTest4.value" with:
|
2018-02-09 17:50:18 +00:00
|
|
|
"""
|
2019-08-14 19:20:36 +00:00
|
|
|
IGListDiffableTest4 includes(IGListDiffable) {
|
2018-02-09 17:50:18 +00:00
|
|
|
CGRect someRect
|
|
|
|
|
}
|
|
|
|
|
"""
|
|
|
|
|
When I run `../../bin/generate project`
|
2019-08-14 19:20:36 +00:00
|
|
|
Then the file "project/values/IGListDiffableTest4.h" should contain:
|
2018-02-09 17:50:18 +00:00
|
|
|
"""
|
|
|
|
|
#import <Foundation/Foundation.h>
|
|
|
|
|
#import <CoreGraphics/CGGeometry.h>
|
2018-02-27 07:00:41 +00:00
|
|
|
#import <IGListKit/IGListDiffable.h>
|
2018-02-09 17:50:18 +00:00
|
|
|
|
2019-08-14 19:20:36 +00:00
|
|
|
@interface IGListDiffableTest4 : NSObject <IGListDiffable, NSCopying>
|
2018-02-09 17:50:18 +00:00
|
|
|
|
|
|
|
|
@property (nonatomic, readonly) CGRect someRect;
|
|
|
|
|
|
|
|
|
|
+ (instancetype)new NS_UNAVAILABLE;
|
|
|
|
|
|
|
|
|
|
- (instancetype)init NS_UNAVAILABLE;
|
|
|
|
|
|
|
|
|
|
- (instancetype)initWithSomeRect:(CGRect)someRect NS_DESIGNATED_INITIALIZER;
|
|
|
|
|
|
|
|
|
|
@end
|
|
|
|
|
|
|
|
|
|
"""
|
2019-08-14 19:20:36 +00:00
|
|
|
And the file "project/values/IGListDiffableTest4.m" should contain:
|
2018-02-09 17:50:18 +00:00
|
|
|
"""
|
|
|
|
|
- (id<NSObject>)diffIdentifier
|
|
|
|
|
{
|
|
|
|
|
return self;
|
|
|
|
|
}
|
2019-08-14 19:20:36 +00:00
|
|
|
"""
|
|
|
|
|
And the file "project/values/IGListDiffableTest4.m" should contain:
|
|
|
|
|
"""
|
2021-03-18 09:19:18 +00:00
|
|
|
- (BOOL)isEqualToDiffableObject:(nullable id<IGListDiffable>)object
|
2018-02-09 17:50:18 +00:00
|
|
|
{
|
|
|
|
|
return [self isEqual:object];
|
|
|
|
|
}
|
|
|
|
|
"""
|