diff --git a/tests/spec/fs.fsync.spec.js b/tests/spec/fs.fsync.spec.js index 6c218770..ce68f024 100644 --- a/tests/spec/fs.fsync.spec.js +++ b/tests/spec/fs.fsync.spec.js @@ -12,16 +12,18 @@ describe('fs.fsync', function() { it('should return error when fd is not a number', function(done) { var fs = util.fs(); - fs.fsync('1', function(error) { + fs.fsync('notAnInteger', function(error) { expect(error).to.exist; expect(error.code).to.equal('EINVAL'); done(); }); }); - it('should return error when fd is invalid', function(done) { - var fs = util.fs(); - fs.fsync(1, function(error) { + it('should return an error if file descriptor is negative', function(done) { + let fs = util.fs(); + + // File descriptor should be a non-negative number + fs.fsync(-1, function(error) { expect(error).to.exist; expect(error.code).to.equal('EBADF'); done(); diff --git a/tests/spec/fs.ftruncate.spec.js b/tests/spec/fs.ftruncate.spec.js index 9f6726dd..7940561f 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.';