2014-01-21 21:25:09 +00:00
|
|
|
define(["Filer", "util"], function(Filer, util) {
|
2013-11-27 17:18:09 +00:00
|
|
|
|
|
|
|
describe('fs.lstat', function() {
|
2014-01-21 21:25:09 +00:00
|
|
|
beforeEach(util.setup);
|
|
|
|
afterEach(util.cleanup);
|
2013-11-27 17:18:09 +00:00
|
|
|
|
|
|
|
it('should be a function', function() {
|
2014-01-21 21:25:09 +00:00
|
|
|
var fs = util.fs();
|
|
|
|
expect(typeof fs.lstat).to.equal('function');
|
2013-11-27 17:18:09 +00:00
|
|
|
});
|
|
|
|
|
2014-01-21 21:25:09 +00:00
|
|
|
it('should return an error if path does not exist', function(done) {
|
|
|
|
var fs = util.fs();
|
2013-11-27 17:18:09 +00:00
|
|
|
var _error, _result;
|
|
|
|
|
2014-01-21 21:25:09 +00:00
|
|
|
fs.lstat('/tmp', function(error, result) {
|
|
|
|
expect(error).to.exist;
|
|
|
|
expect(result).not.to.exist;
|
|
|
|
done();
|
2013-11-27 17:18:09 +00:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2014-01-21 21:25:09 +00:00
|
|
|
it('should return a stat object if path is not a symbolic link', function(done) {
|
|
|
|
var fs = util.fs();
|
2013-11-27 17:18:09 +00:00
|
|
|
|
2014-01-21 21:25:09 +00:00
|
|
|
fs.lstat('/', function(error, result) {
|
|
|
|
expect(error).not.to.exist;
|
|
|
|
expect(result).to.exist;
|
|
|
|
expect(result.type).to.equal('DIRECTORY');
|
|
|
|
done();
|
2013-11-27 17:18:09 +00:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2014-01-21 21:25:09 +00:00
|
|
|
it('should return a stat object if path is a symbolic link', function(done) {
|
|
|
|
var fs = util.fs();
|
2013-11-27 17:18:09 +00:00
|
|
|
|
2014-01-21 21:25:09 +00:00
|
|
|
fs.symlink('/', '/mylink', function(error) {
|
2013-11-27 17:18:09 +00:00
|
|
|
if(error) throw error;
|
|
|
|
|
2014-01-21 21:25:09 +00:00
|
|
|
fs.lstat('/mylink', function(error, result) {
|
|
|
|
expect(error).not.to.exist;
|
|
|
|
expect(result).to.exist;
|
|
|
|
expect(result.type).to.equal('SYMLINK');
|
|
|
|
done();
|
2013-11-27 17:18:09 +00:00
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
});
|