@testing-library/react-native 11.5.0 → 11.5.2
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/build/act.d.ts +3 -1
- package/build/act.js +1 -13
- package/build/act.js.map +1 -1
- package/build/config.d.ts +21 -0
- package/build/config.js +16 -0
- package/build/config.js.map +1 -1
- package/build/fireEvent.js +3 -3
- package/build/fireEvent.js.map +1 -1
- package/build/helpers/accessiblity.d.ts +1 -0
- package/build/helpers/accessiblity.js +10 -0
- package/build/helpers/accessiblity.js.map +1 -1
- package/build/helpers/deprecation.d.ts +1 -0
- package/build/helpers/deprecation.js +29 -0
- package/build/helpers/deprecation.js.map +1 -0
- package/build/helpers/host-component-names.d.ts +3 -0
- package/build/helpers/host-component-names.js +62 -0
- package/build/helpers/host-component-names.js.map +1 -0
- package/build/helpers/matchers/matchLabelText.d.ts +3 -0
- package/build/helpers/matchers/matchLabelText.js +26 -0
- package/build/helpers/matchers/matchLabelText.js.map +1 -0
- package/build/helpers/matchers/matchTextContent.d.ts +7 -0
- package/build/helpers/matchers/matchTextContent.js +7 -5
- package/build/helpers/matchers/matchTextContent.js.map +1 -1
- package/build/helpers/query-name.d.ts +1 -0
- package/build/helpers/query-name.js +11 -0
- package/build/helpers/query-name.js.map +1 -0
- package/build/helpers/timers.d.ts +0 -2
- package/build/index.flow.js +1 -0
- package/build/queries/a11yState.js +15 -12
- package/build/queries/a11yState.js.map +1 -1
- package/build/queries/a11yValue.js +15 -12
- package/build/queries/a11yValue.js.map +1 -1
- package/build/queries/displayValue.js +5 -1
- package/build/queries/displayValue.js.map +1 -1
- package/build/queries/labelText.js +6 -11
- package/build/queries/labelText.js.map +1 -1
- package/build/queries/placeholderText.js +6 -2
- package/build/queries/placeholderText.js.map +1 -1
- package/build/queries/role.js +4 -2
- package/build/queries/role.js.map +1 -1
- package/build/queries/testId.js +1 -2
- package/build/queries/testId.js.map +1 -1
- package/build/queries/text.d.ts +1 -1
- package/build/queries/text.js +20 -6
- package/build/queries/text.js.map +1 -1
- package/build/render.d.ts +18 -18
- package/build/render.js +2 -0
- package/build/render.js.map +1 -1
- package/build/within.d.ts +18 -18
- package/package.json +13 -14
- package/typings/index.flow.js +1 -0
|
@@ -5,6 +5,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.bindByA11yValueQueries = void 0;
|
|
7
7
|
var _accessiblity = require("../helpers/accessiblity");
|
|
8
|
+
var _deprecation = require("../helpers/deprecation");
|
|
8
9
|
var _findAll = require("../helpers/findAll");
|
|
9
10
|
var _accessibilityValue = require("../helpers/matchers/accessibilityValue");
|
|
10
11
|
var _makeQueries = require("./makeQueries");
|
|
@@ -38,18 +39,20 @@ const bindByA11yValueQueries = instance => {
|
|
|
38
39
|
const findByA11yValue = findBy(instance);
|
|
39
40
|
const findAllByA11yValue = findAllBy(instance);
|
|
40
41
|
return {
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
42
|
+
...(0, _deprecation.deprecateQueries)({
|
|
43
|
+
getByA11yValue,
|
|
44
|
+
getAllByA11yValue,
|
|
45
|
+
queryByA11yValue,
|
|
46
|
+
queryAllByA11yValue,
|
|
47
|
+
findByA11yValue,
|
|
48
|
+
findAllByA11yValue,
|
|
49
|
+
getByAccessibilityValue: getByA11yValue,
|
|
50
|
+
getAllByAccessibilityValue: getAllByA11yValue,
|
|
51
|
+
queryByAccessibilityValue: queryByA11yValue,
|
|
52
|
+
queryAllByAccessibilityValue: queryAllByA11yValue,
|
|
53
|
+
findByAccessibilityValue: findByA11yValue,
|
|
54
|
+
findAllByAccessibilityValue: findAllByA11yValue
|
|
55
|
+
}, 'Use expect(...).toHaveAccessibilityValue(...) matcher from "@testing-library/jest-native" package or {queryPrefix}ByRole(role, { value: ... }) query instead.')
|
|
53
56
|
};
|
|
54
57
|
};
|
|
55
58
|
exports.bindByA11yValueQueries = bindByA11yValueQueries;
|
|
@@ -1 +1 @@
|
|
|
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
|
|
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","deprecateQueries","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 { deprecateQueries } from '../helpers/deprecation';\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 ...deprecateQueries(\n {\n getByA11yValue,\n getAllByA11yValue,\n queryByA11yValue,\n queryAllByA11yValue,\n findByA11yValue,\n findAllByA11yValue,\n getByAccessibilityValue: getByA11yValue,\n getAllByAccessibilityValue: getAllByA11yValue,\n queryByAccessibilityValue: queryByA11yValue,\n queryAllByAccessibilityValue: queryAllByA11yValue,\n findByAccessibilityValue: findByA11yValue,\n findAllByAccessibilityValue: findAllByA11yValue,\n },\n 'Use expect(...).toHaveAccessibilityValue(...) matcher from \"@testing-library/jest-native\" package or {queryPrefix}ByRole(role, { value: ... }) query instead.'\n ),\n };\n};\n"],"mappings":";;;;;;AACA;AACA;AACA;AACA;AAIA;AAWA,MAAMA,mBAAmB,GACvBC,QAA2B,IAK3B,SAASC,qBAAqB,CAACC,KAAK,EAAEC,YAAY,EAAE;EAClD,OAAO,IAAAC,gBAAO,EACZJ,QAAQ,EACPK,IAAI,IACH,OAAOA,IAAI,CAACC,IAAI,KAAK,QAAQ,IAAI,IAAAC,2CAAuB,EAACF,IAAI,EAAEH,KAAK,CAAC,EACvEC,YAAY,CACb;AACH,CAAC;AAEH,MAAMK,iBAAiB,GAAIC,OAAkC,IAAK;EAChE,MAAMC,MAAgB,GAAG,EAAE;EAE3BC,mCAAqB,CAACC,OAAO,CAAEC,QAAQ,IAAK;IAC1C,IAAIJ,OAAO,CAACI,QAAQ,CAAC,KAAKC,SAAS,EAAE;MACnCJ,MAAM,CAACK,IAAI,CAAE,GAAEF,QAAS,WAAUJ,OAAO,CAACI,QAAQ,CAAE,EAAC,CAAC;IACxD;EACF,CAAC,CAAC;EAEF,OAAOH,MAAM,CAACM,IAAI,CAAC,IAAI,CAAC;AAC1B,CAAC;AAED,MAAMC,gBAAgB,GAAIR,OAAkC,IACzD,gCAA+BD,iBAAiB,CAACC,OAAO,CAAE,EAAC;AAE9D,MAAMS,eAAe,GAAIT,OAAkC,IACxD,kCAAiCD,iBAAiB,CAACC,OAAO,CAAE,EAAC;AAEhE,MAAM;EAAEU,KAAK;EAAEC,QAAQ;EAAEC,OAAO;EAAEC,UAAU;EAAEC,MAAM;EAAEC;AAAU,CAAC,GAAG,IAAAC,wBAAW,EAC7E1B,mBAAmB,EACnBmB,eAAe,EACfD,gBAAgB,CACjB;AA6CM,MAAMS,sBAAsB,GACjC1B,QAA2B,IACJ;EACvB,MAAM2B,cAAc,GAAGR,KAAK,CAACnB,QAAQ,CAAC;EACtC,MAAM4B,iBAAiB,GAAGR,QAAQ,CAACpB,QAAQ,CAAC;EAC5C,MAAM6B,gBAAgB,GAAGR,OAAO,CAACrB,QAAQ,CAAC;EAC1C,MAAMD,mBAAmB,GAAGuB,UAAU,CAACtB,QAAQ,CAAC;EAChD,MAAM8B,eAAe,GAAGP,MAAM,CAACvB,QAAQ,CAAC;EACxC,MAAM+B,kBAAkB,GAAGP,SAAS,CAACxB,QAAQ,CAAC;EAE9C,OAAO;IACL,GAAG,IAAAgC,6BAAgB,EACjB;MACEL,cAAc;MACdC,iBAAiB;MACjBC,gBAAgB;MAChB9B,mBAAmB;MACnB+B,eAAe;MACfC,kBAAkB;MAClBE,uBAAuB,EAAEN,cAAc;MACvCO,0BAA0B,EAAEN,iBAAiB;MAC7CO,yBAAyB,EAAEN,gBAAgB;MAC3CO,4BAA4B,EAAErC,mBAAmB;MACjDsC,wBAAwB,EAAEP,eAAe;MACzCQ,2BAA2B,EAAEP;IAC/B,CAAC,EACD,+JAA+J;EAEnK,CAAC;AACH,CAAC;AAAC"}
|
|
@@ -8,6 +8,8 @@ var _reactNative = require("react-native");
|
|
|
8
8
|
var _filterNodeByType = require("../helpers/filterNodeByType");
|
|
9
9
|
var _findAll = require("../helpers/findAll");
|
|
10
10
|
var _matches = require("../matches");
|
|
11
|
+
var _config = require("../config");
|
|
12
|
+
var _hostComponentNames = require("../helpers/host-component-names");
|
|
11
13
|
var _makeQueries = require("./makeQueries");
|
|
12
14
|
const getTextInputNodeByDisplayValue = (node, value, options = {}) => {
|
|
13
15
|
const {
|
|
@@ -15,7 +17,9 @@ const getTextInputNodeByDisplayValue = (node, value, options = {}) => {
|
|
|
15
17
|
normalizer
|
|
16
18
|
} = options;
|
|
17
19
|
const nodeValue = node.props.value !== undefined ? node.props.value : node.props.defaultValue;
|
|
18
|
-
|
|
20
|
+
const shouldReturnHostTextInput = (0, _config.getConfig)().useBreakingChanges;
|
|
21
|
+
const textInputType = shouldReturnHostTextInput ? (0, _hostComponentNames.getHostComponentNames)().textInput : _reactNative.TextInput;
|
|
22
|
+
return (0, _filterNodeByType.filterNodeByType)(node, textInputType) && (0, _matches.matches)(value, nodeValue, normalizer, exact);
|
|
19
23
|
};
|
|
20
24
|
const queryAllByDisplayValue = instance => function queryAllByDisplayValueFn(displayValue, queryOptions) {
|
|
21
25
|
return (0, _findAll.findAll)(instance, node => getTextInputNodeByDisplayValue(node, displayValue, queryOptions), queryOptions);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"displayValue.js","names":["getTextInputNodeByDisplayValue","node","value","options","exact","normalizer","nodeValue","props","undefined","defaultValue","
|
|
1
|
+
{"version":3,"file":"displayValue.js","names":["getTextInputNodeByDisplayValue","node","value","options","exact","normalizer","nodeValue","props","undefined","defaultValue","shouldReturnHostTextInput","getConfig","useBreakingChanges","textInputType","getHostComponentNames","textInput","TextInput","filterNodeByType","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 { getConfig } from '../config';\nimport { getHostComponentNames } from '../helpers/host-component-names';\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 const shouldReturnHostTextInput = getConfig().useBreakingChanges;\n const textInputType = shouldReturnHostTextInput\n ? getHostComponentNames().textInput\n : TextInput;\n\n return (\n filterNodeByType(node, textInputType) &&\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: findAll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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"}
|
|
@@ -5,18 +5,13 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.bindByLabelTextQueries = void 0;
|
|
7
7
|
var _findAll = require("../helpers/findAll");
|
|
8
|
-
var
|
|
8
|
+
var _matchLabelText = require("../helpers/matchers/matchLabelText");
|
|
9
9
|
var _makeQueries = require("./makeQueries");
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
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);
|
|
19
|
-
};
|
|
10
|
+
function queryAllByLabelText(instance) {
|
|
11
|
+
return (text, queryOptions) => {
|
|
12
|
+
return (0, _findAll.findAll)(instance, node => typeof node.type === 'string' && (0, _matchLabelText.matchLabelText)(instance, node, text, queryOptions), queryOptions);
|
|
13
|
+
};
|
|
14
|
+
}
|
|
20
15
|
const getMultipleError = labelText => `Found multiple elements with accessibilityLabel: ${String(labelText)} `;
|
|
21
16
|
const getMissingError = labelText => `Unable to find an element with accessibilityLabel: ${String(labelText)}`;
|
|
22
17
|
const {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"labelText.js","names":["
|
|
1
|
+
{"version":3,"file":"labelText.js","names":["queryAllByLabelText","instance","text","queryOptions","findAll","node","type","matchLabelText","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 { TextMatch, TextMatchOptions } from '../matches';\nimport { matchLabelText } from '../helpers/matchers/matchLabelText';\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\nfunction queryAllByLabelText(instance: ReactTestInstance) {\n return (text: TextMatch, queryOptions?: ByLabelTextOptions) => {\n return findAll(\n instance,\n (node) =>\n typeof node.type === 'string' &&\n matchLabelText(instance, node, text, queryOptions),\n queryOptions\n );\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;AAEA;AACA;AAaA,SAASA,mBAAmB,CAACC,QAA2B,EAAE;EACxD,OAAO,CAACC,IAAe,EAAEC,YAAiC,KAAK;IAC7D,OAAO,IAAAC,gBAAO,EACZH,QAAQ,EACPI,IAAI,IACH,OAAOA,IAAI,CAACC,IAAI,KAAK,QAAQ,IAC7B,IAAAC,8BAAc,EAACN,QAAQ,EAAEI,IAAI,EAAEH,IAAI,EAAEC,YAAY,CAAC,EACpDA,YAAY,CACb;EACH,CAAC;AACH;AAEA,MAAMK,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,EAC7ElB,mBAAmB,EACnBW,eAAe,EACfH,gBAAgB,CACjB;AAWM,MAAMW,sBAAsB,GACjClB,QAA2B,KACH;EACxBmB,cAAc,EAAER,KAAK,CAACX,QAAQ,CAAC;EAC/BoB,iBAAiB,EAAER,QAAQ,CAACZ,QAAQ,CAAC;EACrCqB,gBAAgB,EAAER,OAAO,CAACb,QAAQ,CAAC;EACnCD,mBAAmB,EAAEe,UAAU,CAACd,QAAQ,CAAC;EACzCsB,eAAe,EAAEP,MAAM,CAACf,QAAQ,CAAC;EACjCuB,kBAAkB,EAAEP,SAAS,CAAChB,QAAQ;AACxC,CAAC,CAAC;AAAC"}
|
|
@@ -6,15 +6,19 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.bindByPlaceholderTextQueries = void 0;
|
|
7
7
|
var _reactNative = require("react-native");
|
|
8
8
|
var _findAll = require("../helpers/findAll");
|
|
9
|
-
var _filterNodeByType = require("../helpers/filterNodeByType");
|
|
10
9
|
var _matches = require("../matches");
|
|
10
|
+
var _config = require("../config");
|
|
11
|
+
var _filterNodeByType = require("../helpers/filterNodeByType");
|
|
12
|
+
var _hostComponentNames = require("../helpers/host-component-names");
|
|
11
13
|
var _makeQueries = require("./makeQueries");
|
|
12
14
|
const getTextInputNodeByPlaceholderText = (node, placeholder, options = {}) => {
|
|
13
15
|
const {
|
|
14
16
|
exact,
|
|
15
17
|
normalizer
|
|
16
18
|
} = options;
|
|
17
|
-
|
|
19
|
+
const shouldReturnHostTextInput = (0, _config.getConfig)().useBreakingChanges;
|
|
20
|
+
const textInputType = shouldReturnHostTextInput ? (0, _hostComponentNames.getHostComponentNames)().textInput : _reactNative.TextInput;
|
|
21
|
+
return (0, _filterNodeByType.filterNodeByType)(node, textInputType) && (0, _matches.matches)(placeholder, node.props.placeholder, normalizer, exact);
|
|
18
22
|
};
|
|
19
23
|
const queryAllByPlaceholderText = instance => function queryAllByPlaceholderFn(placeholder, queryOptions) {
|
|
20
24
|
return (0, _findAll.findAll)(instance, node => getTextInputNodeByPlaceholderText(node, placeholder, queryOptions), queryOptions);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"placeholderText.js","names":["getTextInputNodeByPlaceholderText","node","placeholder","options","exact","normalizer","
|
|
1
|
+
{"version":3,"file":"placeholderText.js","names":["getTextInputNodeByPlaceholderText","node","placeholder","options","exact","normalizer","shouldReturnHostTextInput","getConfig","useBreakingChanges","textInputType","getHostComponentNames","textInput","TextInput","filterNodeByType","matches","props","queryAllByPlaceholderText","instance","queryAllByPlaceholderFn","queryOptions","findAll","getMultipleError","String","getMissingError","getBy","getAllBy","queryBy","queryAllBy","findBy","findAllBy","makeQueries","bindByPlaceholderTextQueries","getByPlaceholderText","getAllByPlaceholderText","queryByPlaceholderText","findByPlaceholderText","findAllByPlaceholderText"],"sources":["../../src/queries/placeholderText.ts"],"sourcesContent":["import type { ReactTestInstance } from 'react-test-renderer';\nimport { TextInput } from 'react-native';\nimport { findAll } from '../helpers/findAll';\nimport { matches, TextMatch, TextMatchOptions } from '../matches';\nimport { getConfig } from '../config';\nimport { filterNodeByType } from '../helpers/filterNodeByType';\nimport { getHostComponentNames } from '../helpers/host-component-names';\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 ByPlaceholderTextOptions = CommonQueryOptions & TextMatchOptions;\n\nconst getTextInputNodeByPlaceholderText = (\n node: ReactTestInstance,\n placeholder: TextMatch,\n options: TextMatchOptions = {}\n) => {\n const { exact, normalizer } = options;\n const shouldReturnHostTextInput = getConfig().useBreakingChanges;\n const textInputType = shouldReturnHostTextInput\n ? getHostComponentNames().textInput\n : TextInput;\n\n return (\n filterNodeByType(node, textInputType) &&\n matches(placeholder, node.props.placeholder, normalizer, exact)\n );\n};\n\nconst queryAllByPlaceholderText = (\n instance: ReactTestInstance\n): ((\n placeholder: TextMatch,\n queryOptions?: ByPlaceholderTextOptions\n) => Array<ReactTestInstance>) =>\n function queryAllByPlaceholderFn(placeholder, queryOptions) {\n return findAll(\n instance,\n (node) =>\n getTextInputNodeByPlaceholderText(node, placeholder, queryOptions),\n queryOptions\n );\n };\n\nconst getMultipleError = (placeholder: TextMatch) =>\n `Found multiple elements with placeholder: ${String(placeholder)} `;\nconst getMissingError = (placeholder: TextMatch) =>\n `Unable to find an element with placeholder: ${String(placeholder)}`;\n\nconst { getBy, getAllBy, queryBy, queryAllBy, findBy, findAllBy } = makeQueries(\n queryAllByPlaceholderText,\n getMissingError,\n getMultipleError\n);\n\nexport type ByPlaceholderTextQueries = {\n getByPlaceholderText: GetByQuery<TextMatch, ByPlaceholderTextOptions>;\n getAllByPlaceholderText: GetAllByQuery<TextMatch, ByPlaceholderTextOptions>;\n queryByPlaceholderText: QueryByQuery<TextMatch, ByPlaceholderTextOptions>;\n queryAllByPlaceholderText: QueryAllByQuery<\n TextMatch,\n ByPlaceholderTextOptions\n >;\n findByPlaceholderText: FindByQuery<TextMatch, ByPlaceholderTextOptions>;\n findAllByPlaceholderText: FindAllByQuery<TextMatch, ByPlaceholderTextOptions>;\n};\n\nexport const bindByPlaceholderTextQueries = (\n instance: ReactTestInstance\n): ByPlaceholderTextQueries => ({\n getByPlaceholderText: getBy(instance),\n getAllByPlaceholderText: getAllBy(instance),\n queryByPlaceholderText: queryBy(instance),\n queryAllByPlaceholderText: queryAllBy(instance),\n findByPlaceholderText: findBy(instance),\n findAllByPlaceholderText: findAllBy(instance),\n});\n"],"mappings":";;;;;;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAaA,MAAMA,iCAAiC,GAAG,CACxCC,IAAuB,EACvBC,WAAsB,EACtBC,OAAyB,GAAG,CAAC,CAAC,KAC3B;EACH,MAAM;IAAEC,KAAK;IAAEC;EAAW,CAAC,GAAGF,OAAO;EACrC,MAAMG,yBAAyB,GAAG,IAAAC,iBAAS,GAAE,CAACC,kBAAkB;EAChE,MAAMC,aAAa,GAAGH,yBAAyB,GAC3C,IAAAI,yCAAqB,GAAE,CAACC,SAAS,GACjCC,sBAAS;EAEb,OACE,IAAAC,kCAAgB,EAACZ,IAAI,EAAEQ,aAAa,CAAC,IACrC,IAAAK,gBAAO,EAACZ,WAAW,EAAED,IAAI,CAACc,KAAK,CAACb,WAAW,EAAEG,UAAU,EAAED,KAAK,CAAC;AAEnE,CAAC;AAED,MAAMY,yBAAyB,GAC7BC,QAA2B,IAK3B,SAASC,uBAAuB,CAAChB,WAAW,EAAEiB,YAAY,EAAE;EAC1D,OAAO,IAAAC,gBAAO,EACZH,QAAQ,EACPhB,IAAI,IACHD,iCAAiC,CAACC,IAAI,EAAEC,WAAW,EAAEiB,YAAY,CAAC,EACpEA,YAAY,CACb;AACH,CAAC;AAEH,MAAME,gBAAgB,GAAInB,WAAsB,IAC7C,6CAA4CoB,MAAM,CAACpB,WAAW,CAAE,GAAE;AACrE,MAAMqB,eAAe,GAAIrB,WAAsB,IAC5C,+CAA8CoB,MAAM,CAACpB,WAAW,CAAE,EAAC;AAEtE,MAAM;EAAEsB,KAAK;EAAEC,QAAQ;EAAEC,OAAO;EAAEC,UAAU;EAAEC,MAAM;EAAEC;AAAU,CAAC,GAAG,IAAAC,wBAAW,EAC7Ed,yBAAyB,EACzBO,eAAe,EACfF,gBAAgB,CACjB;AAcM,MAAMU,4BAA4B,GACvCd,QAA2B,KACG;EAC9Be,oBAAoB,EAAER,KAAK,CAACP,QAAQ,CAAC;EACrCgB,uBAAuB,EAAER,QAAQ,CAACR,QAAQ,CAAC;EAC3CiB,sBAAsB,EAAER,OAAO,CAACT,QAAQ,CAAC;EACzCD,yBAAyB,EAAEW,UAAU,CAACV,QAAQ,CAAC;EAC/CkB,qBAAqB,EAAEP,MAAM,CAACX,QAAQ,CAAC;EACvCmB,wBAAwB,EAAEP,SAAS,CAACZ,QAAQ;AAC9C,CAAC,CAAC;AAAC"}
|
package/build/queries/role.js
CHANGED
|
@@ -10,6 +10,7 @@ var _accessibilityState = require("../helpers/matchers/accessibilityState");
|
|
|
10
10
|
var _accessibilityValue = require("../helpers/matchers/accessibilityValue");
|
|
11
11
|
var _matchStringProp = require("../helpers/matchers/matchStringProp");
|
|
12
12
|
var _within = require("../within");
|
|
13
|
+
var _config = require("../config");
|
|
13
14
|
var _makeQueries = require("./makeQueries");
|
|
14
15
|
const matchAccessibleNameIfNeeded = (node, name) => {
|
|
15
16
|
if (name == null) return true;
|
|
@@ -26,9 +27,10 @@ const matchAccessibilityValueIfNeeded = (node, value) => {
|
|
|
26
27
|
return value != null ? (0, _accessibilityValue.matchAccessibilityValue)(node, value) : true;
|
|
27
28
|
};
|
|
28
29
|
const queryAllByRole = instance => function queryAllByRoleFn(role, options) {
|
|
30
|
+
const shouldMatchOnlyAccessibilityElements = (0, _config.getConfig)().useBreakingChanges;
|
|
29
31
|
return (0, _findAll.findAll)(instance, node =>
|
|
30
|
-
// run the cheapest checks first, and early exit
|
|
31
|
-
typeof node.type === 'string' && (0, _matchStringProp.matchStringProp)(node.props.accessibilityRole, role) && matchAccessibleStateIfNeeded(node, options) && matchAccessibilityValueIfNeeded(node, options?.value) && matchAccessibleNameIfNeeded(node, options?.name), options);
|
|
32
|
+
// run the cheapest checks first, and early exit to avoid unneeded computations
|
|
33
|
+
typeof node.type === 'string' && (!shouldMatchOnlyAccessibilityElements || (0, _accessiblity.isAccessibilityElement)(node)) && (0, _matchStringProp.matchStringProp)(node.props.accessibilityRole, role) && matchAccessibleStateIfNeeded(node, options) && matchAccessibilityValueIfNeeded(node, options?.value) && matchAccessibleNameIfNeeded(node, options?.name), options);
|
|
32
34
|
};
|
|
33
35
|
const formatQueryParams = (role, options = {}) => {
|
|
34
36
|
const params = [`role: "${String(role)}"`];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"role.js","names":["matchAccessibleNameIfNeeded","node","name","queryAllByText","queryAllByLabelText","getQueriesForElement","length","matchAccessibleStateIfNeeded","options","matchAccessibilityState","matchAccessibilityValueIfNeeded","value","matchAccessibilityValue","queryAllByRole","instance","queryAllByRoleFn","role","findAll","type","matchStringProp","props","accessibilityRole","formatQueryParams","params","String","push","accessibilityStateKeys","forEach","stateKey","undefined","accessiblityValueKeys","valueKey","join","getMultipleError","getMissingError","getBy","getAllBy","queryBy","queryAllBy","findBy","findAllBy","makeQueries","bindByRoleQueries","getByRole","getAllByRole","queryByRole","findByRole","findAllByRole"],"sources":["../../src/queries/role.ts"],"sourcesContent":["import type { AccessibilityState } from 'react-native';\nimport type { ReactTestInstance } from 'react-test-renderer';\nimport {\n accessibilityStateKeys,\n accessiblityValueKeys,\n} from '../helpers/accessiblity';\nimport { findAll } from '../helpers/findAll';\nimport { matchAccessibilityState } from '../helpers/matchers/accessibilityState';\nimport {\n AccessibilityValueMatcher,\n matchAccessibilityValue,\n} from '../helpers/matchers/accessibilityValue';\nimport { matchStringProp } from '../helpers/matchers/matchStringProp';\nimport type { TextMatch } from '../matches';\nimport { getQueriesForElement } from '../within';\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 ByRoleOptions = CommonQueryOptions &\n AccessibilityState & {\n name?: TextMatch;\n value?: AccessibilityValueMatcher;\n };\n\nconst matchAccessibleNameIfNeeded = (\n node: ReactTestInstance,\n name?: TextMatch\n) => {\n if (name == null) return true;\n\n const { queryAllByText, queryAllByLabelText } = getQueriesForElement(node);\n return (\n queryAllByText(name).length > 0 || queryAllByLabelText(name).length > 0\n );\n};\n\nconst matchAccessibleStateIfNeeded = (\n node: ReactTestInstance,\n options?: ByRoleOptions\n) => {\n return options != null ? matchAccessibilityState(node, options) : true;\n};\n\nconst matchAccessibilityValueIfNeeded = (\n node: ReactTestInstance,\n value?: AccessibilityValueMatcher\n) => {\n return value != null ? matchAccessibilityValue(node, value) : true;\n};\n\nconst queryAllByRole = (\n instance: ReactTestInstance\n): ((role: TextMatch, options?: ByRoleOptions) => Array<ReactTestInstance>) =>\n function queryAllByRoleFn(role, options) {\n return findAll(\n instance,\n (node) =>\n // run the cheapest checks first, and early exit
|
|
1
|
+
{"version":3,"file":"role.js","names":["matchAccessibleNameIfNeeded","node","name","queryAllByText","queryAllByLabelText","getQueriesForElement","length","matchAccessibleStateIfNeeded","options","matchAccessibilityState","matchAccessibilityValueIfNeeded","value","matchAccessibilityValue","queryAllByRole","instance","queryAllByRoleFn","role","shouldMatchOnlyAccessibilityElements","getConfig","useBreakingChanges","findAll","type","isAccessibilityElement","matchStringProp","props","accessibilityRole","formatQueryParams","params","String","push","accessibilityStateKeys","forEach","stateKey","undefined","accessiblityValueKeys","valueKey","join","getMultipleError","getMissingError","getBy","getAllBy","queryBy","queryAllBy","findBy","findAllBy","makeQueries","bindByRoleQueries","getByRole","getAllByRole","queryByRole","findByRole","findAllByRole"],"sources":["../../src/queries/role.ts"],"sourcesContent":["import type { AccessibilityState } from 'react-native';\nimport type { ReactTestInstance } from 'react-test-renderer';\nimport {\n accessibilityStateKeys,\n accessiblityValueKeys,\n isAccessibilityElement,\n} from '../helpers/accessiblity';\nimport { findAll } from '../helpers/findAll';\nimport { matchAccessibilityState } from '../helpers/matchers/accessibilityState';\nimport {\n AccessibilityValueMatcher,\n matchAccessibilityValue,\n} from '../helpers/matchers/accessibilityValue';\nimport { matchStringProp } from '../helpers/matchers/matchStringProp';\nimport type { TextMatch } from '../matches';\nimport { getQueriesForElement } from '../within';\nimport { getConfig } from '../config';\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 ByRoleOptions = CommonQueryOptions &\n AccessibilityState & {\n name?: TextMatch;\n value?: AccessibilityValueMatcher;\n };\n\nconst matchAccessibleNameIfNeeded = (\n node: ReactTestInstance,\n name?: TextMatch\n) => {\n if (name == null) return true;\n\n const { queryAllByText, queryAllByLabelText } = getQueriesForElement(node);\n return (\n queryAllByText(name).length > 0 || queryAllByLabelText(name).length > 0\n );\n};\n\nconst matchAccessibleStateIfNeeded = (\n node: ReactTestInstance,\n options?: ByRoleOptions\n) => {\n return options != null ? matchAccessibilityState(node, options) : true;\n};\n\nconst matchAccessibilityValueIfNeeded = (\n node: ReactTestInstance,\n value?: AccessibilityValueMatcher\n) => {\n return value != null ? matchAccessibilityValue(node, value) : true;\n};\n\nconst queryAllByRole = (\n instance: ReactTestInstance\n): ((role: TextMatch, options?: ByRoleOptions) => Array<ReactTestInstance>) =>\n function queryAllByRoleFn(role, options) {\n const shouldMatchOnlyAccessibilityElements = getConfig().useBreakingChanges;\n\n return findAll(\n instance,\n (node) =>\n // run the cheapest checks first, and early exit to avoid unneeded computations\n typeof node.type === 'string' &&\n (!shouldMatchOnlyAccessibilityElements ||\n isAccessibilityElement(node)) &&\n matchStringProp(node.props.accessibilityRole, role) &&\n matchAccessibleStateIfNeeded(node, options) &&\n matchAccessibilityValueIfNeeded(node, options?.value) &&\n matchAccessibleNameIfNeeded(node, options?.name),\n options\n );\n };\n\nconst formatQueryParams = (role: TextMatch, options: ByRoleOptions = {}) => {\n const params = [`role: \"${String(role)}\"`];\n\n if (options.name) {\n params.push(`name: \"${String(options.name)}\"`);\n }\n\n accessibilityStateKeys.forEach((stateKey) => {\n if (options[stateKey] !== undefined) {\n params.push(`${stateKey} state: ${options[stateKey]}`);\n }\n });\n\n accessiblityValueKeys.forEach((valueKey) => {\n if (options?.value?.[valueKey] !== undefined) {\n params.push(`${valueKey} value: ${options?.value?.[valueKey]}`);\n }\n });\n\n return params.join(', ');\n};\n\nconst getMultipleError = (role: TextMatch, options?: ByRoleOptions) =>\n `Found multiple elements with ${formatQueryParams(role, options)}`;\n\nconst getMissingError = (role: TextMatch, options?: ByRoleOptions) =>\n `Unable to find an element with ${formatQueryParams(role, options)}`;\n\nconst { getBy, getAllBy, queryBy, queryAllBy, findBy, findAllBy } = makeQueries(\n queryAllByRole,\n getMissingError,\n getMultipleError\n);\n\nexport type ByRoleQueries = {\n getByRole: GetByQuery<TextMatch, ByRoleOptions>;\n getAllByRole: GetAllByQuery<TextMatch, ByRoleOptions>;\n queryByRole: QueryByQuery<TextMatch, ByRoleOptions>;\n queryAllByRole: QueryAllByQuery<TextMatch, ByRoleOptions>;\n findByRole: FindByQuery<TextMatch, ByRoleOptions>;\n findAllByRole: FindAllByQuery<TextMatch, ByRoleOptions>;\n};\n\nexport const bindByRoleQueries = (\n instance: ReactTestInstance\n): ByRoleQueries => ({\n getByRole: getBy(instance),\n getAllByRole: getAllBy(instance),\n queryByRole: queryBy(instance),\n queryAllByRole: queryAllBy(instance),\n findByRole: findBy(instance),\n findAllByRole: findAllBy(instance),\n});\n"],"mappings":";;;;;;AAEA;AAKA;AACA;AACA;AAIA;AAEA;AACA;AACA;AAiBA,MAAMA,2BAA2B,GAAG,CAClCC,IAAuB,EACvBC,IAAgB,KACb;EACH,IAAIA,IAAI,IAAI,IAAI,EAAE,OAAO,IAAI;EAE7B,MAAM;IAAEC,cAAc;IAAEC;EAAoB,CAAC,GAAG,IAAAC,4BAAoB,EAACJ,IAAI,CAAC;EAC1E,OACEE,cAAc,CAACD,IAAI,CAAC,CAACI,MAAM,GAAG,CAAC,IAAIF,mBAAmB,CAACF,IAAI,CAAC,CAACI,MAAM,GAAG,CAAC;AAE3E,CAAC;AAED,MAAMC,4BAA4B,GAAG,CACnCN,IAAuB,EACvBO,OAAuB,KACpB;EACH,OAAOA,OAAO,IAAI,IAAI,GAAG,IAAAC,2CAAuB,EAACR,IAAI,EAAEO,OAAO,CAAC,GAAG,IAAI;AACxE,CAAC;AAED,MAAME,+BAA+B,GAAG,CACtCT,IAAuB,EACvBU,KAAiC,KAC9B;EACH,OAAOA,KAAK,IAAI,IAAI,GAAG,IAAAC,2CAAuB,EAACX,IAAI,EAAEU,KAAK,CAAC,GAAG,IAAI;AACpE,CAAC;AAED,MAAME,cAAc,GAClBC,QAA2B,IAE3B,SAASC,gBAAgB,CAACC,IAAI,EAAER,OAAO,EAAE;EACvC,MAAMS,oCAAoC,GAAG,IAAAC,iBAAS,GAAE,CAACC,kBAAkB;EAE3E,OAAO,IAAAC,gBAAO,EACZN,QAAQ,EACPb,IAAI;EACH;EACA,OAAOA,IAAI,CAACoB,IAAI,KAAK,QAAQ,KAC5B,CAACJ,oCAAoC,IACpC,IAAAK,oCAAsB,EAACrB,IAAI,CAAC,CAAC,IAC/B,IAAAsB,gCAAe,EAACtB,IAAI,CAACuB,KAAK,CAACC,i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iCkB,iBAAiB,CAACV,IAAI,EAAER,OAAO,CAAE,EAAC;AAEtE,MAAM;EAAE+B,KAAK;EAAEC,QAAQ;EAAEC,OAAO;EAAEC,UAAU;EAAEC,MAAM;EAAEC;AAAU,CAAC,GAAG,IAAAC,wBAAW,EAC7EhC,cAAc,EACdyB,eAAe,EACfD,gBAAgB,CACjB;AAWM,MAAMS,iBAAiB,GAC5BhC,QAA2B,KACR;EACnBiC,SAAS,EAAER,KAAK,CAACzB,QAAQ,CAAC;EAC1BkC,YAAY,EAAER,QAAQ,CAAC1B,QAAQ,CAAC;EAChCmC,WAAW,EAAER,OAAO,CAAC3B,QAAQ,CAAC;EAC9BD,cAAc,EAAE6B,UAAU,CAAC5B,QAAQ,CAAC;EACpCoC,UAAU,EAAEP,MAAM,CAAC7B,QAAQ,CAAC;EAC5BqC,aAAa,EAAEP,SAAS,CAAC9B,QAAQ;AACnC,CAAC,CAAC;AAAC"}
|
package/build/queries/testId.js
CHANGED
|
@@ -15,8 +15,7 @@ const getNodeByTestId = (node, testID, options = {}) => {
|
|
|
15
15
|
return (0, _matches.matches)(testID, node.props.testID, normalizer, exact);
|
|
16
16
|
};
|
|
17
17
|
const queryAllByTestId = instance => function queryAllByTestIdFn(testId, queryOptions) {
|
|
18
|
-
|
|
19
|
-
return results.filter(element => typeof element.type === 'string');
|
|
18
|
+
return (0, _findAll.findAll)(instance, node => typeof node.type === 'string' && getNodeByTestId(node, testId, queryOptions), queryOptions);
|
|
20
19
|
};
|
|
21
20
|
const getMultipleError = testId => `Found multiple elements with testID: ${String(testId)}`;
|
|
22
21
|
const getMissingError = testId => `Unable to find an element with testID: ${String(testId)}`;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"testId.js","names":["getNodeByTestId","node","testID","options","exact","normalizer","matches","props","queryAllByTestId","instance","queryAllByTestIdFn","testId","queryOptions","
|
|
1
|
+
{"version":3,"file":"testId.js","names":["getNodeByTestId","node","testID","options","exact","normalizer","matches","props","queryAllByTestId","instance","queryAllByTestIdFn","testId","queryOptions","findAll","type","getMultipleError","String","getMissingError","getBy","getAllBy","queryBy","queryAllBy","findBy","findAllBy","makeQueries","bindByTestIdQueries","getByTestId","getAllByTestId","queryByTestId","findByTestId","findAllByTestId"],"sources":["../../src/queries/testId.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 type { CommonQueryOptions } from './options';\n\ntype ByTestIdOptions = CommonQueryOptions & TextMatchOptions;\n\nconst getNodeByTestId = (\n node: ReactTestInstance,\n testID: TextMatch,\n options: TextMatchOptions = {}\n) => {\n const { exact, normalizer } = options;\n return matches(testID, node.props.testID, normalizer, exact);\n};\n\nconst queryAllByTestId = (\n instance: ReactTestInstance\n): ((\n testId: TextMatch,\n queryOptions?: ByTestIdOptions\n) => Array<ReactTestInstance>) =>\n function queryAllByTestIdFn(testId, queryOptions) {\n return findAll(\n instance,\n (node) =>\n typeof node.type === 'string' &&\n getNodeByTestId(node, testId, queryOptions),\n queryOptions\n );\n };\n\nconst getMultipleError = (testId: TextMatch) =>\n `Found multiple elements with testID: ${String(testId)}`;\nconst getMissingError = (testId: TextMatch) =>\n `Unable to find an element with testID: ${String(testId)}`;\n\nconst { getBy, getAllBy, queryBy, queryAllBy, findBy, findAllBy } = makeQueries(\n queryAllByTestId,\n getMissingError,\n getMultipleError\n);\n\nexport type ByTestIdQueries = {\n getByTestId: GetByQuery<TextMatch, ByTestIdOptions>;\n getAllByTestId: GetAllByQuery<TextMatch, ByTestIdOptions>;\n queryByTestId: QueryByQuery<TextMatch, ByTestIdOptions>;\n queryAllByTestId: QueryAllByQuery<TextMatch, ByTestIdOptions>;\n findByTestId: FindByQuery<TextMatch, ByTestIdOptions>;\n findAllByTestId: FindAllByQuery<TextMatch, ByTestIdOptions>;\n};\n\nexport const bindByTestIdQueries = (\n instance: ReactTestInstance\n): ByTestIdQueries => ({\n getByTestId: getBy(instance),\n getAllByTestId: getAllBy(instance),\n queryByTestId: queryBy(instance),\n queryAllByTestId: queryAllBy(instance),\n findByTestId: findBy(instance),\n findAllByTestId: findAllBy(instance),\n});\n"],"mappings":";;;;;;AACA;AACA;AACA;AAaA,MAAMA,eAAe,GAAG,CACtBC,IAAuB,EACvBC,MAAiB,EACjBC,OAAyB,GAAG,CAAC,CAAC,KAC3B;EACH,MAAM;IAAEC,KAAK;IAAEC;EAAW,CAAC,GAAGF,OAAO;EACrC,OAAO,IAAAG,gBAAO,EAACJ,MAAM,EAAED,IAAI,CAACM,KAAK,CAACL,MAAM,EAAEG,UAAU,EAAED,KAAK,CAAC;AAC9D,CAAC;AAED,MAAMI,gBAAgB,GACpBC,QAA2B,IAK3B,SAASC,kBAAkB,CAACC,MAAM,EAAEC,YAAY,EAAE;EAChD,OAAO,IAAAC,gBAAO,EACZJ,QAAQ,EACPR,IAAI,IACH,OAAOA,IAAI,CAACa,IAAI,KAAK,QAAQ,IAC7Bd,eAAe,CAACC,IAAI,EAAEU,MAAM,EAAEC,YAAY,CAAC,EAC7CA,YAAY,CACb;AACH,CAAC;AAEH,MAAMG,gBAAgB,GAAIJ,MAAiB,IACxC,wCAAuCK,MAAM,CAACL,MAAM,CAAE,EAAC;AAC1D,MAAMM,eAAe,GAAIN,MAAiB,IACvC,0CAAyCK,MAAM,CAACL,MAAM,CAAE,EAAC;AAE5D,MAAM;EAAEO,KAAK;EAAEC,QAAQ;EAAEC,OAAO;EAAEC,UAAU;EAAEC,MAAM;EAAEC;AAAU,CAAC,GAAG,IAAAC,wBAAW,EAC7EhB,gBAAgB,EAChBS,eAAe,EACfF,gBAAgB,CACjB;AAWM,MAAMU,mBAAmB,GAC9BhB,QAA2B,KACN;EACrBiB,WAAW,EAAER,KAAK,CAACT,QAAQ,CAAC;EAC5BkB,cAAc,EAAER,QAAQ,CAACV,QAAQ,CAAC;EAClCmB,aAAa,EAAER,OAAO,CAACX,QAAQ,CAAC;EAChCD,gBAAgB,EAAEa,UAAU,CAACZ,QAAQ,CAAC;EACtCoB,YAAY,EAAEP,MAAM,CAACb,QAAQ,CAAC;EAC9BqB,eAAe,EAAEP,SAAS,CAACd,QAAQ;AACrC,CAAC,CAAC;AAAC"}
|
package/build/queries/text.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { ReactTestInstance } from 'react-test-renderer';
|
|
2
2
|
import { TextMatch, TextMatchOptions } from '../matches';
|
|
3
3
|
import type { FindAllByQuery, FindByQuery, GetAllByQuery, GetByQuery, QueryAllByQuery, QueryByQuery } from './makeQueries';
|
|
4
|
-
import { CommonQueryOptions } from './options';
|
|
4
|
+
import type { CommonQueryOptions } from './options';
|
|
5
5
|
type ByTextOptions = CommonQueryOptions & TextMatchOptions;
|
|
6
6
|
export type ByTextQueries = {
|
|
7
7
|
getByText: GetByQuery<TextMatch, ByTextOptions>;
|
package/build/queries/text.js
CHANGED
|
@@ -5,20 +5,34 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.bindByTextQueries = void 0;
|
|
7
7
|
var _reactNative = require("react-native");
|
|
8
|
+
var _config = require("../config");
|
|
8
9
|
var _componentTree = require("../helpers/component-tree");
|
|
10
|
+
var _filterNodeByType = require("../helpers/filterNodeByType");
|
|
9
11
|
var _findAll = require("../helpers/findAll");
|
|
12
|
+
var _hostComponentNames = require("../helpers/host-component-names");
|
|
10
13
|
var _matchTextContent = require("../helpers/matchers/matchTextContent");
|
|
11
14
|
var _makeQueries = require("./makeQueries");
|
|
12
|
-
const queryAllByText = instance => function queryAllByTextFn(text, options) {
|
|
13
|
-
const
|
|
14
|
-
|
|
15
|
-
|
|
15
|
+
const queryAllByText = instance => function queryAllByTextFn(text, options = {}) {
|
|
16
|
+
const shouldReturnHostText = (0, _config.getConfig)().useBreakingChanges;
|
|
17
|
+
|
|
18
|
+
// Legacy version: return composite Text
|
|
19
|
+
if (!shouldReturnHostText) {
|
|
20
|
+
const baseInstance = (0, _componentTree.isHostElementForType)(instance, _reactNative.Text) ? (0, _componentTree.getCompositeParentOfType)(instance, _reactNative.Text) : instance;
|
|
21
|
+
if (!baseInstance) {
|
|
22
|
+
return [];
|
|
23
|
+
}
|
|
24
|
+
const results = (0, _findAll.findAll)(baseInstance, node => (0, _filterNodeByType.filterNodeByType)(node, _reactNative.Text) && (0, _matchTextContent.matchTextContent)(node, text, options), {
|
|
25
|
+
...options,
|
|
26
|
+
matchDeepestOnly: true
|
|
27
|
+
});
|
|
28
|
+
return results;
|
|
16
29
|
}
|
|
17
|
-
|
|
30
|
+
|
|
31
|
+
// vNext version: returns host Text
|
|
32
|
+
return (0, _findAll.findAll)(instance, node => (0, _filterNodeByType.filterNodeByType)(node, (0, _hostComponentNames.getHostComponentNames)().text) && (0, _matchTextContent.matchTextContent)(node, text, options), {
|
|
18
33
|
...options,
|
|
19
34
|
matchDeepestOnly: true
|
|
20
35
|
});
|
|
21
|
-
return results;
|
|
22
36
|
};
|
|
23
37
|
const getMultipleError = text => `Found multiple elements with text: ${String(text)}`;
|
|
24
38
|
const getMissingError = text => `Unable to find an element with text: ${String(text)}`;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"text.js","names":["queryAllByText","instance","queryAllByTextFn","text","options","baseInstance","isHostElementForType","Text","getCompositeParentOfType","results","findAll","node","matchTextContent","matchDeepestOnly","getMultipleError","String","getMissingError","getBy","getAllBy","queryBy","queryAllBy","findBy","findAllBy","makeQueries","bindByTextQueries","getByText","getAllByText","queryByText","findByText","findAllByText"],"sources":["../../src/queries/text.ts"],"sourcesContent":["import type { ReactTestInstance } from 'react-test-renderer';\nimport { Text } from 'react-native';\nimport {\n
|
|
1
|
+
{"version":3,"file":"text.js","names":["queryAllByText","instance","queryAllByTextFn","text","options","shouldReturnHostText","getConfig","useBreakingChanges","baseInstance","isHostElementForType","Text","getCompositeParentOfType","results","findAll","node","filterNodeByType","matchTextContent","matchDeepestOnly","getHostComponentNames","getMultipleError","String","getMissingError","getBy","getAllBy","queryBy","queryAllBy","findBy","findAllBy","makeQueries","bindByTextQueries","getByText","getAllByText","queryByText","findByText","findAllByText"],"sources":["../../src/queries/text.ts"],"sourcesContent":["import type { ReactTestInstance } from 'react-test-renderer';\nimport { Text } from 'react-native';\nimport { getConfig } from '../config';\nimport {\n getCompositeParentOfType,\n isHostElementForType,\n} from '../helpers/component-tree';\nimport { filterNodeByType } from '../helpers/filterNodeByType';\nimport { findAll } from '../helpers/findAll';\nimport { getHostComponentNames } from '../helpers/host-component-names';\nimport { matchTextContent } from '../helpers/matchers/matchTextContent';\nimport { 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 ByTextOptions = CommonQueryOptions & TextMatchOptions;\n\nconst queryAllByText = (\n instance: ReactTestInstance\n): ((text: TextMatch, options?: ByTextOptions) => Array<ReactTestInstance>) =>\n function queryAllByTextFn(text, options = {}) {\n const shouldReturnHostText = getConfig().useBreakingChanges;\n\n // Legacy version: return composite Text\n if (!shouldReturnHostText) {\n const baseInstance = isHostElementForType(instance, Text)\n ? getCompositeParentOfType(instance, Text)\n : instance;\n\n if (!baseInstance) {\n return [];\n }\n\n const results = findAll(\n baseInstance,\n (node) =>\n filterNodeByType(node, Text) && matchTextContent(node, text, options),\n { ...options, matchDeepestOnly: true }\n );\n\n return results;\n }\n\n // vNext version: returns host Text\n return findAll(\n instance,\n (node) =>\n filterNodeByType(node, getHostComponentNames().text) &&\n matchTextContent(node, text, options),\n {\n ...options,\n matchDeepestOnly: true,\n }\n );\n };\n\nconst getMultipleError = (text: TextMatch) =>\n `Found multiple elements with text: ${String(text)}`;\n\nconst getMissingError = (text: TextMatch) =>\n `Unable to find an element with text: ${String(text)}`;\n\nconst { getBy, getAllBy, queryBy, queryAllBy, findBy, findAllBy } = makeQueries(\n queryAllByText,\n getMissingError,\n getMultipleError\n);\n\nexport type ByTextQueries = {\n getByText: GetByQuery<TextMatch, ByTextOptions>;\n getAllByText: GetAllByQuery<TextMatch, ByTextOptions>;\n queryByText: QueryByQuery<TextMatch, ByTextOptions>;\n queryAllByText: QueryAllByQuery<TextMatch, ByTextOptions>;\n findByText: FindByQuery<TextMatch, ByTextOptions>;\n findAllByText: FindAllByQuery<TextMatch, ByTextOptions>;\n};\n\nexport const bindByTextQueries = (\n instance: ReactTestInstance\n): ByTextQueries => ({\n getByText: getBy(instance),\n getAllByText: getAllBy(instance),\n queryByText: queryBy(instance),\n queryAllByText: queryAllBy(instance),\n findByText: findBy(instance),\n findAllByText: findAllBy(instance),\n});\n"],"mappings":";;;;;;AACA;AACA;AACA;AAIA;AACA;AACA;AACA;AAEA;AAaA,MAAMA,cAAc,GAClBC,QAA2B,IAE3B,SAASC,gBAAgB,CAACC,IAAI,EAAEC,OAAO,GAAG,CAAC,CAAC,EAAE;EAC5C,MAAMC,oBAAoB,GAAG,IAAAC,iBAAS,GAAE,CAACC,kBAAkB;;EAE3D;EACA,IAAI,CAACF,oBAAoB,EAAE;IACzB,MAAMG,YAAY,GAAG,IAAAC,mCAAoB,EAACR,QAAQ,EAAES,iBAAI,CAAC,GACrD,IAAAC,uCAAwB,EAACV,QAAQ,EAAES,iBAAI,CAAC,GACxCT,QAAQ;IAEZ,IAAI,CAACO,YAAY,EAAE;MACjB,OAAO,EAAE;IACX;IAEA,MAAMI,OAAO,GAAG,IAAAC,gBAAO,EACrBL,YAAY,EACXM,IAAI,IACH,IAAAC,kCAAgB,EAACD,IAAI,EAAEJ,iBAAI,CAAC,IAAI,IAAAM,kCAAgB,EAACF,IAAI,EAAEX,IAAI,EAAEC,OAAO,CAAC,EACvE;MAAE,GAAGA,OAAO;MAAEa,gBAAgB,EAAE;IAAK,CAAC,CACvC;IAED,OAAOL,OAAO;EAChB;;EAEA;EACA,OAAO,IAAAC,gBAAO,EACZZ,QAAQ,EACPa,IAAI,IACH,IAAAC,kCAAgB,EAACD,IAAI,EAAE,IAAAI,yCAAqB,GAAE,CAACf,IAAI,CAAC,IACpD,IAAAa,kCAAgB,EAACF,IAAI,EAAEX,IAAI,EAAEC,OAAO,CAAC,EACvC;IACE,GAAGA,OAAO;IACVa,gBAAgB,EAAE;EACpB,CAAC,CACF;AACH,CAAC;AAEH,MAAME,gBAAgB,GAAIhB,IAAe,IACtC,sCAAqCiB,MAAM,CAACjB,IAAI,CAAE,EAAC;AAEtD,MAAMkB,eAAe,GAAIlB,IAAe,IACrC,wCAAuCiB,MAAM,CAACjB,IAAI,CAAE,EAAC;AAExD,MAAM;EAAEmB,KAAK;EAAEC,QAAQ;EAAEC,OAAO;EAAEC,UAAU;EAAEC,MAAM;EAAEC;AAAU,CAAC,GAAG,IAAAC,wBAAW,EAC7E5B,cAAc,EACdqB,eAAe,EACfF,gBAAgB,CACjB;AAWM,MAAMU,iBAAiB,GAC5B5B,QAA2B,KACR;EACnB6B,SAAS,EAAER,KAAK,CAACrB,QAAQ,CAAC;EAC1B8B,YAAY,EAAER,QAAQ,CAACtB,QAAQ,CAAC;EAChC+B,WAAW,EAAER,OAAO,CAACvB,QAAQ,CAAC;EAC9BD,cAAc,EAAEyB,UAAU,CAACxB,QAAQ,CAAC;EACpCgC,UAAU,EAAEP,MAAM,CAACzB,QAAQ,CAAC;EAC5BiC,aAAa,EAAEP,SAAS,CAAC1B,QAAQ;AACnC,CAAC,CAAC;AAAC"}
|
package/build/render.d.ts
CHANGED
|
@@ -46,39 +46,39 @@ export default function render<T>(component: React.ReactElement<T>, { wrapper: W
|
|
|
46
46
|
queryAllByAccessibilityValue: import("./queries/makeQueries").QueryAllByQuery<import("./helpers/matchers/accessibilityValue").AccessibilityValueMatcher, import("./queries/options").CommonQueryOptions>;
|
|
47
47
|
findByAccessibilityValue: import("./queries/makeQueries").FindByQuery<import("./helpers/matchers/accessibilityValue").AccessibilityValueMatcher, import("./queries/options").CommonQueryOptions>;
|
|
48
48
|
findAllByAccessibilityValue: import("./queries/makeQueries").FindAllByQuery<import("./helpers/matchers/accessibilityValue").AccessibilityValueMatcher, import("./queries/options").CommonQueryOptions>;
|
|
49
|
-
getByA11yState: import("./queries/makeQueries").GetByQuery<import("react-native").AccessibilityState, import("./queries/options").CommonQueryOptions>;
|
|
50
|
-
getAllByA11yState: import("./queries/makeQueries").GetAllByQuery<import("react-native").AccessibilityState, import("./queries/options").CommonQueryOptions>;
|
|
51
|
-
queryByA11yState: import("./queries/makeQueries").QueryByQuery<import("react-native").AccessibilityState, import("./queries/options").CommonQueryOptions>;
|
|
52
|
-
queryAllByA11yState: import("./queries/makeQueries").QueryAllByQuery<import("react-native").AccessibilityState, import("./queries/options").CommonQueryOptions>;
|
|
53
|
-
findByA11yState: import("./queries/makeQueries").FindByQuery<import("react-native").AccessibilityState, import("./queries/options").CommonQueryOptions>;
|
|
54
|
-
findAllByA11yState: import("./queries/makeQueries").FindAllByQuery<import("react-native").AccessibilityState, import("./queries/options").CommonQueryOptions>;
|
|
55
|
-
getByAccessibilityState: import("./queries/makeQueries").GetByQuery<import("react-native").AccessibilityState, import("./queries/options").CommonQueryOptions>;
|
|
56
|
-
getAllByAccessibilityState: import("./queries/makeQueries").GetAllByQuery<import("react-native").AccessibilityState, import("./queries/options").CommonQueryOptions>;
|
|
57
|
-
queryByAccessibilityState: import("./queries/makeQueries").QueryByQuery<import("react-native").AccessibilityState, import("./queries/options").CommonQueryOptions>;
|
|
58
|
-
queryAllByAccessibilityState: import("./queries/makeQueries").QueryAllByQuery<import("react-native").AccessibilityState, import("./queries/options").CommonQueryOptions>;
|
|
59
|
-
findByAccessibilityState: import("./queries/makeQueries").FindByQuery<import("react-native").AccessibilityState, import("./queries/options").CommonQueryOptions>;
|
|
60
|
-
findAllByAccessibilityState: import("./queries/makeQueries").FindAllByQuery<import("react-native").AccessibilityState, import("./queries/options").CommonQueryOptions>;
|
|
61
|
-
getByRole: import("./queries/makeQueries").GetByQuery<import("./matches").TextMatch, import("./queries/options").CommonQueryOptions & import("react-native").AccessibilityState & {
|
|
49
|
+
getByA11yState: import("./queries/makeQueries").GetByQuery<import("react-native/types").AccessibilityState, import("./queries/options").CommonQueryOptions>;
|
|
50
|
+
getAllByA11yState: import("./queries/makeQueries").GetAllByQuery<import("react-native/types").AccessibilityState, import("./queries/options").CommonQueryOptions>;
|
|
51
|
+
queryByA11yState: import("./queries/makeQueries").QueryByQuery<import("react-native/types").AccessibilityState, import("./queries/options").CommonQueryOptions>;
|
|
52
|
+
queryAllByA11yState: import("./queries/makeQueries").QueryAllByQuery<import("react-native/types").AccessibilityState, import("./queries/options").CommonQueryOptions>;
|
|
53
|
+
findByA11yState: import("./queries/makeQueries").FindByQuery<import("react-native/types").AccessibilityState, import("./queries/options").CommonQueryOptions>;
|
|
54
|
+
findAllByA11yState: import("./queries/makeQueries").FindAllByQuery<import("react-native/types").AccessibilityState, import("./queries/options").CommonQueryOptions>;
|
|
55
|
+
getByAccessibilityState: import("./queries/makeQueries").GetByQuery<import("react-native/types").AccessibilityState, import("./queries/options").CommonQueryOptions>;
|
|
56
|
+
getAllByAccessibilityState: import("./queries/makeQueries").GetAllByQuery<import("react-native/types").AccessibilityState, import("./queries/options").CommonQueryOptions>;
|
|
57
|
+
queryByAccessibilityState: import("./queries/makeQueries").QueryByQuery<import("react-native/types").AccessibilityState, import("./queries/options").CommonQueryOptions>;
|
|
58
|
+
queryAllByAccessibilityState: import("./queries/makeQueries").QueryAllByQuery<import("react-native/types").AccessibilityState, import("./queries/options").CommonQueryOptions>;
|
|
59
|
+
findByAccessibilityState: import("./queries/makeQueries").FindByQuery<import("react-native/types").AccessibilityState, import("./queries/options").CommonQueryOptions>;
|
|
60
|
+
findAllByAccessibilityState: import("./queries/makeQueries").FindAllByQuery<import("react-native/types").AccessibilityState, import("./queries/options").CommonQueryOptions>;
|
|
61
|
+
getByRole: import("./queries/makeQueries").GetByQuery<import("./matches").TextMatch, import("./queries/options").CommonQueryOptions & import("react-native/types").AccessibilityState & {
|
|
62
62
|
name?: import("./matches").TextMatch | undefined;
|
|
63
63
|
value?: import("./helpers/matchers/accessibilityValue").AccessibilityValueMatcher | undefined;
|
|
64
64
|
}>;
|
|
65
|
-
getAllByRole: import("./queries/makeQueries").GetAllByQuery<import("./matches").TextMatch, import("./queries/options").CommonQueryOptions & import("react-native").AccessibilityState & {
|
|
65
|
+
getAllByRole: import("./queries/makeQueries").GetAllByQuery<import("./matches").TextMatch, import("./queries/options").CommonQueryOptions & import("react-native/types").AccessibilityState & {
|
|
66
66
|
name?: import("./matches").TextMatch | undefined;
|
|
67
67
|
value?: import("./helpers/matchers/accessibilityValue").AccessibilityValueMatcher | undefined;
|
|
68
68
|
}>;
|
|
69
|
-
queryByRole: import("./queries/makeQueries").QueryByQuery<import("./matches").TextMatch, import("./queries/options").CommonQueryOptions & import("react-native").AccessibilityState & {
|
|
69
|
+
queryByRole: import("./queries/makeQueries").QueryByQuery<import("./matches").TextMatch, import("./queries/options").CommonQueryOptions & import("react-native/types").AccessibilityState & {
|
|
70
70
|
name?: import("./matches").TextMatch | undefined;
|
|
71
71
|
value?: import("./helpers/matchers/accessibilityValue").AccessibilityValueMatcher | undefined;
|
|
72
72
|
}>;
|
|
73
|
-
queryAllByRole: import("./queries/makeQueries").QueryAllByQuery<import("./matches").TextMatch, import("./queries/options").CommonQueryOptions & import("react-native").AccessibilityState & {
|
|
73
|
+
queryAllByRole: import("./queries/makeQueries").QueryAllByQuery<import("./matches").TextMatch, import("./queries/options").CommonQueryOptions & import("react-native/types").AccessibilityState & {
|
|
74
74
|
name?: import("./matches").TextMatch | undefined;
|
|
75
75
|
value?: import("./helpers/matchers/accessibilityValue").AccessibilityValueMatcher | undefined;
|
|
76
76
|
}>;
|
|
77
|
-
findByRole: import("./queries/makeQueries").FindByQuery<import("./matches").TextMatch, import("./queries/options").CommonQueryOptions & import("react-native").AccessibilityState & {
|
|
77
|
+
findByRole: import("./queries/makeQueries").FindByQuery<import("./matches").TextMatch, import("./queries/options").CommonQueryOptions & import("react-native/types").AccessibilityState & {
|
|
78
78
|
name?: import("./matches").TextMatch | undefined;
|
|
79
79
|
value?: import("./helpers/matchers/accessibilityValue").AccessibilityValueMatcher | undefined;
|
|
80
80
|
}>;
|
|
81
|
-
findAllByRole: import("./queries/makeQueries").FindAllByQuery<import("./matches").TextMatch, import("./queries/options").CommonQueryOptions & import("react-native").AccessibilityState & {
|
|
81
|
+
findAllByRole: import("./queries/makeQueries").FindAllByQuery<import("./matches").TextMatch, import("./queries/options").CommonQueryOptions & import("react-native/types").AccessibilityState & {
|
|
82
82
|
name?: import("./matches").TextMatch | undefined;
|
|
83
83
|
value?: import("./helpers/matchers/accessibilityValue").AccessibilityValueMatcher | undefined;
|
|
84
84
|
}>;
|
package/build/render.js
CHANGED
|
@@ -14,6 +14,7 @@ var _within = require("./within");
|
|
|
14
14
|
var _screen = require("./screen");
|
|
15
15
|
var _stringValidation = require("./helpers/stringValidation");
|
|
16
16
|
var _config = require("./config");
|
|
17
|
+
var _hostComponentNames = require("./helpers/host-component-names");
|
|
17
18
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
18
19
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
19
20
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
@@ -26,6 +27,7 @@ function render(component, {
|
|
|
26
27
|
createNodeMock,
|
|
27
28
|
unstable_validateStringsRenderedWithinText
|
|
28
29
|
} = {}) {
|
|
30
|
+
(0, _hostComponentNames.configureHostComponentNamesIfNeeded)();
|
|
29
31
|
if (unstable_validateStringsRenderedWithinText) {
|
|
30
32
|
return renderWithStringValidation(component, {
|
|
31
33
|
wrapper: Wrapper,
|
package/build/render.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"render.js","names":["render","component","wrapper","Wrapper","createNodeMock","unstable_validateStringsRenderedWithinText","renderWithStringValidation","wrap","element","renderer","renderWithAct","undefined","buildRenderResult","handleRender","_","phase","validateStringsRenderedWithinText","screen","toJSON","update","updateWithAct","instance","root","unmount","act","addToCleanupQueue","result","getQueriesForElement","container","rerender","debug","setRenderResult","options","TestRenderer","create","debugImpl","defaultDebugOptions","getConfig","debugOptions","message","console","warn","json","debugDeep","shallow","debugShallow"],"sources":["../src/render.tsx"],"sourcesContent":["import TestRenderer from 'react-test-renderer';\nimport type { ReactTestInstance, ReactTestRenderer } from 'react-test-renderer';\nimport * as React from 'react';\nimport { Profiler } from 'react';\nimport act from './act';\nimport { addToCleanupQueue } from './cleanup';\nimport debugShallow from './helpers/debugShallow';\nimport debugDeep, { DebugOptions } from './helpers/debugDeep';\nimport { getQueriesForElement } from './within';\nimport { setRenderResult, screen } from './screen';\nimport { validateStringsRenderedWithinText } from './helpers/stringValidation';\nimport { getConfig } from './config';\n\nexport type RenderOptions = {\n wrapper?: React.ComponentType<any>;\n createNodeMock?: (element: React.ReactElement) => any;\n unstable_validateStringsRenderedWithinText?: boolean;\n};\n\ntype TestRendererOptions = {\n createNodeMock: (element: React.ReactElement) => any;\n};\n\nexport type RenderResult = ReturnType<typeof render>;\n\n/**\n * Renders test component deeply using react-test-renderer and exposes helpers\n * to assert on the output.\n */\nexport default function render<T>(\n component: React.ReactElement<T>,\n {\n wrapper: Wrapper,\n createNodeMock,\n unstable_validateStringsRenderedWithinText,\n }: RenderOptions = {}\n) {\n if (unstable_validateStringsRenderedWithinText) {\n return renderWithStringValidation(component, {\n wrapper: Wrapper,\n createNodeMock,\n });\n }\n\n const wrap = (element: React.ReactElement) =>\n Wrapper ? <Wrapper>{element}</Wrapper> : element;\n\n const renderer = renderWithAct(\n wrap(component),\n createNodeMock ? { createNodeMock } : undefined\n );\n\n return buildRenderResult(renderer, wrap);\n}\n\nfunction renderWithStringValidation<T>(\n component: React.ReactElement<T>,\n {\n wrapper: Wrapper,\n createNodeMock,\n }: Omit<RenderOptions, 'unstable_validateStringsRenderedWithinText'> = {}\n) {\n const handleRender: React.ProfilerProps['onRender'] = (_, phase) => {\n if (phase === 'update') {\n validateStringsRenderedWithinText(screen.toJSON());\n }\n };\n\n const wrap = (element: React.ReactElement) => (\n <Profiler id=\"renderProfiler\" onRender={handleRender}>\n {Wrapper ? <Wrapper>{element}</Wrapper> : element}\n </Profiler>\n );\n\n const renderer = renderWithAct(\n wrap(component),\n createNodeMock ? { createNodeMock } : undefined\n );\n validateStringsRenderedWithinText(renderer.toJSON());\n\n return buildRenderResult(renderer, wrap);\n}\n\nfunction buildRenderResult(\n renderer: ReactTestRenderer,\n wrap: (element: React.ReactElement) => JSX.Element\n) {\n const update = updateWithAct(renderer, wrap);\n const instance = renderer.root;\n\n const unmount = () => {\n act(() => {\n renderer.unmount();\n });\n };\n\n addToCleanupQueue(unmount);\n\n const result = {\n ...getQueriesForElement(instance),\n update,\n unmount,\n container: instance,\n rerender: update, // alias for `update`\n toJSON: renderer.toJSON,\n debug: debug(instance, renderer),\n };\n\n setRenderResult(result);\n return result;\n}\n\nfunction renderWithAct(\n component: React.ReactElement,\n options?: TestRendererOptions\n): ReactTestRenderer {\n let renderer: ReactTestRenderer;\n\n act(() => {\n renderer = TestRenderer.create(component, options);\n });\n\n // @ts-ignore act is sync, so renderer is always initialised here\n return renderer;\n}\n\nfunction updateWithAct(\n renderer: ReactTestRenderer,\n wrap: (innerElement: React.ReactElement) => React.ReactElement\n) {\n return function (component: React.ReactElement) {\n act(() => {\n renderer.update(wrap(component));\n });\n };\n}\n\ninterface DebugFunction {\n (options?: DebugOptions | string): void;\n shallow: (message?: string) => void;\n}\n\nfunction debug(\n instance: ReactTestInstance,\n renderer: ReactTestRenderer\n): DebugFunction {\n function debugImpl(options?: DebugOptions | string) {\n const { defaultDebugOptions } = getConfig();\n const debugOptions =\n typeof options === 'string'\n ? { ...defaultDebugOptions, message: options }\n : { ...defaultDebugOptions, ...options };\n\n if (typeof options === 'string') {\n // eslint-disable-next-line no-console\n console.warn(\n 'Using debug(\"message\") is deprecated and will be removed in future release, please use debug({ message; \"message\" }) instead.'\n );\n }\n\n const json = renderer.toJSON();\n if (json) {\n return debugDeep(json, debugOptions);\n }\n }\n debugImpl.shallow = (message?: string) => debugShallow(instance, message);\n return debugImpl;\n}\n"],"mappings":";;;;;;AAAA;AAEA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;
|
|
1
|
+
{"version":3,"file":"render.js","names":["render","component","wrapper","Wrapper","createNodeMock","unstable_validateStringsRenderedWithinText","configureHostComponentNamesIfNeeded","renderWithStringValidation","wrap","element","renderer","renderWithAct","undefined","buildRenderResult","handleRender","_","phase","validateStringsRenderedWithinText","screen","toJSON","update","updateWithAct","instance","root","unmount","act","addToCleanupQueue","result","getQueriesForElement","container","rerender","debug","setRenderResult","options","TestRenderer","create","debugImpl","defaultDebugOptions","getConfig","debugOptions","message","console","warn","json","debugDeep","shallow","debugShallow"],"sources":["../src/render.tsx"],"sourcesContent":["import TestRenderer from 'react-test-renderer';\nimport type { ReactTestInstance, ReactTestRenderer } from 'react-test-renderer';\nimport * as React from 'react';\nimport { Profiler } from 'react';\nimport act from './act';\nimport { addToCleanupQueue } from './cleanup';\nimport debugShallow from './helpers/debugShallow';\nimport debugDeep, { DebugOptions } from './helpers/debugDeep';\nimport { getQueriesForElement } from './within';\nimport { setRenderResult, screen } from './screen';\nimport { validateStringsRenderedWithinText } from './helpers/stringValidation';\nimport { getConfig } from './config';\nimport { configureHostComponentNamesIfNeeded } from './helpers/host-component-names';\n\nexport type RenderOptions = {\n wrapper?: React.ComponentType<any>;\n createNodeMock?: (element: React.ReactElement) => any;\n unstable_validateStringsRenderedWithinText?: boolean;\n};\n\ntype TestRendererOptions = {\n createNodeMock: (element: React.ReactElement) => any;\n};\n\nexport type RenderResult = ReturnType<typeof render>;\n\n/**\n * Renders test component deeply using react-test-renderer and exposes helpers\n * to assert on the output.\n */\nexport default function render<T>(\n component: React.ReactElement<T>,\n {\n wrapper: Wrapper,\n createNodeMock,\n unstable_validateStringsRenderedWithinText,\n }: RenderOptions = {}\n) {\n configureHostComponentNamesIfNeeded();\n\n if (unstable_validateStringsRenderedWithinText) {\n return renderWithStringValidation(component, {\n wrapper: Wrapper,\n createNodeMock,\n });\n }\n\n const wrap = (element: React.ReactElement) =>\n Wrapper ? <Wrapper>{element}</Wrapper> : element;\n\n const renderer = renderWithAct(\n wrap(component),\n createNodeMock ? { createNodeMock } : undefined\n );\n\n return buildRenderResult(renderer, wrap);\n}\n\nfunction renderWithStringValidation<T>(\n component: React.ReactElement<T>,\n {\n wrapper: Wrapper,\n createNodeMock,\n }: Omit<RenderOptions, 'unstable_validateStringsRenderedWithinText'> = {}\n) {\n const handleRender: React.ProfilerProps['onRender'] = (_, phase) => {\n if (phase === 'update') {\n validateStringsRenderedWithinText(screen.toJSON());\n }\n };\n\n const wrap = (element: React.ReactElement) => (\n <Profiler id=\"renderProfiler\" onRender={handleRender}>\n {Wrapper ? <Wrapper>{element}</Wrapper> : element}\n </Profiler>\n );\n\n const renderer = renderWithAct(\n wrap(component),\n createNodeMock ? { createNodeMock } : undefined\n );\n validateStringsRenderedWithinText(renderer.toJSON());\n\n return buildRenderResult(renderer, wrap);\n}\n\nfunction buildRenderResult(\n renderer: ReactTestRenderer,\n wrap: (element: React.ReactElement) => JSX.Element\n) {\n const update = updateWithAct(renderer, wrap);\n const instance = renderer.root;\n\n const unmount = () => {\n act(() => {\n renderer.unmount();\n });\n };\n\n addToCleanupQueue(unmount);\n\n const result = {\n ...getQueriesForElement(instance),\n update,\n unmount,\n container: instance,\n rerender: update, // alias for `update`\n toJSON: renderer.toJSON,\n debug: debug(instance, renderer),\n };\n\n setRenderResult(result);\n return result;\n}\n\nfunction renderWithAct(\n component: React.ReactElement,\n options?: TestRendererOptions\n): ReactTestRenderer {\n let renderer: ReactTestRenderer;\n\n act(() => {\n renderer = TestRenderer.create(component, options);\n });\n\n // @ts-ignore act is sync, so renderer is always initialised here\n return renderer;\n}\n\nfunction updateWithAct(\n renderer: ReactTestRenderer,\n wrap: (innerElement: React.ReactElement) => React.ReactElement\n) {\n return function (component: React.ReactElement) {\n act(() => {\n renderer.update(wrap(component));\n });\n };\n}\n\ninterface DebugFunction {\n (options?: DebugOptions | string): void;\n shallow: (message?: string) => void;\n}\n\nfunction debug(\n instance: ReactTestInstance,\n renderer: ReactTestRenderer\n): DebugFunction {\n function debugImpl(options?: DebugOptions | string) {\n const { defaultDebugOptions } = getConfig();\n const debugOptions =\n typeof options === 'string'\n ? { ...defaultDebugOptions, message: options }\n : { ...defaultDebugOptions, ...options };\n\n if (typeof options === 'string') {\n // eslint-disable-next-line no-console\n console.warn(\n 'Using debug(\"message\") is deprecated and will be removed in future release, please use debug({ message; \"message\" }) instead.'\n );\n }\n\n const json = renderer.toJSON();\n if (json) {\n return debugDeep(json, debugOptions);\n }\n }\n debugImpl.shallow = (message?: string) => debugShallow(instance, message);\n return debugImpl;\n}\n"],"mappings":";;;;;;AAAA;AAEA;AAEA;AACA;AAC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