Skip to content

Conversation

@Dajust
Copy link

@Dajust Dajust commented Jun 12, 2018

What: Add a within API

Why: Kindly see #53

How: Exported getQueriesForElement as within from the index.js file

Checklist:

  • Documentation
  • Tests
  • Ready to be merged
  • Added myself to contributors table

Copy link
Member

@kentcdodds kentcdodds left a comment

Choose a reason for hiding this comment

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

Looks super! Just a few simple changes. Thanks!

README.md Outdated
Example: To get the text 'hello' only within a section called 'messages', you could do:

```javascript
import {render, within} from 'react-testing-library'
Copy link
Member

Choose a reason for hiding this comment

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

Could you change this example to work better in the dom-testing-library docs?

import {within} from 'dom-testing-library'

const {getByText} = within(document.body.getElementById('messages'))
const helloMessage = getByText('hello')

Also, could you add a note that says:

> Fun fact, this is actually just an alias to the `getQueriesForElement` function!

src/index.js Outdated
export * from './pretty-dom'

// The original name of bindElementToQueries was weird
// The new name is better. Remove this in the next major version bump.
Copy link
Member

Choose a reason for hiding this comment

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

Could you move these two comments to right above the bindElementsToQueries export? That's where the comment applies. We'll keep the within alias indefinitely.

},
{
"login": "Dajust",
"name": "Justice Mba ",
Copy link
Collaborator

Choose a reason for hiding this comment

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

There's an extra space after your name, typo?

Copy link
Author

Choose a reason for hiding this comment

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

Not sure, I think that file is auto-generated.

Copy link
Member

Choose a reason for hiding this comment

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

You can fix it manually.

You may want to fix it on GitHub too though 😉

screen shot 2018-06-12 at 11 59 51 am

Copy link
Collaborator

@sompylasar sompylasar left a comment

Choose a reason for hiding this comment

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

👍

@kentcdodds kentcdodds merged commit b5bd755 into testing-library:master Jun 12, 2018
@kentcdodds
Copy link
Member

🎉 This PR is included in version 2.6.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

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants