Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: createTestHandler constructor can be extended #134

Merged
merged 2 commits into from
Mar 29, 2018

Conversation

guillaumearm
Copy link
Owner

@guillaumearm guillaumearm commented Mar 29, 2018

  • expose createTestHandler
  • add constructor parameter
  • write example-readme-custom-testhandler tests
  • write documentation about extending testHandler constructor

usage:

import { createTestHandler } from 'handle-io';
import { io } from 'handle-io';

const log = io(console.log);

const createCustomTestHandler = (h, mockedIOs, expectedRetValue, assertRet, constructor = createCustomTestHandler) => {
  return {
    ...createTestHandler(h, mockedIOs, expectedRetValue, assertRet, constructor),
    matchLog: (arg, ret) => constructor(
      h,
      [...mockedIOs, [log(arg), ret]],
      expectedRetValue,
      assertRet,
      constructor,
    )
  }
}

const customTestHandler = h => createCustomTestHandler(h);

const myHandler = handler(function*(value) {
  yield log(value);
  yield log(value);
  return 42
})

customTestHandler(myHandler('hello world'))
  .matchLog('hello world')
  .shouldReturn(42)
  .run()

Closes #133

usage: import { createTestHandler } from 'handle-io/src/testHandler'

Closes #133
@guillaumearm guillaumearm self-assigned this Mar 29, 2018
@guillaumearm guillaumearm changed the title feat: export createTestHandler feat: createTestHandler constructor can be extended Mar 29, 2018
- write tests
- write documentation

Ref #134
@guillaumearm guillaumearm added the feat This is about feature label Mar 29, 2018
@guillaumearm guillaumearm merged commit 088184b into master Mar 29, 2018
@guillaumearm guillaumearm deleted the export-createTestHandler branch March 29, 2018 15:26
guillaumearm pushed a commit that referenced this pull request Mar 29, 2018
<a name="0.5.0"></a>
# [0.5.0](v0.4.1...v0.5.0) (2018-03-29)

### Features

* createTestHandler constructor can be extended ([#134](#134)) ([088184b](088184b)), closes [#133](#133)
@guillaumearm
Copy link
Owner Author

🎉 This PR is included in version 0.5.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feat This is about feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant