@testing-library/react-native 13.0.0 → 13.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -2
- package/build/act.d.ts +1 -1
- package/build/act.js +1 -3
- package/build/act.js.map +1 -1
- package/build/config.d.ts +1 -1
- package/build/config.js.map +1 -1
- package/build/fire-event.d.ts +3 -3
- package/build/fire-event.js.map +1 -1
- package/build/helpers/accessibility.d.ts +1 -1
- package/build/helpers/accessibility.js.map +1 -1
- package/build/helpers/component-tree.d.ts +1 -1
- package/build/helpers/component-tree.js.map +1 -1
- package/build/helpers/debug.d.ts +3 -3
- package/build/helpers/debug.js +8 -11
- package/build/helpers/debug.js.map +1 -1
- package/build/helpers/errors.js +4 -4
- package/build/helpers/errors.js.map +1 -1
- package/build/helpers/find-all.d.ts +2 -2
- package/build/helpers/find-all.js.map +1 -1
- package/build/helpers/format-element.d.ts +18 -0
- package/build/helpers/format-element.js +81 -0
- package/build/helpers/format-element.js.map +1 -0
- package/build/helpers/host-component-names.d.ts +2 -2
- package/build/helpers/host-component-names.js.map +1 -1
- package/build/helpers/logger.d.ts +6 -0
- package/build/helpers/logger.js +37 -0
- package/build/helpers/logger.js.map +1 -0
- package/build/helpers/{format-default.d.ts → map-props.d.ts} +1 -0
- package/build/helpers/{format-default.js → map-props.js} +2 -2
- package/build/helpers/map-props.js.map +1 -0
- package/build/helpers/matchers/match-accessibility-state.d.ts +1 -1
- package/build/helpers/matchers/match-accessibility-state.js.map +1 -1
- package/build/helpers/matchers/match-accessibility-value.d.ts +2 -2
- package/build/helpers/matchers/match-accessibility-value.js.map +1 -1
- package/build/helpers/matchers/match-label-text.d.ts +2 -2
- package/build/helpers/matchers/match-label-text.js.map +1 -1
- package/build/helpers/matchers/match-string-prop.d.ts +1 -1
- package/build/helpers/matchers/match-string-prop.js.map +1 -1
- package/build/helpers/matchers/match-text-content.d.ts +1 -1
- package/build/helpers/matchers/match-text-content.js.map +1 -1
- package/build/helpers/object.d.ts +1 -1
- package/build/helpers/object.js.map +1 -1
- package/build/helpers/pointer-events.d.ts +1 -1
- package/build/helpers/pointer-events.js.map +1 -1
- package/build/helpers/string-validation.d.ts +1 -1
- package/build/helpers/string-validation.js.map +1 -1
- package/build/helpers/text-input.d.ts +1 -1
- package/build/helpers/text-input.js.map +1 -1
- package/build/helpers/timers.d.ts +1 -1
- package/build/helpers/timers.js.map +1 -1
- package/build/index.flow.js +28 -32
- package/build/index.js +3 -4
- package/build/index.js.map +1 -1
- package/build/matchers/extend-expect.js +2 -2
- package/build/matchers/extend-expect.js.map +1 -1
- package/build/matchers/index.d.ts +1 -1
- package/build/matchers/index.js.map +1 -1
- package/build/matchers/to-be-busy.d.ts +1 -1
- package/build/matchers/to-be-busy.js +4 -1
- package/build/matchers/to-be-busy.js.map +1 -1
- package/build/matchers/to-be-checked.js +4 -1
- package/build/matchers/to-be-checked.js.map +1 -1
- package/build/matchers/to-be-disabled.js +5 -2
- package/build/matchers/to-be-disabled.js.map +1 -1
- package/build/matchers/to-be-empty-element.d.ts +1 -1
- package/build/matchers/to-be-empty-element.js +4 -1
- package/build/matchers/to-be-empty-element.js.map +1 -1
- package/build/matchers/to-be-expanded.d.ts +1 -1
- package/build/matchers/to-be-expanded.js +5 -2
- package/build/matchers/to-be-expanded.js.map +1 -1
- package/build/matchers/to-be-on-the-screen.js +4 -1
- package/build/matchers/to-be-on-the-screen.js.map +1 -1
- package/build/matchers/to-be-partially-checked.js +4 -1
- package/build/matchers/to-be-partially-checked.js.map +1 -1
- package/build/matchers/to-be-selected.d.ts +1 -1
- package/build/matchers/to-be-selected.js +4 -1
- package/build/matchers/to-be-selected.js.map +1 -1
- package/build/matchers/to-be-visible.js +5 -2
- package/build/matchers/to-be-visible.js.map +1 -1
- package/build/matchers/to-contain-element.d.ts +1 -1
- package/build/matchers/to-contain-element.js +4 -1
- package/build/matchers/to-contain-element.js.map +1 -1
- package/build/matchers/to-have-accessibility-value.d.ts +1 -1
- package/build/matchers/to-have-accessibility-value.js.map +1 -1
- package/build/matchers/to-have-accessible-name.d.ts +1 -1
- package/build/matchers/to-have-accessible-name.js.map +1 -1
- package/build/matchers/to-have-display-value.d.ts +1 -1
- package/build/matchers/to-have-display-value.js +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.d.ts +1 -1
- package/build/matchers/to-have-style.js.map +1 -1
- package/build/matchers/to-have-text-content.d.ts +1 -1
- package/build/matchers/to-have-text-content.js.map +1 -1
- package/build/matchers/types.d.ts +3 -3
- package/build/matchers/types.js.map +1 -1
- package/build/matchers/utils.d.ts +1 -8
- package/build/matchers/utils.js +0 -41
- package/build/matchers/utils.js.map +1 -1
- package/build/native-state.d.ts +3 -3
- package/build/native-state.js +1 -1
- package/build/native-state.js.map +1 -1
- package/build/queries/display-value.d.ts +1 -1
- package/build/queries/display-value.js.map +1 -1
- package/build/queries/hint-text.d.ts +2 -2
- package/build/queries/hint-text.js.map +1 -1
- package/build/queries/label-text.d.ts +2 -2
- package/build/queries/label-text.js.map +1 -1
- package/build/queries/make-queries.js +5 -8
- package/build/queries/make-queries.js.map +1 -1
- package/build/queries/options.d.ts +1 -1
- package/build/queries/options.js.map +1 -1
- package/build/queries/placeholder-text.d.ts +1 -1
- package/build/queries/placeholder-text.js +1 -1
- package/build/queries/placeholder-text.js.map +1 -1
- package/build/queries/role.d.ts +5 -5
- package/build/queries/role.js.map +1 -1
- package/build/queries/test-id.d.ts +1 -1
- package/build/queries/test-id.js.map +1 -1
- package/build/queries/text.d.ts +1 -1
- package/build/queries/text.js.map +1 -1
- package/build/queries/unsafe-props.d.ts +6 -12
- package/build/queries/unsafe-props.js.map +1 -1
- package/build/queries/unsafe-type.d.ts +2 -1
- package/build/queries/unsafe-type.js +2 -0
- package/build/queries/unsafe-type.js.map +1 -1
- package/build/render-act.js +2 -2
- package/build/render-act.js.map +1 -1
- package/build/render-hook.d.ts +16 -6
- package/build/render-hook.js +21 -21
- package/build/render-hook.js.map +1 -1
- package/build/render.d.ts +12 -12
- package/build/render.js +9 -18
- package/build/render.js.map +1 -1
- package/build/screen.d.ts +1 -1
- package/build/screen.js.map +1 -1
- package/build/tsconfig.release.tsbuildinfo +1 -1
- package/build/user-event/clear.d.ts +2 -2
- package/build/user-event/clear.js +2 -2
- package/build/user-event/clear.js.map +1 -1
- package/build/user-event/event-builder/base.d.ts +2 -2
- package/build/user-event/event-builder/base.js.map +1 -1
- package/build/user-event/event-builder/scroll-view.d.ts +1 -1
- package/build/user-event/event-builder/scroll-view.js.map +1 -1
- package/build/user-event/event-builder/text-input.d.ts +2 -2
- package/build/user-event/event-builder/text-input.js.map +1 -1
- package/build/user-event/index.d.ts +4 -4
- package/build/user-event/index.js.map +1 -1
- package/build/user-event/paste.d.ts +2 -2
- package/build/user-event/paste.js.map +1 -1
- package/build/user-event/press/index.d.ts +1 -1
- package/build/user-event/press/index.js.map +1 -1
- package/build/user-event/press/press.d.ts +2 -2
- package/build/user-event/press/press.js +2 -2
- package/build/user-event/press/press.js.map +1 -1
- package/build/user-event/scroll/index.d.ts +1 -1
- package/build/user-event/scroll/index.js.map +1 -1
- package/build/user-event/scroll/scroll-to.d.ts +3 -3
- package/build/user-event/scroll/scroll-to.js +1 -1
- package/build/user-event/scroll/scroll-to.js.map +1 -1
- package/build/user-event/scroll/utils.d.ts +1 -1
- package/build/user-event/scroll/utils.js.map +1 -1
- package/build/user-event/setup/setup.d.ts +4 -4
- package/build/user-event/setup/setup.js.map +1 -1
- package/build/user-event/type/type.d.ts +2 -2
- package/build/user-event/type/type.js +3 -3
- package/build/user-event/type/type.js.map +1 -1
- package/build/user-event/utils/content-size.d.ts +1 -1
- package/build/user-event/utils/content-size.js.map +1 -1
- package/build/user-event/utils/dispatch-event.d.ts +1 -1
- package/build/user-event/utils/dispatch-event.js.map +1 -1
- package/build/user-event/utils/wait.d.ts +6 -2
- package/build/user-event/utils/wait.js +1 -1
- package/build/user-event/utils/wait.js.map +1 -1
- package/build/wait-for-element-to-be-removed.js +1 -1
- package/build/wait-for-element-to-be-removed.js.map +1 -1
- package/build/wait-for.js +1 -4
- package/build/wait-for.js.map +1 -1
- package/build/within.d.ts +4 -4
- package/build/within.js +5 -5
- package/build/within.js.map +1 -1
- package/package.json +8 -7
- package/typings/index.flow.js +28 -32
- package/build/helpers/format-default.js.map +0 -1
- package/build/helpers/format.d.ts +0 -7
- package/build/helpers/format.js +0 -31
- package/build/helpers/format.js.map +0 -1
|
@@ -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.ts"],"sourcesContent":["import type {
|
|
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.ts"],"sourcesContent":["import type { ImageStyle, StyleProp, TextStyle, ViewStyle } from 'react-native';\nimport { StyleSheet } from 'react-native';\nimport type { ReactTestInstance } from 'react-test-renderer';\nimport { diff, matcherHint } 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;AAEA,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,KAA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M,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,GACtB,GAAGA,IAAI,KAAKG,IAAI,CAACC,SAAS,CAAClC,KAAK,CAAC8B,IAAI,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,GAAG,GACnD,GAAGA,IAAI,KAAK9B,KAAK,CAAC8B,IAAI,CAAC,GAC7B,CAAC,CACAR,IAAI,CAAC,IAAI,CAAC;AACf","ignoreList":[]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { ReactTestInstance } from 'react-test-renderer';
|
|
2
|
-
import { TextMatch, TextMatchOptions } from '../matches';
|
|
2
|
+
import type { TextMatch, TextMatchOptions } from '../matches';
|
|
3
3
|
export declare function toHaveTextContent(this: jest.MatcherContext, element: ReactTestInstance, expectedText: TextMatch, options?: TextMatchOptions): {
|
|
4
4
|
pass: boolean;
|
|
5
5
|
message: () => string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"to-have-text-content.js","names":["_jestMatcherUtils","require","_textContent","_matches","_utils","toHaveTextContent","element","expectedText","options","checkHostElement","text","getTextContent","pass","matches","normalizer","exact","message","formatMessage","matcherHint","isNot","join"],"sources":["../../src/matchers/to-have-text-content.ts"],"sourcesContent":["import type { ReactTestInstance } from 'react-test-renderer';\nimport { matcherHint } from 'jest-matcher-utils';\nimport { getTextContent } from '../helpers/text-content';\nimport { TextMatch, TextMatchOptions
|
|
1
|
+
{"version":3,"file":"to-have-text-content.js","names":["_jestMatcherUtils","require","_textContent","_matches","_utils","toHaveTextContent","element","expectedText","options","checkHostElement","text","getTextContent","pass","matches","normalizer","exact","message","formatMessage","matcherHint","isNot","join"],"sources":["../../src/matchers/to-have-text-content.ts"],"sourcesContent":["import type { ReactTestInstance } from 'react-test-renderer';\nimport { matcherHint } from 'jest-matcher-utils';\nimport { getTextContent } from '../helpers/text-content';\nimport type { TextMatch, TextMatchOptions } from '../matches';\nimport { matches } from '../matches';\nimport { checkHostElement, formatMessage } from './utils';\n\nexport function toHaveTextContent(\n this: jest.MatcherContext,\n element: ReactTestInstance,\n expectedText: TextMatch,\n options?: TextMatchOptions,\n) {\n checkHostElement(element, toHaveTextContent, this);\n\n const text = getTextContent(element);\n\n return {\n pass: matches(expectedText, text, options?.normalizer, options?.exact),\n message: () => {\n return [\n formatMessage(\n matcherHint(`${this.isNot ? '.not' : ''}.toHaveTextContent`, 'element', ''),\n `Expected element ${this.isNot ? 'not to' : 'to'} have text content`,\n expectedText,\n 'Received',\n text,\n ),\n ].join('\\n');\n },\n };\n}\n"],"mappings":";;;;;;AACA,IAAAA,iBAAA,GAAAC,OAAA;AACA,IAAAC,YAAA,GAAAD,OAAA;AAEA,IAAAE,QAAA,GAAAF,OAAA;AACA,IAAAG,MAAA,GAAAH,OAAA;AAEO,SAASI,iBAAiBA,CAE/BC,OAA0B,EAC1BC,YAAuB,EACvBC,OAA0B,EAC1B;EACA,IAAAC,uBAAgB,EAACH,OAAO,EAAED,iBAAiB,EAAE,IAAI,CAAC;EAElD,MAAMK,IAAI,GAAG,IAAAC,2BAAc,EAACL,OAAO,CAAC;EAEpC,OAAO;IACLM,IAAI,EAAE,IAAAC,gBAAO,EAACN,YAAY,EAAEG,IAAI,EAAEF,OAAO,EAAEM,UAAU,EAAEN,OAAO,EAAEO,KAAK,CAAC;IACtEC,OAAO,EAAEA,CAAA,KAAM;MACb,OAAO,CACL,IAAAC,oBAAa,EACX,IAAAC,6BAAW,EAAC,GAAG,IAAI,CAACC,KAAK,GAAG,MAAM,GAAG,EAAE,oBAAoB,EAAE,SAAS,EAAE,EAAE,CAAC,EAC3E,oBAAoB,IAAI,CAACA,KAAK,GAAG,QAAQ,GAAG,IAAI,oBAAoB,EACpEZ,YAAY,EACZ,UAAU,EACVG,IACF,CAAC,CACF,CAACU,IAAI,CAAC,IAAI,CAAC;IACd;EACF,CAAC;AACH","ignoreList":[]}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { StyleProp } from 'react-native';
|
|
2
2
|
import type { ReactTestInstance } from 'react-test-renderer';
|
|
3
|
-
import { AccessibilityValueMatcher } from '../helpers/matchers/match-accessibility-value';
|
|
4
|
-
import { TextMatch, TextMatchOptions } from '../matches';
|
|
5
|
-
import { Style } from './to-have-style';
|
|
3
|
+
import type { AccessibilityValueMatcher } from '../helpers/matchers/match-accessibility-value';
|
|
4
|
+
import type { TextMatch, TextMatchOptions } from '../matches';
|
|
5
|
+
import type { Style } from './to-have-style';
|
|
6
6
|
export interface JestNativeMatchers<R> {
|
|
7
7
|
/**
|
|
8
8
|
* Assert whether a host element is present in the element tree (screen) or not.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","names":[],"sources":["../../src/matchers/types.ts"],"sourcesContent":["import type { StyleProp } from 'react-native';\nimport type { ReactTestInstance } from 'react-test-renderer';\nimport { AccessibilityValueMatcher } from '../helpers/matchers/match-accessibility-value';\nimport { TextMatch, TextMatchOptions } from '../matches';\nimport { Style } from './to-have-style';\n\nexport interface JestNativeMatchers<R> {\n /**\n * Assert whether a host element is present in the element tree (screen) or not.\n *\n * @see\n * [Jest Matchers docs](https://callstack.github.io/react-native-testing-library/docs/jest-matchers#tobeonthescreen)\n *\n * @example\n * <Text>Hello</Text>\n *\n * expect(getByText('Hello')).toBeOnTheScreen()\n * expect(queryByText('Other')).not.toBeOnTheScreen()\n */\n toBeOnTheScreen(): R;\n\n /**\n * Assert whether a host element is checked based on accessibility props.\n *\n * @see\n * [Jest Matchers docs](https://callstack.github.io/react-native-testing-library/docs/jest-matchers#tobechecked)\n *\n * @see {@link toBePartiallyChecked} for a related matcher.\n *\n * @example\n * <View accessible role=\"checkbox\" aria-checked aria-label=\"Enable\" />\n *\n * expect(getByRole('checkbox', { name: \"Enable\" })).toBeChecked()\n */\n toBeChecked(): R;\n\n /**\n * Assert whether a host element is collapsed based on accessibility props.\n *\n * @see\n * [Jest Matchers docs](https://callstack.github.io/react-native-testing-library/docs/jest-matchers#tobeexpanded)\n *\n * @see {@link toBeExpanded} for an inverse matcher.\n *\n * @example\n * <View testID=\"details\" aria-expanded={false} />\n *\n * expect(getByTestId('details').toBeCollapsed()\n */\n toBeCollapsed(): R;\n\n /**\n * Assert whether a host element is disabled based on accessibility props.\n *\n * This matcher will check ancestor elements for their disabled state as well.\n *\n * @see\n * [Jest Matchers docs](https://callstack.github.io/react-native-testing-library/docs/jest-matchers#tobeenabled)\n *\n * @see {@link toBeEnabled} for an inverse matcher.\n *\n * @example\n * <View role=\"button\" aria-disabled />\n *\n * expect(getByRole('button').toBeDisabled()\n *\n */\n toBeDisabled(): R;\n\n /**\n * Assert whether a host element is busy based on accessibility props.\n *\n * This matcher will check ancestor elements for their disabled state as well.\n *\n * @see\n * [Jest Matchers docs](https://callstack.github.io/react-native-testing-library/docs/jest-matchers#tobebusy)\n *\n * @example\n * <View testID=\"loader\" aria-busy />\n *\n * expect(getByTestId('loader')).toBeBusy()\n */\n toBeBusy(): R;\n\n /**\n * Assert whether a host element has no host children or text content.\n *\n * @see\n * [Jest Matchers docs](https://callstack.github.io/react-native-testing-library/docs/jest-matchers#tobeemptyelement)\n *\n * @example\n * <View testID=\"not-empty\">\n * <View testID=\"empty\" />\n * </View>\n *\n * expect(getByTestId('empty')).toBeEmptyElement()\n * expect(getByTestId('not-mepty')).not.toBeEmptyElement()\n */\n toBeEmptyElement(): R;\n\n /**\n * Assert whether a host element is enabled based on accessibility props.\n *\n * This matcher will check ancestor elements for their disabled state as well.\n *\n * @see\n * [Jest Matchers docs](https://callstack.github.io/react-native-testing-library/docs/jest-matchers#tobeenabled)\n *\n * @see {@link toBeDisabled} for inverse matcher.\n *\n * @example\n * <View role=\"button\" aria-disabled={false} />\n *\n * expect(getByRole('button').toBeEnabled()\n */\n toBeEnabled(): R;\n\n /**\n * Assert whether a host element is expanded based on accessibility props.\n *\n * @see\n * [Jest Matchers docs](https://callstack.github.io/react-native-testing-library/docs/jest-matchers#tobeexpanded)\n *\n * @see {@link toBeCollapsed} for inverse matcher.\n *\n * @example\n * <View testID=\"details\" aria-expanded />\n *\n * expect(getByTestId('details').toBeExpanded()\n */\n toBeExpanded(): R;\n\n /**\n * Assert whether a host element is partially checked based on accessibility props.\n *\n * @see\n * [Jest Matchers docs](https://callstack.github.io/react-native-testing-library/docs/jest-matchers#tobechecked)\n *\n * @see {@link toBeChecked} for related matcher.\n *\n * @example\n * <View accessible role=\"checkbox\" aria-checked=\"mixed\" aria-label=\"Enable\" />\n *\n * expect(getByRole('checkbox', { name: \"Enable\" })).toBePartiallyChecked()\n */\n toBePartiallyChecked(): R;\n\n /**\n * Assert whether a host element is selected based on accessibility props.\n *\n * @see\n * [Jest Matchers docs](https://callstack.github.io/react-native-testing-library/docs/jest-matchers#tobeselected)\n *\n * @example\n * <View testID=\"view\" aria-selected />\n *\n * expect(getByTestId('view')).toBeSelected()\n */\n toBeSelected(): R;\n\n /**\n * Assert whether a host element is visible based on style and accessibility props.\n *\n * This matcher will check ancestor elements for their visibility as well.\n *\n * @see\n * [Jest Matchers docs](https://callstack.github.io/react-native-testing-library/docs/jest-matchers#tobevisible)\n *\n * @example\n * <View testID=\"visible\" />\n * <View testID=\"not-visible\" style={{ display: 'none' }} />\n *\n * expect(getByTestId('visible')).toBeVisible()\n * expect(getByTestId('not-visible')).not.toBeVisible()\n */\n toBeVisible(): R;\n\n /**\n * Assert whether a host element contains another host element.\n *\n * @see\n * [Jest Matchers docs](https://callstack.github.io/react-native-testing-library/docs/jest-matchers#tocontainelement)\n *\n * @example\n * <View testID=\"outer\">\n * <View testID=\"inner\" />\n * </View>\n *\n * expect(getByTestId('outer')).toContainElement(getByTestId('inner'));\n */\n toContainElement(element: ReactTestInstance | null): R;\n\n /**\n * Assert whether a host element has a given accessbility value.\n *\n * @see\n * [Jest Matchers docs](https://callstack.github.io/react-native-testing-library/docs/jest-matchers#tohaveaccessibilityvalue)\n *\n *\n * @example\n * <View testID=\"view\" aria-valuetext=\"33%\" />\n *\n * expect(getByTestId('view')).toHaveAccessibilityValue({ text: '33%' });\n */\n toHaveAccessibilityValue(expectedValue: AccessibilityValueMatcher): R;\n\n /**\n * Assert whether a host element has a given accessibile name based on the accessibility label or text content.\n *\n * @see\n * [Jest Matchers docs](https://callstack.github.io/react-native-testing-library/docs/jest-matchers#tohaveaccessiblename)\n *\n * @example\n * <View testID=\"view\" aria-label=\"Hello\" />\n *\n * expect(getByTestId('view')).toHaveAccessibleName('Hello');\n */\n toHaveAccessibleName(expectedName?: TextMatch, options?: TextMatchOptions): R;\n\n /**\n * Assert whether a host `TextInput` element has a given display value based on `value` prop, unmanaged native state, and `defaultValue` prop.\n *\n * @see\n * [Jest Matchers docs](https://callstack.github.io/react-native-testing-library/docs/jest-matchers#tohavedisplayvalue)\n *\n * @example\n * <TextInput testID=\"input\" value=\"Hello\" />\n *\n * expect(getByTestId('input')).toHaveDisplayValue('Hello');\n */\n toHaveDisplayValue(expectedValue: TextMatch, options?: TextMatchOptions): R;\n\n /**\n * Assert whether a host element has a given prop.\n *\n * @see\n * [Jest Matchers docs](https://callstack.github.io/react-native-testing-library/docs/jest-matchers#tohaveprop)\n *\n * @example\n * <Text testID=\"text\" numberOfLines={1]} />\n *\n * expect(getByTestId('text')).toHaveProp('numberOfLines');\n * expect(getByTestId('text')).toHaveProp('numberOfLines', 1);\n */\n toHaveProp(name: string, expectedValue?: unknown): R;\n\n /**\n * Assert whether a host element has a given style.\n *\n * @see\n * [Jest Matchers docs](https://callstack.github.io/react-native-testing-library/docs/jest-matchers#tohavestyle)\n *\n * @example\n * <View testID=\"view\" style={{ width: '100%' }} />\n *\n * expect(getByTestId('view')).toHaveStyle({ width: '100%' });\n * expect(getByTestId('view')).not.toHaveStyle({ width: '50%' });\n */\n toHaveStyle(style: StyleProp<Style>): R;\n\n /**\n * Assert whether a host element has a given text content.\n *\n * @see\n * [Jest Matchers docs](https://callstack.github.io/react-native-testing-library/docs/jest-matchers#tohavetextcontent)\n *\n * @example\n * <View testID=\"view\">\n * <Text>Hello World</Text>\n * </View>\n *\n * expect(getByTestId('view')).toHaveTextContent('Hello World');\n * expect(getByTestId('view')).toHaveTextContent('Hello', { exact: false }});\n * expect(getByTestId('view')).toHaveTextContent(/hello/i);\n * expect(getByTestId('view')).not.toHaveTextContent('Hello');\n */\n toHaveTextContent(expectedText: TextMatch, options?: TextMatchOptions): R;\n}\n\n// Implicit Jest global `expect`.\ndeclare global {\n namespace jest {\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n interface Matchers<R, T = {}> extends JestNativeMatchers<R> {}\n }\n}\n\n// Explicit `@jest/globals` `expect` matchers.\n// @ts-
|
|
1
|
+
{"version":3,"file":"types.js","names":[],"sources":["../../src/matchers/types.ts"],"sourcesContent":["import type { StyleProp } from 'react-native';\nimport type { ReactTestInstance } from 'react-test-renderer';\nimport type { AccessibilityValueMatcher } from '../helpers/matchers/match-accessibility-value';\nimport type { TextMatch, TextMatchOptions } from '../matches';\nimport type { Style } from './to-have-style';\n\nexport interface JestNativeMatchers<R> {\n /**\n * Assert whether a host element is present in the element tree (screen) or not.\n *\n * @see\n * [Jest Matchers docs](https://callstack.github.io/react-native-testing-library/docs/jest-matchers#tobeonthescreen)\n *\n * @example\n * <Text>Hello</Text>\n *\n * expect(getByText('Hello')).toBeOnTheScreen()\n * expect(queryByText('Other')).not.toBeOnTheScreen()\n */\n toBeOnTheScreen(): R;\n\n /**\n * Assert whether a host element is checked based on accessibility props.\n *\n * @see\n * [Jest Matchers docs](https://callstack.github.io/react-native-testing-library/docs/jest-matchers#tobechecked)\n *\n * @see {@link toBePartiallyChecked} for a related matcher.\n *\n * @example\n * <View accessible role=\"checkbox\" aria-checked aria-label=\"Enable\" />\n *\n * expect(getByRole('checkbox', { name: \"Enable\" })).toBeChecked()\n */\n toBeChecked(): R;\n\n /**\n * Assert whether a host element is collapsed based on accessibility props.\n *\n * @see\n * [Jest Matchers docs](https://callstack.github.io/react-native-testing-library/docs/jest-matchers#tobeexpanded)\n *\n * @see {@link toBeExpanded} for an inverse matcher.\n *\n * @example\n * <View testID=\"details\" aria-expanded={false} />\n *\n * expect(getByTestId('details').toBeCollapsed()\n */\n toBeCollapsed(): R;\n\n /**\n * Assert whether a host element is disabled based on accessibility props.\n *\n * This matcher will check ancestor elements for their disabled state as well.\n *\n * @see\n * [Jest Matchers docs](https://callstack.github.io/react-native-testing-library/docs/jest-matchers#tobeenabled)\n *\n * @see {@link toBeEnabled} for an inverse matcher.\n *\n * @example\n * <View role=\"button\" aria-disabled />\n *\n * expect(getByRole('button').toBeDisabled()\n *\n */\n toBeDisabled(): R;\n\n /**\n * Assert whether a host element is busy based on accessibility props.\n *\n * This matcher will check ancestor elements for their disabled state as well.\n *\n * @see\n * [Jest Matchers docs](https://callstack.github.io/react-native-testing-library/docs/jest-matchers#tobebusy)\n *\n * @example\n * <View testID=\"loader\" aria-busy />\n *\n * expect(getByTestId('loader')).toBeBusy()\n */\n toBeBusy(): R;\n\n /**\n * Assert whether a host element has no host children or text content.\n *\n * @see\n * [Jest Matchers docs](https://callstack.github.io/react-native-testing-library/docs/jest-matchers#tobeemptyelement)\n *\n * @example\n * <View testID=\"not-empty\">\n * <View testID=\"empty\" />\n * </View>\n *\n * expect(getByTestId('empty')).toBeEmptyElement()\n * expect(getByTestId('not-mepty')).not.toBeEmptyElement()\n */\n toBeEmptyElement(): R;\n\n /**\n * Assert whether a host element is enabled based on accessibility props.\n *\n * This matcher will check ancestor elements for their disabled state as well.\n *\n * @see\n * [Jest Matchers docs](https://callstack.github.io/react-native-testing-library/docs/jest-matchers#tobeenabled)\n *\n * @see {@link toBeDisabled} for inverse matcher.\n *\n * @example\n * <View role=\"button\" aria-disabled={false} />\n *\n * expect(getByRole('button').toBeEnabled()\n */\n toBeEnabled(): R;\n\n /**\n * Assert whether a host element is expanded based on accessibility props.\n *\n * @see\n * [Jest Matchers docs](https://callstack.github.io/react-native-testing-library/docs/jest-matchers#tobeexpanded)\n *\n * @see {@link toBeCollapsed} for inverse matcher.\n *\n * @example\n * <View testID=\"details\" aria-expanded />\n *\n * expect(getByTestId('details').toBeExpanded()\n */\n toBeExpanded(): R;\n\n /**\n * Assert whether a host element is partially checked based on accessibility props.\n *\n * @see\n * [Jest Matchers docs](https://callstack.github.io/react-native-testing-library/docs/jest-matchers#tobechecked)\n *\n * @see {@link toBeChecked} for related matcher.\n *\n * @example\n * <View accessible role=\"checkbox\" aria-checked=\"mixed\" aria-label=\"Enable\" />\n *\n * expect(getByRole('checkbox', { name: \"Enable\" })).toBePartiallyChecked()\n */\n toBePartiallyChecked(): R;\n\n /**\n * Assert whether a host element is selected based on accessibility props.\n *\n * @see\n * [Jest Matchers docs](https://callstack.github.io/react-native-testing-library/docs/jest-matchers#tobeselected)\n *\n * @example\n * <View testID=\"view\" aria-selected />\n *\n * expect(getByTestId('view')).toBeSelected()\n */\n toBeSelected(): R;\n\n /**\n * Assert whether a host element is visible based on style and accessibility props.\n *\n * This matcher will check ancestor elements for their visibility as well.\n *\n * @see\n * [Jest Matchers docs](https://callstack.github.io/react-native-testing-library/docs/jest-matchers#tobevisible)\n *\n * @example\n * <View testID=\"visible\" />\n * <View testID=\"not-visible\" style={{ display: 'none' }} />\n *\n * expect(getByTestId('visible')).toBeVisible()\n * expect(getByTestId('not-visible')).not.toBeVisible()\n */\n toBeVisible(): R;\n\n /**\n * Assert whether a host element contains another host element.\n *\n * @see\n * [Jest Matchers docs](https://callstack.github.io/react-native-testing-library/docs/jest-matchers#tocontainelement)\n *\n * @example\n * <View testID=\"outer\">\n * <View testID=\"inner\" />\n * </View>\n *\n * expect(getByTestId('outer')).toContainElement(getByTestId('inner'));\n */\n toContainElement(element: ReactTestInstance | null): R;\n\n /**\n * Assert whether a host element has a given accessbility value.\n *\n * @see\n * [Jest Matchers docs](https://callstack.github.io/react-native-testing-library/docs/jest-matchers#tohaveaccessibilityvalue)\n *\n *\n * @example\n * <View testID=\"view\" aria-valuetext=\"33%\" />\n *\n * expect(getByTestId('view')).toHaveAccessibilityValue({ text: '33%' });\n */\n toHaveAccessibilityValue(expectedValue: AccessibilityValueMatcher): R;\n\n /**\n * Assert whether a host element has a given accessibile name based on the accessibility label or text content.\n *\n * @see\n * [Jest Matchers docs](https://callstack.github.io/react-native-testing-library/docs/jest-matchers#tohaveaccessiblename)\n *\n * @example\n * <View testID=\"view\" aria-label=\"Hello\" />\n *\n * expect(getByTestId('view')).toHaveAccessibleName('Hello');\n */\n toHaveAccessibleName(expectedName?: TextMatch, options?: TextMatchOptions): R;\n\n /**\n * Assert whether a host `TextInput` element has a given display value based on `value` prop, unmanaged native state, and `defaultValue` prop.\n *\n * @see\n * [Jest Matchers docs](https://callstack.github.io/react-native-testing-library/docs/jest-matchers#tohavedisplayvalue)\n *\n * @example\n * <TextInput testID=\"input\" value=\"Hello\" />\n *\n * expect(getByTestId('input')).toHaveDisplayValue('Hello');\n */\n toHaveDisplayValue(expectedValue: TextMatch, options?: TextMatchOptions): R;\n\n /**\n * Assert whether a host element has a given prop.\n *\n * @see\n * [Jest Matchers docs](https://callstack.github.io/react-native-testing-library/docs/jest-matchers#tohaveprop)\n *\n * @example\n * <Text testID=\"text\" numberOfLines={1]} />\n *\n * expect(getByTestId('text')).toHaveProp('numberOfLines');\n * expect(getByTestId('text')).toHaveProp('numberOfLines', 1);\n */\n toHaveProp(name: string, expectedValue?: unknown): R;\n\n /**\n * Assert whether a host element has a given style.\n *\n * @see\n * [Jest Matchers docs](https://callstack.github.io/react-native-testing-library/docs/jest-matchers#tohavestyle)\n *\n * @example\n * <View testID=\"view\" style={{ width: '100%' }} />\n *\n * expect(getByTestId('view')).toHaveStyle({ width: '100%' });\n * expect(getByTestId('view')).not.toHaveStyle({ width: '50%' });\n */\n toHaveStyle(style: StyleProp<Style>): R;\n\n /**\n * Assert whether a host element has a given text content.\n *\n * @see\n * [Jest Matchers docs](https://callstack.github.io/react-native-testing-library/docs/jest-matchers#tohavetextcontent)\n *\n * @example\n * <View testID=\"view\">\n * <Text>Hello World</Text>\n * </View>\n *\n * expect(getByTestId('view')).toHaveTextContent('Hello World');\n * expect(getByTestId('view')).toHaveTextContent('Hello', { exact: false }});\n * expect(getByTestId('view')).toHaveTextContent(/hello/i);\n * expect(getByTestId('view')).not.toHaveTextContent('Hello');\n */\n toHaveTextContent(expectedText: TextMatch, options?: TextMatchOptions): R;\n}\n\n// Implicit Jest global `expect`.\ndeclare global {\n // eslint-disable-next-line @typescript-eslint/no-namespace\n namespace jest {\n // eslint-disable-next-line @typescript-eslint/no-empty-object-type, @typescript-eslint/no-unused-vars\n interface Matchers<R, T = {}> extends JestNativeMatchers<R> {}\n }\n}\n\n// Explicit `@jest/globals` `expect` matchers.\n// @ts-expect-error: Invalid module name in augmentation, module '@jest/expect' cannot be found\ndeclare module '@jest/expect' {\n // eslint-disable-next-line @typescript-eslint/no-empty-object-type\n interface Matchers<R extends void | Promise<void>> extends JestNativeMatchers<R> {}\n}\n"],"mappings":"","ignoreList":[]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ReactTestInstance } from 'react-test-renderer';
|
|
1
|
+
import type { ReactTestInstance } from 'react-test-renderer';
|
|
2
2
|
/**
|
|
3
3
|
* Throws HostElementTypeError if passed element is not a host element.
|
|
4
4
|
*
|
|
@@ -7,11 +7,4 @@ import { ReactTestInstance } from 'react-test-renderer';
|
|
|
7
7
|
* @param context Jest matcher context used for formatting error.
|
|
8
8
|
*/
|
|
9
9
|
export declare function checkHostElement(element: ReactTestInstance | null | undefined, matcherFn: jest.CustomMatcher, context: jest.MatcherContext): asserts element is ReactTestInstance;
|
|
10
|
-
/***
|
|
11
|
-
* Format given element as a pretty-printed string.
|
|
12
|
-
*
|
|
13
|
-
* @param element Element to format.
|
|
14
|
-
*/
|
|
15
|
-
export declare function formatElement(element: ReactTestInstance | null): string;
|
|
16
|
-
export declare function formatElementArray(elements: ReactTestInstance[]): string;
|
|
17
10
|
export declare function formatMessage(matcher: string, expectedLabel: string, expectedValue: string | RegExp | null | undefined, receivedLabel: string, receivedValue: string | null | undefined): string;
|
package/build/matchers/utils.js
CHANGED
|
@@ -4,17 +4,11 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.checkHostElement = checkHostElement;
|
|
7
|
-
exports.formatElement = formatElement;
|
|
8
|
-
exports.formatElementArray = formatElementArray;
|
|
9
7
|
exports.formatMessage = formatMessage;
|
|
10
8
|
var _jestMatcherUtils = require("jest-matcher-utils");
|
|
11
|
-
var _prettyFormat = _interopRequireWildcard(require("pretty-format"));
|
|
12
9
|
var _redent = _interopRequireDefault(require("redent"));
|
|
13
10
|
var _componentTree = require("../helpers/component-tree");
|
|
14
|
-
var _formatDefault = require("../helpers/format-default");
|
|
15
11
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
16
|
-
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
17
|
-
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; }
|
|
18
12
|
class HostElementTypeError extends Error {
|
|
19
13
|
constructor(received, matcherFn, context) {
|
|
20
14
|
super();
|
|
@@ -46,41 +40,6 @@ function checkHostElement(element, matcherFn, context) {
|
|
|
46
40
|
throw new HostElementTypeError(element, matcherFn, context);
|
|
47
41
|
}
|
|
48
42
|
}
|
|
49
|
-
|
|
50
|
-
/***
|
|
51
|
-
* Format given element as a pretty-printed string.
|
|
52
|
-
*
|
|
53
|
-
* @param element Element to format.
|
|
54
|
-
*/
|
|
55
|
-
function formatElement(element) {
|
|
56
|
-
if (element == null) {
|
|
57
|
-
return ' null';
|
|
58
|
-
}
|
|
59
|
-
const {
|
|
60
|
-
children,
|
|
61
|
-
...props
|
|
62
|
-
} = element.props;
|
|
63
|
-
const childrenToDisplay = typeof children === 'string' ? [children] : undefined;
|
|
64
|
-
return (0, _redent.default)((0, _prettyFormat.default)({
|
|
65
|
-
// This prop is needed persuade the prettyFormat that the element is
|
|
66
|
-
// a ReactTestRendererJSON instance, so it is formatted as JSX.
|
|
67
|
-
$$typeof: Symbol.for('react.test.json'),
|
|
68
|
-
type: element.type,
|
|
69
|
-
props: (0, _formatDefault.defaultMapProps)(props),
|
|
70
|
-
children: childrenToDisplay
|
|
71
|
-
}, {
|
|
72
|
-
plugins: [_prettyFormat.plugins.ReactTestComponent, _prettyFormat.plugins.ReactElement],
|
|
73
|
-
printFunctionName: false,
|
|
74
|
-
printBasicPrototype: false,
|
|
75
|
-
highlight: true
|
|
76
|
-
}), 2);
|
|
77
|
-
}
|
|
78
|
-
function formatElementArray(elements) {
|
|
79
|
-
if (elements.length === 0) {
|
|
80
|
-
return ' (no elements)';
|
|
81
|
-
}
|
|
82
|
-
return (0, _redent.default)(elements.map(formatElement).join('\n'), 2);
|
|
83
|
-
}
|
|
84
43
|
function formatMessage(matcher, expectedLabel, expectedValue, receivedLabel, receivedValue) {
|
|
85
44
|
return [`${matcher}\n`, `${expectedLabel}:\n${(0, _jestMatcherUtils.EXPECTED_COLOR)((0, _redent.default)(formatValue(expectedValue), 2))}`, `${receivedLabel}:\n${(0, _jestMatcherUtils.RECEIVED_COLOR)((0, _redent.default)(formatValue(receivedValue), 2))}`].join('\n');
|
|
86
45
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","names":["_jestMatcherUtils","require","
|
|
1
|
+
{"version":3,"file":"utils.js","names":["_jestMatcherUtils","require","_redent","_interopRequireDefault","_componentTree","e","__esModule","default","HostElementTypeError","Error","constructor","received","matcherFn","context","captureStackTrace","withType","printWithType","printReceived","message","matcherHint","isNot","name","RECEIVED_COLOR","join","checkHostElement","element","isHostElement","formatMessage","matcher","expectedLabel","expectedValue","receivedLabel","receivedValue","EXPECTED_COLOR","redent","formatValue","value","stringify"],"sources":["../../src/matchers/utils.ts"],"sourcesContent":["import type { ReactTestInstance } from 'react-test-renderer';\nimport {\n EXPECTED_COLOR,\n matcherHint,\n printReceived,\n printWithType,\n RECEIVED_COLOR,\n stringify,\n} from 'jest-matcher-utils';\nimport redent from 'redent';\nimport { isHostElement } from '../helpers/component-tree';\n\nclass HostElementTypeError extends Error {\n constructor(received: unknown, matcherFn: jest.CustomMatcher, context: jest.MatcherContext) {\n super();\n\n /* istanbul ignore next */\n if (Error.captureStackTrace) {\n Error.captureStackTrace(this, matcherFn);\n }\n\n let withType = '';\n try {\n withType = printWithType('Received', received, printReceived);\n /* istanbul ignore next */\n } catch {\n // Deliberately empty.\n }\n\n this.message = [\n matcherHint(`${context.isNot ? '.not' : ''}.${matcherFn.name}`, 'received', ''),\n '',\n `${RECEIVED_COLOR('received')} value must be a host element.`,\n withType,\n ].join('\\n');\n }\n}\n\n/**\n * Throws HostElementTypeError if passed element is not a host element.\n *\n * @param element ReactTestInstance to check.\n * @param matcherFn Matcher function calling the check used for formatting error.\n * @param context Jest matcher context used for formatting error.\n */\nexport function checkHostElement(\n element: ReactTestInstance | null | undefined,\n matcherFn: jest.CustomMatcher,\n context: jest.MatcherContext,\n): asserts element is ReactTestInstance {\n if (!isHostElement(element)) {\n throw new HostElementTypeError(element, matcherFn, context);\n }\n}\n\nexport function formatMessage(\n matcher: string,\n expectedLabel: string,\n expectedValue: string | RegExp | null | undefined,\n receivedLabel: string,\n receivedValue: string | null | undefined,\n) {\n return [\n `${matcher}\\n`,\n `${expectedLabel}:\\n${EXPECTED_COLOR(redent(formatValue(expectedValue), 2))}`,\n `${receivedLabel}:\\n${RECEIVED_COLOR(redent(formatValue(receivedValue), 2))}`,\n ].join('\\n');\n}\n\nfunction formatValue(value: unknown) {\n return typeof value === 'string' ? value : stringify(value);\n}\n"],"mappings":";;;;;;;AACA,IAAAA,iBAAA,GAAAC,OAAA;AAQA,IAAAC,OAAA,GAAAC,sBAAA,CAAAF,OAAA;AACA,IAAAG,cAAA,GAAAH,OAAA;AAA0D,SAAAE,uBAAAE,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAE1D,MAAMG,oBAAoB,SAASC,KAAK,CAAC;EACvCC,WAAWA,CAACC,QAAiB,EAAEC,SAA6B,EAAEC,OAA4B,EAAE;IAC1F,KAAK,CAAC,CAAC;;IAEP;IACA,IAAIJ,KAAK,CAACK,iBAAiB,EAAE;MAC3BL,KAAK,CAACK,iBAAiB,CAAC,IAAI,EAAEF,SAAS,CAAC;IAC1C;IAEA,IAAIG,QAAQ,GAAG,EAAE;IACjB,IAAI;MACFA,QAAQ,GAAG,IAAAC,+BAAa,EAAC,UAAU,EAAEL,QAAQ,EAAEM,+BAAa,CAAC;MAC7D;IACF,CAAC,CAAC,MAAM;MACN;IAAA;IAGF,IAAI,CAACC,OAAO,GAAG,CACb,IAAAC,6BAAW,EAAC,GAAGN,OAAO,CAACO,KAAK,GAAG,MAAM,GAAG,EAAE,IAAIR,SAAS,CAACS,IAAI,EAAE,EAAE,UAAU,EAAE,EAAE,CAAC,EAC/E,EAAE,EACF,GAAG,IAAAC,gCAAc,EAAC,UAAU,CAAC,gCAAgC,EAC7DP,QAAQ,CACT,CAACQ,IAAI,CAAC,IAAI,CAAC;EACd;AACF;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASC,gBAAgBA,CAC9BC,OAA6C,EAC7Cb,SAA6B,EAC7BC,OAA4B,EACU;EACtC,IAAI,CAAC,IAAAa,4BAAa,EAACD,OAAO,CAAC,EAAE;IAC3B,MAAM,IAAIjB,oBAAoB,CAACiB,OAAO,EAAEb,SAAS,EAAEC,OAAO,CAAC;EAC7D;AACF;AAEO,SAASc,aAAaA,CAC3BC,OAAe,EACfC,aAAqB,EACrBC,aAAiD,EACjDC,aAAqB,EACrBC,aAAwC,EACxC;EACA,OAAO,CACL,GAAGJ,OAAO,IAAI,EACd,GAAGC,aAAa,MAAM,IAAAI,gCAAc,EAAC,IAAAC,eAAM,EAACC,WAAW,CAACL,aAAa,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,EAC7E,GAAGC,aAAa,MAAM,IAAAT,gCAAc,EAAC,IAAAY,eAAM,EAACC,WAAW,CAACH,aAAa,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAC9E,CAACT,IAAI,CAAC,IAAI,CAAC;AACd;AAEA,SAASY,WAAWA,CAACC,KAAc,EAAE;EACnC,OAAO,OAAOA,KAAK,KAAK,QAAQ,GAAGA,KAAK,GAAG,IAAAC,2BAAS,EAACD,KAAK,CAAC;AAC7D","ignoreList":[]}
|
package/build/native-state.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { ReactTestInstance } from 'react-test-renderer';
|
|
2
|
-
import { Point } from './types';
|
|
1
|
+
import type { ReactTestInstance } from 'react-test-renderer';
|
|
2
|
+
import type { Point } from './types';
|
|
3
3
|
/**
|
|
4
4
|
* Simulated native state for unmanaged controls.
|
|
5
5
|
*
|
|
@@ -9,4 +9,4 @@ export type NativeState = {
|
|
|
9
9
|
valueForElement: WeakMap<ReactTestInstance, string>;
|
|
10
10
|
contentOffsetForElement: WeakMap<ReactTestInstance, Point>;
|
|
11
11
|
};
|
|
12
|
-
export declare
|
|
12
|
+
export declare const nativeState: NativeState;
|
package/build/native-state.js
CHANGED
|
@@ -10,7 +10,7 @@ exports.nativeState = void 0;
|
|
|
10
10
|
* Values from `value` props (managed controls) should take precedence over these values.
|
|
11
11
|
*/
|
|
12
12
|
|
|
13
|
-
|
|
13
|
+
const nativeState = exports.nativeState = {
|
|
14
14
|
valueForElement: new WeakMap(),
|
|
15
15
|
contentOffsetForElement: new WeakMap()
|
|
16
16
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"native-state.js","names":["nativeState","exports","valueForElement","WeakMap","contentOffsetForElement"],"sources":["../src/native-state.ts"],"sourcesContent":["import { ReactTestInstance } from 'react-test-renderer';\nimport { Point } from './types';\n\n/**\n * Simulated native state for unmanaged controls.\n *\n * Values from `value` props (managed controls) should take precedence over these values.\n */\nexport type NativeState = {\n valueForElement: WeakMap<ReactTestInstance, string>;\n contentOffsetForElement: WeakMap<ReactTestInstance, Point>;\n};\n\nexport
|
|
1
|
+
{"version":3,"file":"native-state.js","names":["nativeState","exports","valueForElement","WeakMap","contentOffsetForElement"],"sources":["../src/native-state.ts"],"sourcesContent":["import type { ReactTestInstance } from 'react-test-renderer';\nimport type { Point } from './types';\n\n/**\n * Simulated native state for unmanaged controls.\n *\n * Values from `value` props (managed controls) should take precedence over these values.\n */\nexport type NativeState = {\n valueForElement: WeakMap<ReactTestInstance, string>;\n contentOffsetForElement: WeakMap<ReactTestInstance, Point>;\n};\n\nexport const nativeState: NativeState = {\n valueForElement: new WeakMap(),\n contentOffsetForElement: new WeakMap(),\n};\n"],"mappings":";;;;;;AAGA;AACA;AACA;AACA;AACA;;AAMO,MAAMA,WAAwB,GAAAC,OAAA,CAAAD,WAAA,GAAG;EACtCE,eAAe,EAAE,IAAIC,OAAO,CAAC,CAAC;EAC9BC,uBAAuB,EAAE,IAAID,OAAO,CAAC;AACvC,CAAC","ignoreList":[]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { ReactTestInstance } from 'react-test-renderer';
|
|
2
|
-
import { TextMatch, TextMatchOptions } from '../matches';
|
|
2
|
+
import type { TextMatch, TextMatchOptions } from '../matches';
|
|
3
3
|
import type { FindAllByQuery, FindByQuery, GetAllByQuery, GetByQuery, QueryAllByQuery, QueryByQuery } from './make-queries';
|
|
4
4
|
import type { CommonQueryOptions } from './options';
|
|
5
5
|
type ByDisplayValueOptions = CommonQueryOptions & TextMatchOptions;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"display-value.js","names":["_findAll","require","_hostComponentNames","_textInput","_matches","_makeQueries","matchDisplayValue","node","expectedValue","options","exact","normalizer","nodeValue","getTextInputValue","matches","queryAllByDisplayValue","instance","queryAllByDisplayValueFn","displayValue","queryOptions","findAll","isHostTextInput","getMultipleError","String","getMissingError","getBy","getAllBy","queryBy","queryAllBy","findBy","findAllBy","makeQueries","bindByDisplayValueQueries","getByDisplayValue","getAllByDisplayValue","queryByDisplayValue","findByDisplayValue","findAllByDisplayValue","exports"],"sources":["../../src/queries/display-value.ts"],"sourcesContent":["import type { ReactTestInstance } from 'react-test-renderer';\nimport { findAll } from '../helpers/find-all';\nimport { isHostTextInput } from '../helpers/host-component-names';\nimport { getTextInputValue } from '../helpers/text-input';\nimport {
|
|
1
|
+
{"version":3,"file":"display-value.js","names":["_findAll","require","_hostComponentNames","_textInput","_matches","_makeQueries","matchDisplayValue","node","expectedValue","options","exact","normalizer","nodeValue","getTextInputValue","matches","queryAllByDisplayValue","instance","queryAllByDisplayValueFn","displayValue","queryOptions","findAll","isHostTextInput","getMultipleError","String","getMissingError","getBy","getAllBy","queryBy","queryAllBy","findBy","findAllBy","makeQueries","bindByDisplayValueQueries","getByDisplayValue","getAllByDisplayValue","queryByDisplayValue","findByDisplayValue","findAllByDisplayValue","exports"],"sources":["../../src/queries/display-value.ts"],"sourcesContent":["import type { ReactTestInstance } from 'react-test-renderer';\nimport { findAll } from '../helpers/find-all';\nimport { isHostTextInput } from '../helpers/host-component-names';\nimport { getTextInputValue } from '../helpers/text-input';\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 ByDisplayValueOptions = CommonQueryOptions & TextMatchOptions;\n\nconst matchDisplayValue = (\n node: ReactTestInstance,\n expectedValue: TextMatch,\n options: TextMatchOptions = {},\n) => {\n const { exact, normalizer } = options;\n const nodeValue = getTextInputValue(node);\n return matches(expectedValue, nodeValue, normalizer, exact);\n};\n\nconst queryAllByDisplayValue = (\n instance: ReactTestInstance,\n): QueryAllByQuery<TextMatch, ByDisplayValueOptions> =>\n function queryAllByDisplayValueFn(displayValue, queryOptions) {\n return findAll(\n instance,\n (node) => isHostTextInput(node) && matchDisplayValue(node, displayValue, queryOptions),\n queryOptions,\n );\n };\n\nconst getMultipleError = (displayValue: TextMatch) =>\n `Found multiple elements with display value: ${String(displayValue)} `;\nconst getMissingError = (displayValue: TextMatch) =>\n `Unable to find an element with displayValue: ${String(displayValue)}`;\n\nconst { getBy, getAllBy, queryBy, queryAllBy, findBy, findAllBy } = makeQueries(\n queryAllByDisplayValue,\n getMissingError,\n getMultipleError,\n);\n\nexport type ByDisplayValueQueries = {\n getByDisplayValue: GetByQuery<TextMatch, ByDisplayValueOptions>;\n getAllByDisplayValue: GetAllByQuery<TextMatch, ByDisplayValueOptions>;\n queryByDisplayValue: QueryByQuery<TextMatch, ByDisplayValueOptions>;\n queryAllByDisplayValue: QueryAllByQuery<TextMatch, ByDisplayValueOptions>;\n findByDisplayValue: FindByQuery<TextMatch, ByDisplayValueOptions>;\n findAllByDisplayValue: FindAllByQuery<TextMatch, ByDisplayValueOptions>;\n};\n\nexport const bindByDisplayValueQueries = (instance: ReactTestInstance): ByDisplayValueQueries => ({\n getByDisplayValue: getBy(instance),\n getAllByDisplayValue: getAllBy(instance),\n queryByDisplayValue: queryBy(instance),\n queryAllByDisplayValue: queryAllBy(instance),\n findByDisplayValue: findBy(instance),\n findAllByDisplayValue: findAllBy(instance),\n});\n"],"mappings":";;;;;;AACA,IAAAA,QAAA,GAAAC,OAAA;AACA,IAAAC,mBAAA,GAAAD,OAAA;AACA,IAAAE,UAAA,GAAAF,OAAA;AAEA,IAAAG,QAAA,GAAAH,OAAA;AASA,IAAAI,YAAA,GAAAJ,OAAA;AAKA,MAAMK,iBAAiB,GAAGA,CACxBC,IAAuB,EACvBC,aAAwB,EACxBC,OAAyB,GAAG,CAAC,CAAC,KAC3B;EACH,MAAM;IAAEC,KAAK;IAAEC;EAAW,CAAC,GAAGF,OAAO;EACrC,MAAMG,SAAS,GAAG,IAAAC,4BAAiB,EAACN,IAAI,CAAC;EACzC,OAAO,IAAAO,gBAAO,EAACN,aAAa,EAAEI,SAAS,EAAED,UAAU,EAAED,KAAK,CAAC;AAC7D,CAAC;AAED,MAAMK,sBAAsB,GAC1BC,QAA2B,IAE3B,SAASC,wBAAwBA,CAACC,YAAY,EAAEC,YAAY,EAAE;EAC5D,OAAO,IAAAC,gBAAO,EACZJ,QAAQ,EACPT,IAAI,IAAK,IAAAc,mCAAe,EAACd,IAAI,CAAC,IAAID,iBAAiB,CAACC,IAAI,EAAEW,YAAY,EAAEC,YAAY,CAAC,EACtFA,YACF,CAAC;AACH,CAAC;AAEH,MAAMG,gBAAgB,GAAIJ,YAAuB,IAC/C,+CAA+CK,MAAM,CAACL,YAAY,CAAC,GAAG;AACxE,MAAMM,eAAe,GAAIN,YAAuB,IAC9C,gDAAgDK,MAAM,CAACL,YAAY,CAAC,EAAE;AAExE,MAAM;EAAEO,KAAK;EAAEC,QAAQ;EAAEC,OAAO;EAAEC,UAAU;EAAEC,MAAM;EAAEC;AAAU,CAAC,GAAG,IAAAC,wBAAW,EAC7EhB,sBAAsB,EACtBS,eAAe,EACfF,gBACF,CAAC;AAWM,MAAMU,yBAAyB,GAAIhB,QAA2B,KAA6B;EAChGiB,iBAAiB,EAAER,KAAK,CAACT,QAAQ,CAAC;EAClCkB,oBAAoB,EAAER,QAAQ,CAACV,QAAQ,CAAC;EACxCmB,mBAAmB,EAAER,OAAO,CAACX,QAAQ,CAAC;EACtCD,sBAAsB,EAAEa,UAAU,CAACZ,QAAQ,CAAC;EAC5CoB,kBAAkB,EAAEP,MAAM,CAACb,QAAQ,CAAC;EACpCqB,qBAAqB,EAAEP,SAAS,CAACd,QAAQ;AAC3C,CAAC,CAAC;AAACsB,OAAA,CAAAN,yBAAA,GAAAA,yBAAA","ignoreList":[]}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { ReactTestInstance } from 'react-test-renderer';
|
|
2
|
-
import { TextMatch, TextMatchOptions } from '../matches';
|
|
2
|
+
import type { TextMatch, TextMatchOptions } from '../matches';
|
|
3
3
|
import type { FindAllByQuery, FindByQuery, GetAllByQuery, GetByQuery, QueryAllByQuery, QueryByQuery } from './make-queries';
|
|
4
|
-
import { CommonQueryOptions } from './options';
|
|
4
|
+
import type { CommonQueryOptions } from './options';
|
|
5
5
|
type ByHintTextOptions = CommonQueryOptions & TextMatchOptions;
|
|
6
6
|
export type ByHintTextQueries = {
|
|
7
7
|
getByHintText: GetByQuery<TextMatch, ByHintTextOptions>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hint-text.js","names":["_findAll","require","_matches","_makeQueries","getNodeByHintText","node","text","options","exact","normalizer","matches","props","accessibilityHint","queryAllByHintText","instance","queryAllByA11yHintFn","hint","queryOptions","findAll","getMultipleError","String","getMissingError","getBy","getAllBy","queryBy","queryAllBy","findBy","findAllBy","makeQueries","bindByHintTextQueries","getByHintText","getAllByHintText","queryByHintText","findByHintText","findAllByHintText","getByA11yHint","getAllByA11yHint","queryByA11yHint","queryAllByA11yHint","findByA11yHint","findAllByA11yHint","getByAccessibilityHint","getAllByAccessibilityHint","queryByAccessibilityHint","queryAllByAccessibilityHint","findByAccessibilityHint","findAllByAccessibilityHint","exports"],"sources":["../../src/queries/hint-text.ts"],"sourcesContent":["import type { ReactTestInstance } from 'react-test-renderer';\nimport { findAll } from '../helpers/find-all';\nimport {
|
|
1
|
+
{"version":3,"file":"hint-text.js","names":["_findAll","require","_matches","_makeQueries","getNodeByHintText","node","text","options","exact","normalizer","matches","props","accessibilityHint","queryAllByHintText","instance","queryAllByA11yHintFn","hint","queryOptions","findAll","getMultipleError","String","getMissingError","getBy","getAllBy","queryBy","queryAllBy","findBy","findAllBy","makeQueries","bindByHintTextQueries","getByHintText","getAllByHintText","queryByHintText","findByHintText","findAllByHintText","getByA11yHint","getAllByA11yHint","queryByA11yHint","queryAllByA11yHint","findByA11yHint","findAllByA11yHint","getByAccessibilityHint","getAllByAccessibilityHint","queryByAccessibilityHint","queryAllByAccessibilityHint","findByAccessibilityHint","findAllByAccessibilityHint","exports"],"sources":["../../src/queries/hint-text.ts"],"sourcesContent":["import type { ReactTestInstance } from 'react-test-renderer';\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 ByHintTextOptions = CommonQueryOptions & TextMatchOptions;\n\nconst getNodeByHintText = (\n node: ReactTestInstance,\n text: TextMatch,\n options: TextMatchOptions = {},\n) => {\n const { exact, normalizer } = options;\n return matches(text, node.props.accessibilityHint, normalizer, exact);\n};\n\nconst queryAllByHintText = (\n instance: ReactTestInstance,\n): QueryAllByQuery<TextMatch, ByHintTextOptions> =>\n function queryAllByA11yHintFn(hint, queryOptions) {\n return findAll(instance, (node) => getNodeByHintText(node, hint, queryOptions), queryOptions);\n };\n\nconst getMultipleError = (hint: TextMatch) =>\n `Found multiple elements with accessibility hint: ${String(hint)} `;\nconst getMissingError = (hint: TextMatch) =>\n `Unable to find an element with accessibility hint: ${String(hint)}`;\n\nconst { getBy, getAllBy, queryBy, queryAllBy, findBy, findAllBy } = makeQueries(\n queryAllByHintText,\n getMissingError,\n getMultipleError,\n);\n\nexport type ByHintTextQueries = {\n getByHintText: GetByQuery<TextMatch, ByHintTextOptions>;\n getAllByHintText: GetAllByQuery<TextMatch, ByHintTextOptions>;\n queryByHintText: QueryByQuery<TextMatch, ByHintTextOptions>;\n queryAllByHintText: QueryAllByQuery<TextMatch, ByHintTextOptions>;\n findByHintText: FindByQuery<TextMatch, ByHintTextOptions>;\n findAllByHintText: FindAllByQuery<TextMatch, ByHintTextOptions>;\n\n // a11yHint aliases\n getByA11yHint: GetByQuery<TextMatch, ByHintTextOptions>;\n getAllByA11yHint: GetAllByQuery<TextMatch, ByHintTextOptions>;\n queryByA11yHint: QueryByQuery<TextMatch, ByHintTextOptions>;\n queryAllByA11yHint: QueryAllByQuery<TextMatch, ByHintTextOptions>;\n findByA11yHint: FindByQuery<TextMatch, ByHintTextOptions>;\n findAllByA11yHint: FindAllByQuery<TextMatch, ByHintTextOptions>;\n\n // accessibilityHint aliases\n getByAccessibilityHint: GetByQuery<TextMatch, ByHintTextOptions>;\n getAllByAccessibilityHint: GetAllByQuery<TextMatch, ByHintTextOptions>;\n queryByAccessibilityHint: QueryByQuery<TextMatch, ByHintTextOptions>;\n queryAllByAccessibilityHint: QueryAllByQuery<TextMatch, ByHintTextOptions>;\n findByAccessibilityHint: FindByQuery<TextMatch, ByHintTextOptions>;\n findAllByAccessibilityHint: FindAllByQuery<TextMatch, ByHintTextOptions>;\n};\n\nexport const bindByHintTextQueries = (instance: ReactTestInstance): ByHintTextQueries => {\n const getByHintText = getBy(instance);\n const getAllByHintText = getAllBy(instance);\n const queryByHintText = queryBy(instance);\n const queryAllByHintText = queryAllBy(instance);\n const findByHintText = findBy(instance);\n const findAllByHintText = findAllBy(instance);\n\n return {\n getByHintText,\n getAllByHintText,\n queryByHintText,\n queryAllByHintText,\n findByHintText,\n findAllByHintText,\n\n // a11yHint aliases\n getByA11yHint: getByHintText,\n getAllByA11yHint: getAllByHintText,\n queryByA11yHint: queryByHintText,\n queryAllByA11yHint: queryAllByHintText,\n findByA11yHint: findByHintText,\n findAllByA11yHint: findAllByHintText,\n\n // accessibilityHint aliases\n getByAccessibilityHint: getByHintText,\n getAllByAccessibilityHint: getAllByHintText,\n queryByAccessibilityHint: queryByHintText,\n queryAllByAccessibilityHint: queryAllByHintText,\n findByAccessibilityHint: findByHintText,\n findAllByAccessibilityHint: findAllByHintText,\n };\n};\n"],"mappings":";;;;;;AACA,IAAAA,QAAA,GAAAC,OAAA;AAEA,IAAAC,QAAA,GAAAD,OAAA;AASA,IAAAE,YAAA,GAAAF,OAAA;AAKA,MAAMG,iBAAiB,GAAGA,CACxBC,IAAuB,EACvBC,IAAe,EACfC,OAAyB,GAAG,CAAC,CAAC,KAC3B;EACH,MAAM;IAAEC,KAAK;IAAEC;EAAW,CAAC,GAAGF,OAAO;EACrC,OAAO,IAAAG,gBAAO,EAACJ,IAAI,EAAED,IAAI,CAACM,KAAK,CAACC,iBAAiB,EAAEH,UAAU,EAAED,KAAK,CAAC;AACvE,CAAC;AAED,MAAMK,kBAAkB,GACtBC,QAA2B,IAE3B,SAASC,oBAAoBA,CAACC,IAAI,EAAEC,YAAY,EAAE;EAChD,OAAO,IAAAC,gBAAO,EAACJ,QAAQ,EAAGT,IAAI,IAAKD,iBAAiB,CAACC,IAAI,EAAEW,IAAI,EAAEC,YAAY,CAAC,EAAEA,YAAY,CAAC;AAC/F,CAAC;AAEH,MAAME,gBAAgB,GAAIH,IAAe,IACvC,oDAAoDI,MAAM,CAACJ,IAAI,CAAC,GAAG;AACrE,MAAMK,eAAe,GAAIL,IAAe,IACtC,sD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matches';
|
|
2
|
+
import type { TextMatch, TextMatchOptions } from '../matches';
|
|
3
3
|
import type { FindAllByQuery, FindByQuery, GetAllByQuery, GetByQuery, QueryAllByQuery, QueryByQuery } from './make-queries';
|
|
4
|
-
import { CommonQueryOptions } from './options';
|
|
4
|
+
import type { CommonQueryOptions } from './options';
|
|
5
5
|
type ByLabelTextOptions = CommonQueryOptions & TextMatchOptions;
|
|
6
6
|
export type ByLabelTextQueries = {
|
|
7
7
|
getByLabelText: GetByQuery<TextMatch, ByLabelTextOptions>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"label-text.js","names":["_findAll","require","_matchLabelText","_makeQueries","queryAllByLabelText","instance","text","queryOptions","findAll","node","matchAccessibilityLabel","getMultipleError","labelText","String","getMissingError","getBy","getAllBy","queryBy","queryAllBy","findBy","findAllBy","makeQueries","bindByLabelTextQueries","getByLabelText","getAllByLabelText","queryByLabelText","findByLabelText","findAllByLabelText","exports"],"sources":["../../src/queries/label-text.ts"],"sourcesContent":["import type { ReactTestInstance } from 'react-test-renderer';\nimport { findAll } from '../helpers/find-all';\nimport {
|
|
1
|
+
{"version":3,"file":"label-text.js","names":["_findAll","require","_matchLabelText","_makeQueries","queryAllByLabelText","instance","text","queryOptions","findAll","node","matchAccessibilityLabel","getMultipleError","labelText","String","getMissingError","getBy","getAllBy","queryBy","queryAllBy","findBy","findAllBy","makeQueries","bindByLabelTextQueries","getByLabelText","getAllByLabelText","queryByLabelText","findByLabelText","findAllByLabelText","exports"],"sources":["../../src/queries/label-text.ts"],"sourcesContent":["import type { ReactTestInstance } from 'react-test-renderer';\nimport { findAll } from '../helpers/find-all';\nimport { matchAccessibilityLabel } from '../helpers/matchers/match-label-text';\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 ByLabelTextOptions = CommonQueryOptions & TextMatchOptions;\n\nfunction queryAllByLabelText(instance: ReactTestInstance) {\n return (text: TextMatch, queryOptions?: ByLabelTextOptions) => {\n return findAll(\n instance,\n (node) => matchAccessibilityLabel(node, text, queryOptions),\n queryOptions,\n );\n };\n}\n\nconst getMultipleError = (labelText: TextMatch) =>\n `Found multiple elements with accessibility label: ${String(labelText)} `;\nconst getMissingError = (labelText: TextMatch) =>\n `Unable to find an element with accessibility label: ${String(labelText)}`;\n\nconst { getBy, getAllBy, queryBy, queryAllBy, findBy, findAllBy } = makeQueries(\n queryAllByLabelText,\n getMissingError,\n getMultipleError,\n);\n\nexport type ByLabelTextQueries = {\n getByLabelText: GetByQuery<TextMatch, ByLabelTextOptions>;\n getAllByLabelText: GetAllByQuery<TextMatch, ByLabelTextOptions>;\n queryByLabelText: QueryByQuery<TextMatch, ByLabelTextOptions>;\n queryAllByLabelText: QueryAllByQuery<TextMatch, ByLabelTextOptions>;\n findByLabelText: FindByQuery<TextMatch, ByLabelTextOptions>;\n findAllByLabelText: FindAllByQuery<TextMatch, ByLabelTextOptions>;\n};\n\nexport const bindByLabelTextQueries = (instance: ReactTestInstance): ByLabelTextQueries => ({\n getByLabelText: getBy(instance),\n getAllByLabelText: getAllBy(instance),\n queryByLabelText: queryBy(instance),\n queryAllByLabelText: queryAllBy(instance),\n findByLabelText: findBy(instance),\n findAllByLabelText: findAllBy(instance),\n});\n"],"mappings":";;;;;;AACA,IAAAA,QAAA,GAAAC,OAAA;AACA,IAAAC,eAAA,GAAAD,OAAA;AAUA,IAAAE,YAAA,GAAAF,OAAA;AAKA,SAASG,mBAAmBA,CAACC,QAA2B,EAAE;EACxD,OAAO,CAACC,IAAe,EAAEC,YAAiC,KAAK;IAC7D,OAAO,IAAAC,gBAAO,EACZH,QAAQ,EACPI,IAAI,IAAK,IAAAC,uCAAuB,EAACD,IAAI,EAAEH,IAAI,EAAEC,YAAY,CAAC,EAC3DA,YACF,CAAC;EACH,CAAC;AACH;AAEA,MAAMI,gBAAgB,GAAIC,SAAoB,IAC5C,qDAAqDC,MAAM,CAACD,SAAS,CAAC,GAAG;AAC3E,MAAME,eAAe,GAAIF,SAAoB,IAC3C,uDAAuDC,MAAM,CAACD,SAAS,CAAC,EAAE;AAE5E,MAAM;EAAEG,KAAK;EAAEC,QAAQ;EAAEC,OAAO;EAAEC,UAAU;EAAEC,MAAM;EAAEC;AAAU,CAAC,GAAG,IAAAC,wBAAW,EAC7EjB,mBAAmB,EACnBU,eAAe,EACfH,gBACF,CAAC;AAWM,MAAMW,sBAAsB,GAAIjB,QAA2B,KAA0B;EAC1FkB,cAAc,EAAER,KAAK,CAACV,QAAQ,CAAC;EAC/BmB,iBAAiB,EAAER,QAAQ,CAACX,QAAQ,CAAC;EACrCoB,gBAAgB,EAAER,OAAO,CAACZ,QAAQ,CAAC;EACnCD,mBAAmB,EAAEc,UAAU,CAACb,QAAQ,CAAC;EACzCqB,eAAe,EAAEP,MAAM,CAACd,QAAQ,CAAC;EACjCsB,kBAAkB,EAAEP,SAAS,CAACf,QAAQ;AACxC,CAAC,CAAC;AAACuB,OAAA,CAAAN,sBAAA,GAAAA,sBAAA","ignoreList":[]}
|
|
@@ -5,10 +5,10 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.makeQueries = makeQueries;
|
|
7
7
|
var _errors = require("../helpers/errors");
|
|
8
|
-
var
|
|
9
|
-
var
|
|
8
|
+
var _formatElement = require("../helpers/format-element");
|
|
9
|
+
var _logger = require("../helpers/logger");
|
|
10
10
|
var _screen = require("../screen");
|
|
11
|
-
var
|
|
11
|
+
var _waitFor = _interopRequireDefault(require("../wait-for"));
|
|
12
12
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
13
13
|
const deprecatedKeys = ['timeout', 'interval', 'stackTraceError'];
|
|
14
14
|
|
|
@@ -26,8 +26,7 @@ function extractDeprecatedWaitForOptions(options) {
|
|
|
26
26
|
deprecatedKeys.forEach(key => {
|
|
27
27
|
const option = options[key];
|
|
28
28
|
if (option) {
|
|
29
|
-
|
|
30
|
-
console.warn(`Use of option "${key}" in a findBy* query options (2nd parameter) is deprecated. Please pass this option in the waitForOptions (3rd parameter).
|
|
29
|
+
_logger.logger.warn(`Use of option "${key}" in a findBy* query options (2nd parameter) is deprecated. Please pass this option in the waitForOptions (3rd parameter).
|
|
31
30
|
Example:
|
|
32
31
|
|
|
33
32
|
findByText(text, {}, { ${key}: ${option.toString()} })`);
|
|
@@ -46,9 +45,7 @@ function formatErrorMessage(message, printElementTree) {
|
|
|
46
45
|
if (!json) {
|
|
47
46
|
return message;
|
|
48
47
|
}
|
|
49
|
-
return `${message}\n\n${(0,
|
|
50
|
-
mapProps: _formatDefault.defaultMapProps
|
|
51
|
-
})}`;
|
|
48
|
+
return `${message}\n\n${(0, _formatElement.formatJson)(json)}`;
|
|
52
49
|
}
|
|
53
50
|
function appendElementTreeToError(error) {
|
|
54
51
|
const oldMessage = error.message;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"make-queries.js","names":["_errors","require","_waitFor","_interopRequireDefault","_format","_screen","_formatDefault","e","__esModule","default","deprecatedKeys","extractDeprecatedWaitForOptions","options","undefined","waitForOptions","timeout","interval","stackTraceError","forEach","key","option","console","warn","toString","formatErrorMessage","message","printElementTree","screen","isDetached","json","toJSON","format","mapProps","defaultMapProps","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 { ReactTestInstance } from 'react-test-renderer';\nimport { ErrorWithStack } from '../helpers/errors';\nimport waitFor from '../wait-for';\nimport type { WaitForOptions } from '../wait-for';\nimport format from '../helpers/format';\nimport { screen } from '../screen';\nimport { defaultMapProps } from '../helpers/format-default';\n\nexport type GetByQuery<Predicate, Options = void> = (\n predicate: Predicate,\n options?: Options,\n) => ReactTestInstance;\n\nexport type GetAllByQuery<Predicate, Options = void> = (\n predicate: Predicate,\n options?: Options,\n) => ReactTestInstance[];\n\nexport type QueryByQuery<Predicate, Options = void> = (\n predicate: Predicate,\n options?: Options,\n) => ReactTestInstance | null;\n\nexport type QueryAllByQuery<Predicate, Options = void> = (\n predicate: Predicate,\n options?: Options,\n) => ReactTestInstance[];\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<ReactTestInstance>;\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<ReactTestInstance[]>;\n\ntype UnboundQuery<Query> = (instance: ReactTestInstance) => 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 // eslint-disable-next-line no-console\n console.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${format(json, {\n mapProps: defaultMapProps,\n })}`;\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: ReactTestInstance, { 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: ReactTestInstance, { 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: ReactTestInstance, { 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: ReactTestInstance) {\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: ReactTestInstance) {\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: query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AC,EACtB;MACA,MAAMG,eAAe,GAAG,IAAIiC,sBAAc,CAAC,mBAAmB,EAAEM,SAAS,CAAC;MAC1E,MAAMG,wBAAwB,GAAGhD,+BAA+B,CAAC8C,YAAY,CAAC;MAE9E,OAAO,IAAAG,gBAAO,EACZ,MAAMjB,aAAa,CAACC,QAAQ,EAAE;QAAElB,gBAAgB,EAAE;MAAM,CAAC,CAAC,CAACoB,SAAS,EAAEW,YAAY,CAAC,EACnF;QACE,GAAGE,wBAAwB;QAC3B,GAAG7C,cAAc;QACjBG,eAAe;QACfyC;MACF,CACF,CAAC;IACH,CAAC;EACH;EAEA,SAASG,WAAWA,CAACjB,QAA2B,EAAE;IAChD,OAAO,SAASkB,MAAMA,CACpBhB,SAAoB,EACpBW,YAAuC,EACvC;MACEC,SAAS,GAAIvB,KAAK,IAAKD,wBAAwB,CAACC,KAAK,CAAC;MACtD,GAAGrB;IACW,CAAC,GAAG,CAAC,CAAC,EACtB;MACA,MAAMG,eAAe,GAAG,IAAIiC,sBAAc,CAAC,mBAAmB,EAAEY,MAAM,CAAC;MACvE,MAAMH,wBAAwB,GAAGhD,+BAA+B,CAAC8C,YAAY,CAAC;MAE9E,OAAO,IAAAG,gBAAO,EACZ,MAAMP,UAAU,CAACT,QAAQ,EAAE;QAAElB,gBAAgB,EAAE;MAAM,CAAC,CAAC,CAACoB,SAAS,EAAEW,YAAY,CAAC,EAChF;QACE,GAAGE,wBAAwB;QAC3B,GAAG7C,cAAc;QACjBG,eAAe;QACfyC;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","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 { ReactTestInstance } from 'react-test-renderer';\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) => ReactTestInstance;\n\nexport type GetAllByQuery<Predicate, Options = void> = (\n predicate: Predicate,\n options?: Options,\n) => ReactTestInstance[];\n\nexport type QueryByQuery<Predicate, Options = void> = (\n predicate: Predicate,\n options?: Options,\n) => ReactTestInstance | null;\n\nexport type QueryAllByQuery<Predicate, Options = void> = (\n predicate: Predicate,\n options?: Options,\n) => ReactTestInstance[];\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<ReactTestInstance>;\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<ReactTestInstance[]>;\n\ntype UnboundQuery<Query> = (instance: ReactTestInstance) => 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: ReactTestInstance, { 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: ReactTestInstance, { 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: ReactTestInstance, { 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: ReactTestInstance) {\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: ReactTestInstance) {\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":";;;;;;AACA,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,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,G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B,EAAE;MAAM,CAAC,CAAC,CAACkB,SAAS,EAAEW,YAAY,CAAC,EAChF;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":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"options.js","names":[],"sources":["../../src/queries/options.ts"],"sourcesContent":["import { NormalizerFn } from '../matches';\n\nexport type CommonQueryOptions = {\n /** Should query include elements hidden from accessibility. */\n includeHiddenElements?: boolean;\n\n /** RTL-compatibile alias to `includeHiddenElements`. */\n hidden?: boolean;\n};\n\nexport type TextMatchOptions = {\n exact?: boolean;\n normalizer?: NormalizerFn;\n};\n"],"mappings":"","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"options.js","names":[],"sources":["../../src/queries/options.ts"],"sourcesContent":["import type { NormalizerFn } from '../matches';\n\nexport type CommonQueryOptions = {\n /** Should query include elements hidden from accessibility. */\n includeHiddenElements?: boolean;\n\n /** RTL-compatibile alias to `includeHiddenElements`. */\n hidden?: boolean;\n};\n\nexport type TextMatchOptions = {\n exact?: boolean;\n normalizer?: NormalizerFn;\n};\n"],"mappings":"","ignoreList":[]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { ReactTestInstance } from 'react-test-renderer';
|
|
2
|
-
import { TextMatch, TextMatchOptions } from '../matches';
|
|
2
|
+
import type { TextMatch, TextMatchOptions } from '../matches';
|
|
3
3
|
import type { FindAllByQuery, FindByQuery, GetAllByQuery, GetByQuery, QueryAllByQuery, QueryByQuery } from './make-queries';
|
|
4
4
|
import type { CommonQueryOptions } from './options';
|
|
5
5
|
type ByPlaceholderTextOptions = CommonQueryOptions & TextMatchOptions;
|
|
@@ -5,8 +5,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.bindByPlaceholderTextQueries = void 0;
|
|
7
7
|
var _findAll = require("../helpers/find-all");
|
|
8
|
-
var _matches = require("../matches");
|
|
9
8
|
var _hostComponentNames = require("../helpers/host-component-names");
|
|
9
|
+
var _matches = require("../matches");
|
|
10
10
|
var _makeQueries = require("./make-queries");
|
|
11
11
|
const matchPlaceholderText = (node, placeholder, options = {}) => {
|
|
12
12
|
const {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"placeholder-text.js","names":["_findAll","require","
|
|
1
|
+
{"version":3,"file":"placeholder-text.js","names":["_findAll","require","_hostComponentNames","_matches","_makeQueries","matchPlaceholderText","node","placeholder","options","exact","normalizer","matches","props","queryAllByPlaceholderText","instance","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 { ReactTestInstance } from 'react-test-renderer';\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: ReactTestInstance,\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 instance: ReactTestInstance,\n): QueryAllByQuery<TextMatch, ByPlaceholderTextOptions> =>\n function queryAllByPlaceholderFn(placeholder, queryOptions) {\n return findAll(\n instance,\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 = (\n instance: ReactTestInstance,\n): ByPlaceholderTextQueries => ({\n getByPlaceholderText: getBy(instance),\n getAllByPlaceholderText: getAllBy(instance),\n queryByPlaceholderText: queryBy(instance),\n queryAllByPlaceholderText: queryAllBy(instance),\n findByPlaceholderText: findBy(instance),\n findAllByPlaceholderText: findAllBy(instance),\n});\n"],"mappings":";;;;;;AACA,IAAAA,QAAA,GAAAC,OAAA;AACA,IAAAC,mBAAA,GAAAD,OAAA;AAEA,IAAAE,QAAA,GAAAF,OAAA;AASA,IAAAG,YAAA,GAAAH,OAAA;AAKA,MAAMI,oBAAoB,GAAGA,CAC3BC,IAAuB,EACvBC,WAAsB,EACtBC,OAAyB,GAAG,CAAC,CAAC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 +1,11 @@
|
|
|
1
|
-
import type { ReactTestInstance } from 'react-test-renderer';
|
|
2
1
|
import type { AccessibilityRole, Role } from 'react-native';
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
2
|
+
import type { ReactTestInstance } from 'react-test-renderer';
|
|
3
|
+
import type { AccessibilityStateMatcher } from '../helpers/matchers/match-accessibility-state';
|
|
4
|
+
import type { AccessibilityValueMatcher } from '../helpers/matchers/match-accessibility-value';
|
|
5
5
|
import type { TextMatch } from '../matches';
|
|
6
|
-
import { StringWithAutocomplete } from '../types';
|
|
6
|
+
import type { StringWithAutocomplete } from '../types';
|
|
7
7
|
import type { FindAllByQuery, FindByQuery, GetAllByQuery, GetByQuery, QueryAllByQuery, QueryByQuery } from './make-queries';
|
|
8
|
-
import { CommonQueryOptions } from './options';
|
|
8
|
+
import type { CommonQueryOptions } from './options';
|
|
9
9
|
export type ByRoleMatcher = StringWithAutocomplete<AccessibilityRole | Role> | RegExp;
|
|
10
10
|
export type ByRoleOptions = CommonQueryOptions & AccessibilityStateMatcher & {
|
|
11
11
|
name?: TextMatch;
|