Skip to content

Commit

Permalink
test: apply fs.chown() test to fsPromises.chown()
Browse files Browse the repository at this point in the history
Make test-fs-chown-type-check test both fs.chown() and
fsPromises.chown().
  • Loading branch information
Trott committed May 8, 2018
1 parent 5f1b840 commit 63f3ff6
Showing 1 changed file with 18 additions and 19 deletions.
37 changes: 18 additions & 19 deletions test/parallel/test-fs-chown-type-check.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
'use strict';

const common = require('../common');

const assert = require('assert');
const fs = require('fs');

[false, 1, {}, [], null, undefined].forEach((i) => {
common.expectsError(
() => fs.chown(i, 1, 1, common.mustNotCall()),
{
code: 'ERR_INVALID_ARG_TYPE',
type: TypeError
}
);
const checkErr = (e) => {
assert.strictEqual(e.code, 'ERR_INVALID_ARG_TYPE');
assert.ok(e instanceof TypeError);
return true;
};
common.fsTest('chown', [i, 1, 1, checkErr], { throws: true });
common.expectsError(
() => fs.chownSync(i, 1, 1),
{
Expand All @@ -21,20 +22,18 @@ const fs = require('fs');
});

[false, 'test', {}, [], null, undefined].forEach((i) => {
common.expectsError(
() => fs.chown('not_a_file_that_exists', i, 1, common.mustNotCall()),
{
code: 'ERR_INVALID_ARG_TYPE',
type: TypeError
}
const checkErr = (e) => {
assert.strictEqual(e.code, 'ERR_INVALID_ARG_TYPE');
assert.ok(e instanceof TypeError);
return true;
};
common.fsTest(
'chown', ['not_a_file_that_exists', i, 1, checkErr], { throws: true }
);
common.expectsError(
() => fs.chown('not_a_file_that_exists', 1, i, common.mustNotCall()),
{
code: 'ERR_INVALID_ARG_TYPE',
type: TypeError
}
common.fsTest(
'chown', ['not_a_file_that_exists', 1, i, checkErr], { throws: true }
);

common.expectsError(
() => fs.chownSync('not_a_file_that_exists', i, 1),
{
Expand Down

0 comments on commit 63f3ff6

Please sign in to comment.