@testing-library/react-native 14.0.0-alpha.1 → 14.0.0-alpha.3
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 +7 -11
- package/build/act.d.ts +2 -4
- package/build/act.js +4 -5
- package/build/act.js.map +1 -1
- package/build/cleanup.d.ts +3 -1
- package/build/cleanup.js +8 -0
- package/build/cleanup.js.map +1 -1
- package/build/event-handler.d.ts +2 -2
- package/build/event-handler.js +10 -10
- package/build/event-handler.js.map +1 -1
- package/build/fire-event.d.ts +8 -1
- package/build/fire-event.js +44 -28
- package/build/fire-event.js.map +1 -1
- package/build/helpers/accessibility.js +5 -2
- package/build/helpers/accessibility.js.map +1 -1
- package/build/helpers/component-tree.d.ts +8 -8
- package/build/helpers/component-tree.js +19 -16
- package/build/helpers/component-tree.js.map +1 -1
- package/build/helpers/debug.d.ts +1 -1
- package/build/helpers/debug.js +6 -7
- package/build/helpers/debug.js.map +1 -1
- package/build/helpers/find-all.js +7 -27
- package/build/helpers/find-all.js.map +1 -1
- package/build/helpers/format-element.d.ts +3 -3
- package/build/helpers/format-element.js +9 -9
- package/build/helpers/format-element.js.map +1 -1
- package/build/helpers/host-component-names.d.ts +0 -1
- package/build/helpers/host-component-names.js +7 -9
- package/build/helpers/host-component-names.js.map +1 -1
- package/build/helpers/logger.d.ts +22 -0
- package/build/helpers/logger.js +13 -8
- package/build/helpers/logger.js.map +1 -1
- package/build/helpers/pointer-events.js +9 -5
- package/build/helpers/pointer-events.js.map +1 -1
- package/build/helpers/wrap-async.d.ts +0 -1
- package/build/helpers/wrap-async.js +0 -1
- package/build/helpers/wrap-async.js.map +1 -1
- package/build/index.d.ts +0 -1
- package/build/index.flow.js +5 -4
- package/build/index.js +1 -12
- package/build/index.js.map +1 -1
- package/build/matchers/to-be-empty-element.js +6 -3
- package/build/matchers/to-be-empty-element.js.map +1 -1
- package/build/matchers/to-be-visible.js +3 -3
- package/build/matchers/to-be-visible.js.map +1 -1
- package/build/matchers/to-contain-element.js +1 -2
- package/build/matchers/to-contain-element.js.map +1 -1
- package/build/matchers/to-have-style.js +1 -1
- package/build/matchers/to-have-style.js.map +1 -1
- package/build/matchers/utils.js +3 -2
- package/build/matchers/utils.js.map +1 -1
- package/build/pure.d.ts +7 -5
- package/build/pure.js +30 -4
- package/build/pure.js.map +1 -1
- package/build/queries/display-value.d.ts +1 -1
- package/build/queries/display-value.js +9 -9
- package/build/queries/display-value.js.map +1 -1
- package/build/queries/hint-text.d.ts +1 -1
- package/build/queries/hint-text.js +9 -9
- package/build/queries/hint-text.js.map +1 -1
- package/build/queries/label-text.d.ts +1 -1
- package/build/queries/label-text.js +9 -9
- package/build/queries/label-text.js.map +1 -1
- package/build/queries/make-queries.d.ts +2 -2
- package/build/queries/make-queries.js +11 -11
- package/build/queries/make-queries.js.map +1 -1
- package/build/queries/placeholder-text.d.ts +1 -1
- package/build/queries/placeholder-text.js +9 -9
- package/build/queries/placeholder-text.js.map +1 -1
- package/build/queries/role.d.ts +2 -2
- package/build/queries/role.js +16 -9
- package/build/queries/role.js.map +1 -1
- package/build/queries/test-id.d.ts +1 -1
- package/build/queries/test-id.js +9 -9
- package/build/queries/test-id.js.map +1 -1
- package/build/queries/text.d.ts +1 -1
- package/build/queries/text.js +9 -9
- package/build/queries/text.js.map +1 -1
- package/build/react-versions.js +1 -2
- package/build/react-versions.js.map +1 -1
- package/build/render-act.d.ts +3 -0
- package/build/render-act.js +29 -0
- package/build/render-act.js.map +1 -0
- package/build/render-async.d.ts +83 -0
- package/build/render-async.js +96 -0
- package/build/render-async.js.map +1 -0
- package/build/render-hook.d.ts +9 -7
- package/build/render-hook.js +44 -14
- package/build/render-hook.js.map +1 -1
- package/build/render.d.ts +87 -18
- package/build/render.js +54 -27
- package/build/render.js.map +1 -1
- package/build/screen.js +7 -7
- package/build/screen.js.map +1 -1
- package/build/test-utils/console.d.ts +1 -0
- package/build/test-utils/console.js +17 -0
- package/build/test-utils/console.js.map +1 -0
- package/build/test-utils/json.d.ts +6 -0
- package/build/test-utils/json.js +33 -0
- package/build/test-utils/json.js.map +1 -0
- package/build/tsconfig.release.tsbuildinfo +1 -1
- package/build/types.d.ts +4 -0
- package/build/types.js.map +1 -1
- package/build/user-event/clear.js +4 -4
- package/build/user-event/clear.js.map +1 -1
- package/build/user-event/paste.js +8 -8
- package/build/user-event/paste.js.map +1 -1
- package/build/user-event/press/press.js +17 -10
- package/build/user-event/press/press.js.map +1 -1
- package/build/user-event/scroll/scroll-to.js +7 -7
- package/build/user-event/scroll/scroll-to.js.map +1 -1
- package/build/user-event/type/type.js +11 -11
- package/build/user-event/type/type.js.map +1 -1
- package/build/user-event/utils/dispatch-event.d.ts +1 -1
- package/build/user-event/utils/dispatch-event.js +4 -4
- package/build/user-event/utils/dispatch-event.js.map +1 -1
- package/build/wait-for.js +3 -1
- package/build/wait-for.js.map +1 -1
- package/build/within.d.ts +19 -19
- package/build/within.js +8 -8
- package/build/within.js.map +1 -1
- package/package.json +37 -35
- package/typings/index.flow.js +5 -4
- package/build/test-utils/index.d.ts +0 -1
- package/build/test-utils/index.js +0 -17
- package/build/test-utils/index.js.map +0 -1
|
@@ -39,7 +39,7 @@ function formatErrorMessage(message, printElementTree) {
|
|
|
39
39
|
return message;
|
|
40
40
|
}
|
|
41
41
|
if (_screen.screen.isDetached) {
|
|
42
|
-
return `${message}\n\nScreen is no longer attached. Check your test for "findBy*" or "waitFor" calls that have not been awaited.\n\nWe recommend enabling "eslint-plugin-testing-library" to catch these issues at build time:\nhttps://callstack.github.io/react-native-testing-library/docs/
|
|
42
|
+
return `${message}\n\nScreen is no longer attached. Check your test for "findBy*" or "waitFor" calls that have not been awaited.\n\nWe recommend enabling "eslint-plugin-testing-library" to catch these issues at build time:\nhttps://callstack.github.io/react-native-testing-library/docs/start/quick-start#eslint-plugin`;
|
|
43
43
|
}
|
|
44
44
|
const json = _screen.screen.toJSON();
|
|
45
45
|
if (!json) {
|
|
@@ -56,11 +56,11 @@ function appendElementTreeToError(error) {
|
|
|
56
56
|
return error;
|
|
57
57
|
}
|
|
58
58
|
function makeQueries(queryAllByQuery, getMissingError, getMultipleError) {
|
|
59
|
-
function getAllByQuery(
|
|
59
|
+
function getAllByQuery(element, {
|
|
60
60
|
printElementTree = true
|
|
61
61
|
} = {}) {
|
|
62
62
|
return function getAllFn(predicate, options) {
|
|
63
|
-
const results = queryAllByQuery(
|
|
63
|
+
const results = queryAllByQuery(element)(predicate, options);
|
|
64
64
|
if (results.length === 0) {
|
|
65
65
|
const errorMessage = formatErrorMessage(getMissingError(predicate, options), printElementTree);
|
|
66
66
|
throw new _errors.ErrorWithStack(errorMessage, getAllFn);
|
|
@@ -68,11 +68,11 @@ function makeQueries(queryAllByQuery, getMissingError, getMultipleError) {
|
|
|
68
68
|
return results;
|
|
69
69
|
};
|
|
70
70
|
}
|
|
71
|
-
function queryByQuery(
|
|
71
|
+
function queryByQuery(element, {
|
|
72
72
|
printElementTree = true
|
|
73
73
|
} = {}) {
|
|
74
74
|
return function singleQueryFn(predicate, options) {
|
|
75
|
-
const results = queryAllByQuery(
|
|
75
|
+
const results = queryAllByQuery(element)(predicate, options);
|
|
76
76
|
if (results.length > 1) {
|
|
77
77
|
throw new _errors.ErrorWithStack(formatErrorMessage(getMultipleError(predicate, options), printElementTree), singleQueryFn);
|
|
78
78
|
}
|
|
@@ -82,11 +82,11 @@ function makeQueries(queryAllByQuery, getMissingError, getMultipleError) {
|
|
|
82
82
|
return results[0];
|
|
83
83
|
};
|
|
84
84
|
}
|
|
85
|
-
function getByQuery(
|
|
85
|
+
function getByQuery(element, {
|
|
86
86
|
printElementTree = true
|
|
87
87
|
} = {}) {
|
|
88
88
|
return function getFn(predicate, options) {
|
|
89
|
-
const results = queryAllByQuery(
|
|
89
|
+
const results = queryAllByQuery(element)(predicate, options);
|
|
90
90
|
if (results.length > 1) {
|
|
91
91
|
throw new _errors.ErrorWithStack(getMultipleError(predicate, options), getFn);
|
|
92
92
|
}
|
|
@@ -97,14 +97,14 @@ function makeQueries(queryAllByQuery, getMissingError, getMultipleError) {
|
|
|
97
97
|
return results[0];
|
|
98
98
|
};
|
|
99
99
|
}
|
|
100
|
-
function findAllByQuery(
|
|
100
|
+
function findAllByQuery(element) {
|
|
101
101
|
return function findAllFn(predicate, queryOptions, {
|
|
102
102
|
onTimeout = error => appendElementTreeToError(error),
|
|
103
103
|
...waitForOptions
|
|
104
104
|
} = {}) {
|
|
105
105
|
const stackTraceError = new _errors.ErrorWithStack('STACK_TRACE_ERROR', findAllFn);
|
|
106
106
|
const deprecatedWaitForOptions = extractDeprecatedWaitForOptions(queryOptions);
|
|
107
|
-
return (0, _waitFor.default)(() => getAllByQuery(
|
|
107
|
+
return (0, _waitFor.default)(() => getAllByQuery(element, {
|
|
108
108
|
printElementTree: false
|
|
109
109
|
})(predicate, queryOptions), {
|
|
110
110
|
...deprecatedWaitForOptions,
|
|
@@ -114,14 +114,14 @@ function makeQueries(queryAllByQuery, getMissingError, getMultipleError) {
|
|
|
114
114
|
});
|
|
115
115
|
};
|
|
116
116
|
}
|
|
117
|
-
function findByQuery(
|
|
117
|
+
function findByQuery(element) {
|
|
118
118
|
return function findFn(predicate, queryOptions, {
|
|
119
119
|
onTimeout = error => appendElementTreeToError(error),
|
|
120
120
|
...waitForOptions
|
|
121
121
|
} = {}) {
|
|
122
122
|
const stackTraceError = new _errors.ErrorWithStack('STACK_TRACE_ERROR', findFn);
|
|
123
123
|
const deprecatedWaitForOptions = extractDeprecatedWaitForOptions(queryOptions);
|
|
124
|
-
return (0, _waitFor.default)(() => getByQuery(
|
|
124
|
+
return (0, _waitFor.default)(() => getByQuery(element, {
|
|
125
125
|
printElementTree: false
|
|
126
126
|
})(predicate, queryOptions), {
|
|
127
127
|
...deprecatedWaitForOptions,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"make-queries.js","names":["_errors","require","_formatElement","_logger","_screen","_waitFor","_interopRequireDefault","e","__esModule","default","deprecatedKeys","extractDeprecatedWaitForOptions","options","undefined","waitForOptions","timeout","interval","stackTraceError","forEach","key","option","logger","warn","toString","formatErrorMessage","message","printElementTree","screen","isDetached","json","toJSON","formatJson","appendElementTreeToError","error","oldMessage","stack","replace","makeQueries","queryAllByQuery","getMissingError","getMultipleError","getAllByQuery","instance","getAllFn","predicate","results","length","errorMessage","ErrorWithStack","queryByQuery","singleQueryFn","getByQuery","getFn","findAllByQuery","findAllFn","queryOptions","onTimeout","deprecatedWaitForOptions","waitFor","findByQuery","findFn","getBy","getAllBy","queryBy","queryAllBy","findBy","findAllBy"],"sources":["../../src/queries/make-queries.ts"],"sourcesContent":["import type { HostElement } from 'universal-test-renderer';\n\nimport { ErrorWithStack } from '../helpers/errors';\nimport { formatJson } from '../helpers/format-element';\nimport { logger } from '../helpers/logger';\nimport { screen } from '../screen';\nimport waitFor, { type WaitForOptions } from '../wait-for';\n\nexport type GetByQuery<Predicate, Options = void> = (\n predicate: Predicate,\n options?: Options,\n) => HostElement;\n\nexport type GetAllByQuery<Predicate, Options = void> = (\n predicate: Predicate,\n options?: Options,\n) => HostElement[];\n\nexport type QueryByQuery<Predicate, Options = void> = (\n predicate: Predicate,\n options?: Options,\n) => HostElement | null;\n\nexport type QueryAllByQuery<Predicate, Options = void> = (\n predicate: Predicate,\n options?: Options,\n) => HostElement[];\n\nexport type FindByQuery<Predicate, Options = void> = (\n predicate: Predicate,\n // Remove `& WaitForOptions` when all queries have been migrated to support 2nd arg query options.\n options?: Options & WaitForOptions,\n waitForOptions?: WaitForOptions,\n) => Promise<HostElement>;\n\nexport type FindAllByQuery<Predicate, Options = void> = (\n predicate: Predicate,\n // Remove `& WaitForOptions` when all queries have been migrated to support 2nd arg query options.\n options?: Options & WaitForOptions,\n waitForOptions?: WaitForOptions,\n) => Promise<HostElement[]>;\n\ntype UnboundQuery<Query> = (instance: HostElement) => Query;\n\nexport type UnboundQueries<Predicate, Options> = {\n getBy: UnboundQuery<GetByQuery<Predicate, Options>>;\n getAllBy: UnboundQuery<GetAllByQuery<Predicate, Options>>;\n queryBy: UnboundQuery<QueryByQuery<Predicate, Options>>;\n queryAllBy: UnboundQuery<QueryAllByQuery<Predicate, Options>>;\n findBy: UnboundQuery<FindByQuery<Predicate, Options>>;\n findAllBy: UnboundQuery<FindAllByQuery<Predicate, Options>>;\n};\n\nconst deprecatedKeys: (keyof WaitForOptions)[] = ['timeout', 'interval', 'stackTraceError'];\n\n// The WaitForOptions has been moved to the second option param of findBy* methods with the adding of TextMatchOptions\n// To make the migration easier and avoid a breaking change, keep reading this options from the first param but warn\nfunction extractDeprecatedWaitForOptions(options?: WaitForOptions) {\n if (!options) {\n return undefined;\n }\n\n const waitForOptions: WaitForOptions = {\n timeout: options.timeout,\n interval: options.interval,\n stackTraceError: options.stackTraceError,\n };\n\n deprecatedKeys.forEach((key) => {\n const option = options[key];\n if (option) {\n logger.warn(\n `Use of option \"${key}\" in a findBy* query options (2nd parameter) is deprecated. Please pass this option in the waitForOptions (3rd parameter).\nExample:\n\n findByText(text, {}, { ${key}: ${option.toString()} })`,\n );\n }\n });\n\n return waitForOptions;\n}\n\nfunction formatErrorMessage(message: string, printElementTree: boolean) {\n if (!printElementTree) {\n return message;\n }\n\n if (screen.isDetached) {\n return `${message}\\n\\nScreen is no longer attached. Check your test for \"findBy*\" or \"waitFor\" calls that have not been awaited.\\n\\nWe recommend enabling \"eslint-plugin-testing-library\" to catch these issues at build time:\\nhttps://callstack.github.io/react-native-testing-library/docs/getting-started#eslint-plugin`;\n }\n\n const json = screen.toJSON();\n if (!json) {\n return message;\n }\n\n return `${message}\\n\\n${formatJson(json)}`;\n}\n\nfunction appendElementTreeToError(error: Error) {\n const oldMessage = error.message;\n error.message = formatErrorMessage(oldMessage, true);\n\n // Required to make Jest print the element tree on error\n error.stack = error.stack?.replace(oldMessage, error.message);\n\n return error;\n}\n\nexport function makeQueries<Predicate, Options>(\n queryAllByQuery: UnboundQuery<QueryAllByQuery<Predicate, Options>>,\n getMissingError: (predicate: Predicate, options?: Options) => string,\n getMultipleError: (predicate: Predicate, options?: Options) => string,\n): UnboundQueries<Predicate, Options> {\n function getAllByQuery(instance: HostElement, { printElementTree = true } = {}) {\n return function getAllFn(predicate: Predicate, options?: Options) {\n const results = queryAllByQuery(instance)(predicate, options);\n\n if (results.length === 0) {\n const errorMessage = formatErrorMessage(\n getMissingError(predicate, options),\n printElementTree,\n );\n throw new ErrorWithStack(errorMessage, getAllFn);\n }\n\n return results;\n };\n }\n\n function queryByQuery(instance: HostElement, { printElementTree = true } = {}) {\n return function singleQueryFn(predicate: Predicate, options?: Options) {\n const results = queryAllByQuery(instance)(predicate, options);\n\n if (results.length > 1) {\n throw new ErrorWithStack(\n formatErrorMessage(getMultipleError(predicate, options), printElementTree),\n singleQueryFn,\n );\n }\n\n if (results.length === 0) {\n return null;\n }\n\n return results[0];\n };\n }\n\n function getByQuery(instance: HostElement, { printElementTree = true } = {}) {\n return function getFn(predicate: Predicate, options?: Options) {\n const results = queryAllByQuery(instance)(predicate, options);\n\n if (results.length > 1) {\n throw new ErrorWithStack(getMultipleError(predicate, options), getFn);\n }\n\n if (results.length === 0) {\n const errorMessage = formatErrorMessage(\n getMissingError(predicate, options),\n printElementTree,\n );\n throw new ErrorWithStack(errorMessage, getFn);\n }\n\n return results[0];\n };\n }\n\n function findAllByQuery(instance: HostElement) {\n return function findAllFn(\n predicate: Predicate,\n queryOptions?: Options & WaitForOptions,\n {\n onTimeout = (error) => appendElementTreeToError(error),\n ...waitForOptions\n }: WaitForOptions = {},\n ) {\n const stackTraceError = new ErrorWithStack('STACK_TRACE_ERROR', findAllFn);\n const deprecatedWaitForOptions = extractDeprecatedWaitForOptions(queryOptions);\n\n return waitFor(\n () => getAllByQuery(instance, { printElementTree: false })(predicate, queryOptions),\n {\n ...deprecatedWaitForOptions,\n ...waitForOptions,\n stackTraceError,\n onTimeout,\n },\n );\n };\n }\n\n function findByQuery(instance: HostElement) {\n return function findFn(\n predicate: Predicate,\n queryOptions?: Options & WaitForOptions,\n {\n onTimeout = (error) => appendElementTreeToError(error),\n ...waitForOptions\n }: WaitForOptions = {},\n ) {\n const stackTraceError = new ErrorWithStack('STACK_TRACE_ERROR', findFn);\n const deprecatedWaitForOptions = extractDeprecatedWaitForOptions(queryOptions);\n\n return waitFor(\n () => getByQuery(instance, { printElementTree: false })(predicate, queryOptions),\n {\n ...deprecatedWaitForOptions,\n ...waitForOptions,\n stackTraceError,\n onTimeout,\n },\n );\n };\n }\n\n return {\n getBy: getByQuery,\n getAllBy: getAllByQuery,\n queryBy: queryByQuery,\n queryAllBy: queryAllByQuery,\n findBy: findByQuery,\n findAllBy: findAllByQuery,\n };\n}\n"],"mappings":";;;;;;AAEA,IAAAA,OAAA,GAAAC,OAAA;AACA,IAAAC,cAAA,GAAAD,OAAA;AACA,IAAAE,OAAA,GAAAF,OAAA;AACA,IAAAG,OAAA,GAAAH,OAAA;AACA,IAAAI,QAAA,GAAAC,sBAAA,CAAAL,OAAA;AAA2D,SAAAK,uBAAAC,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AA+C3D,MAAMG,cAAwC,GAAG,CAAC,SAAS,EAAE,UAAU,EAAE,iBAAiB,CAAC;;AAE3F;AACA;AACA,SAASC,+BAA+BA,CAACC,OAAwB,EAAE;EACjE,IAAI,CAACA,OAAO,EAAE;IACZ,OAAOC,SAAS;EAClB;EAEA,MAAMC,cAA8B,GAAG;IACrCC,OAAO,EAAEH,OAAO,CAACG,OAAO;IACxBC,QAAQ,EAAEJ,OAAO,CAACI,QAAQ;IAC1BC,eAAe,EAAEL,OAAO,CAACK;EAC3B,CAAC;EAEDP,cAAc,CAACQ,OAAO,CAAEC,GAAG,IAAK;IAC9B,MAAMC,MAAM,GAAGR,OAAO,CAACO,GAAG,CAAC;IAC3B,IAAIC,MAAM,EAAE;MACVC,cAAM,CAACC,IAAI,CACT,kBAAkBH,GAAG;AAC7B;AACA;AACA,2BAA2BA,GAA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;QACjBG,eAAe;QACfuC;MACF,CACF,CAAC;IACH,CAAC;EACH;EAEA,OAAO;IACLK,KAAK,EAAEV,UAAU;IACjBW,QAAQ,EAAErB,aAAa;IACvBsB,OAAO,EAAEd,YAAY;IACrBe,UAAU,EAAE1B,eAAe;IAC3B2B,MAAM,EAAEN,WAAW;IACnBO,SAAS,EAAEb;EACb,CAAC;AACH","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"make-queries.js","names":["_errors","require","_formatElement","_logger","_screen","_waitFor","_interopRequireDefault","e","__esModule","default","deprecatedKeys","extractDeprecatedWaitForOptions","options","undefined","waitForOptions","timeout","interval","stackTraceError","forEach","key","option","logger","warn","toString","formatErrorMessage","message","printElementTree","screen","isDetached","json","toJSON","formatJson","appendElementTreeToError","error","oldMessage","stack","replace","makeQueries","queryAllByQuery","getMissingError","getMultipleError","getAllByQuery","element","getAllFn","predicate","results","length","errorMessage","ErrorWithStack","queryByQuery","singleQueryFn","getByQuery","getFn","findAllByQuery","findAllFn","queryOptions","onTimeout","deprecatedWaitForOptions","waitFor","findByQuery","findFn","getBy","getAllBy","queryBy","queryAllBy","findBy","findAllBy"],"sources":["../../src/queries/make-queries.ts"],"sourcesContent":["import type { HostElement } from 'universal-test-renderer';\n\nimport { ErrorWithStack } from '../helpers/errors';\nimport { formatJson } from '../helpers/format-element';\nimport { logger } from '../helpers/logger';\nimport { screen } from '../screen';\nimport type { WaitForOptions } from '../wait-for';\nimport waitFor from '../wait-for';\n\nexport type GetByQuery<Predicate, Options = void> = (\n predicate: Predicate,\n options?: Options,\n) => HostElement;\n\nexport type GetAllByQuery<Predicate, Options = void> = (\n predicate: Predicate,\n options?: Options,\n) => HostElement[];\n\nexport type QueryByQuery<Predicate, Options = void> = (\n predicate: Predicate,\n options?: Options,\n) => HostElement | null;\n\nexport type QueryAllByQuery<Predicate, Options = void> = (\n predicate: Predicate,\n options?: Options,\n) => HostElement[];\n\nexport type FindByQuery<Predicate, Options = void> = (\n predicate: Predicate,\n // Remove `& WaitForOptions` when all queries have been migrated to support 2nd arg query options.\n options?: Options & WaitForOptions,\n waitForOptions?: WaitForOptions,\n) => Promise<HostElement>;\n\nexport type FindAllByQuery<Predicate, Options = void> = (\n predicate: Predicate,\n // Remove `& WaitForOptions` when all queries have been migrated to support 2nd arg query options.\n options?: Options & WaitForOptions,\n waitForOptions?: WaitForOptions,\n) => Promise<HostElement[]>;\n\ntype UnboundQuery<Query> = (element: HostElement) => Query;\n\nexport type UnboundQueries<Predicate, Options> = {\n getBy: UnboundQuery<GetByQuery<Predicate, Options>>;\n getAllBy: UnboundQuery<GetAllByQuery<Predicate, Options>>;\n queryBy: UnboundQuery<QueryByQuery<Predicate, Options>>;\n queryAllBy: UnboundQuery<QueryAllByQuery<Predicate, Options>>;\n findBy: UnboundQuery<FindByQuery<Predicate, Options>>;\n findAllBy: UnboundQuery<FindAllByQuery<Predicate, Options>>;\n};\n\nconst deprecatedKeys: (keyof WaitForOptions)[] = ['timeout', 'interval', 'stackTraceError'];\n\n// The WaitForOptions has been moved to the second option param of findBy* methods with the adding of TextMatchOptions\n// To make the migration easier and avoid a breaking change, keep reading this options from the first param but warn\nfunction extractDeprecatedWaitForOptions(options?: WaitForOptions) {\n if (!options) {\n return undefined;\n }\n\n const waitForOptions: WaitForOptions = {\n timeout: options.timeout,\n interval: options.interval,\n stackTraceError: options.stackTraceError,\n };\n\n deprecatedKeys.forEach((key) => {\n const option = options[key];\n if (option) {\n logger.warn(\n `Use of option \"${key}\" in a findBy* query options (2nd parameter) is deprecated. Please pass this option in the waitForOptions (3rd parameter).\nExample:\n\n findByText(text, {}, { ${key}: ${option.toString()} })`,\n );\n }\n });\n\n return waitForOptions;\n}\n\nfunction formatErrorMessage(message: string, printElementTree: boolean) {\n if (!printElementTree) {\n return message;\n }\n\n if (screen.isDetached) {\n return `${message}\\n\\nScreen is no longer attached. Check your test for \"findBy*\" or \"waitFor\" calls that have not been awaited.\\n\\nWe recommend enabling \"eslint-plugin-testing-library\" to catch these issues at build time:\\nhttps://callstack.github.io/react-native-testing-library/docs/start/quick-start#eslint-plugin`;\n }\n\n const json = screen.toJSON();\n if (!json) {\n return message;\n }\n\n return `${message}\\n\\n${formatJson(json)}`;\n}\n\nfunction appendElementTreeToError(error: Error) {\n const oldMessage = error.message;\n error.message = formatErrorMessage(oldMessage, true);\n\n // Required to make Jest print the element tree on error\n error.stack = error.stack?.replace(oldMessage, error.message);\n\n return error;\n}\n\nexport function makeQueries<Predicate, Options>(\n queryAllByQuery: UnboundQuery<QueryAllByQuery<Predicate, Options>>,\n getMissingError: (predicate: Predicate, options?: Options) => string,\n getMultipleError: (predicate: Predicate, options?: Options) => string,\n): UnboundQueries<Predicate, Options> {\n function getAllByQuery(element: HostElement, { printElementTree = true } = {}) {\n return function getAllFn(predicate: Predicate, options?: Options) {\n const results = queryAllByQuery(element)(predicate, options);\n\n if (results.length === 0) {\n const errorMessage = formatErrorMessage(\n getMissingError(predicate, options),\n printElementTree,\n );\n throw new ErrorWithStack(errorMessage, getAllFn);\n }\n\n return results;\n };\n }\n\n function queryByQuery(element: HostElement, { printElementTree = true } = {}) {\n return function singleQueryFn(predicate: Predicate, options?: Options) {\n const results = queryAllByQuery(element)(predicate, options);\n\n if (results.length > 1) {\n throw new ErrorWithStack(\n formatErrorMessage(getMultipleError(predicate, options), printElementTree),\n singleQueryFn,\n );\n }\n\n if (results.length === 0) {\n return null;\n }\n\n return results[0];\n };\n }\n\n function getByQuery(element: HostElement, { printElementTree = true } = {}) {\n return function getFn(predicate: Predicate, options?: Options) {\n const results = queryAllByQuery(element)(predicate, options);\n\n if (results.length > 1) {\n throw new ErrorWithStack(getMultipleError(predicate, options), getFn);\n }\n\n if (results.length === 0) {\n const errorMessage = formatErrorMessage(\n getMissingError(predicate, options),\n printElementTree,\n );\n throw new ErrorWithStack(errorMessage, getFn);\n }\n\n return results[0];\n };\n }\n\n function findAllByQuery(element: HostElement) {\n return function findAllFn(\n predicate: Predicate,\n queryOptions?: Options & WaitForOptions,\n {\n onTimeout = (error) => appendElementTreeToError(error),\n ...waitForOptions\n }: WaitForOptions = {},\n ) {\n const stackTraceError = new ErrorWithStack('STACK_TRACE_ERROR', findAllFn);\n const deprecatedWaitForOptions = extractDeprecatedWaitForOptions(queryOptions);\n\n return waitFor(\n () => getAllByQuery(element, { printElementTree: false })(predicate, queryOptions),\n {\n ...deprecatedWaitForOptions,\n ...waitForOptions,\n stackTraceError,\n onTimeout,\n },\n );\n };\n }\n\n function findByQuery(element: HostElement) {\n return function findFn(\n predicate: Predicate,\n queryOptions?: Options & WaitForOptions,\n {\n onTimeout = (error) => appendElementTreeToError(error),\n ...waitForOptions\n }: WaitForOptions = {},\n ) {\n const stackTraceError = new ErrorWithStack('STACK_TRACE_ERROR', findFn);\n const deprecatedWaitForOptions = extractDeprecatedWaitForOptions(queryOptions);\n\n return waitFor(\n () => getByQuery(element, { printElementTree: false })(predicate, queryOptions),\n {\n ...deprecatedWaitForOptions,\n ...waitForOptions,\n stackTraceError,\n onTimeout,\n },\n );\n };\n }\n\n return {\n getBy: getByQuery,\n getAllBy: getAllByQuery,\n queryBy: queryByQuery,\n queryAllBy: queryAllByQuery,\n findBy: findByQuery,\n findAllBy: findAllByQuery,\n };\n}\n"],"mappings":";;;;;;AAEA,IAAAA,OAAA,GAAAC,OAAA;AACA,IAAAC,cAAA,GAAAD,OAAA;AACA,IAAAE,OAAA,GAAAF,OAAA;AACA,IAAAG,OAAA,GAAAH,OAAA;AAEA,IAAAI,QAAA,GAAAC,sBAAA,CAAAL,OAAA;AAAkC,SAAAK,uBAAAC,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AA+ClC,MAAMG,cAAwC,GAAG,CAAC,SAAS,EAAE,UAAU,EAAE,iBAAiB,CAAC;;AAE3F;AACA;AACA,SAASC,+BAA+BA,CAACC,OAAwB,EAAE;EACjE,IAAI,CAACA,OAAO,EAAE;IACZ,OAAOC,SA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;IACW,CAAC,GAAG,CAAC,CAAC,EACtB;MACA,MAAMG,eAAe,GAAG,IAAI+B,sBAAc,CAAC,mBAAmB,EAAEY,MAAM,CAAC;MACvE,MAAMH,wBAAwB,GAAG9C,+BAA+B,CAAC4C,YAAY,CAAC;MAE9E,OAAO,IAAAG,gBAAO,EACZ,MAAMP,UAAU,CAACT,OAAO,EAAE;QAAEhB,gBAAgB,EAAE;MAAM,CAAC,CAAC,CAACkB,SAAS,EAAEW,YAAY,CAAC,EAC/E;QACE,GAAGE,wBAAwB;QAC3B,GAAG3C,cAAc;QACjBG,eAAe;QACfuC;MACF,CACF,CAAC;IACH,CAAC;EACH;EAEA,OAAO;IACLK,KAAK,EAAEV,UAAU;IACjBW,QAAQ,EAAErB,aAAa;IACvBsB,OAAO,EAAEd,YAAY;IACrBe,UAAU,EAAE1B,eAAe;IAC3B2B,MAAM,EAAEN,WAAW;IACnBO,SAAS,EAAEb;EACb,CAAC;AACH","ignoreList":[]}
|
|
@@ -11,5 +11,5 @@ export type ByPlaceholderTextQueries = {
|
|
|
11
11
|
findByPlaceholderText: FindByQuery<TextMatch, ByPlaceholderTextOptions>;
|
|
12
12
|
findAllByPlaceholderText: FindAllByQuery<TextMatch, ByPlaceholderTextOptions>;
|
|
13
13
|
};
|
|
14
|
-
export declare const bindByPlaceholderTextQueries: (
|
|
14
|
+
export declare const bindByPlaceholderTextQueries: (element: HostElement) => ByPlaceholderTextQueries;
|
|
15
15
|
export {};
|
|
@@ -15,8 +15,8 @@ const matchPlaceholderText = (node, placeholder, options = {}) => {
|
|
|
15
15
|
} = options;
|
|
16
16
|
return (0, _matches.matches)(placeholder, node.props.placeholder, normalizer, exact);
|
|
17
17
|
};
|
|
18
|
-
const queryAllByPlaceholderText =
|
|
19
|
-
return (0, _findAll.findAll)(
|
|
18
|
+
const queryAllByPlaceholderText = element => function queryAllByPlaceholderFn(placeholder, queryOptions) {
|
|
19
|
+
return (0, _findAll.findAll)(element, node => (0, _hostComponentNames.isHostTextInput)(node) && matchPlaceholderText(node, placeholder, queryOptions), queryOptions);
|
|
20
20
|
};
|
|
21
21
|
const getMultipleError = placeholder => `Found multiple elements with placeholder: ${String(placeholder)} `;
|
|
22
22
|
const getMissingError = placeholder => `Unable to find an element with placeholder: ${String(placeholder)}`;
|
|
@@ -28,13 +28,13 @@ const {
|
|
|
28
28
|
findBy,
|
|
29
29
|
findAllBy
|
|
30
30
|
} = (0, _makeQueries.makeQueries)(queryAllByPlaceholderText, getMissingError, getMultipleError);
|
|
31
|
-
const bindByPlaceholderTextQueries =
|
|
32
|
-
getByPlaceholderText: getBy(
|
|
33
|
-
getAllByPlaceholderText: getAllBy(
|
|
34
|
-
queryByPlaceholderText: queryBy(
|
|
35
|
-
queryAllByPlaceholderText: queryAllBy(
|
|
36
|
-
findByPlaceholderText: findBy(
|
|
37
|
-
findAllByPlaceholderText: findAllBy(
|
|
31
|
+
const bindByPlaceholderTextQueries = element => ({
|
|
32
|
+
getByPlaceholderText: getBy(element),
|
|
33
|
+
getAllByPlaceholderText: getAllBy(element),
|
|
34
|
+
queryByPlaceholderText: queryBy(element),
|
|
35
|
+
queryAllByPlaceholderText: queryAllBy(element),
|
|
36
|
+
findByPlaceholderText: findBy(element),
|
|
37
|
+
findAllByPlaceholderText: findAllBy(element)
|
|
38
38
|
});
|
|
39
39
|
exports.bindByPlaceholderTextQueries = bindByPlaceholderTextQueries;
|
|
40
40
|
//# sourceMappingURL=placeholder-text.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"placeholder-text.js","names":["_findAll","require","_hostComponentNames","_matches","_makeQueries","matchPlaceholderText","node","placeholder","options","exact","normalizer","matches","props","queryAllByPlaceholderText","
|
|
1
|
+
{"version":3,"file":"placeholder-text.js","names":["_findAll","require","_hostComponentNames","_matches","_makeQueries","matchPlaceholderText","node","placeholder","options","exact","normalizer","matches","props","queryAllByPlaceholderText","element","queryAllByPlaceholderFn","queryOptions","findAll","isHostTextInput","getMultipleError","String","getMissingError","getBy","getAllBy","queryBy","queryAllBy","findBy","findAllBy","makeQueries","bindByPlaceholderTextQueries","getByPlaceholderText","getAllByPlaceholderText","queryByPlaceholderText","findByPlaceholderText","findAllByPlaceholderText","exports"],"sources":["../../src/queries/placeholder-text.ts"],"sourcesContent":["import type { HostElement } from 'universal-test-renderer';\n\nimport { findAll } from '../helpers/find-all';\nimport { isHostTextInput } from '../helpers/host-component-names';\nimport type { TextMatch, TextMatchOptions } from '../matches';\nimport { matches } from '../matches';\nimport type {\n FindAllByQuery,\n FindByQuery,\n GetAllByQuery,\n GetByQuery,\n QueryAllByQuery,\n QueryByQuery,\n} from './make-queries';\nimport { makeQueries } from './make-queries';\nimport type { CommonQueryOptions } from './options';\n\ntype ByPlaceholderTextOptions = CommonQueryOptions & TextMatchOptions;\n\nconst matchPlaceholderText = (\n node: HostElement,\n placeholder: TextMatch,\n options: TextMatchOptions = {},\n) => {\n const { exact, normalizer } = options;\n return matches(placeholder, node.props.placeholder, normalizer, exact);\n};\n\nconst queryAllByPlaceholderText = (\n element: HostElement,\n): QueryAllByQuery<TextMatch, ByPlaceholderTextOptions> =>\n function queryAllByPlaceholderFn(placeholder, queryOptions) {\n return findAll(\n element,\n (node) => isHostTextInput(node) && matchPlaceholderText(node, placeholder, queryOptions),\n queryOptions,\n );\n };\n\nconst getMultipleError = (placeholder: TextMatch) =>\n `Found multiple elements with placeholder: ${String(placeholder)} `;\nconst getMissingError = (placeholder: TextMatch) =>\n `Unable to find an element with placeholder: ${String(placeholder)}`;\n\nconst { getBy, getAllBy, queryBy, queryAllBy, findBy, findAllBy } = makeQueries(\n queryAllByPlaceholderText,\n getMissingError,\n getMultipleError,\n);\n\nexport type ByPlaceholderTextQueries = {\n getByPlaceholderText: GetByQuery<TextMatch, ByPlaceholderTextOptions>;\n getAllByPlaceholderText: GetAllByQuery<TextMatch, ByPlaceholderTextOptions>;\n queryByPlaceholderText: QueryByQuery<TextMatch, ByPlaceholderTextOptions>;\n queryAllByPlaceholderText: QueryAllByQuery<TextMatch, ByPlaceholderTextOptions>;\n findByPlaceholderText: FindByQuery<TextMatch, ByPlaceholderTextOptions>;\n findAllByPlaceholderText: FindAllByQuery<TextMatch, ByPlaceholderTextOptions>;\n};\n\nexport const bindByPlaceholderTextQueries = (element: HostElement): ByPlaceholderTextQueries => ({\n getByPlaceholderText: getBy(element),\n getAllByPlaceholderText: getAllBy(element),\n queryByPlaceholderText: queryBy(element),\n queryAllByPlaceholderText: queryAllBy(element),\n findByPlaceholderText: findBy(element),\n findAllByPlaceholderText: findAllBy(element),\n});\n"],"mappings":";;;;;;AAEA,IAAAA,QAAA,GAAAC,OAAA;AACA,IAAAC,mBAAA,GAAAD,OAAA;AAEA,IAAAE,QAAA,GAAAF,OAAA;AASA,IAAAG,YAAA,GAAAH,OAAA;AAKA,MAAMI,oBAAoB,GAAGA,CAC3BC,IAAiB,EACjBC,WAAsB,EACtBC,OAAyB,GAAG,CAAC,CAAC,KAC3B;EACH,MAAM;IAAEC,KAAK;IAAEC;EAAW,CAAC,GAAGF,OAAO;EACrC,OAAO,IAAAG,gBAAO,EAACJ,WAAW,EAAED,IAAI,CAACM,KAAK,CAACL,WAAW,EAAEG,UAAU,EAAED,KAAK,CAAC;AACxE,CAAC;AAED,MAAMI,yBAAyB,GAC7BC,OAAoB,IAEpB,SAASC,uBAAuBA,CAACR,WAAW,EAAES,YAAY,EAAE;EAC1D,OAAO,IAAAC,gBAAO,EACZH,OAAO,EACNR,IAAI,IAAK,IAAAY,mCAAe,EAACZ,IAAI,CAAC,IAAID,oBAAoB,CAACC,IAAI,EAAEC,WAAW,EAAES,YAAY,CAAC,EACxFA,YACF,CAAC;AACH,CAAC;AAEH,MAAMG,gBAAgB,GAAIZ,WAAsB,IAC9C,6CAA6Ca,MAAM,CAACb,WAAW,CAAC,GAAG;AACrE,MAAMc,eAAe,GAAId,WAAsB,IAC7C,+CAA+Ca,MAAM,CAACb,WAAW,CAAC,EAAE;AAEtE,MAAM;EAAEe,KAAK;EAAEC,QAAQ;EAAEC,OAAO;EAAEC,UAAU;EAAEC,MAAM;EAAEC;AAAU,CAAC,GAAG,IAAAC,wBAAW,EAC7Ef,yBAAyB,EACzBQ,eAAe,EACfF,gBACF,CAAC;AAWM,MAAMU,4BAA4B,GAAIf,OAAoB,KAAgC;EAC/FgB,oBAAoB,EAAER,KAAK,CAACR,OAAO,CAAC;EACpCiB,uBAAuB,EAAER,QAAQ,CAACT,OAAO,CAAC;EAC1CkB,sBAAsB,EAAER,OAAO,CAACV,OAAO,CAAC;EACxCD,yBAAyB,EAAEY,UAAU,CAACX,OAAO,CAAC;EAC9CmB,qBAAqB,EAAEP,MAAM,CAACZ,OAAO,CAAC;EACtCoB,wBAAwB,EAAEP,SAAS,CAACb,OAAO;AAC7C,CAAC,CAAC;AAACqB,OAAA,CAAAN,4BAAA,GAAAA,4BAAA","ignoreList":[]}
|
package/build/queries/role.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import type { AccessibilityRole, Role } from 'react-native';
|
|
|
2
2
|
import type { HostElement } from 'universal-test-renderer';
|
|
3
3
|
import type { AccessibilityStateMatcher } from '../helpers/matchers/match-accessibility-state';
|
|
4
4
|
import type { AccessibilityValueMatcher } from '../helpers/matchers/match-accessibility-value';
|
|
5
|
-
import type
|
|
5
|
+
import { type TextMatch } from '../matches';
|
|
6
6
|
import type { StringWithAutocomplete } from '../types';
|
|
7
7
|
import type { FindAllByQuery, FindByQuery, GetAllByQuery, GetByQuery, QueryAllByQuery, QueryByQuery } from './make-queries';
|
|
8
8
|
import type { CommonQueryOptions } from './options';
|
|
@@ -19,4 +19,4 @@ export type ByRoleQueries = {
|
|
|
19
19
|
findByRole: FindByQuery<ByRoleMatcher, ByRoleOptions>;
|
|
20
20
|
findAllByRole: FindAllByQuery<ByRoleMatcher, ByRoleOptions>;
|
|
21
21
|
};
|
|
22
|
-
export declare const bindByRoleQueries: (
|
|
22
|
+
export declare const bindByRoleQueries: (element: HostElement) => ByRoleQueries;
|
package/build/queries/role.js
CHANGED
|
@@ -9,10 +9,17 @@ var _findAll = require("../helpers/find-all");
|
|
|
9
9
|
var _matchAccessibilityState = require("../helpers/matchers/match-accessibility-state");
|
|
10
10
|
var _matchAccessibilityValue = require("../helpers/matchers/match-accessibility-value");
|
|
11
11
|
var _matchStringProp = require("../helpers/matchers/match-string-prop");
|
|
12
|
+
var _matches = require("../matches");
|
|
12
13
|
var _within = require("../within");
|
|
13
14
|
var _makeQueries = require("./make-queries");
|
|
14
15
|
const matchAccessibleNameIfNeeded = (node, name) => {
|
|
15
16
|
if (name == null) return true;
|
|
17
|
+
|
|
18
|
+
// TODO: rewrite computeAccessibleName for real world a11y compliance
|
|
19
|
+
const accessibleName = (0, _accessibility.computeAccessibleName)(node);
|
|
20
|
+
if ((0, _matches.matches)(name, accessibleName)) {
|
|
21
|
+
return true;
|
|
22
|
+
}
|
|
16
23
|
const {
|
|
17
24
|
queryAllByText,
|
|
18
25
|
queryAllByLabelText
|
|
@@ -25,9 +32,9 @@ const matchAccessibleStateIfNeeded = (node, options) => {
|
|
|
25
32
|
const matchAccessibilityValueIfNeeded = (node, value) => {
|
|
26
33
|
return value != null ? (0, _matchAccessibilityValue.matchAccessibilityValue)(node, value) : true;
|
|
27
34
|
};
|
|
28
|
-
const queryAllByRole =
|
|
35
|
+
const queryAllByRole = element => function queryAllByRoleFn(role, options) {
|
|
29
36
|
const normalizedRole = typeof role === 'string' ? (0, _accessibility.normalizeRole)(role) : role;
|
|
30
|
-
return (0, _findAll.findAll)(
|
|
37
|
+
return (0, _findAll.findAll)(element, node =>
|
|
31
38
|
// run the cheapest checks first, and early exit to avoid unneeded computations
|
|
32
39
|
(0, _accessibility.isAccessibilityElement)(node) && (0, _matchStringProp.matchStringProp)((0, _accessibility.getRole)(node), normalizedRole) && matchAccessibleStateIfNeeded(node, options) && matchAccessibilityValueIfNeeded(node, options?.value) && matchAccessibleNameIfNeeded(node, options?.name), options);
|
|
33
40
|
};
|
|
@@ -58,13 +65,13 @@ const {
|
|
|
58
65
|
findBy,
|
|
59
66
|
findAllBy
|
|
60
67
|
} = (0, _makeQueries.makeQueries)(queryAllByRole, getMissingError, getMultipleError);
|
|
61
|
-
const bindByRoleQueries =
|
|
62
|
-
getByRole: getBy(
|
|
63
|
-
getAllByRole: getAllBy(
|
|
64
|
-
queryByRole: queryBy(
|
|
65
|
-
queryAllByRole: queryAllBy(
|
|
66
|
-
findByRole: findBy(
|
|
67
|
-
findAllByRole: findAllBy(
|
|
68
|
+
const bindByRoleQueries = element => ({
|
|
69
|
+
getByRole: getBy(element),
|
|
70
|
+
getAllByRole: getAllBy(element),
|
|
71
|
+
queryByRole: queryBy(element),
|
|
72
|
+
queryAllByRole: queryAllBy(element),
|
|
73
|
+
findByRole: findBy(element),
|
|
74
|
+
findAllByRole: findAllBy(element)
|
|
68
75
|
});
|
|
69
76
|
exports.bindByRoleQueries = bindByRoleQueries;
|
|
70
77
|
//# sourceMappingURL=role.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"role.js","names":["_accessibility","require","_findAll","_matchAccessibilityState","_matchAccessibilityValue","_matchStringProp","_within","_makeQueries","matchAccessibleNameIfNeeded","node","name","queryAllByText","queryAllByLabelText","getQueriesForElement","length","matchAccessibleStateIfNeeded","options","matchAccessibilityState","matchAccessibilityValueIfNeeded","value","matchAccessibilityValue","queryAllByRole","
|
|
1
|
+
{"version":3,"file":"role.js","names":["_accessibility","require","_findAll","_matchAccessibilityState","_matchAccessibilityValue","_matchStringProp","_matches","_within","_makeQueries","matchAccessibleNameIfNeeded","node","name","accessibleName","computeAccessibleName","matches","queryAllByText","queryAllByLabelText","getQueriesForElement","length","matchAccessibleStateIfNeeded","options","matchAccessibilityState","matchAccessibilityValueIfNeeded","value","matchAccessibilityValue","queryAllByRole","element","queryAllByRoleFn","role","normalizedRole","normalizeRole","findAll","isAccessibilityElement","matchStringProp","getRole","formatQueryParams","params","String","push","accessibilityStateKeys","forEach","stateKey","undefined","accessibilityValueKeys","valueKey","join","getMultipleError","getMissingError","getBy","getAllBy","queryBy","queryAllBy","findBy","findAllBy","makeQueries","bindByRoleQueries","getByRole","getAllByRole","queryByRole","findByRole","findAllByRole","exports"],"sources":["../../src/queries/role.ts"],"sourcesContent":["import type { AccessibilityRole, Role } from 'react-native';\nimport type { HostElement } from 'universal-test-renderer';\n\nimport {\n accessibilityStateKeys,\n accessibilityValueKeys,\n computeAccessibleName,\n getRole,\n isAccessibilityElement,\n normalizeRole,\n} from '../helpers/accessibility';\nimport { findAll } from '../helpers/find-all';\nimport type { AccessibilityStateMatcher } from '../helpers/matchers/match-accessibility-state';\nimport { matchAccessibilityState } from '../helpers/matchers/match-accessibility-state';\nimport type { AccessibilityValueMatcher } from '../helpers/matchers/match-accessibility-value';\nimport { matchAccessibilityValue } from '../helpers/matchers/match-accessibility-value';\nimport { matchStringProp } from '../helpers/matchers/match-string-prop';\nimport { matches, type TextMatch } from '../matches';\nimport type { StringWithAutocomplete } from '../types';\nimport { getQueriesForElement } from '../within';\nimport type {\n FindAllByQuery,\n FindByQuery,\n GetAllByQuery,\n GetByQuery,\n QueryAllByQuery,\n QueryByQuery,\n} from './make-queries';\nimport { makeQueries } from './make-queries';\nimport type { CommonQueryOptions } from './options';\n\nexport type ByRoleMatcher = StringWithAutocomplete<AccessibilityRole | Role> | RegExp;\n\nexport type ByRoleOptions = CommonQueryOptions &\n AccessibilityStateMatcher & {\n name?: TextMatch;\n value?: AccessibilityValueMatcher;\n };\n\nconst matchAccessibleNameIfNeeded = (node: HostElement, name?: TextMatch) => {\n if (name == null) return true;\n\n // TODO: rewrite computeAccessibleName for real world a11y compliance\n const accessibleName = computeAccessibleName(node);\n if (matches(name, accessibleName)) {\n return true;\n }\n\n const { queryAllByText, queryAllByLabelText } = getQueriesForElement(node);\n return queryAllByText(name).length > 0 || queryAllByLabelText(name).length > 0;\n};\n\nconst matchAccessibleStateIfNeeded = (node: HostElement, options?: ByRoleOptions) => {\n return options != null ? matchAccessibilityState(node, options) : true;\n};\n\nconst matchAccessibilityValueIfNeeded = (node: HostElement, value?: AccessibilityValueMatcher) => {\n return value != null ? matchAccessibilityValue(node, value) : true;\n};\n\nconst queryAllByRole = (element: HostElement): QueryAllByQuery<ByRoleMatcher, ByRoleOptions> =>\n function queryAllByRoleFn(role, options) {\n const normalizedRole = typeof role === 'string' ? normalizeRole(role) : role;\n return findAll(\n element,\n (node) =>\n // run the cheapest checks first, and early exit to avoid unneeded computations\n isAccessibilityElement(node) &&\n matchStringProp(getRole(node), normalizedRole) &&\n matchAccessibleStateIfNeeded(node, options) &&\n matchAccessibilityValueIfNeeded(node, options?.value) &&\n matchAccessibleNameIfNeeded(node, options?.name),\n options,\n );\n };\n\nconst formatQueryParams = (role: TextMatch, options: ByRoleOptions = {}) => {\n const params = [`role: ${String(role)}`];\n\n if (options.name) {\n params.push(`name: ${String(options.name)}`);\n }\n\n accessibilityStateKeys.forEach((stateKey) => {\n if (options[stateKey] !== undefined) {\n params.push(`${stateKey} state: ${options[stateKey]}`);\n }\n });\n\n accessibilityValueKeys.forEach((valueKey) => {\n if (options?.value?.[valueKey] !== undefined) {\n params.push(`${valueKey} value: ${options?.value?.[valueKey]}`);\n }\n });\n\n return params.join(', ');\n};\n\nconst getMultipleError = (role: TextMatch, options?: ByRoleOptions) =>\n `Found multiple elements with ${formatQueryParams(role, options)}`;\n\nconst getMissingError = (role: TextMatch, options?: ByRoleOptions) =>\n `Unable to find an element with ${formatQueryParams(role, options)}`;\n\nconst { getBy, getAllBy, queryBy, queryAllBy, findBy, findAllBy } = makeQueries(\n queryAllByRole,\n getMissingError,\n getMultipleError,\n);\n\nexport type ByRoleQueries = {\n getByRole: GetByQuery<ByRoleMatcher, ByRoleOptions>;\n getAllByRole: GetAllByQuery<ByRoleMatcher, ByRoleOptions>;\n queryByRole: QueryByQuery<ByRoleMatcher, ByRoleOptions>;\n queryAllByRole: QueryAllByQuery<ByRoleMatcher, ByRoleOptions>;\n findByRole: FindByQuery<ByRoleMatcher, ByRoleOptions>;\n findAllByRole: FindAllByQuery<ByRoleMatcher, ByRoleOptions>;\n};\n\nexport const bindByRoleQueries = (element: HostElement): ByRoleQueries => ({\n getByRole: getBy(element),\n getAllByRole: getAllBy(element),\n queryByRole: queryBy(element),\n queryAllByRole: queryAllBy(element),\n findByRole: findBy(element),\n findAllByRole: findAllBy(element),\n});\n"],"mappings":";;;;;;AAGA,IAAAA,cAAA,GAAAC,OAAA;AAQA,IAAAC,QAAA,GAAAD,OAAA;AAEA,IAAAE,wBAAA,GAAAF,OAAA;AAEA,IAAAG,wBAAA,GAAAH,OAAA;AACA,IAAAI,gBAAA,GAAAJ,OAAA;AACA,IAAAK,QAAA,GAAAL,OAAA;AAEA,IAAAM,OAAA,GAAAN,OAAA;AASA,IAAAO,YAAA,GAAAP,OAAA;AAWA,MAAMQ,2BAA2B,GAAGA,CAACC,IAAiB,EAAEC,IAAgB,KAAK;EAC3E,IAAIA,IAAI,IAAI,IAAI,EAAE,OAAO,IAAI;;EAE7B;EACA,MAAMC,cAAc,GAAG,IAAAC,oCAAqB,EAACH,IAAI,CAAC;EAClD,IAAI,IAAAI,gBAAO,EAACH,IAAI,EAAEC,cAAc,CAAC,EAAE;IACjC,OAAO,IAAI;EACb;EAEA,MAAM;IAAEG,cAAc;IAAEC;EAAoB,CAAC,GAAG,IAAAC,4BAAoB,EAACP,IAAI,CAAC;EAC1E,OAAOK,cAAc,CAACJ,IAAI,CAAC,CAACO,MAAM,GAAG,CAAC,IAAIF,mBAAmB,CAACL,IAAI,CAAC,CAACO,MAAM,GAAG,CAAC;AAChF,CAAC;AAED,MAAMC,4BAA4B,GAAGA,CAACT,IAAiB,EAAEU,OAAuB,KAAK;EACnF,OAAOA,OAAO,IAAI,IAAI,GAAG,IAAAC,gDAAuB,EAACX,IAAI,EAAEU,OAAO,CAAC,GAAG,IAAI;AACxE,CAAC;AAED,MAAME,+BAA+B,GAAGA,CAACZ,IAAiB,EAAEa,KAAiC,KAAK;EAChG,OAAOA,KA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xB,OAAO,EAAEG,KAAK,GAAGqB,QAAQ,CAAC,KAAKF,SAAS,EAAE;MAC5CN,MAAM,CAACE,IAAI,CAAC,GAAGM,QAAQ,WAAWxB,OAAO,EAAEG,KAAK,GAAGqB,QAAQ,CAAC,EAAE,CAAC;IACjE;EACF,CAAC,CAAC;EAEF,OAAOR,MAAM,CAACS,IAAI,CAAC,IAAI,CAAC;AAC1B,CAAC;AAED,MAAMC,gBAAgB,GAAGA,CAAClB,IAAe,EAAER,OAAuB,KAChE,gCAAgCe,iBAAiB,CAACP,IAAI,EAAER,OAAO,CAAC,EAAE;AAEpE,MAAM2B,eAAe,GAAGA,CAACnB,IAAe,EAAER,OAAuB,KAC/D,kCAAkCe,iBAAiB,CAACP,IAAI,EAAER,OAAO,CAAC,EAAE;AAEtE,MAAM;EAAE4B,KAAK;EAAEC,QAAQ;EAAEC,OAAO;EAAEC,UAAU;EAAEC,MAAM;EAAEC;AAAU,CAAC,GAAG,IAAAC,wBAAW,EAC7E7B,cAAc,EACdsB,eAAe,EACfD,gBACF,CAAC;AAWM,MAAMS,iBAAiB,GAAI7B,OAAoB,KAAqB;EACzE8B,SAAS,EAAER,KAAK,CAACtB,OAAO,CAAC;EACzB+B,YAAY,EAAER,QAAQ,CAACvB,OAAO,CAAC;EAC/BgC,WAAW,EAAER,OAAO,CAACxB,OAAO,CAAC;EAC7BD,cAAc,EAAE0B,UAAU,CAACzB,OAAO,CAAC;EACnCiC,UAAU,EAAEP,MAAM,CAAC1B,OAAO,CAAC;EAC3BkC,aAAa,EAAEP,SAAS,CAAC3B,OAAO;AAClC,CAAC,CAAC;AAACmC,OAAA,CAAAN,iBAAA,GAAAA,iBAAA","ignoreList":[]}
|
|
@@ -11,5 +11,5 @@ export type ByTestIdQueries = {
|
|
|
11
11
|
findByTestId: FindByQuery<TextMatch, ByTestIdOptions>;
|
|
12
12
|
findAllByTestId: FindAllByQuery<TextMatch, ByTestIdOptions>;
|
|
13
13
|
};
|
|
14
|
-
export declare const bindByTestIdQueries: (
|
|
14
|
+
export declare const bindByTestIdQueries: (element: HostElement) => ByTestIdQueries;
|
|
15
15
|
export {};
|
package/build/queries/test-id.js
CHANGED
|
@@ -14,8 +14,8 @@ const matchTestId = (node, testId, options = {}) => {
|
|
|
14
14
|
} = options;
|
|
15
15
|
return (0, _matches.matches)(testId, node.props.testID, normalizer, exact);
|
|
16
16
|
};
|
|
17
|
-
const queryAllByTestId =
|
|
18
|
-
return (0, _findAll.findAll)(
|
|
17
|
+
const queryAllByTestId = element => function queryAllByTestIdFn(testId, queryOptions) {
|
|
18
|
+
return (0, _findAll.findAll)(element, node => matchTestId(node, testId, queryOptions), queryOptions);
|
|
19
19
|
};
|
|
20
20
|
const getMultipleError = testId => `Found multiple elements with testID: ${String(testId)}`;
|
|
21
21
|
const getMissingError = testId => `Unable to find an element with testID: ${String(testId)}`;
|
|
@@ -27,13 +27,13 @@ const {
|
|
|
27
27
|
findBy,
|
|
28
28
|
findAllBy
|
|
29
29
|
} = (0, _makeQueries.makeQueries)(queryAllByTestId, getMissingError, getMultipleError);
|
|
30
|
-
const bindByTestIdQueries =
|
|
31
|
-
getByTestId: getBy(
|
|
32
|
-
getAllByTestId: getAllBy(
|
|
33
|
-
queryByTestId: queryBy(
|
|
34
|
-
queryAllByTestId: queryAllBy(
|
|
35
|
-
findByTestId: findBy(
|
|
36
|
-
findAllByTestId: findAllBy(
|
|
30
|
+
const bindByTestIdQueries = element => ({
|
|
31
|
+
getByTestId: getBy(element),
|
|
32
|
+
getAllByTestId: getAllBy(element),
|
|
33
|
+
queryByTestId: queryBy(element),
|
|
34
|
+
queryAllByTestId: queryAllBy(element),
|
|
35
|
+
findByTestId: findBy(element),
|
|
36
|
+
findAllByTestId: findAllBy(element)
|
|
37
37
|
});
|
|
38
38
|
exports.bindByTestIdQueries = bindByTestIdQueries;
|
|
39
39
|
//# sourceMappingURL=test-id.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"test-id.js","names":["_findAll","require","_matches","_makeQueries","matchTestId","node","testId","options","exact","normalizer","matches","props","testID","queryAllByTestId","
|
|
1
|
+
{"version":3,"file":"test-id.js","names":["_findAll","require","_matches","_makeQueries","matchTestId","node","testId","options","exact","normalizer","matches","props","testID","queryAllByTestId","element","queryAllByTestIdFn","queryOptions","findAll","getMultipleError","String","getMissingError","getBy","getAllBy","queryBy","queryAllBy","findBy","findAllBy","makeQueries","bindByTestIdQueries","getByTestId","getAllByTestId","queryByTestId","findByTestId","findAllByTestId","exports"],"sources":["../../src/queries/test-id.ts"],"sourcesContent":["import type { HostElement } from 'universal-test-renderer';\n\nimport { findAll } from '../helpers/find-all';\nimport type { TextMatch, TextMatchOptions } from '../matches';\nimport { matches } from '../matches';\nimport type {\n FindAllByQuery,\n FindByQuery,\n GetAllByQuery,\n GetByQuery,\n QueryAllByQuery,\n QueryByQuery,\n} from './make-queries';\nimport { makeQueries } from './make-queries';\nimport type { CommonQueryOptions } from './options';\n\ntype ByTestIdOptions = CommonQueryOptions & TextMatchOptions;\n\nconst matchTestId = (node: HostElement, testId: TextMatch, options: TextMatchOptions = {}) => {\n const { exact, normalizer } = options;\n return matches(testId, node.props.testID, normalizer, exact);\n};\n\nconst queryAllByTestId = (element: HostElement): QueryAllByQuery<TextMatch, ByTestIdOptions> =>\n function queryAllByTestIdFn(testId, queryOptions) {\n return findAll(element, (node) => matchTestId(node, testId, queryOptions), queryOptions);\n };\n\nconst getMultipleError = (testId: TextMatch) =>\n `Found multiple elements with testID: ${String(testId)}`;\nconst getMissingError = (testId: TextMatch) =>\n `Unable to find an element with testID: ${String(testId)}`;\n\nconst { getBy, getAllBy, queryBy, queryAllBy, findBy, findAllBy } = makeQueries(\n queryAllByTestId,\n getMissingError,\n getMultipleError,\n);\n\nexport type ByTestIdQueries = {\n getByTestId: GetByQuery<TextMatch, ByTestIdOptions>;\n getAllByTestId: GetAllByQuery<TextMatch, ByTestIdOptions>;\n queryByTestId: QueryByQuery<TextMatch, ByTestIdOptions>;\n queryAllByTestId: QueryAllByQuery<TextMatch, ByTestIdOptions>;\n findByTestId: FindByQuery<TextMatch, ByTestIdOptions>;\n findAllByTestId: FindAllByQuery<TextMatch, ByTestIdOptions>;\n};\n\nexport const bindByTestIdQueries = (element: HostElement): ByTestIdQueries => ({\n getByTestId: getBy(element),\n getAllByTestId: getAllBy(element),\n queryByTestId: queryBy(element),\n queryAllByTestId: queryAllBy(element),\n findByTestId: findBy(element),\n findAllByTestId: findAllBy(element),\n});\n"],"mappings":";;;;;;AAEA,IAAAA,QAAA,GAAAC,OAAA;AAEA,IAAAC,QAAA,GAAAD,OAAA;AASA,IAAAE,YAAA,GAAAF,OAAA;AAKA,MAAMG,WAAW,GAAGA,CAACC,IAAiB,EAAEC,MAAiB,EAAEC,OAAyB,GAAG,CAAC,CAAC,KAAK;EAC5F,MAAM;IAAEC,KAAK;IAAEC;EAAW,CAAC,GAAGF,OAAO;EACrC,OAAO,IAAAG,gBAAO,EAACJ,MAAM,EAAED,IAAI,CAACM,KAAK,CAACC,MAAM,EAAEH,UAAU,EAAED,KAAK,CAAC;AAC9D,CAAC;AAED,MAAMK,gBAAgB,GAAIC,OAAoB,IAC5C,SAASC,kBAAkBA,CAACT,MAAM,EAAEU,YAAY,EAAE;EAChD,OAAO,IAAAC,gBAAO,EAACH,OAAO,EAAGT,IAAI,IAAKD,WAAW,CAACC,IAAI,EAAEC,MAAM,EAAEU,YAAY,CAAC,EAAEA,YAAY,CAAC;AAC1F,CAAC;AAEH,MAAME,gBAAgB,GAAIZ,MAAiB,IACzC,wCAAwCa,MAAM,CAACb,MAAM,CAAC,EAAE;AAC1D,MAAMc,eAAe,GAAId,MAAiB,IACxC,0CAA0Ca,MAAM,CAACb,MAAM,CAAC,EAAE;AAE5D,MAAM;EAAEe,KAAK;EAAEC,QAAQ;EAAEC,OAAO;EAAEC,UAAU;EAAEC,MAAM;EAAEC;AAAU,CAAC,GAAG,IAAAC,wBAAW,EAC7Ed,gBAAgB,EAChBO,eAAe,EACfF,gBACF,CAAC;AAWM,MAAMU,mBAAmB,GAAId,OAAoB,KAAuB;EAC7Ee,WAAW,EAAER,KAAK,CAACP,OAAO,CAAC;EAC3BgB,cAAc,EAAER,QAAQ,CAACR,OAAO,CAAC;EACjCiB,aAAa,EAAER,OAAO,CAACT,OAAO,CAAC;EAC/BD,gBAAgB,EAAEW,UAAU,CAACV,OAAO,CAAC;EACrCkB,YAAY,EAAEP,MAAM,CAACX,OAAO,CAAC;EAC7BmB,eAAe,EAAEP,SAAS,CAACZ,OAAO;AACpC,CAAC,CAAC;AAACoB,OAAA,CAAAN,mBAAA,GAAAA,mBAAA","ignoreList":[]}
|
package/build/queries/text.d.ts
CHANGED
|
@@ -11,5 +11,5 @@ export type ByTextQueries = {
|
|
|
11
11
|
findByText: FindByQuery<TextMatch, ByTextOptions>;
|
|
12
12
|
findAllByText: FindAllByQuery<TextMatch, ByTextOptions>;
|
|
13
13
|
};
|
|
14
|
-
export declare const bindByTextQueries: (
|
|
14
|
+
export declare const bindByTextQueries: (element: HostElement) => ByTextQueries;
|
|
15
15
|
export {};
|
package/build/queries/text.js
CHANGED
|
@@ -8,8 +8,8 @@ var _findAll = require("../helpers/find-all");
|
|
|
8
8
|
var _hostComponentNames = require("../helpers/host-component-names");
|
|
9
9
|
var _matchTextContent = require("../helpers/matchers/match-text-content");
|
|
10
10
|
var _makeQueries = require("./make-queries");
|
|
11
|
-
const queryAllByText =
|
|
12
|
-
return (0, _findAll.findAll)(
|
|
11
|
+
const queryAllByText = element => function queryAllByTextFn(text, options = {}) {
|
|
12
|
+
return (0, _findAll.findAll)(element, node => (0, _hostComponentNames.isHostText)(node) && (0, _matchTextContent.matchTextContent)(node, text, options), {
|
|
13
13
|
...options,
|
|
14
14
|
matchDeepestOnly: true
|
|
15
15
|
});
|
|
@@ -24,13 +24,13 @@ const {
|
|
|
24
24
|
findBy,
|
|
25
25
|
findAllBy
|
|
26
26
|
} = (0, _makeQueries.makeQueries)(queryAllByText, getMissingError, getMultipleError);
|
|
27
|
-
const bindByTextQueries =
|
|
28
|
-
getByText: getBy(
|
|
29
|
-
getAllByText: getAllBy(
|
|
30
|
-
queryByText: queryBy(
|
|
31
|
-
queryAllByText: queryAllBy(
|
|
32
|
-
findByText: findBy(
|
|
33
|
-
findAllByText: findAllBy(
|
|
27
|
+
const bindByTextQueries = element => ({
|
|
28
|
+
getByText: getBy(element),
|
|
29
|
+
getAllByText: getAllBy(element),
|
|
30
|
+
queryByText: queryBy(element),
|
|
31
|
+
queryAllByText: queryAllBy(element),
|
|
32
|
+
findByText: findBy(element),
|
|
33
|
+
findAllByText: findAllBy(element)
|
|
34
34
|
});
|
|
35
35
|
exports.bindByTextQueries = bindByTextQueries;
|
|
36
36
|
//# sourceMappingURL=text.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"text.js","names":["_findAll","require","_hostComponentNames","_matchTextContent","_makeQueries","queryAllByText","
|
|
1
|
+
{"version":3,"file":"text.js","names":["_findAll","require","_hostComponentNames","_matchTextContent","_makeQueries","queryAllByText","element","queryAllByTextFn","text","options","findAll","node","isHostText","matchTextContent","matchDeepestOnly","getMultipleError","String","getMissingError","getBy","getAllBy","queryBy","queryAllBy","findBy","findAllBy","makeQueries","bindByTextQueries","getByText","getAllByText","queryByText","findByText","findAllByText","exports"],"sources":["../../src/queries/text.ts"],"sourcesContent":["import type { HostElement } from 'universal-test-renderer';\n\nimport { findAll } from '../helpers/find-all';\nimport { isHostText } from '../helpers/host-component-names';\nimport { matchTextContent } from '../helpers/matchers/match-text-content';\nimport type { TextMatch, TextMatchOptions } from '../matches';\nimport type {\n FindAllByQuery,\n FindByQuery,\n GetAllByQuery,\n GetByQuery,\n QueryAllByQuery,\n QueryByQuery,\n} from './make-queries';\nimport { makeQueries } from './make-queries';\nimport type { CommonQueryOptions } from './options';\n\ntype ByTextOptions = CommonQueryOptions & TextMatchOptions;\n\nconst queryAllByText = (element: HostElement): QueryAllByQuery<TextMatch, ByTextOptions> =>\n function queryAllByTextFn(text, options = {}) {\n return findAll(element, (node) => isHostText(node) && matchTextContent(node, text, options), {\n ...options,\n matchDeepestOnly: true,\n });\n };\n\nconst getMultipleError = (text: TextMatch) => `Found multiple elements with text: ${String(text)}`;\n\nconst getMissingError = (text: TextMatch) => `Unable to find an element with text: ${String(text)}`;\n\nconst { getBy, getAllBy, queryBy, queryAllBy, findBy, findAllBy } = makeQueries(\n queryAllByText,\n getMissingError,\n getMultipleError,\n);\n\nexport type ByTextQueries = {\n getByText: GetByQuery<TextMatch, ByTextOptions>;\n getAllByText: GetAllByQuery<TextMatch, ByTextOptions>;\n queryByText: QueryByQuery<TextMatch, ByTextOptions>;\n queryAllByText: QueryAllByQuery<TextMatch, ByTextOptions>;\n findByText: FindByQuery<TextMatch, ByTextOptions>;\n findAllByText: FindAllByQuery<TextMatch, ByTextOptions>;\n};\n\nexport const bindByTextQueries = (element: HostElement): ByTextQueries => ({\n getByText: getBy(element),\n getAllByText: getAllBy(element),\n queryByText: queryBy(element),\n queryAllByText: queryAllBy(element),\n findByText: findBy(element),\n findAllByText: findAllBy(element),\n});\n"],"mappings":";;;;;;AAEA,IAAAA,QAAA,GAAAC,OAAA;AACA,IAAAC,mBAAA,GAAAD,OAAA;AACA,IAAAE,iBAAA,GAAAF,OAAA;AAUA,IAAAG,YAAA,GAAAH,OAAA;AAKA,MAAMI,cAAc,GAAIC,OAAoB,IAC1C,SAASC,gBAAgBA,CAACC,IAAI,EAAEC,OAAO,GAAG,CAAC,CAAC,EAAE;EAC5C,OAAO,IAAAC,gBAAO,EAACJ,OAAO,EAAGK,IAAI,IAAK,IAAAC,8BAAU,EAACD,IAAI,CAAC,IAAI,IAAAE,kCAAgB,EAACF,IAAI,EAAEH,IAAI,EAAEC,OAAO,CAAC,EAAE;IAC3F,GAAGA,OAAO;IACVK,gBAAgB,EAAE;EACpB,CAAC,CAAC;AACJ,CAAC;AAEH,MAAMC,gBAAgB,GAAIP,IAAe,IAAK,sCAAsCQ,MAAM,CAACR,IAAI,CAAC,EAAE;AAElG,MAAMS,eAAe,GAAIT,IAAe,IAAK,wCAAwCQ,MAAM,CAACR,IAAI,CAAC,EAAE;AAEnG,MAAM;EAAEU,KAAK;EAAEC,QAAQ;EAAEC,OAAO;EAAEC,UAAU;EAAEC,MAAM;EAAEC;AAAU,CAAC,GAAG,IAAAC,wBAAW,EAC7EnB,cAAc,EACdY,eAAe,EACfF,gBACF,CAAC;AAWM,MAAMU,iBAAiB,GAAInB,OAAoB,KAAqB;EACzEoB,SAAS,EAAER,KAAK,CAACZ,OAAO,CAAC;EACzBqB,YAAY,EAAER,QAAQ,CAACb,OAAO,CAAC;EAC/BsB,WAAW,EAAER,OAAO,CAACd,OAAO,CAAC;EAC7BD,cAAc,EAAEgB,UAAU,CAACf,OAAO,CAAC;EACnCuB,UAAU,EAAEP,MAAM,CAAChB,OAAO,CAAC;EAC3BwB,aAAa,EAAEP,SAAS,CAACjB,OAAO;AAClC,CAAC,CAAC;AAACyB,OAAA,CAAAN,iBAAA,GAAAA,iBAAA","ignoreList":[]}
|
package/build/react-versions.js
CHANGED
|
@@ -5,8 +5,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.checkReactVersionAtLeast = checkReactVersionAtLeast;
|
|
7
7
|
var React = _interopRequireWildcard(require("react"));
|
|
8
|
-
function
|
|
9
|
-
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
8
|
+
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
|
|
10
9
|
function checkReactVersionAtLeast(major, minor) {
|
|
11
10
|
if (React.version === undefined) return false;
|
|
12
11
|
const [actualMajor, actualMinor] = React.version.split('.').map(Number);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"react-versions.js","names":["React","_interopRequireWildcard","require","
|
|
1
|
+
{"version":3,"file":"react-versions.js","names":["React","_interopRequireWildcard","require","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","default","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","checkReactVersionAtLeast","major","minor","version","undefined","actualMajor","actualMinor","split","map","Number"],"sources":["../src/react-versions.ts"],"sourcesContent":["import * as React from 'react';\n\nexport function checkReactVersionAtLeast(major: number, minor: number): boolean {\n if (React.version === undefined) return false;\n const [actualMajor, actualMinor] = React.version.split('.').map(Number);\n\n return actualMajor > major || (actualMajor === major && actualMinor >= minor);\n}\n"],"mappings":";;;;;;AAAA,IAAAA,KAAA,GAAAC,uBAAA,CAAAC,OAAA;AAA+B,SAAAD,wBAAAE,CAAA,EAAAC,CAAA,6BAAAC,OAAA,MAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAJ,uBAAA,YAAAA,CAAAE,CAAA,EAAAC,CAAA,SAAAA,CAAA,IAAAD,CAAA,IAAAA,CAAA,CAAAK,UAAA,SAAAL,CAAA,MAAAM,CAAA,EAAAC,CAAA,EAAAC,CAAA,KAAAC,SAAA,QAAAC,OAAA,EAAAV,CAAA,iBAAAA,CAAA,uBAAAA,CAAA,yBAAAA,CAAA,SAAAQ,CAAA,MAAAF,CAAA,GAAAL,CAAA,GAAAG,CAAA,GAAAD,CAAA,QAAAG,CAAA,CAAAK,GAAA,CAAAX,CAAA,UAAAM,CAAA,CAAAM,GAAA,CAAAZ,CAAA,GAAAM,CAAA,CAAAO,GAAA,CAAAb,CAAA,EAAAQ,CAAA,gBAAAP,CAAA,IAAAD,CAAA,gBAAAC,CAAA,OAAAa,cAAA,CAAAC,IAAA,CAAAf,CAAA,EAAAC,CAAA,OAAAM,CAAA,IAAAD,CAAA,GAAAU,MAAA,CAAAC,cAAA,KAAAD,MAAA,CAAAE,wBAAA,CAAAlB,CAAA,EAAAC,CAAA,OAAAM,CAAA,CAAAK,GAAA,IAAAL,CAAA,CAAAM,GAAA,IAAAP,CAAA,CAAAE,CAAA,EAAAP,CAAA,EAAAM,CAAA,IAAAC,CAAA,CAAAP,CAAA,IAAAD,CAAA,CAAAC,CAAA,WAAAO,CAAA,KAAAR,CAAA,EAAAC,CAAA;AAExB,SAASkB,wBAAwBA,CAACC,KAAa,EAAEC,KAAa,EAAW;EAC9E,IAAIxB,KAAK,CAACyB,OAAO,KAAKC,SAAS,EAAE,OAAO,KAAK;EAC7C,MAAM,CAACC,WAAW,EAAEC,WAAW,CAAC,GAAG5B,KAAK,CAACyB,OAAO,CAACI,KAAK,CAAC,GAAG,CAAC,CAACC,GAAG,CAACC,MAAM,CAAC;EAEvE,OAAOJ,WAAW,GAAGJ,KAAK,IAAKI,WAAW,KAAKJ,KAAK,IAAIK,WAAW,IAAIJ,KAAM;AAC/E","ignoreList":[]}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { Root, RootOptions } from 'universal-test-renderer';
|
|
2
|
+
export declare function renderWithAct(element: React.ReactElement, options?: RootOptions): Root;
|
|
3
|
+
export declare function renderWithAsyncAct(element: React.ReactElement, options?: RootOptions): Promise<Root>;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.renderWithAct = renderWithAct;
|
|
7
|
+
exports.renderWithAsyncAct = renderWithAsyncAct;
|
|
8
|
+
var _universalTestRenderer = require("universal-test-renderer");
|
|
9
|
+
var _act = _interopRequireDefault(require("./act"));
|
|
10
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
11
|
+
function renderWithAct(element, options) {
|
|
12
|
+
const root = (0, _universalTestRenderer.createRoot)(options);
|
|
13
|
+
|
|
14
|
+
// This will be called synchronously.
|
|
15
|
+
void (0, _act.default)(() => {
|
|
16
|
+
root.render(element);
|
|
17
|
+
});
|
|
18
|
+
return root;
|
|
19
|
+
}
|
|
20
|
+
async function renderWithAsyncAct(element, options) {
|
|
21
|
+
const root = (0, _universalTestRenderer.createRoot)(options);
|
|
22
|
+
|
|
23
|
+
// eslint-disable-next-line require-await
|
|
24
|
+
await (0, _act.default)(async () => {
|
|
25
|
+
root.render(element);
|
|
26
|
+
});
|
|
27
|
+
return root;
|
|
28
|
+
}
|
|
29
|
+
//# sourceMappingURL=render-act.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"render-act.js","names":["_universalTestRenderer","require","_act","_interopRequireDefault","e","__esModule","default","renderWithAct","element","options","root","createRoot","act","render","renderWithAsyncAct"],"sources":["../src/render-act.ts"],"sourcesContent":["import type { Root, RootOptions } from 'universal-test-renderer';\nimport { createRoot } from 'universal-test-renderer';\n\nimport act from './act';\n\nexport function renderWithAct(element: React.ReactElement, options?: RootOptions): Root {\n const root = createRoot(options);\n\n // This will be called synchronously.\n void act(() => {\n root.render(element);\n });\n\n return root;\n}\n\nexport async function renderWithAsyncAct(\n element: React.ReactElement,\n options?: RootOptions,\n): Promise<Root> {\n const root = createRoot(options);\n\n // eslint-disable-next-line require-await\n await act(async () => {\n root.render(element);\n });\n\n return root;\n}\n"],"mappings":";;;;;;;AACA,IAAAA,sBAAA,GAAAC,OAAA;AAEA,IAAAC,IAAA,GAAAC,sBAAA,CAAAF,OAAA;AAAwB,SAAAE,uBAAAC,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAEjB,SAASG,aAAaA,CAACC,OAA2B,EAAEC,OAAqB,EAAQ;EACtF,MAAMC,IAAI,GAAG,IAAAC,iCAAU,EAACF,OAAO,CAAC;;EAEhC;EACA,KAAK,IAAAG,YAAG,EAAC,MAAM;IACbF,IAAI,CAACG,MAAM,CAACL,OAAO,CAAC;EACtB,CAAC,CAAC;EAEF,OAAOE,IAAI;AACb;AAEO,eAAeI,kBAAkBA,CACtCN,OAA2B,EAC3BC,OAAqB,EACN;EACf,MAAMC,IAAI,GAAG,IAAAC,iCAAU,EAACF,OAAO,CAAC;;EAEhC;EACA,MAAM,IAAAG,YAAG,EAAC,YAAY;IACpBF,IAAI,CAACG,MAAM,CAACL,OAAO,CAAC;EACtB,CAAC,CAAC;EAEF,OAAOE,IAAI;AACb","ignoreList":[]}
|