paralleldrive / paralleldrive/riteway
Examples folder
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 1.2k
- Forks
- 40
- Avg merge
- 4h 53m
- Merged PRs (30d)
- 7
Description
So, I've been using RITEway a lot over the last two weeks and I love it, especially for TDD 👌🏻 But there where some edge cases where I wasted up to a couple of hours figuring out the selectors. I think others could save that time.
I'm wondering whether you would be open for an examples/ folder? If you are okay with it, I would include the following cases (for which I already have the code, except for the regex one):
1, Select multiple elements in a React component with the same class (useful for lists, tables).
2, Select input's vaules in a React component
3, Test whether selection is a certain tag (e.g. <button /> or <select /> etc.) in React Component.
4. Add context and dummy required props for propTypes in a React component. This would be in the createComponent factory function. E.g.:
// in the component
Counter.propTypes = {
onClick: PropTypes.func.isRequired
}
// ... in the test
const createCounter = clickCount =>
render(
<ClickCounter clicks={ clickCount } onClick={() => {}} />
)
;
- Regex.
- The reducer from your "Unit Testing React Components" article and adding tests for selectors.
I still have 3 questions about these:
- Do you even recommend to use propTypes? If not, why not?
- You said you would use regex like this:
/search text/.test(renderedOutput). I couldn't figure out how you would use this. Could you give a more concrete example? - Is it correct that you would test selectors like this:
const getCount = state => state.counter;
assert({
given: 'a click count and a click action',
should: 'add a click to the count',
actual: getCount({ counter: reducer(3, click()) }),
expected: 4
});
If you could answer these questions and like the idea of an examples/ folder, I will make a PR asap 😊Also would you like to see another case?
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 by reading the existing “Unit Testing React Components” article and the six proposed example cases. The issue names no files or tests, so confirm the folder’s scope and the three maintainer questions before coding; done would mean the agreed React selector, propTypes, regex, reducer, and selector examples are documented and runnable.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, react
- Domain
- documentation, frontend, testing
- Issue type
- Documentation
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100