testdouble / testdouble/testdouble.js

td doesn't work with curry functions.

Open
#272 3 comments 0 reactions 0 assignees View on GitHub

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

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.