File tree Expand file tree Collapse file tree 2 files changed +6
-4
lines changed Expand file tree Collapse file tree 2 files changed +6
-4
lines changed Original file line number Diff line number Diff line change @@ -112,7 +112,7 @@ export interface Document {
112
112
const MAXSIZE = 1024 * 1024 * 17 ;
113
113
114
114
// Current Internal Temporary Serialization Buffer
115
- let buffer = Buffer . allocUnsafe ( MAXSIZE ) ;
115
+ let buffer = Buffer . alloc ( MAXSIZE ) ;
116
116
117
117
/**
118
118
* Sets the size of the internal serialization buffer.
Original file line number Diff line number Diff line change 1
1
'use strict' ;
2
2
3
- // const { BSONTypeError } = require('../register-bson');
4
3
const BSON = require ( '../register-bson' ) ;
5
4
const Decimal128 = BSON . Decimal128 ;
6
5
@@ -1219,14 +1218,17 @@ describe('Decimal128', function () {
1219
1218
expect ( new Decimal128 ( '-1e400' ) . toString ( ) ) . to . equal ( '-1E+400' ) ;
1220
1219
} ) ;
1221
1220
1222
- it ( 'throws appropriate error for invalid constructor arguments' , ( ) => {
1223
- const byteLengthErrMsg = 'Decimal128 must take a Buffer of 16 bytes' ;
1221
+ it ( 'throws correct error for invalid constructor argument type' , ( ) => {
1224
1222
const constructorArgErrMsg = 'Decimal128 must take a Buffer or string' ;
1225
1223
1226
1224
expect ( ( ) => new Decimal128 ( - 0 ) ) . to . throw ( constructorArgErrMsg ) ;
1227
1225
expect ( ( ) => new Decimal128 ( - 1 ) ) . to . throw ( constructorArgErrMsg ) ;
1228
1226
expect ( ( ) => new Decimal128 ( 10 ) ) . to . throw ( constructorArgErrMsg ) ;
1229
1227
expect ( ( ) => new Decimal128 ( 1111111111111111 ) ) . to . throw ( constructorArgErrMsg ) ;
1228
+ } ) ;
1229
+
1230
+ it ( 'throws correct error for an invalid Buffer constructor argument' , ( ) => {
1231
+ const byteLengthErrMsg = 'Decimal128 must take a Buffer of 16 bytes' ;
1230
1232
1231
1233
expect ( ( ) => new Decimal128 ( new Uint8Array ( 0 ) ) ) . to . throw ( byteLengthErrMsg ) ;
1232
1234
expect ( ( ) => new Decimal128 ( Buffer . alloc ( 0 ) ) ) . to . throw ( byteLengthErrMsg ) ;
You can’t perform that action at this time.
0 commit comments