testdouble / testdouble/testdouble.js
td doesn't work with curry functions.
Open
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 1.4k
- Forks
- 140
- Avg merge
- 22h
- Merged PRs (30d)
- 1
Description
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})))
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the curry-function reproduction in LanguageTranslationHelpersV2 and the td.replace/td.when setup shown in the issue. Check how td handles replaced functions invoked with multiple arguments, then run the reproduction to determine whether curry functions are supported and document or test the observed behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- testing
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100