@testing-library/react-native 11.5.0 → 11.5.1
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/host-component-names.d.ts +2 -0
- package/build/helpers/host-component-names.js +50 -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/timers.d.ts +0 -2
- package/build/index.flow.js +1 -0
- 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/within.d.ts +18 -18
- package/package.json +13 -14
- package/typings/index.flow.js +1 -0
package/build/act.d.ts
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
|
+
import { act as reactTestRendererAct } from 'react-test-renderer';
|
|
2
|
+
type ReactAct = typeof reactTestRendererAct;
|
|
1
3
|
declare global {
|
|
2
4
|
var IS_REACT_ACT_ENVIRONMENT: boolean | undefined;
|
|
3
5
|
}
|
|
4
6
|
declare function setIsReactActEnvironment(isReactActEnvironment: boolean | undefined): void;
|
|
5
7
|
declare function getIsReactActEnvironment(): boolean | undefined;
|
|
6
|
-
declare const act:
|
|
8
|
+
declare const act: ReactAct;
|
|
7
9
|
export default act;
|
|
8
10
|
export { setIsReactActEnvironment as setReactActEnvironment, getIsReactActEnvironment, };
|
package/build/act.js
CHANGED
|
@@ -11,12 +11,6 @@ var _reactVersions = require("./react-versions");
|
|
|
11
11
|
// This file and the act() implementation is sourced from react-testing-library
|
|
12
12
|
// https://github.com/testing-library/react-testing-library/blob/c80809a956b0b9f3289c4a6fa8b5e8cc72d6ef6d/src/act-compat.js
|
|
13
13
|
|
|
14
|
-
const actMock = callback => {
|
|
15
|
-
callback();
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
// See https://github.com/reactwg/react-18/discussions/102 for more context on global.IS_REACT_ACT_ENVIRONMENT
|
|
19
|
-
|
|
20
14
|
function setIsReactActEnvironment(isReactActEnvironment) {
|
|
21
15
|
globalThis.IS_REACT_ACT_ENVIRONMENT = isReactActEnvironment;
|
|
22
16
|
}
|
|
@@ -70,13 +64,7 @@ function withGlobalActEnvironment(actImplementation) {
|
|
|
70
64
|
}
|
|
71
65
|
};
|
|
72
66
|
}
|
|
73
|
-
const
|
|
74
|
-
if (!_reactTestRenderer.act) {
|
|
75
|
-
return actMock;
|
|
76
|
-
}
|
|
77
|
-
return (0, _reactVersions.checkReactVersionAtLeast)(18, 0) ? withGlobalActEnvironment(_reactTestRenderer.act) : _reactTestRenderer.act;
|
|
78
|
-
};
|
|
79
|
-
const act = getAct();
|
|
67
|
+
const act = (0, _reactVersions.checkReactVersionAtLeast)(18, 0) ? withGlobalActEnvironment(_reactTestRenderer.act) : _reactTestRenderer.act;
|
|
80
68
|
var _default = act;
|
|
81
69
|
exports.default = _default;
|
|
82
70
|
//# sourceMappingURL=act.js.map
|
package/build/act.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"act.js","names":["
|
|
1
|
+
{"version":3,"file":"act.js","names":["setIsReactActEnvironment","isReactActEnvironment","globalThis","IS_REACT_ACT_ENVIRONMENT","getIsReactActEnvironment","withGlobalActEnvironment","actImplementation","callback","previousActEnvironment","callbackNeedsToBeAwaited","actResult","result","then","thenable","resolve","reject","returnValue","error","act","checkReactVersionAtLeast","reactTestRendererAct"],"sources":["../src/act.ts"],"sourcesContent":["// This file and the act() implementation is sourced from react-testing-library\n// https://github.com/testing-library/react-testing-library/blob/c80809a956b0b9f3289c4a6fa8b5e8cc72d6ef6d/src/act-compat.js\nimport { act as reactTestRendererAct } from 'react-test-renderer';\nimport { checkReactVersionAtLeast } from './react-versions';\n\ntype ReactAct = typeof reactTestRendererAct;\n\n// See https://github.com/reactwg/react-18/discussions/102 for more context on global.IS_REACT_ACT_ENVIRONMENT\ndeclare global {\n var IS_REACT_ACT_ENVIRONMENT: boolean | undefined;\n}\n\nfunction setIsReactActEnvironment(isReactActEnvironment: boolean | undefined) {\n globalThis.IS_REACT_ACT_ENVIRONMENT = isReactActEnvironment;\n}\n\nfunction getIsReactActEnvironment() {\n return globalThis.IS_REACT_ACT_ENVIRONMENT;\n}\n\nfunction withGlobalActEnvironment(actImplementation: ReactAct) {\n return (callback: Parameters<ReactAct>[0]) => {\n const previousActEnvironment = getIsReactActEnvironment();\n setIsReactActEnvironment(true);\n\n // this code is riddled with eslint disabling comments because this doesn't use real promises but eslint thinks we do\n try {\n // The return value of `act` is always a thenable.\n let callbackNeedsToBeAwaited = false;\n const actResult = actImplementation(() => {\n const result = callback();\n if (\n result !== null &&\n typeof result === 'object' &&\n // @ts-expect-error this should be a promise or thenable\n // eslint-disable-next-line promise/prefer-await-to-then\n typeof result.then === 'function'\n ) {\n callbackNeedsToBeAwaited = true;\n }\n return result;\n });\n\n if (callbackNeedsToBeAwaited) {\n const thenable = actResult;\n return {\n then: (\n resolve: (value: never) => never,\n reject: (value: never) => never\n ) => {\n // eslint-disable-next-line\n thenable.then(\n // eslint-disable-next-line promise/always-return\n (returnValue) => {\n setIsReactActEnvironment(previousActEnvironment);\n resolve(returnValue);\n },\n (error) => {\n setIsReactActEnvironment(previousActEnvironment);\n reject(error);\n }\n );\n },\n };\n } else {\n setIsReactActEnvironment(previousActEnvironment);\n return actResult;\n }\n } catch (error) {\n // Can't be a `finally {}` block since we don't know if we have to immediately restore IS_REACT_ACT_ENVIRONMENT\n // or if we have to await the callback first.\n setIsReactActEnvironment(previousActEnvironment);\n throw error;\n }\n };\n}\n\nconst act: ReactAct = checkReactVersionAtLeast(18, 0)\n ? (withGlobalActEnvironment(reactTestRendererAct) as ReactAct)\n : reactTestRendererAct;\n\nexport default act;\nexport {\n setIsReactActEnvironment as setReactActEnvironment,\n getIsReactActEnvironment,\n};\n"],"mappings":";;;;;;;;AAEA;AACA;AAHA;AACA;;AAWA,SAASA,wBAAwB,CAACC,qBAA0C,EAAE;EAC5EC,UAAU,CAACC,wBAAwB,GAAGF,qBAAqB;AAC7D;AAEA,SAASG,wBAAwB,GAAG;EAClC,OAAOF,UAAU,CAACC,wBAAwB;AAC5C;AAEA,SAASE,wBAAwB,CAACC,iBAA2B,EAAE;EAC7D,OAAQC,QAAiC,IAAK;IAC5C,MAAMC,sBAAsB,GAAGJ,wBAAwB,EAAE;IACzDJ,wBAAwB,CAAC,IAAI,CAAC;;IAE9B;IACA,IAAI;MACF;MACA,IAAIS,wBAAwB,GAAG,KAAK;MACpC,MAAMC,SAAS,GAAGJ,iBAAiB,CAAC,MAAM;QACxC,MAAMK,MAAM,GAAGJ,QAAQ,EAAE;QACzB,IACEI,MAAM,KAAK,IAAI,IACf,OAAOA,MAAM,KAAK,QAAQ;QAC1B;QACA;QACA,OAAOA,MAAM,CAACC,IAAI,KAAK,UAAU,EACjC;UACAH,wBAAwB,GAAG,IAAI;QACjC;QACA,OAAOE,MAAM;MACf,CAAC,CAAC;MAEF,IAAIF,wBAAwB,EAAE;QAC5B,MAAMI,QAAQ,GAAGH,SAAS;QAC1B,OAAO;UACLE,IAAI,EAAE,CACJE,OAAgC,EAChCC,MAA+B,KAC5B;YACH;YACAF,QAAQ,CAACD,IAAI;YACX;YACCI,WAAW,IAAK;cACfhB,wBAAwB,CAACQ,sBAAsB,CAAC;cAChDM,OAAO,CAACE,WAAW,CAAC;YACtB,CAAC,EACAC,KAAK,IAAK;cACTjB,wBAAwB,CAACQ,sBAAsB,CAAC;cAChDO,MAAM,CAACE,KAAK,CAAC;YACf,CAAC,CACF;UACH;QACF,CAAC;MACH,CAAC,MAAM;QACLjB,wBAAwB,CAACQ,sBAAsB,CAAC;QAChD,OAAOE,SAAS;MAClB;IACF,CAAC,CAAC,OAAOO,KAAK,EAAE;MACd;MACA;MACAjB,wBAAwB,CAACQ,sBAAsB,CAAC;MAChD,MAAMS,KAAK;IACb;EACF,CAAC;AACH;AAEA,MAAMC,GAAa,GAAG,IAAAC,uCAAwB,EAAC,EAAE,EAAE,CAAC,CAAC,GAChDd,wBAAwB,CAACe,sBAAoB,CAAC,GAC/CA,sBAAoB;AAAC,eAEVF,GAAG;AAAA"}
|
package/build/config.d.ts
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
import { DebugOptions } from './helpers/debugDeep';
|
|
2
|
+
/**
|
|
3
|
+
* Global configuration options for React Native Testing Library.
|
|
4
|
+
*/
|
|
2
5
|
export type Config = {
|
|
3
6
|
/** Default timeout, in ms, for `waitFor` and `findBy*` queries. */
|
|
4
7
|
asyncUtilTimeout: number;
|
|
@@ -11,7 +14,21 @@ export type ConfigAliasOptions = {
|
|
|
11
14
|
/** RTL-compatibility alias to `defaultIncludeHiddenElements` */
|
|
12
15
|
defaultHidden: boolean;
|
|
13
16
|
};
|
|
17
|
+
export type HostComponentNames = {
|
|
18
|
+
text: string;
|
|
19
|
+
textInput: string;
|
|
20
|
+
};
|
|
21
|
+
export type InternalConfig = Config & {
|
|
22
|
+
/** Whether to use breaking changes intended for next major version release. */
|
|
23
|
+
useBreakingChanges: boolean;
|
|
24
|
+
/** Names for key React Native host components. */
|
|
25
|
+
hostComponentNames?: HostComponentNames;
|
|
26
|
+
};
|
|
27
|
+
/**
|
|
28
|
+
* Configure global options for React Native Testing Library.
|
|
29
|
+
*/
|
|
14
30
|
export declare function configure(options: Partial<Config & ConfigAliasOptions>): void;
|
|
31
|
+
export declare function configureInternal(option: Partial<InternalConfig>): void;
|
|
15
32
|
export declare function resetToDefaults(): void;
|
|
16
33
|
export declare function getConfig(): {
|
|
17
34
|
/** Default timeout, in ms, for `waitFor` and `findBy*` queries. */
|
|
@@ -20,4 +37,8 @@ export declare function getConfig(): {
|
|
|
20
37
|
defaultIncludeHiddenElements: boolean;
|
|
21
38
|
/** Default options for `debug` helper. */
|
|
22
39
|
defaultDebugOptions?: Partial<DebugOptions> | undefined;
|
|
40
|
+
/** Whether to use breaking changes intended for next major version release. */
|
|
41
|
+
useBreakingChanges: boolean;
|
|
42
|
+
/** Names for key React Native host components. */
|
|
43
|
+
hostComponentNames?: HostComponentNames | undefined;
|
|
23
44
|
};
|
package/build/config.js
CHANGED
|
@@ -4,15 +4,25 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.configure = configure;
|
|
7
|
+
exports.configureInternal = configureInternal;
|
|
7
8
|
exports.getConfig = getConfig;
|
|
8
9
|
exports.resetToDefaults = resetToDefaults;
|
|
10
|
+
/**
|
|
11
|
+
* Global configuration options for React Native Testing Library.
|
|
12
|
+
*/
|
|
13
|
+
|
|
9
14
|
const defaultConfig = {
|
|
15
|
+
useBreakingChanges: false,
|
|
10
16
|
asyncUtilTimeout: 1000,
|
|
11
17
|
defaultIncludeHiddenElements: true
|
|
12
18
|
};
|
|
13
19
|
let config = {
|
|
14
20
|
...defaultConfig
|
|
15
21
|
};
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Configure global options for React Native Testing Library.
|
|
25
|
+
*/
|
|
16
26
|
function configure(options) {
|
|
17
27
|
const {
|
|
18
28
|
defaultHidden,
|
|
@@ -25,6 +35,12 @@ function configure(options) {
|
|
|
25
35
|
defaultIncludeHiddenElements
|
|
26
36
|
};
|
|
27
37
|
}
|
|
38
|
+
function configureInternal(option) {
|
|
39
|
+
config = {
|
|
40
|
+
...config,
|
|
41
|
+
...option
|
|
42
|
+
};
|
|
43
|
+
}
|
|
28
44
|
function resetToDefaults() {
|
|
29
45
|
config = {
|
|
30
46
|
...defaultConfig
|
package/build/config.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.js","names":["defaultConfig","asyncUtilTimeout","defaultIncludeHiddenElements","config","configure","options","defaultHidden","restOptions","resetToDefaults","getConfig"],"sources":["../src/config.ts"],"sourcesContent":["import { DebugOptions } from './helpers/debugDeep';\n\nexport type Config = {\n /** Default timeout, in ms, for `waitFor` and `findBy*` queries. */\n asyncUtilTimeout: number;\n\n /** Default value for `includeHiddenElements` query option. */\n defaultIncludeHiddenElements: boolean;\n\n /** Default options for `debug` helper. */\n defaultDebugOptions?: Partial<DebugOptions>;\n};\n\nexport type ConfigAliasOptions = {\n /** RTL-compatibility alias to `defaultIncludeHiddenElements` */\n defaultHidden: boolean;\n};\n\nconst defaultConfig:
|
|
1
|
+
{"version":3,"file":"config.js","names":["defaultConfig","useBreakingChanges","asyncUtilTimeout","defaultIncludeHiddenElements","config","configure","options","defaultHidden","restOptions","configureInternal","option","resetToDefaults","getConfig"],"sources":["../src/config.ts"],"sourcesContent":["import { DebugOptions } from './helpers/debugDeep';\n\n/**\n * Global configuration options for React Native Testing Library.\n */\n\nexport type Config = {\n /** Default timeout, in ms, for `waitFor` and `findBy*` queries. */\n asyncUtilTimeout: number;\n\n /** Default value for `includeHiddenElements` query option. */\n defaultIncludeHiddenElements: boolean;\n\n /** Default options for `debug` helper. */\n defaultDebugOptions?: Partial<DebugOptions>;\n};\n\nexport type ConfigAliasOptions = {\n /** RTL-compatibility alias to `defaultIncludeHiddenElements` */\n defaultHidden: boolean;\n};\n\nexport type HostComponentNames = {\n text: string;\n textInput: string;\n};\n\nexport type InternalConfig = Config & {\n /** Whether to use breaking changes intended for next major version release. */\n useBreakingChanges: boolean;\n\n /** Names for key React Native host components. */\n hostComponentNames?: HostComponentNames;\n};\n\nconst defaultConfig: InternalConfig = {\n useBreakingChanges: false,\n asyncUtilTimeout: 1000,\n defaultIncludeHiddenElements: true,\n};\n\nlet config = { ...defaultConfig };\n\n/**\n * Configure global options for React Native Testing Library.\n */\nexport function configure(options: Partial<Config & ConfigAliasOptions>) {\n const { defaultHidden, ...restOptions } = options;\n\n const defaultIncludeHiddenElements =\n restOptions.defaultIncludeHiddenElements ??\n defaultHidden ??\n config.defaultIncludeHiddenElements;\n\n config = {\n ...config,\n ...restOptions,\n defaultIncludeHiddenElements,\n };\n}\n\nexport function configureInternal(option: Partial<InternalConfig>) {\n config = {\n ...config,\n ...option,\n };\n}\n\nexport function resetToDefaults() {\n config = { ...defaultConfig };\n}\n\nexport function getConfig() {\n return config;\n}\n"],"mappings":";;;;;;;;;AAEA;AACA;AACA;;AA+BA,MAAMA,aAA6B,GAAG;EACpCC,kBAAkB,EAAE,KAAK;EACzBC,gBAAgB,EAAE,IAAI;EACtBC,4BAA4B,EAAE;AAChC,CAAC;AAED,IAAIC,MAAM,GAAG;EAAE,GAAGJ;AAAc,CAAC;;AAEjC;AACA;AACA;AACO,SAASK,SAAS,CAACC,OAA6C,EAAE;EACvE,MAAM;IAAEC,aAAa;IAAE,GAAGC;EAAY,CAAC,GAAGF,OAAO;EAEjD,MAAMH,4BAA4B,GAChCK,WAAW,CAACL,4BAA4B,IACxCI,aAAa,IACbH,MAAM,CAACD,4BAA4B;EAErCC,MAAM,GAAG;IACP,GAAGA,MAAM;IACT,GAAGI,WAAW;IACdL;EACF,CAAC;AACH;AAEO,SAASM,iBAAiB,CAACC,MAA+B,EAAE;EACjEN,MAAM,GAAG;IACP,GAAGA,MAAM;IACT,GAAGM;EACL,CAAC;AACH;AAEO,SAASC,eAAe,GAAG;EAChCP,MAAM,GAAG;IAAE,GAAGJ;EAAc,CAAC;AAC/B;AAEO,SAASY,SAAS,GAAG;EAC1B,OAAOR,MAAM;AACf"}
|
package/build/fireEvent.js
CHANGED
|
@@ -8,6 +8,7 @@ var _reactNative = require("react-native");
|
|
|
8
8
|
var _act = _interopRequireDefault(require("./act"));
|
|
9
9
|
var _componentTree = require("./helpers/component-tree");
|
|
10
10
|
var _filterNodeByType = require("./helpers/filterNodeByType");
|
|
11
|
+
var _hostComponentNames = require("./helpers/host-component-names");
|
|
11
12
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
12
13
|
const isTextInput = element => {
|
|
13
14
|
if (!element) {
|
|
@@ -17,10 +18,9 @@ const isTextInput = element => {
|
|
|
17
18
|
// We have to test if the element type is either the TextInput component
|
|
18
19
|
// (which would if it is a composite component) or the string
|
|
19
20
|
// TextInput (which would be true if it is a host component)
|
|
20
|
-
// All queries
|
|
21
|
-
// if all queries returned host components, since fireEvent bubbles up
|
|
21
|
+
// All queries return host components but since fireEvent bubbles up
|
|
22
22
|
// it would trigger the parent prop without the composite component check
|
|
23
|
-
return (0, _filterNodeByType.filterNodeByType)(element, _reactNative.TextInput) || (0, _filterNodeByType.filterNodeByType)(element,
|
|
23
|
+
return (0, _filterNodeByType.filterNodeByType)(element, _reactNative.TextInput) || (0, _filterNodeByType.filterNodeByType)(element, (0, _hostComponentNames.getHostComponentNames)().textInput);
|
|
24
24
|
};
|
|
25
25
|
const isTouchResponder = element => {
|
|
26
26
|
if (!(0, _componentTree.isHostElement)(element)) return false;
|
package/build/fireEvent.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fireEvent.js","names":["isTextInput","element","filterNodeByType","TextInput","isTouchResponder","isHostElement","props","onStartShouldSetResponder","isPointerEventEnabled","isParent","parentCondition","pointerEvents","parent","isTouchEvent","eventName","isEventEnabled","touchResponder","editable","touchStart","touchMove","onMoveShouldSetResponder","undefined","findEventHandler","callsite","nearestTouchResponder","handler","getEventHandler","eventHandlerName","toEventHandlerName","invokeEvent","data","returnValue","act","charAt","toUpperCase","slice","pressHandler","changeTextHandler","scrollHandler","fireEvent","press","changeText","scroll"],"sources":["../src/fireEvent.ts"],"sourcesContent":["import { ReactTestInstance } from 'react-test-renderer';\nimport { TextInput } from 'react-native';\nimport act from './act';\nimport { isHostElement } from './helpers/component-tree';\nimport { filterNodeByType } from './helpers/filterNodeByType';\n\ntype EventHandler = (...args: any) => unknown;\n\nconst isTextInput = (element?: ReactTestInstance) => {\n if (!element) {\n return false;\n }\n\n // We have to test if the element type is either the TextInput component\n // (which would if it is a composite component) or the string\n // TextInput (which would be true if it is a host component)\n // All queries
|
|
1
|
+
{"version":3,"file":"fireEvent.js","names":["isTextInput","element","filterNodeByType","TextInput","getHostComponentNames","textInput","isTouchResponder","isHostElement","props","onStartShouldSetResponder","isPointerEventEnabled","isParent","parentCondition","pointerEvents","parent","isTouchEvent","eventName","isEventEnabled","touchResponder","editable","touchStart","touchMove","onMoveShouldSetResponder","undefined","findEventHandler","callsite","nearestTouchResponder","handler","getEventHandler","eventHandlerName","toEventHandlerName","invokeEvent","data","returnValue","act","charAt","toUpperCase","slice","pressHandler","changeTextHandler","scrollHandler","fireEvent","press","changeText","scroll"],"sources":["../src/fireEvent.ts"],"sourcesContent":["import { ReactTestInstance } from 'react-test-renderer';\nimport { TextInput } from 'react-native';\nimport act from './act';\nimport { isHostElement } from './helpers/component-tree';\nimport { filterNodeByType } from './helpers/filterNodeByType';\nimport { getHostComponentNames } from './helpers/host-component-names';\n\ntype EventHandler = (...args: any) => unknown;\n\nconst isTextInput = (element?: ReactTestInstance) => {\n if (!element) {\n return false;\n }\n\n // We have to test if the element type is either the TextInput component\n // (which would if it is a composite component) or the string\n // TextInput (which would be true if it is a host component)\n // All queries return host components but since fireEvent bubbles up\n // it would trigger the parent prop without the composite component check\n return (\n filterNodeByType(element, TextInput) ||\n filterNodeByType(element, getHostComponentNames().textInput)\n );\n};\n\nconst isTouchResponder = (element?: ReactTestInstance) => {\n if (!isHostElement(element)) return false;\n\n return !!element?.props.onStartShouldSetResponder || isTextInput(element);\n};\n\nconst isPointerEventEnabled = (\n element?: ReactTestInstance,\n isParent?: boolean\n): boolean => {\n const parentCondition = isParent\n ? element?.props.pointerEvents === 'box-only'\n : element?.props.pointerEvents === 'box-none';\n\n if (element?.props.pointerEvents === 'none' || parentCondition) {\n return false;\n }\n\n if (!element?.parent) return true;\n\n return isPointerEventEnabled(element.parent, true);\n};\n\nconst isTouchEvent = (eventName?: string) => {\n return eventName === 'press';\n};\n\nconst isEventEnabled = (\n element?: ReactTestInstance,\n touchResponder?: ReactTestInstance,\n eventName?: string\n) => {\n if (isTextInput(element)) return element?.props.editable !== false;\n if (!isPointerEventEnabled(element) && isTouchEvent(eventName)) return false;\n\n const touchStart = touchResponder?.props.onStartShouldSetResponder?.();\n const touchMove = touchResponder?.props.onMoveShouldSetResponder?.();\n\n if (touchStart || touchMove) return true;\n\n return touchStart === undefined && touchMove === undefined;\n};\n\nconst findEventHandler = (\n element: ReactTestInstance,\n eventName: string,\n callsite?: any,\n nearestTouchResponder?: ReactTestInstance\n): EventHandler | null => {\n const touchResponder = isTouchResponder(element)\n ? element\n : nearestTouchResponder;\n\n const handler = getEventHandler(element, eventName);\n if (handler && isEventEnabled(element, touchResponder, eventName))\n return handler;\n\n if (element.parent === null || element.parent.parent === null) {\n return null;\n }\n\n return findEventHandler(element.parent, eventName, callsite, touchResponder);\n};\n\nconst getEventHandler = (\n element: ReactTestInstance,\n eventName: string\n): EventHandler | undefined => {\n const eventHandlerName = toEventHandlerName(eventName);\n if (typeof element.props[eventHandlerName] === 'function') {\n return element.props[eventHandlerName];\n }\n\n if (typeof element.props[eventName] === 'function') {\n return element.props[eventName];\n }\n\n return undefined;\n};\n\nconst invokeEvent = (\n element: ReactTestInstance,\n eventName: string,\n callsite?: any,\n ...data: Array<any>\n) => {\n const handler = findEventHandler(element, eventName, callsite);\n\n if (!handler) {\n return;\n }\n\n let returnValue;\n\n act(() => {\n returnValue = handler(...data);\n });\n\n return returnValue;\n};\n\nconst toEventHandlerName = (eventName: string) =>\n `on${eventName.charAt(0).toUpperCase()}${eventName.slice(1)}`;\n\nconst pressHandler = (element: ReactTestInstance, ...data: Array<any>): void =>\n invokeEvent(element, 'press', pressHandler, ...data);\nconst changeTextHandler = (\n element: ReactTestInstance,\n ...data: Array<any>\n): void => invokeEvent(element, 'changeText', changeTextHandler, ...data);\nconst scrollHandler = (element: ReactTestInstance, ...data: Array<any>): void =>\n invokeEvent(element, 'scroll', scrollHandler, ...data);\n\nconst fireEvent = (\n element: ReactTestInstance,\n eventName: string,\n ...data: Array<any>\n): void => invokeEvent(element, eventName, fireEvent, ...data);\n\nfireEvent.press = pressHandler;\nfireEvent.changeText = changeTextHandler;\nfireEvent.scroll = scrollHandler;\n\nexport default fireEvent;\n"],"mappings":"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"}
|
|
@@ -8,4 +8,5 @@ export declare const accessiblityValueKeys: (keyof AccessibilityValue)[];
|
|
|
8
8
|
export declare function isHiddenFromAccessibility(element: ReactTestInstance | null, { cache }?: IsInaccessibleOptions): boolean;
|
|
9
9
|
/** RTL-compatitibility alias for `isHiddenFromAccessibility` */
|
|
10
10
|
export declare const isInaccessible: typeof isHiddenFromAccessibility;
|
|
11
|
+
export declare function isAccessibilityElement(element: ReactTestInstance | null): boolean;
|
|
11
12
|
export {};
|
|
@@ -4,6 +4,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.accessiblityValueKeys = exports.accessibilityStateKeys = void 0;
|
|
7
|
+
exports.isAccessibilityElement = isAccessibilityElement;
|
|
7
8
|
exports.isHiddenFromAccessibility = isHiddenFromAccessibility;
|
|
8
9
|
exports.isInaccessible = void 0;
|
|
9
10
|
var _reactNative = require("react-native");
|
|
@@ -61,4 +62,13 @@ function isSubtreeInaccessible(element) {
|
|
|
61
62
|
}
|
|
62
63
|
return false;
|
|
63
64
|
}
|
|
65
|
+
function isAccessibilityElement(element) {
|
|
66
|
+
if (element == null) {
|
|
67
|
+
return false;
|
|
68
|
+
}
|
|
69
|
+
if (element.props.accessible !== undefined) {
|
|
70
|
+
return element.props.accessible;
|
|
71
|
+
}
|
|
72
|
+
return (0, _componentTree.isHostElementForType)(element, _reactNative.Text) || (0, _componentTree.isHostElementForType)(element, _reactNative.TextInput) || (0, _componentTree.isHostElementForType)(element, _reactNative.Switch);
|
|
73
|
+
}
|
|
64
74
|
//# sourceMappingURL=accessiblity.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"accessiblity.js","names":["accessibilityStateKeys","accessiblityValueKeys","isHiddenFromAccessibility","element","cache","current","isCurrentSubtreeInaccessible","get","undefined","isSubtreeInaccessible","set","parent","isInaccessible","props","accessibilityElementsHidden","importantForAccessibility","flatStyle","StyleSheet","flatten","style","display","hostSiblings","getHostSiblings","some","sibling","accessibilityViewIsModal"],"sources":["../../src/helpers/accessiblity.ts"],"sourcesContent":["import {\n AccessibilityState,\n AccessibilityValue,\n StyleSheet,\n} from 'react-native';\nimport { ReactTestInstance } from 'react-test-renderer';\nimport { getHostSiblings } from './component-tree';\n\ntype IsInaccessibleOptions = {\n cache?: WeakMap<ReactTestInstance, boolean>;\n};\n\nexport const accessibilityStateKeys: (keyof AccessibilityState)[] = [\n 'disabled',\n 'selected',\n 'checked',\n 'busy',\n 'expanded',\n];\n\nexport const accessiblityValueKeys: (keyof AccessibilityValue)[] = [\n 'min',\n 'max',\n 'now',\n 'text',\n];\n\nexport function isHiddenFromAccessibility(\n element: ReactTestInstance | null,\n { cache }: IsInaccessibleOptions = {}\n): boolean {\n if (element == null) {\n return true;\n }\n\n let current: ReactTestInstance | null = element;\n while (current) {\n let isCurrentSubtreeInaccessible = cache?.get(current);\n\n if (isCurrentSubtreeInaccessible === undefined) {\n isCurrentSubtreeInaccessible = isSubtreeInaccessible(current);\n cache?.set(current, isCurrentSubtreeInaccessible);\n }\n\n if (isCurrentSubtreeInaccessible) {\n return true;\n }\n\n current = current.parent;\n }\n\n return false;\n}\n\n/** RTL-compatitibility alias for `isHiddenFromAccessibility` */\nexport const isInaccessible = isHiddenFromAccessibility;\n\nfunction isSubtreeInaccessible(element: ReactTestInstance): boolean {\n // iOS: accessibilityElementsHidden\n // See: https://reactnative.dev/docs/accessibility#accessibilityelementshidden-ios\n if (element.props.accessibilityElementsHidden) {\n return true;\n }\n\n // Android: importantForAccessibility\n // See: https://reactnative.dev/docs/accessibility#importantforaccessibility-android\n if (element.props.importantForAccessibility === 'no-hide-descendants') {\n return true;\n }\n\n // Note that `opacity: 0` is not treated as inaccessible on iOS\n const flatStyle = StyleSheet.flatten(element.props.style) ?? {};\n if (flatStyle.display === 'none') return true;\n\n // iOS: accessibilityViewIsModal\n // See: https://reactnative.dev/docs/accessibility#accessibilityviewismodal-ios\n const hostSiblings = getHostSiblings(element);\n if (hostSiblings.some((sibling) => sibling.props.accessibilityViewIsModal)) {\n return true;\n }\n\n return false;\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"accessiblity.js","names":["accessibilityStateKeys","accessiblityValueKeys","isHiddenFromAccessibility","element","cache","current","isCurrentSubtreeInaccessible","get","undefined","isSubtreeInaccessible","set","parent","isInaccessible","props","accessibilityElementsHidden","importantForAccessibility","flatStyle","StyleSheet","flatten","style","display","hostSiblings","getHostSiblings","some","sibling","accessibilityViewIsModal","isAccessibilityElement","accessible","isHostElementForType","Text","TextInput","Switch"],"sources":["../../src/helpers/accessiblity.ts"],"sourcesContent":["import {\n AccessibilityState,\n AccessibilityValue,\n StyleSheet,\n Switch,\n Text,\n TextInput,\n} from 'react-native';\nimport { ReactTestInstance } from 'react-test-renderer';\nimport { getHostSiblings, isHostElementForType } from './component-tree';\n\ntype IsInaccessibleOptions = {\n cache?: WeakMap<ReactTestInstance, boolean>;\n};\n\nexport const accessibilityStateKeys: (keyof AccessibilityState)[] = [\n 'disabled',\n 'selected',\n 'checked',\n 'busy',\n 'expanded',\n];\n\nexport const accessiblityValueKeys: (keyof AccessibilityValue)[] = [\n 'min',\n 'max',\n 'now',\n 'text',\n];\n\nexport function isHiddenFromAccessibility(\n element: ReactTestInstance | null,\n { cache }: IsInaccessibleOptions = {}\n): boolean {\n if (element == null) {\n return true;\n }\n\n let current: ReactTestInstance | null = element;\n while (current) {\n let isCurrentSubtreeInaccessible = cache?.get(current);\n\n if (isCurrentSubtreeInaccessible === undefined) {\n isCurrentSubtreeInaccessible = isSubtreeInaccessible(current);\n cache?.set(current, isCurrentSubtreeInaccessible);\n }\n\n if (isCurrentSubtreeInaccessible) {\n return true;\n }\n\n current = current.parent;\n }\n\n return false;\n}\n\n/** RTL-compatitibility alias for `isHiddenFromAccessibility` */\nexport const isInaccessible = isHiddenFromAccessibility;\n\nfunction isSubtreeInaccessible(element: ReactTestInstance): boolean {\n // iOS: accessibilityElementsHidden\n // See: https://reactnative.dev/docs/accessibility#accessibilityelementshidden-ios\n if (element.props.accessibilityElementsHidden) {\n return true;\n }\n\n // Android: importantForAccessibility\n // See: https://reactnative.dev/docs/accessibility#importantforaccessibility-android\n if (element.props.importantForAccessibility === 'no-hide-descendants') {\n return true;\n }\n\n // Note that `opacity: 0` is not treated as inaccessible on iOS\n const flatStyle = StyleSheet.flatten(element.props.style) ?? {};\n if (flatStyle.display === 'none') return true;\n\n // iOS: accessibilityViewIsModal\n // See: https://reactnative.dev/docs/accessibility#accessibilityviewismodal-ios\n const hostSiblings = getHostSiblings(element);\n if (hostSiblings.some((sibling) => sibling.props.accessibilityViewIsModal)) {\n return true;\n }\n\n return false;\n}\n\nexport function isAccessibilityElement(\n element: ReactTestInstance | null\n): boolean {\n if (element == null) {\n return false;\n }\n\n if (element.props.accessible !== undefined) {\n return element.props.accessible;\n }\n\n return (\n isHostElementForType(element, Text) ||\n isHostElementForType(element, TextInput) ||\n isHostElementForType(element, Switch)\n );\n}\n"],"mappings":";;;;;;;;;AAAA;AASA;AAMO,MAAMA,sBAAoD,GAAG,CAClE,UAAU,EACV,UAAU,EACV,SAAS,EACT,MAAM,EACN,UAAU,CACX;AAAC;AAEK,MAAMC,qBAAmD,GAAG,CACjE,KAAK,EACL,KAAK,EACL,KAAK,EACL,MAAM,CACP;AAAC;AAEK,SAASC,yBAAyB,CACvCC,OAAiC,EACjC;EAAEC;AAA6B,CAAC,GAAG,CAAC,CAAC,EAC5B;EACT,IAAID,OAAO,IAAI,IAAI,EAAE;IACnB,OAAO,IAAI;EACb;EAEA,IAAIE,OAAiC,GAAGF,OAAO;EAC/C,OAAOE,OAAO,EAAE;IACd,IAAIC,4BAA4B,GAAGF,KAAK,EAAEG,GAAG,CAACF,OAAO,CAAC;IAEtD,IAAIC,4BAA4B,KAAKE,SAAS,EAAE;MAC9CF,4BAA4B,GAAGG,qBAAqB,CAACJ,OAAO,CAAC;MAC7DD,KAAK,EAAEM,GAAG,CAACL,OAAO,EAAEC,4BAA4B,CAAC;IACnD;IAEA,IAAIA,4BAA4B,EAAE;MAChC,OAAO,IAAI;IACb;IAEAD,OAAO,GAAGA,OAAO,CAACM,MAAM;EAC1B;EAEA,OAAO,KAAK;AACd;;AAEA;AACO,MAAMC,cAAc,GAAGV,yBAAyB;AAAC;AAExD,SAASO,qBAAqB,CAACN,OAA0B,EAAW;EAClE;EACA;EACA,IAAIA,OAAO,CAACU,KAAK,CAACC,2BAA2B,EAAE;IAC7C,OAAO,IAAI;EACb;;EAEA;EACA;EACA,IAAIX,OAAO,CAACU,KAAK,CAACE,yBAAyB,KAAK,qBAAqB,EAAE;IACrE,OAAO,IAAI;EACb;;EAEA;EACA,MAAMC,SAAS,GAAGC,uBAAU,CAACC,OAAO,CAACf,OAAO,CAACU,KAAK,CAACM,KAAK,CAAC,IAAI,CAAC,CAAC;EAC/D,IAAIH,SAAS,CAACI,OAAO,KAAK,MAAM,EAAE,OAAO,IAAI;;EAE7C;EACA;EACA,MAAMC,YAAY,GAAG,IAAAC,8BAAe,EAACnB,OAAO,CAAC;EAC7C,IAAIkB,YAAY,CAACE,IAAI,CAAEC,OAAO,IAAKA,OAAO,CAACX,KAAK,CAACY,wBAAwB,CAAC,EAAE;IAC1E,OAAO,IAAI;EACb;EAEA,OAAO,KAAK;AACd;AAEO,SAASC,sBAAsB,CACpCvB,OAAiC,EACxB;EACT,IAAIA,OAAO,IAAI,IAAI,EAAE;IACnB,OAAO,KAAK;EACd;EAEA,IAAIA,OAAO,CAACU,KAAK,CAACc,UAAU,KAAKnB,SAAS,EAAE;IAC1C,OAAOL,OAAO,CAACU,KAAK,CAACc,UAAU;EACjC;EAEA,OACE,IAAAC,mCAAoB,EAACzB,OAAO,EAAE0B,iBAAI,CAAC,IACnC,IAAAD,mCAAoB,EAACzB,OAAO,EAAE2B,sBAAS,CAAC,IACxC,IAAAF,mCAAoB,EAACzB,OAAO,EAAE4B,mBAAM,CAAC;AAEzC"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.getHostComponentNames = getHostComponentNames;
|
|
7
|
+
var _react = _interopRequireDefault(require("react"));
|
|
8
|
+
var _reactNative = require("react-native");
|
|
9
|
+
var _reactTestRenderer = _interopRequireDefault(require("react-test-renderer"));
|
|
10
|
+
var _config = require("../config");
|
|
11
|
+
var _within = require("../within");
|
|
12
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
13
|
+
const defaultErrorMessage = `There seems to be an issue with your configuration that prevents React Native Testing Library from working correctly.
|
|
14
|
+
Please check if you are using compatible versions of React Native and React Native Testing Library.`;
|
|
15
|
+
function getHostComponentNames() {
|
|
16
|
+
const configHostComponentNames = (0, _config.getConfig)().hostComponentNames;
|
|
17
|
+
if (configHostComponentNames) {
|
|
18
|
+
return configHostComponentNames;
|
|
19
|
+
}
|
|
20
|
+
try {
|
|
21
|
+
const renderer = _reactTestRenderer.default.create( /*#__PURE__*/_react.default.createElement(_reactNative.View, null, /*#__PURE__*/_react.default.createElement(_reactNative.Text, {
|
|
22
|
+
testID: "text"
|
|
23
|
+
}, "Hello"), /*#__PURE__*/_react.default.createElement(_reactNative.TextInput, {
|
|
24
|
+
testID: "textInput"
|
|
25
|
+
})));
|
|
26
|
+
const {
|
|
27
|
+
getByTestId
|
|
28
|
+
} = (0, _within.getQueriesForElement)(renderer.root);
|
|
29
|
+
const textHostName = getByTestId('text').type;
|
|
30
|
+
const textInputHostName = getByTestId('textInput').type;
|
|
31
|
+
|
|
32
|
+
// This code path should not happen as getByTestId always returns host elements.
|
|
33
|
+
if (typeof textHostName !== 'string' || typeof textInputHostName !== 'string') {
|
|
34
|
+
throw new Error('getByTestId returned non-host component');
|
|
35
|
+
}
|
|
36
|
+
const hostComponentNames = {
|
|
37
|
+
text: textHostName,
|
|
38
|
+
textInput: textInputHostName
|
|
39
|
+
};
|
|
40
|
+
(0, _config.configureInternal)({
|
|
41
|
+
hostComponentNames
|
|
42
|
+
});
|
|
43
|
+
return hostComponentNames;
|
|
44
|
+
} catch (error) {
|
|
45
|
+
const errorMessage = error && typeof error === 'object' && 'message' in error ? error.message : null;
|
|
46
|
+
throw new Error(`Trying to detect host component names triggered the following error:\n\n${errorMessage}\n\n${defaultErrorMessage}
|
|
47
|
+
`);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
//# sourceMappingURL=host-component-names.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"host-component-names.js","names":["defaultErrorMessage","getHostComponentNames","configHostComponentNames","getConfig","hostComponentNames","renderer","TestRenderer","create","getByTestId","getQueriesForElement","root","textHostName","type","textInputHostName","Error","text","textInput","configureInternal","error","errorMessage","message"],"sources":["../../src/helpers/host-component-names.tsx"],"sourcesContent":["import React from 'react';\nimport { Text, TextInput, View } from 'react-native';\nimport TestRenderer from 'react-test-renderer';\nimport { configureInternal, getConfig, HostComponentNames } from '../config';\nimport { getQueriesForElement } from '../within';\n\nconst defaultErrorMessage = `There seems to be an issue with your configuration that prevents React Native Testing Library from working correctly.\nPlease check if you are using compatible versions of React Native and React Native Testing Library.`;\n\nexport function getHostComponentNames(): HostComponentNames {\n const configHostComponentNames = getConfig().hostComponentNames;\n if (configHostComponentNames) {\n return configHostComponentNames;\n }\n\n try {\n const renderer = TestRenderer.create(\n <View>\n <Text testID=\"text\">Hello</Text>\n <TextInput testID=\"textInput\" />\n </View>\n );\n const { getByTestId } = getQueriesForElement(renderer.root);\n const textHostName = getByTestId('text').type;\n const textInputHostName = getByTestId('textInput').type;\n\n // This code path should not happen as getByTestId always returns host elements.\n if (\n typeof textHostName !== 'string' ||\n typeof textInputHostName !== 'string'\n ) {\n throw new Error('getByTestId returned non-host component');\n }\n\n const hostComponentNames = {\n text: textHostName,\n textInput: textInputHostName,\n };\n configureInternal({ hostComponentNames });\n return hostComponentNames;\n } catch (error) {\n const errorMessage =\n error && typeof error === 'object' && 'message' in error\n ? error.message\n : null;\n\n throw new Error(`Trying to detect host component names triggered the following error:\\n\\n${errorMessage}\\n\\n${defaultErrorMessage}\n`);\n }\n}\n"],"mappings":";;;;;;AAAA;AACA;AACA;AACA;AACA;AAAiD;AAEjD,MAAMA,mBAAmB,GAAI;AAC7B,oGAAoG;AAE7F,SAASC,qBAAqB,GAAuB;EAC1D,MAAMC,wBAAwB,GAAG,IAAAC,iBAAS,GAAE,CAACC,kBAAkB;EAC/D,IAAIF,wBAAwB,EAAE;IAC5B,OAAOA,wBAAwB;EACjC;EAEA,IAAI;IACF,MAAMG,QAAQ,GAAGC,0BAAY,CAACC,MAAM,eAClC,6BAAC,iBAAI,qBACH,6BAAC,iBAAI;MAAC,MAAM,EAAC;IAAM,GAAC,OAAK,CAAO,eAChC,6BAAC,sBAAS;MAAC,MAAM,EAAC;IAAW,EAAG,CAC3B,CACR;IACD,MAAM;MAAEC;IAAY,CAAC,GAAG,IAAAC,4BAAoB,EAACJ,QAAQ,CAACK,IAAI,CAAC;IAC3D,MAAMC,YAAY,GAAGH,WAAW,CAAC,MAAM,CAAC,CAACI,IAAI;IAC7C,MAAMC,iBAAiB,GAAGL,WAAW,CAAC,WAAW,CAAC,CAACI,IAAI;;IAEvD;IACA,IACE,OAAOD,YAAY,KAAK,QAAQ,IAChC,OAAOE,iBAAiB,KAAK,QAAQ,EACrC;MACA,MAAM,IAAIC,KAAK,CAAC,yCAAyC,CAAC;IAC5D;IAEA,MAAMV,kBAAkB,GAAG;MACzBW,IAAI,EAAEJ,YAAY;MAClBK,SAAS,EAAEH;IACb,CAAC;IACD,IAAAI,yBAAiB,EAAC;MAAEb;IAAmB,CAAC,CAAC;IACzC,OAAOA,kBAAkB;EAC3B,CAAC,CAAC,OAAOc,KAAK,EAAE;IACd,MAAMC,YAAY,GAChBD,KAAK,IAAI,OAAOA,KAAK,KAAK,QAAQ,IAAI,SAAS,IAAIA,KAAK,GACpDA,KAAK,CAACE,OAAO,GACb,IAAI;IAEV,MAAM,IAAIN,KAAK,CAAE,2EAA0EK,YAAa,OAAMnB,mBAAoB;AACtI,CAAC,CAAC;EACA;AACF"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.matchLabelText = matchLabelText;
|
|
7
|
+
var _matches = require("../../matches");
|
|
8
|
+
var _findAll = require("../findAll");
|
|
9
|
+
var _matchTextContent = require("./matchTextContent");
|
|
10
|
+
function matchLabelText(root, element, text, options = {}) {
|
|
11
|
+
return matchAccessibilityLabel(element, text, options) || matchAccessibilityLabelledBy(root, element.props.accessibilityLabelledBy, text, options);
|
|
12
|
+
}
|
|
13
|
+
function matchAccessibilityLabel(element, text, options) {
|
|
14
|
+
const {
|
|
15
|
+
exact,
|
|
16
|
+
normalizer
|
|
17
|
+
} = options;
|
|
18
|
+
return (0, _matches.matches)(text, element.props.accessibilityLabel, normalizer, exact);
|
|
19
|
+
}
|
|
20
|
+
function matchAccessibilityLabelledBy(root, nativeId, text, options) {
|
|
21
|
+
if (!nativeId) {
|
|
22
|
+
return false;
|
|
23
|
+
}
|
|
24
|
+
return (0, _findAll.findAll)(root, node => typeof node.type === 'string' && node.props.nativeID === nativeId && (0, _matchTextContent.matchTextContent)(node, text, options)).length > 0;
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=matchLabelText.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"matchLabelText.js","names":["matchLabelText","root","element","text","options","matchAccessibilityLabel","matchAccessibilityLabelledBy","props","accessibilityLabelledBy","exact","normalizer","matches","accessibilityLabel","nativeId","findAll","node","type","nativeID","matchTextContent","length"],"sources":["../../../src/helpers/matchers/matchLabelText.ts"],"sourcesContent":["import { ReactTestInstance } from 'react-test-renderer';\nimport { matches, TextMatch, TextMatchOptions } from '../../matches';\nimport { findAll } from '../findAll';\nimport { matchTextContent } from './matchTextContent';\n\nexport function matchLabelText(\n root: ReactTestInstance,\n element: ReactTestInstance,\n text: TextMatch,\n options: TextMatchOptions = {}\n) {\n return (\n matchAccessibilityLabel(element, text, options) ||\n matchAccessibilityLabelledBy(\n root,\n element.props.accessibilityLabelledBy,\n text,\n options\n )\n );\n}\n\nfunction matchAccessibilityLabel(\n element: ReactTestInstance,\n text: TextMatch,\n options: TextMatchOptions\n) {\n const { exact, normalizer } = options;\n return matches(text, element.props.accessibilityLabel, normalizer, exact);\n}\n\nfunction matchAccessibilityLabelledBy(\n root: ReactTestInstance,\n nativeId: string | undefined,\n text: TextMatch,\n options: TextMatchOptions\n) {\n if (!nativeId) {\n return false;\n }\n\n return (\n findAll(\n root,\n (node) =>\n typeof node.type === 'string' &&\n node.props.nativeID === nativeId &&\n matchTextContent(node, text, options)\n ).length > 0\n );\n}\n"],"mappings":";;;;;;AACA;AACA;AACA;AAEO,SAASA,cAAc,CAC5BC,IAAuB,EACvBC,OAA0B,EAC1BC,IAAe,EACfC,OAAyB,GAAG,CAAC,CAAC,EAC9B;EACA,OACEC,uBAAuB,CAACH,OAAO,EAAEC,IAAI,EAAEC,OAAO,CAAC,IAC/CE,4BAA4B,CAC1BL,IAAI,EACJC,OAAO,CAACK,KAAK,CAACC,uBAAuB,EACrCL,IAAI,EACJC,OAAO,CACR;AAEL;AAEA,SAASC,uBAAuB,CAC9BH,OAA0B,EAC1BC,IAAe,EACfC,OAAyB,EACzB;EACA,MAAM;IAAEK,KAAK;IAAEC;EAAW,CAAC,GAAGN,OAAO;EACrC,OAAO,IAAAO,gBAAO,EAACR,IAAI,EAAED,OAAO,CAACK,KAAK,CAACK,kBAAkB,EAAEF,UAAU,EAAED,KAAK,CAAC;AAC3E;AAEA,SAASH,4BAA4B,CACnCL,IAAuB,EACvBY,QAA4B,EAC5BV,IAAe,EACfC,OAAyB,EACzB;EACA,IAAI,CAACS,QAAQ,EAAE;IACb,OAAO,KAAK;EACd;EAEA,OACE,IAAAC,gBAAO,EACLb,IAAI,EACHc,IAAI,IACH,OAAOA,IAAI,CAACC,IAAI,KAAK,QAAQ,IAC7BD,IAAI,CAACR,KAAK,CAACU,QAAQ,KAAKJ,QAAQ,IAChC,IAAAK,kCAAgB,EAACH,IAAI,EAAEZ,IAAI,EAAEC,OAAO,CAAC,CACxC,CAACe,MAAM,GAAG,CAAC;AAEhB"}
|
|
@@ -1,3 +1,10 @@
|
|
|
1
1
|
import type { ReactTestInstance } from 'react-test-renderer';
|
|
2
2
|
import { TextMatch, TextMatchOptions } from '../../matches';
|
|
3
|
+
/**
|
|
4
|
+
* Matches the given node's text content against string or regex matcher.
|
|
5
|
+
*
|
|
6
|
+
* @param node - Node which text content will be matched
|
|
7
|
+
* @param text - The string or regex to match.
|
|
8
|
+
* @returns - Whether the node's text content matches the given string or regex.
|
|
9
|
+
*/
|
|
3
10
|
export declare function matchTextContent(node: ReactTestInstance, text: TextMatch, options?: TextMatchOptions): boolean;
|
|
@@ -4,14 +4,16 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.matchTextContent = matchTextContent;
|
|
7
|
-
var _reactNative = require("react-native");
|
|
8
7
|
var _matches = require("../../matches");
|
|
9
|
-
var _filterNodeByType = require("../filterNodeByType");
|
|
10
8
|
var _getTextContent = require("../getTextContent");
|
|
9
|
+
/**
|
|
10
|
+
* Matches the given node's text content against string or regex matcher.
|
|
11
|
+
*
|
|
12
|
+
* @param node - Node which text content will be matched
|
|
13
|
+
* @param text - The string or regex to match.
|
|
14
|
+
* @returns - Whether the node's text content matches the given string or regex.
|
|
15
|
+
*/
|
|
11
16
|
function matchTextContent(node, text, options = {}) {
|
|
12
|
-
if (!(0, _filterNodeByType.filterNodeByType)(node, _reactNative.Text)) {
|
|
13
|
-
return false;
|
|
14
|
-
}
|
|
15
17
|
const textContent = (0, _getTextContent.getTextContent)(node);
|
|
16
18
|
const {
|
|
17
19
|
exact,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"matchTextContent.js","names":["matchTextContent","node","text","options","
|
|
1
|
+
{"version":3,"file":"matchTextContent.js","names":["matchTextContent","node","text","options","textContent","getTextContent","exact","normalizer","matches"],"sources":["../../../src/helpers/matchers/matchTextContent.ts"],"sourcesContent":["import type { ReactTestInstance } from 'react-test-renderer';\nimport { matches, TextMatch, TextMatchOptions } from '../../matches';\nimport { getTextContent } from '../getTextContent';\n\n/**\n * Matches the given node's text content against string or regex matcher.\n *\n * @param node - Node which text content will be matched\n * @param text - The string or regex to match.\n * @returns - Whether the node's text content matches the given string or regex.\n */\nexport function matchTextContent(\n node: ReactTestInstance,\n text: TextMatch,\n options: TextMatchOptions = {}\n) {\n const textContent = getTextContent(node);\n const { exact, normalizer } = options;\n return matches(text, textContent, normalizer, exact);\n}\n"],"mappings":";;;;;;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASA,gBAAgB,CAC9BC,IAAuB,EACvBC,IAAe,EACfC,OAAyB,GAAG,CAAC,CAAC,EAC9B;EACA,MAAMC,WAAW,GAAG,IAAAC,8BAAc,EAACJ,IAAI,CAAC;EACxC,MAAM;IAAEK,KAAK;IAAEC;EAAW,CAAC,GAAGJ,OAAO;EACrC,OAAO,IAAAK,gBAAO,EAACN,IAAI,EAAEE,WAAW,EAAEG,UAAU,EAAED,KAAK,CAAC;AACtD"}
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
/// <reference types="react-native" />
|
|
2
|
-
/// <reference types="node" />
|
|
3
1
|
declare function runWithRealTimers<T>(callback: () => T): T;
|
|
4
2
|
declare const jestFakeTimersAreEnabled: () => boolean;
|
|
5
3
|
declare const clearTimeoutFn: typeof clearTimeout, setImmediateFn: typeof setImmediate, setTimeoutFn: typeof setTimeout;
|
package/build/index.flow.js
CHANGED
|
@@ -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: findAllBy(instance),\n});\n"],"mappings":";;;;;;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAaA,MAAMA,8BAA8B,GAAG,CACrCC,IAAuB,EACvBC,KAAgB,EAChBC,OAAyB,GAAG,CAAC,CAAC,KAC3B;EACH,MAAM;IAAEC,KAAK;IAAEC;EAAW,CAAC,GAAGF,OAAO;EACrC,MAAMG,SAAS,GACbL,IAAI,CAACM,KAAK,CAACL,KAAK,KAAKM,SAAS,GAAGP,IAAI,CAACM,KAAK,CAACL,KAAK,GAAGD,IAAI,CAACM,KAAK,CAACE,YAAY;EAC7E,MAAMC,yBAAyB,GAAG,IAAAC,iBAAS,GAAE,CAACC,kBAAkB;EAChE,MAAMC,aAAa,GAAGH,yBAAyB,GAC3C,IAAAI,yCAAqB,GAAE,CAACC,SAAS,GACjCC,sBAAS;EAEb,OACE,IAAAC,kCAAgB,EAAChB,IAAI,EAAEY,aAAa,CAAC,IACrC,IAAAK,gBAAO,EAAChB,KAAK,EAAEI,SAAS,EAAED,UAAU,EAAED,KAAK,CAAC;AAEhD,CAAC;AAED,MAAMe,sBAAsB,GAC1BC,QAA2B,IAK3B,SAASC,wBAAwB,CAACC,YAAY,EAAEC,YAAY,EAAE;EAC5D,OAAO,IAAAC,gBAAO,EACZJ,QAAQ,EACPnB,IAAI,IACHD,8BAA8B,CAACC,IAAI,EAAEqB,YAAY,EAAEC,YAAY,CAAC,EAClEA,YAAY,CACb;AACH,CAAC;AAEH,MAAME,gBAAgB,GAAIH,YAAuB,IAC9C,+CAA8CI,MAAM,CAACJ,YAAY,CAAE,GAAE;AACxE,MAAMK,eAAe,GAAIL,YAAuB,IAC7C,gDAA+CI,MAAM,CAACJ,YAAY,CAAE,EAAC;AAExE,MAAM;EAAEM,KAAK;EAAEC,QAAQ;EAAEC,OAAO;EAAEC,UAAU;EAAEC,MAAM;EAAEC;AAAU,CAAC,GAAG,IAAAC,wBAAW,EAC7Ef,sBAAsB,EACtBQ,eAAe,EACfF,gBAAgB,CACjB;AAWM,MAAMU,yBAAyB,GACpCf,QAA2B,KACA;EAC3BgB,iBAAiB,EAAER,KAAK,CAACR,QAAQ,CAAC;EAClCiB,oBAAoB,EAAER,QAAQ,CAACT,QAAQ,CAAC;EACxCkB,mBAAmB,EAAER,OAAO,CAACV,QAAQ,CAAC;EACtCD,sBAAsB,EAAEY,UAAU,CAACX,QAAQ,CAAC;EAC5CmB,kBAAkB,EAAEP,MAAM,CAACZ,QAAQ,CAAC;EACpCoB,qBAAqB,EAAEP,SAAS,CAACb,QAAQ;AAC3C,CAAC,CAAC;AAAC"}
|
|
@@ -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":"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"}
|
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/within.d.ts
CHANGED
|
@@ -29,39 +29,39 @@ export declare function within(instance: ReactTestInstance): {
|
|
|
29
29
|
queryAllByAccessibilityValue: import("./queries/makeQueries").QueryAllByQuery<import("./helpers/matchers/accessibilityValue").AccessibilityValueMatcher, import("./queries/options").CommonQueryOptions>;
|
|
30
30
|
findByAccessibilityValue: import("./queries/makeQueries").FindByQuery<import("./helpers/matchers/accessibilityValue").AccessibilityValueMatcher, import("./queries/options").CommonQueryOptions>;
|
|
31
31
|
findAllByAccessibilityValue: import("./queries/makeQueries").FindAllByQuery<import("./helpers/matchers/accessibilityValue").AccessibilityValueMatcher, import("./queries/options").CommonQueryOptions>;
|
|
32
|
-
getByA11yState: import("./queries/makeQueries").GetByQuery<import("react-native").AccessibilityState, import("./queries/options").CommonQueryOptions>;
|
|
33
|
-
getAllByA11yState: import("./queries/makeQueries").GetAllByQuery<import("react-native").AccessibilityState, import("./queries/options").CommonQueryOptions>;
|
|
34
|
-
queryByA11yState: import("./queries/makeQueries").QueryByQuery<import("react-native").AccessibilityState, import("./queries/options").CommonQueryOptions>;
|
|
35
|
-
queryAllByA11yState: import("./queries/makeQueries").QueryAllByQuery<import("react-native").AccessibilityState, import("./queries/options").CommonQueryOptions>;
|
|
36
|
-
findByA11yState: import("./queries/makeQueries").FindByQuery<import("react-native").AccessibilityState, import("./queries/options").CommonQueryOptions>;
|
|
37
|
-
findAllByA11yState: import("./queries/makeQueries").FindAllByQuery<import("react-native").AccessibilityState, import("./queries/options").CommonQueryOptions>;
|
|
38
|
-
getByAccessibilityState: import("./queries/makeQueries").GetByQuery<import("react-native").AccessibilityState, import("./queries/options").CommonQueryOptions>;
|
|
39
|
-
getAllByAccessibilityState: import("./queries/makeQueries").GetAllByQuery<import("react-native").AccessibilityState, import("./queries/options").CommonQueryOptions>;
|
|
40
|
-
queryByAccessibilityState: import("./queries/makeQueries").QueryByQuery<import("react-native").AccessibilityState, import("./queries/options").CommonQueryOptions>;
|
|
41
|
-
queryAllByAccessibilityState: import("./queries/makeQueries").QueryAllByQuery<import("react-native").AccessibilityState, import("./queries/options").CommonQueryOptions>;
|
|
42
|
-
findByAccessibilityState: import("./queries/makeQueries").FindByQuery<import("react-native").AccessibilityState, import("./queries/options").CommonQueryOptions>;
|
|
43
|
-
findAllByAccessibilityState: import("./queries/makeQueries").FindAllByQuery<import("react-native").AccessibilityState, import("./queries/options").CommonQueryOptions>;
|
|
44
|
-
getByRole: import("./queries/makeQueries").GetByQuery<import("./matches").TextMatch, import("./queries/options").CommonQueryOptions & import("react-native").AccessibilityState & {
|
|
32
|
+
getByA11yState: import("./queries/makeQueries").GetByQuery<import("react-native/types").AccessibilityState, import("./queries/options").CommonQueryOptions>;
|
|
33
|
+
getAllByA11yState: import("./queries/makeQueries").GetAllByQuery<import("react-native/types").AccessibilityState, import("./queries/options").CommonQueryOptions>;
|
|
34
|
+
queryByA11yState: import("./queries/makeQueries").QueryByQuery<import("react-native/types").AccessibilityState, import("./queries/options").CommonQueryOptions>;
|
|
35
|
+
queryAllByA11yState: import("./queries/makeQueries").QueryAllByQuery<import("react-native/types").AccessibilityState, import("./queries/options").CommonQueryOptions>;
|
|
36
|
+
findByA11yState: import("./queries/makeQueries").FindByQuery<import("react-native/types").AccessibilityState, import("./queries/options").CommonQueryOptions>;
|
|
37
|
+
findAllByA11yState: import("./queries/makeQueries").FindAllByQuery<import("react-native/types").AccessibilityState, import("./queries/options").CommonQueryOptions>;
|
|
38
|
+
getByAccessibilityState: import("./queries/makeQueries").GetByQuery<import("react-native/types").AccessibilityState, import("./queries/options").CommonQueryOptions>;
|
|
39
|
+
getAllByAccessibilityState: import("./queries/makeQueries").GetAllByQuery<import("react-native/types").AccessibilityState, import("./queries/options").CommonQueryOptions>;
|
|
40
|
+
queryByAccessibilityState: import("./queries/makeQueries").QueryByQuery<import("react-native/types").AccessibilityState, import("./queries/options").CommonQueryOptions>;
|
|
41
|
+
queryAllByAccessibilityState: import("./queries/makeQueries").QueryAllByQuery<import("react-native/types").AccessibilityState, import("./queries/options").CommonQueryOptions>;
|
|
42
|
+
findByAccessibilityState: import("./queries/makeQueries").FindByQuery<import("react-native/types").AccessibilityState, import("./queries/options").CommonQueryOptions>;
|
|
43
|
+
findAllByAccessibilityState: import("./queries/makeQueries").FindAllByQuery<import("react-native/types").AccessibilityState, import("./queries/options").CommonQueryOptions>;
|
|
44
|
+
getByRole: import("./queries/makeQueries").GetByQuery<import("./matches").TextMatch, import("./queries/options").CommonQueryOptions & import("react-native/types").AccessibilityState & {
|
|
45
45
|
name?: import("./matches").TextMatch | undefined;
|
|
46
46
|
value?: import("./helpers/matchers/accessibilityValue").AccessibilityValueMatcher | undefined;
|
|
47
47
|
}>;
|
|
48
|
-
getAllByRole: import("./queries/makeQueries").GetAllByQuery<import("./matches").TextMatch, import("./queries/options").CommonQueryOptions & import("react-native").AccessibilityState & {
|
|
48
|
+
getAllByRole: import("./queries/makeQueries").GetAllByQuery<import("./matches").TextMatch, import("./queries/options").CommonQueryOptions & import("react-native/types").AccessibilityState & {
|
|
49
49
|
name?: import("./matches").TextMatch | undefined;
|
|
50
50
|
value?: import("./helpers/matchers/accessibilityValue").AccessibilityValueMatcher | undefined;
|
|
51
51
|
}>;
|
|
52
|
-
queryByRole: import("./queries/makeQueries").QueryByQuery<import("./matches").TextMatch, import("./queries/options").CommonQueryOptions & import("react-native").AccessibilityState & {
|
|
52
|
+
queryByRole: import("./queries/makeQueries").QueryByQuery<import("./matches").TextMatch, import("./queries/options").CommonQueryOptions & import("react-native/types").AccessibilityState & {
|
|
53
53
|
name?: import("./matches").TextMatch | undefined;
|
|
54
54
|
value?: import("./helpers/matchers/accessibilityValue").AccessibilityValueMatcher | undefined;
|
|
55
55
|
}>;
|
|
56
|
-
queryAllByRole: import("./queries/makeQueries").QueryAllByQuery<import("./matches").TextMatch, import("./queries/options").CommonQueryOptions & import("react-native").AccessibilityState & {
|
|
56
|
+
queryAllByRole: import("./queries/makeQueries").QueryAllByQuery<import("./matches").TextMatch, import("./queries/options").CommonQueryOptions & import("react-native/types").AccessibilityState & {
|
|
57
57
|
name?: import("./matches").TextMatch | undefined;
|
|
58
58
|
value?: import("./helpers/matchers/accessibilityValue").AccessibilityValueMatcher | undefined;
|
|
59
59
|
}>;
|
|
60
|
-
findByRole: import("./queries/makeQueries").FindByQuery<import("./matches").TextMatch, import("./queries/options").CommonQueryOptions & import("react-native").AccessibilityState & {
|
|
60
|
+
findByRole: import("./queries/makeQueries").FindByQuery<import("./matches").TextMatch, import("./queries/options").CommonQueryOptions & import("react-native/types").AccessibilityState & {
|
|
61
61
|
name?: import("./matches").TextMatch | undefined;
|
|
62
62
|
value?: import("./helpers/matchers/accessibilityValue").AccessibilityValueMatcher | undefined;
|
|
63
63
|
}>;
|
|
64
|
-
findAllByRole: import("./queries/makeQueries").FindAllByQuery<import("./matches").TextMatch, import("./queries/options").CommonQueryOptions & import("react-native").AccessibilityState & {
|
|
64
|
+
findAllByRole: import("./queries/makeQueries").FindAllByQuery<import("./matches").TextMatch, import("./queries/options").CommonQueryOptions & import("react-native/types").AccessibilityState & {
|
|
65
65
|
name?: import("./matches").TextMatch | undefined;
|
|
66
66
|
value?: import("./helpers/matchers/accessibilityValue").AccessibilityValueMatcher | undefined;
|
|
67
67
|
}>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@testing-library/react-native",
|
|
3
|
-
"version": "11.5.
|
|
3
|
+
"version": "11.5.1",
|
|
4
4
|
"description": "Simple and complete React Native testing utilities that encourage good testing practices.",
|
|
5
5
|
"main": "build/index.js",
|
|
6
6
|
"types": "build/index.d.ts",
|
|
@@ -35,33 +35,32 @@
|
|
|
35
35
|
"@babel/preset-react": "^7.18.6",
|
|
36
36
|
"@babel/preset-typescript": "^7.18.6",
|
|
37
37
|
"@callstack/eslint-config": "^13.0.1",
|
|
38
|
-
"@testing-library/jest-native": "^5.
|
|
38
|
+
"@testing-library/jest-native": "^5.4.0",
|
|
39
39
|
"@types/jest": "^29.2.3",
|
|
40
|
-
"@types/react": "~18.0.
|
|
41
|
-
"@types/react-native": "~0.70.0",
|
|
40
|
+
"@types/react": "~18.0.26",
|
|
42
41
|
"@types/react-test-renderer": "~18.0.0",
|
|
43
|
-
"babel-jest": "^29.
|
|
42
|
+
"babel-jest": "^29.4.0",
|
|
44
43
|
"conventional-changelog-cli": "^2.2.2",
|
|
45
44
|
"dedent": "^0.7.0",
|
|
46
45
|
"del-cli": "^5.0.0",
|
|
47
46
|
"eslint": "^8.21.0",
|
|
48
47
|
"flow-bin": "~0.170.0",
|
|
49
48
|
"flow-copy-source": "^2.0.9",
|
|
50
|
-
"jest": "^29.
|
|
51
|
-
"react": "18.
|
|
52
|
-
"react-native": "0.
|
|
53
|
-
"react-test-renderer": "18.
|
|
49
|
+
"jest": "^29.4.0",
|
|
50
|
+
"react": "18.2.0",
|
|
51
|
+
"react-native": "0.71.1",
|
|
52
|
+
"react-test-renderer": "18.2.0",
|
|
54
53
|
"strip-ansi": "^6.0.0",
|
|
55
54
|
"typescript": "^4.0.2"
|
|
56
55
|
},
|
|
57
56
|
"dependencies": {
|
|
58
|
-
"pretty-format": "^29.
|
|
57
|
+
"pretty-format": "^29.4.0"
|
|
59
58
|
},
|
|
60
59
|
"peerDependencies": {
|
|
61
60
|
"jest": ">=28.0.0",
|
|
62
|
-
"react": ">=16.
|
|
61
|
+
"react": ">=16.8.0",
|
|
63
62
|
"react-native": ">=0.59",
|
|
64
|
-
"react-test-renderer": ">=16.
|
|
63
|
+
"react-test-renderer": ">=16.8.0"
|
|
65
64
|
},
|
|
66
65
|
"peerDependenciesMeta": {
|
|
67
66
|
"jest": {
|
|
@@ -87,8 +86,8 @@
|
|
|
87
86
|
},
|
|
88
87
|
"jest": {
|
|
89
88
|
"preset": "./jest-preset",
|
|
90
|
-
"
|
|
91
|
-
"./
|
|
89
|
+
"setupFilesAfterEnv": [
|
|
90
|
+
"./jest-setup.ts"
|
|
92
91
|
],
|
|
93
92
|
"testPathIgnorePatterns": [
|
|
94
93
|
"timerUtils",
|