tentative: replaced remaining callbacks with promises. check error propagation correctness
This commit is contained in:
parent
a1e73febc1
commit
5abefb6c6a
|
@ -162,33 +162,25 @@ describe('fs.rename', function() {
|
||||||
done();
|
done();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
//TODO: CHECK PROMISE ERRORS ARE PROPAGATED CORRECTLY (re-throw?)
|
||||||
fs.open('/myfile', 'w+', function(error, fd) {
|
Promise.all(
|
||||||
if(error) throw error;
|
fs.promises.open('/myfile', 'w+')
|
||||||
|
.then((fd)=>fs.promises.close(fd)),
|
||||||
fs.close(fd, function(error) {
|
fs.promises.rename('/myfile', '/myotherfile'),
|
||||||
if(error) throw error;
|
//TODO: for both stat() check expect() vs assert()
|
||||||
|
fs.promises.stat('/myfile')
|
||||||
fs.promises.rename('/myfile', '/myotherfile').then(
|
.then( (result)=> expect(result).not.to.exist, (error) => expect(error).to.exist)
|
||||||
function(){
|
.finally(()=>{
|
||||||
fs.stat('/myfile', function(error, result) {
|
|
||||||
expect(error).to.exist;
|
|
||||||
expect(result).not.to.exist;
|
|
||||||
complete1 = true;
|
complete1 = true;
|
||||||
maybeDone();
|
maybeDone();
|
||||||
});
|
}),
|
||||||
|
fs.promises.stat('/myotherfile')
|
||||||
fs.stat('/myotherfile', function(error, result) {
|
.then( (result) => expect(result.nlinks).to.equal(1), (error) => expect(error).not.to.exist)
|
||||||
expect(error).not.to.exist;
|
.finally(()=>{
|
||||||
expect(result.nlinks).to.equal(1);
|
|
||||||
complete2 = true;
|
complete2 = true;
|
||||||
maybeDone();
|
maybeDone();
|
||||||
});
|
})
|
||||||
},
|
|
||||||
function(error){throw error;}
|
|
||||||
);
|
);
|
||||||
|
//TODO: .catch() probably not necessary--we just want errors to percolate up...
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue