You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
How would I setup a test such that i can verify whether sendMessage is called correctly? I understand I can just pass the "promisified" version of sendMessage into someFunction and that eases the stubbing, but it makes my code a little messy.
As for the signature of sqs.sendMessage it would be (message, callbackFn)
Thanks in advance!
The text was updated successfully, but these errors were encountered:
Since the promisification is an implementation detail of the function, then the public contract between it and the test is that sqs should be passed something that expects the callback. As a result, I would pass it a test double wired to respond to a callback and verify that it returns a promise that resolves to the expected value:
// assuming you have a done() callback or somethingvarsqs=td.object(['sendMessage'])td.when(sqs.sendMessage('lol')).thenCallback(null,'kek')varresult=someFunction(sqs,'lol')result.then(function(result){assert.equal(result,'kek')done()})
Hi!
I have a function that does something like this...
How would I setup a test such that i can verify whether
sendMessage
is called correctly? I understand I can just pass the "promisified" version of sendMessage intosomeFunction
and that eases the stubbing, but it makes my code a little messy.As for the signature of
sqs.sendMessage
it would be(message, callbackFn)
Thanks in advance!
The text was updated successfully, but these errors were encountered: