Skip to content

Commit

Permalink
test: adding mustCall in test-fs-readfile-empty.js
Browse files Browse the repository at this point in the history
PR-URL: #27455
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: Rich Trott <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Ouyang Yadong <[email protected]>
  • Loading branch information
chenjian-bzh authored and targos committed Apr 30, 2019
1 parent 457549b commit e89b6fe
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions test/parallel/test-fs-readfile-empty.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,27 +20,26 @@
// USE OR OTHER DEALINGS IN THE SOFTWARE.

'use strict';
require('../common');

// Trivial test of fs.readFile on an empty file.

const assert = require('assert');
const common = require('../common');
const fs = require('fs');
const assert = require('assert');
const fixtures = require('../common/fixtures');

const fn = fixtures.path('empty.txt');

fs.readFile(fn, function(err, data) {
fs.readFile(fn, common.mustCall((err, data) => {
assert.ok(data);
});
}));

fs.readFile(fn, 'utf8', function(err, data) {
fs.readFile(fn, 'utf8', common.mustCall((err, data) => {
assert.strictEqual(data, '');
});
}));

fs.readFile(fn, { encoding: 'utf8' }, function(err, data) {
fs.readFile(fn, { encoding: 'utf8' }, common.mustCall((err, data) => {
assert.strictEqual(data, '');
});
}));

assert.ok(fs.readFileSync(fn));
assert.strictEqual(fs.readFileSync(fn, 'utf8'), '');

0 comments on commit e89b6fe

Please sign in to comment.