@testing-library/react-native 10.1.1 → 11.0.0-rc.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -0
- package/build/fireEvent.js +15 -13
- package/build/fireEvent.js.map +1 -1
- package/build/helpers/errors.js +1 -3
- package/build/helpers/errors.js.map +1 -1
- package/build/helpers/matchers/matchArrayProp.d.ts +8 -0
- package/build/helpers/matchers/matchArrayProp.js +26 -0
- package/build/helpers/matchers/matchArrayProp.js.map +1 -0
- package/build/helpers/matchers/matchObjectProp.d.ts +12 -0
- package/build/helpers/matchers/matchObjectProp.js +27 -0
- package/build/helpers/matchers/matchObjectProp.js.map +1 -0
- package/build/helpers/matchers/matchStringProp.d.ts +9 -0
- package/build/helpers/matchers/matchStringProp.js +26 -0
- package/build/helpers/matchers/matchStringProp.js.map +1 -0
- package/build/helpers/timers.js +12 -2
- package/build/helpers/timers.js.map +1 -1
- package/build/index.flow.js +6 -24
- package/build/queries/a11yState.d.ts +18 -0
- package/build/queries/a11yState.js +53 -0
- package/build/queries/a11yState.js.map +1 -0
- package/build/queries/a11yValue.d.ts +24 -0
- package/build/queries/a11yValue.js +53 -0
- package/build/queries/a11yValue.js.map +1 -0
- package/build/queries/hintText.d.ts +24 -0
- package/build/queries/hintText.js +61 -0
- package/build/queries/hintText.js.map +1 -0
- package/build/queries/labelText.d.ts +12 -0
- package/build/queries/labelText.js +39 -0
- package/build/queries/labelText.js.map +1 -0
- package/build/queries/makeQueries.d.ts +6 -6
- package/build/queries/makeQueries.js +4 -36
- package/build/queries/makeQueries.js.map +1 -1
- package/build/queries/role.d.ts +12 -0
- package/build/queries/role.js +39 -0
- package/build/queries/role.js.map +1 -0
- package/build/queries/text.js +1 -3
- package/build/queries/text.js.map +1 -1
- package/build/render.d.ts +106 -64
- package/build/renderHook.js +2 -2
- package/build/renderHook.js.map +1 -1
- package/build/screen.js +24 -12
- package/build/screen.js.map +1 -1
- package/build/waitFor.js +1 -1
- package/build/waitFor.js.map +1 -1
- package/build/within.d.ts +106 -64
- package/build/within.js +16 -4
- package/build/within.js.map +1 -1
- package/package.json +21 -17
- package/typings/index.flow.js +6 -24
- package/build/queries/a11yAPI.d.ts +0 -66
- package/build/queries/a11yAPI.js +0 -94
- package/build/queries/a11yAPI.js.map +0 -1
- package/build/queries/makeA11yQuery.d.ts +0 -13
- package/build/queries/makeA11yQuery.js +0 -80
- package/build/queries/makeA11yQuery.js.map +0 -1
package/README.md
CHANGED
|
@@ -141,6 +141,10 @@ The [public API](https://callstack.github.io/react-native-testing-library/docs/a
|
|
|
141
141
|
- [Migration to 7.0](https://callstack.github.io/react-native-testing-library/docs/migration-v7)
|
|
142
142
|
- [Migration to 2.0](https://callstack.github.io/react-native-testing-library/docs/migration-v2)
|
|
143
143
|
|
|
144
|
+
## Troubleshooting
|
|
145
|
+
|
|
146
|
+
- [Understanding `act` function](https://callstack.github.io/react-native-testing-library/docs/undestanding-act)
|
|
147
|
+
|
|
144
148
|
## Related External Resources
|
|
145
149
|
|
|
146
150
|
- [Real world extensive examples repo](https://github.com/vanGalilea/react-native-testing)
|
package/build/fireEvent.js
CHANGED
|
@@ -10,7 +10,7 @@ var _act = _interopRequireDefault(require("./act"));
|
|
|
10
10
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
11
11
|
|
|
12
12
|
const isHostElement = element => {
|
|
13
|
-
return typeof
|
|
13
|
+
return typeof element?.type === 'string';
|
|
14
14
|
};
|
|
15
15
|
|
|
16
16
|
const isTextInput = element => {
|
|
@@ -18,32 +18,34 @@ const isTextInput = element => {
|
|
|
18
18
|
TextInput
|
|
19
19
|
} = require('react-native');
|
|
20
20
|
|
|
21
|
-
return
|
|
21
|
+
return element?.type === TextInput;
|
|
22
22
|
};
|
|
23
23
|
|
|
24
24
|
const isTouchResponder = element => {
|
|
25
25
|
if (!isHostElement(element)) return false;
|
|
26
|
-
return !!
|
|
26
|
+
return !!element?.props.onStartShouldSetResponder || isTextInput(element);
|
|
27
27
|
};
|
|
28
28
|
|
|
29
29
|
const isPointerEventEnabled = (element, isParent) => {
|
|
30
|
-
const parentCondition = isParent ?
|
|
30
|
+
const parentCondition = isParent ? element?.props.pointerEvents === 'box-only' : element?.props.pointerEvents === 'box-none';
|
|
31
31
|
|
|
32
|
-
if (
|
|
32
|
+
if (element?.props.pointerEvents === 'none' || parentCondition) {
|
|
33
33
|
return false;
|
|
34
34
|
}
|
|
35
35
|
|
|
36
|
-
if (!
|
|
36
|
+
if (!element?.parent) return true;
|
|
37
37
|
return isPointerEventEnabled(element.parent, true);
|
|
38
38
|
};
|
|
39
39
|
|
|
40
|
-
const
|
|
41
|
-
|
|
40
|
+
const isTouchEvent = eventName => {
|
|
41
|
+
return eventName === 'press';
|
|
42
|
+
};
|
|
42
43
|
|
|
43
|
-
|
|
44
|
-
if (
|
|
45
|
-
|
|
46
|
-
const
|
|
44
|
+
const isEventEnabled = (element, touchResponder, eventName) => {
|
|
45
|
+
if (isTextInput(element)) return element?.props.editable !== false;
|
|
46
|
+
if (!isPointerEventEnabled(element) && isTouchEvent(eventName)) return false;
|
|
47
|
+
const touchStart = touchResponder?.props.onStartShouldSetResponder?.();
|
|
48
|
+
const touchMove = touchResponder?.props.onMoveShouldSetResponder?.();
|
|
47
49
|
if (touchStart || touchMove) return true;
|
|
48
50
|
return touchStart === undefined && touchMove === undefined;
|
|
49
51
|
};
|
|
@@ -51,7 +53,7 @@ const isEventEnabled = (element, touchResponder) => {
|
|
|
51
53
|
const findEventHandler = (element, eventName, callsite, nearestTouchResponder) => {
|
|
52
54
|
const touchResponder = isTouchResponder(element) ? element : nearestTouchResponder;
|
|
53
55
|
const handler = getEventHandler(element, eventName);
|
|
54
|
-
if (handler && isEventEnabled(element, touchResponder)) return handler;
|
|
56
|
+
if (handler && isEventEnabled(element, touchResponder, eventName)) return handler;
|
|
55
57
|
|
|
56
58
|
if (element.parent === null || element.parent.parent === null) {
|
|
57
59
|
return null;
|
package/build/fireEvent.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/fireEvent.ts"],"names":["isHostElement","element","type","isTextInput","TextInput","require","isTouchResponder","props","onStartShouldSetResponder","isPointerEventEnabled","isParent","parentCondition","pointerEvents","parent","isEventEnabled","touchResponder","editable","touchStart","touchMove","onMoveShouldSetResponder","undefined","findEventHandler","
|
|
1
|
+
{"version":3,"sources":["../src/fireEvent.ts"],"names":["isHostElement","element","type","isTextInput","TextInput","require","isTouchResponder","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","charAt","toUpperCase","slice","pressHandler","changeTextHandler","scrollHandler","fireEvent","press","changeText","scroll"],"mappings":";;;;;;;AACA;;;;AAIA,MAAMA,aAAa,GAAIC,OAAD,IAAiC;AACrD,SAAO,OAAOA,OAAO,EAAEC,IAAhB,KAAyB,QAAhC;AACD,CAFD;;AAIA,MAAMC,WAAW,GAAIF,OAAD,IAAiC;AACnD,QAAM;AAAEG,IAAAA;AAAF,MAAgBC,OAAO,CAAC,cAAD,CAA7B;;AACA,SAAOJ,OAAO,EAAEC,IAAT,KAAkBE,SAAzB;AACD,CAHD;;AAKA,MAAME,gBAAgB,GAAIL,OAAD,IAAiC;AACxD,MAAI,CAACD,aAAa,CAACC,OAAD,CAAlB,EAA6B,OAAO,KAAP;AAE7B,SAAO,CAAC,CAACA,OAAO,EAAEM,KAAT,CAAeC,yBAAjB,IAA8CL,WAAW,CAACF,OAAD,CAAhE;AACD,CAJD;;AAMA,MAAMQ,qBAAqB,GAAG,CAC5BR,OAD4B,EAE5BS,QAF4B,KAGhB;AACZ,QAAMC,eAAe,GAAGD,QAAQ,GAC5BT,OAAO,EAAEM,KAAT,CAAeK,aAAf,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,CAAgB,CAAhB,CAAmB,EAD9D;;AAGA,MAAMC,YAAY,GAAG,CAACnC,OAAD,EAA6B,GAAG8B,IAAhC,KACnBD,WAAW,CAAC7B,OAAD,EAAU,OAAV,EAAmBmC,YAAnB,EAAiC,GAAGL,IAApC,CADb;;AAEA,MAAMM,iBAAiB,GAAG,CACxBpC,OADwB,EAExB,GAAG8B,IAFqB,KAGfD,WAAW,CAAC7B,OAAD,EAAU,YAAV,EAAwBoC,iBAAxB,EAA2C,GAAGN,IAA9C,CAHtB;;AAIA,MAAMO,aAAa,GAAG,CAACrC,OAAD,EAA6B,GAAG8B,IAAhC,KACpBD,WAAW,CAAC7B,OAAD,EAAU,QAAV,EAAoBqC,aAApB,EAAmC,GAAGP,IAAtC,CADb;;AAGA,MAAMQ,SAAS,GAAG,CAChBtC,OADgB,EAEhBc,SAFgB,EAGhB,GAAGgB,IAHa,KAIPD,WAAW,CAAC7B,OAAD,EAAUc,SAAV,EAAqBwB,SAArB,EAAgC,GAAGR,IAAnC,CAJtB;;AAMAQ,SAAS,CAACC,KAAV,GAAkBJ,YAAlB;AACAG,SAAS,CAACE,UAAV,GAAuBJ,iBAAvB;AACAE,SAAS,CAACG,MAAV,GAAmBJ,aAAnB;eAEeC,S","sourcesContent":["import { ReactTestInstance } from 'react-test-renderer';\nimport act from './act';\n\ntype EventHandler = (...args: any) => unknown;\n\nconst isHostElement = (element?: ReactTestInstance) => {\n return typeof element?.type === 'string';\n};\n\nconst isTextInput = (element?: ReactTestInstance) => {\n const { TextInput } = require('react-native');\n return element?.type === TextInput;\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"],"file":"fireEvent.js"}
|
package/build/helpers/errors.js
CHANGED
|
@@ -55,8 +55,6 @@ const prepareErrorMessage = (error, name, value) => {
|
|
|
55
55
|
exports.prepareErrorMessage = prepareErrorMessage;
|
|
56
56
|
|
|
57
57
|
const createQueryByError = (error, callsite) => {
|
|
58
|
-
var _toString, _ref;
|
|
59
|
-
|
|
60
58
|
if (error instanceof Error) {
|
|
61
59
|
if (error.message.includes('No instances found')) {
|
|
62
60
|
return null;
|
|
@@ -67,7 +65,7 @@ const createQueryByError = (error, callsite) => {
|
|
|
67
65
|
|
|
68
66
|
throw new ErrorWithStack( // generic refining of `unknown` is very hard, you cannot do `'toString' in error` or anything like that
|
|
69
67
|
// Converting as any with extra safe optional chaining will do the job just as well
|
|
70
|
-
`Query: caught unknown error type: ${typeof error}, value: ${error
|
|
68
|
+
`Query: caught unknown error type: ${typeof error}, value: ${error?.toString?.()}`, callsite);
|
|
71
69
|
};
|
|
72
70
|
|
|
73
71
|
exports.createQueryByError = createQueryByError;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/helpers/errors.ts"],"names":["ErrorWithStack","Error","constructor","message","callsite","captureStackTrace","createLibraryNotSupportedError","error","prepareErrorMessage","name","value","errorMessage","replace","toString","min","createQueryByError","includes","copyStackTrace","target","stackTraceSource","stack","warned","printDeprecationWarning","functionName","console","warn","throwRemovedFunctionError","docsRef","throwRenamedFunctionError","newFunctionName"],"mappings":";;;;;;;;;;;;AAAA;;;;AAEO,MAAMA,cAAN,SAA6BC,KAA7B,CAAmC;AACxCC,EAAAA,WAAW,CAACC,OAAD,EAA8BC,QAA9B,EAAkD;AAC3D,UAAMD,OAAN;;AACA,QAAIF,KAAK,CAACI,iBAAV,EAA6B;AAC3BJ,MAAAA,KAAK,CAACI,iBAAN,CAAwB,IAAxB,EAA8BD,QAA9B;AACD;AACF;;AANuC;;;;AASnC,MAAME,8BAA8B,GAAIC,KAAD,IAC5C,IAAIN,KAAJ,CACG,gFACCM,KAAK,YAAYN,KAAjB,GAAyBM,KAAK,CAACJ,OAA/B,GAAyC,EAC1C,EAHH,CADK;;;;AAOA,MAAMK,mBAAmB,GAAG,CAGjCD,KAHiC,EAIjCE,IAJiC,EAKjCC,KALiC,KAMtB;AACX,MAAIC,YAAJ;;AACA,MAAIJ,KAAK,YAAYN,KAArB,EAA4B;AAC1B;AACAU,IAAAA,YAAY,GAAGJ,KAAK,CAACJ,OAAN,CAAcS,OAAd,CACb,kCADa,EAEb,EAFa,CAAf;AAID,GAND,MAMO,IAAIL,KAAK,IAAI,OAAOA,KAAP,KAAiB,QAA9B,EAAwC;AAC7CI,IAAAA,YAAY,GAAGJ,KAAK,CAACM,QAAN,EAAf;AACD,GAFM,MAEA;AACLF,IAAAA,YAAY,GAAG,sBAAf;AACD;;AAED,MAAIF,IAAI,IAAIC,KAAZ,EAAmB;AACjBC,IAAAA,YAAY,IAAK,SAAQF,IAAK,IAAG,2BAAaC,KAAb,EAAoB;AAAEI,MAAAA,GAAG,EAAE;AAAP,KAApB,CAAmC,EAApE;AACD;;AACD,SAAOH,YAAP;AACD,CAxBM;;;;AA0BA,MAAMI,kBAAkB,GAAG,CAChCR,KADgC,EAEhCH,QAFgC,KAGvB;
|
|
1
|
+
{"version":3,"sources":["../../src/helpers/errors.ts"],"names":["ErrorWithStack","Error","constructor","message","callsite","captureStackTrace","createLibraryNotSupportedError","error","prepareErrorMessage","name","value","errorMessage","replace","toString","min","createQueryByError","includes","copyStackTrace","target","stackTraceSource","stack","warned","printDeprecationWarning","functionName","console","warn","throwRemovedFunctionError","docsRef","throwRenamedFunctionError","newFunctionName"],"mappings":";;;;;;;;;;;;AAAA;;;;AAEO,MAAMA,cAAN,SAA6BC,KAA7B,CAAmC;AACxCC,EAAAA,WAAW,CAACC,OAAD,EAA8BC,QAA9B,EAAkD;AAC3D,UAAMD,OAAN;;AACA,QAAIF,KAAK,CAACI,iBAAV,EAA6B;AAC3BJ,MAAAA,KAAK,CAACI,iBAAN,CAAwB,IAAxB,EAA8BD,QAA9B;AACD;AACF;;AANuC;;;;AASnC,MAAME,8BAA8B,GAAIC,KAAD,IAC5C,IAAIN,KAAJ,CACG,gFACCM,KAAK,YAAYN,KAAjB,GAAyBM,KAAK,CAACJ,OAA/B,GAAyC,EAC1C,EAHH,CADK;;;;AAOA,MAAMK,mBAAmB,GAAG,CAGjCD,KAHiC,EAIjCE,IAJiC,EAKjCC,KALiC,KAMtB;AACX,MAAIC,YAAJ;;AACA,MAAIJ,KAAK,YAAYN,KAArB,EAA4B;AAC1B;AACAU,IAAAA,YAAY,GAAGJ,KAAK,CAACJ,OAAN,CAAcS,OAAd,CACb,kCADa,EAEb,EAFa,CAAf;AAID,GAND,MAMO,IAAIL,KAAK,IAAI,OAAOA,KAAP,KAAiB,QAA9B,EAAwC;AAC7CI,IAAAA,YAAY,GAAGJ,KAAK,CAACM,QAAN,EAAf;AACD,GAFM,MAEA;AACLF,IAAAA,YAAY,GAAG,sBAAf;AACD;;AAED,MAAIF,IAAI,IAAIC,KAAZ,EAAmB;AACjBC,IAAAA,YAAY,IAAK,SAAQF,IAAK,IAAG,2BAAaC,KAAb,EAAoB;AAAEI,MAAAA,GAAG,EAAE;AAAP,KAApB,CAAmC,EAApE;AACD;;AACD,SAAOH,YAAP;AACD,CAxBM;;;;AA0BA,MAAMI,kBAAkB,GAAG,CAChCR,KADgC,EAEhCH,QAFgC,KAGvB;AACT,MAAIG,KAAK,YAAYN,KAArB,EAA4B;AAC1B,QAAIM,KAAK,CAACJ,OAAN,CAAca,QAAd,CAAuB,oBAAvB,CAAJ,EAAkD;AAChD,aAAO,IAAP;AACD;;AACD,UAAM,IAAIhB,cAAJ,CAAmBO,KAAK,CAACJ,OAAzB,EAAkCC,QAAlC,CAAN;AACD;;AAED,QAAM,IAAIJ,cAAJ,EACJ;AACA;AACC,uCAAoC,OAAOO,KAAM,YAAYA,KAAD,EAAgBM,QAAhB,IAA6B,EAHtF,EAIJT,QAJI,CAAN;AAMD,CAjBM;;;;AAmBA,SAASa,cAAT,CAAwBC,MAAxB,EAAyCC,gBAAzC,EAAkE;AACvE,MAAID,MAAM,YAAYjB,KAAlB,IAA2BkB,gBAAgB,CAACC,KAAhD,EAAuD;AACrDF,IAAAA,MAAM,CAACE,KAAP,GAAeD,gBAAgB,CAACC,KAAjB,CAAuBR,OAAvB,CACbO,gBAAgB,CAAChB,OADJ,EAEbe,MAAM,CAACf,OAFM,CAAf;AAID;AACF;;AAED,MAAMkB,MAA2C,GAAG,EAApD;;AAEO,SAASC,uBAAT,CAAiCC,YAAjC,EAAuD;AAC5D,MAAIF,MAAM,CAACE,YAAD,CAAV,EAA0B;AACxB;AACD,GAH2D,CAK5D;;;AACAC,EAAAA,OAAO,CAACC,IAAR,CAAc;AAChB;AACA,WAAWF,YAAa;AACxB,GAHE;AAKAF,EAAAA,MAAM,CAACE,YAAD,CAAN,GAAuB,IAAvB;AACD;;AAEM,SAASG,yBAAT,CACLH,YADK,EAELI,OAFK,EAGL;AACA,QAAM,IAAI1B,KAAJ,CACH,IAAGsB,YAAa,wGAAuGI,OAAQ,EAD5H,CAAN;AAGD;;AAEM,SAASC,yBAAT,CACLL,YADK,EAELM,eAFK,EAGL;AACA,QAAM,IAAI7B,cAAJ,CACH,QAAOuB,YAAa,mCAAkCM,eAAgB,oCADnE,EAEJD,yBAFI,CAAN;AAID","sourcesContent":["import prettyFormat from 'pretty-format';\n\nexport class ErrorWithStack extends Error {\n constructor(message: string | undefined, callsite: Function) {\n super(message);\n if (Error.captureStackTrace) {\n Error.captureStackTrace(this, callsite);\n }\n }\n}\n\nexport const createLibraryNotSupportedError = (error: unknown): Error =>\n new Error(\n `Currently the only supported library to search by text is \"react-native\".\\n\\n${\n error instanceof Error ? error.message : ''\n }`\n );\n\nexport const prepareErrorMessage = (\n // TS states that error caught in a catch close are of type `unknown`\n // most real cases will be `Error`, but better safe than sorry\n error: unknown,\n name?: string,\n value?: unknown\n): string => {\n let errorMessage: string;\n if (error instanceof Error) {\n // Strip info about custom predicate\n errorMessage = error.message.replace(\n / matching custom predicate[^]*/gm,\n ''\n );\n } else if (error && typeof error === 'object') {\n errorMessage = error.toString();\n } else {\n errorMessage = 'Caught unknown error';\n }\n\n if (name && value) {\n errorMessage += ` with ${name} ${prettyFormat(value, { min: true })}`;\n }\n return errorMessage;\n};\n\nexport const createQueryByError = (\n error: NonNullable<unknown>,\n callsite: Function\n): null => {\n if (error instanceof Error) {\n if (error.message.includes('No instances found')) {\n return null;\n }\n throw new ErrorWithStack(error.message, callsite);\n }\n\n throw new ErrorWithStack(\n // generic refining of `unknown` is very hard, you cannot do `'toString' in error` or anything like that\n // Converting as any with extra safe optional chaining will do the job just as well\n `Query: caught unknown error type: ${typeof error}, value: ${(error as any)?.toString?.()}`,\n callsite\n );\n};\n\nexport function copyStackTrace(target: unknown, stackTraceSource: Error) {\n if (target instanceof Error && stackTraceSource.stack) {\n target.stack = stackTraceSource.stack.replace(\n stackTraceSource.message,\n target.message\n );\n }\n}\n\nconst warned: { [functionName: string]: boolean } = {};\n\nexport function printDeprecationWarning(functionName: string) {\n if (warned[functionName]) {\n return;\n }\n\n // eslint-disable-next-line no-console\n console.warn(`\n Deprecation Warning:\n Use of ${functionName} is not recommended and will be deleted in future versions of @testing-library/react-native.\n `);\n\n warned[functionName] = true;\n}\n\nexport function throwRemovedFunctionError(\n functionName: string,\n docsRef: string\n) {\n throw new Error(\n `\"${functionName}\" has been removed.\\n\\nPlease consult: https://callstack.github.io/react-native-testing-library/docs/${docsRef}`\n );\n}\n\nexport function throwRenamedFunctionError(\n functionName: string,\n newFunctionName: string\n) {\n throw new ErrorWithStack(\n `The \"${functionName}\" function has been renamed to \"${newFunctionName}\". Please replace all occurrences.`,\n throwRenamedFunctionError\n );\n}\n"],"file":"errors.js"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Matches whether given array prop contains the given value, or all given values.
|
|
3
|
+
*
|
|
4
|
+
* @param prop - The array prop to match.
|
|
5
|
+
* @param matcher - The value or values to be included in the array.
|
|
6
|
+
* @returns Whether the array prop contains the given value, or all given values.
|
|
7
|
+
*/
|
|
8
|
+
export declare function matchArrayProp(prop: Array<string> | undefined, matcher: string | Array<string>): boolean;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.matchArrayProp = matchArrayProp;
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Matches whether given array prop contains the given value, or all given values.
|
|
10
|
+
*
|
|
11
|
+
* @param prop - The array prop to match.
|
|
12
|
+
* @param matcher - The value or values to be included in the array.
|
|
13
|
+
* @returns Whether the array prop contains the given value, or all given values.
|
|
14
|
+
*/
|
|
15
|
+
function matchArrayProp(prop, matcher) {
|
|
16
|
+
if (!prop || matcher.length === 0) {
|
|
17
|
+
return false;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
if (typeof matcher === 'string') {
|
|
21
|
+
return prop.includes(matcher);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
return matcher.every(e => prop.includes(e));
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=matchArrayProp.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/helpers/matchers/matchArrayProp.ts"],"names":["matchArrayProp","prop","matcher","length","includes","every","e"],"mappings":";;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASA,cAAT,CACLC,IADK,EAELC,OAFK,EAGI;AACT,MAAI,CAACD,IAAD,IAASC,OAAO,CAACC,MAAR,KAAmB,CAAhC,EAAmC;AACjC,WAAO,KAAP;AACD;;AAED,MAAI,OAAOD,OAAP,KAAmB,QAAvB,EAAiC;AAC/B,WAAOD,IAAI,CAACG,QAAL,CAAcF,OAAd,CAAP;AACD;;AAED,SAAOA,OAAO,CAACG,KAAR,CAAeC,CAAD,IAAOL,IAAI,CAACG,QAAL,CAAcE,CAAd,CAArB,CAAP;AACD","sourcesContent":["/**\n * Matches whether given array prop contains the given value, or all given values.\n *\n * @param prop - The array prop to match.\n * @param matcher - The value or values to be included in the array.\n * @returns Whether the array prop contains the given value, or all given values.\n */\nexport function matchArrayProp(\n prop: Array<string> | undefined,\n matcher: string | Array<string>\n): boolean {\n if (!prop || matcher.length === 0) {\n return false;\n }\n\n if (typeof matcher === 'string') {\n return prop.includes(matcher);\n }\n\n return matcher.every((e) => prop.includes(e));\n}\n"],"file":"matchArrayProp.js"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* check that each key value pair of the objects match
|
|
3
|
+
* BE CAREFUL it works only for 1 level deep key value pairs
|
|
4
|
+
* won't work for nested objects
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Matches whether given object prop contains all key/value pairs.
|
|
8
|
+
* @param prop - The object prop to match.
|
|
9
|
+
* @param matcher - The key/value pairs to be included in the object.
|
|
10
|
+
* @returns Whether the object prop contains all key/value pairs.
|
|
11
|
+
*/
|
|
12
|
+
export declare function matchObjectProp<T extends Record<string, unknown>>(prop: T | undefined, matcher: T): boolean;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.matchObjectProp = matchObjectProp;
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* check that each key value pair of the objects match
|
|
10
|
+
* BE CAREFUL it works only for 1 level deep key value pairs
|
|
11
|
+
* won't work for nested objects
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Matches whether given object prop contains all key/value pairs.
|
|
16
|
+
* @param prop - The object prop to match.
|
|
17
|
+
* @param matcher - The key/value pairs to be included in the object.
|
|
18
|
+
* @returns Whether the object prop contains all key/value pairs.
|
|
19
|
+
*/
|
|
20
|
+
function matchObjectProp(prop, matcher) {
|
|
21
|
+
if (!prop || Object.keys(matcher).length === 0) {
|
|
22
|
+
return false;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
return Object.keys(prop).length !== 0 && Object.keys(matcher).every(key => prop[key] === matcher[key]);
|
|
26
|
+
}
|
|
27
|
+
//# sourceMappingURL=matchObjectProp.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/helpers/matchers/matchObjectProp.ts"],"names":["matchObjectProp","prop","matcher","Object","keys","length","every","key"],"mappings":";;;;;;;AAAA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACO,SAASA,eAAT,CACLC,IADK,EAELC,OAFK,EAGI;AACT,MAAI,CAACD,IAAD,IAASE,MAAM,CAACC,IAAP,CAAYF,OAAZ,EAAqBG,MAArB,KAAgC,CAA7C,EAAgD;AAC9C,WAAO,KAAP;AACD;;AAED,SACEF,MAAM,CAACC,IAAP,CAAYH,IAAZ,EAAkBI,MAAlB,KAA6B,CAA7B,IACAF,MAAM,CAACC,IAAP,CAAYF,OAAZ,EAAqBI,KAArB,CAA4BC,GAAD,IAASN,IAAI,CAACM,GAAD,CAAJ,KAAcL,OAAO,CAACK,GAAD,CAAzD,CAFF;AAID","sourcesContent":["/**\n * check that each key value pair of the objects match\n * BE CAREFUL it works only for 1 level deep key value pairs\n * won't work for nested objects\n */\n\n/**\n * Matches whether given object prop contains all key/value pairs.\n * @param prop - The object prop to match.\n * @param matcher - The key/value pairs to be included in the object.\n * @returns Whether the object prop contains all key/value pairs.\n */\nexport function matchObjectProp<T extends Record<string, unknown>>(\n prop: T | undefined,\n matcher: T\n): boolean {\n if (!prop || Object.keys(matcher).length === 0) {\n return false;\n }\n\n return (\n Object.keys(prop).length !== 0 &&\n Object.keys(matcher).every((key) => prop[key] === matcher[key])\n );\n}\n"],"file":"matchObjectProp.js"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { TextMatch } from '../../matches';
|
|
2
|
+
/**
|
|
3
|
+
* Matches the given string property again string or regex matcher.
|
|
4
|
+
*
|
|
5
|
+
* @param prop - The string prop to match.
|
|
6
|
+
* @param matcher - The string or regex to match.
|
|
7
|
+
* @returns - Whether the string prop matches the given string or regex.
|
|
8
|
+
*/
|
|
9
|
+
export declare function matchStringProp(prop: string | undefined, matcher: TextMatch): boolean;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.matchStringProp = matchStringProp;
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Matches the given string property again string or regex matcher.
|
|
10
|
+
*
|
|
11
|
+
* @param prop - The string prop to match.
|
|
12
|
+
* @param matcher - The string or regex to match.
|
|
13
|
+
* @returns - Whether the string prop matches the given string or regex.
|
|
14
|
+
*/
|
|
15
|
+
function matchStringProp(prop, matcher) {
|
|
16
|
+
if (!prop) {
|
|
17
|
+
return false;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
if (typeof matcher === 'string') {
|
|
21
|
+
return prop === matcher;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
return prop.match(matcher) != null;
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=matchStringProp.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/helpers/matchers/matchStringProp.ts"],"names":["matchStringProp","prop","matcher","match"],"mappings":";;;;;;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASA,eAAT,CACLC,IADK,EAELC,OAFK,EAGI;AACT,MAAI,CAACD,IAAL,EAAW;AACT,WAAO,KAAP;AACD;;AAED,MAAI,OAAOC,OAAP,KAAmB,QAAvB,EAAiC;AAC/B,WAAOD,IAAI,KAAKC,OAAhB;AACD;;AAED,SAAOD,IAAI,CAACE,KAAL,CAAWD,OAAX,KAAuB,IAA9B;AACD","sourcesContent":["import { TextMatch } from '../../matches';\n\n/**\n * Matches the given string property again string or regex matcher.\n *\n * @param prop - The string prop to match.\n * @param matcher - The string or regex to match.\n * @returns - Whether the string prop matches the given string or regex.\n */\nexport function matchStringProp(\n prop: string | undefined,\n matcher: TextMatch\n): boolean {\n if (!prop) {\n return false;\n }\n\n if (typeof matcher === 'string') {\n return prop === matcher;\n }\n\n return prop.match(matcher) != null;\n}\n"],"file":"matchStringProp.js"}
|
package/build/helpers/timers.js
CHANGED
|
@@ -9,8 +9,9 @@ exports.setTimeout = exports.setImmediate = void 0;
|
|
|
9
9
|
// Most content of this file sourced directly from https://github.com/testing-library/dom-testing-library/blob/main/src/helpers.js
|
|
10
10
|
|
|
11
11
|
/* globals jest */
|
|
12
|
-
const globalObj = typeof window === 'undefined' ? global : window;
|
|
12
|
+
const globalObj = typeof window === 'undefined' ? global : window;
|
|
13
13
|
|
|
14
|
+
// Currently this fn only supports jest timers, but it could support other test runners in the future.
|
|
14
15
|
function runWithRealTimers(callback) {
|
|
15
16
|
const fakeTimersType = getJestFakeTimersType();
|
|
16
17
|
|
|
@@ -21,7 +22,8 @@ function runWithRealTimers(callback) {
|
|
|
21
22
|
const callbackReturnValue = callback();
|
|
22
23
|
|
|
23
24
|
if (fakeTimersType) {
|
|
24
|
-
|
|
25
|
+
const fakeTimersConfig = getFakeTimersConfigFromType(fakeTimersType);
|
|
26
|
+
jest.useFakeTimers(fakeTimersConfig);
|
|
25
27
|
}
|
|
26
28
|
|
|
27
29
|
return callbackReturnValue;
|
|
@@ -52,6 +54,14 @@ function getJestFakeTimersType() {
|
|
|
52
54
|
return null;
|
|
53
55
|
}
|
|
54
56
|
|
|
57
|
+
function getFakeTimersConfigFromType(type) {
|
|
58
|
+
return type === 'legacy' ? {
|
|
59
|
+
legacyFakeTimers: true
|
|
60
|
+
} : {
|
|
61
|
+
legacyFakeTimers: false
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
|
|
55
65
|
const jestFakeTimersAreEnabled = () => Boolean(getJestFakeTimersType()); // we only run our tests in node, and setImmediate is supported in node.
|
|
56
66
|
|
|
57
67
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/helpers/timers.ts"],"names":["globalObj","window","global","runWithRealTimers","callback","fakeTimersType","getJestFakeTimersType","jest","useRealTimers","callbackReturnValue","useFakeTimers","setTimeout","_isMockFunction","clock","getRealSystemTime","jestFakeTimersAreEnabled","Boolean","setImmediatePolyfill","fn","bindTimeFunctions","clearTimeoutFn","clearTimeout","setImmediateFn","setImmediate","setTimeoutFn"],"mappings":";;;;;;;;AAAA;;AACA;AACA,MAAMA,SAAS,GAAG,OAAOC,MAAP,KAAkB,WAAlB,GAAgCC,MAAhC,GAAyCD,MAA3D
|
|
1
|
+
{"version":3,"sources":["../../src/helpers/timers.ts"],"names":["globalObj","window","global","runWithRealTimers","callback","fakeTimersType","getJestFakeTimersType","jest","useRealTimers","callbackReturnValue","fakeTimersConfig","getFakeTimersConfigFromType","useFakeTimers","setTimeout","_isMockFunction","clock","getRealSystemTime","type","legacyFakeTimers","jestFakeTimersAreEnabled","Boolean","setImmediatePolyfill","fn","bindTimeFunctions","clearTimeoutFn","clearTimeout","setImmediateFn","setImmediate","setTimeoutFn"],"mappings":";;;;;;;;AAAA;;AACA;AACA,MAAMA,SAAS,GAAG,OAAOC,MAAP,KAAkB,WAAlB,GAAgCC,MAAhC,GAAyCD,MAA3D;;AAIA;AACA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,EAAyB,CAAzB,CAAP;AACD;;AAQD,SAASC,iBAAT,GAAgD;AAC9C,SAAO;AACLC,IAAAA,cAAc,EAAExB,SAAS,CAACyB,YADrB;AAELC,IAAAA,cAAc,EAAE1B,SAAS,CAAC2B,YAAV,IAA0BN,oBAFrC;AAGLO,IAAAA,YAAY,EAAE5B,SAAS,CAACa;AAHnB,GAAP;AAKD;;AAED,MAAM;AAAEW,EAAAA,cAAF;AAAkBE,EAAAA,cAAlB;AAAkCE,EAAAA;AAAlC,IAAmDzB,iBAAiB,CACxEoB,iBADwE,CAA1E","sourcesContent":["// Most content of this file sourced directly from https://github.com/testing-library/dom-testing-library/blob/main/src/helpers.js\n/* globals jest */\nconst globalObj = typeof window === 'undefined' ? global : window;\n\ntype FakeTimersTypes = 'modern' | 'legacy';\n\n// Currently this fn only supports jest timers, but it could support other test runners in the future.\nfunction runWithRealTimers<T>(callback: () => T): T {\n const fakeTimersType = getJestFakeTimersType();\n if (fakeTimersType) {\n jest.useRealTimers();\n }\n\n const callbackReturnValue = callback();\n\n if (fakeTimersType) {\n const fakeTimersConfig = getFakeTimersConfigFromType(fakeTimersType);\n jest.useFakeTimers(fakeTimersConfig);\n }\n\n return callbackReturnValue;\n}\n\nfunction getJestFakeTimersType(): FakeTimersTypes | null {\n // istanbul ignore if\n if (\n typeof jest === 'undefined' ||\n typeof globalObj.setTimeout === 'undefined'\n ) {\n return null;\n }\n\n if (\n // @ts-expect-error jest mutates setTimeout\n typeof globalObj.setTimeout._isMockFunction !== 'undefined' &&\n // @ts-expect-error jest mutates setTimeout\n globalObj.setTimeout._isMockFunction\n ) {\n return 'legacy';\n }\n\n if (\n // @ts-expect-error jest mutates setTimeout\n typeof globalObj.setTimeout.clock !== 'undefined' &&\n typeof jest.getRealSystemTime !== 'undefined'\n ) {\n try {\n // jest.getRealSystemTime is only supported for Jest's `modern` fake timers and otherwise throws\n jest.getRealSystemTime();\n return 'modern';\n } catch {\n // not using Jest's modern fake timers\n }\n }\n\n return null;\n}\n\nfunction getFakeTimersConfigFromType(type: FakeTimersTypes) {\n return type === 'legacy'\n ? { legacyFakeTimers: true }\n : { legacyFakeTimers: false };\n}\n\nconst jestFakeTimersAreEnabled = (): boolean =>\n Boolean(getJestFakeTimersType());\n\n// we only run our tests in node, and setImmediate is supported in node.\nfunction setImmediatePolyfill(fn: Function) {\n return globalObj.setTimeout(fn, 0);\n}\n\ntype BindTimeFunctions = {\n clearTimeoutFn: typeof clearTimeout;\n setImmediateFn: typeof setImmediate;\n setTimeoutFn: typeof setTimeout;\n};\n\nfunction bindTimeFunctions(): BindTimeFunctions {\n return {\n clearTimeoutFn: globalObj.clearTimeout,\n setImmediateFn: globalObj.setImmediate || setImmediatePolyfill,\n setTimeoutFn: globalObj.setTimeout,\n };\n}\n\nconst { clearTimeoutFn, setImmediateFn, setTimeoutFn } = runWithRealTimers(\n bindTimeFunctions\n) as BindTimeFunctions;\n\nexport {\n runWithRealTimers,\n jestFakeTimersAreEnabled,\n clearTimeoutFn as clearTimeout,\n setImmediateFn as setImmediate,\n setTimeoutFn as setTimeout,\n};\n"],"file":"timers.js"}
|
package/build/index.flow.js
CHANGED
|
@@ -56,16 +56,6 @@ declare type A11yState = {|
|
|
|
56
56
|
expanded?: boolean,
|
|
57
57
|
|};
|
|
58
58
|
|
|
59
|
-
declare type A11yStates =
|
|
60
|
-
| 'disabled'
|
|
61
|
-
| 'selected'
|
|
62
|
-
| 'checked'
|
|
63
|
-
| 'unchecked'
|
|
64
|
-
| 'busy'
|
|
65
|
-
| 'expanded'
|
|
66
|
-
| 'collapsed'
|
|
67
|
-
| 'hasPopup';
|
|
68
|
-
|
|
69
59
|
declare type A11yValue = {
|
|
70
60
|
min?: number,
|
|
71
61
|
max?: number,
|
|
@@ -266,25 +256,17 @@ interface A11yAPI {
|
|
|
266
256
|
waitForOptions?: WaitForOptions
|
|
267
257
|
) => FindAllReturn;
|
|
268
258
|
|
|
269
|
-
// States
|
|
270
|
-
getByA11yStates: (matcher: A11yStates | Array<A11yStates>) => GetReturn;
|
|
271
|
-
getAllByA11yStates: (matcher: A11yStates | Array<A11yStates>) => GetAllReturn;
|
|
272
|
-
queryByA11yStates: (matcher: A11yStates | Array<A11yStates>) => QueryReturn;
|
|
273
|
-
queryAllByA11yStates: (
|
|
274
|
-
matcher: A11yStates | Array<A11yStates>
|
|
275
|
-
) => QueryAllReturn;
|
|
276
|
-
|
|
277
259
|
// State
|
|
278
|
-
getByA11yState: (matcher:
|
|
279
|
-
getAllByA11yState: (matcher:
|
|
280
|
-
queryByA11yState: (matcher:
|
|
281
|
-
queryAllByA11yState: (matcher:
|
|
260
|
+
getByA11yState: (matcher: A11yState) => GetReturn;
|
|
261
|
+
getAllByA11yState: (matcher: A11yState) => GetAllReturn;
|
|
262
|
+
queryByA11yState: (matcher: A11yState) => QueryReturn;
|
|
263
|
+
queryAllByA11yState: (matcher: A11yState) => QueryAllReturn;
|
|
282
264
|
findByA11yState: (
|
|
283
|
-
matcher:
|
|
265
|
+
matcher: A11yState,
|
|
284
266
|
waitForOptions?: WaitForOptions
|
|
285
267
|
) => FindReturn;
|
|
286
268
|
findAllByA11yState: (
|
|
287
|
-
matcher:
|
|
269
|
+
matcher: A11yState,
|
|
288
270
|
waitForOptions?: WaitForOptions
|
|
289
271
|
) => FindAllReturn;
|
|
290
272
|
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { ReactTestInstance } from 'react-test-renderer';
|
|
2
|
+
import { AccessibilityState } from 'react-native';
|
|
3
|
+
import type { FindAllByQuery, FindByQuery, GetAllByQuery, GetByQuery, QueryAllByQuery, QueryByQuery } from './makeQueries';
|
|
4
|
+
export declare type ByA11yStateQueries = {
|
|
5
|
+
getByA11yState: GetByQuery<AccessibilityState>;
|
|
6
|
+
getAllByA11yState: GetAllByQuery<AccessibilityState>;
|
|
7
|
+
queryByA11yState: QueryByQuery<AccessibilityState>;
|
|
8
|
+
queryAllByA11yState: QueryAllByQuery<AccessibilityState>;
|
|
9
|
+
findByA11yState: FindByQuery<AccessibilityState>;
|
|
10
|
+
findAllByA11yState: FindAllByQuery<AccessibilityState>;
|
|
11
|
+
getByAccessibilityState: GetByQuery<AccessibilityState>;
|
|
12
|
+
getAllByAccessibilityState: GetAllByQuery<AccessibilityState>;
|
|
13
|
+
queryByAccessibilityState: QueryByQuery<AccessibilityState>;
|
|
14
|
+
queryAllByAccessibilityState: QueryAllByQuery<AccessibilityState>;
|
|
15
|
+
findByAccessibilityState: FindByQuery<AccessibilityState>;
|
|
16
|
+
findAllByAccessibilityState: FindAllByQuery<AccessibilityState>;
|
|
17
|
+
};
|
|
18
|
+
export declare const bindByA11yStateQueries: (instance: ReactTestInstance) => ByA11yStateQueries;
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.bindByA11yStateQueries = void 0;
|
|
7
|
+
|
|
8
|
+
var _matchObjectProp = require("../helpers/matchers/matchObjectProp");
|
|
9
|
+
|
|
10
|
+
var _makeQueries = require("./makeQueries");
|
|
11
|
+
|
|
12
|
+
const queryAllByA11yState = instance => function queryAllByA11yStateFn(state) {
|
|
13
|
+
return instance.findAll(node => typeof node.type === 'string' && (0, _matchObjectProp.matchObjectProp)(node.props.accessibilityState, state));
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
const getMultipleError = state => `Found multiple elements with accessibilityState: ${JSON.stringify(state)}`;
|
|
17
|
+
|
|
18
|
+
const getMissingError = state => `Unable to find an element with accessibilityState: ${JSON.stringify(state)}`;
|
|
19
|
+
|
|
20
|
+
const {
|
|
21
|
+
getBy,
|
|
22
|
+
getAllBy,
|
|
23
|
+
queryBy,
|
|
24
|
+
queryAllBy,
|
|
25
|
+
findBy,
|
|
26
|
+
findAllBy
|
|
27
|
+
} = (0, _makeQueries.makeQueries)(queryAllByA11yState, getMissingError, getMultipleError);
|
|
28
|
+
|
|
29
|
+
const bindByA11yStateQueries = instance => {
|
|
30
|
+
const getByA11yState = getBy(instance);
|
|
31
|
+
const getAllByA11yState = getAllBy(instance);
|
|
32
|
+
const queryByA11yState = queryBy(instance);
|
|
33
|
+
const queryAllByA11yState = queryAllBy(instance);
|
|
34
|
+
const findByA11yState = findBy(instance);
|
|
35
|
+
const findAllByA11yState = findAllBy(instance);
|
|
36
|
+
return {
|
|
37
|
+
getByA11yState,
|
|
38
|
+
getAllByA11yState,
|
|
39
|
+
queryByA11yState,
|
|
40
|
+
queryAllByA11yState,
|
|
41
|
+
findByA11yState,
|
|
42
|
+
findAllByA11yState,
|
|
43
|
+
getByAccessibilityState: getByA11yState,
|
|
44
|
+
getAllByAccessibilityState: getAllByA11yState,
|
|
45
|
+
queryByAccessibilityState: queryByA11yState,
|
|
46
|
+
queryAllByAccessibilityState: queryAllByA11yState,
|
|
47
|
+
findByAccessibilityState: findByA11yState,
|
|
48
|
+
findAllByAccessibilityState: findAllByA11yState
|
|
49
|
+
};
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
exports.bindByA11yStateQueries = bindByA11yStateQueries;
|
|
53
|
+
//# sourceMappingURL=a11yState.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/queries/a11yState.ts"],"names":["queryAllByA11yState","instance","queryAllByA11yStateFn","state","findAll","node","type","props","accessibilityState","getMultipleError","JSON","stringify","getMissingError","getBy","getAllBy","queryBy","queryAllBy","findBy","findAllBy","bindByA11yStateQueries","getByA11yState","getAllByA11yState","queryByA11yState","findByA11yState","findAllByA11yState","getByAccessibilityState","getAllByAccessibilityState","queryByAccessibilityState","queryAllByAccessibilityState","findByAccessibilityState","findAllByAccessibilityState"],"mappings":";;;;;;;AAEA;;AACA;;AAUA,MAAMA,mBAAmB,GACvBC,QAD0B,IAG1B,SAASC,qBAAT,CAA+BC,KAA/B,EAAsC;AACpC,SAAOF,QAAQ,CAACG,OAAT,CACJC,IAAD,IACE,OAAOA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EAAEN;AAbxB,GAAP;AAeD,CAzBM","sourcesContent":["import type { ReactTestInstance } from 'react-test-renderer';\nimport { AccessibilityState } from 'react-native';\nimport { matchObjectProp } from '../helpers/matchers/matchObjectProp';\nimport { makeQueries } from './makeQueries';\nimport type {\n FindAllByQuery,\n FindByQuery,\n GetAllByQuery,\n GetByQuery,\n QueryAllByQuery,\n QueryByQuery,\n} from './makeQueries';\n\nconst queryAllByA11yState = (\n instance: ReactTestInstance\n): ((state: AccessibilityState) => Array<ReactTestInstance>) =>\n function queryAllByA11yStateFn(state) {\n return instance.findAll(\n (node) =>\n typeof node.type === 'string' &&\n matchObjectProp(node.props.accessibilityState, state)\n );\n };\n\nconst getMultipleError = (state: AccessibilityState) =>\n `Found multiple elements with accessibilityState: ${JSON.stringify(state)}`;\nconst getMissingError = (state: AccessibilityState) =>\n `Unable to find an element with accessibilityState: ${JSON.stringify(state)}`;\n\nconst { getBy, getAllBy, queryBy, queryAllBy, findBy, findAllBy } = makeQueries(\n queryAllByA11yState,\n getMissingError,\n getMultipleError\n);\n\nexport type ByA11yStateQueries = {\n getByA11yState: GetByQuery<AccessibilityState>;\n getAllByA11yState: GetAllByQuery<AccessibilityState>;\n queryByA11yState: QueryByQuery<AccessibilityState>;\n queryAllByA11yState: QueryAllByQuery<AccessibilityState>;\n findByA11yState: FindByQuery<AccessibilityState>;\n findAllByA11yState: FindAllByQuery<AccessibilityState>;\n\n getByAccessibilityState: GetByQuery<AccessibilityState>;\n getAllByAccessibilityState: GetAllByQuery<AccessibilityState>;\n queryByAccessibilityState: QueryByQuery<AccessibilityState>;\n queryAllByAccessibilityState: QueryAllByQuery<AccessibilityState>;\n findByAccessibilityState: FindByQuery<AccessibilityState>;\n findAllByAccessibilityState: FindAllByQuery<AccessibilityState>;\n};\n\nexport const bindByA11yStateQueries = (\n instance: ReactTestInstance\n): ByA11yStateQueries => {\n const getByA11yState = getBy(instance);\n const getAllByA11yState = getAllBy(instance);\n const queryByA11yState = queryBy(instance);\n const queryAllByA11yState = queryAllBy(instance);\n const findByA11yState = findBy(instance);\n const findAllByA11yState = findAllBy(instance);\n\n return {\n getByA11yState,\n getAllByA11yState,\n queryByA11yState,\n queryAllByA11yState,\n findByA11yState,\n findAllByA11yState,\n\n getByAccessibilityState: getByA11yState,\n getAllByAccessibilityState: getAllByA11yState,\n queryByAccessibilityState: queryByA11yState,\n queryAllByAccessibilityState: queryAllByA11yState,\n findByAccessibilityState: findByA11yState,\n findAllByAccessibilityState: findAllByA11yState,\n };\n};\n"],"file":"a11yState.js"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { ReactTestInstance } from 'react-test-renderer';
|
|
2
|
+
import type { FindAllByQuery, FindByQuery, GetAllByQuery, GetByQuery, QueryAllByQuery, QueryByQuery } from './makeQueries';
|
|
3
|
+
declare type A11yValue = {
|
|
4
|
+
min?: number;
|
|
5
|
+
max?: number;
|
|
6
|
+
now?: number;
|
|
7
|
+
text?: string;
|
|
8
|
+
};
|
|
9
|
+
export declare type ByA11yValueQueries = {
|
|
10
|
+
getByA11yValue: GetByQuery<A11yValue>;
|
|
11
|
+
getAllByA11yValue: GetAllByQuery<A11yValue>;
|
|
12
|
+
queryByA11yValue: QueryByQuery<A11yValue>;
|
|
13
|
+
queryAllByA11yValue: QueryAllByQuery<A11yValue>;
|
|
14
|
+
findByA11yValue: FindByQuery<A11yValue>;
|
|
15
|
+
findAllByA11yValue: FindAllByQuery<A11yValue>;
|
|
16
|
+
getByAccessibilityValue: GetByQuery<A11yValue>;
|
|
17
|
+
getAllByAccessibilityValue: GetAllByQuery<A11yValue>;
|
|
18
|
+
queryByAccessibilityValue: QueryByQuery<A11yValue>;
|
|
19
|
+
queryAllByAccessibilityValue: QueryAllByQuery<A11yValue>;
|
|
20
|
+
findByAccessibilityValue: FindByQuery<A11yValue>;
|
|
21
|
+
findAllByAccessibilityValue: FindAllByQuery<A11yValue>;
|
|
22
|
+
};
|
|
23
|
+
export declare const bindByA11yValueQueries: (instance: ReactTestInstance) => ByA11yValueQueries;
|
|
24
|
+
export {};
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.bindByA11yValueQueries = void 0;
|
|
7
|
+
|
|
8
|
+
var _matchObjectProp = require("../helpers/matchers/matchObjectProp");
|
|
9
|
+
|
|
10
|
+
var _makeQueries = require("./makeQueries");
|
|
11
|
+
|
|
12
|
+
const queryAllByA11yValue = instance => function queryAllByA11yValueFn(value) {
|
|
13
|
+
return instance.findAll(node => typeof node.type === 'string' && (0, _matchObjectProp.matchObjectProp)(node.props.accessibilityValue, value));
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
const getMultipleError = value => `Found multiple elements with accessibilityValue: ${JSON.stringify(value)} `;
|
|
17
|
+
|
|
18
|
+
const getMissingError = value => `Unable to find an element with accessibilityValue: ${JSON.stringify(value)}`;
|
|
19
|
+
|
|
20
|
+
const {
|
|
21
|
+
getBy,
|
|
22
|
+
getAllBy,
|
|
23
|
+
queryBy,
|
|
24
|
+
queryAllBy,
|
|
25
|
+
findBy,
|
|
26
|
+
findAllBy
|
|
27
|
+
} = (0, _makeQueries.makeQueries)(queryAllByA11yValue, getMissingError, getMultipleError);
|
|
28
|
+
|
|
29
|
+
const bindByA11yValueQueries = instance => {
|
|
30
|
+
const getByA11yValue = getBy(instance);
|
|
31
|
+
const getAllByA11yValue = getAllBy(instance);
|
|
32
|
+
const queryByA11yValue = queryBy(instance);
|
|
33
|
+
const queryAllByA11yValue = queryAllBy(instance);
|
|
34
|
+
const findByA11yValue = findBy(instance);
|
|
35
|
+
const findAllByA11yValue = findAllBy(instance);
|
|
36
|
+
return {
|
|
37
|
+
getByA11yValue,
|
|
38
|
+
getAllByA11yValue,
|
|
39
|
+
queryByA11yValue,
|
|
40
|
+
queryAllByA11yValue,
|
|
41
|
+
findByA11yValue,
|
|
42
|
+
findAllByA11yValue,
|
|
43
|
+
getByAccessibilityValue: getByA11yValue,
|
|
44
|
+
getAllByAccessibilityValue: getAllByA11yValue,
|
|
45
|
+
queryByAccessibilityValue: queryByA11yValue,
|
|
46
|
+
queryAllByAccessibilityValue: queryAllByA11yValue,
|
|
47
|
+
findByAccessibilityValue: findByA11yValue,
|
|
48
|
+
findAllByAccessibilityValue: findAllByA11yValue
|
|
49
|
+
};
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
exports.bindByA11yValueQueries = bindByA11yValueQueries;
|
|
53
|
+
//# sourceMappingURL=a11yValue.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/queries/a11yValue.ts"],"names":["queryAllByA11yValue","instance","queryAllByA11yValueFn","value","findAll","node","type","props","accessibilityValue","getMultipleError","JSON","stringify","getMissingError","getBy","getAllBy","queryBy","queryAllBy","findBy","findAllBy","bindByA11yValueQueries","getByA11yValue","getAllByA11yValue","queryByA11yValue","findByA11yValue","findAllByA11yValue","getByAccessibilityValue","getAllByAccessibilityValue","queryByAccessibilityValue","queryAllByAccessibilityValue","findByAccessibilityValue","findAllByAccessibilityValue"],"mappings":";;;;;;;AACA;;AACA;;AAiBA,MAAMA,mBAAmB,GACvBC,QAD0B,IAG1B,SAASC,qBAAT,CAA+BC,KAA/B,EAAsC;AACpC,SAAOF,QAAQ,CAACG,OAAT,CACJC,IAAD,IACE,OAAOA,IAAI,CAACC,IAAZ,KAAqB,QAArB,IACA,sCAAgBD,IAAI,CAACE,KAAL,CAAWC,kBAA3B,EAA+CL,KAA/C,CAHG,CAAP;AAKD,CATH;;AAWA,MAAMM,gBAAgB,GAAIN,KAAD,IACtB,oDAAmDO,IAAI,CAACC,SAAL,CAAeR,KAAf,CAAsB,GAD5E;;AAEA,MAAMS,eAAe,GAAIT,KAAD,IACrB,sDAAqDO,IAAI,CAACC,SAAL,CAAeR,KAAf,CAAsB,EAD9E;;AAGA,MAAM;AAAEU,EAAAA,KAAF;AAASC,EAAAA,QAAT;AAAmBC,EAAAA,OAAnB;AAA4BC,EAAAA,UAA5B;AAAwCC,EAAAA,MAAxC;AAAgDC,EAAAA;AAAhD,IAA8D,8BAClElB,mBADkE,EAElEY,eAFkE,EAGlEH,gBAHkE,CAApE;;AAsBO,MAAMU,sBAAsB,GACjClB,QADoC,IAEb;AACvB,QAAMmB,cAAc,GAAGP,KAAK,CAACZ,QAAD,CAA5B;AACA,QAAMoB,iBAAiB,GAAGP,QAAQ,CAACb,QAAD,CAAlC;AACA,QAAMqB,gBAAgB,GAAGP,OAAO,CAACd,QAAD,CAAhC;AACA,QAAMD,mBAAmB,GAAGgB,UAAU,CAACf,QAAD,CAAtC;AACA,QAAMsB,eAAe,GAAGN,MAAM,CAAChB,QAAD,CAA9B;AACA,QAAMuB,kBAAkB,GAAGN,SAAS,CAACjB,QAAD,CAApC;AAEA,SAAO;AACLmB,IAAAA,cADK;AAELC,IAAAA,iBAFK;AAGLC,IAAAA,gBAHK;AAILtB,IAAAA,mBAJK;AAKLuB,IAAAA,eALK;AAMLC,IAAAA,kBANK;AAQLC,IAAAA,uBAAuB,EAAEL,cARpB;AASLM,IAAAA,0BAA0B,EAAEL,iBATvB;AAULM,IAAAA,yBAAyB,EAAEL,gBAVtB;AAWLM,IAAAA,4BAA4B,EAAE5B,mBAXzB;AAYL6B,IAAAA,wBAAwB,EAAEN,eAZrB;AAaLO,IAAAA,2BAA2B,EAAEN;AAbxB,GAAP;AAeD,CAzBM","sourcesContent":["import type { ReactTestInstance } from 'react-test-renderer';\nimport { matchObjectProp } from '../helpers/matchers/matchObjectProp';\nimport { makeQueries } from './makeQueries';\nimport type {\n FindAllByQuery,\n FindByQuery,\n GetAllByQuery,\n GetByQuery,\n QueryAllByQuery,\n QueryByQuery,\n} from './makeQueries';\n\ntype A11yValue = {\n min?: number;\n max?: number;\n now?: number;\n text?: string;\n};\n\nconst queryAllByA11yValue = (\n instance: ReactTestInstance\n): ((value: A11yValue) => Array<ReactTestInstance>) =>\n function queryAllByA11yValueFn(value) {\n return instance.findAll(\n (node) =>\n typeof node.type === 'string' &&\n matchObjectProp(node.props.accessibilityValue, value)\n );\n };\n\nconst getMultipleError = (value: A11yValue) =>\n `Found multiple elements with accessibilityValue: ${JSON.stringify(value)} `;\nconst getMissingError = (value: A11yValue) =>\n `Unable to find an element with accessibilityValue: ${JSON.stringify(value)}`;\n\nconst { getBy, getAllBy, queryBy, queryAllBy, findBy, findAllBy } = makeQueries(\n queryAllByA11yValue,\n getMissingError,\n getMultipleError\n);\n\nexport type ByA11yValueQueries = {\n getByA11yValue: GetByQuery<A11yValue>;\n getAllByA11yValue: GetAllByQuery<A11yValue>;\n queryByA11yValue: QueryByQuery<A11yValue>;\n queryAllByA11yValue: QueryAllByQuery<A11yValue>;\n findByA11yValue: FindByQuery<A11yValue>;\n findAllByA11yValue: FindAllByQuery<A11yValue>;\n\n getByAccessibilityValue: GetByQuery<A11yValue>;\n getAllByAccessibilityValue: GetAllByQuery<A11yValue>;\n queryByAccessibilityValue: QueryByQuery<A11yValue>;\n queryAllByAccessibilityValue: QueryAllByQuery<A11yValue>;\n findByAccessibilityValue: FindByQuery<A11yValue>;\n findAllByAccessibilityValue: FindAllByQuery<A11yValue>;\n};\n\nexport const bindByA11yValueQueries = (\n instance: ReactTestInstance\n): ByA11yValueQueries => {\n const getByA11yValue = getBy(instance);\n const getAllByA11yValue = getAllBy(instance);\n const queryByA11yValue = queryBy(instance);\n const queryAllByA11yValue = queryAllBy(instance);\n const findByA11yValue = findBy(instance);\n const findAllByA11yValue = findAllBy(instance);\n\n return {\n getByA11yValue,\n getAllByA11yValue,\n queryByA11yValue,\n queryAllByA11yValue,\n findByA11yValue,\n findAllByA11yValue,\n\n getByAccessibilityValue: getByA11yValue,\n getAllByAccessibilityValue: getAllByA11yValue,\n queryByAccessibilityValue: queryByA11yValue,\n queryAllByAccessibilityValue: queryAllByA11yValue,\n findByAccessibilityValue: findByA11yValue,\n findAllByAccessibilityValue: findAllByA11yValue,\n };\n};\n"],"file":"a11yValue.js"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { ReactTestInstance } from 'react-test-renderer';
|
|
2
|
+
import { TextMatch } from '../matches';
|
|
3
|
+
import type { FindAllByQuery, FindByQuery, GetAllByQuery, GetByQuery, QueryAllByQuery, QueryByQuery } from './makeQueries';
|
|
4
|
+
export declare type ByHintTextQueries = {
|
|
5
|
+
getByHintText: GetByQuery<TextMatch>;
|
|
6
|
+
getAllByHintText: GetAllByQuery<TextMatch>;
|
|
7
|
+
queryByHintText: QueryByQuery<TextMatch>;
|
|
8
|
+
queryAllByHintText: QueryAllByQuery<TextMatch>;
|
|
9
|
+
findByHintText: FindByQuery<TextMatch>;
|
|
10
|
+
findAllByHintText: FindAllByQuery<TextMatch>;
|
|
11
|
+
getByA11yHint: GetByQuery<TextMatch>;
|
|
12
|
+
getAllByA11yHint: GetAllByQuery<TextMatch>;
|
|
13
|
+
queryByA11yHint: QueryByQuery<TextMatch>;
|
|
14
|
+
queryAllByA11yHint: QueryAllByQuery<TextMatch>;
|
|
15
|
+
findByA11yHint: FindByQuery<TextMatch>;
|
|
16
|
+
findAllByA11yHint: FindAllByQuery<TextMatch>;
|
|
17
|
+
getByAccessibilityHint: GetByQuery<TextMatch>;
|
|
18
|
+
getAllByAccessibilityHint: GetAllByQuery<TextMatch>;
|
|
19
|
+
queryByAccessibilityHint: QueryByQuery<TextMatch>;
|
|
20
|
+
queryAllByAccessibilityHint: QueryAllByQuery<TextMatch>;
|
|
21
|
+
findByAccessibilityHint: FindByQuery<TextMatch>;
|
|
22
|
+
findAllByAccessibilityHint: FindAllByQuery<TextMatch>;
|
|
23
|
+
};
|
|
24
|
+
export declare const bindByHintTextQueries: (instance: ReactTestInstance) => ByHintTextQueries;
|