From 14ea068f5fd03a658017f8472a4078a727fabc3a Mon Sep 17 00:00:00 2001 From: Konstantin Varlamov Date: Tue, 20 Feb 2018 17:33:57 -0500 Subject: Make FSTTimestamp into a public Firestore class (#698) - FSTTimestamp is now FIRTimestamp, under Firestore/Source/{Public,API}. This is a temporary solution; eventually, FIRTimestamp is supposed to live somewhere under Firebase; - move most internal Timestamp methods to the public header (the only exception is ISOString). --- .../Tests/Integration/API/FIRFieldsTests.mm | 25 ++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'Firestore/Example/Tests/Integration/API') diff --git a/Firestore/Example/Tests/Integration/API/FIRFieldsTests.mm b/Firestore/Example/Tests/Integration/API/FIRFieldsTests.mm index 34bd87e..0e75b8e 100644 --- a/Firestore/Example/Tests/Integration/API/FIRFieldsTests.mm +++ b/Firestore/Example/Tests/Integration/API/FIRFieldsTests.mm @@ -14,6 +14,7 @@ * limitations under the License. */ +#import #import #import @@ -220,4 +221,28 @@ [self awaitExpectations]; } +- (NSDictionary *)testDataWithTimestamp:(FIRTimestamp *)timestamp { + return @{ + @"timestamp" : [timestamp approximateDateValue], + @"metadata" : @{@"nestedTimestamp" : [timestamp approximateDateValue]} + }; +} + +// This test should break once the default for how timestamps are returned changes. +- (void)testThatDataContainsNativeDateType { + NSDate *date = [NSDate date]; + FIRTimestamp *timestamp = [FIRTimestamp timestampWithDate:date]; + FIRDocumentReference *doc = [self documentRef]; + [self writeDocumentRef:doc data:[self testDataWithTimestamp:timestamp]]; + + FIRDocumentSnapshot *result = [self readDocumentForRef:doc]; + NSDate *resultDate = result.data[@"timestamp"]; + XCTAssertEqualWithAccuracy([resultDate timeIntervalSince1970], [date timeIntervalSince1970], + 0.000001); + XCTAssertEqualObjects(result.data[@"timestamp"], resultDate); + NSDate *resultNestedDate = result[@"metadata.nestedTimestamp"]; + XCTAssertEqualWithAccuracy([resultNestedDate timeIntervalSince1970], [date timeIntervalSince1970], + 0.000001); +} + @end -- cgit v1.2.3