@@ -14,7 +14,7 @@ const assert = require('assert');
14
14
const tmpDir = tmpdir . path ;
15
15
16
16
async function read ( fileHandle , buffer , offset , length , position , options ) {
17
- return options . useConf ?
17
+ return options ? .useConf ?
18
18
fileHandle . read ( { buffer, offset, length, position } ) :
19
19
fileHandle . read ( buffer , offset , length , position ) ;
20
20
}
@@ -96,6 +96,21 @@ async function validateReadLength(len) {
96
96
assert . strictEqual ( bytesRead , len ) ;
97
97
}
98
98
99
+ async function validateReadWithNoOptions ( byte ) {
100
+ const buf = Buffer . alloc ( byte ) ;
101
+ const filePath = fixtures . path ( 'x.txt' ) ;
102
+ const fileHandle = await open ( filePath , 'r' ) ;
103
+ let response = await fileHandle . read ( buf ) ;
104
+ assert . strictEqual ( response . bytesRead , byte ) ;
105
+ response = await read ( fileHandle , buf , 0 , undefined , 0 ) ;
106
+ assert . strictEqual ( response . bytesRead , byte ) ;
107
+ response = await read ( fileHandle , buf , 0 , null , 0 ) ;
108
+ assert . strictEqual ( response . bytesRead , byte ) ;
109
+ response = await read ( fileHandle , buf , 0 , undefined , 0 , { useConf : true } ) ;
110
+ assert . strictEqual ( response . bytesRead , byte ) ;
111
+ response = await read ( fileHandle , buf , 0 , null , 0 , { useConf : true } ) ;
112
+ assert . strictEqual ( response . bytesRead , byte ) ;
113
+ }
99
114
100
115
( async function ( ) {
101
116
tmpdir . refresh ( ) ;
@@ -109,4 +124,6 @@ async function validateReadLength(len) {
109
124
await validateReadWithPositionZero ( ) ;
110
125
await validateReadLength ( 0 ) ;
111
126
await validateReadLength ( 1 ) ;
127
+ await validateReadWithNoOptions ( 0 ) ;
128
+ await validateReadWithNoOptions ( 1 ) ;
112
129
} ) ( ) . then ( common . mustCall ( ) ) ;
0 commit comments