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

Create sample unit tests for components #22

Open
2 tasks
brettdh opened this issue Jan 16, 2018 · 0 comments
Open
2 tasks

Create sample unit tests for components #22

brettdh opened this issue Jan 16, 2018 · 0 comments

Comments

@brettdh
Copy link
Contributor

brettdh commented Jan 16, 2018

split from #15

Motivation

We want to establish a pattern for testing that components produce
expected output based on the inputs they are given. We also want to
have a pattern for testing components that are connected to Redux
state.

The component/store seam is a useful place to validate behavior.
We have state-focused tests that ensure that dispatched actions update
the state in expected ways; this issue is about ensuring that

  1. the components handle a given state in the expected way; and
  2. the components dispatch actions in expected ways in response to interactions
    (e.g. the onPress handler of a button)

Plan of action

Create sample tests for these cases:

  • Presentation-only test
    • Either:
      • Test a component that isn't connect()ed to Redux; or
      • Export a presentation component (the one you wrap with connect())
    • Pass it props and assert something based on the rendered DOM
  • Test mapStateToProps/mapDispatchToProps directly
    • Pass them a state object / dispatch function
    • Assert on the resulting props object
    • For mapDispatchToProps, assert that the functions returned dispatch the expected action(s)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant