@@ -70,26 +70,23 @@ const invalidUtf8InOtherKeyJSON = {
70
70
ok : 1
71
71
} ;
72
72
73
- describe . only ( 'BinMsg' , function ( ) {
73
+ describe ( 'BinMsg' , function ( ) {
74
74
it ( 'should not throw invalid utf8 error when validation disabled for writeErrors' , function ( ) {
75
- const binMsgValidWriteError = new BinMsg (
75
+ const binMsgInvalidUtf8ErrorMsg = new BinMsg (
76
76
Buffer . alloc ( 0 ) ,
77
77
msgHeader ,
78
- msgBodyInvalidUtf8WriteErrors ,
79
- {
80
- validation : { utf8 : { writeErrors : false } }
81
- }
78
+ msgBodyInvalidUtf8WriteErrors
82
79
) ;
83
80
expect ( ( ) =>
84
- binMsgValidWriteError . parse ( { validation : { utf8 : { writeErrors : false } } } )
81
+ binMsgInvalidUtf8ErrorMsg . parse ( { validation : { utf8 : { writeErrors : false } } } )
85
82
) . to . not . throw ( ) ;
86
83
expect (
87
84
BSON . deserialize ( badutf8inputtodeserialize , { validation : { utf8 : { writeErrors : false } } } )
88
85
) . to . deep . equals ( invalidUtf8InWriteErrorsJSON ) ;
89
86
} ) ;
90
87
91
- it ( 'should throw invalid utf8 error when validation not specified or enabled for writeErrors ' , function ( ) {
92
- const binMsgValidWriteError = new BinMsg (
88
+ it ( 'should by default disable validation for writeErrors if no validation specified ' , function ( ) {
89
+ const binMsgInvalidUtf8ErrorMsg = new BinMsg (
93
90
Buffer . alloc ( 0 ) ,
94
91
msgHeader ,
95
92
msgBodyInvalidUtf8WriteErrors
@@ -100,12 +97,17 @@ describe.only('BinMsg', function () {
100
97
promoteLongs : true ,
101
98
promoteValues : true
102
99
} ;
103
- expect ( ( ) => binMsgValidWriteError . parse ( options ) ) . to . throw (
104
- BSONError ,
105
- 'Invalid UTF-8 string in BSON document'
100
+ expect ( ( ) => binMsgInvalidUtf8ErrorMsg . parse ( options ) ) . to . not . throw ( ) ;
101
+ } ) ;
102
+
103
+ it ( 'should throw invalid utf8 error when validation enabled for writeErrors' , function ( ) {
104
+ const binMsgInvalidUtf8ErrorMsg = new BinMsg (
105
+ Buffer . alloc ( 0 ) ,
106
+ msgHeader ,
107
+ msgBodyInvalidUtf8WriteErrors
106
108
) ;
107
109
expect ( ( ) =>
108
- binMsgValidWriteError . parse ( { validation : { utf8 : { writeErrors : true } } } )
110
+ binMsgInvalidUtf8ErrorMsg . parse ( { validation : { utf8 : { writeErrors : true } } } )
109
111
) . to . throw ( BSONError , 'Invalid UTF-8 string in BSON document' ) ;
110
112
} ) ;
111
113
0 commit comments