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: query nested text nodes #293

Merged
merged 5 commits into from
May 11, 2020
Merged

feat: query nested text nodes #293

merged 5 commits into from
May 11, 2020

Conversation

marchenk0va
Copy link
Contributor

@marchenk0va marchenk0va commented May 8, 2020

Summary

Support *ByText to match text for nested Text components.
Closes #275

Test plan

  • Nest node into Text, eg <Text/>RN Testing <Text/>Library</Text></Text>
  • Check the existence of 'RN Testing Library' with getAllByText

@thymikee
Copy link
Member

thymikee commented May 8, 2020

Awesome! Can we add a test please? :)

if (child.props.children) {
const { children } = child.props;

if (children instanceof Array) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't use instanceof to check for array. Use .length

src/helpers/getByAPI.js Outdated Show resolved Hide resolved
if (children instanceof Array) {
children.forEach(node => {
// eslint-disable-next-line
const { Text } = require('react-native');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Text is retrieved from the caller, let's pass it through function parameters, instead of requiring it in yet another place.

Copy link
Member

@thymikee thymikee left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you so much for this contribution! It's a good start and we can make it even better 👍

@thymikee thymikee merged commit c8395ef into master May 11, 2020
@thymikee thymikee deleted the query-text-nodes branch May 11, 2020 17:13
@thymikee
Copy link
Member

Thanks once again! @Trancever will be happy :D

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

Successfully merging this pull request may close these issues.

Ability to query by text that is not a single node.
3 participants