From fe7d902a2c28ebe2b2be5c83ce72c5754d8f909d Mon Sep 17 00:00:00 2001 From: Julia Yatsenko Date: Wed, 19 Dec 2018 18:13:02 -0500 Subject: [PATCH] fix #635: added test for fs.ftruncate() --- tests/spec/fs.ftruncate.spec.js | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/tests/spec/fs.ftruncate.spec.js b/tests/spec/fs.ftruncate.spec.js index 9f6726d..7940561 100644 --- a/tests/spec/fs.ftruncate.spec.js +++ b/tests/spec/fs.ftruncate.spec.js @@ -10,6 +10,27 @@ describe('fs.ftruncate', function() { expect(fs.ftruncate).to.be.a('function'); }); + it('should return an error if length is not an integer', function(done) { + let fs = util.fs(); + let contents = 'This is a file.'; + + fs.writeFile('/myfile', contents, function(error) { + if(error) throw error; + + fs.open('/myfile', 'w', function(err, fd) { + + fs.ftruncate(fd, 'notAnInteger', function(error) { + expect(error).to.exist; + expect(error.code).to.equal('EINVAL'); + done(); + }); + + // Close file descriptor when done + fs.close(fd); + }); + }); + }); + it('should return an error if length is negative', function(done) { let fs = util.fs(); let contents = 'This is a file.';