I have a function that looks like
const BypassSFTP = {
execute: function(config, callback) {
const sftp = new Client()
sftp.connect(config)
.then(() => {
return sftp.list('./');
})
.then((fileList) => {
console.log(fileList)
return retrieveFileStreams.go(sftp, fileList, "sftp")
})
.then((fileStreams) => {
console.log(fileStreams)
return streamToString(fileStreams)
})
})}
im stubbing it with sinon like
sinon.stub(Client.prototype, 'connect').callsFake(function(config) {
return Q.when()
});
sinon.stub(Client.prototype, 'list').callsFake(function() {
return Q.when('meow2')
});
sinon.stub(retrieveFileStreams, 'go').callsFake(function(a, b, c) {
return Q.when('meow3')
});
im doing some asserts like
bypassSFTP.execute(config, callback_2);
sinon.assert.calledOnce(Client.prototype.connect);
sinon.assert.calledOnce(Client.prototype.list);
sinon.assert.calledOnce(retrieveFileStreams.go);
Now the issue is that after the Client.connect
call it does not recognize that the other function like sftp.list()
are called
What would be the best way to test this?
via Seal
No comments:
Post a Comment