fix #418 test for fsPromises.truncate(path[, len]) to test when length is negative
This commit is contained in:
parent
1775c24d37
commit
e3a285ae54
|
@ -213,10 +213,10 @@ describe('fs.truncate', function() {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
describe('fsPromises.truncate', function () {
|
describe('fsPromises.truncate', function () {
|
||||||
beforeEach(util.setup);
|
beforeEach(util.setup);
|
||||||
afterEach(util.cleanup);
|
afterEach(util.cleanup);
|
||||||
|
|
||||||
it('should error when path does not exist (with promises)', () => {
|
it('should error when path does not exist (with promises)', () => {
|
||||||
var fsPromises = util.fs().promises;
|
var fsPromises = util.fs().promises;
|
||||||
|
|
||||||
|
@ -226,4 +226,16 @@ describe('fsPromises.truncate', function () {
|
||||||
expect(error.code).to.equal('ENOENT');
|
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');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
Loading…
Reference in New Issue