@@ -108,40 +108,29 @@ const parseErrorForRootDocument = scenario => {
108
108
}
109
109
} ;
110
110
111
- const skipBSON = {
112
- 'NaN with payload' :
113
- 'passing this would require building a custom type to store the NaN payload data.'
114
- } ;
115
- // tests from the corpus that we need to skip, and explanations why
116
- const skipExtendedJSON = {
117
- 'Timestamp with high-order bit set on both seconds and increment' :
118
- 'Current BSON implementation of timestamp/long cannot hold these values - 1 too large.' ,
119
- 'Timestamp with high-order bit set on both seconds and increment (not UINT32_MAX)' :
120
- 'Current BSON implementation of timestamp/long cannot hold these values - 1 too large.'
121
- } ;
122
-
123
- const SKIP_TESTS = new Map ( [
124
- ...Object . entries ( skipBSON ) ,
125
- ...Object . entries ( skipExtendedJSON ) ,
126
- [
127
- 'All BSON types' ,
128
- 'there is just too much variation in the specified expectation to make this work'
129
- ]
130
- ] ) ;
131
-
132
111
const corpus = require ( './tools/bson_corpus_test_loader' ) ;
133
112
describe ( 'BSON Corpus' , function ( ) {
134
113
for ( const scenario of corpus ) {
135
114
const deprecated = scenario . deprecated ;
136
115
const description = scenario . description ;
137
- const valid = scenario . valid || [ ] ;
116
+ const scenarioName = `${ description } (${ scenario . _filename } )` ;
117
+ const valid = scenario . valid ;
138
118
139
- describe ( description , function ( ) {
119
+ describe ( scenarioName , function ( ) {
140
120
if ( valid ) {
141
121
describe ( 'valid-bson' , function ( ) {
142
122
for ( const v of valid ) {
143
123
it ( v . description , function ( ) {
144
- if ( SKIP_TESTS . has ( v . description ) ) {
124
+ if ( v . description === 'NaN with payload' ) {
125
+ // TODO(NODE-3630): remove custom float parser so we can handle the NaN payload data
126
+ this . skip ( ) ;
127
+ }
128
+
129
+ if (
130
+ v . description === 'All BSON types' &&
131
+ scenario . _filename === 'multi-type-deprecated'
132
+ ) {
133
+ // TODO(NODE-3987): fix multi-type-deprecated test
145
134
this . skip ( ) ;
146
135
}
147
136
@@ -181,9 +170,6 @@ describe('BSON Corpus', function () {
181
170
describe ( 'valid-extjson' , function ( ) {
182
171
for ( const v of valid ) {
183
172
it ( v . description , function ( ) {
184
- if ( SKIP_TESTS . has ( v . description ) ) {
185
- this . skip ( ) ;
186
- }
187
173
// read in test case data. if this scenario is for a deprecated
188
174
// type, we want to use the "converted" BSON and EJSON, which
189
175
// use the upgraded version of the deprecated type. otherwise,
@@ -230,6 +216,7 @@ describe('BSON Corpus', function () {
230
216
expect ( nativeToREJSON ( nativeFromCB ) ) . to . equal ( rEJ ) ;
231
217
232
218
// relaxed EJSON -> native -> relaxed EJSON unchanged
219
+ // TODO(NODE-3396): jsonToNative doesn't correctly parse the relaxed form
233
220
expect ( nativeToREJSON ( jsonToNative ( rEJ ) ) ) . to . equal ( rEJ ) ;
234
221
}
235
222
} ) ;
@@ -242,7 +229,7 @@ describe('BSON Corpus', function () {
242
229
for ( const d of scenario . decodeErrors ) {
243
230
it ( d . description , function ( ) {
244
231
const B = Buffer . from ( d . bson , 'hex' ) ;
245
- expect ( ( ) => BSON . deserialize ( B , deserializeOptions ) ) . to . throw ( ) ;
232
+ expect ( ( ) => BSON . deserialize ( B , deserializeOptions ) ) . to . throw ( BSONError ) ;
246
233
} ) ;
247
234
}
248
235
} ) ;
0 commit comments