node/test/parallel/test-fs-open.js
Adrian Estrada 15c71f6c66 test: improve code in test-fs-open.js
* use const and let instead of var
* use assert.strictEqual instead of assert.equal
* use assert.strictEqual instead of assert.ok
* use assert.ifError

PR-URL: https://github.com/nodejs/node/pull/10312
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Italo A. Casas <me@italoacasas.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
2016-12-19 20:03:17 -05:00

25 lines
579 B
JavaScript

'use strict';
const common = require('../common');
const assert = require('assert');
const fs = require('fs');
let caughtException = false;
try {
// should throw ENOENT, not EBADF
// see https://github.com/joyent/node/pull/1228
fs.openSync('/path/to/file/that/does/not/exist', 'r');
} catch (e) {
assert.strictEqual(e.code, 'ENOENT');
caughtException = true;
}
assert.strictEqual(caughtException, true);
fs.open(__filename, 'r', common.mustCall((err) => {
assert.ifError(err);
}));
fs.open(__filename, 'rs', common.mustCall((err) => {
assert.ifError(err);
}));