Skip to content

Commit 4ef0025

Browse files
MErge
1 parent 41a4ba3 commit 4ef0025

File tree

1 file changed

+29
-39
lines changed

1 file changed

+29
-39
lines changed

packages/firestore/test/unit/model/values.test.ts

Lines changed: 29 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -29,17 +29,16 @@ import {
2929
estimateByteSize
3030
} from '../../../src/model/values';
3131
import { DocumentKey } from '../../../src/model/document_key';
32-
import { PrimitiveValue } from '../../../src/model/proto_field_value';
3332
import { primitiveComparator } from '../../../src/util/misc';
3433
import {
3534
blob,
3635
dbId,
3736
expectCorrectComparisonGroups,
3837
expectEqualitySets,
3938
key,
40-
ref
39+
ref, wrap
4140
} from '../../util/helpers';
42-
import { valueOf } from '../../util/values';
41+
import {serverTimestamp} from "../../../src/model/server_timestamps";
4342

4443
describe('Values', () => {
4544
const date1 = new Date(2016, 4, 2, 1, 5);
@@ -69,13 +68,12 @@ describe('Values', () => {
6968
[wrap('\u00e9a')],
7069
[wrap(date1), wrap(Timestamp.fromDate(date1))],
7170
[wrap(date2)],
72-
// TODO(mrschmidt): Support ServerTimestamps
73-
// [
74-
// // NOTE: ServerTimestampValues can't be parsed via wrap().
75-
// serverTimestamp(Timestamp.fromDate(date1), null),
76-
// serverTimestamp(Timestamp.fromDate(date1), null)
77-
// ],
78-
// [serverTimestamp(Timestamp.fromDate(date2), null)],
71+
[
72+
// NOTE: ServerTimestampValues can't be parsed via wrap().
73+
serverTimestamp(Timestamp.fromDate(date1), null),
74+
serverTimestamp(Timestamp.fromDate(date1), null)
75+
],
76+
[serverTimestamp(Timestamp.fromDate(date2), null)],
7977
[wrap(new GeoPoint(0, 1)), wrap(new GeoPoint(0, 1))],
8078
[wrap(new GeoPoint(1, 0))],
8179
[wrap(ref('project', 'coll/doc1')), wrap(ref('project', 'coll/doc1'))],
@@ -152,10 +150,9 @@ describe('Values', () => {
152150
[wrap(date1)],
153151
[wrap(date2)],
154152

155-
// TODO(mrschmidt): Support ServerTimestamps
156-
// // server timestamps come after all concrete timestamps.
157-
// [serverTimestamp(Timestamp.fromDate(date1), null)],
158-
// [serverTimestamp(Timestamp.fromDate(date2), null)],
153+
// server timestamps come after all concrete timestamps.
154+
[serverTimestamp(Timestamp.fromDate(date1), null)],
155+
[serverTimestamp(Timestamp.fromDate(date2), null)],
159156

160157
// strings
161158
[wrap('')],
@@ -285,21 +282,20 @@ describe('Values', () => {
285282
expectedByteSize: 16,
286283
elements: [wrap(Timestamp.fromMillis(100)), wrap(Timestamp.now())]
287284
},
288-
// TODO(mrschmidt): Support ServerTimestamps
289-
// {
290-
// expectedByteSize: 16,
291-
// elements: [
292-
// serverTimestamp(Timestamp.fromMillis(100), null),
293-
// serverTimestamp(Timestamp.now(), null)
294-
// ]
295-
// },
296-
// {
297-
// expectedByteSize: 20,
298-
// elements: [
299-
// serverTimestamp(Timestamp.fromMillis(100), wrap(true)),
300-
// serverTimestamp(Timestamp.now(), wrap(false))
301-
// ]
302-
// },
285+
{
286+
expectedByteSize: 16,
287+
elements: [
288+
serverTimestamp(Timestamp.fromMillis(100), null),
289+
serverTimestamp(Timestamp.now(), null)
290+
]
291+
},
292+
{
293+
expectedByteSize: 20,
294+
elements: [
295+
serverTimestamp(Timestamp.fromMillis(100), wrap(true)),
296+
serverTimestamp(Timestamp.now(), wrap(false))
297+
]
298+
},
303299
{
304300
expectedByteSize: 42,
305301
elements: [
@@ -327,11 +323,10 @@ describe('Values', () => {
327323
// as the size of the underlying data grows.
328324
const relativeGroups: api.Value[][] = [
329325
[wrap(blob(0)), wrap(blob(0, 1))],
330-
// TODO(mrschmidt): Support ServerTimestamps
331-
// [
332-
// serverTimestamp(Timestamp.fromMillis(100), null),
333-
// serverTimestamp(Timestamp.now(), wrap(null))
334-
// ],
326+
[
327+
serverTimestamp(Timestamp.fromMillis(100), null),
328+
serverTimestamp(Timestamp.now(), wrap(null))
329+
],
335330
[
336331
refValue(dbId('p1', 'd1'), key('c1/doc1')),
337332
refValue(dbId('p1', 'd1'), key('c1/doc1/c2/doc2'))
@@ -407,11 +402,6 @@ describe('Values', () => {
407402
});
408403
});
409404

410-
// TODO(mrschmidt): Clean up the helpers and merge wrap() with TestUtil.wrap()
411-
function wrap(value: unknown): api.Value {
412-
return new PrimitiveValue(valueOf(value)).proto;
413-
}
414-
415405
/** Creates a referenceValue Proto for `databaseId` and `key`. */
416406
export function refValue(databaseId: DatabaseId, key: DocumentKey): api.Value {
417407
return {

0 commit comments

Comments
 (0)