@@ -29,7 +29,7 @@ import {
29
29
ObjectValue ,
30
30
PrimitiveValue
31
31
} from '../../../src/model/proto_field_value' ;
32
- import { canonicalId } from '../../../src/model/proto_values' ;
32
+ import { canonicalId , estimateByteSize } from '../../../src/model/proto_values' ;
33
33
import { ByteString } from '../../../src/util/byte_string' ;
34
34
import { primitiveComparator } from '../../../src/util/misc' ;
35
35
import * as typeUtils from '../../../src/util/types' ;
@@ -630,9 +630,7 @@ describe('FieldValue', () => {
630
630
) ;
631
631
} ) ;
632
632
633
- // TODO(mrschmidt): Fix size accounting
634
- // eslint-disable-next-line no-restricted-properties
635
- it . skip ( 'estimates size correctly for fixed sized values' , ( ) => {
633
+ it ( 'estimates size correctly for fixed sized values' , ( ) => {
636
634
// This test verifies that each member of a group takes up the same amount
637
635
// of space in memory (based on its estimated in-memory size).
638
636
const equalityGroups = [
@@ -653,22 +651,23 @@ describe('FieldValue', () => {
653
651
expectedByteSize : 16 ,
654
652
elements : [ wrap ( Timestamp . fromMillis ( 100 ) ) , wrap ( Timestamp . now ( ) ) ]
655
653
} ,
654
+ // TODO(mrschmidt): Support server timestamps
655
+ // {
656
+ // expectedByteSize: 16,
657
+ // elements: [
658
+ // new ServerTimestampValue(Timestamp.fromMillis(100), null),
659
+ // new ServerTimestampValue(Timestamp.now(), null)
660
+ // ]
661
+ // },
662
+ // {
663
+ // expectedByteSize: 20,
664
+ // elements: [
665
+ // new ServerTimestampValue(Timestamp.fromMillis(100), wrap(true)),
666
+ // new ServerTimestampValue(Timestamp.now(), wrap(false))
667
+ // ]
668
+ // },
656
669
{
657
- expectedByteSize : 16 ,
658
- elements : [
659
- new ServerTimestampValue ( Timestamp . fromMillis ( 100 ) , null ) ,
660
- new ServerTimestampValue ( Timestamp . now ( ) , null )
661
- ]
662
- } ,
663
- {
664
- expectedByteSize : 20 ,
665
- elements : [
666
- new ServerTimestampValue ( Timestamp . fromMillis ( 100 ) , wrap ( true ) ) ,
667
- new ServerTimestampValue ( Timestamp . now ( ) , wrap ( false ) )
668
- ]
669
- } ,
670
- {
671
- expectedByteSize : 11 ,
670
+ expectedByteSize : 42 ,
672
671
elements : [
673
672
wrapRef ( dbId ( 'p1' , 'd1' ) , key ( 'c1/doc1' ) ) ,
674
673
wrapRef ( dbId ( 'p2' , 'd2' ) , key ( 'c2/doc2' ) )
@@ -684,7 +683,9 @@ describe('FieldValue', () => {
684
683
685
684
for ( const group of equalityGroups ) {
686
685
for ( const element of group . elements ) {
687
- expect ( element . approximateByteSize ( ) ) . to . equal ( group . expectedByteSize ) ;
686
+ expect ( estimateByteSize ( element . proto ) ) . to . equal (
687
+ group . expectedByteSize
688
+ ) ;
688
689
}
689
690
}
690
691
} ) ;
0 commit comments