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

Commit 8750ccf

Browse files
committed
fix: add regression test for custom queries
1 parent 9e80fe4 commit 8750ccf

File tree

3 files changed

+27
-16
lines changed

3 files changed

+27
-16
lines changed

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 & 12 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 />);
@@ -30,13 +30,3 @@ test('renders options.wrapper around node', () => {
3030
</View>
3131
`);
3232
});
33-
34-
test('returns the queries passed as options bound to the container', () => {
35-
const _getQueryPassedAsOption = { bind: jest.fn(() => _getQueryPassedAsOption) };
36-
const queries = { getQueryPassedAsOption: _getQueryPassedAsOption };
37-
38-
const { container, getQueryPassedAsOption } = render(<View />, { queries });
39-
40-
expect(queries.getQueryPassedAsOption.bind).toHaveBeenCalledWith(null, container);
41-
expect(getQueryPassedAsOption).toEqual(_getQueryPassedAsOption);
42-
});

0 commit comments

Comments
 (0)