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: add query API #13

Merged
merged 5 commits into from
Oct 7, 2018
Merged

feat: add query API #13

merged 5 commits into from
Oct 7, 2018

Conversation

thymikee
Copy link
Member

@thymikee thymikee commented Oct 7, 2018

Summary

query APIs corresponding to get APIs. For simplicity and code reuse I've decided to go with calling get APIs directly – as a downside we throw/catch errors twice. If this ever has a bigger perf impact we can switch the implementation.

Fixes #6

Test plan

Added unit tests

@thymikee thymikee requested a review from Esemesek October 7, 2018 06:54
README.md Outdated
@@ -282,6 +282,30 @@ test('fetch data', async () => {
});
```

## `query` APIs

Each of the get APIs listed in the render section above have a complimentary query API. The get APIs will throw errors if a proper node cannot be found. This is normally the desired effect. However, if you want to make an assertion that an element is not present in the DOM, then you can use the query API instead:
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think we are not using DOM here C:

src/render.js Outdated
@@ -30,6 +39,15 @@ export default function render(
getAllByName: getAllByName(instance),
getAllByText: getAllByText(instance),
getAllByProps: getAllByProps(instance),

queryByTestId: queryByTestId(instance),
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think we should replace exports from getBy API and queryBy API by some factory function to avoid listing all the re-exports here. Eg.

// getBy.js
...
export const getByAPI (instance) => ({
  queryByTestId: queryByTestId(instance),
  ...
});

// render.js
return {
  ...getByAPI(instance),
  ...queryByAPI(instance),
  ...
}

@Esemesek Esemesek merged commit 495811b into master Oct 7, 2018
@Esemesek Esemesek deleted the feat/query-api branch October 7, 2018 08:59
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.

2 participants