mirror of
https://github.com/nodejs/node.git
synced 2025-05-17 10:27:12 +00:00

Export a new common.noop no-operation function for general use. Allow using common.mustCall() without a fn argument to simplify test cases. Replace various non-op functions throughout tests with common.noop PR-URL: https://github.com/nodejs/node/pull/12027 Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com> Reviewed-By: Richard Lau <riclau@uk.ibm.com> Reviewed-By: Gibson Fahnestock <gibfahn@gmail.com> Reviewed-By: Teddy Katz <teddy.katz@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Franziska Hinkelmann <franziska.hinkelmann@gmail.com>
76 lines
1.7 KiB
JavaScript
76 lines
1.7 KiB
JavaScript
'use strict';
|
|
const common = require('../common');
|
|
const assert = require('assert');
|
|
const fs = require('fs');
|
|
|
|
const options = 'test';
|
|
const unknownEncodingMessage = /^Error: Unknown encoding: test$/;
|
|
|
|
assert.throws(() => {
|
|
fs.readFile('path', options, common.noop);
|
|
}, unknownEncodingMessage);
|
|
|
|
assert.throws(() => {
|
|
fs.readFileSync('path', options);
|
|
}, unknownEncodingMessage);
|
|
|
|
assert.throws(() => {
|
|
fs.readdir('path', options, common.noop);
|
|
}, unknownEncodingMessage);
|
|
|
|
assert.throws(() => {
|
|
fs.readdirSync('path', options);
|
|
}, unknownEncodingMessage);
|
|
|
|
assert.throws(() => {
|
|
fs.readlink('path', options, common.noop);
|
|
}, unknownEncodingMessage);
|
|
|
|
assert.throws(() => {
|
|
fs.readlinkSync('path', options);
|
|
}, unknownEncodingMessage);
|
|
|
|
assert.throws(() => {
|
|
fs.writeFile('path', 'data', options, common.noop);
|
|
}, unknownEncodingMessage);
|
|
|
|
assert.throws(() => {
|
|
fs.writeFileSync('path', 'data', options);
|
|
}, unknownEncodingMessage);
|
|
|
|
assert.throws(() => {
|
|
fs.appendFile('path', 'data', options, common.noop);
|
|
}, unknownEncodingMessage);
|
|
|
|
assert.throws(() => {
|
|
fs.appendFileSync('path', 'data', options);
|
|
}, unknownEncodingMessage);
|
|
|
|
assert.throws(() => {
|
|
fs.watch('path', options, common.noop);
|
|
}, unknownEncodingMessage);
|
|
|
|
assert.throws(() => {
|
|
fs.realpath('path', options, common.noop);
|
|
}, unknownEncodingMessage);
|
|
|
|
assert.throws(() => {
|
|
fs.realpathSync('path', options);
|
|
}, unknownEncodingMessage);
|
|
|
|
assert.throws(() => {
|
|
fs.mkdtemp('path', options, common.noop);
|
|
}, unknownEncodingMessage);
|
|
|
|
assert.throws(() => {
|
|
fs.mkdtempSync('path', options);
|
|
}, unknownEncodingMessage);
|
|
|
|
assert.throws(() => {
|
|
fs.ReadStream('path', options);
|
|
}, unknownEncodingMessage);
|
|
|
|
assert.throws(() => {
|
|
fs.WriteStream('path', options);
|
|
}, unknownEncodingMessage);
|