From 1eab5f0ffd8e36e3ee1efc7942d4aa60d603993c Mon Sep 17 00:00:00 2001 From: Shawn Pang Date: Tue, 16 Oct 2018 11:22:54 -0400 Subject: [PATCH] Fix#461 - Added test for fs.read when attempting to read a file that does not exist (#472) * Added test for fs.read when attempting to read a file that does not exist * Added test for fs.read when attempting to read a file that does not exist * Modified read test for non-existent file to act more similar to earlier tests * Added check in read test for error code --- tests/spec/fs.read.spec.js | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/tests/spec/fs.read.spec.js b/tests/spec/fs.read.spec.js index 4b74bde..86739e2 100644 --- a/tests/spec/fs.read.spec.js +++ b/tests/spec/fs.read.spec.js @@ -87,6 +87,21 @@ describe('fs.read', function() { }); }); }); + + it('should fail to read a file that does not exist', function(done) { + var fs = util.fs(); + + var fd = 0; + var rbuffer = new Filer.Buffer(8); + rbuffer.fill(0); + + fs.read(fd, rbuffer, 0, rbuffer.length, 0, function(error, result) { + expect(error).to.exist; + expect(result).not.to.exist; + expect(error.code).to.equal('EBADF'); + done(); + }); + }); }); describe('fs.promises.read', function() {