@@ -25,23 +25,25 @@ describe('calculateSize()', () => {
25
25
) . to . throw ( BSONVersionError , / U n s u p p o r t e d B S O N v e r s i o n / i) ;
26
26
} ) ;
27
27
28
- describe ( 'bigint' , function ( ) {
28
+ describe ( 'when given a bigint value with a single character key ' , function ( ) {
29
29
beforeEach ( function ( ) {
30
30
if ( BSON . __noBigInt__ ) {
31
31
this . currentTest ?. skip ( ) ;
32
32
}
33
33
} ) ;
34
34
35
- it ( 'returns 8 bytes (+8 meta bytes) size for a bigint value ' , function ( ) {
35
+ it ( 'returns 8 bytes (+4 bytes for document size + 1 type byte + 1 byte for "a" + 2 null terminators) ' , function ( ) {
36
36
const doc = { a : BigInt ( 1 ) } ;
37
- expect ( BSON . calculateObjectSize ( doc ) ) . to . equal ( 16 ) ;
37
+ expect ( BSON . calculateObjectSize ( doc ) ) . to . equal ( 8 + 4 + 1 + 1 + 1 + 1 ) ;
38
38
expect ( BSON . calculateObjectSize ( doc ) ) . to . equal ( BSON . serialize ( doc ) . byteLength ) ;
39
39
} ) ;
40
40
} ) ;
41
41
42
- it ( 'returns 0 bytes (+5 meta bytes) for a symbol value' , function ( ) {
43
- const doc = { a : Symbol ( ) } ;
44
- expect ( BSON . calculateObjectSize ( doc ) ) . to . equal ( 5 ) ;
45
- expect ( BSON . calculateObjectSize ( doc ) ) . to . equal ( BSON . serialize ( doc ) . byteLength ) ;
42
+ describe ( 'when given a symbol value with a single character key' , function ( ) {
43
+ it ( 'returns 0 bytes (+4 bytes for document size + 1 null terminator)' , function ( ) {
44
+ const doc = { a : Symbol ( ) } ;
45
+ expect ( BSON . calculateObjectSize ( doc ) ) . to . equal ( 4 + 1 ) ;
46
+ expect ( BSON . calculateObjectSize ( doc ) ) . to . equal ( BSON . serialize ( doc ) . byteLength ) ;
47
+ } ) ;
46
48
} ) ;
47
49
} ) ;
0 commit comments