Skip to content

Commit 39d2e7c

Browse files
enieberthymikee
authored andcommitted
chore: add links to more sample of code (#104)
* add links to more sample of code * Update API.md * Update API.md
1 parent af067d0 commit 39d2e7c

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

docs/API.md

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@ title: API
55

66
This page gathers public API of `react-native-testing-library` along with usage examples.
77

8-
## `render`
8+
## `render`
9+
10+
- [`Example code`](https://github.com/callstack/react-native-testing-library/blob/master/src/__tests__/render.test.js)
911

1012
Defined as:
1113

@@ -135,6 +137,8 @@ Get the rendered component JSON representation, e.g. for snapshot testing.
135137

136138
## `shallow`
137139

140+
- [`Example code`](https://github.com/callstack/react-native-testing-library/blob/master/src/__tests__/shallow.test.js)
141+
138142
Shallowly renders given React component. Since it doesn't return helpers to query the output, it's mostly advised to used for snapshot testing (short snapshots are best for code reviewers).
139143

140144
```jsx
@@ -148,6 +152,8 @@ test('Component has a structure', () => {
148152

149153
## `fireEvent`
150154

155+
- [`Example code`](https://github.com/callstack/react-native-testing-library/blob/master/src/__tests__/fireEvent.test.js)
156+
151157
Invokes a given event handler (whether native or custom) on the element, bubbling to the root of the rendered tree. The three most common events (`press`, `changeText`, and `scroll`) have been aliased for convenience.
152158

153159
### `fireEvent: (element: ReactTestInstance, eventName: string, data?: *) => void`
@@ -252,6 +258,8 @@ fireEvent.scroll(getByTestId('scroll-view'), eventData);
252258

253259
## `waitForElement`
254260

261+
- [`Example code`](https://github.com/callstack/react-native-testing-library/blob/master/src/__tests__/waitForElement.test.js)
262+
255263
Defined as:
256264

257265
```jsx
@@ -278,6 +286,8 @@ If you're using Jest's [Timer Mocks](https://jestjs.io/docs/en/timer-mocks#docsN
278286

279287
## `debug`
280288

289+
- [`Example code`](https://github.com/callstack/react-native-testing-library/blob/master/src/__tests__/debug.test.js)
290+
281291
Log prettified shallowly rendered component or test instance (just like snapshot) to stdout.
282292

283293
```jsx

0 commit comments

Comments
 (0)