2014-03-07 18:06:11 +00:00
|
|
|
define(["Filer", "util"], function(Filer, util) {
|
2014-02-21 01:56:53 +00:00
|
|
|
|
2014-03-07 18:06:11 +00:00
|
|
|
describe('fs.stats', function() {
|
2014-02-21 01:56:53 +00:00
|
|
|
describe('#isFile()', function() {
|
2014-03-07 18:06:11 +00:00
|
|
|
beforeEach(util.setup);
|
|
|
|
afterEach(util.cleanup);
|
2014-02-21 01:56:53 +00:00
|
|
|
|
|
|
|
it('should be a function', function() {
|
2014-03-07 18:06:11 +00:00
|
|
|
var fs = util.fs();
|
|
|
|
expect(fs.stat.isFile).to.be.a('function');
|
2014-02-21 01:56:53 +00:00
|
|
|
});
|
|
|
|
|
2014-03-07 18:06:11 +00:00
|
|
|
it('should return true if stats are for file', function(done) {
|
|
|
|
var fs = util.fs();
|
2014-02-21 01:56:53 +00:00
|
|
|
var contents = "This is a file.";
|
|
|
|
|
2014-03-07 18:06:11 +00:00
|
|
|
fs.writeFile('/myFile', contents, function(error) {
|
2014-02-21 01:56:53 +00:00
|
|
|
if(error) throw error;
|
2014-03-07 18:06:11 +00:00
|
|
|
fs.stat('/myFile').isFile(function (error, data) {
|
|
|
|
expect(error).not.to.exist;
|
|
|
|
expect(data).toEqual(true);
|
|
|
|
done()
|
|
|
|
});
|
2014-02-21 01:56:53 +00:00
|
|
|
});
|
|
|
|
});
|
2014-03-07 18:06:11 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
/* describe('#isDirectory()', function() {
|
|
|
|
beforeEach(util.setup);
|
|
|
|
afterEach(util.cleanup);
|
2014-02-21 01:56:53 +00:00
|
|
|
|
|
|
|
it('should be a function', function() {
|
|
|
|
var testStat = this.fs.stat('/', function(error) {
|
|
|
|
if(error) throw error;
|
|
|
|
});
|
|
|
|
expect(typeof this.testStat.isDirectory).toEqual('function');
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should only return true if stats are for directory', function() {
|
|
|
|
var complete = false;
|
|
|
|
var _result;
|
|
|
|
var that = this;
|
|
|
|
|
|
|
|
_result = that.fs.stat('/myFile', function(error) {
|
|
|
|
if(error) throw error;
|
|
|
|
}).isFile();
|
|
|
|
complete = true;
|
|
|
|
|
|
|
|
waitsFor(function() {
|
|
|
|
return complete;
|
|
|
|
}, 'test to complete', DEFAULT_TIMEOUT);
|
|
|
|
|
|
|
|
runs(function() {
|
|
|
|
expect(_error).toEqual(null);
|
|
|
|
expect(_result).toEqual(true);
|
|
|
|
});
|
|
|
|
});
|
2014-03-07 18:06:11 +00:00
|
|
|
});
|
2014-02-21 01:56:53 +00:00
|
|
|
|
|
|
|
describe('#isBlockDevice()', function() {
|
2014-03-07 18:06:11 +00:00
|
|
|
beforeEach(util.setup);
|
|
|
|
afterEach(util.cleanup);
|
2014-02-21 01:56:53 +00:00
|
|
|
|
|
|
|
it('should be a function', function() {
|
|
|
|
var testStat = this.fs.stat('/', function(error) {
|
|
|
|
if(error) throw error;
|
|
|
|
});
|
|
|
|
expect(typeof this.testStat.isBlockDevice).toEqual('function');
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should return false', function() {
|
|
|
|
var complete = false;
|
|
|
|
var _result;
|
|
|
|
var that = this;
|
|
|
|
|
|
|
|
_result = that.fs.stat('/', function(error) {
|
|
|
|
if(error) throw error;
|
|
|
|
}).isBlockDevice();
|
|
|
|
complete = true;
|
|
|
|
|
|
|
|
waitsFor(function() {
|
|
|
|
return complete;
|
|
|
|
}, 'test to complete', DEFAULT_TIMEOUT);
|
|
|
|
|
|
|
|
runs(function() {
|
|
|
|
expect(_error).toEqual(null);
|
|
|
|
expect(_result).toEqual(false);
|
|
|
|
});
|
|
|
|
});
|
2014-03-07 18:06:11 +00:00
|
|
|
});
|
2014-02-21 01:56:53 +00:00
|
|
|
|
|
|
|
describe('#isCharacterDevice()', function() {
|
2014-03-07 18:06:11 +00:00
|
|
|
beforeEach(util.setup);
|
|
|
|
afterEach(util.cleanup);
|
2014-02-21 01:56:53 +00:00
|
|
|
|
|
|
|
it('should be a function', function() {
|
|
|
|
var testStat = this.fs.stat('/', function(error) {
|
|
|
|
if(error) throw error;
|
|
|
|
});
|
|
|
|
expect(typeof this.testStat.isCharacterDevice).toEqual('function');
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should return false', function() {
|
|
|
|
var complete = false;
|
|
|
|
var _result;
|
|
|
|
var that = this;
|
|
|
|
|
|
|
|
_result = that.fs.stat('/', function(error) {
|
|
|
|
if(error) throw error;
|
|
|
|
}).isCharacterDevice();
|
|
|
|
complete = true;
|
|
|
|
|
|
|
|
waitsFor(function() {
|
|
|
|
return complete;
|
|
|
|
}, 'test to complete', DEFAULT_TIMEOUT);
|
|
|
|
|
|
|
|
runs(function() {
|
|
|
|
expect(_error).toEqual(null);
|
|
|
|
expect(_result).toEqual(false);
|
|
|
|
});
|
|
|
|
});
|
2014-03-07 18:06:11 +00:00
|
|
|
});
|
2014-02-21 01:56:53 +00:00
|
|
|
|
|
|
|
describe('#isSymbolicLink()', function() {
|
2014-03-07 18:06:11 +00:00
|
|
|
beforeEach(util.setup);
|
|
|
|
afterEach(util.cleanup);
|
2014-02-21 01:56:53 +00:00
|
|
|
|
|
|
|
it('should be a function', function() {
|
|
|
|
var testStat = this.fs.stat('/', function(error) {
|
|
|
|
if(error) throw error;
|
|
|
|
});
|
|
|
|
expect(typeof this.testStat.isSymbolicLink).toEqual('function');
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should return true if stats are for symbolic link', function() {
|
|
|
|
var complete = false;
|
|
|
|
var _error, _result;
|
|
|
|
var that = this;
|
|
|
|
|
|
|
|
that.fs.writeFile('/myfile', '', { encoding: 'utf8' }, function(error) {
|
|
|
|
if(error) throw error;
|
|
|
|
that.fs.symlink('/myfile', '/myFileLink', function (error) {
|
|
|
|
if (error) throw error;
|
|
|
|
_result = that.fs.lstat('/myfile', function(error) {
|
|
|
|
if(error) throw error;
|
|
|
|
}).isSymbolicLink();
|
|
|
|
complete = true;
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
waitsFor(function() {
|
|
|
|
return complete;
|
|
|
|
}, 'test to complete', DEFAULT_TIMEOUT);
|
|
|
|
|
|
|
|
runs(function() {
|
|
|
|
expect(_error).toEqual(null);
|
|
|
|
expect(_result).toEqual(true);
|
|
|
|
});
|
|
|
|
});
|
2014-03-07 18:06:11 +00:00
|
|
|
});
|
2014-02-21 01:56:53 +00:00
|
|
|
|
|
|
|
describe('#isFIFO()', function() {
|
2014-03-07 18:06:11 +00:00
|
|
|
beforeEach(util.setup);
|
|
|
|
afterEach(util.cleanup);
|
2014-02-21 01:56:53 +00:00
|
|
|
|
|
|
|
it('should be a function', function() {
|
|
|
|
var testStat = this.fs.stat('/', function(error) {
|
|
|
|
if(error) throw error;
|
|
|
|
});
|
|
|
|
expect(typeof this.testStat.isFIFO).toEqual('function');
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should return false', function() {
|
|
|
|
var complete = false;
|
|
|
|
var _result;
|
|
|
|
var that = this;
|
|
|
|
|
|
|
|
_result = that.fs.stat('/', function(error) {
|
|
|
|
if(error) throw error;
|
|
|
|
}).isFIFO();
|
|
|
|
complete = true;
|
|
|
|
|
|
|
|
waitsFor(function() {
|
|
|
|
return complete;
|
|
|
|
}, 'test to complete', DEFAULT_TIMEOUT);
|
|
|
|
|
|
|
|
runs(function() {
|
|
|
|
expect(_error).toEqual(null);
|
|
|
|
expect(_result).toEqual(false);
|
|
|
|
});
|
|
|
|
});
|
2014-03-07 18:06:11 +00:00
|
|
|
});
|
2014-02-21 01:56:53 +00:00
|
|
|
|
|
|
|
describe('#isSocket()', function() {
|
2014-03-07 18:06:11 +00:00
|
|
|
beforeEach(util.setup);
|
|
|
|
afterEach(util.cleanup);
|
2014-02-21 01:56:53 +00:00
|
|
|
|
|
|
|
it('should be a function', function() {
|
|
|
|
var testStat = this.fs.stat('/', function(error) {
|
|
|
|
if(error) throw error;
|
|
|
|
});
|
|
|
|
expect(typeof this.testStat.isSocket).toEqual('function');
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should return false', function() {
|
|
|
|
var complete = false;
|
|
|
|
var _result;
|
|
|
|
var that = this;
|
|
|
|
|
|
|
|
_result = that.fs.stat('/', function(error) {
|
|
|
|
if(error) throw error;
|
|
|
|
}).isSocket();
|
|
|
|
complete = true;
|
|
|
|
|
|
|
|
waitsFor(function() {
|
|
|
|
return complete;
|
|
|
|
}, 'test to complete', DEFAULT_TIMEOUT);
|
|
|
|
|
|
|
|
runs(function() {
|
|
|
|
expect(_error).toEqual(null);
|
|
|
|
expect(_result).toEqual(false);
|
|
|
|
});
|
|
|
|
});
|
2014-03-07 18:06:11 +00:00
|
|
|
});*/
|
|
|
|
});
|
|
|
|
)
|