filer/tests/spec/fs.readlink.spec.js

47 lines
1.2 KiB
JavaScript
Raw Normal View History

define(["Filer", "util"], function(Filer, util) {
2013-11-27 17:18:09 +00:00
describe('fs.readlink', 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(fs.readlink).to.be.a('function');
2013-11-27 17:18:09 +00:00
});
it('should return an error if part of the parent destination path does not exist', function(done) {
var fs = util.fs();
2013-11-27 17:18:09 +00:00
fs.readlink('/tmp/mydir', function(error) {
expect(error).to.exist;
expect(error.code).to.equal("ENOENT");
done();
2013-11-27 17:18:09 +00:00
});
});
it('should return an error if the path is not a symbolic link', function(done) {
var fs = util.fs();
2013-11-27 17:18:09 +00:00
fs.readlink('/', function(error) {
expect(error).to.exist;
expect(error.code).to.equal("ENOENT");
done();
2013-11-27 17:18:09 +00:00
});
});
it('should return the contents of a symbolic link', function(done) {
var fs = util.fs();
2013-11-27 17:18:09 +00:00
fs.symlink('/', '/myfile', function(error) {
2013-11-27 17:18:09 +00:00
if(error) throw error;
fs.readlink('/myfile', function(error, result) {
expect(error).not.to.exist;
expect(result).to.equal('/');
done();
2013-11-27 17:18:09 +00:00
});
});
});
});
});