Skip to content
This repository was archived by the owner on Jul 30, 2020. It is now read-only.

Commit 87e62c3

Browse files
author
Brandon Carroll
committed
Merge branch 'next' of github.com:bcarroll22/native-testing-library into next
2 parents a6192db + 8750ccf commit 87e62c3

File tree

8 files changed

+45
-10
lines changed

8 files changed

+45
-10
lines changed

.all-contributorsrc

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,15 @@
6868
"contributions": [
6969
"doc"
7070
]
71+
},
72+
{
73+
"login": "elyalvarado",
74+
"name": "Ely Alvarado",
75+
"avatar_url": "https://avatars1.githubusercontent.com/u/545352?v=4",
76+
"profile": "https://github.com/elyalvarado",
77+
"contributions": [
78+
"code"
79+
]
7180
}
7281
],
7382
"contributorsPerLine": 7,

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
[![downloads](https://img.shields.io/npm/dm/native-testing-library.svg?style=flat-square)](http://www.npmtrends.com/native-testing-library)
2525
[![MIT License](https://img.shields.io/npm/l/native-testing-library.svg?style=flat-square)](https://github.com/testing-library/native-testing-library/blob/master/LICENSE)
2626

27-
[![All Contributors](https://img.shields.io/badge/all_contributors-6-orange.svg?style=flat-square)](#contributors)
27+
[![All Contributors](https://img.shields.io/badge/all_contributors-7-orange.svg?style=flat-square)](#contributors)
2828
[![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat-square)](http://makeapullrequest.com)
2929
[![Code of Conduct](https://img.shields.io/badge/code%20of-conduct-ff69b4.svg?style=flat-square)](https://github.com/testing-library/native-testing-library/blob/master/CODE_OF_CONDUCT.md)
3030

@@ -196,7 +196,7 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d
196196

197197
<!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section -->
198198
<!-- prettier-ignore -->
199-
<table><tr><td align="center"><a href="https://github.com/bcarroll22"><img src="https://avatars2.githubusercontent.com/u/11020406?v=4" width="100px;" alt="Brandon Carroll"/><br /><sub><b>Brandon Carroll</b></sub></a><br /><a href="https://github.com/testing-library/native-testing-library/commits?author=bcarroll22" title="Code">💻</a> <a href="https://github.com/testing-library/native-testing-library/commits?author=bcarroll22" title="Documentation">📖</a> <a href="#infra-bcarroll22" title="Infrastructure (Hosting, Build-Tools, etc)">🚇</a> <a href="https://github.com/testing-library/native-testing-library/commits?author=bcarroll22" title="Tests">⚠️</a></td><td align="center"><a href="http://tagraves.com"><img src="https://avatars1.githubusercontent.com/u/2263711?v=4" width="100px;" alt="Tommy Graves"/><br /><sub><b>Tommy Graves</b></sub></a><br /><a href="#ideas-TAGraves" title="Ideas, Planning, & Feedback">🤔</a> <a href="#maintenance-TAGraves" title="Maintenance">🚧</a> <a href="#review-TAGraves" title="Reviewed Pull Requests">👀</a></td><td align="center"><a href="https://kentcdodds.com"><img src="https://avatars.githubusercontent.com/u/1500684?v=3" width="100px;" alt="Kent C. Dodds"/><br /><sub><b>Kent C. Dodds</b></sub></a><br /><a href="#ideas-kentcdodds" title="Ideas, Planning, & Feedback">🤔</a></td><td align="center"><a href="https://github.com/sz-piotr"><img src="https://avatars2.githubusercontent.com/u/17070569?v=4" width="100px;" alt="Piotr Szlachciak"/><br /><sub><b>Piotr Szlachciak</b></sub></a><br /><a href="https://github.com/testing-library/native-testing-library/commits?author=sz-piotr" title="Code">💻</a></td><td align="center"><a href="https://github.com/mcgloneleviROOT"><img src="https://avatars3.githubusercontent.com/u/48258981?v=4" width="100px;" alt="mcgloneleviROOT"/><br /><sub><b>mcgloneleviROOT</b></sub></a><br /><a href="https://github.com/testing-library/native-testing-library/issues?q=author%3AmcgloneleviROOT" title="Bug reports">🐛</a> <a href="https://github.com/testing-library/native-testing-library/commits?author=mcgloneleviROOT" title="Code">💻</a></td><td align="center"><a href="http://exercism.io/profiles/wolverineks/619ce225090a43cb891d2edcbbf50401"><img src="https://avatars2.githubusercontent.com/u/8462274?v=4" width="100px;" alt="Kevin Sullivan"/><br /><sub><b>Kevin Sullivan</b></sub></a><br /><a href="https://github.com/testing-library/native-testing-library/commits?author=wolverineks" title="Documentation">📖</a></td></tr></table>
199+
<table><tr><td align="center"><a href="https://github.com/bcarroll22"><img src="https://avatars2.githubusercontent.com/u/11020406?v=4" width="100px;" alt="Brandon Carroll"/><br /><sub><b>Brandon Carroll</b></sub></a><br /><a href="https://github.com/testing-library/native-testing-library/commits?author=bcarroll22" title="Code">💻</a> <a href="https://github.com/testing-library/native-testing-library/commits?author=bcarroll22" title="Documentation">📖</a> <a href="#infra-bcarroll22" title="Infrastructure (Hosting, Build-Tools, etc)">🚇</a> <a href="https://github.com/testing-library/native-testing-library/commits?author=bcarroll22" title="Tests">⚠️</a></td><td align="center"><a href="http://tagraves.com"><img src="https://avatars1.githubusercontent.com/u/2263711?v=4" width="100px;" alt="Tommy Graves"/><br /><sub><b>Tommy Graves</b></sub></a><br /><a href="#ideas-TAGraves" title="Ideas, Planning, & Feedback">🤔</a> <a href="#maintenance-TAGraves" title="Maintenance">🚧</a> <a href="#review-TAGraves" title="Reviewed Pull Requests">👀</a></td><td align="center"><a href="https://kentcdodds.com"><img src="https://avatars.githubusercontent.com/u/1500684?v=3" width="100px;" alt="Kent C. Dodds"/><br /><sub><b>Kent C. Dodds</b></sub></a><br /><a href="#ideas-kentcdodds" title="Ideas, Planning, & Feedback">🤔</a></td><td align="center"><a href="https://github.com/sz-piotr"><img src="https://avatars2.githubusercontent.com/u/17070569?v=4" width="100px;" alt="Piotr Szlachciak"/><br /><sub><b>Piotr Szlachciak</b></sub></a><br /><a href="https://github.com/testing-library/native-testing-library/commits?author=sz-piotr" title="Code">💻</a></td><td align="center"><a href="https://github.com/mcgloneleviROOT"><img src="https://avatars3.githubusercontent.com/u/48258981?v=4" width="100px;" alt="mcgloneleviROOT"/><br /><sub><b>mcgloneleviROOT</b></sub></a><br /><a href="https://github.com/testing-library/native-testing-library/issues?q=author%3AmcgloneleviROOT" title="Bug reports">🐛</a> <a href="https://github.com/testing-library/native-testing-library/commits?author=mcgloneleviROOT" title="Code">💻</a></td><td align="center"><a href="http://exercism.io/profiles/wolverineks/619ce225090a43cb891d2edcbbf50401"><img src="https://avatars2.githubusercontent.com/u/8462274?v=4" width="100px;" alt="Kevin Sullivan"/><br /><sub><b>Kevin Sullivan</b></sub></a><br /><a href="https://github.com/testing-library/native-testing-library/commits?author=wolverineks" title="Documentation">📖</a></td><td align="center"><a href="https://github.com/elyalvarado"><img src="https://avatars1.githubusercontent.com/u/545352?v=4" width="100px;" alt="Ely Alvarado"/><br /><sub><b>Ely Alvarado</b></sub></a><br /><a href="https://github.com/testing-library/native-testing-library/commits?author=elyalvarado" title="Code">💻</a></td></tr></table>
200200

201201
<!-- ALL-CONTRIBUTORS-LIST:END -->
202202

package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,15 +56,15 @@
5656
"metro-react-native-babel-preset": "^0.52.0",
5757
"prettier": "^1.16.4",
5858
"pretty-quick": "^1.10.0",
59-
"react": "^16.8.5",
59+
"react": "16.8.3",
6060
"react-hooks-testing-library": "^0.5.0",
6161
"react-intl": "^2.8.0",
6262
"react-intl-native": "^2.1.2",
63-
"react-native": "^0.59.0",
63+
"react-native": "^0.59.5",
6464
"react-native-gesture-handler": "^1.1.0",
6565
"react-navigation": "^3.5.1",
66-
"react-redux": "6.0.1",
67-
"redux": "^4.0.0",
66+
"react-redux": "^7.0.3",
67+
"redux": "^4.0.1",
6868
"semantic-release": "^15.13.3"
6969
},
7070
"peerDependencies": {

src/__tests__/bugs.js

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import { queryAllByProp } from '../lib';
2+
import { render } from '../index';
3+
import { Text, View } from 'react-native';
4+
import React from 'react';
5+
6+
// This is to ensure custom queries can be passed to render. In most cases, you
7+
// wouldn't/shouldn't need to do this, but we do allow it so we'll test to
8+
// make sure that it works for those who use it.
9+
test('returns the queries passed as options bound to the container', () => {
10+
const queryAllBySelectionColor = queryAllByProp.bind(null, 'selectionColor');
11+
const queries = { queryAllBySelectionColor };
12+
13+
const { queryAllBySelectionColor: queryAllByImplementationDetail } = render(
14+
<View>
15+
<Text selectionColor="blue">hello world</Text>
16+
</View>,
17+
{ queries },
18+
);
19+
20+
expect(queryAllByImplementationDetail('blue')).toHaveLength(1);
21+
});

src/__tests__/render.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React from 'react';
2-
import { View } from 'react-native';
3-
import { render } from '../';
2+
import { Text, View } from 'react-native';
3+
import { queryAllByProp, render } from '../';
44

55
test('renders View', () => {
66
const { container } = render(<View />);

src/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ configureNTL({
2121
},
2222
});
2323

24-
function render(ui, { options = {}, wrapper: WrapperComponent } = {}) {
24+
function render(ui, { options = {}, wrapper: WrapperComponent, queries } = {}) {
2525
const wrapUiIfNeeded = innerElement =>
2626
WrapperComponent ? <WrapperComponent>{innerElement}</WrapperComponent> : innerElement;
2727

@@ -41,7 +41,7 @@ function render(ui, { options = {}, wrapper: WrapperComponent } = {}) {
4141
testRenderer.update(wrapUiIfNeeded(rerenderUi));
4242
});
4343
},
44-
...getQueriesForElement(testRenderer),
44+
...getQueriesForElement(testRenderer, queries),
4545
};
4646
}
4747

typings/index.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,3 +59,4 @@ export * from './queries';
5959
export * from './query-helpers';
6060
export * from './wait';
6161
export * from './wait-for-element';
62+
export * from './wait-for-element-to-be-removed';

typings/matches.d.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,18 @@
1+
import { NativeTestInstance } from './query-helpers';
2+
13
export type MatcherFunction = (content: string, element: HTMLElement) => boolean;
24
export type Matcher = string | RegExp | MatcherFunction;
35

46
export type NormalizerFn = (text: string) => string;
7+
export type SelectorFn = (element: NativeTestInstance) => boolean;
58

69
export interface MatcherOptions {
710
exact?: boolean;
811
/** Use normalizer with getDefaultNormalizer instead */
912
trim?: boolean;
1013
/** Use normalizer with getDefaultNormalizer instead */
1114
collapseWhitespace?: boolean;
15+
selector?: SelectorFn;
1216
normalizer?: NormalizerFn;
1317
}
1418

0 commit comments

Comments
 (0)