1010#import " PFObject.h"
1111#import " PFUnitTestCase.h"
1212#import " Parse_Private.h"
13+ #import " PFObjectPrivate.h"
1314
1415@interface ObjectUnitTests : PFUnitTestCase
1516
@@ -186,7 +187,7 @@ - (void)testKeyValueCoding {
186187
187188- (void )testFetchObjectWithoutObjectIdError {
188189 PFObject *object = [PFObject objectWithClassName: @" Test" ];
189-
190+
190191 XCTestExpectation *expectation = [self currentSelectorTestExpectation ];
191192 [[object fetchInBackground ] continueWithBlock: ^id (BFTask *task) {
192193 XCTAssertNotNil (task.error );
@@ -198,4 +199,31 @@ - (void)testFetchObjectWithoutObjectIdError {
198199 [self waitForTestExpectations ];
199200}
200201
202+ #pragma mark Revert
203+
204+ - (void )testRevert {
205+ NSDate *date = [NSDate date ];
206+ NSNumber *number = @0.75 ;
207+ PFObject *object = [PFObject _objectFromDictionary: @{ @" yarr" : date,
208+ @" score" : number }
209+ defaultClassName: @" Test" completeData: YES ];
210+ object[@" yarr" ] = @" yolo" ;
211+ [object revert ];
212+ XCTAssertEqualObjects (object[@" yarr" ], date);
213+ XCTAssertEqualObjects (object[@" score" ], number);
214+ }
215+
216+ - (void )testRevertObjectForKey {
217+ NSDate *date = [NSDate date ];
218+ NSNumber *number = @0.75 ;
219+ PFObject *object = [PFObject _objectFromDictionary: @{ @" yarr" : date,
220+ @" score" : @1.0 }
221+ defaultClassName: @" Test" completeData: YES ];
222+ object[@" yarr" ] = @" yolo" ;
223+ object[@" score" ] = number;
224+ [object revertObjectForKey: @" yarr" ];
225+ XCTAssertEqualObjects (object[@" yarr" ], date);
226+ XCTAssertEqualObjects (object[@" score" ], number);
227+ }
228+
201229@end
0 commit comments