fix indentation
This commit is contained in:
parent
498e76cf9d
commit
3ee97f9920
|
@ -1,43 +1,43 @@
|
||||||
var util = require('../lib/test-utils.js');
|
var util = require('../lib/test-utils.js');
|
||||||
var expect = require('chai').expect;
|
var expect = require('chai').expect;
|
||||||
|
|
||||||
describe('fs.rename', function() {
|
describe('fs.rename', function () {
|
||||||
beforeEach(util.setup);
|
beforeEach(util.setup);
|
||||||
afterEach(util.cleanup);
|
afterEach(util.cleanup);
|
||||||
|
|
||||||
it('should be a function', function() {
|
it('should be a function', function () {
|
||||||
var fs = util.fs();
|
var fs = util.fs();
|
||||||
expect(fs.rename).to.be.a('function');
|
expect(fs.rename).to.be.a('function');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should rename an existing file', function(done) {
|
it('should rename an existing file', function (done) {
|
||||||
var complete1 = false;
|
var complete1 = false;
|
||||||
var complete2 = false;
|
var complete2 = false;
|
||||||
var fs = util.fs();
|
var fs = util.fs();
|
||||||
|
|
||||||
function maybeDone() {
|
function maybeDone() {
|
||||||
if(complete1 && complete2) {
|
if (complete1 && complete2) {
|
||||||
done();
|
done();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fs.open('/myfile', 'w+', function(error, fd) {
|
fs.open('/myfile', 'w+', function (error, fd) {
|
||||||
if(error) throw error;
|
if (error) throw error;
|
||||||
|
|
||||||
fs.close(fd, function(error) {
|
fs.close(fd, function (error) {
|
||||||
if(error) throw error;
|
if (error) throw error;
|
||||||
|
|
||||||
fs.rename('/myfile', '/myotherfile', function(error) {
|
fs.rename('/myfile', '/myotherfile', function (error) {
|
||||||
if(error) throw error;
|
if (error) throw error;
|
||||||
|
|
||||||
fs.stat('/myfile', function(error, result) {
|
fs.stat('/myfile', function (error, result) {
|
||||||
expect(error).to.exist;
|
expect(error).to.exist;
|
||||||
expect(result).not.to.exist;
|
expect(result).not.to.exist;
|
||||||
complete1 = true;
|
complete1 = true;
|
||||||
maybeDone();
|
maybeDone();
|
||||||
});
|
});
|
||||||
|
|
||||||
fs.stat('/myotherfile', function(error, result) {
|
fs.stat('/myotherfile', function (error, result) {
|
||||||
expect(error).not.to.exist;
|
expect(error).not.to.exist;
|
||||||
expect(result.nlinks).to.equal(1);
|
expect(result.nlinks).to.equal(1);
|
||||||
complete2 = true;
|
complete2 = true;
|
||||||
|
@ -48,19 +48,19 @@ describe('fs.rename', function() {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should rename an existing directory', function(done) {
|
it('should rename an existing directory', function (done) {
|
||||||
var fs = util.fs();
|
var fs = util.fs();
|
||||||
|
|
||||||
fs.mkdir('/mydir', function(error) {
|
fs.mkdir('/mydir', function (error) {
|
||||||
if(error) throw error;
|
if (error) throw error;
|
||||||
|
|
||||||
fs.rename('/mydir', '/myotherdir', function(error) {
|
fs.rename('/mydir', '/myotherdir', function (error) {
|
||||||
expect(error).not.to.exist;
|
expect(error).not.to.exist;
|
||||||
fs.stat('/mydir', function(error) {
|
fs.stat('/mydir', function (error) {
|
||||||
expect(error).to.exist;
|
expect(error).to.exist;
|
||||||
expect(error.code).to.equal('ENOENT');
|
expect(error.code).to.equal('ENOENT');
|
||||||
|
|
||||||
fs.stat('/myotherdir', function(error, result) {
|
fs.stat('/myotherdir', function (error, result) {
|
||||||
expect(error).not.to.exist;
|
expect(error).not.to.exist;
|
||||||
expect(result.nlinks).to.equal(1);
|
expect(result.nlinks).to.equal(1);
|
||||||
done();
|
done();
|
||||||
|
@ -69,30 +69,30 @@ describe('fs.rename', function() {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
it('should return error if the file or directory to rename doesnt exist', function(done) {
|
it('should return error if the file or directory to rename doesnt exist', function (done) {
|
||||||
var fs = util.fs();
|
var fs = util.fs();
|
||||||
fs.rename('/fakeDirectory', '/myotherdir', function(error) {
|
fs.rename('/fakeDirectory', '/myotherdir', function (error) {
|
||||||
expect(error).to.exist;
|
expect(error).to.exist;
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should rename an existing directory if the new path points to an existing directory', function(done) {
|
it('should rename an existing directory if the new path points to an existing directory', function (done) {
|
||||||
var fs = util.fs();
|
var fs = util.fs();
|
||||||
|
|
||||||
fs.mkdir('/mydir', function(error) {
|
fs.mkdir('/mydir', function (error) {
|
||||||
if(error) throw error;
|
if (error) throw error;
|
||||||
|
|
||||||
fs.mkdir('/myotherdir', function(error) {
|
fs.mkdir('/myotherdir', function (error) {
|
||||||
if(error) throw error;
|
if (error) throw error;
|
||||||
|
|
||||||
fs.rename('/mydir', '/myotherdir', function(error) {
|
fs.rename('/mydir', '/myotherdir', function (error) {
|
||||||
expect(error).not.to.exist;
|
expect(error).not.to.exist;
|
||||||
fs.stat('/mydir', function(error) {
|
fs.stat('/mydir', function (error) {
|
||||||
expect(error).to.exist;
|
expect(error).to.exist;
|
||||||
expect(error.code).to.equal('ENOENT');
|
expect(error.code).to.equal('ENOENT');
|
||||||
|
|
||||||
fs.stat('/myotherdir', function(error, result) {
|
fs.stat('/myotherdir', function (error, result) {
|
||||||
expect(error).not.to.exist;
|
expect(error).not.to.exist;
|
||||||
expect(result.nlinks).to.equal(1);
|
expect(result.nlinks).to.equal(1);
|
||||||
done();
|
done();
|
||||||
|
@ -103,26 +103,26 @@ describe('fs.rename', function() {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should fail to rename an existing directory if the new path points to an existing directory that is not empty', function(done) {
|
it('should fail to rename an existing directory if the new path points to an existing directory that is not empty', function (done) {
|
||||||
var fs = util.fs();
|
var fs = util.fs();
|
||||||
|
|
||||||
fs.mkdir('/mydir', function(error) {
|
fs.mkdir('/mydir', function (error) {
|
||||||
if(error) throw error;
|
if (error) throw error;
|
||||||
|
|
||||||
fs.mkdir('/myotherdir', function(error) {
|
fs.mkdir('/myotherdir', function (error) {
|
||||||
if(error) throw error;
|
if (error) throw error;
|
||||||
|
|
||||||
fs.writeFile('/myotherdir/myfile', 'This is a file', function(error) {
|
fs.writeFile('/myotherdir/myfile', 'This is a file', function (error) {
|
||||||
if(error) throw error;
|
if (error) throw error;
|
||||||
|
|
||||||
fs.rename('/mydir', '/myotherdir', function(error) {
|
fs.rename('/mydir', '/myotherdir', function (error) {
|
||||||
expect(error).to.exist;
|
expect(error).to.exist;
|
||||||
expect(error.code).to.equal('ENOTEMPTY');
|
expect(error.code).to.equal('ENOTEMPTY');
|
||||||
|
|
||||||
fs.stat('/mydir', function(error) {
|
fs.stat('/mydir', function (error) {
|
||||||
expect(error).not.to.exist;
|
expect(error).not.to.exist;
|
||||||
|
|
||||||
fs.stat('/myotherdir', function(error) {
|
fs.stat('/myotherdir', function (error) {
|
||||||
expect(error).not.to.exist;
|
expect(error).not.to.exist;
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
|
@ -133,23 +133,23 @@ describe('fs.rename', function() {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should fail to rename an existing directory if the new path points to an existing file', function(done) {
|
it('should fail to rename an existing directory if the new path points to an existing file', function (done) {
|
||||||
var fs = util.fs();
|
var fs = util.fs();
|
||||||
|
|
||||||
fs.mkdir('/mydir', function(error) {
|
fs.mkdir('/mydir', function (error) {
|
||||||
if(error) throw error;
|
if (error) throw error;
|
||||||
|
|
||||||
fs.writeFile('/myfile', 'This is a file', function(error) {
|
fs.writeFile('/myfile', 'This is a file', function (error) {
|
||||||
if(error) throw error;
|
if (error) throw error;
|
||||||
|
|
||||||
fs.rename('/mydir', '/myfile', function(error) {
|
fs.rename('/mydir', '/myfile', function (error) {
|
||||||
expect(error).to.exist;
|
expect(error).to.exist;
|
||||||
expect(error.code).to.equal('ENOTDIR');
|
expect(error.code).to.equal('ENOTDIR');
|
||||||
|
|
||||||
fs.stat('/mydir', function(error) {
|
fs.stat('/mydir', function (error) {
|
||||||
expect(error).not.to.exist;
|
expect(error).not.to.exist;
|
||||||
|
|
||||||
fs.stat('/myfile', function(error) {
|
fs.stat('/myfile', function (error) {
|
||||||
expect(error).not.to.exist;
|
expect(error).not.to.exist;
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue