Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed issue#480 using promises to test fs.truncate when path does not exist #516

Merged
merged 2 commits into from Oct 9, 2018
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
19 changes: 19 additions & 0 deletions tests/spec/fs.truncate.spec.js
Expand Up @@ -192,3 +192,22 @@ describe('fs.truncate', function() {
});
});
});


describe('fsPromises.truncate', function () {
beforeEach(util.setup);
afterEach(util.cleanup);
it('should error when path does not exist (with promises)', (done) => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can get rid of done in this callback

var fsPromises = util.fs().promises;

fsPromises.truncate('/NonExistingPath', 0)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add a return before the fsPromises... here, so you return the Promise for this test, to signal it's done.

.then(result => expect(result).not.to.exist)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you can delete this line.

.catch(error => {
expect(error).to.exist;
expect(error.code).to.equal('ENOENT');
})
.then(() => done());
});
});