fix #418 test for fsPromises.truncate(path[, len]) to test when length is negative

This commit is contained in:
Deepanjali Gerangal 2018-09-24 16:34:36 -04:00 committed by David Humphrey
parent 1775c24d37
commit e3a285ae54
1 changed files with 14 additions and 2 deletions

View File

@ -213,10 +213,10 @@ describe('fs.truncate', function() {
});
});
describe('fsPromises.truncate', function () {
beforeEach(util.setup);
afterEach(util.cleanup);
it('should error when path does not exist (with promises)', () => {
var fsPromises = util.fs().promises;
@ -226,4 +226,16 @@ describe('fsPromises.truncate', function () {
expect(error.code).to.equal('ENOENT');
});
});
it('should error when length is negative', () => {
var fsPromises = util.fs().promises;
var contents = 'This is a file.';
fsPromises.writeFile('/myfile', contents)
.then(() => fsPromises.truncate('/myfile', -1))
.catch(error => {
expect(error).to.exist;
expect(error.code).to.equal('EINVAL');
});
});
});