testdouble.js
testdouble.js copied to clipboard
td doesn't work with curry functions.
I was trying to replace the sinon stub with td, but it didn't work with curry functions. Is it supported by td?
//in LanguageTranslationHelpersV2
const deserialize = curry((key, data) => ({
//some data
}))
//in the test
//sinon works with curry function
sinon
.stub(LanguageTranslationHelpersV2, 'deserialize', () => curry(() => ({test: true})))
//tried to rewrite it with td, didn't work.
//error: undefined is not an object (evaluating 'fn(a, _b)')
td.replace(LanguageTranslationHelpersV2, 'deserialize')
td.when(LanguageTranslationHelpersV2.deserialize(td.matchers.anything(), td.matchers.anything()))
.thenDo(() => curry(() => ({test: true})))
What is defining curry in this case? Sorry, I'm familiar with the concept of currying, but I don't know what curry is in your case. It'd be very helpful if you could put together a published Runkit notebook to reproduce your issue
@searls sorry I forgot to mention, the curry I'm using is from Ramda http://ramdajs.com/docs/#curry
That makes more sense. If you'd be able to get your example into runkit for us so we can see it in action, that'd defnitely help (apologies for not looking at it closely otherwise, I have not used ramda)