fix #635: added test for fs.ftruncate()

This commit is contained in:
Julia Yatsenko 2018-12-19 18:13:02 -05:00
parent 69758613db
commit fe7d902a2c
1 changed files with 21 additions and 0 deletions

View File

@ -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.';