2014-05-23 20:53:50 +00:00
|
|
|
var Filer = require('../..');
|
|
|
|
var util = require('../lib/test-utils.js');
|
|
|
|
var expect = require('chai').expect;
|
2013-11-27 17:18:09 +00:00
|
|
|
|
2014-05-23 20:53:50 +00:00
|
|
|
describe('fs.symlink', function() {
|
|
|
|
beforeEach(util.setup);
|
|
|
|
afterEach(util.cleanup);
|
2013-11-27 17:18:09 +00:00
|
|
|
|
2014-05-23 20:53:50 +00:00
|
|
|
it('should be a function', function() {
|
|
|
|
var fs = util.fs();
|
|
|
|
expect(fs.symlink).to.be.a('function');
|
|
|
|
});
|
2013-11-27 17:18:09 +00:00
|
|
|
|
2014-05-23 20:53:50 +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
|
|
|
|
2014-05-23 20:53:50 +00:00
|
|
|
fs.symlink('/', '/tmp/mydir', function(error) {
|
|
|
|
expect(error).to.exist;
|
|
|
|
expect(error.code).to.equal("ENOENT");
|
|
|
|
done();
|
2013-11-27 17:18:09 +00:00
|
|
|
});
|
2014-05-23 20:53:50 +00:00
|
|
|
});
|
2013-11-27 17:18:09 +00:00
|
|
|
|
2014-05-23 20:53:50 +00:00
|
|
|
it('should return an error if the destination path already exists', function(done) {
|
|
|
|
var fs = util.fs();
|
2013-11-27 17:18:09 +00:00
|
|
|
|
2014-05-23 20:53:50 +00:00
|
|
|
fs.symlink('/tmp', '/', function(error) {
|
|
|
|
expect(error).to.exist;
|
|
|
|
expect(error.code).to.equal("EEXIST");
|
|
|
|
done();
|
2013-11-27 17:18:09 +00:00
|
|
|
});
|
2014-05-23 20:53:50 +00:00
|
|
|
});
|
2013-11-27 17:18:09 +00:00
|
|
|
|
2014-05-23 20:53:50 +00:00
|
|
|
it('should create a symlink', function(done) {
|
|
|
|
var fs = util.fs();
|
2013-11-27 17:18:09 +00:00
|
|
|
|
2014-05-23 20:53:50 +00:00
|
|
|
fs.symlink('/', '/myfile', function(error) {
|
|
|
|
expect(error).not.to.exist;
|
2013-11-27 17:18:09 +00:00
|
|
|
|
2014-05-23 20:53:50 +00:00
|
|
|
fs.stat('/myfile', function(err, stats) {
|
|
|
|
expect(error).not.to.exist;
|
|
|
|
expect(stats.type).to.equal('DIRECTORY');
|
|
|
|
done();
|
2014-01-21 21:25:09 +00:00
|
|
|
});
|
2013-11-27 17:18:09 +00:00
|
|
|
});
|
|
|
|
});
|
2014-01-21 21:25:09 +00:00
|
|
|
});
|