diff --git a/tests/spec/fs.truncate.spec.js b/tests/spec/fs.truncate.spec.js index 44fda48..198ab87 100644 --- a/tests/spec/fs.truncate.spec.js +++ b/tests/spec/fs.truncate.spec.js @@ -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'); }); }); -}); \ No newline at end of file + + 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'); + }); + }); +});