@testing-library/react-native 12.4.2 → 12.4.4
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 +18 -12
- package/build/act.d.ts +1 -1
- package/build/act.js.map +1 -1
- package/build/fire-event.js.map +1 -1
- package/build/helpers/accessiblity.js.map +1 -1
- package/build/helpers/component-tree.js.map +1 -1
- package/build/helpers/debug-deep.js.map +1 -1
- package/build/helpers/debug-shallow.js.map +1 -1
- package/build/helpers/deprecation.js.map +1 -1
- package/build/helpers/errors.js.map +1 -1
- package/build/helpers/find-all.js.map +1 -1
- package/build/helpers/format-default.js.map +1 -1
- package/build/helpers/format.js.map +1 -1
- package/build/helpers/host-component-names.js.map +1 -1
- package/build/helpers/matchers/match-accessibility-state.js +1 -0
- package/build/helpers/matchers/match-accessibility-state.js.map +1 -1
- package/build/helpers/matchers/match-accessibility-value.js.map +1 -1
- package/build/helpers/matchers/match-array-prop.js.map +1 -1
- package/build/helpers/matchers/match-label-text.js.map +1 -1
- package/build/helpers/matchers/match-object-prop.js.map +1 -1
- package/build/helpers/matchers/match-string-prop.js.map +1 -1
- package/build/helpers/matchers/match-text-content.js.map +1 -1
- package/build/helpers/pointer-events.js.map +1 -1
- package/build/helpers/string-validation.js.map +1 -1
- package/build/helpers/text-content.js.map +1 -1
- package/build/helpers/text-input.js.map +1 -1
- package/build/helpers/timers.js.map +1 -1
- package/build/helpers/wrap-async.js.map +1 -1
- package/build/index.flow.js +41 -149
- package/build/matchers/to-be-busy.js.map +1 -1
- package/build/matchers/to-be-checked.js.map +1 -1
- package/build/matchers/to-be-collapsed.js.map +1 -1
- package/build/matchers/to-be-disabled.js.map +1 -1
- package/build/matchers/to-be-empty-element.js.map +1 -1
- package/build/matchers/to-be-expanded.js.map +1 -1
- package/build/matchers/to-be-on-the-screen.js.map +1 -1
- package/build/matchers/to-be-partially-checked.js.map +1 -1
- package/build/matchers/to-be-selected.js.map +1 -1
- package/build/matchers/to-be-visible.js.map +1 -1
- package/build/matchers/to-contain-element.js.map +1 -1
- package/build/matchers/to-have-accessibility-value.js.map +1 -1
- package/build/matchers/to-have-accessible-name.js.map +1 -1
- package/build/matchers/to-have-display-value.js.map +1 -1
- package/build/matchers/to-have-prop.js.map +1 -1
- package/build/matchers/to-have-style.js.map +1 -1
- package/build/matchers/to-have-text-content.js.map +1 -1
- package/build/matchers/types.d.ts +233 -1
- package/build/matchers/types.js.map +1 -1
- package/build/matchers/utils.js.map +1 -1
- package/build/matches.js.map +1 -1
- package/build/pure.d.ts +1 -1
- package/build/pure.js.map +1 -1
- package/build/queries/accessibility-state.js.map +1 -1
- package/build/queries/accessibility-value.js.map +1 -1
- package/build/queries/display-value.js.map +1 -1
- package/build/queries/hint-text.js.map +1 -1
- package/build/queries/label-text.js.map +1 -1
- package/build/queries/make-queries.js.map +1 -1
- package/build/queries/placeholder-text.js.map +1 -1
- package/build/queries/role.js.map +1 -1
- package/build/queries/test-id.js.map +1 -1
- package/build/queries/text.js.map +1 -1
- package/build/queries/unsafe-props.js.map +1 -1
- package/build/queries/unsafe-type.js.map +1 -1
- package/build/react-versions.js.map +1 -1
- package/build/render-act.d.ts +0 -1
- package/build/render-act.js.map +1 -1
- package/build/render-hook.js.map +1 -1
- package/build/render.js.map +1 -1
- package/build/shallow.js.map +1 -1
- package/build/user-event/clear.js.map +1 -1
- package/build/user-event/event-builder/common.d.ts +6 -7
- package/build/user-event/event-builder/common.js +2 -2
- package/build/user-event/event-builder/common.js.map +1 -1
- package/build/user-event/event-builder/index.d.ts +6 -7
- package/build/user-event/event-builder/scroll-view.js.map +1 -1
- package/build/user-event/press/press.js.map +1 -1
- package/build/user-event/scroll/scroll-to.js.map +1 -1
- package/build/user-event/scroll/state.js.map +1 -1
- package/build/user-event/scroll/utils.js.map +1 -1
- package/build/user-event/setup/setup.js.map +1 -1
- package/build/user-event/type/type.js.map +1 -1
- package/build/user-event/utils/dispatch-event.js.map +1 -1
- package/build/user-event/utils/wait.js.map +1 -1
- package/build/user-event/utils/warn-about-real-timers.js +3 -0
- package/build/user-event/utils/warn-about-real-timers.js.map +1 -1
- package/build/wait-for-element-to-be-removed.js.map +1 -1
- package/build/wait-for.js.map +1 -1
- package/package.json +13 -13
- package/typings/index.flow.js +41 -149
|
@@ -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","exports","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'
|
|
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","exports","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' ? { legacyFakeTimers: true } : { legacyFakeTimers: false };\n}\n\nconst jestFakeTimersAreEnabled = (): boolean => 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,iBAAiBA,CAAIC,QAAiB,EAAK;EAClD,MAAMC,cAAc,GAAGC,qBAAqB,CAAC,CAAC;EAC9C,IAAID,cAAc,EAAE;IAClBE,IAAI,CAACC,aAAa,CAAC,CAAC;EACtB;EAEA,MAAMC,mBAAmB,GAAGL,QAAQ,CAAC,CAAC;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,qBAAqBA,CAAA,EAA2B;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,CAAC,CAAC;MACxB,OAAO,QAAQ;IACjB,CAAC,CAAC,MAAM;MACN;IAAA;EAEJ;EAEA,OAAO,IAAI;AACb;AAEA,SAASR,2BAA2BA,CAACS,IAAqB,EAAE;EAC1D,OAAOA,IAAI,KAAK,QAAQ,GAAG;IAAEC,gBAAgB,EAAE;EAAK,CAAC,GAAG;IAAEA,gBAAgB,EAAE;EAAM,CAAC;AACrF;AAEA,MAAMC,wBAAwB,GAAGA,CAAA,KAAeC,OAAO,CAACjB,qBAAqB,CAAC,CAAC,CAAC;;AAEhF;AAAAkB,OAAA,CAAAF,wBAAA,GAAAA,wBAAA;AACA,SAASG,oBAAoBA,CAACC,EAAY,EAAE;EAC1C,OAAO1B,SAAS,CAACa,UAAU,CAACa,EAAE,EAAE,CAAC,CAAC;AACpC;AAQA,SAASC,iBAAiBA,CAAA,EAAsB;EAC9C,OAAO;IACLC,cAAc,EAAE5B,SAAS,CAAC6B,YAAY;IACtCC,cAAc,EAAE9B,SAAS,CAAC+B,YAAY,IAAIN,oBAAoB;IAC9DO,YAAY,EAAEhC,SAAS,CAACa;EAC1B,CAAC;AACH;AAEA,MAAM;EAAEe,cAAc;EAAEE,cAAc;EAAEE;AAAa,CAAC,GAAG7B,iBAAiB,CACxEwB,iBACF,CAAsB;AAACH,OAAA,CAAAX,UAAA,GAAAmB,YAAA;AAAAR,OAAA,CAAAO,YAAA,GAAAD,cAAA;AAAAN,OAAA,CAAAK,YAAA,GAAAD,cAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wrap-async.js","names":["_reactTestRenderer","require","_act","_flushMicroTasks","_reactVersions","wrapAsync","callback","checkReactVersionAtLeast","previousActEnvironment","getIsReactActEnvironment","setReactActEnvironment","result","flushMicroTasksLegacy","act"],"sources":["../../src/helpers/wrap-async.ts"],"sourcesContent":["/* istanbul ignore file */\n\nimport { act } from 'react-test-renderer';\nimport { getIsReactActEnvironment, setReactActEnvironment } from '../act';\nimport { flushMicroTasksLegacy } from '../flush-micro-tasks';\nimport { checkReactVersionAtLeast } from '../react-versions';\n\n/**\n * Run given async callback with temporarily disabled `act` environment and flushes microtasks queue.\n *\n * @param callback Async callback to run\n * @returns Result of the callback\n */\nexport async function wrapAsync<Result>(
|
|
1
|
+
{"version":3,"file":"wrap-async.js","names":["_reactTestRenderer","require","_act","_flushMicroTasks","_reactVersions","wrapAsync","callback","checkReactVersionAtLeast","previousActEnvironment","getIsReactActEnvironment","setReactActEnvironment","result","flushMicroTasksLegacy","act"],"sources":["../../src/helpers/wrap-async.ts"],"sourcesContent":["/* istanbul ignore file */\n\nimport { act } from 'react-test-renderer';\nimport { getIsReactActEnvironment, setReactActEnvironment } from '../act';\nimport { flushMicroTasksLegacy } from '../flush-micro-tasks';\nimport { checkReactVersionAtLeast } from '../react-versions';\n\n/**\n * Run given async callback with temporarily disabled `act` environment and flushes microtasks queue.\n *\n * @param callback Async callback to run\n * @returns Result of the callback\n */\nexport async function wrapAsync<Result>(callback: () => Promise<Result>): Promise<Result> {\n if (checkReactVersionAtLeast(18, 0)) {\n const previousActEnvironment = getIsReactActEnvironment();\n setReactActEnvironment(false);\n\n try {\n const result = await callback();\n // Flush the microtask queue before restoring the `act` environment\n await flushMicroTasksLegacy();\n return result;\n } finally {\n setReactActEnvironment(previousActEnvironment);\n }\n }\n\n if (!checkReactVersionAtLeast(16, 9)) {\n return callback();\n }\n\n // Wrapping with act for react version 16.9 to 17.x\n let result: Result;\n await act(async () => {\n result = await callback();\n });\n\n // Either we have result or `callback` threw error\n return result!;\n}\n"],"mappings":";;;;;;AAEA,IAAAA,kBAAA,GAAAC,OAAA;AACA,IAAAC,IAAA,GAAAD,OAAA;AACA,IAAAE,gBAAA,GAAAF,OAAA;AACA,IAAAG,cAAA,GAAAH,OAAA;AALA;;AAOA;AACA;AACA;AACA;AACA;AACA;AACO,eAAeI,SAASA,CAASC,QAA+B,EAAmB;EACxF,IAAI,IAAAC,uCAAwB,EAAC,EAAE,EAAE,CAAC,CAAC,EAAE;IACnC,MAAMC,sBAAsB,GAAG,IAAAC,6BAAwB,EAAC,CAAC;IACzD,IAAAC,2BAAsB,EAAC,KAAK,CAAC;IAE7B,IAAI;MACF,MAAMC,MAAM,GAAG,MAAML,QAAQ,CAAC,CAAC;MAC/B;MACA,MAAM,IAAAM,sCAAqB,EAAC,CAAC;MAC7B,OAAOD,MAAM;IACf,CAAC,SAAS;MACR,IAAAD,2BAAsB,EAACF,sBAAsB,CAAC;IAChD;EACF;EAEA,IAAI,CAAC,IAAAD,uCAAwB,EAAC,EAAE,EAAE,CAAC,CAAC,EAAE;IACpC,OAAOD,QAAQ,CAAC,CAAC;EACnB;;EAEA;EACA,IAAIK,MAAc;EAClB,MAAM,IAAAE,sBAAG,EAAC,YAAY;IACpBF,MAAM,GAAG,MAAML,QAAQ,CAAC,CAAC;EAC3B,CAAC,CAAC;;EAEF;EACA,OAAOK,MAAM;AACf"}
|
package/build/index.flow.js
CHANGED
|
@@ -74,27 +74,15 @@ type WaitForOptions = {
|
|
|
74
74
|
onTimeout?: (error: Error) => Error,
|
|
75
75
|
};
|
|
76
76
|
|
|
77
|
-
type WaitForFunction = <T = any>(
|
|
78
|
-
expectation: () => T,
|
|
79
|
-
options?: WaitForOptions
|
|
80
|
-
) => Promise<T>;
|
|
77
|
+
type WaitForFunction = <T = any>(expectation: () => T, options?: WaitForOptions) => Promise<T>;
|
|
81
78
|
|
|
82
79
|
type ByTextOptions = CommonQueryOptions & TextMatchOptions;
|
|
83
80
|
|
|
84
81
|
interface ByTextQueries {
|
|
85
82
|
getByText: (text: TextMatch, options?: ByTextOptions) => ReactTestInstance;
|
|
86
|
-
getAllByText: (
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
) => Array<ReactTestInstance>;
|
|
90
|
-
queryByText: (
|
|
91
|
-
name: TextMatch,
|
|
92
|
-
options?: ByTextOptions
|
|
93
|
-
) => ReactTestInstance | null;
|
|
94
|
-
queryAllByText: (
|
|
95
|
-
text: TextMatch,
|
|
96
|
-
options?: ByTextOptions
|
|
97
|
-
) => Array<ReactTestInstance> | [];
|
|
83
|
+
getAllByText: (text: TextMatch, options?: ByTextOptions) => Array<ReactTestInstance>;
|
|
84
|
+
queryByText: (name: TextMatch, options?: ByTextOptions) => ReactTestInstance | null;
|
|
85
|
+
queryAllByText: (text: TextMatch, options?: ByTextOptions) => Array<ReactTestInstance> | [];
|
|
98
86
|
findByText: (
|
|
99
87
|
text: TextMatch,
|
|
100
88
|
queryOptions?: ByTextOptions,
|
|
@@ -110,22 +98,10 @@ interface ByTextQueries {
|
|
|
110
98
|
type ByTestIdOptions = CommonQueryOptions & TextMatchOptions;
|
|
111
99
|
|
|
112
100
|
interface ByTestIdQueries {
|
|
113
|
-
getByTestId: (
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
) => ReactTestInstance;
|
|
117
|
-
getAllByTestId: (
|
|
118
|
-
testID: TextMatch,
|
|
119
|
-
options?: ByTestIdOptions
|
|
120
|
-
) => Array<ReactTestInstance>;
|
|
121
|
-
queryByTestId: (
|
|
122
|
-
testID: TextMatch,
|
|
123
|
-
options?: ByTestIdOptions
|
|
124
|
-
) => ReactTestInstance | null;
|
|
125
|
-
queryAllByTestId: (
|
|
126
|
-
testID: TextMatch,
|
|
127
|
-
options?: ByTestIdOptions
|
|
128
|
-
) => Array<ReactTestInstance> | [];
|
|
101
|
+
getByTestId: (testID: TextMatch, options?: ByTestIdOptions) => ReactTestInstance;
|
|
102
|
+
getAllByTestId: (testID: TextMatch, options?: ByTestIdOptions) => Array<ReactTestInstance>;
|
|
103
|
+
queryByTestId: (testID: TextMatch, options?: ByTestIdOptions) => ReactTestInstance | null;
|
|
104
|
+
queryAllByTestId: (testID: TextMatch, options?: ByTestIdOptions) => Array<ReactTestInstance> | [];
|
|
129
105
|
findByTestId: (
|
|
130
106
|
testID: TextMatch,
|
|
131
107
|
queryOptions?: ByTestIdOptions,
|
|
@@ -141,10 +117,7 @@ interface ByTestIdQueries {
|
|
|
141
117
|
type ByDisplayValueOptions = CommonQueryOptions & TextMatchOptions;
|
|
142
118
|
|
|
143
119
|
interface ByDisplayValueQueries {
|
|
144
|
-
getByDisplayValue: (
|
|
145
|
-
value: TextMatch,
|
|
146
|
-
options?: ByDisplayValueOptions
|
|
147
|
-
) => ReactTestInstance;
|
|
120
|
+
getByDisplayValue: (value: TextMatch, options?: ByDisplayValueOptions) => ReactTestInstance;
|
|
148
121
|
getAllByDisplayValue: (
|
|
149
122
|
value: TextMatch,
|
|
150
123
|
options?: ByDisplayValueOptions
|
|
@@ -202,24 +175,16 @@ interface ByPlaceholderTextQueries {
|
|
|
202
175
|
|
|
203
176
|
interface UnsafeByTypeQueries {
|
|
204
177
|
UNSAFE_getByType: <P>(type: React.ComponentType<P>) => ReactTestInstance;
|
|
205
|
-
UNSAFE_getAllByType: <P>(
|
|
206
|
-
|
|
207
|
-
) => Array<ReactTestInstance
|
|
208
|
-
UNSAFE_queryByType: <P>(
|
|
209
|
-
type: React.ComponentType<P>
|
|
210
|
-
) => ReactTestInstance | null;
|
|
211
|
-
UNSAFE_queryAllByType: <P>(
|
|
212
|
-
type: React.ComponentType<P>
|
|
213
|
-
) => Array<ReactTestInstance> | [];
|
|
178
|
+
UNSAFE_getAllByType: <P>(type: React.ComponentType<P>) => Array<ReactTestInstance>;
|
|
179
|
+
UNSAFE_queryByType: <P>(type: React.ComponentType<P>) => ReactTestInstance | null;
|
|
180
|
+
UNSAFE_queryAllByType: <P>(type: React.ComponentType<P>) => Array<ReactTestInstance> | [];
|
|
214
181
|
}
|
|
215
182
|
|
|
216
183
|
interface UnsafeByPropsQueries {
|
|
217
184
|
UNSAFE_getByProps: (props: { [string]: any }) => ReactTestInstance;
|
|
218
185
|
UNSAFE_getAllByProps: (props: { [string]: any }) => Array<ReactTestInstance>;
|
|
219
186
|
UNSAFE_queryByProps: (props: { [string]: any }) => ReactTestInstance | null;
|
|
220
|
-
UNSAFE_queryAllByProps: (props: { [string]: any }) =>
|
|
221
|
-
| Array<ReactTestInstance>
|
|
222
|
-
| [];
|
|
187
|
+
UNSAFE_queryAllByProps: (props: { [string]: any }) => Array<ReactTestInstance> | [];
|
|
223
188
|
}
|
|
224
189
|
|
|
225
190
|
type ByRoleOptions = CommonQueryOptions & {
|
|
@@ -233,22 +198,10 @@ type ByHintTextOptions = CommonQueryOptions & TextMatchOptions;
|
|
|
233
198
|
|
|
234
199
|
interface A11yAPI {
|
|
235
200
|
// Label
|
|
236
|
-
getByLabelText: (
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
) =>
|
|
240
|
-
getAllByLabelText: (
|
|
241
|
-
matcher: TextMatch,
|
|
242
|
-
options?: ByLabelTextOptions
|
|
243
|
-
) => GetAllReturn;
|
|
244
|
-
queryByLabelText: (
|
|
245
|
-
matcher: TextMatch,
|
|
246
|
-
options?: ByLabelTextOptions
|
|
247
|
-
) => QueryReturn;
|
|
248
|
-
queryAllByLabelText: (
|
|
249
|
-
matcher: TextMatch,
|
|
250
|
-
options?: ByLabelTextOptions
|
|
251
|
-
) => QueryAllReturn;
|
|
201
|
+
getByLabelText: (matcher: TextMatch, options?: ByLabelTextOptions) => GetReturn;
|
|
202
|
+
getAllByLabelText: (matcher: TextMatch, options?: ByLabelTextOptions) => GetAllReturn;
|
|
203
|
+
queryByLabelText: (matcher: TextMatch, options?: ByLabelTextOptions) => QueryReturn;
|
|
204
|
+
queryAllByLabelText: (matcher: TextMatch, options?: ByLabelTextOptions) => QueryAllReturn;
|
|
252
205
|
findByLabelText: (
|
|
253
206
|
matcher: TextMatch,
|
|
254
207
|
queryOptions?: ByLabelTextOptions,
|
|
@@ -263,30 +216,12 @@ interface A11yAPI {
|
|
|
263
216
|
// Hint
|
|
264
217
|
getByA11yHint: (matcher: TextMatch, options?: ByHintTextOptions) => GetReturn;
|
|
265
218
|
getByHintText: (matcher: TextMatch, options?: ByHintTextOptions) => GetReturn;
|
|
266
|
-
getAllByA11yHint: (
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
) =>
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
options?: ByHintTextOptions
|
|
273
|
-
) => GetAllReturn;
|
|
274
|
-
queryByA11yHint: (
|
|
275
|
-
matcher: TextMatch,
|
|
276
|
-
options?: ByHintTextOptions
|
|
277
|
-
) => QueryReturn;
|
|
278
|
-
queryByHintText: (
|
|
279
|
-
matcher: TextMatch,
|
|
280
|
-
options?: ByHintTextOptions
|
|
281
|
-
) => QueryReturn;
|
|
282
|
-
queryAllByA11yHint: (
|
|
283
|
-
matcher: TextMatch,
|
|
284
|
-
options?: ByHintTextOptions
|
|
285
|
-
) => QueryAllReturn;
|
|
286
|
-
queryAllByHintText: (
|
|
287
|
-
matcher: TextMatch,
|
|
288
|
-
options?: ByHintTextOptions
|
|
289
|
-
) => QueryAllReturn;
|
|
219
|
+
getAllByA11yHint: (matcher: TextMatch, options?: ByHintTextOptions) => GetAllReturn;
|
|
220
|
+
getAllByHintText: (matcher: TextMatch, options?: ByHintTextOptions) => GetAllReturn;
|
|
221
|
+
queryByA11yHint: (matcher: TextMatch, options?: ByHintTextOptions) => QueryReturn;
|
|
222
|
+
queryByHintText: (matcher: TextMatch, options?: ByHintTextOptions) => QueryReturn;
|
|
223
|
+
queryAllByA11yHint: (matcher: TextMatch, options?: ByHintTextOptions) => QueryAllReturn;
|
|
224
|
+
queryAllByHintText: (matcher: TextMatch, options?: ByHintTextOptions) => QueryAllReturn;
|
|
290
225
|
findByA11yHint: (
|
|
291
226
|
matcher: TextMatch,
|
|
292
227
|
queryOptions?: ByHintTextOptions,
|
|
@@ -310,18 +245,9 @@ interface A11yAPI {
|
|
|
310
245
|
|
|
311
246
|
// Role
|
|
312
247
|
getByRole: (matcher: A11yRole | RegExp, role?: ByRoleOptions) => GetReturn;
|
|
313
|
-
getAllByRole: (
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
) => GetAllReturn;
|
|
317
|
-
queryByRole: (
|
|
318
|
-
matcher: A11yRole | RegExp,
|
|
319
|
-
options?: ByRoleOptions
|
|
320
|
-
) => QueryReturn;
|
|
321
|
-
queryAllByRole: (
|
|
322
|
-
matcher: A11yRole | RegExp,
|
|
323
|
-
options?: ByRoleOptions
|
|
324
|
-
) => QueryAllReturn;
|
|
248
|
+
getAllByRole: (matcher: A11yRole | RegExp, options?: ByRoleOptions) => GetAllReturn;
|
|
249
|
+
queryByRole: (matcher: A11yRole | RegExp, options?: ByRoleOptions) => QueryReturn;
|
|
250
|
+
queryAllByRole: (matcher: A11yRole | RegExp, options?: ByRoleOptions) => QueryAllReturn;
|
|
325
251
|
findByRole: (
|
|
326
252
|
matcher: A11yRole | RegExp,
|
|
327
253
|
queryOptions?: ByRoleOptions,
|
|
@@ -334,22 +260,10 @@ interface A11yAPI {
|
|
|
334
260
|
) => FindAllReturn;
|
|
335
261
|
|
|
336
262
|
// State
|
|
337
|
-
getByA11yState: (
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
) =>
|
|
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;
|
|
263
|
+
getByA11yState: (matcher: A11yState, options?: CommonQueryOptions) => GetReturn;
|
|
264
|
+
getAllByA11yState: (matcher: A11yState, options?: CommonQueryOptions) => GetAllReturn;
|
|
265
|
+
queryByA11yState: (matcher: A11yState, options?: CommonQueryOptions) => QueryReturn;
|
|
266
|
+
queryAllByA11yState: (matcher: A11yState, options?: CommonQueryOptions) => QueryAllReturn;
|
|
353
267
|
findByA11yState: (
|
|
354
268
|
matcher: A11yState,
|
|
355
269
|
queryOptions?: CommonQueryOptions,
|
|
@@ -362,22 +276,10 @@ interface A11yAPI {
|
|
|
362
276
|
) => FindAllReturn;
|
|
363
277
|
|
|
364
278
|
// Value
|
|
365
|
-
getByA11yValue: (
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
) =>
|
|
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;
|
|
279
|
+
getByA11yValue: (matcher: A11yValue, options?: CommonQueryOptions) => GetReturn;
|
|
280
|
+
getAllByA11yValue: (matcher: A11yValue, options?: CommonQueryOptions) => GetAllReturn;
|
|
281
|
+
queryByA11yValue: (matcher: A11yValue, options?: CommonQueryOptions) => QueryReturn;
|
|
282
|
+
queryAllByA11yValue: (matcher: A11yValue, options?: CommonQueryOptions) => QueryAllReturn;
|
|
381
283
|
findByA11yValue: (
|
|
382
284
|
matcher: A11yValue,
|
|
383
285
|
queryOptions?: CommonQueryOptions,
|
|
@@ -478,27 +380,17 @@ declare module '@testing-library/react-native' {
|
|
|
478
380
|
defaultHidden: boolean;
|
|
479
381
|
}
|
|
480
382
|
|
|
481
|
-
declare export var configure: (
|
|
482
|
-
options: $Shape<Config & ConfigAliasOptions>
|
|
483
|
-
) => void;
|
|
383
|
+
declare export var configure: (options: $Shape<Config & ConfigAliasOptions>) => void;
|
|
484
384
|
declare export var resetToDefaults: () => void;
|
|
485
385
|
|
|
486
386
|
declare export var act: (callback: () => void) => Thenable;
|
|
487
387
|
declare export var within: (instance: ReactTestInstance) => Queries;
|
|
488
|
-
declare export var getQueriesForElement: (
|
|
489
|
-
|
|
490
|
-
) =>
|
|
491
|
-
|
|
492
|
-
declare export var
|
|
493
|
-
|
|
494
|
-
) => NormalizerFn;
|
|
495
|
-
|
|
496
|
-
declare export var isHiddenFromAccessibility: (
|
|
497
|
-
element: ReactTestInstance | null
|
|
498
|
-
) => boolean;
|
|
499
|
-
declare export var isInaccessible: (
|
|
500
|
-
element: ReactTestInstance | null
|
|
501
|
-
) => boolean;
|
|
388
|
+
declare export var getQueriesForElement: (element: ReactTestInstance) => Queries;
|
|
389
|
+
|
|
390
|
+
declare export var getDefaultNormalizer: (normalizerConfig?: NormalizerConfig) => NormalizerFn;
|
|
391
|
+
|
|
392
|
+
declare export var isHiddenFromAccessibility: (element: ReactTestInstance | null) => boolean;
|
|
393
|
+
declare export var isInaccessible: (element: ReactTestInstance | null) => boolean;
|
|
502
394
|
|
|
503
395
|
declare type RenderHookResult<Result, Props> = {
|
|
504
396
|
rerender: (props: Props) => void,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"to-be-busy.js","names":["_jestMatcherUtils","require","_accessiblity","_utils","toBeBusy","element","checkHostElement","pass","isElementBusy","message","matcher","matcherHint","isNot","formatElement","join"],"sources":["../../src/matchers/to-be-busy.tsx"],"sourcesContent":["import { ReactTestInstance } from 'react-test-renderer';\nimport { matcherHint } from 'jest-matcher-utils';\nimport { isElementBusy } from '../helpers/accessiblity';\nimport { checkHostElement, formatElement } from './utils';\n\nexport function toBeBusy(
|
|
1
|
+
{"version":3,"file":"to-be-busy.js","names":["_jestMatcherUtils","require","_accessiblity","_utils","toBeBusy","element","checkHostElement","pass","isElementBusy","message","matcher","matcherHint","isNot","formatElement","join"],"sources":["../../src/matchers/to-be-busy.tsx"],"sourcesContent":["import { ReactTestInstance } from 'react-test-renderer';\nimport { matcherHint } from 'jest-matcher-utils';\nimport { isElementBusy } from '../helpers/accessiblity';\nimport { checkHostElement, formatElement } from './utils';\n\nexport function toBeBusy(this: jest.MatcherContext, element: ReactTestInstance) {\n checkHostElement(element, toBeBusy, this);\n\n return {\n pass: isElementBusy(element),\n message: () => {\n const matcher = matcherHint(`${this.isNot ? '.not' : ''}.toBeBusy`, 'element', '');\n return [\n matcher,\n '',\n `Received element is ${this.isNot ? '' : 'not '}busy:`,\n formatElement(element),\n ].join('\\n');\n },\n };\n}\n"],"mappings":";;;;;;AACA,IAAAA,iBAAA,GAAAC,OAAA;AACA,IAAAC,aAAA,GAAAD,OAAA;AACA,IAAAE,MAAA,GAAAF,OAAA;AAEO,SAASG,QAAQA,CAA4BC,OAA0B,EAAE;EAC9E,IAAAC,uBAAgB,EAACD,OAAO,EAAED,QAAQ,EAAE,IAAI,CAAC;EAEzC,OAAO;IACLG,IAAI,EAAE,IAAAC,2BAAa,EAACH,OAAO,CAAC;IAC5BI,OAAO,EAAEA,CAAA,KAAM;MACb,MAAMC,OAAO,GAAG,IAAAC,6BAAW,EAAE,GAAE,IAAI,CAACC,KAAK,GAAG,MAAM,GAAG,EAAG,WAAU,EAAE,SAAS,EAAE,EAAE,CAAC;MAClF,OAAO,CACLF,OAAO,EACP,EAAE,EACD,uBAAsB,IAAI,CAACE,KAAK,GAAG,EAAE,GAAG,MAAO,OAAM,EACtD,IAAAC,oBAAa,EAACR,OAAO,CAAC,CACvB,CAACS,IAAI,CAAC,IAAI,CAAC;IACd;EACF,CAAC;AACH"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"to-be-checked.js","names":["_jestMatcherUtils","require","_accessiblity","_errors","_utils","toBeChecked","element","checkHostElement","hasValidAccessibilityRole","ErrorWithStack","pass","getAccessibilityCheckedState","message","is","isNot","matcherHint","formatElement","join","isAccessibilityElement","role","getAccessibilityRole"],"sources":["../../src/matchers/to-be-checked.tsx"],"sourcesContent":["import type { ReactTestInstance } from 'react-test-renderer';\nimport { matcherHint } from 'jest-matcher-utils';\nimport {\n getAccessibilityCheckedState,\n getAccessibilityRole,\n isAccessibilityElement,\n} from '../helpers/accessiblity';\nimport { ErrorWithStack } from '../helpers/errors';\nimport { checkHostElement, formatElement } from './utils';\n\nexport function toBeChecked(
|
|
1
|
+
{"version":3,"file":"to-be-checked.js","names":["_jestMatcherUtils","require","_accessiblity","_errors","_utils","toBeChecked","element","checkHostElement","hasValidAccessibilityRole","ErrorWithStack","pass","getAccessibilityCheckedState","message","is","isNot","matcherHint","formatElement","join","isAccessibilityElement","role","getAccessibilityRole"],"sources":["../../src/matchers/to-be-checked.tsx"],"sourcesContent":["import type { ReactTestInstance } from 'react-test-renderer';\nimport { matcherHint } from 'jest-matcher-utils';\nimport {\n getAccessibilityCheckedState,\n getAccessibilityRole,\n isAccessibilityElement,\n} from '../helpers/accessiblity';\nimport { ErrorWithStack } from '../helpers/errors';\nimport { checkHostElement, formatElement } from './utils';\n\nexport function toBeChecked(this: jest.MatcherContext, element: ReactTestInstance) {\n checkHostElement(element, toBeChecked, this);\n\n if (!hasValidAccessibilityRole(element)) {\n throw new ErrorWithStack(\n `toBeChecked() works only on accessibility elements with \"checkbox\" or \"radio\" role.`,\n toBeChecked,\n );\n }\n\n return {\n pass: getAccessibilityCheckedState(element) === true,\n message: () => {\n const is = this.isNot ? 'is' : 'is not';\n return [\n matcherHint(`${this.isNot ? '.not' : ''}.toBeChecked`, 'element', ''),\n '',\n `Received element ${is} checked:`,\n formatElement(element),\n ].join('\\n');\n },\n };\n}\n\nfunction hasValidAccessibilityRole(element: ReactTestInstance) {\n if (!isAccessibilityElement(element)) {\n return false;\n }\n\n const role = getAccessibilityRole(element);\n return role === 'checkbox' || role === 'radio';\n}\n"],"mappings":";;;;;;AACA,IAAAA,iBAAA,GAAAC,OAAA;AACA,IAAAC,aAAA,GAAAD,OAAA;AAKA,IAAAE,OAAA,GAAAF,OAAA;AACA,IAAAG,MAAA,GAAAH,OAAA;AAEO,SAASI,WAAWA,CAA4BC,OAA0B,EAAE;EACjF,IAAAC,uBAAgB,EAACD,OAAO,EAAED,WAAW,EAAE,IAAI,CAAC;EAE5C,IAAI,CAACG,yBAAyB,CAACF,OAAO,CAAC,EAAE;IACvC,MAAM,IAAIG,sBAAc,CACrB,qFAAoF,EACrFJ,WACF,CAAC;EACH;EAEA,OAAO;IACLK,IAAI,EAAE,IAAAC,0CAA4B,EAACL,OAAO,CAAC,KAAK,IAAI;IACpDM,OAAO,EAAEA,CAAA,KAAM;MACb,MAAMC,EAAE,GAAG,IAAI,CAACC,KAAK,GAAG,IAAI,GAAG,QAAQ;MACvC,OAAO,CACL,IAAAC,6BAAW,EAAE,GAAE,IAAI,CAACD,KAAK,GAAG,MAAM,GAAG,EAAG,cAAa,EAAE,SAAS,EAAE,EAAE,CAAC,EACrE,EAAE,EACD,oBAAmBD,EAAG,WAAU,EACjC,IAAAG,oBAAa,EAACV,OAAO,CAAC,CACvB,CAACW,IAAI,CAAC,IAAI,CAAC;IACd;EACF,CAAC;AACH;AAEA,SAAST,yBAAyBA,CAACF,OAA0B,EAAE;EAC7D,IAAI,CAAC,IAAAY,oCAAsB,EAACZ,OAAO,CAAC,EAAE;IACpC,OAAO,KAAK;EACd;EAEA,MAAMa,IAAI,GAAG,IAAAC,kCAAoB,EAACd,OAAO,CAAC;EAC1C,OAAOa,IAAI,KAAK,UAAU,IAAIA,IAAI,KAAK,OAAO;AAChD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"to-be-collapsed.js","names":["_jestMatcherUtils","require","_accessiblity","_utils","toBeCollapsed","element","checkHostElement","pass","isElementCollapsed","message","matcher","matcherHint","isNot","formatElement","join"],"sources":["../../src/matchers/to-be-collapsed.tsx"],"sourcesContent":["import { ReactTestInstance } from 'react-test-renderer';\nimport { matcherHint } from 'jest-matcher-utils';\nimport { isElementCollapsed } from '../helpers/accessiblity';\nimport { checkHostElement, formatElement } from './utils';\n\nexport function toBeCollapsed(
|
|
1
|
+
{"version":3,"file":"to-be-collapsed.js","names":["_jestMatcherUtils","require","_accessiblity","_utils","toBeCollapsed","element","checkHostElement","pass","isElementCollapsed","message","matcher","matcherHint","isNot","formatElement","join"],"sources":["../../src/matchers/to-be-collapsed.tsx"],"sourcesContent":["import { ReactTestInstance } from 'react-test-renderer';\nimport { matcherHint } from 'jest-matcher-utils';\nimport { isElementCollapsed } from '../helpers/accessiblity';\nimport { checkHostElement, formatElement } from './utils';\n\nexport function toBeCollapsed(this: jest.MatcherContext, element: ReactTestInstance) {\n checkHostElement(element, toBeCollapsed, this);\n\n return {\n pass: isElementCollapsed(element),\n message: () => {\n const matcher = matcherHint(`${this.isNot ? '.not' : ''}.toBeCollapsed`, 'element', '');\n return [\n matcher,\n '',\n `Received element is ${this.isNot ? '' : 'not '}collapsed:`,\n formatElement(element),\n ].join('\\n');\n },\n };\n}\n"],"mappings":";;;;;;AACA,IAAAA,iBAAA,GAAAC,OAAA;AACA,IAAAC,aAAA,GAAAD,OAAA;AACA,IAAAE,MAAA,GAAAF,OAAA;AAEO,SAASG,aAAaA,CAA4BC,OAA0B,EAAE;EACnF,IAAAC,uBAAgB,EAACD,OAAO,EAAED,aAAa,EAAE,IAAI,CAAC;EAE9C,OAAO;IACLG,IAAI,EAAE,IAAAC,gCAAkB,EAACH,OAAO,CAAC;IACjCI,OAAO,EAAEA,CAAA,KAAM;MACb,MAAMC,OAAO,GAAG,IAAAC,6BAAW,EAAE,GAAE,IAAI,CAACC,KAAK,GAAG,MAAM,GAAG,EAAG,gBAAe,EAAE,SAAS,EAAE,EAAE,CAAC;MACvF,OAAO,CACLF,OAAO,EACP,EAAE,EACD,uBAAsB,IAAI,CAACE,KAAK,GAAG,EAAE,GAAG,MAAO,YAAW,EAC3D,IAAAC,oBAAa,EAACR,OAAO,CAAC,CACvB,CAACS,IAAI,CAAC,IAAI,CAAC;IACd;EACF,CAAC;AACH"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"to-be-disabled.js","names":["_jestMatcherUtils","require","_hostComponentNames","_textInput","_componentTree","_utils","toBeDisabled","element","checkHostElement","isDisabled","isElementDisabled","isAncestorDisabled","pass","message","is","isNot","matcherHint","formatElement","join","toBeEnabled","isEnabled","isHostTextInput","isTextInputEditable","accessibilityState","ariaDisabled","props","disabled","parent","getHostParent"],"sources":["../../src/matchers/to-be-disabled.tsx"],"sourcesContent":["import type { ReactTestInstance } from 'react-test-renderer';\nimport { matcherHint } from 'jest-matcher-utils';\nimport { isHostTextInput } from '../helpers/host-component-names';\nimport { isTextInputEditable } from '../helpers/text-input';\nimport { getHostParent } from '../helpers/component-tree';\nimport { checkHostElement, formatElement } from './utils';\n\nexport function toBeDisabled(
|
|
1
|
+
{"version":3,"file":"to-be-disabled.js","names":["_jestMatcherUtils","require","_hostComponentNames","_textInput","_componentTree","_utils","toBeDisabled","element","checkHostElement","isDisabled","isElementDisabled","isAncestorDisabled","pass","message","is","isNot","matcherHint","formatElement","join","toBeEnabled","isEnabled","isHostTextInput","isTextInputEditable","accessibilityState","ariaDisabled","props","disabled","parent","getHostParent"],"sources":["../../src/matchers/to-be-disabled.tsx"],"sourcesContent":["import type { ReactTestInstance } from 'react-test-renderer';\nimport { matcherHint } from 'jest-matcher-utils';\nimport { isHostTextInput } from '../helpers/host-component-names';\nimport { isTextInputEditable } from '../helpers/text-input';\nimport { getHostParent } from '../helpers/component-tree';\nimport { checkHostElement, formatElement } from './utils';\n\nexport function toBeDisabled(this: jest.MatcherContext, element: ReactTestInstance) {\n checkHostElement(element, toBeDisabled, this);\n\n const isDisabled = isElementDisabled(element) || isAncestorDisabled(element);\n\n return {\n pass: isDisabled,\n message: () => {\n const is = this.isNot ? 'is' : 'is not';\n return [\n matcherHint(`${this.isNot ? '.not' : ''}.toBeDisabled`, 'element', ''),\n '',\n `Received element ${is} disabled:`,\n formatElement(element),\n ].join('\\n');\n },\n };\n}\n\nexport function toBeEnabled(this: jest.MatcherContext, element: ReactTestInstance) {\n checkHostElement(element, toBeEnabled, this);\n\n const isEnabled = !isElementDisabled(element) && !isAncestorDisabled(element);\n\n return {\n pass: isEnabled,\n message: () => {\n const is = this.isNot ? 'is' : 'is not';\n return [\n matcherHint(`${this.isNot ? '.not' : ''}.toBeEnabled`, 'element', ''),\n '',\n `Received element ${is} enabled:`,\n formatElement(element),\n ].join('\\n');\n },\n };\n}\n\nfunction isElementDisabled(element: ReactTestInstance) {\n if (isHostTextInput(element) && !isTextInputEditable(element)) {\n return true;\n }\n\n const { accessibilityState, 'aria-disabled': ariaDisabled } = element.props;\n return ariaDisabled ?? accessibilityState?.disabled ?? false;\n}\n\nfunction isAncestorDisabled(element: ReactTestInstance): boolean {\n const parent = getHostParent(element);\n if (parent == null) {\n return false;\n }\n\n return isElementDisabled(parent) || isAncestorDisabled(parent);\n}\n"],"mappings":";;;;;;;AACA,IAAAA,iBAAA,GAAAC,OAAA;AACA,IAAAC,mBAAA,GAAAD,OAAA;AACA,IAAAE,UAAA,GAAAF,OAAA;AACA,IAAAG,cAAA,GAAAH,OAAA;AACA,IAAAI,MAAA,GAAAJ,OAAA;AAEO,SAASK,YAAYA,CAA4BC,OAA0B,EAAE;EAClF,IAAAC,uBAAgB,EAACD,OAAO,EAAED,YAAY,EAAE,IAAI,CAAC;EAE7C,MAAMG,UAAU,GAAGC,iBAAiB,CAACH,OAAO,CAAC,IAAII,kBAAkB,CAACJ,OAAO,CAAC;EAE5E,OAAO;IACLK,IAAI,EAAEH,UAAU;IAChBI,OAAO,EAAEA,CAAA,KAAM;MACb,MAAMC,EAAE,GAAG,IAAI,CAACC,KAAK,GAAG,IAAI,GAAG,QAAQ;MACvC,OAAO,CACL,IAAAC,6BAAW,EAAE,GAAE,IAAI,CAACD,KAAK,GAAG,MAAM,GAAG,EAAG,eAAc,EAAE,SAAS,EAAE,EAAE,CAAC,EACtE,EAAE,EACD,oBAAmBD,EAAG,YAAW,EAClC,IAAAG,oBAAa,EAACV,OAAO,CAAC,CACvB,CAACW,IAAI,CAAC,IAAI,CAAC;IACd;EACF,CAAC;AACH;AAEO,SAASC,WAAWA,CAA4BZ,OAA0B,EAAE;EACjF,IAAAC,uBAAgB,EAACD,OAAO,EAAEY,WAAW,EAAE,IAAI,CAAC;EAE5C,MAAMC,SAAS,GAAG,CAACV,iBAAiB,CAACH,OAAO,CAAC,IAAI,CAACI,kBAAkB,CAACJ,OAAO,CAAC;EAE7E,OAAO;IACLK,IAAI,EAAEQ,SAAS;IACfP,OAAO,EAAEA,CAAA,KAAM;MACb,MAAMC,EAAE,GAAG,IAAI,CAACC,KAAK,GAAG,IAAI,GAAG,QAAQ;MACvC,OAAO,CACL,IAAAC,6BAAW,EAAE,GAAE,IAAI,CAACD,KAAK,GAAG,MAAM,GAAG,EAAG,cAAa,EAAE,SAAS,EAAE,EAAE,CAAC,EACrE,EAAE,EACD,oBAAmBD,EAAG,WAAU,EACjC,IAAAG,oBAAa,EAACV,OAAO,CAAC,CACvB,CAACW,IAAI,CAAC,IAAI,CAAC;IACd;EACF,CAAC;AACH;AAEA,SAASR,iBAAiBA,CAACH,OAA0B,EAAE;EACrD,IAAI,IAAAc,mCAAe,EAACd,OAAO,CAAC,IAAI,CAAC,IAAAe,8BAAmB,EAACf,OAAO,CAAC,EAAE;IAC7D,OAAO,IAAI;EACb;EAEA,MAAM;IAAEgB,kBAAkB;IAAE,eAAe,EAAEC;EAAa,CAAC,GAAGjB,OAAO,CAACkB,KAAK;EAC3E,OAAOD,YAAY,IAAID,kBAAkB,EAAEG,QAAQ,IAAI,KAAK;AAC9D;AAEA,SAASf,kBAAkBA,CAACJ,OAA0B,EAAW;EAC/D,MAAMoB,MAAM,GAAG,IAAAC,4BAAa,EAACrB,OAAO,CAAC;EACrC,IAAIoB,MAAM,IAAI,IAAI,EAAE;IAClB,OAAO,KAAK;EACd;EAEA,OAAOjB,iBAAiB,CAACiB,MAAM,CAAC,IAAIhB,kBAAkB,CAACgB,MAAM,CAAC;AAChE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"to-be-empty-element.js","names":["_jestMatcherUtils","require","_componentTree","_utils","toBeEmptyElement","element","checkHostElement","hostChildren","getHostChildren","pass","length","message","matcherHint","isNot","RECEIVED_COLOR","formatElementArray","join"],"sources":["../../src/matchers/to-be-empty-element.tsx"],"sourcesContent":["import { ReactTestInstance } from 'react-test-renderer';\nimport { matcherHint, RECEIVED_COLOR } from 'jest-matcher-utils';\nimport { getHostChildren } from '../helpers/component-tree';\nimport { checkHostElement, formatElementArray } from './utils';\n\nexport function toBeEmptyElement(
|
|
1
|
+
{"version":3,"file":"to-be-empty-element.js","names":["_jestMatcherUtils","require","_componentTree","_utils","toBeEmptyElement","element","checkHostElement","hostChildren","getHostChildren","pass","length","message","matcherHint","isNot","RECEIVED_COLOR","formatElementArray","join"],"sources":["../../src/matchers/to-be-empty-element.tsx"],"sourcesContent":["import { ReactTestInstance } from 'react-test-renderer';\nimport { matcherHint, RECEIVED_COLOR } from 'jest-matcher-utils';\nimport { getHostChildren } from '../helpers/component-tree';\nimport { checkHostElement, formatElementArray } from './utils';\n\nexport function toBeEmptyElement(this: jest.MatcherContext, element: ReactTestInstance) {\n checkHostElement(element, toBeEmptyElement, this);\n\n const hostChildren = getHostChildren(element);\n\n return {\n pass: hostChildren.length === 0,\n message: () => {\n return [\n matcherHint(`${this.isNot ? '.not' : ''}.toBeEmptyElement`, 'element', ''),\n '',\n 'Received:',\n `${RECEIVED_COLOR(formatElementArray(hostChildren))}`,\n ].join('\\n');\n },\n };\n}\n"],"mappings":";;;;;;AACA,IAAAA,iBAAA,GAAAC,OAAA;AACA,IAAAC,cAAA,GAAAD,OAAA;AACA,IAAAE,MAAA,GAAAF,OAAA;AAEO,SAASG,gBAAgBA,CAA4BC,OAA0B,EAAE;EACtF,IAAAC,uBAAgB,EAACD,OAAO,EAAED,gBAAgB,EAAE,IAAI,CAAC;EAEjD,MAAMG,YAAY,GAAG,IAAAC,8BAAe,EAACH,OAAO,CAAC;EAE7C,OAAO;IACLI,IAAI,EAAEF,YAAY,CAACG,MAAM,KAAK,CAAC;IAC/BC,OAAO,EAAEA,CAAA,KAAM;MACb,OAAO,CACL,IAAAC,6BAAW,EAAE,GAAE,IAAI,CAACC,KAAK,GAAG,MAAM,GAAG,EAAG,mBAAkB,EAAE,SAAS,EAAE,EAAE,CAAC,EAC1E,EAAE,EACF,WAAW,EACV,GAAE,IAAAC,gCAAc,EAAC,IAAAC,yBAAkB,EAACR,YAAY,CAAC,CAAE,EAAC,CACtD,CAACS,IAAI,CAAC,IAAI,CAAC;IACd;EACF,CAAC;AACH"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"to-be-expanded.js","names":["_jestMatcherUtils","require","_accessiblity","_utils","toBeExpanded","element","checkHostElement","pass","isElementExpanded","message","matcher","matcherHint","isNot","formatElement","join"],"sources":["../../src/matchers/to-be-expanded.tsx"],"sourcesContent":["import { ReactTestInstance } from 'react-test-renderer';\nimport { matcherHint } from 'jest-matcher-utils';\nimport { isElementExpanded } from '../helpers/accessiblity';\nimport { checkHostElement, formatElement } from './utils';\n\nexport function toBeExpanded(
|
|
1
|
+
{"version":3,"file":"to-be-expanded.js","names":["_jestMatcherUtils","require","_accessiblity","_utils","toBeExpanded","element","checkHostElement","pass","isElementExpanded","message","matcher","matcherHint","isNot","formatElement","join"],"sources":["../../src/matchers/to-be-expanded.tsx"],"sourcesContent":["import { ReactTestInstance } from 'react-test-renderer';\nimport { matcherHint } from 'jest-matcher-utils';\nimport { isElementExpanded } from '../helpers/accessiblity';\nimport { checkHostElement, formatElement } from './utils';\n\nexport function toBeExpanded(this: jest.MatcherContext, element: ReactTestInstance) {\n checkHostElement(element, toBeExpanded, this);\n\n return {\n pass: isElementExpanded(element),\n message: () => {\n const matcher = matcherHint(`${this.isNot ? '.not' : ''}.toBeExpanded`, 'element', '');\n return [\n matcher,\n '',\n `Received element is ${this.isNot ? '' : 'not '}expanded:`,\n formatElement(element),\n ].join('\\n');\n },\n };\n}\n"],"mappings":";;;;;;AACA,IAAAA,iBAAA,GAAAC,OAAA;AACA,IAAAC,aAAA,GAAAD,OAAA;AACA,IAAAE,MAAA,GAAAF,OAAA;AAEO,SAASG,YAAYA,CAA4BC,OAA0B,EAAE;EAClF,IAAAC,uBAAgB,EAACD,OAAO,EAAED,YAAY,EAAE,IAAI,CAAC;EAE7C,OAAO;IACLG,IAAI,EAAE,IAAAC,+BAAiB,EAACH,OAAO,CAAC;IAChCI,OAAO,EAAEA,CAAA,KAAM;MACb,MAAMC,OAAO,GAAG,IAAAC,6BAAW,EAAE,GAAE,IAAI,CAACC,KAAK,GAAG,MAAM,GAAG,EAAG,eAAc,EAAE,SAAS,EAAE,EAAE,CAAC;MACtF,OAAO,CACLF,OAAO,EACP,EAAE,EACD,uBAAsB,IAAI,CAACE,KAAK,GAAG,EAAE,GAAG,MAAO,WAAU,EAC1D,IAAAC,oBAAa,EAACR,OAAO,CAAC,CACvB,CAACS,IAAI,CAAC,IAAI,CAAC;IACd;EACF,CAAC;AACH"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"to-be-on-the-screen.js","names":["_jestMatcherUtils","require","_componentTree","_screen","_utils","toBeOnTheScreen","element","isNot","checkHostElement","pass","screen","UNSAFE_root","getUnsafeRootElement","errorFound","formatElement","errorNotFound","message","matcherHint","RECEIVED_COLOR","join"],"sources":["../../src/matchers/to-be-on-the-screen.tsx"],"sourcesContent":["import type { ReactTestInstance } from 'react-test-renderer';\nimport { matcherHint, RECEIVED_COLOR } from 'jest-matcher-utils';\nimport { getUnsafeRootElement } from '../helpers/component-tree';\nimport { screen } from '../screen';\nimport { checkHostElement, formatElement } from './utils';\n\nexport function toBeOnTheScreen(
|
|
1
|
+
{"version":3,"file":"to-be-on-the-screen.js","names":["_jestMatcherUtils","require","_componentTree","_screen","_utils","toBeOnTheScreen","element","isNot","checkHostElement","pass","screen","UNSAFE_root","getUnsafeRootElement","errorFound","formatElement","errorNotFound","message","matcherHint","RECEIVED_COLOR","join"],"sources":["../../src/matchers/to-be-on-the-screen.tsx"],"sourcesContent":["import type { ReactTestInstance } from 'react-test-renderer';\nimport { matcherHint, RECEIVED_COLOR } from 'jest-matcher-utils';\nimport { getUnsafeRootElement } from '../helpers/component-tree';\nimport { screen } from '../screen';\nimport { checkHostElement, formatElement } from './utils';\n\nexport function toBeOnTheScreen(this: jest.MatcherContext, element: ReactTestInstance) {\n if (element !== null || !this.isNot) {\n checkHostElement(element, toBeOnTheScreen, this);\n }\n\n const pass = element === null ? false : screen.UNSAFE_root === getUnsafeRootElement(element);\n\n const errorFound = () => {\n return `expected element tree not to contain element, but found\\n${formatElement(element)}`;\n };\n\n const errorNotFound = () => {\n return `element could not be found in the element tree`;\n };\n\n return {\n pass,\n message: () => {\n return [\n matcherHint(`${this.isNot ? '.not' : ''}.toBeOnTheScreen`, 'element', ''),\n '',\n RECEIVED_COLOR(this.isNot ? errorFound() : errorNotFound()),\n ].join('\\n');\n },\n };\n}\n"],"mappings":";;;;;;AACA,IAAAA,iBAAA,GAAAC,OAAA;AACA,IAAAC,cAAA,GAAAD,OAAA;AACA,IAAAE,OAAA,GAAAF,OAAA;AACA,IAAAG,MAAA,GAAAH,OAAA;AAEO,SAASI,eAAeA,CAA4BC,OAA0B,EAAE;EACrF,IAAIA,OAAO,KAAK,IAAI,IAAI,CAAC,IAAI,CAACC,KAAK,EAAE;IACnC,IAAAC,uBAAgB,EAACF,OAAO,EAAED,eAAe,EAAE,IAAI,CAAC;EAClD;EAEA,MAAMI,IAAI,GAAGH,OAAO,KAAK,IAAI,GAAG,KAAK,GAAGI,cAAM,CAACC,WAAW,KAAK,IAAAC,mCAAoB,EAACN,OAAO,CAAC;EAE5F,MAAMO,UAAU,GAAGA,CAAA,KAAM;IACvB,OAAQ,4DAA2D,IAAAC,oBAAa,EAACR,OAAO,CAAE,EAAC;EAC7F,CAAC;EAED,MAAMS,aAAa,GAAGA,CAAA,KAAM;IAC1B,OAAQ,gDAA+C;EACzD,CAAC;EAED,OAAO;IACLN,IAAI;IACJO,OAAO,EAAEA,CAAA,KAAM;MACb,OAAO,CACL,IAAAC,6BAAW,EAAE,GAAE,IAAI,CAACV,KAAK,GAAG,MAAM,GAAG,EAAG,kBAAiB,EAAE,SAAS,EAAE,EAAE,CAAC,EACzE,EAAE,EACF,IAAAW,gCAAc,EAAC,IAAI,CAACX,KAAK,GAAGM,UAAU,CAAC,CAAC,GAAGE,aAAa,CAAC,CAAC,CAAC,CAC5D,CAACI,IAAI,CAAC,IAAI,CAAC;IACd;EACF,CAAC;AACH"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"to-be-partially-checked.js","names":["_jestMatcherUtils","require","_accessiblity","_errors","_utils","toBePartiallyChecked","element","checkHostElement","hasValidAccessibilityRole","ErrorWithStack","pass","getAccessibilityCheckedState","message","is","isNot","matcherHint","formatElement","join","role","getAccessibilityRole","isAccessibilityElement"],"sources":["../../src/matchers/to-be-partially-checked.tsx"],"sourcesContent":["import type { ReactTestInstance } from 'react-test-renderer';\nimport { matcherHint } from 'jest-matcher-utils';\nimport {\n getAccessibilityCheckedState,\n getAccessibilityRole,\n isAccessibilityElement,\n} from '../helpers/accessiblity';\nimport { ErrorWithStack } from '../helpers/errors';\nimport { checkHostElement, formatElement } from './utils';\n\nexport function toBePartiallyChecked(
|
|
1
|
+
{"version":3,"file":"to-be-partially-checked.js","names":["_jestMatcherUtils","require","_accessiblity","_errors","_utils","toBePartiallyChecked","element","checkHostElement","hasValidAccessibilityRole","ErrorWithStack","pass","getAccessibilityCheckedState","message","is","isNot","matcherHint","formatElement","join","role","getAccessibilityRole","isAccessibilityElement"],"sources":["../../src/matchers/to-be-partially-checked.tsx"],"sourcesContent":["import type { ReactTestInstance } from 'react-test-renderer';\nimport { matcherHint } from 'jest-matcher-utils';\nimport {\n getAccessibilityCheckedState,\n getAccessibilityRole,\n isAccessibilityElement,\n} from '../helpers/accessiblity';\nimport { ErrorWithStack } from '../helpers/errors';\nimport { checkHostElement, formatElement } from './utils';\n\nexport function toBePartiallyChecked(this: jest.MatcherContext, element: ReactTestInstance) {\n checkHostElement(element, toBePartiallyChecked, this);\n\n if (!hasValidAccessibilityRole(element)) {\n throw new ErrorWithStack(\n 'toBePartiallyChecked() works only on accessibility elements with \"checkbox\" role.',\n toBePartiallyChecked,\n );\n }\n\n return {\n pass: getAccessibilityCheckedState(element) === 'mixed',\n message: () => {\n const is = this.isNot ? 'is' : 'is not';\n return [\n matcherHint(`${this.isNot ? '.not' : ''}.toBePartiallyChecked`, 'element', ''),\n '',\n `Received element ${is} partially checked:`,\n formatElement(element),\n ].join('\\n');\n },\n };\n}\n\nfunction hasValidAccessibilityRole(element: ReactTestInstance) {\n const role = getAccessibilityRole(element);\n return isAccessibilityElement(element) && role === 'checkbox';\n}\n"],"mappings":";;;;;;AACA,IAAAA,iBAAA,GAAAC,OAAA;AACA,IAAAC,aAAA,GAAAD,OAAA;AAKA,IAAAE,OAAA,GAAAF,OAAA;AACA,IAAAG,MAAA,GAAAH,OAAA;AAEO,SAASI,oBAAoBA,CAA4BC,OAA0B,EAAE;EAC1F,IAAAC,uBAAgB,EAACD,OAAO,EAAED,oBAAoB,EAAE,IAAI,CAAC;EAErD,IAAI,CAACG,yBAAyB,CAACF,OAAO,CAAC,EAAE;IACvC,MAAM,IAAIG,sBAAc,CACtB,mFAAmF,EACnFJ,oBACF,CAAC;EACH;EAEA,OAAO;IACLK,IAAI,EAAE,IAAAC,0CAA4B,EAACL,OAAO,CAAC,KAAK,OAAO;IACvDM,OAAO,EAAEA,CAAA,KAAM;MACb,MAAMC,EAAE,GAAG,IAAI,CAACC,KAAK,GAAG,IAAI,GAAG,QAAQ;MACvC,OAAO,CACL,IAAAC,6BAAW,EAAE,GAAE,IAAI,CAACD,KAAK,GAAG,MAAM,GAAG,EAAG,uBAAsB,EAAE,SAAS,EAAE,EAAE,CAAC,EAC9E,EAAE,EACD,oBAAmBD,EAAG,qBAAoB,EAC3C,IAAAG,oBAAa,EAACV,OAAO,CAAC,CACvB,CAACW,IAAI,CAAC,IAAI,CAAC;IACd;EACF,CAAC;AACH;AAEA,SAAST,yBAAyBA,CAACF,OAA0B,EAAE;EAC7D,MAAMY,IAAI,GAAG,IAAAC,kCAAoB,EAACb,OAAO,CAAC;EAC1C,OAAO,IAAAc,oCAAsB,EAACd,OAAO,CAAC,IAAIY,IAAI,KAAK,UAAU;AAC/D"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"to-be-selected.js","names":["_jestMatcherUtils","require","_accessiblity","_utils","toBeSelected","element","checkHostElement","pass","isElementSelected","message","is","isNot","matcherHint","formatElement","join"],"sources":["../../src/matchers/to-be-selected.ts"],"sourcesContent":["import { ReactTestInstance } from 'react-test-renderer';\nimport { matcherHint } from 'jest-matcher-utils';\nimport { isElementSelected } from '../helpers/accessiblity';\nimport { checkHostElement, formatElement } from './utils';\n\nexport function toBeSelected(
|
|
1
|
+
{"version":3,"file":"to-be-selected.js","names":["_jestMatcherUtils","require","_accessiblity","_utils","toBeSelected","element","checkHostElement","pass","isElementSelected","message","is","isNot","matcherHint","formatElement","join"],"sources":["../../src/matchers/to-be-selected.ts"],"sourcesContent":["import { ReactTestInstance } from 'react-test-renderer';\nimport { matcherHint } from 'jest-matcher-utils';\nimport { isElementSelected } from '../helpers/accessiblity';\nimport { checkHostElement, formatElement } from './utils';\n\nexport function toBeSelected(this: jest.MatcherContext, element: ReactTestInstance) {\n checkHostElement(element, toBeSelected, this);\n\n return {\n pass: isElementSelected(element),\n message: () => {\n const is = this.isNot ? 'is' : 'is not';\n return [\n matcherHint(`${this.isNot ? '.not' : ''}.toBeSelected`, 'element', ''),\n '',\n `Received element ${is} selected`,\n formatElement(element),\n ].join('\\n');\n },\n };\n}\n"],"mappings":";;;;;;AACA,IAAAA,iBAAA,GAAAC,OAAA;AACA,IAAAC,aAAA,GAAAD,OAAA;AACA,IAAAE,MAAA,GAAAF,OAAA;AAEO,SAASG,YAAYA,CAA4BC,OAA0B,EAAE;EAClF,IAAAC,uBAAgB,EAACD,OAAO,EAAED,YAAY,EAAE,IAAI,CAAC;EAE7C,OAAO;IACLG,IAAI,EAAE,IAAAC,+BAAiB,EAACH,OAAO,CAAC;IAChCI,OAAO,EAAEA,CAAA,KAAM;MACb,MAAMC,EAAE,GAAG,IAAI,CAACC,KAAK,GAAG,IAAI,GAAG,QAAQ;MACvC,OAAO,CACL,IAAAC,6BAAW,EAAE,GAAE,IAAI,CAACD,KAAK,GAAG,MAAM,GAAG,EAAG,eAAc,EAAE,SAAS,EAAE,EAAE,CAAC,EACtE,EAAE,EACD,oBAAmBD,EAAG,WAAU,EACjC,IAAAG,oBAAa,EAACR,OAAO,CAAC,CACvB,CAACS,IAAI,CAAC,IAAI,CAAC;IACd;EACF,CAAC;AACH"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"to-be-visible.js","names":["_jestMatcherUtils","require","_reactNative","_accessiblity","_componentTree","_hostComponentNames","_utils","toBeVisible","element","isNot","checkHostElement","pass","isElementVisible","message","is","matcherHint","formatElement","join","accessibilityCache","cache","WeakMap","isHiddenFromAccessibility","isHiddenForStyles","isHostModal","props","visible","hostParent","getHostParent","style","display","opacity","StyleSheet","flatten"],"sources":["../../src/matchers/to-be-visible.tsx"],"sourcesContent":["import type { ReactTestInstance } from 'react-test-renderer';\nimport { matcherHint } from 'jest-matcher-utils';\nimport { StyleSheet } from 'react-native';\nimport { isHiddenFromAccessibility } from '../helpers/accessiblity';\nimport { getHostParent } from '../helpers/component-tree';\nimport { isHostModal } from '../helpers/host-component-names';\nimport { checkHostElement, formatElement } from './utils';\n\nexport function toBeVisible(
|
|
1
|
+
{"version":3,"file":"to-be-visible.js","names":["_jestMatcherUtils","require","_reactNative","_accessiblity","_componentTree","_hostComponentNames","_utils","toBeVisible","element","isNot","checkHostElement","pass","isElementVisible","message","is","matcherHint","formatElement","join","accessibilityCache","cache","WeakMap","isHiddenFromAccessibility","isHiddenForStyles","isHostModal","props","visible","hostParent","getHostParent","style","display","opacity","StyleSheet","flatten"],"sources":["../../src/matchers/to-be-visible.tsx"],"sourcesContent":["import type { ReactTestInstance } from 'react-test-renderer';\nimport { matcherHint } from 'jest-matcher-utils';\nimport { StyleSheet } from 'react-native';\nimport { isHiddenFromAccessibility } from '../helpers/accessiblity';\nimport { getHostParent } from '../helpers/component-tree';\nimport { isHostModal } from '../helpers/host-component-names';\nimport { checkHostElement, formatElement } from './utils';\n\nexport function toBeVisible(this: jest.MatcherContext, element: ReactTestInstance) {\n if (element !== null || !this.isNot) {\n checkHostElement(element, toBeVisible, this);\n }\n\n return {\n pass: isElementVisible(element),\n message: () => {\n const is = this.isNot ? 'is' : 'is not';\n return [\n matcherHint(`${this.isNot ? '.not' : ''}.toBeVisible`, 'element', ''),\n '',\n `Received element ${is} visible:`,\n formatElement(element),\n ].join('\\n');\n },\n };\n}\n\nfunction isElementVisible(\n element: ReactTestInstance,\n accessibilityCache?: WeakMap<ReactTestInstance, boolean>,\n): boolean {\n // Use cache to speed up repeated searches by `isHiddenFromAccessibility`.\n const cache = accessibilityCache ?? new WeakMap<ReactTestInstance, boolean>();\n if (isHiddenFromAccessibility(element, { cache })) {\n return false;\n }\n\n if (isHiddenForStyles(element)) {\n return false;\n }\n\n // Note: this seems to be a bug in React Native.\n // PR with fix: https://github.com/facebook/react-native/pull/39157\n if (isHostModal(element) && element.props.visible === false) {\n return false;\n }\n\n const hostParent = getHostParent(element);\n if (hostParent === null) {\n return true;\n }\n\n return isElementVisible(hostParent, cache);\n}\n\nfunction isHiddenForStyles(element: ReactTestInstance) {\n const style = element.props.style ?? {};\n const { display, opacity } = StyleSheet.flatten(style);\n return display === 'none' || opacity === 0;\n}\n"],"mappings":";;;;;;AACA,IAAAA,iBAAA,GAAAC,OAAA;AACA,IAAAC,YAAA,GAAAD,OAAA;AACA,IAAAE,aAAA,GAAAF,OAAA;AACA,IAAAG,cAAA,GAAAH,OAAA;AACA,IAAAI,mBAAA,GAAAJ,OAAA;AACA,IAAAK,MAAA,GAAAL,OAAA;AAEO,SAASM,WAAWA,CAA4BC,OAA0B,EAAE;EACjF,IAAIA,OAAO,KAAK,IAAI,IAAI,CAAC,IAAI,CAACC,KAAK,EAAE;IACnC,IAAAC,uBAAgB,EAACF,OAAO,EAAED,WAAW,EAAE,IAAI,CAAC;EAC9C;EAEA,OAAO;IACLI,IAAI,EAAEC,gBAAgB,CAACJ,OAAO,CAAC;IAC/BK,OAAO,EAAEA,CAAA,KAAM;MACb,MAAMC,EAAE,GAAG,IAAI,CAACL,KAAK,GAAG,IAAI,GAAG,QAAQ;MACvC,OAAO,CACL,IAAAM,6BAAW,EAAE,GAAE,IAAI,CAACN,KAAK,GAAG,MAAM,GAAG,EAAG,cAAa,EAAE,SAAS,EAAE,EAAE,CAAC,EACrE,EAAE,EACD,oBAAmBK,EAAG,WAAU,EACjC,IAAAE,oBAAa,EAACR,OAAO,CAAC,CACvB,CAACS,IAAI,CAAC,IAAI,CAAC;IACd;EACF,CAAC;AACH;AAEA,SAASL,gBAAgBA,CACvBJ,OAA0B,EAC1BU,kBAAwD,EAC/C;EACT;EACA,MAAMC,KAAK,GAAGD,kBAAkB,IAAI,IAAIE,OAAO,CAA6B,CAAC;EAC7E,IAAI,IAAAC,uCAAyB,EAACb,OAAO,EAAE;IAAEW;EAAM,CAAC,CAAC,EAAE;IACjD,OAAO,KAAK;EACd;EAEA,IAAIG,iBAAiB,CAACd,OAAO,CAAC,EAAE;IAC9B,OAAO,KAAK;EACd;;EAEA;EACA;EACA,IAAI,IAAAe,+BAAW,EAACf,OAAO,CAAC,IAAIA,OAAO,CAACgB,KAAK,CAACC,OAAO,KAAK,KAAK,EAAE;IAC3D,OAAO,KAAK;EACd;EAEA,MAAMC,UAAU,GAAG,IAAAC,4BAAa,EAACnB,OAAO,CAAC;EACzC,IAAIkB,UAAU,KAAK,IAAI,EAAE;IACvB,OAAO,IAAI;EACb;EAEA,OAAOd,gBAAgB,CAACc,UAAU,EAAEP,KAAK,CAAC;AAC5C;AAEA,SAASG,iBAAiBA,CAACd,OAA0B,EAAE;EACrD,MAAMoB,KAAK,GAAGpB,OAAO,CAACgB,KAAK,CAACI,KAAK,IAAI,CAAC,CAAC;EACvC,MAAM;IAAEC,OAAO;IAAEC;EAAQ,CAAC,GAAGC,uBAAU,CAACC,OAAO,CAACJ,KAAK,CAAC;EACtD,OAAOC,OAAO,KAAK,MAAM,IAAIC,OAAO,KAAK,CAAC;AAC5C"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"to-contain-element.js","names":["_jestMatcherUtils","require","_utils","toContainElement","container","element","checkHostElement","matches","findAll","node","pass","length","message","matcherHint","isNot","RECEIVED_COLOR","formatElement","join"],"sources":["../../src/matchers/to-contain-element.tsx"],"sourcesContent":["import { ReactTestInstance } from 'react-test-renderer';\nimport { matcherHint, RECEIVED_COLOR } from 'jest-matcher-utils';\nimport { checkHostElement, formatElement } from './utils';\n\nexport function toContainElement(\n this: jest.MatcherContext,\n container: ReactTestInstance,\n element: ReactTestInstance | null
|
|
1
|
+
{"version":3,"file":"to-contain-element.js","names":["_jestMatcherUtils","require","_utils","toContainElement","container","element","checkHostElement","matches","findAll","node","pass","length","message","matcherHint","isNot","RECEIVED_COLOR","formatElement","join"],"sources":["../../src/matchers/to-contain-element.tsx"],"sourcesContent":["import { ReactTestInstance } from 'react-test-renderer';\nimport { matcherHint, RECEIVED_COLOR } from 'jest-matcher-utils';\nimport { checkHostElement, formatElement } from './utils';\n\nexport function toContainElement(\n this: jest.MatcherContext,\n container: ReactTestInstance,\n element: ReactTestInstance | null,\n) {\n checkHostElement(container, toContainElement, this);\n\n if (element !== null) {\n checkHostElement(element, toContainElement, this);\n }\n\n let matches: ReactTestInstance[] = [];\n if (element) {\n matches = container.findAll((node) => node === element);\n }\n\n return {\n pass: matches.length > 0,\n message: () => {\n return [\n matcherHint(`${this.isNot ? '.not' : ''}.toContainElement`, 'container', 'element'),\n '',\n RECEIVED_COLOR(`${formatElement(container)} ${\n this.isNot ? '\\n\\ncontains:\\n\\n' : '\\n\\ndoes not contain:\\n\\n'\n } ${formatElement(element)}\n `),\n ].join('\\n');\n },\n };\n}\n"],"mappings":";;;;;;AACA,IAAAA,iBAAA,GAAAC,OAAA;AACA,IAAAC,MAAA,GAAAD,OAAA;AAEO,SAASE,gBAAgBA,CAE9BC,SAA4B,EAC5BC,OAAiC,EACjC;EACA,IAAAC,uBAAgB,EAACF,SAAS,EAAED,gBAAgB,EAAE,IAAI,CAAC;EAEnD,IAAIE,OAAO,KAAK,IAAI,EAAE;IACpB,IAAAC,uBAAgB,EAACD,OAAO,EAAEF,gBAAgB,EAAE,IAAI,CAAC;EACnD;EAEA,IAAII,OAA4B,GAAG,EAAE;EACrC,IAAIF,OAAO,EAAE;IACXE,OAAO,GAAGH,SAAS,CAACI,OAAO,CAAEC,IAAI,IAAKA,IAAI,KAAKJ,OAAO,CAAC;EACzD;EAEA,OAAO;IACLK,IAAI,EAAEH,OAAO,CAACI,MAAM,GAAG,CAAC;IACxBC,OAAO,EAAEA,CAAA,KAAM;MACb,OAAO,CACL,IAAAC,6BAAW,EAAE,GAAE,IAAI,CAACC,KAAK,GAAG,MAAM,GAAG,EAAG,mBAAkB,EAAE,WAAW,EAAE,SAAS,CAAC,EACnF,EAAE,EACF,IAAAC,gCAAc,EAAE,GAAE,IAAAC,oBAAa,EAACZ,SAAS,CAAE,IACzC,IAAI,CAACU,KAAK,GAAG,mBAAmB,GAAG,2BACpC,IAAG,IAAAE,oBAAa,EAACX,OAAO,CAAE;AACnC,SAAS,CAAC,CACH,CAACY,IAAI,CAAC,IAAI,CAAC;IACd;EACF,CAAC;AACH"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"to-have-accessibility-value.js","names":["_jestMatcherUtils","require","_accessiblity","_matchAccessibilityValue","_object","_utils","toHaveAccessibilityValue","element","expectedValue","checkHostElement","receivedValue","getAccessibilityValue","pass","matchAccessibilityValue","message","matcher","matcherHint","isNot","stringify","formatMessage","removeUndefinedKeys"],"sources":["../../src/matchers/to-have-accessibility-value.tsx"],"sourcesContent":["import type { ReactTestInstance } from 'react-test-renderer';\nimport { matcherHint, stringify } from 'jest-matcher-utils';\nimport { getAccessibilityValue } from '../helpers/accessiblity';\nimport {\n AccessibilityValueMatcher,\n matchAccessibilityValue,\n} from '../helpers/matchers/match-accessibility-value';\nimport { removeUndefinedKeys } from '../helpers/object';\nimport { checkHostElement, formatMessage } from './utils';\n\nexport function toHaveAccessibilityValue(\n this: jest.MatcherContext,\n element: ReactTestInstance,\n expectedValue: AccessibilityValueMatcher
|
|
1
|
+
{"version":3,"file":"to-have-accessibility-value.js","names":["_jestMatcherUtils","require","_accessiblity","_matchAccessibilityValue","_object","_utils","toHaveAccessibilityValue","element","expectedValue","checkHostElement","receivedValue","getAccessibilityValue","pass","matchAccessibilityValue","message","matcher","matcherHint","isNot","stringify","formatMessage","removeUndefinedKeys"],"sources":["../../src/matchers/to-have-accessibility-value.tsx"],"sourcesContent":["import type { ReactTestInstance } from 'react-test-renderer';\nimport { matcherHint, stringify } from 'jest-matcher-utils';\nimport { getAccessibilityValue } from '../helpers/accessiblity';\nimport {\n AccessibilityValueMatcher,\n matchAccessibilityValue,\n} from '../helpers/matchers/match-accessibility-value';\nimport { removeUndefinedKeys } from '../helpers/object';\nimport { checkHostElement, formatMessage } from './utils';\n\nexport function toHaveAccessibilityValue(\n this: jest.MatcherContext,\n element: ReactTestInstance,\n expectedValue: AccessibilityValueMatcher,\n) {\n checkHostElement(element, toHaveAccessibilityValue, this);\n\n const receivedValue = getAccessibilityValue(element);\n\n return {\n pass: matchAccessibilityValue(element, expectedValue),\n message: () => {\n const matcher = matcherHint(\n `${this.isNot ? '.not' : ''}.toHaveAccessibilityValue`,\n 'element',\n stringify(expectedValue),\n );\n return formatMessage(\n matcher,\n `Expected the element ${this.isNot ? 'not to' : 'to'} have accessibility value`,\n stringify(expectedValue),\n 'Received element with accessibility value',\n stringify(removeUndefinedKeys(receivedValue)),\n );\n },\n };\n}\n"],"mappings":";;;;;;AACA,IAAAA,iBAAA,GAAAC,OAAA;AACA,IAAAC,aAAA,GAAAD,OAAA;AACA,IAAAE,wBAAA,GAAAF,OAAA;AAIA,IAAAG,OAAA,GAAAH,OAAA;AACA,IAAAI,MAAA,GAAAJ,OAAA;AAEO,SAASK,wBAAwBA,CAEtCC,OAA0B,EAC1BC,aAAwC,EACxC;EACA,IAAAC,uBAAgB,EAACF,OAAO,EAAED,wBAAwB,EAAE,IAAI,CAAC;EAEzD,MAAMI,aAAa,GAAG,IAAAC,mCAAqB,EAACJ,OAAO,CAAC;EAEpD,OAAO;IACLK,IAAI,EAAE,IAAAC,gDAAuB,EAACN,OAAO,EAAEC,aAAa,CAAC;IACrDM,OAAO,EAAEA,CAAA,KAAM;MACb,MAAMC,OAAO,GAAG,IAAAC,6BAAW,EACxB,GAAE,IAAI,CAACC,KAAK,GAAG,MAAM,GAAG,EAAG,2BAA0B,EACtD,SAAS,EACT,IAAAC,2BAAS,EAACV,aAAa,CACzB,CAAC;MACD,OAAO,IAAAW,oBAAa,EAClBJ,OAAO,EACN,wBAAuB,IAAI,CAACE,KAAK,GAAG,QAAQ,GAAG,IAAK,2BAA0B,EAC/E,IAAAC,2BAAS,EAACV,aAAa,CAAC,EACxB,2CAA2C,EAC3C,IAAAU,2BAAS,EAAC,IAAAE,2BAAmB,EAACV,aAAa,CAAC,CAC9C,CAAC;IACH;EACF,CAAC;AACH"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"to-have-accessible-name.js","names":["_jestMatcherUtils","require","_accessiblity","_matches","_utils","toHaveAccessibleName","element","expectedName","options","checkHostElement","receivedName","getAccessibleName","missingExpectedValue","arguments","length","pass","matches","normalizer","exact","message","formatMessage","matcherHint","isNot","join"],"sources":["../../src/matchers/to-have-accessible-name.tsx"],"sourcesContent":["import type { ReactTestInstance } from 'react-test-renderer';\nimport { matcherHint } from 'jest-matcher-utils';\nimport { getAccessibleName } from '../helpers/accessiblity';\nimport { TextMatch, TextMatchOptions, matches } from '../matches';\nimport { checkHostElement, formatMessage } from './utils';\n\nexport function toHaveAccessibleName(\n this: jest.MatcherContext,\n element: ReactTestInstance,\n expectedName?: TextMatch,\n options?: TextMatchOptions
|
|
1
|
+
{"version":3,"file":"to-have-accessible-name.js","names":["_jestMatcherUtils","require","_accessiblity","_matches","_utils","toHaveAccessibleName","element","expectedName","options","checkHostElement","receivedName","getAccessibleName","missingExpectedValue","arguments","length","pass","matches","normalizer","exact","message","formatMessage","matcherHint","isNot","join"],"sources":["../../src/matchers/to-have-accessible-name.tsx"],"sourcesContent":["import type { ReactTestInstance } from 'react-test-renderer';\nimport { matcherHint } from 'jest-matcher-utils';\nimport { getAccessibleName } from '../helpers/accessiblity';\nimport { TextMatch, TextMatchOptions, matches } from '../matches';\nimport { checkHostElement, formatMessage } from './utils';\n\nexport function toHaveAccessibleName(\n this: jest.MatcherContext,\n element: ReactTestInstance,\n expectedName?: TextMatch,\n options?: TextMatchOptions,\n) {\n checkHostElement(element, toHaveAccessibleName, this);\n\n const receivedName = getAccessibleName(element);\n const missingExpectedValue = arguments.length === 1;\n\n let pass = false;\n if (missingExpectedValue) {\n pass = receivedName !== '';\n } else {\n pass =\n expectedName != null\n ? matches(expectedName, receivedName, options?.normalizer, options?.exact)\n : false;\n }\n\n return {\n pass,\n message: () => {\n return [\n formatMessage(\n matcherHint(`${this.isNot ? '.not' : ''}.toHaveAccessibleName`, 'element', ''),\n `Expected element ${this.isNot ? 'not to' : 'to'} have accessible name`,\n expectedName,\n 'Received',\n receivedName,\n ),\n ].join('\\n');\n },\n };\n}\n"],"mappings":";;;;;;AACA,IAAAA,iBAAA,GAAAC,OAAA;AACA,IAAAC,aAAA,GAAAD,OAAA;AACA,IAAAE,QAAA,GAAAF,OAAA;AACA,IAAAG,MAAA,GAAAH,OAAA;AAEO,SAASI,oBAAoBA,CAElCC,OAA0B,EAC1BC,YAAwB,EACxBC,OAA0B,EAC1B;EACA,IAAAC,uBAAgB,EAACH,OAAO,EAAED,oBAAoB,EAAE,IAAI,CAAC;EAErD,MAAMK,YAAY,GAAG,IAAAC,+BAAiB,EAACL,OAAO,CAAC;EAC/C,MAAMM,oBAAoB,GAAGC,SAAS,CAACC,MAAM,KAAK,CAAC;EAEnD,IAAIC,IAAI,GAAG,KAAK;EAChB,IAAIH,oBAAoB,EAAE;IACxBG,IAAI,GAAGL,YAAY,KAAK,EAAE;EAC5B,CAAC,MAAM;IACLK,IAAI,GACFR,YAAY,IAAI,IAAI,GAChB,IAAAS,gBAAO,EAACT,YAAY,EAAEG,YAAY,EAAEF,OAAO,EAAES,UAAU,EAAET,OAAO,EAAEU,KAAK,CAAC,GACxE,KAAK;EACb;EAEA,OAAO;IACLH,IAAI;IACJI,OAAO,EAAEA,CAAA,KAAM;MACb,OAAO,CACL,IAAAC,oBAAa,EACX,IAAAC,6BAAW,EAAE,GAAE,IAAI,CAACC,KAAK,GAAG,MAAM,GAAG,EAAG,uBAAsB,EAAE,SAAS,EAAE,EAAE,CAAC,EAC7E,oBAAmB,IAAI,CAACA,KAAK,GAAG,QAAQ,GAAG,IAAK,uBAAsB,EACvEf,YAAY,EACZ,UAAU,EACVG,YACF,CAAC,CACF,CAACa,IAAI,CAAC,IAAI,CAAC;IACd;EACF,CAAC;AACH"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"to-have-display-value.js","names":["_jestMatcherUtils","require","_hostComponentNames","_errors","_textInput","_matches","_utils","toHaveDisplayValue","element","expectedValue","options","checkHostElement","isHostTextInput","ErrorWithStack","type","receivedValue","getTextInputValue","pass","matches","normalizer","exact","message","formatMessage","matcherHint","isNot","join"],"sources":["../../src/matchers/to-have-display-value.tsx"],"sourcesContent":["import type { ReactTestInstance } from 'react-test-renderer';\nimport { matcherHint } from 'jest-matcher-utils';\nimport { isHostTextInput } from '../helpers/host-component-names';\nimport { ErrorWithStack } from '../helpers/errors';\nimport { getTextInputValue } from '../helpers/text-input';\nimport { TextMatch, TextMatchOptions, matches } from '../matches';\nimport { checkHostElement, formatMessage } from './utils';\n\nexport function toHaveDisplayValue(\n this: jest.MatcherContext,\n element: ReactTestInstance,\n expectedValue: TextMatch,\n options?: TextMatchOptions
|
|
1
|
+
{"version":3,"file":"to-have-display-value.js","names":["_jestMatcherUtils","require","_hostComponentNames","_errors","_textInput","_matches","_utils","toHaveDisplayValue","element","expectedValue","options","checkHostElement","isHostTextInput","ErrorWithStack","type","receivedValue","getTextInputValue","pass","matches","normalizer","exact","message","formatMessage","matcherHint","isNot","join"],"sources":["../../src/matchers/to-have-display-value.tsx"],"sourcesContent":["import type { ReactTestInstance } from 'react-test-renderer';\nimport { matcherHint } from 'jest-matcher-utils';\nimport { isHostTextInput } from '../helpers/host-component-names';\nimport { ErrorWithStack } from '../helpers/errors';\nimport { getTextInputValue } from '../helpers/text-input';\nimport { TextMatch, TextMatchOptions, matches } from '../matches';\nimport { checkHostElement, formatMessage } from './utils';\n\nexport function toHaveDisplayValue(\n this: jest.MatcherContext,\n element: ReactTestInstance,\n expectedValue: TextMatch,\n options?: TextMatchOptions,\n) {\n checkHostElement(element, toHaveDisplayValue, this);\n\n if (!isHostTextInput(element)) {\n throw new ErrorWithStack(\n `toHaveDisplayValue() works only with host \"TextInput\" elements. Passed element has type \"${element.type}\".`,\n toHaveDisplayValue,\n );\n }\n\n const receivedValue = getTextInputValue(element);\n\n return {\n pass: matches(expectedValue, receivedValue, options?.normalizer, options?.exact),\n message: () => {\n return [\n formatMessage(\n matcherHint(`${this.isNot ? '.not' : ''}.toHaveDisplayValue`, 'element', ''),\n `Expected element ${this.isNot ? 'not to' : 'to'} have display value`,\n expectedValue,\n 'Received',\n receivedValue,\n ),\n ].join('\\n');\n },\n };\n}\n"],"mappings":";;;;;;AACA,IAAAA,iBAAA,GAAAC,OAAA;AACA,IAAAC,mBAAA,GAAAD,OAAA;AACA,IAAAE,OAAA,GAAAF,OAAA;AACA,IAAAG,UAAA,GAAAH,OAAA;AACA,IAAAI,QAAA,GAAAJ,OAAA;AACA,IAAAK,MAAA,GAAAL,OAAA;AAEO,SAASM,kBAAkBA,CAEhCC,OAA0B,EAC1BC,aAAwB,EACxBC,OAA0B,EAC1B;EACA,IAAAC,uBAAgB,EAACH,OAAO,EAAED,kBAAkB,EAAE,IAAI,CAAC;EAEnD,IAAI,CAAC,IAAAK,mCAAe,EAACJ,OAAO,CAAC,EAAE;IAC7B,MAAM,IAAIK,sBAAc,CACrB,4FAA2FL,OAAO,CAACM,IAAK,IAAG,EAC5GP,kBACF,CAAC;EACH;EAEA,MAAMQ,aAAa,GAAG,IAAAC,4BAAiB,EAACR,OAAO,CAAC;EAEhD,OAAO;IACLS,IAAI,EAAE,IAAAC,gBAAO,EAACT,aAAa,EAAEM,aAAa,EAAEL,OAAO,EAAES,UAAU,EAAET,OAAO,EAAEU,KAAK,CAAC;IAChFC,OAAO,EAAEA,CAAA,KAAM;MACb,OAAO,CACL,IAAAC,oBAAa,EACX,IAAAC,6BAAW,EAAE,GAAE,IAAI,CAACC,KAAK,GAAG,MAAM,GAAG,EAAG,qBAAoB,EAAE,SAAS,EAAE,EAAE,CAAC,EAC3E,oBAAmB,IAAI,CAACA,KAAK,GAAG,QAAQ,GAAG,IAAK,qBAAoB,EACrEf,aAAa,EACb,UAAU,EACVM,aACF,CAAC,CACF,CAACU,IAAI,CAAC,IAAI,CAAC;IACd;EACF,CAAC;AACH"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"to-have-prop.js","names":["_jestMatcherUtils","require","_utils","toHaveProp","element","name","expectedValue","checkHostElement","isExpectedValueDefined","undefined","hasProp","props","receivedValue","pass","equals","message","to","isNot","matcher","matcherHint","printExpected","secondArgument","formatMessage","formatProp","value","stringify"],"sources":["../../src/matchers/to-have-prop.ts"],"sourcesContent":["import type { ReactTestInstance } from 'react-test-renderer';\nimport { matcherHint, stringify, printExpected } from 'jest-matcher-utils';\nimport { checkHostElement, formatMessage } from './utils';\n\nexport function toHaveProp(\n this: jest.MatcherContext,\n element: ReactTestInstance,\n name: string,\n expectedValue: unknown
|
|
1
|
+
{"version":3,"file":"to-have-prop.js","names":["_jestMatcherUtils","require","_utils","toHaveProp","element","name","expectedValue","checkHostElement","isExpectedValueDefined","undefined","hasProp","props","receivedValue","pass","equals","message","to","isNot","matcher","matcherHint","printExpected","secondArgument","formatMessage","formatProp","value","stringify"],"sources":["../../src/matchers/to-have-prop.ts"],"sourcesContent":["import type { ReactTestInstance } from 'react-test-renderer';\nimport { matcherHint, stringify, printExpected } from 'jest-matcher-utils';\nimport { checkHostElement, formatMessage } from './utils';\n\nexport function toHaveProp(\n this: jest.MatcherContext,\n element: ReactTestInstance,\n name: string,\n expectedValue: unknown,\n) {\n checkHostElement(element, toHaveProp, this);\n\n const isExpectedValueDefined = expectedValue !== undefined;\n const hasProp = name in element.props;\n const receivedValue = element.props[name];\n\n const pass = isExpectedValueDefined\n ? hasProp && this.equals(expectedValue, receivedValue)\n : hasProp;\n\n return {\n pass,\n message: () => {\n const to = this.isNot ? 'not to' : 'to';\n const matcher = matcherHint(\n `${this.isNot ? '.not' : ''}.toHaveProp`,\n 'element',\n printExpected(name),\n {\n secondArgument: isExpectedValueDefined ? printExpected(expectedValue) : undefined,\n },\n );\n return formatMessage(\n matcher,\n `Expected element ${to} have prop`,\n formatProp(name, expectedValue),\n 'Received',\n hasProp ? formatProp(name, receivedValue) : undefined,\n );\n },\n };\n}\n\nfunction formatProp(name: string, value: unknown) {\n if (value === undefined) {\n return name;\n }\n\n if (typeof value === 'string') {\n return `${name}=\"${value}\"`;\n }\n\n return `${name}={${stringify(value)}}`;\n}\n"],"mappings":";;;;;;AACA,IAAAA,iBAAA,GAAAC,OAAA;AACA,IAAAC,MAAA,GAAAD,OAAA;AAEO,SAASE,UAAUA,CAExBC,OAA0B,EAC1BC,IAAY,EACZC,aAAsB,EACtB;EACA,IAAAC,uBAAgB,EAACH,OAAO,EAAED,UAAU,EAAE,IAAI,CAAC;EAE3C,MAAMK,sBAAsB,GAAGF,aAAa,KAAKG,SAAS;EAC1D,MAAMC,OAAO,IAAGL,IAAI,IAAID,OAAO,CAACO,KAAK;EACrC,MAAMC,aAAa,GAAGR,OAAO,CAACO,KAAK,CAACN,IAAI,CAAC;EAEzC,MAAMQ,IAAI,GAAGL,sBAAsB,GAC/BE,OAAO,IAAI,IAAI,CAACI,MAAM,CAACR,aAAa,EAAEM,aAAa,CAAC,GACpDF,OAAO;EAEX,OAAO;IACLG,IAAI;IACJE,OAAO,EAAEA,CAAA,KAAM;MACb,MAAMC,EAAE,GAAG,IAAI,CAACC,KAAK,GAAG,QAAQ,GAAG,IAAI;MACvC,MAAMC,OAAO,GAAG,IAAAC,6BAAW,EACxB,GAAE,IAAI,CAACF,KAAK,GAAG,MAAM,GAAG,EAAG,aAAY,EACxC,SAAS,EACT,IAAAG,+BAAa,EAACf,IAAI,CAAC,EACnB;QACEgB,cAAc,EAAEb,sBAAsB,GAAG,IAAAY,+BAAa,EAACd,aAAa,CAAC,GAAGG;MAC1E,CACF,CAAC;MACD,OAAO,IAAAa,oBAAa,EAClBJ,OAAO,EACN,oBAAmBF,EAAG,YAAW,EAClCO,UAAU,CAAClB,IAAI,EAAEC,aAAa,CAAC,EAC/B,UAAU,EACVI,OAAO,GAAGa,UAAU,CAAClB,IAAI,EAAEO,aAAa,CAAC,GAAGH,SAC9C,CAAC;IACH;EACF,CAAC;AACH;AAEA,SAASc,UAAUA,CAAClB,IAAY,EAAEmB,KAAc,EAAE;EAChD,IAAIA,KAAK,KAAKf,SAAS,EAAE;IACvB,OAAOJ,IAAI;EACb;EAEA,IAAI,OAAOmB,KAAK,KAAK,QAAQ,EAAE;IAC7B,OAAQ,GAAEnB,IAAK,KAAImB,KAAM,GAAE;EAC7B;EAEA,OAAQ,GAAEnB,IAAK,KAAI,IAAAoB,2BAAS,EAACD,KAAK,CAAE,GAAE;AACxC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"to-have-style.js","names":["_reactNative","require","_jestMatcherUtils","_utils","toHaveStyle","element","style","checkHostElement","expected","StyleSheet","flatten","received","props","pass","Object","keys","every","key","equals","message","to","isNot","matcher","matcherHint","formatMessage","formatStyles","pickReceivedStyles","expectedDiff","join","receivedNarrow","diff","result","forEach","undefined","sort","map","prop","Array","isArray","JSON","stringify"],"sources":["../../src/matchers/to-have-style.tsx"],"sourcesContent":["import type { ReactTestInstance } from 'react-test-renderer';\nimport {
|
|
1
|
+
{"version":3,"file":"to-have-style.js","names":["_reactNative","require","_jestMatcherUtils","_utils","toHaveStyle","element","style","checkHostElement","expected","StyleSheet","flatten","received","props","pass","Object","keys","every","key","equals","message","to","isNot","matcher","matcherHint","formatMessage","formatStyles","pickReceivedStyles","expectedDiff","join","receivedNarrow","diff","result","forEach","undefined","sort","map","prop","Array","isArray","JSON","stringify"],"sources":["../../src/matchers/to-have-style.tsx"],"sourcesContent":["import type { ReactTestInstance } from 'react-test-renderer';\nimport { ImageStyle, StyleProp, StyleSheet, TextStyle, ViewStyle } from 'react-native';\nimport { matcherHint, diff } from 'jest-matcher-utils';\nimport { checkHostElement, formatMessage } from './utils';\n\nexport type Style = ViewStyle | TextStyle | ImageStyle;\n\ntype StyleLike = Record<string, unknown>;\n\nexport function toHaveStyle(\n this: jest.MatcherContext,\n element: ReactTestInstance,\n style: StyleProp<Style>,\n) {\n checkHostElement(element, toHaveStyle, this);\n\n const expected = (StyleSheet.flatten(style) as StyleLike) ?? {};\n const received = (StyleSheet.flatten(element.props.style) as StyleLike) ?? {};\n\n const pass = Object.keys(expected).every((key) => this.equals(expected[key], received[key]));\n\n return {\n pass,\n message: () => {\n const to = this.isNot ? 'not to' : 'to';\n const matcher = matcherHint(`${this.isNot ? '.not' : ''}.toHaveStyle`, 'element', '');\n\n if (pass) {\n return formatMessage(\n matcher,\n `Expected element ${to} have style`,\n formatStyles(expected),\n 'Received',\n formatStyles(pickReceivedStyles(expected, received)),\n );\n } else {\n return [matcher, '', expectedDiff(expected, received)].join('\\n');\n }\n },\n };\n}\n\n/**\n * Generate diff between `expected` and `received` styles.\n */\nfunction expectedDiff(expected: StyleLike, received: StyleLike) {\n const receivedNarrow = pickReceivedStyles(expected, received);\n return diff(formatStyles(expected), formatStyles(receivedNarrow));\n}\n\n/**\n * Pick from `received` style only the keys present in `expected` style.\n */\nfunction pickReceivedStyles(expected: StyleLike, received: StyleLike) {\n const result: StyleLike = {};\n Object.keys(received).forEach((key) => {\n if (expected[key] !== undefined) {\n result[key] = received[key];\n }\n });\n\n return result;\n}\n\nfunction formatStyles(style: StyleLike) {\n return Object.keys(style)\n .sort()\n .map((prop) =>\n Array.isArray(style[prop])\n ? `${prop}: ${JSON.stringify(style[prop], null, 2)};`\n : `${prop}: ${style[prop]};`,\n )\n .join('\\n');\n}\n"],"mappings":";;;;;;AACA,IAAAA,YAAA,GAAAC,OAAA;AACA,IAAAC,iBAAA,GAAAD,OAAA;AACA,IAAAE,MAAA,GAAAF,OAAA;AAMO,SAASG,WAAWA,CAEzBC,OAA0B,EAC1BC,KAAuB,EACvB;EACA,IAAAC,uBAAgB,EAACF,OAAO,EAAED,WAAW,EAAE,IAAI,CAAC;EAE5C,MAAMI,QAAQ,GAAIC,uBAAU,CAACC,OAAO,CAACJ,KAAK,CAAC,IAAkB,CAAC,CAAC;EAC/D,MAAMK,QAAQ,GAAIF,uBAAU,CAACC,OAAO,CAACL,OAAO,CAACO,KAAK,CAACN,KAAK,CAAC,IAAkB,CAAC,CAAC;EAE7E,MAAMO,IAAI,GAAGC,MAAM,CAACC,IAAI,CAACP,QAAQ,CAAC,CAACQ,KAAK,CAAEC,GAAG,IAAK,IAAI,CAACC,MAAM,CAACV,QAAQ,CAACS,GAAG,CAAC,EAAEN,QAAQ,CAACM,GAAG,CAAC,CAAC,CAAC;EAE5F,OAAO;IACLJ,IAAI;IACJM,OAAO,EAAEA,CAAA,KAAM;MACb,MAAMC,EAAE,GAAG,IAAI,CAACC,KAAK,GAAG,QAAQ,GAAG,IAAI;MACvC,MAAMC,OAAO,GAAG,IAAAC,6BAAW,EAAE,GAAE,IAAI,CAACF,KAAK,GAAG,MAAM,GAAG,EAAG,cAAa,EAAE,SAAS,EAAE,EAAE,CAAC;MAErF,IAAIR,IAAI,EAAE;QACR,OAAO,IAAAW,oBAAa,EAClBF,OAAO,EACN,oBAAmBF,EAAG,aAAY,EACnCK,YAAY,CAACjB,QAAQ,CAAC,EACtB,UAAU,EACViB,YAAY,CAACC,kBAAkB,CAAClB,QAAQ,EAAEG,QAAQ,CAAC,CACrD,CAAC;MACH,CAAC,MAAM;QACL,OAAO,CAACW,OAAO,EAAE,EAAE,EAAEK,YAAY,CAACnB,QAAQ,EAAEG,QAAQ,CAAC,CAAC,CAACiB,IAAI,CAAC,IAAI,CAAC;MACnE;IACF;EACF,CAAC;AACH;;AAEA;AACA;AACA;AACA,SAASD,YAAYA,CAACnB,QAAmB,EAAEG,QAAmB,EAAE;EAC9D,MAAMkB,cAAc,GAAGH,kBAAkB,CAAClB,QAAQ,EAAEG,QAAQ,CAAC;EAC7D,OAAO,IAAAmB,sBAAI,EAACL,YAAY,CAACjB,QAAQ,CAAC,EAAEiB,YAAY,CAACI,cAAc,CAAC,CAAC;AACnE;;AAEA;AACA;AACA;AACA,SAASH,kBAAkBA,CAAClB,QAAmB,EAAEG,QAAmB,EAAE;EACpE,MAAMoB,MAAiB,GAAG,CAAC,CAAC;EAC5BjB,MAAM,CAACC,IAAI,CAACJ,QAAQ,CAAC,CAACqB,OAAO,CAAEf,GAAG,IAAK;IACrC,IAAIT,QAAQ,CAACS,GAAG,CAAC,KAAKgB,SAAS,EAAE;MAC/BF,MAAM,CAACd,GAAG,CAAC,GAAGN,QAAQ,CAACM,GAAG,CAAC;IAC7B;EACF,CAAC,CAAC;EAEF,OAAOc,MAAM;AACf;AAEA,SAASN,YAAYA,CAACnB,KAAgB,EAAE;EACtC,OAAOQ,MAAM,CAACC,IAAI,CAACT,KAAK,CAAC,CACtB4B,IAAI,CAAC,CAAC,CACNC,GAAG,CAAEC,IAAI,IACRC,KAAK,CAACC,OAAO,CAAChC,KAAK,CAAC8B,IAAI,CAAC,CAAC,GACrB,GAAEA,IAAK,KAAIG,IAAI,CAACC,SAAS,CAAClC,KAAK,CAAC8B,IAAI,CAAC,EAAE,IAAI,EAAE,CAAC,CAAE,GAAE,GAClD,GAAEA,IAAK,KAAI9B,KAAK,CAAC8B,IAAI,CAAE,GAC9B,CAAC,CACAR,IAAI,CAAC,IAAI,CAAC;AACf"}
|