@testing-library/react-native 11.3.0 → 11.4.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 +3 -0
- package/build/act.js +9 -15
- package/build/act.js.map +1 -1
- package/build/cleanup.js +0 -4
- package/build/cleanup.js.map +1 -1
- package/build/config.d.ts +5 -0
- package/build/config.js +4 -5
- package/build/config.js.map +1 -1
- package/build/fireEvent.js +3 -31
- package/build/fireEvent.js.map +1 -1
- package/build/flushMicroTasks.js +0 -3
- package/build/flushMicroTasks.js.map +1 -1
- package/build/helpers/accessiblity.d.ts +3 -0
- package/build/helpers/accessiblity.js +14 -20
- 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/format.d.ts +5 -1
- package/build/helpers/format.js +17 -7
- package/build/helpers/format.js.map +1 -1
- 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/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/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 +66 -21
- package/build/index.js +0 -6
- package/build/index.js.map +1 -1
- package/build/matches.js +2 -4
- package/build/matches.js.map +1 -1
- package/build/pure.js +0 -13
- package/build/pure.js.map +1 -1
- package/build/queries/a11yState.js +15 -13
- package/build/queries/a11yState.js.map +1 -1
- package/build/queries/a11yValue.js +0 -8
- package/build/queries/a11yValue.js.map +1 -1
- package/build/queries/displayValue.js +0 -11
- package/build/queries/displayValue.js.map +1 -1
- package/build/queries/hintText.d.ts +19 -18
- package/build/queries/hintText.js +10 -11
- package/build/queries/hintText.js.map +1 -1
- package/build/queries/labelText.d.ts +7 -6
- package/build/queries/labelText.js +10 -11
- package/build/queries/labelText.js.map +1 -1
- package/build/queries/makeQueries.d.ts +3 -3
- package/build/queries/makeQueries.js +40 -24
- package/build/queries/makeQueries.js.map +1 -1
- package/build/queries/placeholderText.js +0 -11
- package/build/queries/placeholderText.js.map +1 -1
- package/build/queries/role.d.ts +3 -2
- package/build/queries/role.js +23 -13
- package/build/queries/role.js.map +1 -1
- package/build/queries/testId.js +0 -9
- package/build/queries/testId.js.map +1 -1
- package/build/queries/text.js +0 -24
- package/build/queries/text.js.map +1 -1
- package/build/queries/unsafeProps.js +2 -11
- package/build/queries/unsafeProps.js.map +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 +32 -31
- package/build/render.js +21 -31
- package/build/render.js.map +1 -1
- 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.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 +30 -30
- package/build/within.js +2 -14
- package/build/within.js.map +1 -1
- package/package.json +9 -8
- package/typings/index.flow.js +66 -21
|
@@ -4,19 +4,20 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.bindByHintTextQueries = void 0;
|
|
7
|
-
|
|
8
|
-
var _matchStringProp = require("../helpers/matchers/matchStringProp");
|
|
9
|
-
|
|
7
|
+
var _matches = require("../matches");
|
|
10
8
|
var _makeQueries = require("./makeQueries");
|
|
11
|
-
|
|
12
|
-
const
|
|
13
|
-
|
|
9
|
+
const getNodeByHintText = (node, text, options = {}) => {
|
|
10
|
+
const {
|
|
11
|
+
exact,
|
|
12
|
+
normalizer
|
|
13
|
+
} = options;
|
|
14
|
+
return (0, _matches.matches)(text, node.props.accessibilityHint, normalizer, exact);
|
|
15
|
+
};
|
|
16
|
+
const queryAllByHintText = instance => function queryAllByA11yHintFn(hint, queryOptions) {
|
|
17
|
+
return instance.findAll(node => typeof node.type === 'string' && getNodeByHintText(node, hint, queryOptions));
|
|
14
18
|
};
|
|
15
|
-
|
|
16
19
|
const getMultipleError = hint => `Found multiple elements with accessibilityHint: ${String(hint)} `;
|
|
17
|
-
|
|
18
20
|
const getMissingError = hint => `Unable to find an element with accessibilityHint: ${String(hint)}`;
|
|
19
|
-
|
|
20
21
|
const {
|
|
21
22
|
getBy,
|
|
22
23
|
getAllBy,
|
|
@@ -25,7 +26,6 @@ const {
|
|
|
25
26
|
findBy,
|
|
26
27
|
findAllBy
|
|
27
28
|
} = (0, _makeQueries.makeQueries)(queryAllByHintText, getMissingError, getMultipleError);
|
|
28
|
-
|
|
29
29
|
const bindByHintTextQueries = instance => {
|
|
30
30
|
const getByHintText = getBy(instance);
|
|
31
31
|
const getAllByHintText = getAllBy(instance);
|
|
@@ -56,6 +56,5 @@ const bindByHintTextQueries = instance => {
|
|
|
56
56
|
findAllByAccessibilityHint: findAllByHintText
|
|
57
57
|
};
|
|
58
58
|
};
|
|
59
|
-
|
|
60
59
|
exports.bindByHintTextQueries = bindByHintTextQueries;
|
|
61
60
|
//# 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 { 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 { TextMatchOptions } from './text';\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?: TextMatchOptions\n) => Array<ReactTestInstance>) =>\n function queryAllByA11yHintFn(hint, queryOptions) {\n return instance.findAll(\n (node) =>\n typeof node.type === 'string' &&\n getNodeByHintText(node, hint, 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, TextMatchOptions>;\n getAllByHintText: GetAllByQuery<TextMatch, TextMatchOptions>;\n queryByHintText: QueryByQuery<TextMatch, TextMatchOptions>;\n queryAllByHintText: QueryAllByQuery<TextMatch, TextMatchOptions>;\n findByHintText: FindByQuery<TextMatch, TextMatchOptions>;\n findAllByHintText: FindAllByQuery<TextMatch, TextMatchOptions>;\n\n // a11yHint aliases\n getByA11yHint: GetByQuery<TextMatch, TextMatchOptions>;\n getAllByA11yHint: GetAllByQuery<TextMatch, TextMatchOptions>;\n queryByA11yHint: QueryByQuery<TextMatch, TextMatchOptions>;\n queryAllByA11yHint: QueryAllByQuery<TextMatch, TextMatchOptions>;\n findByA11yHint: FindByQuery<TextMatch, TextMatchOptions>;\n findAllByA11yHint: FindAllByQuery<TextMatch, TextMatchOptions>;\n\n // accessibilityHint aliases\n getByAccessibilityHint: GetByQuery<TextMatch, TextMatchOptions>;\n getAllByAccessibilityHint: GetAllByQuery<TextMatch, TextMatchOptions>;\n queryByAccessibilityHint: QueryByQuery<TextMatch, TextMatchOptions>;\n queryAllByAccessibilityHint: QueryAllByQuery<TextMatch, TextMatchOptions>;\n findByAccessibilityHint: FindByQuery<TextMatch, TextMatchOptions>;\n findAllByAccessibilityHint: FindAllByQuery<TextMatch, TextMatchOptions>;\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: findAllByHintText,\n };\n};\n"],"mappings":";;;;;;AACA;AACA;AAWA,MAAMA,iBAAiB,GAAG,CACxBC,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,iBAAiB,EAAEH,UAAU,EAAED,KAAK,CAAC;AACvE,CAAC;AAED,MAAMK,kBAAkB,GACtBC,QAA2B,IAK3B,SAASC,oBAAoB,CAACC,IAAI,EAAEC,YAAY,EAAE;EAChD,OAAOH,QAAQ,CAACI,OAAO,CACpBb,IAAI,IACH,OAAOA,IAAI,CAACc,IAAI,KAAK,QAAQ,IAC7Bf,iBAAiB,CAACC,IAAI,EAAEW,IAAI,EAAEC,YAAY,CAAC,CAC9C;AACH,CAAC;AAEH,MAAMG,gBAAgB,GAAIJ,IAAe,IACtC,mDAAkDK,MAAM,CAACL,IAAI,CAAE,GAAE;AACpE,MAAMM,eAAe,GAAIN,IAAe,IACrC,qDAAoDK,MAAM,CAACL,IAAI,CAAE,EAAC;AAErE,MAAM;EAAEO,KAAK;EAAEC,QAAQ;EAAEC,OAAO;EAAEC,UAAU;EAAEC,MAAM;EAAEC;AAAU,CAAC,GAAG,IAAAC,wBAAW,EAC7EhB,kBAAkB,EAClBS,eAAe,EACfF,gBAAgB,CACjB;AA2BM,MAAMU,qBAAqB,GAChChB,QAA2B,IACL;EACtB,MAAMiB,aAAa,GAAGR,KAAK,CAACT,QAAQ,CAAC;EACrC,MAAMkB,gBAAgB,GAAGR,QAAQ,CAACV,QAAQ,CAAC;EAC3C,MAAMmB,eAAe,GAAGR,OAAO,CAACX,QAAQ,CAAC;EACzC,MAAMD,kBAAkB,GAAGa,UAAU,CAACZ,QAAQ,CAAC;EAC/C,MAAMoB,cAAc,GAAGP,MAAM,CAACb,QAAQ,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,13 @@
|
|
|
1
1
|
import type { ReactTestInstance } from 'react-test-renderer';
|
|
2
2
|
import { TextMatch } from '../matches';
|
|
3
3
|
import type { FindAllByQuery, FindByQuery, GetAllByQuery, GetByQuery, QueryAllByQuery, QueryByQuery } from './makeQueries';
|
|
4
|
+
import { TextMatchOptions } from './text';
|
|
4
5
|
export declare type ByLabelTextQueries = {
|
|
5
|
-
getByLabelText: GetByQuery<TextMatch>;
|
|
6
|
-
getAllByLabelText: GetAllByQuery<TextMatch>;
|
|
7
|
-
queryByLabelText: QueryByQuery<TextMatch>;
|
|
8
|
-
queryAllByLabelText: QueryAllByQuery<TextMatch>;
|
|
9
|
-
findByLabelText: FindByQuery<TextMatch>;
|
|
10
|
-
findAllByLabelText: FindAllByQuery<TextMatch>;
|
|
6
|
+
getByLabelText: GetByQuery<TextMatch, TextMatchOptions>;
|
|
7
|
+
getAllByLabelText: GetAllByQuery<TextMatch, TextMatchOptions>;
|
|
8
|
+
queryByLabelText: QueryByQuery<TextMatch, TextMatchOptions>;
|
|
9
|
+
queryAllByLabelText: QueryAllByQuery<TextMatch, TextMatchOptions>;
|
|
10
|
+
findByLabelText: FindByQuery<TextMatch, TextMatchOptions>;
|
|
11
|
+
findAllByLabelText: FindAllByQuery<TextMatch, TextMatchOptions>;
|
|
11
12
|
};
|
|
12
13
|
export declare const bindByLabelTextQueries: (instance: ReactTestInstance) => ByLabelTextQueries;
|
|
@@ -4,19 +4,20 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.bindByLabelTextQueries = void 0;
|
|
7
|
-
|
|
8
|
-
var _matchStringProp = require("../helpers/matchers/matchStringProp");
|
|
9
|
-
|
|
7
|
+
var _matches = require("../matches");
|
|
10
8
|
var _makeQueries = require("./makeQueries");
|
|
11
|
-
|
|
12
|
-
const
|
|
13
|
-
|
|
9
|
+
const getNodeByLabelText = (node, text, options = {}) => {
|
|
10
|
+
const {
|
|
11
|
+
exact,
|
|
12
|
+
normalizer
|
|
13
|
+
} = options;
|
|
14
|
+
return (0, _matches.matches)(text, node.props.accessibilityLabel, normalizer, exact);
|
|
15
|
+
};
|
|
16
|
+
const queryAllByLabelText = instance => function queryAllByLabelTextFn(text, queryOptions) {
|
|
17
|
+
return instance.findAll(node => typeof node.type === 'string' && getNodeByLabelText(node, text, queryOptions));
|
|
14
18
|
};
|
|
15
|
-
|
|
16
19
|
const getMultipleError = labelText => `Found multiple elements with accessibilityLabel: ${String(labelText)} `;
|
|
17
|
-
|
|
18
20
|
const getMissingError = labelText => `Unable to find an element with accessibilityLabel: ${String(labelText)}`;
|
|
19
|
-
|
|
20
21
|
const {
|
|
21
22
|
getBy,
|
|
22
23
|
getAllBy,
|
|
@@ -25,7 +26,6 @@ const {
|
|
|
25
26
|
findBy,
|
|
26
27
|
findAllBy
|
|
27
28
|
} = (0, _makeQueries.makeQueries)(queryAllByLabelText, getMissingError, getMultipleError);
|
|
28
|
-
|
|
29
29
|
const bindByLabelTextQueries = instance => ({
|
|
30
30
|
getByLabelText: getBy(instance),
|
|
31
31
|
getAllByLabelText: getAllBy(instance),
|
|
@@ -34,6 +34,5 @@ const bindByLabelTextQueries = instance => ({
|
|
|
34
34
|
findByLabelText: findBy(instance),
|
|
35
35
|
findAllByLabelText: findAllBy(instance)
|
|
36
36
|
});
|
|
37
|
-
|
|
38
37
|
exports.bindByLabelTextQueries = bindByLabelTextQueries;
|
|
39
38
|
//# 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 { 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 { TextMatchOptions } from './text';\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?: TextMatchOptions\n) => Array<ReactTestInstance>) =>\n function queryAllByLabelTextFn(text, queryOptions?: TextMatchOptions) {\n return instance.findAll(\n (node) =>\n typeof node.type === 'string' &&\n getNodeByLabelText(node, text, 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, TextMatchOptions>;\n getAllByLabelText: GetAllByQuery<TextMatch, TextMatchOptions>;\n queryByLabelText: QueryByQuery<TextMatch, TextMatchOptions>;\n queryAllByLabelText: QueryAllByQuery<TextMatch, TextMatchOptions>;\n findByLabelText: FindByQuery<TextMatch, TextMatchOptions>;\n findAllByLabelText: FindAllByQuery<TextMatch, TextMatchOptions>;\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;AAWA,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,YAA+B,EAAE;EACpE,OAAOF,QAAQ,CAACG,OAAO,CACpBZ,IAAI,IACH,OAAOA,IAAI,CAACa,IAAI,KAAK,QAAQ,IAC7Bd,kBAAkB,CAACC,IAAI,EAAEC,IAAI,EAAEU,YAAY,CAAC,CAC/C;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"}
|
|
@@ -4,8 +4,8 @@ export declare type GetByQuery<Predicate, Options = void> = (predicate: Predicat
|
|
|
4
4
|
export declare type GetAllByQuery<Predicate, Options = void> = (predicate: Predicate, options?: Options) => ReactTestInstance[];
|
|
5
5
|
export declare type QueryByQuery<Predicate, Options = void> = (predicate: Predicate, options?: Options) => ReactTestInstance | null;
|
|
6
6
|
export declare type QueryAllByQuery<Predicate, Options = void> = (predicate: Predicate, options?: Options) => ReactTestInstance[];
|
|
7
|
-
export declare type FindByQuery<Predicate, Options = void> = (predicate: Predicate, options?: Options, waitForOptions?: WaitForOptions) => Promise<ReactTestInstance>;
|
|
8
|
-
export declare type FindAllByQuery<Predicate, Options = void> = (predicate: Predicate, options?: Options, waitForOptions?: WaitForOptions) => Promise<ReactTestInstance[]>;
|
|
7
|
+
export declare type FindByQuery<Predicate, Options = void> = (predicate: Predicate, options?: Options & WaitForOptions, waitForOptions?: WaitForOptions) => Promise<ReactTestInstance>;
|
|
8
|
+
export declare type FindAllByQuery<Predicate, Options = void> = (predicate: Predicate, options?: Options & WaitForOptions, waitForOptions?: WaitForOptions) => Promise<ReactTestInstance[]>;
|
|
9
9
|
declare type UnboundQuery<Query> = (instance: ReactTestInstance) => Query;
|
|
10
10
|
export declare type UnboundQueries<Predicate, Options> = {
|
|
11
11
|
getBy: UnboundQuery<GetByQuery<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 {};
|
|
@@ -4,70 +4,86 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.makeQueries = makeQueries;
|
|
7
|
-
|
|
8
7
|
var _errors = require("../helpers/errors");
|
|
9
|
-
|
|
10
8
|
var _waitFor = _interopRequireDefault(require("../waitFor"));
|
|
11
|
-
|
|
12
9
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
10
|
+
const deprecatedKeys = ['timeout', 'interval', 'stackTraceError'];
|
|
13
11
|
|
|
12
|
+
// The WaitForOptions has been moved to the second option param of findBy* methods with the adding of TextMatchOptions
|
|
13
|
+
// To make the migration easier and avoid a breaking change, keep reading this options from the first param but warn
|
|
14
|
+
function extractDeprecatedWaitForOptions(options) {
|
|
15
|
+
if (!options) {
|
|
16
|
+
return undefined;
|
|
17
|
+
}
|
|
18
|
+
const waitForOptions = {
|
|
19
|
+
timeout: options.timeout,
|
|
20
|
+
interval: options.interval,
|
|
21
|
+
stackTraceError: options.stackTraceError
|
|
22
|
+
};
|
|
23
|
+
deprecatedKeys.forEach(key => {
|
|
24
|
+
const option = options[key];
|
|
25
|
+
if (option) {
|
|
26
|
+
// eslint-disable-next-line no-console
|
|
27
|
+
console.warn(`Use of option "${key}" in a findBy* query options (2nd parameter) is deprecated. Please pass this option in the waitForOptions (3rd parameter).
|
|
28
|
+
Example:
|
|
29
|
+
|
|
30
|
+
findByText(text, {}, { ${key}: ${option.toString()} })`);
|
|
31
|
+
}
|
|
32
|
+
});
|
|
33
|
+
return waitForOptions;
|
|
34
|
+
}
|
|
14
35
|
function makeQueries(queryAllByQuery, getMissingError, getMultipleError) {
|
|
15
36
|
function getAllByQuery(instance) {
|
|
16
37
|
return function getAllFn(predicate, options) {
|
|
17
38
|
const results = queryAllByQuery(instance)(predicate, options);
|
|
18
|
-
|
|
19
39
|
if (results.length === 0) {
|
|
20
|
-
throw new _errors.ErrorWithStack(getMissingError(predicate), getAllFn);
|
|
40
|
+
throw new _errors.ErrorWithStack(getMissingError(predicate, options), getAllFn);
|
|
21
41
|
}
|
|
22
|
-
|
|
23
42
|
return results;
|
|
24
43
|
};
|
|
25
44
|
}
|
|
26
|
-
|
|
27
45
|
function queryByQuery(instance) {
|
|
28
46
|
return function singleQueryFn(predicate, options) {
|
|
29
47
|
const results = queryAllByQuery(instance)(predicate, options);
|
|
30
|
-
|
|
31
48
|
if (results.length > 1) {
|
|
32
|
-
throw new _errors.ErrorWithStack(getMultipleError(predicate), singleQueryFn);
|
|
49
|
+
throw new _errors.ErrorWithStack(getMultipleError(predicate, options), singleQueryFn);
|
|
33
50
|
}
|
|
34
|
-
|
|
35
51
|
if (results.length === 0) {
|
|
36
52
|
return null;
|
|
37
53
|
}
|
|
38
|
-
|
|
39
54
|
return results[0];
|
|
40
55
|
};
|
|
41
56
|
}
|
|
42
|
-
|
|
43
57
|
function getByQuery(instance) {
|
|
44
58
|
return function getFn(predicate, options) {
|
|
45
59
|
const results = queryAllByQuery(instance)(predicate, options);
|
|
46
|
-
|
|
47
60
|
if (results.length > 1) {
|
|
48
|
-
throw new _errors.ErrorWithStack(getMultipleError(predicate), getFn);
|
|
61
|
+
throw new _errors.ErrorWithStack(getMultipleError(predicate, options), getFn);
|
|
49
62
|
}
|
|
50
|
-
|
|
51
63
|
if (results.length === 0) {
|
|
52
|
-
throw new _errors.ErrorWithStack(getMissingError(predicate), getFn);
|
|
64
|
+
throw new _errors.ErrorWithStack(getMissingError(predicate, options), getFn);
|
|
53
65
|
}
|
|
54
|
-
|
|
55
66
|
return results[0];
|
|
56
67
|
};
|
|
57
68
|
}
|
|
58
|
-
|
|
59
69
|
function findAllByQuery(instance) {
|
|
60
|
-
return function findAllFn(predicate, queryOptions, waitForOptions) {
|
|
61
|
-
|
|
70
|
+
return function findAllFn(predicate, queryOptions, waitForOptions = {}) {
|
|
71
|
+
const deprecatedWaitForOptions = extractDeprecatedWaitForOptions(queryOptions);
|
|
72
|
+
return (0, _waitFor.default)(() => getAllByQuery(instance)(predicate, queryOptions), {
|
|
73
|
+
...deprecatedWaitForOptions,
|
|
74
|
+
...waitForOptions
|
|
75
|
+
});
|
|
62
76
|
};
|
|
63
77
|
}
|
|
64
|
-
|
|
65
78
|
function findByQuery(instance) {
|
|
66
|
-
return function findFn(predicate, queryOptions, waitForOptions) {
|
|
67
|
-
|
|
79
|
+
return function findFn(predicate, queryOptions, waitForOptions = {}) {
|
|
80
|
+
const deprecatedWaitForOptions = extractDeprecatedWaitForOptions(queryOptions);
|
|
81
|
+
return (0, _waitFor.default)(() => getByQuery(instance)(predicate, queryOptions), {
|
|
82
|
+
...deprecatedWaitForOptions,
|
|
83
|
+
...waitForOptions
|
|
84
|
+
});
|
|
68
85
|
};
|
|
69
86
|
}
|
|
70
|
-
|
|
71
87
|
return {
|
|
72
88
|
getBy: getByQuery,
|
|
73
89
|
getAllBy: getAllByQuery,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"makeQueries.js","names":["makeQueries","queryAllByQuery","getMissingError","getMultipleError","getAllByQuery","instance","getAllFn","predicate","
|
|
1
|
+
{"version":3,"file":"makeQueries.js","names":["deprecatedKeys","extractDeprecatedWaitForOptions","options","undefined","waitForOptions","timeout","interval","stackTraceError","forEach","key","option","console","warn","toString","makeQueries","queryAllByQuery","getMissingError","getMultipleError","getAllByQuery","instance","getAllFn","predicate","results","length","ErrorWithStack","queryByQuery","singleQueryFn","getByQuery","getFn","findAllByQuery","findAllFn","queryOptions","deprecatedWaitForOptions","waitFor","findByQuery","findFn","getBy","getAllBy","queryBy","queryAllBy","findBy","findAllBy"],"sources":["../../src/queries/makeQueries.ts"],"sourcesContent":["import type { ReactTestInstance } from 'react-test-renderer';\nimport { ErrorWithStack } from '../helpers/errors';\nimport waitFor from '../waitFor';\nimport type { WaitForOptions } from '../waitFor';\n\nexport type GetByQuery<Predicate, Options = void> = (\n predicate: Predicate,\n options?: Options\n) => ReactTestInstance;\n\nexport type GetAllByQuery<Predicate, Options = void> = (\n predicate: Predicate,\n options?: Options\n) => ReactTestInstance[];\n\nexport type QueryByQuery<Predicate, Options = void> = (\n predicate: Predicate,\n options?: Options\n) => ReactTestInstance | null;\n\nexport type QueryAllByQuery<Predicate, Options = void> = (\n predicate: Predicate,\n options?: Options\n) => ReactTestInstance[];\n\nexport type FindByQuery<Predicate, Options = void> = (\n predicate: Predicate,\n // Remove `& WaitForOptions` when all queries have been migrated to support 2nd arg query options.\n options?: Options & WaitForOptions,\n waitForOptions?: WaitForOptions\n) => Promise<ReactTestInstance>;\n\nexport type FindAllByQuery<Predicate, Options = void> = (\n predicate: Predicate,\n // Remove `& WaitForOptions` when all queries have been migrated to support 2nd arg query options.\n options?: Options & WaitForOptions,\n waitForOptions?: WaitForOptions\n) => Promise<ReactTestInstance[]>;\n\ntype UnboundQuery<Query> = (instance: ReactTestInstance) => Query;\n\nexport type UnboundQueries<Predicate, Options> = {\n getBy: UnboundQuery<GetByQuery<Predicate, Options>>;\n getAllBy: UnboundQuery<GetAllByQuery<Predicate, Options>>;\n queryBy: UnboundQuery<QueryByQuery<Predicate, Options>>;\n queryAllBy: UnboundQuery<QueryAllByQuery<Predicate, Options>>;\n findBy: UnboundQuery<FindByQuery<Predicate, Options>>;\n findAllBy: UnboundQuery<FindAllByQuery<Predicate, Options>>;\n};\n\nconst deprecatedKeys: (keyof WaitForOptions)[] = [\n 'timeout',\n 'interval',\n 'stackTraceError',\n];\n\n// The WaitForOptions has been moved to the second option param of findBy* methods with the adding of TextMatchOptions\n// To make the migration easier and avoid a breaking change, keep reading this options from the first param but warn\nfunction extractDeprecatedWaitForOptions(options?: WaitForOptions) {\n if (!options) {\n return undefined;\n }\n\n const waitForOptions: WaitForOptions = {\n timeout: options.timeout,\n interval: options.interval,\n stackTraceError: options.stackTraceError,\n };\n\n deprecatedKeys.forEach((key) => {\n const option = options[key];\n if (option) {\n // eslint-disable-next-line no-console\n console.warn(\n `Use of option \"${key}\" in a findBy* query options (2nd parameter) is deprecated. Please pass this option in the waitForOptions (3rd parameter). \nExample: \n\n findByText(text, {}, { ${key}: ${option.toString()} })`\n );\n }\n });\n\n return waitForOptions;\n}\n\nexport function makeQueries<Predicate, Options>(\n queryAllByQuery: UnboundQuery<QueryAllByQuery<Predicate, Options>>,\n getMissingError: (predicate: Predicate, options?: Options) => string,\n getMultipleError: (predicate: Predicate, options?: Options) => string\n): UnboundQueries<Predicate, Options> {\n function getAllByQuery(instance: ReactTestInstance) {\n return function getAllFn(predicate: Predicate, options?: Options) {\n const results = queryAllByQuery(instance)(predicate, options);\n\n if (results.length === 0) {\n throw new ErrorWithStack(getMissingError(predicate, options), getAllFn);\n }\n\n return results;\n };\n }\n\n function queryByQuery(instance: ReactTestInstance) {\n return function singleQueryFn(predicate: Predicate, options?: Options) {\n const results = queryAllByQuery(instance)(predicate, options);\n\n if (results.length > 1) {\n throw new ErrorWithStack(\n getMultipleError(predicate, options),\n singleQueryFn\n );\n }\n\n if (results.length === 0) {\n return null;\n }\n\n return results[0];\n };\n }\n\n function getByQuery(instance: ReactTestInstance) {\n return function getFn(predicate: Predicate, options?: Options) {\n const results = queryAllByQuery(instance)(predicate, options);\n\n if (results.length > 1) {\n throw new ErrorWithStack(getMultipleError(predicate, options), getFn);\n }\n\n if (results.length === 0) {\n throw new ErrorWithStack(getMissingError(predicate, options), getFn);\n }\n\n return results[0];\n };\n }\n\n function findAllByQuery(instance: ReactTestInstance) {\n return function findAllFn(\n predicate: Predicate,\n queryOptions?: Options & WaitForOptions,\n waitForOptions: WaitForOptions = {}\n ) {\n const deprecatedWaitForOptions =\n extractDeprecatedWaitForOptions(queryOptions);\n return waitFor(() => getAllByQuery(instance)(predicate, queryOptions), {\n ...deprecatedWaitForOptions,\n ...waitForOptions,\n });\n };\n }\n\n function findByQuery(instance: ReactTestInstance) {\n return function findFn(\n predicate: Predicate,\n queryOptions?: Options & WaitForOptions,\n waitForOptions: WaitForOptions = {}\n ) {\n const deprecatedWaitForOptions =\n extractDeprecatedWaitForOptions(queryOptions);\n return waitFor(() => getByQuery(instance)(predicate, queryOptions), {\n ...deprecatedWaitForOptions,\n ...waitForOptions,\n });\n };\n }\n\n return {\n getBy: getByQuery,\n getAllBy: getAllByQuery,\n queryBy: queryByQuery,\n queryAllBy: queryAllByQuery,\n findBy: findByQuery,\n findAllBy: findAllByQuery,\n };\n}\n"],"mappings":";;;;;;AACA;AACA;AAAiC;AAgDjC,MAAMA,cAAwC,GAAG,CA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d,SAAoB,EACpBU,YAAuC,EACvC3B,cAA8B,GAAG,CAAC,CAAC,EACnC;MACA,MAAM4B,wBAAwB,GAC5B/B,+BAA+B,CAAC8B,YAAY,CAAC;MAC/C,OAAO,IAAAE,gBAAO,EAAC,MAAMN,UAAU,CAACR,QAAQ,CAAC,CAACE,SAAS,EAAEU,YAAY,CAAC,EAAE;QAClE,GAAGC,wBAAwB;QAC3B,GAAG5B;MACL,CAAC,CAAC;IACJ,CAAC;EACH;EAEA,OAAO;IACLgC,KAAK,EAAET,UAAU;IACjBU,QAAQ,EAAEnB,aAAa;IACvBoB,OAAO,EAAEb,YAAY;IACrBc,UAAU,EAAExB,eAAe;IAC3ByB,MAAM,EAAEN,WAAW;IACnBO,SAAS,EAAEZ;EACb,CAAC;AACH"}
|
|
@@ -4,15 +4,10 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.bindByPlaceholderTextQueries = void 0;
|
|
7
|
-
|
|
8
7
|
var _reactNative = require("react-native");
|
|
9
|
-
|
|
10
8
|
var _filterNodeByType = require("../helpers/filterNodeByType");
|
|
11
|
-
|
|
12
9
|
var _matches = require("../matches");
|
|
13
|
-
|
|
14
10
|
var _makeQueries = require("./makeQueries");
|
|
15
|
-
|
|
16
11
|
const getTextInputNodeByPlaceholderText = (node, placeholder, options = {}) => {
|
|
17
12
|
const {
|
|
18
13
|
exact,
|
|
@@ -20,15 +15,11 @@ const getTextInputNodeByPlaceholderText = (node, placeholder, options = {}) => {
|
|
|
20
15
|
} = options;
|
|
21
16
|
return (0, _filterNodeByType.filterNodeByType)(node, _reactNative.TextInput) && (0, _matches.matches)(placeholder, node.props.placeholder, normalizer, exact);
|
|
22
17
|
};
|
|
23
|
-
|
|
24
18
|
const queryAllByPlaceholderText = instance => function queryAllByPlaceholderFn(placeholder, queryOptions) {
|
|
25
19
|
return instance.findAll(node => getTextInputNodeByPlaceholderText(node, placeholder, queryOptions));
|
|
26
20
|
};
|
|
27
|
-
|
|
28
21
|
const getMultipleError = placeholder => `Found multiple elements with placeholder: ${String(placeholder)} `;
|
|
29
|
-
|
|
30
22
|
const getMissingError = placeholder => `Unable to find an element with placeholder: ${String(placeholder)}`;
|
|
31
|
-
|
|
32
23
|
const {
|
|
33
24
|
getBy,
|
|
34
25
|
getAllBy,
|
|
@@ -37,7 +28,6 @@ const {
|
|
|
37
28
|
findBy,
|
|
38
29
|
findAllBy
|
|
39
30
|
} = (0, _makeQueries.makeQueries)(queryAllByPlaceholderText, getMissingError, getMultipleError);
|
|
40
|
-
|
|
41
31
|
const bindByPlaceholderTextQueries = instance => ({
|
|
42
32
|
getByPlaceholderText: getBy(instance),
|
|
43
33
|
getAllByPlaceholderText: getAllBy(instance),
|
|
@@ -46,6 +36,5 @@ const bindByPlaceholderTextQueries = instance => ({
|
|
|
46
36
|
findByPlaceholderText: findBy(instance),
|
|
47
37
|
findAllByPlaceholderText: findAllBy(instance)
|
|
48
38
|
});
|
|
49
|
-
|
|
50
39
|
exports.bindByPlaceholderTextQueries = bindByPlaceholderTextQueries;
|
|
51
40
|
//# sourceMappingURL=placeholderText.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"placeholderText.js","names":["getTextInputNodeByPlaceholderText","node","placeholder","options","exact","normalizer","filterNodeByType","TextInput","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 { 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 { TextMatchOptions } from './text';\n\nconst getTextInputNodeByPlaceholderText = (\n node: ReactTestInstance,\n placeholder: TextMatch,\n options: TextMatchOptions = {}\n) => {\n const { exact, normalizer } = options;\n return (\n filterNodeByType(node, TextInput) &&\n matches(placeholder, node.props.placeholder, normalizer, exact)\n );\n};\n\nconst queryAllByPlaceholderText = (\n instance: ReactTestInstance\n): ((\n placeholder: TextMatch,\n queryOptions?: TextMatchOptions\n) => Array<ReactTestInstance>) =>\n function queryAllByPlaceholderFn(placeholder, queryOptions) {\n return instance.findAll((node) =>\n getTextInputNodeByPlaceholderText(node, placeholder, 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, TextMatchOptions>;\n getAllByPlaceholderText: GetAllByQuery<TextMatch, TextMatchOptions>;\n queryByPlaceholderText: QueryByQuery<TextMatch, TextMatchOptions>;\n queryAllByPlaceholderText: QueryAllByQuery<TextMatch, TextMatchOptions>;\n findByPlaceholderText: FindByQuery<TextMatch, TextMatchOptions>;\n findAllByPlaceholderText: FindAllByQuery<TextMatch, TextMatchOptions>;\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":"
|
|
1
|
+
{"version":3,"file":"placeholderText.js","names":["getTextInputNodeByPlaceholderText","node","placeholder","options","exact","normalizer","filterNodeByType","TextInput","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 { 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 { TextMatchOptions } from './text';\n\nconst getTextInputNodeByPlaceholderText = (\n node: ReactTestInstance,\n placeholder: TextMatch,\n options: TextMatchOptions = {}\n) => {\n const { exact, normalizer } = options;\n return (\n filterNodeByType(node, TextInput) &&\n matches(placeholder, node.props.placeholder, normalizer, exact)\n );\n};\n\nconst queryAllByPlaceholderText = (\n instance: ReactTestInstance\n): ((\n placeholder: TextMatch,\n queryOptions?: TextMatchOptions\n) => Array<ReactTestInstance>) =>\n function queryAllByPlaceholderFn(placeholder, queryOptions) {\n return instance.findAll((node) =>\n getTextInputNodeByPlaceholderText(node, placeholder, 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, TextMatchOptions>;\n getAllByPlaceholderText: GetAllByQuery<TextMatch, TextMatchOptions>;\n queryByPlaceholderText: QueryByQuery<TextMatch, TextMatchOptions>;\n queryAllByPlaceholderText: QueryAllByQuery<TextMatch, TextMatchOptions>;\n findByPlaceholderText: FindByQuery<TextMatch, TextMatchOptions>;\n findAllByPlaceholderText: FindAllByQuery<TextMatch, TextMatchOptions>;\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;AAWA,MAAMA,iCAAiC,GAAG,CACxCC,IAAuB,EACvBC,WAAsB,EACtBC,OAAyB,GAAG,CAAC,CAAC,KAC3B;EACH,MAAM;IAAEC,KAAK;IAAEC;EAAW,CAAC,GAAGF,OAAO;EACrC,OACE,IAAAG,kCAAgB,EAACL,IAAI,EAAEM,sBAAS,CAAC,IACjC,IAAAC,gBAAO,EAACN,WAAW,EAAED,IAAI,CAACQ,KAAK,CAACP,WAAW,EAAEG,UAAU,EAAED,KAAK,CAAC;AAEnE,CAAC;AAED,MAAMM,yBAAyB,GAC7BC,QAA2B,IAK3B,SAASC,uBAAuB,CAACV,WAAW,EAAEW,YAAY,EAAE;EAC1D,OAAOF,QAAQ,CAACG,OAAO,CAAEb,IAAI,IAC3BD,iCAAiC,CAACC,IAAI,EAAEC,WAAW,EAAEW,YAAY,CAAC,CACnE;AACH,CAAC;AAEH,MAAME,gBAAgB,GAAIb,WAAsB,IAC7C,6CAA4Cc,MAAM,CAACd,WAAW,CAAE,GAAE;AACrE,MAAMe,eAAe,GAAIf,WAAsB,IAC5C,+CAA8Cc,MAAM,CAACd,WAAW,CAAE,EAAC;AAEtE,MAAM;EAAEgB,KAAK;EAAEC,QAAQ;EAAEC,OAAO;EAAEC,UAAU;EAAEC,MAAM;EAAEC;AAAU,CAAC,GAAG,IAAAC,wBAAW,EAC7Ed,yBAAyB,EACzBO,eAAe,EACfF,gBAAgB,CACjB;AAWM,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.d.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
|
+
import { type AccessibilityState } from 'react-native';
|
|
1
2
|
import type { ReactTestInstance } from 'react-test-renderer';
|
|
2
|
-
import { TextMatch } from '../matches';
|
|
3
|
+
import type { TextMatch } from '../matches';
|
|
3
4
|
import type { FindAllByQuery, FindByQuery, GetAllByQuery, GetByQuery, QueryAllByQuery, QueryByQuery } from './makeQueries';
|
|
4
5
|
declare type ByRoleOptions = {
|
|
5
6
|
name?: TextMatch;
|
|
6
|
-
};
|
|
7
|
+
} & AccessibilityState;
|
|
7
8
|
export declare type ByRoleQueries = {
|
|
8
9
|
getByRole: GetByQuery<TextMatch, ByRoleOptions>;
|
|
9
10
|
getAllByRole: GetAllByQuery<TextMatch, ByRoleOptions>;
|
package/build/queries/role.js
CHANGED
|
@@ -4,13 +4,11 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.bindByRoleQueries = void 0;
|
|
7
|
-
|
|
7
|
+
var _accessiblity = require("../helpers/accessiblity");
|
|
8
|
+
var _accessibilityState = require("../helpers/matchers/accessibilityState");
|
|
8
9
|
var _matchStringProp = require("../helpers/matchers/matchStringProp");
|
|
9
|
-
|
|
10
10
|
var _within = require("../within");
|
|
11
|
-
|
|
12
11
|
var _makeQueries = require("./makeQueries");
|
|
13
|
-
|
|
14
12
|
const matchAccessibleNameIfNeeded = (node, name) => {
|
|
15
13
|
if (name == null) return true;
|
|
16
14
|
const {
|
|
@@ -19,15 +17,29 @@ const matchAccessibleNameIfNeeded = (node, name) => {
|
|
|
19
17
|
} = (0, _within.getQueriesForElement)(node);
|
|
20
18
|
return queryAllByText(name).length > 0 || queryAllByLabelText(name).length > 0;
|
|
21
19
|
};
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
return instance.findAll(node => typeof node.type === 'string' && (0, _matchStringProp.matchStringProp)(node.props.accessibilityRole, role) && matchAccessibleNameIfNeeded(node, options?.name));
|
|
20
|
+
const matchAccessibleStateIfNeeded = (node, options) => {
|
|
21
|
+
return options != null ? (0, _accessibilityState.matchAccessibilityState)(node, options) : true;
|
|
25
22
|
};
|
|
23
|
+
const queryAllByRole = instance => function queryAllByRoleFn(role, options) {
|
|
24
|
+
return instance.findAll(node =>
|
|
25
|
+
// run the cheapest checks first, and early exit too avoid unneeded computations
|
|
26
26
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
const
|
|
30
|
-
|
|
27
|
+
typeof node.type === 'string' && (0, _matchStringProp.matchStringProp)(node.props.accessibilityRole, role) && matchAccessibleStateIfNeeded(node, options) && matchAccessibleNameIfNeeded(node, options?.name));
|
|
28
|
+
};
|
|
29
|
+
const buildErrorMessage = (role, options = {}) => {
|
|
30
|
+
const errors = [`role: "${String(role)}"`];
|
|
31
|
+
if (options.name) {
|
|
32
|
+
errors.push(`name: "${String(options.name)}"`);
|
|
33
|
+
}
|
|
34
|
+
_accessiblity.accessibilityStateKeys.forEach(stateKey => {
|
|
35
|
+
if (options[stateKey] !== undefined) {
|
|
36
|
+
errors.push(`${stateKey} state: ${options[stateKey]}`);
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
return errors.join(', ');
|
|
40
|
+
};
|
|
41
|
+
const getMultipleError = (role, options) => `Found multiple elements with ${buildErrorMessage(role, options)}`;
|
|
42
|
+
const getMissingError = (role, options) => `Unable to find an element with ${buildErrorMessage(role, options)}`;
|
|
31
43
|
const {
|
|
32
44
|
getBy,
|
|
33
45
|
getAllBy,
|
|
@@ -36,7 +48,6 @@ const {
|
|
|
36
48
|
findBy,
|
|
37
49
|
findAllBy
|
|
38
50
|
} = (0, _makeQueries.makeQueries)(queryAllByRole, getMissingError, getMultipleError);
|
|
39
|
-
|
|
40
51
|
const bindByRoleQueries = instance => ({
|
|
41
52
|
getByRole: getBy(instance),
|
|
42
53
|
getAllByRole: getAllBy(instance),
|
|
@@ -45,6 +56,5 @@ const bindByRoleQueries = instance => ({
|
|
|
45
56
|
findByRole: findBy(instance),
|
|
46
57
|
findAllByRole: findAllBy(instance)
|
|
47
58
|
});
|
|
48
|
-
|
|
49
59
|
exports.bindByRoleQueries = bindByRoleQueries;
|
|
50
60
|
//# sourceMappingURL=role.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"role.js","names":["matchAccessibleNameIfNeeded","node","name","queryAllByText","queryAllByLabelText","getQueriesForElement","length","queryAllByRole","instance","queryAllByRoleFn","role","
|
|
1
|
+
{"version":3,"file":"role.js","names":["matchAccessibleNameIfNeeded","node","name","queryAllByText","queryAllByLabelText","getQueriesForElement","length","matchAccessibleStateIfNeeded","options","matchAccessibilityState","queryAllByRole","instance","queryAllByRoleFn","role","findAll","type","matchStringProp","props","accessibilityRole","buildErrorMessage","errors","String","push","accessibilityStateKeys","forEach","stateKey","undefined","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 { accessibilityStateKeys } from '../helpers/accessiblity';\nimport { matchAccessibilityState } from '../helpers/matchers/accessibilityState';\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';\n\ntype ByRoleOptions = {\n name?: TextMatch;\n} & AccessibilityState;\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 queryAllByRole = (\n instance: ReactTestInstance\n): ((role: TextMatch, options?: ByRoleOptions) => Array<ReactTestInstance>) =>\n function queryAllByRoleFn(role, options) {\n return instance.findAll(\n (node) =>\n // run the cheapest checks first, and early exit too avoid unneeded computations\n\n typeof node.type === 'string' &&\n matchStringProp(node.props.accessibilityRole, role) &&\n matchAccessibleStateIfNeeded(node, options) &&\n matchAccessibleNameIfNeeded(node, options?.name)\n );\n };\n\nconst buildErrorMessage = (role: TextMatch, options: ByRoleOptions = {}) => {\n const errors = [`role: \"${String(role)}\"`];\n\n if (options.name) {\n errors.push(`name: \"${String(options.name)}\"`);\n }\n\n accessibilityStateKeys.forEach((stateKey) => {\n if (options[stateKey] !== undefined) {\n errors.push(`${stateKey} state: ${options[stateKey]}`);\n }\n });\n\n return errors.join(', ');\n};\n\nconst getMultipleError = (role: TextMatch, options?: ByRoleOptions) =>\n `Found multiple elements with ${buildErrorMessage(role, options)}`;\n\nconst getMissingError = (role: TextMatch, options?: ByRoleOptions) =>\n `Unable to find an element with ${buildErrorMessage(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;AACA;AACA;AAEA;AACA;AAcA,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,cAAc,GAClBC,QAA2B,IAE3B,SAASC,gBAAgB,CAACC,IAAI,EAAEL,OAAO,EAAE;EACvC,OAAOG,QAAQ,CAACG,OAAO,CACpBb,IAAI;EACH;;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,MAAMS,iBAAiB,GAC5B1B,QAA2B,KACR;EACnB2B,SAAS,EAAER,KAAK,CAACnB,QAAQ,CAAC;EAC1B4B,YAAY,EAAER,QAAQ,CAACpB,QAAQ,CAAC;EAChC6B,WAAW,EAAER,OAAO,CAACrB,QAAQ,CAAC;EAC9BD,cAAc,EAAEuB,UAAU,CAACtB,QAAQ,CAAC;EACpC8B,UAAU,EAAEP,MAAM,CAACvB,QAAQ,CAAC;EAC5B+B,aAAa,EAAEP,SAAS,CAACxB,QAAQ;AACnC,CAAC,CAAC;AAAC"}
|
package/build/queries/testId.js
CHANGED
|
@@ -4,11 +4,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.bindByTestIdQueries = void 0;
|
|
7
|
-
|
|
8
7
|
var _matches = require("../matches");
|
|
9
|
-
|
|
10
8
|
var _makeQueries = require("./makeQueries");
|
|
11
|
-
|
|
12
9
|
const getNodeByTestId = (node, testID, options = {}) => {
|
|
13
10
|
const {
|
|
14
11
|
exact,
|
|
@@ -16,16 +13,12 @@ const getNodeByTestId = (node, testID, options = {}) => {
|
|
|
16
13
|
} = options;
|
|
17
14
|
return (0, _matches.matches)(testID, node.props.testID, normalizer, exact);
|
|
18
15
|
};
|
|
19
|
-
|
|
20
16
|
const queryAllByTestId = instance => function queryAllByTestIdFn(testId, queryOptions) {
|
|
21
17
|
const results = instance.findAll(node => getNodeByTestId(node, testId, queryOptions)).filter(element => typeof element.type === 'string');
|
|
22
18
|
return results;
|
|
23
19
|
};
|
|
24
|
-
|
|
25
20
|
const getMultipleError = testId => `Found multiple elements with testID: ${String(testId)}`;
|
|
26
|
-
|
|
27
21
|
const getMissingError = testId => `Unable to find an element with testID: ${String(testId)}`;
|
|
28
|
-
|
|
29
22
|
const {
|
|
30
23
|
getBy,
|
|
31
24
|
getAllBy,
|
|
@@ -34,7 +27,6 @@ const {
|
|
|
34
27
|
findBy,
|
|
35
28
|
findAllBy
|
|
36
29
|
} = (0, _makeQueries.makeQueries)(queryAllByTestId, getMissingError, getMultipleError);
|
|
37
|
-
|
|
38
30
|
const bindByTestIdQueries = instance => ({
|
|
39
31
|
getByTestId: getBy(instance),
|
|
40
32
|
getAllByTestId: getAllBy(instance),
|
|
@@ -43,6 +35,5 @@ const bindByTestIdQueries = instance => ({
|
|
|
43
35
|
findByTestId: findBy(instance),
|
|
44
36
|
findAllByTestId: findAllBy(instance)
|
|
45
37
|
});
|
|
46
|
-
|
|
47
38
|
exports.bindByTestIdQueries = bindByTestIdQueries;
|
|
48
39
|
//# sourceMappingURL=testId.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"testId.js","names":["getNodeByTestId","node","testID","options","exact","normalizer","matches","props","queryAllByTestId","instance","queryAllByTestIdFn","testId","queryOptions","results","findAll","filter","element","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 { 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 { TextMatchOptions } from './text';\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?: TextMatchOptions\n) => Array<ReactTestInstance>) =>\n function queryAllByTestIdFn(testId, queryOptions) {\n const results = instance\n .findAll((node) => getNodeByTestId(node, testId, queryOptions))\n .filter((element) => typeof element.type === 'string');\n\n return results;\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, TextMatchOptions>;\n getAllByTestId: GetAllByQuery<TextMatch, TextMatchOptions>;\n queryByTestId: QueryByQuery<TextMatch, TextMatchOptions>;\n queryAllByTestId: QueryAllByQuery<TextMatch, TextMatchOptions>;\n findByTestId: FindByQuery<TextMatch, TextMatchOptions>;\n findAllByTestId: FindAllByQuery<TextMatch, TextMatchOptions>;\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":"
|
|
1
|
+
{"version":3,"file":"testId.js","names":["getNodeByTestId","node","testID","options","exact","normalizer","matches","props","queryAllByTestId","instance","queryAllByTestIdFn","testId","queryOptions","results","findAll","filter","element","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 { 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 { TextMatchOptions } from './text';\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?: TextMatchOptions\n) => Array<ReactTestInstance>) =>\n function queryAllByTestIdFn(testId, queryOptions) {\n const results = instance\n .findAll((node) => getNodeByTestId(node, testId, queryOptions))\n .filter((element) => typeof element.type === 'string');\n\n return results;\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, TextMatchOptions>;\n getAllByTestId: GetAllByQuery<TextMatch, TextMatchOptions>;\n queryByTestId: QueryByQuery<TextMatch, TextMatchOptions>;\n queryAllByTestId: QueryAllByQuery<TextMatch, TextMatchOptions>;\n findByTestId: FindByQuery<TextMatch, TextMatchOptions>;\n findAllByTestId: FindAllByQuery<TextMatch, TextMatchOptions>;\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;AAWA,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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