filer/tests/spec/fs.close.spec.js

31 lines
752 B
JavaScript
Raw Normal View History

define(["Filer", "util"], function(Filer, util) {
2013-11-27 17:18:09 +00:00
describe('fs.close', function() {
beforeEach(util.setup);
afterEach(util.cleanup);
2013-11-27 17:18:09 +00:00
it('should be a function', function() {
var fs = util.fs();
expect(typeof fs.close).to.equal('function');
2013-11-27 17:18:09 +00:00
});
it('should release the file descriptor', function(done) {
2013-11-27 17:18:09 +00:00
var buffer = new Uint8Array(0);
var fs = util.fs();
2013-11-27 17:18:09 +00:00
fs.open('/myfile', 'w+', function(error, result) {
2013-11-27 17:18:09 +00:00
if(error) throw error;
var fd = result;
fs.close(fd, function(error) {
fs.read(fd, buffer, 0, buffer.length, undefined, function(error, result) {
expect(error).to.exist;
done();
2013-11-27 17:18:09 +00:00
});
});
});
});
});
});