#387 Added unit test for writing data using the Promise API

This commit is contained in:
Dilan Guneratne 2018-09-17 23:19:55 -04:00
parent fd3de6be2c
commit ad42a0d6ba
6 changed files with 1889 additions and 1762 deletions

589
dist/filer.js vendored

File diff suppressed because it is too large Load Diff

2
dist/filer.map vendored

File diff suppressed because one or more lines are too long

82
dist/filer.min.js vendored

File diff suppressed because one or more lines are too long

2
dist/filer.min.map vendored

File diff suppressed because one or more lines are too long

2952
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -59,4 +59,28 @@ describe('fs.write', function() {
}); });
}); });
}); });
it('should write data to a file using the Promise API', function(done) {
var fs = util.fs().promises;
var buffer = new Filer.Buffer([1, 2, 3, 4, 5, 6, 7, 8]);
fs.open('/myfile', 'w+')
.then((fd) => {
fs.write(fd, buffer, 0, buffer.length, 0)
.then((result) => {
expect(result).to.equal(buffer.length);
});
})
.then(() => {
fs.stat('/myfile')
.then((result) => {
expect(result.type).to.equal('FILE');
expect(result.size).to.equal(buffer.length);
});
})
.catch(function(error) {
if(error) throw error;
})
.finally(done);
});
}); });