MCPcopy Index your code
hub / github.com/nodejs/node / testValid

Function testValid

test/parallel/test-fs-read-optional-params.js:13–29  ·  view source on GitHub ↗
(message, ...options)

Source from the content-addressed store, hash-verified

11const bufferAsOption = Buffer.allocUnsafe(expected.byteLength);
12
13function testValid(message, ...options) {
14 const paramsMsg = `${message} (as params)`;
15 const paramsFilehandle = fs.openSync(filepath, 'r');
16 fs.read(paramsFilehandle, ...options, common.mustSucceed((bytesRead, buffer) => {
17 assert.strictEqual(bytesRead, expected.byteLength, paramsMsg);
18 assert.deepStrictEqual(defaultBufferAsync.byteLength, buffer.byteLength, paramsMsg);
19 fs.closeSync(paramsFilehandle);
20 }));
21
22 const optionsMsg = `${message} (as options)`;
23 const optionsFilehandle = fs.openSync(filepath, 'r');
24 fs.read(optionsFilehandle, bufferAsOption, ...options, common.mustSucceed((bytesRead, buffer) => {
25 assert.strictEqual(bytesRead, expected.byteLength, optionsMsg);
26 assert.deepStrictEqual(bufferAsOption.byteLength, buffer.byteLength, optionsMsg);
27 fs.closeSync(optionsFilehandle);
28 }));
29}
30
31testValid('Not passing in any object');
32testValid('Passing in a null', null);

Callers 2

runTestsFunction · 0.70

Calls 3

openSyncMethod · 0.45
readMethod · 0.45
closeSyncMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…