filer/tests/spec/fs.exists.spec.js

60 lines
1.4 KiB
JavaScript
Raw Normal View History

2014-02-21 11:53:12 +00:00
define(["Filer", "util"], function(Filer, util) {
describe('fs.exists', function() {
beforeEach(util.setup);
afterEach(util.cleanup);
it('should be a function', function() {
var fs = util.fs();
expect(typeof fs.exists).to.equal('function');
});
it('should return false if path does not exist', function(done) {
var fs = util.fs();
fs.exists('/tmp', function(result) {
expect(result).to.be.false;
2014-02-21 11:53:12 +00:00
done();
});
});
it('should return true if path exists', function(done) {
var fs = util.fs();
fs.open('/myfile', 'w', function(err, fd) {
if(err) throw err;
fs.close(fd, function(err) {
2014-02-21 11:53:12 +00:00
if(err) throw err;
fs.exists('/myfile', function(result) {
expect(result).to.be.true;
done();
2014-02-21 11:53:12 +00:00
});
});
});
});
2014-02-21 11:53:12 +00:00
it('should follow symbolic links and return true for the resulting path', function(done) {
var fs = util.fs();
fs.open('/myfile', 'w', function(error, fd) {
if(error) throw error;
2014-02-21 11:53:12 +00:00
fs.close(fd, function(error) {
if(error) throw error;
2014-02-21 11:53:12 +00:00
fs.symlink('/myfile', '/myfilelink', function(error) {
if(error) throw error;
2014-02-21 11:53:12 +00:00
fs.exists('/myfilelink', function(result) {
expect(result).to.be.true;
2014-02-21 11:53:12 +00:00
done();
});
});
});
});
});
});
});