From e89b6fee3a7c4fd34dd6d656e1936f41b0a40475 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=88=E5=81=A5?= Date: Sun, 28 Apr 2019 16:46:28 +0800 Subject: [PATCH] test: adding mustCall in test-fs-readfile-empty.js PR-URL: https://github.com/nodejs/node/pull/27455 Reviewed-By: Colin Ihrig Reviewed-By: Rich Trott Reviewed-By: James M Snell Reviewed-By: Ouyang Yadong --- test/parallel/test-fs-readfile-empty.js | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/test/parallel/test-fs-readfile-empty.js b/test/parallel/test-fs-readfile-empty.js index 7bb942fc2d6fe3..f6303777b29384 100644 --- a/test/parallel/test-fs-readfile-empty.js +++ b/test/parallel/test-fs-readfile-empty.js @@ -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'), '');