diff options
author | Konstantin Varlamov <var-const@users.noreply.github.com> | 2018-02-20 17:33:57 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-02-20 17:33:57 -0500 |
commit | 14ea068f5fd03a658017f8472a4078a727fabc3a (patch) | |
tree | 56696c49546e2147ec1b8ebdeba24dd292f0c951 /Firestore/Example/Tests/Integration/API | |
parent | de00de25deebc35c4c7167135d5b1f29a7d9fe6f (diff) |
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).
Diffstat (limited to 'Firestore/Example/Tests/Integration/API')
-rw-r--r-- | Firestore/Example/Tests/Integration/API/FIRFieldsTests.mm | 25 |
1 files changed, 25 insertions, 0 deletions
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 <FirebaseFirestore/FIRTimestamp.h> #import <FirebaseFirestore/FirebaseFirestore.h> #import <XCTest/XCTest.h> @@ -220,4 +221,28 @@ [self awaitExpectations]; } +- (NSDictionary<NSString *, id> *)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 |