Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions tests/spec/fs.fsync.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,18 @@ describe('fs.fsync', function() {

it('should return error when fd is not a number', function(done) {
var fs = util.fs();
fs.fsync('1', function(error) {
fs.fsync('notAnInteger', function(error) {
expect(error).to.exist;
expect(error.code).to.equal('EINVAL');
done();
});
});

it('should return error when fd is invalid', function(done) {
var fs = util.fs();
fs.fsync(1, function(error) {
it('should return an error if file descriptor is negative', function(done) {
let fs = util.fs();

// File descriptor should be a non-negative number
fs.fsync(-1, function(error) {
expect(error).to.exist;
expect(error.code).to.equal('EBADF');
done();
Expand Down
21 changes: 21 additions & 0 deletions tests/spec/fs.ftruncate.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,27 @@ describe('fs.ftruncate', function() {
expect(fs.ftruncate).to.be.a('function');
});

it('should return an error if length is not an integer', function(done) {
let fs = util.fs();
let contents = 'This is a file.';

fs.writeFile('/myfile', contents, function(error) {
if(error) throw error;

fs.open('/myfile', 'w', function(err, fd) {

fs.ftruncate(fd, 'notAnInteger', function(error) {
expect(error).to.exist;
expect(error.code).to.equal('EINVAL');
done();
});

// Close file descriptor when done
fs.close(fd);
});
});
});

it('should return an error if length is negative', function(done) {
let fs = util.fs();
let contents = 'This is a file.';
Expand Down