@@ -331,7 +331,6 @@ describe('Extended JSON', function() {
331
331
it . skip ( 'skipping 4.x/1.x interop tests' , ( ) => { } ) ;
332
332
} else {
333
333
it ( 'should interoperate 4.x with 1.x versions of this library' , function ( ) {
334
-
335
334
const buffer = Buffer . alloc ( 64 ) ;
336
335
for ( var i = 0 ; i < buffer . length ; i ++ ) {
337
336
buffer [ i ] = i ;
@@ -363,10 +362,11 @@ describe('Extended JSON', function() {
363
362
oldObjectOldSerializer : OldBSON . serialize ( oldBsonObject , serializationOptions ) ,
364
363
oldObjectNewSerializer : BSON . serialize ( oldBsonObject , serializationOptions ) ,
365
364
newObjectOldSerializer : OldBSON . serialize ( newBsonObject , serializationOptions ) ,
366
- newObjectNewSerializer : BSON . serialize ( newBsonObject , serializationOptions ) ,
365
+ newObjectNewSerializer : BSON . serialize ( newBsonObject , serializationOptions )
367
366
} ;
368
367
369
- const expectedBufferBase64 = 'VgEAAAViaW5hcnkAQAAAAAAAAQIDBAUGBwgJCgsMDQ4PEBESExQVFhcYGRobHB0eHyAhIiMkJSYnKCkqKywtLi8wMTIzNDU2Nzg5Ojs8PT4/DWNvZGUADgAAAGZ1bmN0aW9uKCkge30AA2RiUmVmACwAAAACJHJlZgAGAAAAdGVzdHMAECRpZAABAAAAAiRkYgAFAAAAdGVzdAAAE2RlY2ltYWwxMjgA//837RjxE6AdAgAAAABAMAFkb3VibGUAMzMzMzMzJEAQaW50MzIACgAAABJsb25nAP//38RiSvoQf21heEtleQAHb2JqZWN0SWQAERERERERERERERERB29iamVjdElEABEREREREREREREREQtic29uUmVnRXhwAGhlbGxvIHdvcmxkAGkADnN5bWJvbAAHAAAAc3ltYm9sABF0aW1lc3RhbXAAAAAAAAAAAAAA' ;
368
+ const expectedBufferBase64 =
369
+ 'VgEAAAViaW5hcnkAQAAAAAAAAQIDBAUGBwgJCgsMDQ4PEBESExQVFhcYGRobHB0eHyAhIiMkJSYnKCkqKywtLi8wMTIzNDU2Nzg5Ojs8PT4/DWNvZGUADgAAAGZ1bmN0aW9uKCkge30AA2RiUmVmACwAAAACJHJlZgAGAAAAdGVzdHMAECRpZAABAAAAAiRkYgAFAAAAdGVzdAAAE2RlY2ltYWwxMjgA//837RjxE6AdAgAAAABAMAFkb3VibGUAMzMzMzMzJEAQaW50MzIACgAAABJsb25nAP//38RiSvoQf21heEtleQAHb2JqZWN0SWQAERERERERERERERERB29iamVjdElEABEREREREREREREREQtic29uUmVnRXhwAGhlbGxvIHdvcmxkAGkADnN5bWJvbAAHAAAAc3ltYm9sABF0aW1lc3RhbXAAAAAAAAAAAAAA' ;
370
370
const expectedBuffer = Buffer . from ( expectedBufferBase64 , 'base64' ) ;
371
371
372
372
// Regardless of which library version created the objects, and which library version
@@ -383,20 +383,28 @@ describe('Extended JSON', function() {
383
383
const deserializationOptions = { promoteValues : false } ;
384
384
const deserialized = {
385
385
usingOldDeserializer : OldBSON . deserialize ( expectedBuffer , deserializationOptions ) ,
386
- usingNewDeserializer : BSON . deserialize ( expectedBuffer , deserializationOptions ) ,
386
+ usingNewDeserializer : BSON . deserialize ( expectedBuffer , deserializationOptions )
387
387
} ;
388
388
// Apparently the Symbol BSON type was deprecated in V4. Symbols in BSON are deserialized as strings in V4
389
389
// Therefore, for this type we know there will be a difference between the V1 library and the V4 library,
390
390
// so remove Symbol from the list of BSON types that are being compared.
391
391
// Browser tests currently don't handle BSON Symbol correctly, so only test this under Node where OldBSON !=== BSON module.
392
392
if ( BSON !== OldBSON ) {
393
- expect ( deserialized . usingOldDeserializer [ 'symbol' ] . value ) . to . equal ( deserialized . usingNewDeserializer [ 'symbol' ] ) ;
393
+ expect ( deserialized . usingOldDeserializer [ 'symbol' ] . value ) . to . equal (
394
+ deserialized . usingNewDeserializer [ 'symbol' ]
395
+ ) ;
394
396
}
395
397
delete deserialized . usingOldDeserializer [ 'symbol' ] ;
396
398
delete deserialized . usingNewDeserializer [ 'symbol' ] ;
397
399
398
400
const ejsonExpected = {
399
- binary : { $binary : { base64 : 'AAECAwQFBgcICQoLDA0ODxAREhMUFRYXGBkaGxwdHh8gISIjJCUmJygpKissLS4vMDEyMzQ1Njc4OTo7PD0+Pw==' , subType : '00' } } ,
401
+ binary : {
402
+ $binary : {
403
+ base64 :
404
+ 'AAECAwQFBgcICQoLDA0ODxAREhMUFRYXGBkaGxwdHh8gISIjJCUmJygpKissLS4vMDEyMzQ1Njc4OTo7PD0+Pw==' ,
405
+ subType : '00'
406
+ }
407
+ } ,
400
408
code : { $code : 'function() {}' } ,
401
409
dbRef : { $ref : 'tests' , $id : { $numberInt : '1' } , $db : 'test' } ,
402
410
decimal128 : { $numberDecimal : '9991223372036854775807' } ,
@@ -412,9 +420,15 @@ describe('Extended JSON', function() {
412
420
timestamp : { $timestamp : { t : 0 , i : 0 } }
413
421
} ;
414
422
const ejsonSerializationOptions = { relaxed : false } ;
415
- const resultOld = EJSON . serialize ( deserialized . usingOldDeserializer , ejsonSerializationOptions ) ;
423
+ const resultOld = EJSON . serialize (
424
+ deserialized . usingOldDeserializer ,
425
+ ejsonSerializationOptions
426
+ ) ;
416
427
expect ( resultOld ) . to . deep . equal ( ejsonExpected ) ;
417
- const resultNew = EJSON . serialize ( deserialized . usingNewDeserializer , ejsonSerializationOptions ) ;
428
+ const resultNew = EJSON . serialize (
429
+ deserialized . usingNewDeserializer ,
430
+ ejsonSerializationOptions
431
+ ) ;
418
432
expect ( resultNew ) . to . deep . equal ( ejsonExpected ) ;
419
433
} ) ;
420
434
@@ -444,7 +458,7 @@ describe('Extended JSON', function() {
444
458
oldObjectOldSerializer : OldBSON . serialize ( oldMinKey , serializationOptions ) ,
445
459
oldObjectNewSerializer : BSON . serialize ( oldMinKey , serializationOptions ) ,
446
460
newObjectOldSerializer : OldBSON . serialize ( newMinKey , serializationOptions ) ,
447
- newObjectNewSerializer : BSON . serialize ( newMinKey , serializationOptions ) ,
461
+ newObjectNewSerializer : BSON . serialize ( newMinKey , serializationOptions )
448
462
} ;
449
463
450
464
expect ( expectedBufferMinKey ) . to . deep . equal ( bsonBuffersMinKey . newObjectNewSerializer ) ;
@@ -453,17 +467,23 @@ describe('Extended JSON', function() {
453
467
expect ( expectedBufferMinKey ) . to . deep . equal ( bsonBuffersMinKey . oldObjectOldSerializer ) ;
454
468
455
469
const ejsonExpected = {
456
- minKey : { $minKey : 1 } ,
470
+ minKey : { $minKey : 1 }
457
471
} ;
458
472
459
473
const deserialized = {
460
474
usingOldDeserializer : OldBSON . deserialize ( expectedBufferMinKey , deserializationOptions ) ,
461
- usingNewDeserializer : BSON . deserialize ( expectedBufferMinKey , deserializationOptions ) ,
475
+ usingNewDeserializer : BSON . deserialize ( expectedBufferMinKey , deserializationOptions )
462
476
} ;
463
477
const ejsonSerializationOptions = { relaxed : false } ;
464
- const resultOld = EJSON . serialize ( deserialized . usingOldDeserializer , ejsonSerializationOptions ) ;
478
+ const resultOld = EJSON . serialize (
479
+ deserialized . usingOldDeserializer ,
480
+ ejsonSerializationOptions
481
+ ) ;
465
482
expect ( resultOld ) . to . deep . equal ( ejsonExpected ) ;
466
- const resultNew = EJSON . serialize ( deserialized . usingNewDeserializer , ejsonSerializationOptions ) ;
483
+ const resultNew = EJSON . serialize (
484
+ deserialized . usingNewDeserializer ,
485
+ ejsonSerializationOptions
486
+ ) ;
467
487
expect ( resultNew ) . to . deep . equal ( ejsonExpected ) ;
468
488
} ) ;
469
489
}
0 commit comments