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

Created a test for promises version of fs.unlink() #468

Closed
wants to merge 2 commits into from
Closed
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
27 changes: 27 additions & 0 deletions tests/spec/fs.unlink.spec.js
Expand Up @@ -104,3 +104,30 @@ describe('fs.unlink', function() {
});
});
});

describe('fsPromises.stat', function() {
beforeEach(util.setup);
afterEach(util.cleanup);

it('should not unlink directories (using promises)', () => {
var fsPromises = util.fs().promises;

return fsPromises.mkdir('/mydir')
.then(() => {
fsPromises.unlink('/mydir')
.catch((error) => {
expect(error).to.exist;
expect(error.code).to.equal('EPERM');
fsPromises.stat('/mydir')
.then((error, stats) =>{
expect(error).not.to.exist;
expect(stats).to.exist;
expect(stats.type).to.equal('DIRECTORY');
});
});
})
.catch((error) => {
if (error) throw error;
});
});
});
Copy link
Contributor

Choose a reason for hiding this comment

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

Hey @mphan6 - nice job here 👏 ! Just one tiny nitpick - GitHub is telling us that you didn't add a blank line at the end of the file with the image icon.

Can you amend that to your existing commit then force push again? Let me know if you need any help with that!