node/test/parallel/test-fs-makeStatsCallback.js
Ruben Bridgewater e9f2cecf1a
Revert "fs: Revert throw on invalid callbacks"
This reverts commit 8250bfd1e5.

PR-URL: https://github.com/nodejs/node/pull/18668
Refs: https://github.com/nodejs/node/pull/12562
Refs: https://github.com/nodejs/node/pull/12976
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Reviewed-By: Gus Caplan <me@gus.host>
2018-02-26 23:18:12 +00:00

26 lines
663 B
JavaScript

'use strict';
const common = require('../common');
const fs = require('fs');
const callbackThrowValues = [null, true, false, 0, 1, 'foo', /foo/, [], {}];
function testMakeStatsCallback(cb) {
return function() {
// fs.stat() calls makeStatsCallback() on its second argument
fs.stat(__filename, cb);
};
}
// Verify the case where a callback function is provided
testMakeStatsCallback(common.mustCall())();
function invalidCallbackThrowsTests() {
callbackThrowValues.forEach((value) => {
common.expectsError(testMakeStatsCallback(value), {
code: 'ERR_INVALID_CALLBACK',
type: TypeError
});
});
}
invalidCallbackThrowsTests();