mirror of
https://github.com/nodejs/node.git
synced 2025-08-15 13:48:44 +02:00
lib: tweak use of internal/errors
In addition refactor common.throws to common.expectsError PR-URL: https://github.com/nodejs/node/pull/13829 Refs: https://github.com/nodejs/node/issues/11273 Reviewed-By: Refael Ackermann <refack@gmail.com> Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
This commit is contained in:
parent
8979b4fc9f
commit
095357e26e
6 changed files with 49 additions and 53 deletions
|
@ -1,17 +1,11 @@
|
|||
'use strict';
|
||||
|
||||
const common = require('../common');
|
||||
const assert = require('assert');
|
||||
const fs = require('fs');
|
||||
|
||||
const encoding = 'foo-8';
|
||||
const filename = 'bar.txt';
|
||||
const expectedError = common.expectsError({
|
||||
code: 'ERR_INVALID_OPT_VALUE_ENCODING',
|
||||
type: TypeError,
|
||||
});
|
||||
|
||||
assert.throws(
|
||||
common.expectsError(
|
||||
fs.readFile.bind(fs, filename, { encoding }, common.mustNotCall()),
|
||||
expectedError
|
||||
{ code: 'ERR_INVALID_OPT_VALUE_ENCODING', type: TypeError }
|
||||
);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue