@testing-library/react-native 11.4.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/README.md +3 -3
- package/build/act.d.ts +3 -1
- package/build/act.js +1 -13
- package/build/act.js.map +1 -1
- package/build/cleanup.d.ts +1 -1
- package/build/config.d.ts +31 -2
- package/build/config.js +28 -3
- package/build/config.js.map +1 -1
- package/build/fireEvent.js +3 -3
- package/build/fireEvent.js.map +1 -1
- package/build/flushMicroTasks.d.ts +1 -1
- package/build/helpers/accessiblity.d.ts +11 -4
- package/build/helpers/accessiblity.js +29 -9
- package/build/helpers/accessiblity.js.map +1 -1
- package/build/helpers/debugDeep.d.ts +1 -1
- package/build/helpers/findAll.d.ts +10 -0
- package/build/helpers/findAll.js +44 -0
- package/build/helpers/findAll.js.map +1 -0
- package/build/helpers/format.d.ts +2 -2
- package/build/helpers/getTextContent.d.ts +2 -0
- package/build/helpers/getTextContent.js +20 -0
- package/build/helpers/getTextContent.js.map +1 -0
- package/build/helpers/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/accessibilityValue.d.ts +9 -0
- package/build/helpers/matchers/accessibilityValue.js +12 -0
- package/build/helpers/matchers/accessibilityValue.js.map +1 -0
- package/build/helpers/matchers/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 +10 -0
- package/build/helpers/matchers/matchTextContent.js +24 -0
- package/build/helpers/matchers/matchTextContent.js.map +1 -0
- package/build/helpers/timers.d.ts +0 -2
- package/build/helpers/timers.js.map +1 -1
- package/build/index.flow.js +123 -54
- package/build/matches.d.ts +7 -3
- package/build/matches.js.map +1 -1
- package/build/pure.d.ts +12 -23
- package/build/pure.js +8 -2
- package/build/pure.js.map +1 -1
- package/build/queries/a11yState.d.ts +15 -14
- package/build/queries/a11yState.js +3 -2
- package/build/queries/a11yState.js.map +1 -1
- package/build/queries/a11yValue.d.ts +15 -20
- package/build/queries/a11yValue.js +16 -5
- package/build/queries/a11yValue.js.map +1 -1
- package/build/queries/displayValue.d.ts +11 -9
- package/build/queries/displayValue.js +7 -2
- package/build/queries/displayValue.js.map +1 -1
- package/build/queries/hintText.d.ts +23 -21
- package/build/queries/hintText.js +2 -1
- package/build/queries/hintText.js.map +1 -1
- package/build/queries/labelText.d.ts +11 -9
- package/build/queries/labelText.js +7 -11
- package/build/queries/labelText.js.map +1 -1
- package/build/queries/makeQueries.d.ts +8 -8
- package/build/queries/options.d.ts +11 -0
- package/build/queries/options.js +2 -0
- package/build/queries/options.js.map +1 -0
- package/build/queries/placeholderText.d.ts +11 -9
- package/build/queries/placeholderText.js +8 -3
- package/build/queries/placeholderText.js.map +1 -1
- package/build/queries/role.d.ts +7 -4
- package/build/queries/role.js +22 -11
- package/build/queries/role.js.map +1 -1
- package/build/queries/testId.d.ts +11 -9
- package/build/queries/testId.js +2 -2
- package/build/queries/testId.js.map +1 -1
- package/build/queries/text.d.ts +11 -13
- package/build/queries/text.js +24 -51
- package/build/queries/text.js.map +1 -1
- package/build/queries/unsafeProps.d.ts +1 -1
- package/build/queries/unsafeType.d.ts +1 -1
- package/build/render.d.ts +92 -146
- package/build/renderHook.d.ts +2 -2
- package/build/waitFor.d.ts +1 -1
- package/build/within.d.ts +90 -144
- package/package.json +17 -18
- package/typings/index.flow.js +123 -54
|
@@ -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"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { ReactTestInstance } from 'react-test-renderer';
|
|
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
|
+
*/
|
|
10
|
+
export declare function matchTextContent(node: ReactTestInstance, text: TextMatch, options?: TextMatchOptions): boolean;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.matchTextContent = matchTextContent;
|
|
7
|
+
var _matches = require("../../matches");
|
|
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
|
+
*/
|
|
16
|
+
function matchTextContent(node, text, options = {}) {
|
|
17
|
+
const textContent = (0, _getTextContent.getTextContent)(node);
|
|
18
|
+
const {
|
|
19
|
+
exact,
|
|
20
|
+
normalizer
|
|
21
|
+
} = options;
|
|
22
|
+
return (0, _matches.matches)(text, textContent, normalizer, exact);
|
|
23
|
+
}
|
|
24
|
+
//# sourceMappingURL=matchTextContent.js.map
|
|
@@ -0,0 +1 @@
|
|
|
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;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"timers.js","names":["globalObj","window","global","runWithRealTimers","callback","fakeTimersType","getJestFakeTimersType","jest","useRealTimers","callbackReturnValue","fakeTimersConfig","getFakeTimersConfigFromType","useFakeTimers","setTimeout","process","env","RNTL_SKIP_AUTO_DETECT_FAKE_TIMERS","_isMockFunction","clock","getRealSystemTime","type","legacyFakeTimers","jestFakeTimersAreEnabled","Boolean","setImmediatePolyfill","fn","bindTimeFunctions","clearTimeoutFn","clearTimeout","setImmediateFn","setImmediate","setTimeoutFn"],"sources":["../../src/helpers/timers.ts"],"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 process.env.RNTL_SKIP_AUTO_DETECT_FAKE_TIMERS\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"],"mappings":";;;;;;;;AAAA;AACA;AACA,MAAMA,SAAS,GAAG,OAAOC,MAAM,KAAK,WAAW,GAAGC,MAAM,GAAGD,MAAM;AAIjE;AACA,SAASE,iBAAiB,CAAIC,QAAiB,EAAK;EAClD,MAAMC,cAAc,GAAGC,qBAAqB,EAAE;EAC9C,IAAID,cAAc,EAAE;IAClBE,IAAI,CAACC,aAAa,EAAE;EACtB;EAEA,MAAMC,mBAAmB,GAAGL,QAAQ,EAAE;EAEtC,IAAIC,cAAc,EAAE;IAClB,MAAMK,gBAAgB,GAAGC,2BAA2B,CAACN,cAAc,CAAC;IACpEE,IAAI,CAACK,aAAa,CAACF,gBAAgB,CAAC;EACtC;EAEA,OAAOD,mBAAmB;AAC5B;AAEA,SAASH,qBAAqB,GAA2B;EACvD;EACA,IACE,OAAOC,IAAI,KAAK,WAAW,IAC3B,OAAOP,SAAS,CAACa,UAAU,KAAK,WAAW,IAC3CC,OAAO,CAACC,GAAG,CAACC,iCAAiC,EAC7C;IACA,OAAO,IAAI;EACb;EAEA;EACE;EACA,OAAOhB,SAAS,CAACa,UAAU,CAACI,eAAe,KAAK,WAAW;EAC3D;EACAjB,SAAS,CAACa,UAAU,CAACI,eAAe,EACpC;IACA,OAAO,QAAQ;EACjB;EAEA;EACE;EACA,OAAOjB,SAAS,CAACa,UAAU,CAACK,KAAK,KAAK,WAAW,IACjD,OAAOX,IAAI,CAACY,iBAAiB,KAAK,WAAW,EAC7C;IACA,IAAI;MACF;MACAZ,IAAI,CAACY,iBAAiB,EAAE;MACxB,OAAO,QAAQ;IACjB,CAAC,CAAC,MAAM;MACN;
|
|
1
|
+
{"version":3,"file":"timers.js","names":["globalObj","window","global","runWithRealTimers","callback","fakeTimersType","getJestFakeTimersType","jest","useRealTimers","callbackReturnValue","fakeTimersConfig","getFakeTimersConfigFromType","useFakeTimers","setTimeout","process","env","RNTL_SKIP_AUTO_DETECT_FAKE_TIMERS","_isMockFunction","clock","getRealSystemTime","type","legacyFakeTimers","jestFakeTimersAreEnabled","Boolean","setImmediatePolyfill","fn","bindTimeFunctions","clearTimeoutFn","clearTimeout","setImmediateFn","setImmediate","setTimeoutFn"],"sources":["../../src/helpers/timers.ts"],"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 process.env.RNTL_SKIP_AUTO_DETECT_FAKE_TIMERS\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"],"mappings":";;;;;;;;AAAA;AACA;AACA,MAAMA,SAAS,GAAG,OAAOC,MAAM,KAAK,WAAW,GAAGC,MAAM,GAAGD,MAAM;AAIjE;AACA,SAASE,iBAAiB,CAAIC,QAAiB,EAAK;EAClD,MAAMC,cAAc,GAAGC,qBAAqB,EAAE;EAC9C,IAAID,cAAc,EAAE;IAClBE,IAAI,CAACC,aAAa,EAAE;EACtB;EAEA,MAAMC,mBAAmB,GAAGL,QAAQ,EAAE;EAEtC,IAAIC,cAAc,EAAE;IAClB,MAAMK,gBAAgB,GAAGC,2BAA2B,CAACN,cAAc,CAAC;IACpEE,IAAI,CAACK,aAAa,CAACF,gBAAgB,CAAC;EACtC;EAEA,OAAOD,mBAAmB;AAC5B;AAEA,SAASH,qBAAqB,GAA2B;EACvD;EACA,IACE,OAAOC,IAAI,KAAK,WAAW,IAC3B,OAAOP,SAAS,CAACa,UAAU,KAAK,WAAW,IAC3CC,OAAO,CAACC,GAAG,CAACC,iCAAiC,EAC7C;IACA,OAAO,IAAI;EACb;EAEA;EACE;EACA,OAAOhB,SAAS,CAACa,UAAU,CAACI,eAAe,KAAK,WAAW;EAC3D;EACAjB,SAAS,CAACa,UAAU,CAACI,eAAe,EACpC;IACA,OAAO,QAAQ;EACjB;EAEA;EACE;EACA,OAAOjB,SAAS,CAACa,UAAU,CAACK,KAAK,KAAK,WAAW,IACjD,OAAOX,IAAI,CAACY,iBAAiB,KAAK,WAAW,EAC7C;IACA,IAAI;MACF;MACAZ,IAAI,CAACY,iBAAiB,EAAE;MACxB,OAAO,QAAQ;IACjB,CAAC,CAAC,MAAM;MACN;IAAA;EAEJ;EAEA,OAAO,IAAI;AACb;AAEA,SAASR,2BAA2B,CAACS,IAAqB,EAAE;EAC1D,OAAOA,IAAI,KAAK,QAAQ,GACpB;IAAEC,gBAAgB,EAAE;EAAK,CAAC,GAC1B;IAAEA,gBAAgB,EAAE;EAAM,CAAC;AACjC;AAEA,MAAMC,wBAAwB,GAAG,MAC/BC,OAAO,CAACjB,qBAAqB,EAAE,CAAC;;AAElC;AAAA;AACA,SAASkB,oBAAoB,CAACC,EAAY,EAAE;EAC1C,OAAOzB,SAAS,CAACa,UAAU,CAACY,EAAE,EAAE,CAAC,CAAC;AACpC;AAQA,SAASC,iBAAiB,GAAsB;EAC9C,OAAO;IACLC,cAAc,EAAE3B,SAAS,CAAC4B,YAAY;IACtCC,cAAc,EAAE7B,SAAS,CAAC8B,YAAY,IAAIN,oBAAoB;IAC9DO,YAAY,EAAE/B,SAAS,CAACa;EAC1B,CAAC;AACH;AAEA,MAAM;EAAEc,cAAc;EAAEE,cAAc;EAAEE;AAAa,CAAC,GAAG5B,iBAAiB,CACxEuB,iBAAiB,CACG;AAAC;AAAA;AAAA"}
|
package/build/index.flow.js
CHANGED
|
@@ -8,6 +8,11 @@ type QueryAllReturn = Array<ReactTestInstance> | [];
|
|
|
8
8
|
type FindReturn = Promise<ReactTestInstance>;
|
|
9
9
|
type FindAllReturn = Promise<ReactTestInstance[]>;
|
|
10
10
|
|
|
11
|
+
type CommonQueryOptions = {
|
|
12
|
+
includeHiddenElements?: boolean,
|
|
13
|
+
hidden?: boolean,
|
|
14
|
+
};
|
|
15
|
+
|
|
11
16
|
type TextMatch = string | RegExp;
|
|
12
17
|
|
|
13
18
|
declare type NormalizerFn = (textToNormalize: string) => string;
|
|
@@ -60,7 +65,7 @@ declare type A11yValue = {
|
|
|
60
65
|
min?: number,
|
|
61
66
|
max?: number,
|
|
62
67
|
now?: number,
|
|
63
|
-
text?:
|
|
68
|
+
text?: TextMatch,
|
|
64
69
|
};
|
|
65
70
|
|
|
66
71
|
type WaitForOptions = {
|
|
@@ -74,109 +79,123 @@ type WaitForFunction = <T = any>(
|
|
|
74
79
|
options?: WaitForOptions
|
|
75
80
|
) => Promise<T>;
|
|
76
81
|
|
|
82
|
+
type ByTextOptions = CommonQueryOptions & TextMatchOptions;
|
|
83
|
+
|
|
77
84
|
interface ByTextQueries {
|
|
78
|
-
getByText: (text: TextMatch, options?:
|
|
85
|
+
getByText: (text: TextMatch, options?: ByTextOptions) => ReactTestInstance;
|
|
79
86
|
getAllByText: (
|
|
80
87
|
text: TextMatch,
|
|
81
|
-
options?:
|
|
88
|
+
options?: ByTextOptions
|
|
82
89
|
) => Array<ReactTestInstance>;
|
|
83
90
|
queryByText: (
|
|
84
91
|
name: TextMatch,
|
|
85
|
-
options?:
|
|
92
|
+
options?: ByTextOptions
|
|
86
93
|
) => ReactTestInstance | null;
|
|
87
94
|
queryAllByText: (
|
|
88
95
|
text: TextMatch,
|
|
89
|
-
options?:
|
|
96
|
+
options?: ByTextOptions
|
|
90
97
|
) => Array<ReactTestInstance> | [];
|
|
91
98
|
findByText: (
|
|
92
99
|
text: TextMatch,
|
|
93
|
-
queryOptions?:
|
|
100
|
+
queryOptions?: ByTextOptions,
|
|
94
101
|
waitForOptions?: WaitForOptions
|
|
95
102
|
) => FindReturn;
|
|
96
103
|
findAllByText: (
|
|
97
104
|
text: TextMatch,
|
|
98
|
-
queryOptions?:
|
|
105
|
+
queryOptions?: ByTextOptions,
|
|
99
106
|
waitForOptions?: WaitForOptions
|
|
100
107
|
) => FindAllReturn;
|
|
101
108
|
}
|
|
102
109
|
|
|
110
|
+
type ByTestIdOptions = CommonQueryOptions & TextMatchOptions;
|
|
111
|
+
|
|
103
112
|
interface ByTestIdQueries {
|
|
104
113
|
getByTestId: (
|
|
105
114
|
testID: TextMatch,
|
|
106
|
-
options?:
|
|
115
|
+
options?: ByTestIdOptions
|
|
107
116
|
) => ReactTestInstance;
|
|
108
117
|
getAllByTestId: (
|
|
109
118
|
testID: TextMatch,
|
|
110
|
-
options?:
|
|
119
|
+
options?: ByTestIdOptions
|
|
111
120
|
) => Array<ReactTestInstance>;
|
|
112
|
-
queryByTestId: (
|
|
113
|
-
|
|
121
|
+
queryByTestId: (
|
|
122
|
+
testID: TextMatch,
|
|
123
|
+
options?: ByTestIdOptions
|
|
124
|
+
) => ReactTestInstance | null;
|
|
125
|
+
queryAllByTestId: (
|
|
126
|
+
testID: TextMatch,
|
|
127
|
+
options?: ByTestIdOptions
|
|
128
|
+
) => Array<ReactTestInstance> | [];
|
|
114
129
|
findByTestId: (
|
|
115
130
|
testID: TextMatch,
|
|
116
|
-
queryOptions?:
|
|
131
|
+
queryOptions?: ByTestIdOptions,
|
|
117
132
|
waitForOptions?: WaitForOptions
|
|
118
133
|
) => FindReturn;
|
|
119
134
|
findAllByTestId: (
|
|
120
135
|
testID: TextMatch,
|
|
121
|
-
queryOptions?:
|
|
136
|
+
queryOptions?: ByTestIdOptions,
|
|
122
137
|
waitForOptions?: WaitForOptions
|
|
123
138
|
) => FindAllReturn;
|
|
124
139
|
}
|
|
125
140
|
|
|
141
|
+
type ByDisplayValueOptions = CommonQueryOptions & TextMatchOptions;
|
|
142
|
+
|
|
126
143
|
interface ByDisplayValueQueries {
|
|
127
144
|
getByDisplayValue: (
|
|
128
145
|
value: TextMatch,
|
|
129
|
-
options?:
|
|
146
|
+
options?: ByDisplayValueOptions
|
|
130
147
|
) => ReactTestInstance;
|
|
131
148
|
getAllByDisplayValue: (
|
|
132
149
|
value: TextMatch,
|
|
133
|
-
options?:
|
|
150
|
+
options?: ByDisplayValueOptions
|
|
134
151
|
) => Array<ReactTestInstance>;
|
|
135
152
|
queryByDisplayValue: (
|
|
136
153
|
value: TextMatch,
|
|
137
|
-
options?:
|
|
154
|
+
options?: ByDisplayValueOptions
|
|
138
155
|
) => ReactTestInstance | null;
|
|
139
156
|
queryAllByDisplayValue: (
|
|
140
157
|
value: TextMatch,
|
|
141
|
-
options?:
|
|
158
|
+
options?: ByDisplayValueOptions
|
|
142
159
|
) => Array<ReactTestInstance> | [];
|
|
143
160
|
findByDisplayValue: (
|
|
144
161
|
value: TextMatch,
|
|
145
|
-
queryOptions?:
|
|
162
|
+
queryOptions?: ByDisplayValueOptions,
|
|
146
163
|
waitForOptions?: WaitForOptions
|
|
147
164
|
) => FindReturn;
|
|
148
165
|
findAllByDisplayValue: (
|
|
149
166
|
value: TextMatch,
|
|
150
|
-
queryOptions?:
|
|
167
|
+
queryOptions?: ByDisplayValueOptions,
|
|
151
168
|
waitForOptions?: WaitForOptions
|
|
152
169
|
) => FindAllReturn;
|
|
153
170
|
}
|
|
154
171
|
|
|
172
|
+
type ByPlaceholderTextOptions = CommonQueryOptions & TextMatchOptions;
|
|
173
|
+
|
|
155
174
|
interface ByPlaceholderTextQueries {
|
|
156
175
|
getByPlaceholderText: (
|
|
157
176
|
placeholder: TextMatch,
|
|
158
|
-
options?:
|
|
177
|
+
options?: ByPlaceholderTextOptions
|
|
159
178
|
) => ReactTestInstance;
|
|
160
179
|
getAllByPlaceholderText: (
|
|
161
180
|
placeholder: TextMatch,
|
|
162
|
-
options?:
|
|
181
|
+
options?: ByPlaceholderTextOptions
|
|
163
182
|
) => Array<ReactTestInstance>;
|
|
164
183
|
queryByPlaceholderText: (
|
|
165
184
|
placeholder: TextMatch,
|
|
166
|
-
options?:
|
|
185
|
+
options?: ByPlaceholderTextOptions
|
|
167
186
|
) => ReactTestInstance | null;
|
|
168
187
|
queryAllByPlaceholderText: (
|
|
169
188
|
placeholder: TextMatch,
|
|
170
|
-
options?:
|
|
189
|
+
options?: ByPlaceholderTextOptions
|
|
171
190
|
) => Array<ReactTestInstance> | [];
|
|
172
191
|
findByPlaceholderText: (
|
|
173
192
|
placeholder: TextMatch,
|
|
174
|
-
queryOptions?:
|
|
193
|
+
queryOptions?: ByPlaceholderTextOptions,
|
|
175
194
|
waitForOptions?: WaitForOptions
|
|
176
195
|
) => FindReturn;
|
|
177
196
|
findAllByPlaceholderText: (
|
|
178
197
|
placeholder: TextMatch,
|
|
179
|
-
queryOptions?:
|
|
198
|
+
queryOptions?: ByPlaceholderTextOptions,
|
|
180
199
|
waitForOptions?: WaitForOptions
|
|
181
200
|
) => FindAllReturn;
|
|
182
201
|
}
|
|
@@ -203,82 +222,89 @@ interface UnsafeByPropsQueries {
|
|
|
203
222
|
| [];
|
|
204
223
|
}
|
|
205
224
|
|
|
206
|
-
type ByRoleOptions = {
|
|
225
|
+
type ByRoleOptions = CommonQueryOptions & {
|
|
207
226
|
...A11yState,
|
|
208
227
|
name?: string,
|
|
228
|
+
value?: A11yValue,
|
|
209
229
|
};
|
|
210
230
|
|
|
231
|
+
type ByLabelTextOptions = CommonQueryOptions & TextMatchOptions;
|
|
232
|
+
type ByHintTextOptions = CommonQueryOptions & TextMatchOptions;
|
|
233
|
+
|
|
211
234
|
interface A11yAPI {
|
|
212
235
|
// Label
|
|
213
|
-
getByLabelText: (
|
|
236
|
+
getByLabelText: (
|
|
237
|
+
matcher: TextMatch,
|
|
238
|
+
options?: ByLabelTextOptions
|
|
239
|
+
) => GetReturn;
|
|
214
240
|
getAllByLabelText: (
|
|
215
241
|
matcher: TextMatch,
|
|
216
|
-
options?:
|
|
242
|
+
options?: ByLabelTextOptions
|
|
217
243
|
) => GetAllReturn;
|
|
218
244
|
queryByLabelText: (
|
|
219
245
|
matcher: TextMatch,
|
|
220
|
-
options?:
|
|
246
|
+
options?: ByLabelTextOptions
|
|
221
247
|
) => QueryReturn;
|
|
222
248
|
queryAllByLabelText: (
|
|
223
249
|
matcher: TextMatch,
|
|
224
|
-
options?:
|
|
250
|
+
options?: ByLabelTextOptions
|
|
225
251
|
) => QueryAllReturn;
|
|
226
252
|
findByLabelText: (
|
|
227
253
|
matcher: TextMatch,
|
|
228
|
-
queryOptions?:
|
|
254
|
+
queryOptions?: ByLabelTextOptions,
|
|
229
255
|
waitForOptions?: WaitForOptions
|
|
230
256
|
) => FindReturn;
|
|
231
257
|
findAllByLabelText: (
|
|
232
258
|
matcher: TextMatch,
|
|
233
|
-
queryOptions?:
|
|
259
|
+
queryOptions?: ByLabelTextOptions,
|
|
234
260
|
waitForOptions?: WaitForOptions
|
|
235
261
|
) => FindAllReturn;
|
|
236
262
|
|
|
237
263
|
// Hint
|
|
238
|
-
getByA11yHint: (matcher: TextMatch, options?:
|
|
239
|
-
getByHintText: (matcher: TextMatch, options?:
|
|
264
|
+
getByA11yHint: (matcher: TextMatch, options?: ByHintTextOptions) => GetReturn;
|
|
265
|
+
getByHintText: (matcher: TextMatch, options?: ByHintTextOptions) => GetReturn;
|
|
240
266
|
getAllByA11yHint: (
|
|
241
267
|
matcher: TextMatch,
|
|
242
|
-
options?:
|
|
268
|
+
options?: ByHintTextOptions
|
|
243
269
|
) => GetAllReturn;
|
|
244
270
|
getAllByHintText: (
|
|
245
271
|
matcher: TextMatch,
|
|
246
|
-
options?:
|
|
272
|
+
options?: ByHintTextOptions
|
|
247
273
|
) => GetAllReturn;
|
|
248
274
|
queryByA11yHint: (
|
|
249
275
|
matcher: TextMatch,
|
|
250
|
-
options?:
|
|
276
|
+
options?: ByHintTextOptions
|
|
251
277
|
) => QueryReturn;
|
|
252
278
|
queryByHintText: (
|
|
253
279
|
matcher: TextMatch,
|
|
254
|
-
options?:
|
|
280
|
+
options?: ByHintTextOptions
|
|
255
281
|
) => QueryReturn;
|
|
256
282
|
queryAllByA11yHint: (
|
|
257
283
|
matcher: TextMatch,
|
|
258
|
-
options?:
|
|
284
|
+
options?: ByHintTextOptions
|
|
259
285
|
) => QueryAllReturn;
|
|
260
286
|
queryAllByHintText: (
|
|
261
287
|
matcher: TextMatch,
|
|
262
|
-
options?:
|
|
288
|
+
options?: ByHintTextOptions
|
|
263
289
|
) => QueryAllReturn;
|
|
264
290
|
findByA11yHint: (
|
|
265
291
|
matcher: TextMatch,
|
|
266
|
-
queryOptions?:
|
|
292
|
+
queryOptions?: ByHintTextOptions,
|
|
267
293
|
waitForOptions?: WaitForOptions
|
|
268
294
|
) => FindReturn;
|
|
269
295
|
findByHintText: (
|
|
270
296
|
matcher: TextMatch,
|
|
271
|
-
queryOptions?:
|
|
297
|
+
queryOptions?: ByHintTextOptions,
|
|
272
298
|
waitForOptions?: WaitForOptions
|
|
273
299
|
) => FindReturn;
|
|
274
300
|
findAllByA11yHint: (
|
|
275
301
|
matcher: TextMatch,
|
|
276
|
-
queryOptions?:
|
|
302
|
+
queryOptions?: ByHintTextOptions,
|
|
277
303
|
waitForOptions?: WaitForOptions
|
|
278
304
|
) => FindAllReturn;
|
|
279
305
|
findAllByHintText: (
|
|
280
306
|
matcher: TextMatch,
|
|
281
|
-
queryOptions?:
|
|
307
|
+
queryOptions?: ByHintTextOptions,
|
|
282
308
|
waitForOptions?: WaitForOptions
|
|
283
309
|
) => FindAllReturn;
|
|
284
310
|
|
|
@@ -308,30 +334,58 @@ interface A11yAPI {
|
|
|
308
334
|
) => FindAllReturn;
|
|
309
335
|
|
|
310
336
|
// State
|
|
311
|
-
getByA11yState: (
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
337
|
+
getByA11yState: (
|
|
338
|
+
matcher: A11yState,
|
|
339
|
+
options?: CommonQueryOptions
|
|
340
|
+
) => GetReturn;
|
|
341
|
+
getAllByA11yState: (
|
|
342
|
+
matcher: A11yState,
|
|
343
|
+
options?: CommonQueryOptions
|
|
344
|
+
) => GetAllReturn;
|
|
345
|
+
queryByA11yState: (
|
|
346
|
+
matcher: A11yState,
|
|
347
|
+
options?: CommonQueryOptions
|
|
348
|
+
) => QueryReturn;
|
|
349
|
+
queryAllByA11yState: (
|
|
350
|
+
matcher: A11yState,
|
|
351
|
+
options?: CommonQueryOptions
|
|
352
|
+
) => QueryAllReturn;
|
|
315
353
|
findByA11yState: (
|
|
316
354
|
matcher: A11yState,
|
|
355
|
+
queryOptions?: CommonQueryOptions,
|
|
317
356
|
waitForOptions?: WaitForOptions
|
|
318
357
|
) => FindReturn;
|
|
319
358
|
findAllByA11yState: (
|
|
320
359
|
matcher: A11yState,
|
|
360
|
+
queryOptions?: CommonQueryOptions,
|
|
321
361
|
waitForOptions?: WaitForOptions
|
|
322
362
|
) => FindAllReturn;
|
|
323
363
|
|
|
324
364
|
// Value
|
|
325
|
-
getByA11yValue: (
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
365
|
+
getByA11yValue: (
|
|
366
|
+
matcher: A11yValue,
|
|
367
|
+
options?: CommonQueryOptions
|
|
368
|
+
) => GetReturn;
|
|
369
|
+
getAllByA11yValue: (
|
|
370
|
+
matcher: A11yValue,
|
|
371
|
+
options?: CommonQueryOptions
|
|
372
|
+
) => GetAllReturn;
|
|
373
|
+
queryByA11yValue: (
|
|
374
|
+
matcher: A11yValue,
|
|
375
|
+
options?: CommonQueryOptions
|
|
376
|
+
) => QueryReturn;
|
|
377
|
+
queryAllByA11yValue: (
|
|
378
|
+
matcher: A11yValue,
|
|
379
|
+
options?: CommonQueryOptions
|
|
380
|
+
) => QueryAllReturn;
|
|
329
381
|
findByA11yValue: (
|
|
330
382
|
matcher: A11yValue,
|
|
383
|
+
queryOptions?: CommonQueryOptions,
|
|
331
384
|
waitForOptions?: WaitForOptions
|
|
332
385
|
) => FindReturn;
|
|
333
386
|
findAllByA11yValue: (
|
|
334
387
|
matcher: A11yValue,
|
|
388
|
+
queryOptions?: CommonQueryOptions,
|
|
335
389
|
waitForOptions?: WaitForOptions
|
|
336
390
|
) => FindAllReturn;
|
|
337
391
|
}
|
|
@@ -414,22 +468,37 @@ declare module '@testing-library/react-native' {
|
|
|
414
468
|
|
|
415
469
|
declare interface Config {
|
|
416
470
|
asyncUtilTimeout: number;
|
|
471
|
+
defaultIncludeHiddenElements: boolean;
|
|
417
472
|
defaultDebugOptions?: $Shape<DebugOptions>;
|
|
418
473
|
}
|
|
419
474
|
|
|
420
|
-
declare
|
|
475
|
+
declare interface ConfigAliasOptions {
|
|
476
|
+
/** Alias to `defaultIncludeHiddenElements` for RTL compatibility */
|
|
477
|
+
defaultHidden: boolean;
|
|
478
|
+
}
|
|
479
|
+
|
|
480
|
+
declare export var configure: (
|
|
481
|
+
options: $Shape<Config & ConfigAliasOptions>
|
|
482
|
+
) => void;
|
|
421
483
|
declare export var resetToDefaults: () => void;
|
|
422
484
|
|
|
423
485
|
declare export var act: (callback: () => void) => Thenable;
|
|
424
486
|
declare export var within: (instance: ReactTestInstance) => Queries;
|
|
425
487
|
declare export var getQueriesForElement: (
|
|
426
|
-
|
|
488
|
+
element: ReactTestInstance
|
|
427
489
|
) => Queries;
|
|
428
490
|
|
|
429
491
|
declare export var getDefaultNormalizer: (
|
|
430
492
|
normalizerConfig?: NormalizerConfig
|
|
431
493
|
) => NormalizerFn;
|
|
432
494
|
|
|
495
|
+
declare export var isHiddenFromAccessibility: (
|
|
496
|
+
element: ReactTestInstance | null
|
|
497
|
+
) => boolean;
|
|
498
|
+
declare export var isInaccessible: (
|
|
499
|
+
element: ReactTestInstance | null
|
|
500
|
+
) => boolean;
|
|
501
|
+
|
|
433
502
|
declare type RenderHookResult<Result, Props> = {
|
|
434
503
|
rerender: (props: Props) => void,
|
|
435
504
|
result: { current: Result },
|
package/build/matches.d.ts
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
|
-
export
|
|
2
|
-
export
|
|
1
|
+
export type NormalizerFn = (textToNormalize: string) => string;
|
|
2
|
+
export type TextMatch = string | RegExp;
|
|
3
|
+
export type TextMatchOptions = {
|
|
4
|
+
exact?: boolean;
|
|
5
|
+
normalizer?: NormalizerFn;
|
|
6
|
+
};
|
|
3
7
|
export declare function matches(matcher: TextMatch, text: string, normalizer?: NormalizerFn, exact?: boolean): boolean;
|
|
4
|
-
|
|
8
|
+
type NormalizerConfig = {
|
|
5
9
|
trim?: boolean;
|
|
6
10
|
collapseWhitespace?: boolean;
|
|
7
11
|
};
|
package/build/matches.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"matches.js","names":["matches","matcher","text","normalizer","getDefaultNormalizer","exact","normalizedText","normalizedMatcher","toLowerCase","includes","lastIndex","test","trim","collapseWhitespace","replace"],"sources":["../src/matches.ts"],"sourcesContent":["export type NormalizerFn = (textToNormalize: string) => string;\nexport type TextMatch = string | RegExp;\n\nexport function matches(\n matcher: TextMatch,\n text: string,\n normalizer: NormalizerFn = getDefaultNormalizer(),\n exact: boolean = true\n): boolean {\n if (typeof text !== 'string') {\n return false;\n }\n\n const normalizedText = normalizer(text);\n if (typeof matcher === 'string') {\n const normalizedMatcher = normalizer(matcher);\n return exact\n ? normalizedText === normalizedMatcher\n : normalizedText.toLowerCase().includes(normalizedMatcher.toLowerCase());\n } else {\n // Reset state for global regexes: https://stackoverflow.com/a/1520839/484499\n matcher.lastIndex = 0;\n return matcher.test(normalizedText);\n }\n}\n\ntype NormalizerConfig = {\n trim?: boolean;\n collapseWhitespace?: boolean;\n};\n\nexport function getDefaultNormalizer({\n trim = true,\n collapseWhitespace = true,\n}: NormalizerConfig = {}): NormalizerFn {\n return (text: string) => {\n let normalizedText = text;\n normalizedText = trim ? normalizedText.trim() : normalizedText;\n normalizedText = collapseWhitespace\n ? normalizedText.replace(/\\s+/g, ' ')\n : normalizedText;\n return normalizedText;\n };\n}\n"],"mappings":";;;;;;;
|
|
1
|
+
{"version":3,"file":"matches.js","names":["matches","matcher","text","normalizer","getDefaultNormalizer","exact","normalizedText","normalizedMatcher","toLowerCase","includes","lastIndex","test","trim","collapseWhitespace","replace"],"sources":["../src/matches.ts"],"sourcesContent":["export type NormalizerFn = (textToNormalize: string) => string;\n\nexport type TextMatch = string | RegExp;\nexport type TextMatchOptions = {\n exact?: boolean;\n normalizer?: NormalizerFn;\n};\n\nexport function matches(\n matcher: TextMatch,\n text: string,\n normalizer: NormalizerFn = getDefaultNormalizer(),\n exact: boolean = true\n): boolean {\n if (typeof text !== 'string') {\n return false;\n }\n\n const normalizedText = normalizer(text);\n if (typeof matcher === 'string') {\n const normalizedMatcher = normalizer(matcher);\n return exact\n ? normalizedText === normalizedMatcher\n : normalizedText.toLowerCase().includes(normalizedMatcher.toLowerCase());\n } else {\n // Reset state for global regexes: https://stackoverflow.com/a/1520839/484499\n matcher.lastIndex = 0;\n return matcher.test(normalizedText);\n }\n}\n\ntype NormalizerConfig = {\n trim?: boolean;\n collapseWhitespace?: boolean;\n};\n\nexport function getDefaultNormalizer({\n trim = true,\n collapseWhitespace = true,\n}: NormalizerConfig = {}): NormalizerFn {\n return (text: string) => {\n let normalizedText = text;\n normalizedText = trim ? normalizedText.trim() : normalizedText;\n normalizedText = collapseWhitespace\n ? normalizedText.replace(/\\s+/g, ' ')\n : normalizedText;\n return normalizedText;\n };\n}\n"],"mappings":";;;;;;;AAQO,SAASA,OAAO,CACrBC,OAAkB,EAClBC,IAAY,EACZC,UAAwB,GAAGC,oBAAoB,EAAE,EACjDC,KAAc,GAAG,IAAI,EACZ;EACT,IAAI,OAAOH,IAAI,KAAK,QAAQ,EAAE;IAC5B,OAAO,KAAK;EACd;EAEA,MAAMI,cAAc,GAAGH,UAAU,CAACD,IAAI,CAAC;EACvC,IAAI,OAAOD,OAAO,KAAK,QAAQ,EAAE;IAC/B,MAAMM,iBAAiB,GAAGJ,UAAU,CAACF,OAAO,CAAC;IAC7C,OAAOI,KAAK,GACRC,cAAc,KAAKC,iBAAiB,GACpCD,cAAc,CAACE,WAAW,EAAE,CAACC,QAAQ,CAACF,iBAAiB,CAACC,WAAW,EAAE,CAAC;EAC5E,CAAC,MAAM;IACL;IACAP,OAAO,CAACS,SAAS,GAAG,CAAC;IACrB,OAAOT,OAAO,CAACU,IAAI,CAACL,cAAc,CAAC;EACrC;AACF;AAOO,SAASF,oBAAoB,CAAC;EACnCQ,IAAI,GAAG,IAAI;EACXC,kBAAkB,GAAG;AACL,CAAC,GAAG,CAAC,CAAC,EAAgB;EACtC,OAAQX,IAAY,IAAK;IACvB,IAAII,cAAc,GAAGJ,IAAI;IACzBI,cAAc,GAAGM,IAAI,GAAGN,cAAc,CAACM,IAAI,EAAE,GAAGN,cAAc;IAC9DA,cAAc,GAAGO,kBAAkB,GAC/BP,cAAc,CAACQ,OAAO,CAAC,MAAM,EAAE,GAAG,CAAC,GACnCR,cAAc;IAClB,OAAOA,cAAc;EACvB,CAAC;AACH"}
|
package/build/pure.d.ts
CHANGED
|
@@ -1,26 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
1
|
+
export { default as act } from './act';
|
|
2
|
+
export { default as cleanup } from './cleanup';
|
|
3
|
+
export { default as fireEvent } from './fireEvent';
|
|
4
|
+
export { default as render } from './render';
|
|
5
|
+
export { default as waitFor } from './waitFor';
|
|
6
|
+
export { default as waitForElementToBeRemoved } from './waitForElementToBeRemoved';
|
|
7
|
+
export { within, getQueriesForElement } from './within';
|
|
8
|
+
export { configure, resetToDefaults } from './config';
|
|
9
|
+
export { isHiddenFromAccessibility, isInaccessible, } from './helpers/accessiblity';
|
|
10
|
+
export { getDefaultNormalizer } from './matches';
|
|
11
|
+
export { renderHook } from './renderHook';
|
|
12
|
+
export { screen } from './screen';
|
|
12
13
|
export type { RenderOptions, RenderResult, RenderResult as RenderAPI, } from './render';
|
|
13
14
|
export type { RenderHookOptions, RenderHookResult } from './renderHook';
|
|
14
15
|
export type { Config } from './config';
|
|
15
|
-
export { act };
|
|
16
|
-
export { cleanup };
|
|
17
|
-
export { configure, resetToDefaults } from './config';
|
|
18
|
-
export { fireEvent };
|
|
19
|
-
export { render };
|
|
20
|
-
export { waitFor };
|
|
21
|
-
export { waitForElementToBeRemoved };
|
|
22
|
-
export { within, getQueriesForElement };
|
|
23
|
-
export { getDefaultNormalizer };
|
|
24
|
-
export { renderHook };
|
|
25
|
-
export { screen };
|
|
26
|
-
export { isInaccessible };
|
package/build/pure.js
CHANGED
|
@@ -39,6 +39,12 @@ Object.defineProperty(exports, "getQueriesForElement", {
|
|
|
39
39
|
return _within.getQueriesForElement;
|
|
40
40
|
}
|
|
41
41
|
});
|
|
42
|
+
Object.defineProperty(exports, "isHiddenFromAccessibility", {
|
|
43
|
+
enumerable: true,
|
|
44
|
+
get: function () {
|
|
45
|
+
return _accessiblity.isHiddenFromAccessibility;
|
|
46
|
+
}
|
|
47
|
+
});
|
|
42
48
|
Object.defineProperty(exports, "isInaccessible", {
|
|
43
49
|
enumerable: true,
|
|
44
50
|
get: function () {
|
|
@@ -94,10 +100,10 @@ var _render = _interopRequireDefault(require("./render"));
|
|
|
94
100
|
var _waitFor = _interopRequireDefault(require("./waitFor"));
|
|
95
101
|
var _waitForElementToBeRemoved = _interopRequireDefault(require("./waitForElementToBeRemoved"));
|
|
96
102
|
var _within = require("./within");
|
|
103
|
+
var _config = require("./config");
|
|
104
|
+
var _accessiblity = require("./helpers/accessiblity");
|
|
97
105
|
var _matches = require("./matches");
|
|
98
106
|
var _renderHook = require("./renderHook");
|
|
99
107
|
var _screen = require("./screen");
|
|
100
|
-
var _accessiblity = require("./helpers/accessiblity");
|
|
101
|
-
var _config = require("./config");
|
|
102
108
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
103
109
|
//# sourceMappingURL=pure.js.map
|
package/build/pure.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pure.js","names":[],"sources":["../src/pure.ts"],"sourcesContent":["
|
|
1
|
+
{"version":3,"file":"pure.js","names":[],"sources":["../src/pure.ts"],"sourcesContent":["export { default as act } from './act';\nexport { default as cleanup } from './cleanup';\nexport { default as fireEvent } from './fireEvent';\nexport { default as render } from './render';\nexport { default as waitFor } from './waitFor';\nexport { default as waitForElementToBeRemoved } from './waitForElementToBeRemoved';\nexport { within, getQueriesForElement } from './within';\n\nexport { configure, resetToDefaults } from './config';\nexport {\n isHiddenFromAccessibility,\n isInaccessible,\n} from './helpers/accessiblity';\nexport { getDefaultNormalizer } from './matches';\nexport { renderHook } from './renderHook';\nexport { screen } from './screen';\n\nexport type {\n RenderOptions,\n RenderResult,\n RenderResult as RenderAPI,\n} from './render';\nexport type { RenderHookOptions, RenderHookResult } from './renderHook';\nexport type { Config } from './config';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AAIA;AACA;AACA;AAAkC"}
|
|
@@ -1,18 +1,19 @@
|
|
|
1
1
|
import type { ReactTestInstance } from 'react-test-renderer';
|
|
2
|
-
import
|
|
2
|
+
import { AccessibilityState } from 'react-native';
|
|
3
3
|
import type { FindAllByQuery, FindByQuery, GetAllByQuery, GetByQuery, QueryAllByQuery, QueryByQuery } from './makeQueries';
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
4
|
+
import { CommonQueryOptions } from './options';
|
|
5
|
+
export type ByA11yStateQueries = {
|
|
6
|
+
getByA11yState: GetByQuery<AccessibilityState, CommonQueryOptions>;
|
|
7
|
+
getAllByA11yState: GetAllByQuery<AccessibilityState, CommonQueryOptions>;
|
|
8
|
+
queryByA11yState: QueryByQuery<AccessibilityState, CommonQueryOptions>;
|
|
9
|
+
queryAllByA11yState: QueryAllByQuery<AccessibilityState, CommonQueryOptions>;
|
|
10
|
+
findByA11yState: FindByQuery<AccessibilityState, CommonQueryOptions>;
|
|
11
|
+
findAllByA11yState: FindAllByQuery<AccessibilityState, CommonQueryOptions>;
|
|
12
|
+
getByAccessibilityState: GetByQuery<AccessibilityState, CommonQueryOptions>;
|
|
13
|
+
getAllByAccessibilityState: GetAllByQuery<AccessibilityState, CommonQueryOptions>;
|
|
14
|
+
queryByAccessibilityState: QueryByQuery<AccessibilityState, CommonQueryOptions>;
|
|
15
|
+
queryAllByAccessibilityState: QueryAllByQuery<AccessibilityState, CommonQueryOptions>;
|
|
16
|
+
findByAccessibilityState: FindByQuery<AccessibilityState, CommonQueryOptions>;
|
|
17
|
+
findAllByAccessibilityState: FindAllByQuery<AccessibilityState, CommonQueryOptions>;
|
|
17
18
|
};
|
|
18
19
|
export declare const bindByA11yStateQueries: (instance: ReactTestInstance) => ByA11yStateQueries;
|
|
@@ -5,10 +5,11 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.bindByA11yStateQueries = void 0;
|
|
7
7
|
var _accessiblity = require("../helpers/accessiblity");
|
|
8
|
+
var _findAll = require("../helpers/findAll");
|
|
8
9
|
var _accessibilityState = require("../helpers/matchers/accessibilityState");
|
|
9
10
|
var _makeQueries = require("./makeQueries");
|
|
10
|
-
const queryAllByA11yState = instance => function queryAllByA11yStateFn(matcher) {
|
|
11
|
-
return
|
|
11
|
+
const queryAllByA11yState = instance => function queryAllByA11yStateFn(matcher, queryOptions) {
|
|
12
|
+
return (0, _findAll.findAll)(instance, node => typeof node.type === 'string' && (0, _accessibilityState.matchAccessibilityState)(node, matcher), queryOptions);
|
|
12
13
|
};
|
|
13
14
|
const buildErrorMessage = (state = {}) => {
|
|
14
15
|
const errors = [];
|