diff --git a/tests/spec/fs.rename.spec.js b/tests/spec/fs.rename.spec.js index 51959c2..4940c9d 100644 --- a/tests/spec/fs.rename.spec.js +++ b/tests/spec/fs.rename.spec.js @@ -151,4 +151,44 @@ describe('fs.rename', function() { }); }); }); + + it('(promise version) should rename an existing file', function(done) { + var complete1 = false; + var complete2 = false; + var fs = util.fs(); + + function maybeDone() { + if(complete1 && complete2) { + done(); + } + } + + fs.open('/myfile', 'w+', function(error, fd) { + if(error) throw error; + + fs.close(fd, function(error) { + if(error) throw error; + + fs.promises.rename('/myfile', '/myotherfile').then( + function(){ + fs.stat('/myfile', function(error, result) { + expect(error).to.exist; + expect(result).not.to.exist; + complete1 = true; + maybeDone(); + }); + + fs.stat('/myotherfile', function(error, result) { + expect(error).not.to.exist; + expect(result.nlinks).to.equal(1); + complete2 = true; + maybeDone(); + }); + }, + function(error){throw error;} + ); + + }); + }); + }); });