File tree Expand file tree Collapse file tree 1 file changed +14
-0
lines changed Expand file tree Collapse file tree 1 file changed +14
-0
lines changed Original file line number Diff line number Diff line change @@ -49,6 +49,20 @@ describe('serialize()', () => {
49
49
) ;
50
50
} ) ;
51
51
52
+ it ( 'does permit objects with a _bsontype prop that is not a string' , ( ) => {
53
+ const expected = bufferFromHexArray ( [
54
+ '10' , // int32
55
+ Buffer . from ( '_bsontype\x00' , 'utf8' ) . toString ( 'hex' ) ,
56
+ '02000000'
57
+ ] ) ;
58
+ const result = BSON . serialize ( { _bsontype : 2 } ) ;
59
+ expect ( result ) . to . deep . equal ( expected ) ;
60
+
61
+ expect ( ( ) => BSON . serialize ( { _bsontype : true } ) ) . to . not . throw ( ) ;
62
+ expect ( ( ) => BSON . serialize ( { _bsontype : / a / } ) ) . to . not . throw ( ) ;
63
+ expect ( ( ) => BSON . serialize ( { _bsontype : new Date ( ) } ) ) . to . not . throw ( ) ;
64
+ } ) ;
65
+
52
66
it ( 'does not permit non-objects as the root input' , ( ) => {
53
67
// @ts -expect-error: Testing invalid input
54
68
expect ( ( ) => BSON . serialize ( true ) ) . to . throw ( / d o e s n o t s u p p o r t n o n - o b j e c t / ) ;
You can’t perform that action at this time.
0 commit comments