@testing-library/react-native 11.3.0 → 11.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -2
- package/build/act.js +9 -15
- package/build/act.js.map +1 -1
- package/build/cleanup.d.ts +1 -1
- package/build/cleanup.js +0 -4
- package/build/cleanup.js.map +1 -1
- package/build/config.d.ts +15 -2
- package/build/config.js +16 -8
- package/build/config.js.map +1 -1
- package/build/fireEvent.js +3 -31
- package/build/fireEvent.js.map +1 -1
- package/build/flushMicroTasks.d.ts +1 -1
- package/build/flushMicroTasks.js +0 -3
- package/build/flushMicroTasks.js.map +1 -1
- package/build/helpers/accessiblity.d.ts +10 -1
- package/build/helpers/accessiblity.js +28 -24
- package/build/helpers/accessiblity.js.map +1 -1
- package/build/helpers/component-tree.js +6 -27
- package/build/helpers/component-tree.js.map +1 -1
- package/build/helpers/debugDeep.d.ts +5 -1
- package/build/helpers/debugDeep.js +7 -6
- package/build/helpers/debugDeep.js.map +1 -1
- package/build/helpers/debugShallow.js +0 -5
- package/build/helpers/debugShallow.js.map +1 -1
- package/build/helpers/errors.js +4 -25
- package/build/helpers/errors.js.map +1 -1
- package/build/helpers/filterNodeByType.js +0 -2
- package/build/helpers/filterNodeByType.js.map +1 -1
- package/build/helpers/findAll.d.ts +10 -0
- package/build/helpers/findAll.js +44 -0
- package/build/helpers/findAll.js.map +1 -0
- package/build/helpers/format.d.ts +5 -1
- package/build/helpers/format.js +17 -7
- package/build/helpers/format.js.map +1 -1
- package/build/helpers/getTextContent.d.ts +2 -0
- package/build/helpers/getTextContent.js +20 -0
- package/build/helpers/getTextContent.js.map +1 -0
- package/build/helpers/matchers/accessibilityState.d.ts +3 -0
- package/build/helpers/matchers/accessibilityState.js +28 -0
- package/build/helpers/matchers/accessibilityState.js.map +1 -0
- package/build/helpers/matchers/accessibilityValue.d.ts +9 -0
- package/build/helpers/matchers/accessibilityValue.js +12 -0
- package/build/helpers/matchers/accessibilityValue.js.map +1 -0
- package/build/helpers/matchers/matchArrayProp.js +0 -3
- package/build/helpers/matchers/matchArrayProp.js.map +1 -1
- package/build/helpers/matchers/matchObjectProp.js +0 -2
- package/build/helpers/matchers/matchObjectProp.js.map +1 -1
- package/build/helpers/matchers/matchStringProp.js +0 -3
- package/build/helpers/matchers/matchStringProp.js.map +1 -1
- package/build/helpers/matchers/matchTextContent.d.ts +3 -0
- package/build/helpers/matchers/matchTextContent.js +22 -0
- package/build/helpers/matchers/matchTextContent.js.map +1 -0
- package/build/helpers/stringValidation.js +0 -7
- package/build/helpers/stringValidation.js.map +1 -1
- package/build/helpers/timers.js +10 -21
- package/build/helpers/timers.js.map +1 -1
- package/build/index.flow.js +169 -56
- package/build/index.js +0 -6
- package/build/index.js.map +1 -1
- package/build/matches.d.ts +7 -3
- package/build/matches.js +2 -4
- package/build/matches.js.map +1 -1
- package/build/pure.d.ts +12 -23
- package/build/pure.js +8 -15
- package/build/pure.js.map +1 -1
- package/build/queries/a11yState.d.ts +15 -14
- package/build/queries/a11yState.js +16 -13
- package/build/queries/a11yState.js.map +1 -1
- package/build/queries/a11yValue.d.ts +15 -20
- package/build/queries/a11yValue.js +16 -13
- package/build/queries/a11yValue.js.map +1 -1
- package/build/queries/displayValue.d.ts +11 -9
- package/build/queries/displayValue.js +2 -12
- package/build/queries/displayValue.js.map +1 -1
- package/build/queries/hintText.d.ts +23 -20
- package/build/queries/hintText.js +11 -11
- package/build/queries/hintText.js.map +1 -1
- package/build/queries/labelText.d.ts +11 -8
- package/build/queries/labelText.js +11 -11
- package/build/queries/labelText.js.map +1 -1
- package/build/queries/makeQueries.d.ts +9 -9
- package/build/queries/makeQueries.js +40 -24
- package/build/queries/makeQueries.js.map +1 -1
- package/build/queries/options.d.ts +11 -0
- package/build/queries/options.js +2 -0
- package/build/queries/options.js.map +1 -0
- package/build/queries/placeholderText.d.ts +11 -9
- package/build/queries/placeholderText.js +2 -12
- package/build/queries/placeholderText.js.map +1 -1
- package/build/queries/role.d.ts +7 -3
- package/build/queries/role.js +32 -13
- package/build/queries/role.js.map +1 -1
- package/build/queries/testId.d.ts +11 -9
- package/build/queries/testId.js +3 -11
- package/build/queries/testId.js.map +1 -1
- package/build/queries/text.d.ts +11 -13
- package/build/queries/text.js +6 -71
- package/build/queries/text.js.map +1 -1
- package/build/queries/unsafeProps.d.ts +1 -1
- package/build/queries/unsafeProps.js +2 -11
- package/build/queries/unsafeProps.js.map +1 -1
- package/build/queries/unsafeType.d.ts +1 -1
- package/build/queries/unsafeType.js +2 -9
- package/build/queries/unsafeType.js.map +1 -1
- package/build/react-versions.js +0 -4
- package/build/react-versions.js.map +1 -1
- package/build/render.d.ts +88 -141
- package/build/render.js +21 -31
- package/build/render.js.map +1 -1
- package/build/renderHook.d.ts +2 -2
- package/build/renderHook.js +2 -12
- package/build/renderHook.js.map +1 -1
- package/build/screen.js +0 -6
- package/build/screen.js.map +1 -1
- package/build/shallow.js +0 -6
- package/build/shallow.js.map +1 -1
- package/build/waitFor.d.ts +1 -1
- package/build/waitFor.js +29 -52
- package/build/waitFor.js.map +1 -1
- package/build/waitForElementToBeRemoved.js +2 -11
- package/build/waitForElementToBeRemoved.js.map +1 -1
- package/build/within.d.ts +84 -138
- package/build/within.js +2 -14
- package/build/within.js.map +1 -1
- package/package.json +12 -11
- package/typings/index.flow.js +169 -56
|
@@ -4,19 +4,24 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.bindByA11yStateQueries = void 0;
|
|
7
|
-
|
|
8
|
-
var
|
|
9
|
-
|
|
7
|
+
var _accessiblity = require("../helpers/accessiblity");
|
|
8
|
+
var _findAll = require("../helpers/findAll");
|
|
9
|
+
var _accessibilityState = require("../helpers/matchers/accessibilityState");
|
|
10
10
|
var _makeQueries = require("./makeQueries");
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
return instance.findAll(node => typeof node.type === 'string' && (0, _matchObjectProp.matchObjectProp)(node.props.accessibilityState, state));
|
|
11
|
+
const queryAllByA11yState = instance => function queryAllByA11yStateFn(matcher, queryOptions) {
|
|
12
|
+
return (0, _findAll.findAll)(instance, node => typeof node.type === 'string' && (0, _accessibilityState.matchAccessibilityState)(node, matcher), queryOptions);
|
|
14
13
|
};
|
|
15
|
-
|
|
16
|
-
const
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
14
|
+
const buildErrorMessage = (state = {}) => {
|
|
15
|
+
const errors = [];
|
|
16
|
+
_accessiblity.accessibilityStateKeys.forEach(stateKey => {
|
|
17
|
+
if (state[stateKey] !== undefined) {
|
|
18
|
+
errors.push(`${stateKey} state: ${state[stateKey]}`);
|
|
19
|
+
}
|
|
20
|
+
});
|
|
21
|
+
return errors.join(', ');
|
|
22
|
+
};
|
|
23
|
+
const getMultipleError = state => `Found multiple elements with ${buildErrorMessage(state)}`;
|
|
24
|
+
const getMissingError = state => `Unable to find an element with ${buildErrorMessage(state)}`;
|
|
20
25
|
const {
|
|
21
26
|
getBy,
|
|
22
27
|
getAllBy,
|
|
@@ -25,7 +30,6 @@ const {
|
|
|
25
30
|
findBy,
|
|
26
31
|
findAllBy
|
|
27
32
|
} = (0, _makeQueries.makeQueries)(queryAllByA11yState, getMissingError, getMultipleError);
|
|
28
|
-
|
|
29
33
|
const bindByA11yStateQueries = instance => {
|
|
30
34
|
const getByA11yState = getBy(instance);
|
|
31
35
|
const getAllByA11yState = getAllBy(instance);
|
|
@@ -48,6 +52,5 @@ const bindByA11yStateQueries = instance => {
|
|
|
48
52
|
findAllByAccessibilityState: findAllByA11yState
|
|
49
53
|
};
|
|
50
54
|
};
|
|
51
|
-
|
|
52
55
|
exports.bindByA11yStateQueries = bindByA11yStateQueries;
|
|
53
56
|
//# sourceMappingURL=a11yState.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"a11yState.js","names":["queryAllByA11yState","instance","queryAllByA11yStateFn","
|
|
1
|
+
{"version":3,"file":"a11yState.js","names":["queryAllByA11yState","instance","queryAllByA11yStateFn","matcher","queryOptions","findAll","node","type","matchAccessibilityState","buildErrorMessage","state","errors","accessibilityStateKeys","forEach","stateKey","undefined","push","join","getMultipleError","getMissingError","getBy","getAllBy","queryBy","queryAllBy","findBy","findAllBy","makeQueries","bindByA11yStateQueries","getByA11yState","getAllByA11yState","queryByA11yState","findByA11yState","findAllByA11yState","getByAccessibilityState","getAllByAccessibilityState","queryByAccessibilityState","queryAllByAccessibilityState","findByAccessibilityState","findAllByAccessibilityState"],"sources":["../../src/queries/a11yState.ts"],"sourcesContent":["import type { ReactTestInstance } from 'react-test-renderer';\nimport { AccessibilityState } from 'react-native';\nimport { accessibilityStateKeys } from '../helpers/accessiblity';\nimport { findAll } from '../helpers/findAll';\nimport { matchAccessibilityState } from '../helpers/matchers/accessibilityState';\nimport { makeQueries } from './makeQueries';\nimport type {\n FindAllByQuery,\n FindByQuery,\n GetAllByQuery,\n GetByQuery,\n QueryAllByQuery,\n QueryByQuery,\n} from './makeQueries';\nimport { CommonQueryOptions } from './options';\n\nconst queryAllByA11yState = (\n instance: ReactTestInstance\n): ((\n matcher: AccessibilityState,\n queryOptions?: CommonQueryOptions\n) => Array<ReactTestInstance>) =>\n function queryAllByA11yStateFn(matcher, queryOptions) {\n return findAll(\n instance,\n (node) =>\n typeof node.type === 'string' && matchAccessibilityState(node, matcher),\n queryOptions\n );\n };\n\nconst buildErrorMessage = (state: AccessibilityState = {}) => {\n const errors: string[] = [];\n\n accessibilityStateKeys.forEach((stateKey) => {\n if (state[stateKey] !== undefined) {\n errors.push(`${stateKey} state: ${state[stateKey]}`);\n }\n });\n\n return errors.join(', ');\n};\n\nconst getMultipleError = (state: AccessibilityState) =>\n `Found multiple elements with ${buildErrorMessage(state)}`;\n\nconst getMissingError = (state: AccessibilityState) =>\n `Unable to find an element with ${buildErrorMessage(state)}`;\n\nconst { getBy, getAllBy, queryBy, queryAllBy, findBy, findAllBy } = makeQueries(\n queryAllByA11yState,\n getMissingError,\n getMultipleError\n);\n\nexport type ByA11yStateQueries = {\n getByA11yState: GetByQuery<AccessibilityState, CommonQueryOptions>;\n getAllByA11yState: GetAllByQuery<AccessibilityState, CommonQueryOptions>;\n queryByA11yState: QueryByQuery<AccessibilityState, CommonQueryOptions>;\n queryAllByA11yState: QueryAllByQuery<AccessibilityState, CommonQueryOptions>;\n findByA11yState: FindByQuery<AccessibilityState, CommonQueryOptions>;\n findAllByA11yState: FindAllByQuery<AccessibilityState, CommonQueryOptions>;\n\n getByAccessibilityState: GetByQuery<AccessibilityState, CommonQueryOptions>;\n getAllByAccessibilityState: GetAllByQuery<\n AccessibilityState,\n CommonQueryOptions\n >;\n queryByAccessibilityState: QueryByQuery<\n AccessibilityState,\n CommonQueryOptions\n >;\n queryAllByAccessibilityState: QueryAllByQuery<\n AccessibilityState,\n CommonQueryOptions\n >;\n findByAccessibilityState: FindByQuery<AccessibilityState, CommonQueryOptions>;\n findAllByAccessibilityState: FindAllByQuery<\n AccessibilityState,\n CommonQueryOptions\n >;\n};\n\nexport const bindByA11yStateQueries = (\n instance: ReactTestInstance\n): ByA11yStateQueries => {\n const getByA11yState = getBy(instance);\n const getAllByA11yState = getAllBy(instance);\n const queryByA11yState = queryBy(instance);\n const queryAllByA11yState = queryAllBy(instance);\n const findByA11yState = findBy(instance);\n const findAllByA11yState = findAllBy(instance);\n\n return {\n getByA11yState,\n getAllByA11yState,\n queryByA11yState,\n queryAllByA11yState,\n findByA11yState,\n findAllByA11yState,\n\n getByAccessibilityState: getByA11yState,\n getAllByAccessibilityState: getAllByA11yState,\n queryByAccessibilityState: queryByA11yState,\n queryAllByAccessibilityState: queryAllByA11yState,\n findByAccessibilityState: findByA11yState,\n findAllByAccessibilityState: findAllByA11yState,\n };\n};\n"],"mappings":";;;;;;AAEA;AACA;AACA;AACA;AAWA,MAAMA,mBAAmB,GACvBC,QAA2B,IAK3B,SAASC,qBAAqB,CAACC,OAAO,EAAEC,YAAY,EAAE;EACpD,OAAO,IAAAC,gBAA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GP,SAAS,CAACxB,QAAQ,CAAC;EAE9C,OAAO;IACL2B,cAAc;IACdC,iBAAiB;IACjBC,gBAAgB;IAChB9B,mBAAmB;IACnB+B,eAAe;IACfC,kBAAkB;IAElBC,uBAAuB,EAAEL,cAAc;IACvCM,0BAA0B,EAAEL,iBAAiB;IAC7CM,yBAAyB,EAAEL,gBAAgB;IAC3CM,4BAA4B,EAAEpC,mBAAmB;IACjDqC,wBAAwB,EAAEN,eAAe;IACzCO,2BAA2B,EAAEN;EAC/B,CAAC;AACH,CAAC;AAAC"}
|
|
@@ -1,24 +1,19 @@
|
|
|
1
1
|
import type { ReactTestInstance } from 'react-test-renderer';
|
|
2
|
+
import { AccessibilityValueMatcher } from '../helpers/matchers/accessibilityValue';
|
|
2
3
|
import type { FindAllByQuery, FindByQuery, GetAllByQuery, GetByQuery, QueryAllByQuery, QueryByQuery } from './makeQueries';
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
getAllByAccessibilityValue: GetAllByQuery<A11yValue>;
|
|
18
|
-
queryByAccessibilityValue: QueryByQuery<A11yValue>;
|
|
19
|
-
queryAllByAccessibilityValue: QueryAllByQuery<A11yValue>;
|
|
20
|
-
findByAccessibilityValue: FindByQuery<A11yValue>;
|
|
21
|
-
findAllByAccessibilityValue: FindAllByQuery<A11yValue>;
|
|
4
|
+
import { CommonQueryOptions } from './options';
|
|
5
|
+
export type ByA11yValueQueries = {
|
|
6
|
+
getByA11yValue: GetByQuery<AccessibilityValueMatcher, CommonQueryOptions>;
|
|
7
|
+
getAllByA11yValue: GetAllByQuery<AccessibilityValueMatcher, CommonQueryOptions>;
|
|
8
|
+
queryByA11yValue: QueryByQuery<AccessibilityValueMatcher, CommonQueryOptions>;
|
|
9
|
+
queryAllByA11yValue: QueryAllByQuery<AccessibilityValueMatcher, CommonQueryOptions>;
|
|
10
|
+
findByA11yValue: FindByQuery<AccessibilityValueMatcher, CommonQueryOptions>;
|
|
11
|
+
findAllByA11yValue: FindAllByQuery<AccessibilityValueMatcher, CommonQueryOptions>;
|
|
12
|
+
getByAccessibilityValue: GetByQuery<AccessibilityValueMatcher, CommonQueryOptions>;
|
|
13
|
+
getAllByAccessibilityValue: GetAllByQuery<AccessibilityValueMatcher, CommonQueryOptions>;
|
|
14
|
+
queryByAccessibilityValue: QueryByQuery<AccessibilityValueMatcher, CommonQueryOptions>;
|
|
15
|
+
queryAllByAccessibilityValue: QueryAllByQuery<AccessibilityValueMatcher, CommonQueryOptions>;
|
|
16
|
+
findByAccessibilityValue: FindByQuery<AccessibilityValueMatcher, CommonQueryOptions>;
|
|
17
|
+
findAllByAccessibilityValue: FindAllByQuery<AccessibilityValueMatcher, CommonQueryOptions>;
|
|
22
18
|
};
|
|
23
19
|
export declare const bindByA11yValueQueries: (instance: ReactTestInstance) => ByA11yValueQueries;
|
|
24
|
-
export {};
|
|
@@ -4,19 +4,24 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.bindByA11yValueQueries = void 0;
|
|
7
|
-
|
|
8
|
-
var
|
|
9
|
-
|
|
7
|
+
var _accessiblity = require("../helpers/accessiblity");
|
|
8
|
+
var _findAll = require("../helpers/findAll");
|
|
9
|
+
var _accessibilityValue = require("../helpers/matchers/accessibilityValue");
|
|
10
10
|
var _makeQueries = require("./makeQueries");
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
return instance.findAll(node => typeof node.type === 'string' && (0, _matchObjectProp.matchObjectProp)(node.props.accessibilityValue, value));
|
|
11
|
+
const queryAllByA11yValue = instance => function queryAllByA11yValueFn(value, queryOptions) {
|
|
12
|
+
return (0, _findAll.findAll)(instance, node => typeof node.type === 'string' && (0, _accessibilityValue.matchAccessibilityValue)(node, value), queryOptions);
|
|
14
13
|
};
|
|
15
|
-
|
|
16
|
-
const
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
14
|
+
const formatQueryParams = matcher => {
|
|
15
|
+
const params = [];
|
|
16
|
+
_accessiblity.accessiblityValueKeys.forEach(valueKey => {
|
|
17
|
+
if (matcher[valueKey] !== undefined) {
|
|
18
|
+
params.push(`${valueKey} value: ${matcher[valueKey]}`);
|
|
19
|
+
}
|
|
20
|
+
});
|
|
21
|
+
return params.join(', ');
|
|
22
|
+
};
|
|
23
|
+
const getMultipleError = matcher => `Found multiple elements with ${formatQueryParams(matcher)}`;
|
|
24
|
+
const getMissingError = matcher => `Unable to find an element with ${formatQueryParams(matcher)}`;
|
|
20
25
|
const {
|
|
21
26
|
getBy,
|
|
22
27
|
getAllBy,
|
|
@@ -25,7 +30,6 @@ const {
|
|
|
25
30
|
findBy,
|
|
26
31
|
findAllBy
|
|
27
32
|
} = (0, _makeQueries.makeQueries)(queryAllByA11yValue, getMissingError, getMultipleError);
|
|
28
|
-
|
|
29
33
|
const bindByA11yValueQueries = instance => {
|
|
30
34
|
const getByA11yValue = getBy(instance);
|
|
31
35
|
const getAllByA11yValue = getAllBy(instance);
|
|
@@ -48,6 +52,5 @@ const bindByA11yValueQueries = instance => {
|
|
|
48
52
|
findAllByAccessibilityValue: findAllByA11yValue
|
|
49
53
|
};
|
|
50
54
|
};
|
|
51
|
-
|
|
52
55
|
exports.bindByA11yValueQueries = bindByA11yValueQueries;
|
|
53
56
|
//# sourceMappingURL=a11yValue.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"a11yValue.js","names":["queryAllByA11yValue","instance","queryAllByA11yValueFn","value","findAll","node","type","
|
|
1
|
+
{"version":3,"file":"a11yValue.js","names":["queryAllByA11yValue","instance","queryAllByA11yValueFn","value","queryOptions","findAll","node","type","matchAccessibilityValue","formatQueryParams","matcher","params","accessiblityValueKeys","forEach","valueKey","undefined","push","join","getMultipleError","getMissingError","getBy","getAllBy","queryBy","queryAllBy","findBy","findAllBy","makeQueries","bindByA11yValueQueries","getByA11yValue","getAllByA11yValue","queryByA11yValue","findByA11yValue","findAllByA11yValue","getByAccessibilityValue","getAllByAccessibilityValue","queryByAccessibilityValue","queryAllByAccessibilityValue","findByAccessibilityValue","findAllByAccessibilityValue"],"sources":["../../src/queries/a11yValue.ts"],"sourcesContent":["import type { ReactTestInstance } from 'react-test-renderer';\nimport { accessiblityValueKeys } from '../helpers/accessiblity';\nimport { findAll } from '../helpers/findAll';\nimport {\n AccessibilityValueMatcher,\n matchAccessibilityValue,\n} from '../helpers/matchers/accessibilityValue';\nimport { makeQueries } from './makeQueries';\nimport type {\n FindAllByQuery,\n FindByQuery,\n GetAllByQuery,\n GetByQuery,\n QueryAllByQuery,\n QueryByQuery,\n} from './makeQueries';\nimport { CommonQueryOptions } from './options';\n\nconst queryAllByA11yValue = (\n instance: ReactTestInstance\n): ((\n value: AccessibilityValueMatcher,\n queryOptions?: CommonQueryOptions\n) => Array<ReactTestInstance>) =>\n function queryAllByA11yValueFn(value, queryOptions) {\n return findAll(\n instance,\n (node) =>\n typeof node.type === 'string' && matchAccessibilityValue(node, value),\n queryOptions\n );\n };\n\nconst formatQueryParams = (matcher: AccessibilityValueMatcher) => {\n const params: string[] = [];\n\n accessiblityValueKeys.forEach((valueKey) => {\n if (matcher[valueKey] !== undefined) {\n params.push(`${valueKey} value: ${matcher[valueKey]}`);\n }\n });\n\n return params.join(', ');\n};\n\nconst getMultipleError = (matcher: AccessibilityValueMatcher) =>\n `Found multiple elements with ${formatQueryParams(matcher)}`;\n\nconst getMissingError = (matcher: AccessibilityValueMatcher) =>\n `Unable to find an element with ${formatQueryParams(matcher)}`;\n\nconst { getBy, getAllBy, queryBy, queryAllBy, findBy, findAllBy } = makeQueries(\n queryAllByA11yValue,\n getMissingError,\n getMultipleError\n);\n\nexport type ByA11yValueQueries = {\n getByA11yValue: GetByQuery<AccessibilityValueMatcher, CommonQueryOptions>;\n getAllByA11yValue: GetAllByQuery<\n AccessibilityValueMatcher,\n CommonQueryOptions\n >;\n queryByA11yValue: QueryByQuery<AccessibilityValueMatcher, CommonQueryOptions>;\n queryAllByA11yValue: QueryAllByQuery<\n AccessibilityValueMatcher,\n CommonQueryOptions\n >;\n findByA11yValue: FindByQuery<AccessibilityValueMatcher, CommonQueryOptions>;\n findAllByA11yValue: FindAllByQuery<\n AccessibilityValueMatcher,\n CommonQueryOptions\n >;\n\n getByAccessibilityValue: GetByQuery<\n AccessibilityValueMatcher,\n CommonQueryOptions\n >;\n getAllByAccessibilityValue: GetAllByQuery<\n AccessibilityValueMatcher,\n CommonQueryOptions\n >;\n queryByAccessibilityValue: QueryByQuery<\n AccessibilityValueMatcher,\n CommonQueryOptions\n >;\n queryAllByAccessibilityValue: QueryAllByQuery<\n AccessibilityValueMatcher,\n CommonQueryOptions\n >;\n findByAccessibilityValue: FindByQuery<\n AccessibilityValueMatcher,\n CommonQueryOptions\n >;\n findAllByAccessibilityValue: FindAllByQuery<\n AccessibilityValueMatcher,\n CommonQueryOptions\n >;\n};\n\nexport const bindByA11yValueQueries = (\n instance: ReactTestInstance\n): ByA11yValueQueries => {\n const getByA11yValue = getBy(instance);\n const getAllByA11yValue = getAllBy(instance);\n const queryByA11yValue = queryBy(instance);\n const queryAllByA11yValue = queryAllBy(instance);\n const findByA11yValue = findBy(instance);\n const findAllByA11yValue = findAllBy(instance);\n\n return {\n getByA11yValue,\n getAllByA11yValue,\n queryByA11yValue,\n queryAllByA11yValue,\n findByA11yValue,\n findAllByA11yValue,\n\n getByAccessibilityValue: getByA11yValue,\n getAllByAccessibilityValue: getAllByA11yValue,\n queryByAccessibilityValue: queryByA11yValue,\n queryAllByAccessibilityValue: queryAllByA11yValue,\n findByAccessibilityValue: findByA11yValue,\n findAllByAccessibilityValue: findAllByA11yValue,\n };\n};\n"],"mappings":";;;;;;AACA;AACA;AACA;AAIA;AAWA,MAAMA,mBAAmB,GACvBC,QAA2B,IAK3B,SAASC,qBAAqB,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AC;EACxC,MAAM+B,kBAAkB,GAAGP,SAAS,CAACxB,QAAQ,CAAC;EAE9C,OAAO;IACL2B,cAAc;IACdC,iBAAiB;IACjBC,gBAAgB;IAChB9B,mBAAmB;IACnB+B,eAAe;IACfC,kBAAkB;IAElBC,uBAAuB,EAAEL,cAAc;IACvCM,0BAA0B,EAAEL,iBAAiB;IAC7CM,yBAAyB,EAAEL,gBAAgB;IAC3CM,4BAA4B,EAAEpC,mBAAmB;IACjDqC,wBAAwB,EAAEN,eAAe;IACzCO,2BAA2B,EAAEN;EAC/B,CAAC;AACH,CAAC;AAAC"}
|
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
import type { ReactTestInstance } from 'react-test-renderer';
|
|
2
|
-
import { TextMatch } from '../matches';
|
|
2
|
+
import { TextMatch, TextMatchOptions } from '../matches';
|
|
3
3
|
import type { FindAllByQuery, FindByQuery, GetAllByQuery, GetByQuery, QueryAllByQuery, QueryByQuery } from './makeQueries';
|
|
4
|
-
import type {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
4
|
+
import type { CommonQueryOptions } from './options';
|
|
5
|
+
type ByDisplayValueOptions = CommonQueryOptions & TextMatchOptions;
|
|
6
|
+
export type ByDisplayValueQueries = {
|
|
7
|
+
getByDisplayValue: GetByQuery<TextMatch, ByDisplayValueOptions>;
|
|
8
|
+
getAllByDisplayValue: GetAllByQuery<TextMatch, ByDisplayValueOptions>;
|
|
9
|
+
queryByDisplayValue: QueryByQuery<TextMatch, ByDisplayValueOptions>;
|
|
10
|
+
queryAllByDisplayValue: QueryAllByQuery<TextMatch, ByDisplayValueOptions>;
|
|
11
|
+
findByDisplayValue: FindByQuery<TextMatch, ByDisplayValueOptions>;
|
|
12
|
+
findAllByDisplayValue: FindAllByQuery<TextMatch, ByDisplayValueOptions>;
|
|
12
13
|
};
|
|
13
14
|
export declare const bindByDisplayValueQueries: (instance: ReactTestInstance) => ByDisplayValueQueries;
|
|
15
|
+
export {};
|
|
@@ -4,15 +4,11 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.bindByDisplayValueQueries = void 0;
|
|
7
|
-
|
|
8
7
|
var _reactNative = require("react-native");
|
|
9
|
-
|
|
10
8
|
var _filterNodeByType = require("../helpers/filterNodeByType");
|
|
11
|
-
|
|
9
|
+
var _findAll = require("../helpers/findAll");
|
|
12
10
|
var _matches = require("../matches");
|
|
13
|
-
|
|
14
11
|
var _makeQueries = require("./makeQueries");
|
|
15
|
-
|
|
16
12
|
const getTextInputNodeByDisplayValue = (node, value, options = {}) => {
|
|
17
13
|
const {
|
|
18
14
|
exact,
|
|
@@ -21,15 +17,11 @@ const getTextInputNodeByDisplayValue = (node, value, options = {}) => {
|
|
|
21
17
|
const nodeValue = node.props.value !== undefined ? node.props.value : node.props.defaultValue;
|
|
22
18
|
return (0, _filterNodeByType.filterNodeByType)(node, _reactNative.TextInput) && (0, _matches.matches)(value, nodeValue, normalizer, exact);
|
|
23
19
|
};
|
|
24
|
-
|
|
25
20
|
const queryAllByDisplayValue = instance => function queryAllByDisplayValueFn(displayValue, queryOptions) {
|
|
26
|
-
return
|
|
21
|
+
return (0, _findAll.findAll)(instance, node => getTextInputNodeByDisplayValue(node, displayValue, queryOptions), queryOptions);
|
|
27
22
|
};
|
|
28
|
-
|
|
29
23
|
const getMultipleError = displayValue => `Found multiple elements with display value: ${String(displayValue)} `;
|
|
30
|
-
|
|
31
24
|
const getMissingError = displayValue => `Unable to find an element with displayValue: ${String(displayValue)}`;
|
|
32
|
-
|
|
33
25
|
const {
|
|
34
26
|
getBy,
|
|
35
27
|
getAllBy,
|
|
@@ -38,7 +30,6 @@ const {
|
|
|
38
30
|
findBy,
|
|
39
31
|
findAllBy
|
|
40
32
|
} = (0, _makeQueries.makeQueries)(queryAllByDisplayValue, getMissingError, getMultipleError);
|
|
41
|
-
|
|
42
33
|
const bindByDisplayValueQueries = instance => ({
|
|
43
34
|
getByDisplayValue: getBy(instance),
|
|
44
35
|
getAllByDisplayValue: getAllBy(instance),
|
|
@@ -47,6 +38,5 @@ const bindByDisplayValueQueries = instance => ({
|
|
|
47
38
|
findByDisplayValue: findBy(instance),
|
|
48
39
|
findAllByDisplayValue: findAllBy(instance)
|
|
49
40
|
});
|
|
50
|
-
|
|
51
41
|
exports.bindByDisplayValueQueries = bindByDisplayValueQueries;
|
|
52
42
|
//# sourceMappingURL=displayValue.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"displayValue.js","names":["getTextInputNodeByDisplayValue","node","value","options","exact","normalizer","nodeValue","props","undefined","defaultValue","filterNodeByType","TextInput","matches","queryAllByDisplayValue","instance","queryAllByDisplayValueFn","displayValue","queryOptions","findAll","getMultipleError","String","getMissingError","getBy","getAllBy","queryBy","queryAllBy","findBy","findAllBy","makeQueries","bindByDisplayValueQueries","getByDisplayValue","getAllByDisplayValue","queryByDisplayValue","findByDisplayValue","findAllByDisplayValue"],"sources":["../../src/queries/displayValue.ts"],"sourcesContent":["import type { ReactTestInstance } from 'react-test-renderer';\nimport { TextInput } from 'react-native';\nimport { filterNodeByType } from '../helpers/filterNodeByType';\nimport { matches, TextMatch } from '../matches';\nimport { makeQueries } from './makeQueries';\nimport type {\n FindAllByQuery,\n FindByQuery,\n GetAllByQuery,\n GetByQuery,\n QueryAllByQuery,\n QueryByQuery,\n} from './makeQueries';\nimport type {
|
|
1
|
+
{"version":3,"file":"displayValue.js","names":["getTextInputNodeByDisplayValue","node","value","options","exact","normalizer","nodeValue","props","undefined","defaultValue","filterNodeByType","TextInput","matches","queryAllByDisplayValue","instance","queryAllByDisplayValueFn","displayValue","queryOptions","findAll","getMultipleError","String","getMissingError","getBy","getAllBy","queryBy","queryAllBy","findBy","findAllBy","makeQueries","bindByDisplayValueQueries","getByDisplayValue","getAllByDisplayValue","queryByDisplayValue","findByDisplayValue","findAllByDisplayValue"],"sources":["../../src/queries/displayValue.ts"],"sourcesContent":["import type { ReactTestInstance } from 'react-test-renderer';\nimport { TextInput } from 'react-native';\nimport { filterNodeByType } from '../helpers/filterNodeByType';\nimport { findAll } from '../helpers/findAll';\nimport { matches, TextMatch, TextMatchOptions } from '../matches';\nimport { makeQueries } from './makeQueries';\nimport type {\n FindAllByQuery,\n FindByQuery,\n GetAllByQuery,\n GetByQuery,\n QueryAllByQuery,\n QueryByQuery,\n} from './makeQueries';\nimport type { CommonQueryOptions } from './options';\n\ntype ByDisplayValueOptions = CommonQueryOptions & TextMatchOptions;\n\nconst getTextInputNodeByDisplayValue = (\n node: ReactTestInstance,\n value: TextMatch,\n options: TextMatchOptions = {}\n) => {\n const { exact, normalizer } = options;\n const nodeValue =\n node.props.value !== undefined ? node.props.value : node.props.defaultValue;\n return (\n filterNodeByType(node, TextInput) &&\n matches(value, nodeValue, normalizer, exact)\n );\n};\n\nconst queryAllByDisplayValue = (\n instance: ReactTestInstance\n): ((\n displayValue: TextMatch,\n queryOptions?: ByDisplayValueOptions\n) => Array<ReactTestInstance>) =>\n function queryAllByDisplayValueFn(displayValue, queryOptions) {\n return findAll(\n instance,\n (node) =>\n getTextInputNodeByDisplayValue(node, displayValue, queryOptions),\n queryOptions\n );\n };\n\nconst getMultipleError = (displayValue: TextMatch) =>\n `Found multiple elements with display value: ${String(displayValue)} `;\nconst getMissingError = (displayValue: TextMatch) =>\n `Unable to find an element with displayValue: ${String(displayValue)}`;\n\nconst { getBy, getAllBy, queryBy, queryAllBy, findBy, findAllBy } = makeQueries(\n queryAllByDisplayValue,\n getMissingError,\n getMultipleError\n);\n\nexport type ByDisplayValueQueries = {\n getByDisplayValue: GetByQuery<TextMatch, ByDisplayValueOptions>;\n getAllByDisplayValue: GetAllByQuery<TextMatch, ByDisplayValueOptions>;\n queryByDisplayValue: QueryByQuery<TextMatch, ByDisplayValueOptions>;\n queryAllByDisplayValue: QueryAllByQuery<TextMatch, ByDisplayValueOptions>;\n findByDisplayValue: FindByQuery<TextMatch, ByDisplayValueOptions>;\n findAllByDisplayValue: FindAllByQuery<TextMatch, ByDisplayValueOptions>;\n};\n\nexport const bindByDisplayValueQueries = (\n instance: ReactTestInstance\n): ByDisplayValueQueries => ({\n getByDisplayValue: getBy(instance),\n getAllByDisplayValue: getAllBy(instance),\n queryByDisplayValue: queryBy(instance),\n queryAllByDisplayValue: queryAllBy(instance),\n findByDisplayValue: findBy(instance),\n findAllByDisplayValue: findAllBy(instance),\n});\n"],"mappings":";;;;;;AACA;AACA;AACA;AACA;AACA;AAaA,MAAMA,8BAA8B,GAAG,CACrCC,IAAuB,EACvBC,KAAgB,EAChBC,OAAyB,GAAG,CAAC,CAAC,KAC3B;EACH,MAAM;IAAEC,KAAK;IAAEC;EAAW,CAAC,GAAGF,OAAO;EACrC,MAAMG,SAAS,GACbL,IAAI,CAACM,KAAK,CAACL,KAAK,KAAKM,SAAS,GAAGP,IAAI,CAACM,KAAK,CAACL,KAAK,GAAGD,IAAI,CAACM,KAAK,CAACE,YAAY;EAC7E,OACE,IAAAC,kCAAgB,EAACT,IAAI,EAAEU,sBAAS,CAAC,IACjC,IAAAC,gBAAO,EAACV,KAAK,EAAEI,SAAS,EAAED,UAAU,EAAED,KAAK,CAAC;AAEhD,CAAC;AAED,MAAMS,sBAAsB,GAC1BC,QAA2B,IAK3B,SAASC,wBAAwB,CAACC,YAAY,EAAEC,YAAY,EAAE;EAC5D,OAAO,IAAAC,gBAAO,EACZJ,QAAQ,EACPb,IAAI,IACHD,8BAA8B,CAACC,IAAI,EAAEe,YAAY,EAAEC,YAAY,CAAC,EAClEA,YAAY,CACb;AACH,CAAC;AAEH,MAAME,gBAAgB,GAAIH,YAAuB,IAC9C,+CAA8CI,MAAM,CAACJ,YAAY,CAAE,GAAE;AACxE,MAAMK,eAAe,GAAIL,YAAuB,IAC7C,gDAA+CI,MAAM,CAACJ,YAAY,CAAE,EAAC;AAExE,MAAM;EAAEM,KAAK;EAAEC,QAAQ;EAAEC,OAAO;EAAEC,UAAU;EAAEC,MAAM;EAAEC;AAAU,CAAC,GAAG,IAAAC,wBAAW,EAC7Ef,sBAAsB,EACtBQ,eAAe,EACfF,gBAAgB,CACjB;AAWM,MAAMU,yBAAyB,GACpCf,QAA2B,KACA;EAC3BgB,iBAAiB,EAAER,KAAK,CAACR,QAAQ,CAAC;EAClCiB,oBAAoB,EAAER,QAAQ,CAACT,QAAQ,CAAC;EACxCkB,mBAAmB,EAAER,OAAO,CAACV,QAAQ,CAAC;EACtCD,sBAAsB,EAAEY,UAAU,CAACX,QAAQ,CAAC;EAC5CmB,kBAAkB,EAAEP,MAAM,CAACZ,QAAQ,CAAC;EACpCoB,qBAAqB,EAAEP,SAAS,CAACb,QAAQ;AAC3C,CAAC,CAAC;AAAC"}
|
|
@@ -1,24 +1,27 @@
|
|
|
1
1
|
import type { ReactTestInstance } from 'react-test-renderer';
|
|
2
|
-
import { TextMatch } from '../matches';
|
|
2
|
+
import { TextMatch, TextMatchOptions } from '../matches';
|
|
3
3
|
import type { FindAllByQuery, FindByQuery, GetAllByQuery, GetByQuery, QueryAllByQuery, QueryByQuery } from './makeQueries';
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
4
|
+
import { CommonQueryOptions } from './options';
|
|
5
|
+
type ByHintTextOptions = CommonQueryOptions & TextMatchOptions;
|
|
6
|
+
export type ByHintTextQueries = {
|
|
7
|
+
getByHintText: GetByQuery<TextMatch, ByHintTextOptions>;
|
|
8
|
+
getAllByHintText: GetAllByQuery<TextMatch, ByHintTextOptions>;
|
|
9
|
+
queryByHintText: QueryByQuery<TextMatch, ByHintTextOptions>;
|
|
10
|
+
queryAllByHintText: QueryAllByQuery<TextMatch, ByHintTextOptions>;
|
|
11
|
+
findByHintText: FindByQuery<TextMatch, ByHintTextOptions>;
|
|
12
|
+
findAllByHintText: FindAllByQuery<TextMatch, ByHintTextOptions>;
|
|
13
|
+
getByA11yHint: GetByQuery<TextMatch, ByHintTextOptions>;
|
|
14
|
+
getAllByA11yHint: GetAllByQuery<TextMatch, ByHintTextOptions>;
|
|
15
|
+
queryByA11yHint: QueryByQuery<TextMatch, ByHintTextOptions>;
|
|
16
|
+
queryAllByA11yHint: QueryAllByQuery<TextMatch, ByHintTextOptions>;
|
|
17
|
+
findByA11yHint: FindByQuery<TextMatch, ByHintTextOptions>;
|
|
18
|
+
findAllByA11yHint: FindAllByQuery<TextMatch, ByHintTextOptions>;
|
|
19
|
+
getByAccessibilityHint: GetByQuery<TextMatch, ByHintTextOptions>;
|
|
20
|
+
getAllByAccessibilityHint: GetAllByQuery<TextMatch, ByHintTextOptions>;
|
|
21
|
+
queryByAccessibilityHint: QueryByQuery<TextMatch, ByHintTextOptions>;
|
|
22
|
+
queryAllByAccessibilityHint: QueryAllByQuery<TextMatch, ByHintTextOptions>;
|
|
23
|
+
findByAccessibilityHint: FindByQuery<TextMatch, ByHintTextOptions>;
|
|
24
|
+
findAllByAccessibilityHint: FindAllByQuery<TextMatch, ByHintTextOptions>;
|
|
23
25
|
};
|
|
24
26
|
export declare const bindByHintTextQueries: (instance: ReactTestInstance) => ByHintTextQueries;
|
|
27
|
+
export {};
|
|
@@ -4,19 +4,21 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.bindByHintTextQueries = void 0;
|
|
7
|
-
|
|
8
|
-
var
|
|
9
|
-
|
|
7
|
+
var _findAll = require("../helpers/findAll");
|
|
8
|
+
var _matches = require("../matches");
|
|
10
9
|
var _makeQueries = require("./makeQueries");
|
|
11
|
-
|
|
12
|
-
const
|
|
13
|
-
|
|
10
|
+
const getNodeByHintText = (node, text, options = {}) => {
|
|
11
|
+
const {
|
|
12
|
+
exact,
|
|
13
|
+
normalizer
|
|
14
|
+
} = options;
|
|
15
|
+
return (0, _matches.matches)(text, node.props.accessibilityHint, normalizer, exact);
|
|
16
|
+
};
|
|
17
|
+
const queryAllByHintText = instance => function queryAllByA11yHintFn(hint, queryOptions) {
|
|
18
|
+
return (0, _findAll.findAll)(instance, node => typeof node.type === 'string' && getNodeByHintText(node, hint, queryOptions), queryOptions);
|
|
14
19
|
};
|
|
15
|
-
|
|
16
20
|
const getMultipleError = hint => `Found multiple elements with accessibilityHint: ${String(hint)} `;
|
|
17
|
-
|
|
18
21
|
const getMissingError = hint => `Unable to find an element with accessibilityHint: ${String(hint)}`;
|
|
19
|
-
|
|
20
22
|
const {
|
|
21
23
|
getBy,
|
|
22
24
|
getAllBy,
|
|
@@ -25,7 +27,6 @@ const {
|
|
|
25
27
|
findBy,
|
|
26
28
|
findAllBy
|
|
27
29
|
} = (0, _makeQueries.makeQueries)(queryAllByHintText, getMissingError, getMultipleError);
|
|
28
|
-
|
|
29
30
|
const bindByHintTextQueries = instance => {
|
|
30
31
|
const getByHintText = getBy(instance);
|
|
31
32
|
const getAllByHintText = getAllBy(instance);
|
|
@@ -56,6 +57,5 @@ const bindByHintTextQueries = instance => {
|
|
|
56
57
|
findAllByAccessibilityHint: findAllByHintText
|
|
57
58
|
};
|
|
58
59
|
};
|
|
59
|
-
|
|
60
60
|
exports.bindByHintTextQueries = bindByHintTextQueries;
|
|
61
61
|
//# sourceMappingURL=hintText.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hintText.js","names":["
|
|
1
|
+
{"version":3,"file":"hintText.js","names":["getNodeByHintText","node","text","options","exact","normalizer","matches","props","accessibilityHint","queryAllByHintText","instance","queryAllByA11yHintFn","hint","queryOptions","findAll","type","getMultipleError","String","getMissingError","getBy","getAllBy","queryBy","queryAllBy","findBy","findAllBy","makeQueries","bindByHintTextQueries","getByHintText","getAllByHintText","queryByHintText","findByHintText","findAllByHintText","getByA11yHint","getAllByA11yHint","queryByA11yHint","queryAllByA11yHint","findByA11yHint","findAllByA11yHint","getByAccessibilityHint","getAllByAccessibilityHint","queryByAccessibilityHint","queryAllByAccessibilityHint","findByAccessibilityHint","findAllByAccessibilityHint"],"sources":["../../src/queries/hintText.ts"],"sourcesContent":["import type { ReactTestInstance } from 'react-test-renderer';\nimport { findAll } from '../helpers/findAll';\nimport { matches, TextMatch, TextMatchOptions } from '../matches';\nimport { makeQueries } from './makeQueries';\nimport type {\n FindAllByQuery,\n FindByQuery,\n GetAllByQuery,\n GetByQuery,\n QueryAllByQuery,\n QueryByQuery,\n} from './makeQueries';\nimport { CommonQueryOptions } from './options';\n\ntype ByHintTextOptions = CommonQueryOptions & TextMatchOptions;\n\nconst getNodeByHintText = (\n node: ReactTestInstance,\n text: TextMatch,\n options: TextMatchOptions = {}\n) => {\n const { exact, normalizer } = options;\n return matches(text, node.props.accessibilityHint, normalizer, exact);\n};\n\nconst queryAllByHintText = (\n instance: ReactTestInstance\n): ((\n hint: TextMatch,\n queryOptions?: ByHintTextOptions\n) => Array<ReactTestInstance>) =>\n function queryAllByA11yHintFn(hint, queryOptions) {\n return findAll(\n instance,\n (node) =>\n typeof node.type === 'string' &&\n getNodeByHintText(node, hint, queryOptions),\n queryOptions\n );\n };\n\nconst getMultipleError = (hint: TextMatch) =>\n `Found multiple elements with accessibilityHint: ${String(hint)} `;\nconst getMissingError = (hint: TextMatch) =>\n `Unable to find an element with accessibilityHint: ${String(hint)}`;\n\nconst { getBy, getAllBy, queryBy, queryAllBy, findBy, findAllBy } = makeQueries(\n queryAllByHintText,\n getMissingError,\n getMultipleError\n);\n\nexport type ByHintTextQueries = {\n getByHintText: GetByQuery<TextMatch, ByHintTextOptions>;\n getAllByHintText: GetAllByQuery<TextMatch, ByHintTextOptions>;\n queryByHintText: QueryByQuery<TextMatch, ByHintTextOptions>;\n queryAllByHintText: QueryAllByQuery<TextMatch, ByHintTextOptions>;\n findByHintText: FindByQuery<TextMatch, ByHintTextOptions>;\n findAllByHintText: FindAllByQuery<TextMatch, ByHintTextOptions>;\n\n // a11yHint aliases\n getByA11yHint: GetByQuery<TextMatch, ByHintTextOptions>;\n getAllByA11yHint: GetAllByQuery<TextMatch, ByHintTextOptions>;\n queryByA11yHint: QueryByQuery<TextMatch, ByHintTextOptions>;\n queryAllByA11yHint: QueryAllByQuery<TextMatch, ByHintTextOptions>;\n findByA11yHint: FindByQuery<TextMatch, ByHintTextOptions>;\n findAllByA11yHint: FindAllByQuery<TextMatch, ByHintTextOptions>;\n\n // accessibilityHint aliases\n getByAccessibilityHint: GetByQuery<TextMatch, ByHintTextOptions>;\n getAllByAccessibilityHint: GetAllByQuery<TextMatch, ByHintTextOptions>;\n queryByAccessibilityHint: QueryByQuery<TextMatch, ByHintTextOptions>;\n queryAllByAccessibilityHint: QueryAllByQuery<TextMatch, ByHintTextOptions>;\n findByAccessibilityHint: FindByQuery<TextMatch, ByHintTextOptions>;\n findAllByAccessibilityHint: FindAllByQuery<TextMatch, ByHintTextOptions>;\n};\n\nexport const bindByHintTextQueries = (\n instance: ReactTestInstance\n): ByHintTextQueries => {\n const getByHintText = getBy(instance);\n const getAllByHintText = getAllBy(instance);\n const queryByHintText = queryBy(instance);\n const queryAllByHintText = queryAllBy(instance);\n const findByHintText = findBy(instance);\n const findAllByHintText = findAllBy(instance);\n\n return {\n getByHintText,\n getAllByHintText,\n queryByHintText,\n queryAllByHintText,\n findByHintText,\n findAllByHintText,\n\n // a11yHint aliases\n getByA11yHint: getByHintText,\n getAllByA11yHint: getAllByHintText,\n queryByA11yHint: queryByHintText,\n queryAllByA11yHint: queryAllByHintText,\n findByA11yHint: findByHintText,\n findAllByA11yHint: findAllByHintText,\n\n // accessibilityHint aliases\n getByAccessibilityHint: getByHintText,\n getAllByAccessibilityHint: getAllByHintText,\n queryByAccessibilityHint: queryByHintText,\n queryAllByAccessibilityHint: queryAllByHintText,\n findByAccessibilityHint: findByHintText,\n findAllByAccessibilityHint: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AAQ,CAAC;EACvC,MAAMqB,iBAAiB,GAAGP,SAAS,CAACd,QAAQ,CAAC;EAE7C,OAAO;IACLiB,aAAa;IACbC,gBAAgB;IAChBC,eAAe;IACfpB,kBAAkB;IAClBqB,cAAc;IACdC,iBAAiB;IAEjB;IACAC,aAAa,EAAEL,aAAa;IAC5BM,gBAAgB,EAAEL,gBAAgB;IAClCM,eAAe,EAAEL,eAAe;IAChCM,kBAAkB,EAAE1B,kBAAkB;IACtC2B,cAAc,EAAEN,cAAc;IAC9BO,iBAAiB,EAAEN,iBAAiB;IAEpC;IACAO,sBAAsB,EAAEX,aAAa;IACrCY,yBAAyB,EAAEX,gBAAgB;IAC3CY,wBAAwB,EAAEX,eAAe;IACzCY,2BAA2B,EAAEhC,kBAAkB;IAC/CiC,uBAAuB,EAAEZ,cAAc;IACvCa,0BAA0B,EAAEZ;EAC9B,CAAC;AACH,CAAC;AAAC"}
|
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
import type { ReactTestInstance } from 'react-test-renderer';
|
|
2
|
-
import { TextMatch } from '../matches';
|
|
2
|
+
import { TextMatch, TextMatchOptions } from '../matches';
|
|
3
3
|
import type { FindAllByQuery, FindByQuery, GetAllByQuery, GetByQuery, QueryAllByQuery, QueryByQuery } from './makeQueries';
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
4
|
+
import { CommonQueryOptions } from './options';
|
|
5
|
+
type ByLabelTextOptions = CommonQueryOptions & TextMatchOptions;
|
|
6
|
+
export type ByLabelTextQueries = {
|
|
7
|
+
getByLabelText: GetByQuery<TextMatch, ByLabelTextOptions>;
|
|
8
|
+
getAllByLabelText: GetAllByQuery<TextMatch, ByLabelTextOptions>;
|
|
9
|
+
queryByLabelText: QueryByQuery<TextMatch, ByLabelTextOptions>;
|
|
10
|
+
queryAllByLabelText: QueryAllByQuery<TextMatch, ByLabelTextOptions>;
|
|
11
|
+
findByLabelText: FindByQuery<TextMatch, ByLabelTextOptions>;
|
|
12
|
+
findAllByLabelText: FindAllByQuery<TextMatch, ByLabelTextOptions>;
|
|
11
13
|
};
|
|
12
14
|
export declare const bindByLabelTextQueries: (instance: ReactTestInstance) => ByLabelTextQueries;
|
|
15
|
+
export {};
|
|
@@ -4,19 +4,21 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.bindByLabelTextQueries = void 0;
|
|
7
|
-
|
|
8
|
-
var
|
|
9
|
-
|
|
7
|
+
var _findAll = require("../helpers/findAll");
|
|
8
|
+
var _matches = require("../matches");
|
|
10
9
|
var _makeQueries = require("./makeQueries");
|
|
11
|
-
|
|
12
|
-
const
|
|
13
|
-
|
|
10
|
+
const getNodeByLabelText = (node, text, options = {}) => {
|
|
11
|
+
const {
|
|
12
|
+
exact,
|
|
13
|
+
normalizer
|
|
14
|
+
} = options;
|
|
15
|
+
return (0, _matches.matches)(text, node.props.accessibilityLabel, normalizer, exact);
|
|
16
|
+
};
|
|
17
|
+
const queryAllByLabelText = instance => function queryAllByLabelTextFn(text, queryOptions) {
|
|
18
|
+
return (0, _findAll.findAll)(instance, node => typeof node.type === 'string' && getNodeByLabelText(node, text, queryOptions), queryOptions);
|
|
14
19
|
};
|
|
15
|
-
|
|
16
20
|
const getMultipleError = labelText => `Found multiple elements with accessibilityLabel: ${String(labelText)} `;
|
|
17
|
-
|
|
18
21
|
const getMissingError = labelText => `Unable to find an element with accessibilityLabel: ${String(labelText)}`;
|
|
19
|
-
|
|
20
22
|
const {
|
|
21
23
|
getBy,
|
|
22
24
|
getAllBy,
|
|
@@ -25,7 +27,6 @@ const {
|
|
|
25
27
|
findBy,
|
|
26
28
|
findAllBy
|
|
27
29
|
} = (0, _makeQueries.makeQueries)(queryAllByLabelText, getMissingError, getMultipleError);
|
|
28
|
-
|
|
29
30
|
const bindByLabelTextQueries = instance => ({
|
|
30
31
|
getByLabelText: getBy(instance),
|
|
31
32
|
getAllByLabelText: getAllBy(instance),
|
|
@@ -34,6 +35,5 @@ const bindByLabelTextQueries = instance => ({
|
|
|
34
35
|
findByLabelText: findBy(instance),
|
|
35
36
|
findAllByLabelText: findAllBy(instance)
|
|
36
37
|
});
|
|
37
|
-
|
|
38
38
|
exports.bindByLabelTextQueries = bindByLabelTextQueries;
|
|
39
39
|
//# sourceMappingURL=labelText.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"labelText.js","names":["
|
|
1
|
+
{"version":3,"file":"labelText.js","names":["getNodeByLabelText","node","text","options","exact","normalizer","matches","props","accessibilityLabel","queryAllByLabelText","instance","queryAllByLabelTextFn","queryOptions","findAll","type","getMultipleError","labelText","String","getMissingError","getBy","getAllBy","queryBy","queryAllBy","findBy","findAllBy","makeQueries","bindByLabelTextQueries","getByLabelText","getAllByLabelText","queryByLabelText","findByLabelText","findAllByLabelText"],"sources":["../../src/queries/labelText.ts"],"sourcesContent":["import type { ReactTestInstance } from 'react-test-renderer';\nimport { findAll } from '../helpers/findAll';\nimport { matches, TextMatch, TextMatchOptions } from '../matches';\nimport { makeQueries } from './makeQueries';\nimport type {\n FindAllByQuery,\n FindByQuery,\n GetAllByQuery,\n GetByQuery,\n QueryAllByQuery,\n QueryByQuery,\n} from './makeQueries';\nimport { CommonQueryOptions } from './options';\n\ntype ByLabelTextOptions = CommonQueryOptions & TextMatchOptions;\n\nconst getNodeByLabelText = (\n node: ReactTestInstance,\n text: TextMatch,\n options: TextMatchOptions = {}\n) => {\n const { exact, normalizer } = options;\n return matches(text, node.props.accessibilityLabel, normalizer, exact);\n};\n\nconst queryAllByLabelText = (\n instance: ReactTestInstance\n): ((\n text: TextMatch,\n queryOptions?: ByLabelTextOptions\n) => Array<ReactTestInstance>) =>\n function queryAllByLabelTextFn(text, queryOptions) {\n return findAll(\n instance,\n (node) =>\n typeof node.type === 'string' &&\n getNodeByLabelText(node, text, queryOptions),\n queryOptions\n );\n };\n\nconst getMultipleError = (labelText: TextMatch) =>\n `Found multiple elements with accessibilityLabel: ${String(labelText)} `;\nconst getMissingError = (labelText: TextMatch) =>\n `Unable to find an element with accessibilityLabel: ${String(labelText)}`;\n\nconst { getBy, getAllBy, queryBy, queryAllBy, findBy, findAllBy } = makeQueries(\n queryAllByLabelText,\n getMissingError,\n getMultipleError\n);\n\nexport type ByLabelTextQueries = {\n getByLabelText: GetByQuery<TextMatch, ByLabelTextOptions>;\n getAllByLabelText: GetAllByQuery<TextMatch, ByLabelTextOptions>;\n queryByLabelText: QueryByQuery<TextMatch, ByLabelTextOptions>;\n queryAllByLabelText: QueryAllByQuery<TextMatch, ByLabelTextOptions>;\n findByLabelText: FindByQuery<TextMatch, ByLabelTextOptions>;\n findAllByLabelText: FindAllByQuery<TextMatch, ByLabelTextOptions>;\n};\n\nexport const bindByLabelTextQueries = (\n instance: ReactTestInstance\n): ByLabelTextQueries => ({\n getByLabelText: getBy(instance),\n getAllByLabelText: getAllBy(instance),\n queryByLabelText: queryBy(instance),\n queryAllByLabelText: queryAllBy(instance),\n findByLabelText: findBy(instance),\n findAllByLabelText: findAllBy(instance),\n});\n"],"mappings":";;;;;;AACA;AACA;AACA;AAaA,MAAMA,kBAAkB,GAAG,CACzBC,IAAuB,EACvBC,IAAe,EACfC,OAAyB,GAAG,CAAC,CAAC,KAC3B;EACH,MAAM;IAAEC,KAAK;IAAEC;EAAW,CAAC,GAAGF,OAAO;EACrC,OAAO,IAAAG,gBAAO,EAACJ,IAAI,EAAED,IAAI,CAACM,KAAK,CAACC,kBAAkB,EAAEH,UAAU,EAAED,KAAK,CAAC;AACxE,CAAC;AAED,MAAMK,mBAAmB,GACvBC,QAA2B,IAK3B,SAASC,qBAAqB,CAACT,IAAI,EAAEU,YAAY,EAAE;EACjD,OAAO,IAAAC,gBAAO,EACZH,QAAQ,EACPT,IAAI,IACH,OAAOA,IAAI,CAACa,IAAI,KAAK,QAAQ,IAC7Bd,kBAAkB,CAACC,IAAI,EAAEC,IAAI,EAAEU,YAAY,CAAC,EAC9CA,YAAY,CACb;AACH,CAAC;AAEH,MAAMG,gBAAgB,GAAIC,SAAoB,IAC3C,oDAAmDC,MAAM,CAACD,SAAS,CAAE,GAAE;AAC1E,MAAME,eAAe,GAAIF,SAAoB,IAC1C,sDAAqDC,MAAM,CAACD,SAAS,CAAE,EAAC;AAE3E,MAAM;EAAEG,KAAK;EAAEC,QAAQ;EAAEC,OAAO;EAAEC,UAAU;EAAEC,MAAM;EAAEC;AAAU,CAAC,GAAG,IAAAC,wBAAW,EAC7EhB,mBAAmB,EACnBS,eAAe,EACfH,gBAAgB,CACjB;AAWM,MAAMW,sBAAsB,GACjChB,QAA2B,KACH;EACxBiB,cAAc,EAAER,KAAK,CAACT,QAAQ,CAAC;EAC/BkB,iBAAiB,EAAER,QAAQ,CAACV,QAAQ,CAAC;EACrCmB,gBAAgB,EAAER,OAAO,CAACX,QAAQ,CAAC;EACnCD,mBAAmB,EAAEa,UAAU,CAACZ,QAAQ,CAAC;EACzCoB,eAAe,EAAEP,MAAM,CAACb,QAAQ,CAAC;EACjCqB,kBAAkB,EAAEP,SAAS,CAACd,QAAQ;AACxC,CAAC,CAAC;AAAC"}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import type { ReactTestInstance } from 'react-test-renderer';
|
|
2
2
|
import type { WaitForOptions } from '../waitFor';
|
|
3
|
-
export
|
|
4
|
-
export
|
|
5
|
-
export
|
|
6
|
-
export
|
|
7
|
-
export
|
|
8
|
-
export
|
|
9
|
-
|
|
10
|
-
export
|
|
3
|
+
export type GetByQuery<Predicate, Options = void> = (predicate: Predicate, options?: Options) => ReactTestInstance;
|
|
4
|
+
export type GetAllByQuery<Predicate, Options = void> = (predicate: Predicate, options?: Options) => ReactTestInstance[];
|
|
5
|
+
export type QueryByQuery<Predicate, Options = void> = (predicate: Predicate, options?: Options) => ReactTestInstance | null;
|
|
6
|
+
export type QueryAllByQuery<Predicate, Options = void> = (predicate: Predicate, options?: Options) => ReactTestInstance[];
|
|
7
|
+
export type FindByQuery<Predicate, Options = void> = (predicate: Predicate, options?: Options & WaitForOptions, waitForOptions?: WaitForOptions) => Promise<ReactTestInstance>;
|
|
8
|
+
export type FindAllByQuery<Predicate, Options = void> = (predicate: Predicate, options?: Options & WaitForOptions, waitForOptions?: WaitForOptions) => Promise<ReactTestInstance[]>;
|
|
9
|
+
type UnboundQuery<Query> = (instance: ReactTestInstance) => Query;
|
|
10
|
+
export type UnboundQueries<Predicate, Options> = {
|
|
11
11
|
getBy: UnboundQuery<GetByQuery<Predicate, Options>>;
|
|
12
12
|
getAllBy: UnboundQuery<GetAllByQuery<Predicate, Options>>;
|
|
13
13
|
queryBy: UnboundQuery<QueryByQuery<Predicate, Options>>;
|
|
@@ -15,5 +15,5 @@ export declare type UnboundQueries<Predicate, Options> = {
|
|
|
15
15
|
findBy: UnboundQuery<FindByQuery<Predicate, Options>>;
|
|
16
16
|
findAllBy: UnboundQuery<FindAllByQuery<Predicate, Options>>;
|
|
17
17
|
};
|
|
18
|
-
export declare function makeQueries<Predicate, Options>(queryAllByQuery: UnboundQuery<QueryAllByQuery<Predicate, Options>>, getMissingError: (predicate: Predicate) => string, getMultipleError: (predicate: Predicate) => string): UnboundQueries<Predicate, Options>;
|
|
18
|
+
export declare function makeQueries<Predicate, Options>(queryAllByQuery: UnboundQuery<QueryAllByQuery<Predicate, Options>>, getMissingError: (predicate: Predicate, options?: Options) => string, getMultipleError: (predicate: Predicate, options?: Options) => string): UnboundQueries<Predicate, Options>;
|
|
19
19
|
export {};
|