@@ -231,8 +231,8 @@ describe('types', () => {
231
231
describe ( 'buffer' , ( ) => {
232
232
const bufferType = new types . BufferType ( ) ;
233
233
it ( 'checks isInstance' , ( ) => {
234
- expect ( bufferType . isInstance ( new Buffer ( [ 1 ] ) ) ) . to . be . true ( ) ;
235
- expect ( bufferType . isInstance ( new Buffer ( '123' ) ) ) . to . be . true ( ) ;
234
+ expect ( bufferType . isInstance ( Buffer . from ( [ 1 ] ) ) ) . to . be . true ( ) ;
235
+ expect ( bufferType . isInstance ( Buffer . from ( '123' ) ) ) . to . be . true ( ) ;
236
236
expect ( bufferType . isInstance ( 'str' ) ) . to . be . false ( ) ;
237
237
expect ( bufferType . isInstance ( null ) ) . to . be . true ( ) ;
238
238
expect ( bufferType . isInstance ( undefined ) ) . to . be . true ( ) ;
@@ -248,7 +248,7 @@ describe('types', () => {
248
248
expect ( bufferType . isCoercible ( 'str' ) ) . to . be . true ( ) ;
249
249
expect ( bufferType . isCoercible ( null ) ) . to . be . true ( ) ;
250
250
expect ( bufferType . isCoercible ( undefined ) ) . to . be . true ( ) ;
251
- expect ( bufferType . isCoercible ( new Buffer ( '12' ) ) ) . to . be . true ( ) ;
251
+ expect ( bufferType . isCoercible ( Buffer . from ( '12' ) ) ) . to . be . true ( ) ;
252
252
expect ( bufferType . isCoercible ( [ 1 , 2 ] ) ) . to . be . true ( ) ;
253
253
expect ( bufferType . isCoercible ( { x : 1 } ) ) . to . be . false ( ) ;
254
254
expect ( bufferType . isCoercible ( 1 ) ) . to . be . false ( ) ;
@@ -260,11 +260,11 @@ describe('types', () => {
260
260
} ) ;
261
261
262
262
it ( 'coerces values' , ( ) => {
263
- expect ( bufferType . coerce ( 'str' ) . equals ( new Buffer ( 'str' ) ) ) . to . be . true ( ) ;
263
+ expect ( bufferType . coerce ( 'str' ) . equals ( Buffer . from ( 'str' ) ) ) . to . be . true ( ) ;
264
264
expect ( bufferType . coerce ( [ 1 ] ) . equals ( Buffer . from ( [ 1 ] ) ) ) . to . be . true ( ) ;
265
265
expect ( bufferType . coerce ( null ) ) . to . equal ( null ) ;
266
266
expect ( bufferType . coerce ( undefined ) ) . to . equal ( undefined ) ;
267
- const buf = new Buffer ( '12' ) ;
267
+ const buf = Buffer . from ( '12' ) ;
268
268
expect ( bufferType . coerce ( buf ) ) . exactly ( buf ) ;
269
269
expect ( ( ) => bufferType . coerce ( 1 ) ) . to . throw ( / I n v a l i d b u f f e r / ) ;
270
270
expect ( ( ) => bufferType . coerce ( new Date ( ) ) ) . to . throw ( / I n v a l i d b u f f e r / ) ;
@@ -274,9 +274,9 @@ describe('types', () => {
274
274
275
275
it ( 'serializes values' , ( ) => {
276
276
expect (
277
- bufferType . serialize ( new Buffer ( 'str' ) , { encoding : 'utf-8' } ) ,
277
+ bufferType . serialize ( Buffer . from ( 'str' ) , { encoding : 'utf-8' } ) ,
278
278
) . to . eql ( 'str' ) ;
279
- expect ( bufferType . serialize ( new Buffer ( 'str' ) ) ) . to . eql ( 'c3Ry' ) ;
279
+ expect ( bufferType . serialize ( Buffer . from ( 'str' ) ) ) . to . eql ( 'c3Ry' ) ;
280
280
expect ( bufferType . serialize ( null ) ) . null ( ) ;
281
281
expect ( bufferType . serialize ( undefined ) ) . undefined ( ) ;
282
282
} ) ;
@@ -293,7 +293,7 @@ describe('types', () => {
293
293
expect ( anyType . isInstance ( [ 1 , 2 ] ) ) . to . be . true ( ) ;
294
294
expect ( anyType . isInstance ( 1 ) ) . to . be . true ( ) ;
295
295
expect ( anyType . isInstance ( new Date ( ) ) ) . to . be . true ( ) ;
296
- expect ( anyType . isInstance ( new Buffer ( '123' ) ) ) . to . be . true ( ) ;
296
+ expect ( anyType . isInstance ( Buffer . from ( '123' ) ) ) . to . be . true ( ) ;
297
297
} ) ;
298
298
299
299
it ( 'checks isCoercible' , ( ) => {
@@ -305,7 +305,7 @@ describe('types', () => {
305
305
expect ( anyType . isCoercible ( 1 ) ) . to . be . true ( ) ;
306
306
expect ( anyType . isCoercible ( [ 1 , '2' ] ) ) . to . be . true ( ) ;
307
307
expect ( anyType . isCoercible ( new Date ( ) ) ) . to . be . true ( ) ;
308
- expect ( anyType . isCoercible ( new Buffer ( '123' ) ) ) . to . be . true ( ) ;
308
+ expect ( anyType . isCoercible ( Buffer . from ( '123' ) ) ) . to . be . true ( ) ;
309
309
} ) ;
310
310
311
311
it ( 'creates defaultValue' , ( ) => {
@@ -324,7 +324,7 @@ describe('types', () => {
324
324
expect ( anyType . coerce ( 1 ) ) . to . equal ( 1 ) ;
325
325
const date = new Date ( ) ;
326
326
expect ( anyType . coerce ( date ) ) . to . equal ( date ) ;
327
- const buf = new Buffer ( '12' ) ;
327
+ const buf = Buffer . from ( '12' ) ;
328
328
expect ( anyType . coerce ( buf ) ) . to . equal ( buf ) ;
329
329
} ) ;
330
330
0 commit comments