@testing-library/react-native 12.7.1 → 12.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -53,7 +53,7 @@ import '@testing-library/react-native/extend-expect';
53
53
  ## Example
54
54
 
55
55
  ```jsx
56
- import { render, screen, fireEvent } from '@testing-library/react-native';
56
+ import { render, screen, userEvent } from '@testing-library/react-native';
57
57
  import { QuestionsBoard } from '../QuestionsBoard';
58
58
 
59
59
  // It is recommended to use userEvent with fake timers
@@ -109,7 +109,6 @@ React Native Testing Library consists of following APIs:
109
109
  - [Migration to 12.0](https://callstack.github.io/react-native-testing-library/docs/migration/v12)
110
110
  - [Migration to built-in Jest Matchers](https://callstack.github.io/react-native-testing-library/docs/migration/jest-matchers)
111
111
 
112
-
113
112
  ## Troubleshooting
114
113
 
115
114
  - [Troubleshooting guide](https://callstack.github.io/react-native-testing-library/docs/guides/troubleshooting)
package/build/config.d.ts CHANGED
@@ -9,6 +9,11 @@ export type Config = {
9
9
  defaultIncludeHiddenElements: boolean;
10
10
  /** Default options for `debug` helper. */
11
11
  defaultDebugOptions?: Partial<DebugOptions>;
12
+ /**
13
+ * Set to `true` to enable concurrent rendering.
14
+ * Otherwise `render` will default to legacy synchronous rendering.
15
+ */
16
+ concurrentRoot: boolean;
12
17
  };
13
18
  export type ConfigAliasOptions = {
14
19
  /** RTL-compatibility alias to `defaultIncludeHiddenElements` */
@@ -39,6 +44,11 @@ export declare function getConfig(): {
39
44
  defaultIncludeHiddenElements: boolean;
40
45
  /** Default options for `debug` helper. */
41
46
  defaultDebugOptions?: Partial<DebugOptions>;
47
+ /**
48
+ * Set to `true` to enable concurrent rendering.
49
+ * Otherwise `render` will default to legacy synchronous rendering.
50
+ */
51
+ concurrentRoot: boolean;
42
52
  /** Names for key React Native host components. */
43
53
  hostComponentNames?: HostComponentNames;
44
54
  };
package/build/config.js CHANGED
@@ -13,7 +13,8 @@ exports.resetToDefaults = resetToDefaults;
13
13
 
14
14
  const defaultConfig = {
15
15
  asyncUtilTimeout: 1000,
16
- defaultIncludeHiddenElements: false
16
+ defaultIncludeHiddenElements: false,
17
+ concurrentRoot: false
17
18
  };
18
19
  let config = {
19
20
  ...defaultConfig
@@ -1 +1 @@
1
- {"version":3,"file":"config.js","names":["defaultConfig","asyncUtilTimeout","defaultIncludeHiddenElements","config","configure","options","defaultHidden","restOptions","configureInternal","option","resetToDefaults","getConfig"],"sources":["../src/config.ts"],"sourcesContent":["import { DebugOptions } from './helpers/debug-deep';\n\n/**\n * Global configuration options for React Native Testing Library.\n */\n\nexport type Config = {\n /** Default timeout, in ms, for `waitFor` and `findBy*` queries. */\n asyncUtilTimeout: number;\n\n /** Default value for `includeHiddenElements` query option. */\n defaultIncludeHiddenElements: boolean;\n\n /** Default options for `debug` helper. */\n defaultDebugOptions?: Partial<DebugOptions>;\n};\n\nexport type ConfigAliasOptions = {\n /** RTL-compatibility alias to `defaultIncludeHiddenElements` */\n defaultHidden: boolean;\n};\n\nexport type HostComponentNames = {\n text: string;\n textInput: string;\n image: string;\n switch: string;\n scrollView: string;\n modal: string;\n};\n\nexport type InternalConfig = Config & {\n /** Names for key React Native host components. */\n hostComponentNames?: HostComponentNames;\n};\n\nconst defaultConfig: InternalConfig = {\n asyncUtilTimeout: 1000,\n defaultIncludeHiddenElements: false,\n};\n\nlet config = { ...defaultConfig };\n\n/**\n * Configure global options for React Native Testing Library.\n */\nexport function configure(options: Partial<Config & ConfigAliasOptions>) {\n const { defaultHidden, ...restOptions } = options;\n\n const defaultIncludeHiddenElements =\n restOptions.defaultIncludeHiddenElements ??\n defaultHidden ??\n config.defaultIncludeHiddenElements;\n\n config = {\n ...config,\n ...restOptions,\n defaultIncludeHiddenElements,\n };\n}\n\nexport function configureInternal(option: Partial<InternalConfig>) {\n config = {\n ...config,\n ...option,\n };\n}\n\nexport function resetToDefaults() {\n config = { ...defaultConfig };\n}\n\nexport function getConfig() {\n return config;\n}\n"],"mappings":";;;;;;;;;AAEA;AACA;AACA;;AAgCA,MAAMA,aAA6B,GAAG;EACpCC,gBAAgB,EAAE,IAAI;EACtBC,4BAA4B,EAAE;AAChC,CAAC;AAED,IAAIC,MAAM,GAAG;EAAE,GAAGH;AAAc,CAAC;;AAEjC;AACA;AACA;AACO,SAASI,SAASA,CAACC,OAA6C,EAAE;EACvE,MAAM;IAAEC,aAAa;IAAE,GAAGC;EAAY,CAAC,GAAGF,OAAO;EAEjD,MAAMH,4BAA4B,GAChCK,WAAW,CAACL,4BAA4B,IACxCI,aAAa,IACbH,MAAM,CAACD,4BAA4B;EAErCC,MAAM,GAAG;IACP,GAAGA,MAAM;IACT,GAAGI,WAAW;IACdL;EACF,CAAC;AACH;AAEO,SAASM,iBAAiBA,CAACC,MAA+B,EAAE;EACjEN,MAAM,GAAG;IACP,GAAGA,MAAM;IACT,GAAGM;EACL,CAAC;AACH;AAEO,SAASC,eAAeA,CAAA,EAAG;EAChCP,MAAM,GAAG;IAAE,GAAGH;EAAc,CAAC;AAC/B;AAEO,SAASW,SAASA,CAAA,EAAG;EAC1B,OAAOR,MAAM;AACf","ignoreList":[]}
1
+ {"version":3,"file":"config.js","names":["defaultConfig","asyncUtilTimeout","defaultIncludeHiddenElements","concurrentRoot","config","configure","options","defaultHidden","restOptions","configureInternal","option","resetToDefaults","getConfig"],"sources":["../src/config.ts"],"sourcesContent":["import { DebugOptions } from './helpers/debug-deep';\n\n/**\n * Global configuration options for React Native Testing Library.\n */\n\nexport type Config = {\n /** Default timeout, in ms, for `waitFor` and `findBy*` queries. */\n asyncUtilTimeout: number;\n\n /** Default value for `includeHiddenElements` query option. */\n defaultIncludeHiddenElements: boolean;\n\n /** Default options for `debug` helper. */\n defaultDebugOptions?: Partial<DebugOptions>;\n\n /**\n * Set to `true` to enable concurrent rendering.\n * Otherwise `render` will default to legacy synchronous rendering.\n */\n concurrentRoot: boolean;\n};\n\nexport type ConfigAliasOptions = {\n /** RTL-compatibility alias to `defaultIncludeHiddenElements` */\n defaultHidden: boolean;\n};\n\nexport type HostComponentNames = {\n text: string;\n textInput: string;\n image: string;\n switch: string;\n scrollView: string;\n modal: string;\n};\n\nexport type InternalConfig = Config & {\n /** Names for key React Native host components. */\n hostComponentNames?: HostComponentNames;\n};\n\nconst defaultConfig: InternalConfig = {\n asyncUtilTimeout: 1000,\n defaultIncludeHiddenElements: false,\n concurrentRoot: false,\n};\n\nlet config = { ...defaultConfig };\n\n/**\n * Configure global options for React Native Testing Library.\n */\nexport function configure(options: Partial<Config & ConfigAliasOptions>) {\n const { defaultHidden, ...restOptions } = options;\n\n const defaultIncludeHiddenElements =\n restOptions.defaultIncludeHiddenElements ??\n defaultHidden ??\n config.defaultIncludeHiddenElements;\n\n config = {\n ...config,\n ...restOptions,\n defaultIncludeHiddenElements,\n };\n}\n\nexport function configureInternal(option: Partial<InternalConfig>) {\n config = {\n ...config,\n ...option,\n };\n}\n\nexport function resetToDefaults() {\n config = { ...defaultConfig };\n}\n\nexport function getConfig() {\n return config;\n}\n"],"mappings":";;;;;;;;;AAEA;AACA;AACA;;AAsCA,MAAMA,aAA6B,GAAG;EACpCC,gBAAgB,EAAE,IAAI;EACtBC,4BAA4B,EAAE,KAAK;EACnCC,cAAc,EAAE;AAClB,CAAC;AAED,IAAIC,MAAM,GAAG;EAAE,GAAGJ;AAAc,CAAC;;AAEjC;AACA;AACA;AACO,SAASK,SAASA,CAACC,OAA6C,EAAE;EACvE,MAAM;IAAEC,aAAa;IAAE,GAAGC;EAAY,CAAC,GAAGF,OAAO;EAEjD,MAAMJ,4BAA4B,GAChCM,WAAW,CAACN,4BAA4B,IACxCK,aAAa,IACbH,MAAM,CAACF,4BAA4B;EAErCE,MAAM,GAAG;IACP,GAAGA,MAAM;IACT,GAAGI,WAAW;IACdN;EACF,CAAC;AACH;AAEO,SAASO,iBAAiBA,CAACC,MAA+B,EAAE;EACjEN,MAAM,GAAG;IACP,GAAGA,MAAM;IACT,GAAGM;EACL,CAAC;AACH;AAEO,SAASC,eAAeA,CAAA,EAAG;EAChCP,MAAM,GAAG;IAAE,GAAGJ;EAAc,CAAC;AAC/B;AAEO,SAASY,SAASA,CAAA,EAAG;EAC1B,OAAOR,MAAM;AACf","ignoreList":[]}
@@ -104,10 +104,10 @@ function setNativeStateIfNeeded(element, eventName, value) {
104
104
  }
105
105
  }
106
106
  }
107
- function tryGetContentOffset(value) {
107
+ function tryGetContentOffset(event) {
108
108
  try {
109
109
  // @ts-expect-error: try to extract contentOffset from the event value
110
- const contentOffset = value?.nativeEvent?.contentOffset;
110
+ const contentOffset = event?.nativeEvent?.contentOffset;
111
111
  const x = contentOffset?.x;
112
112
  const y = contentOffset?.y;
113
113
  if (typeof x === 'number' || typeof y === 'number') {
@@ -1 +1 @@
1
- {"version":3,"file":"fire-event.js","names":["_act","_interopRequireDefault","require","_componentTree","_hostComponentNames","_pointerEvents","_textInput","_nativeState","e","__esModule","default","isTouchResponder","element","isHostElement","Boolean","props","onStartShouldSetResponder","isHostTextInput","eventsAffectedByPointerEventsProp","Set","textInputEventsIgnoringEditableProp","isEventEnabled","eventName","nearestTouchResponder","isTextInputEditable","has","isPointerEventEnabled","touchStart","touchMove","onMoveShouldSetResponder","undefined","findEventHandler","touchResponder","handler","getEventHandler","parent","eventHandlerName","getEventHandlerName","charAt","toUpperCase","slice","fireEvent","data","setNativeStateIfNeeded","returnValue","act","press","changeText","scroll","_default","exports","scrollEventNames","value","nativeState","valueForElement","set","isHostScrollView","contentOffset","tryGetContentOffset","contentOffsetForElement","nativeEvent","x","y","Number","isFinite"],"sources":["../src/fire-event.ts"],"sourcesContent":["import { ReactTestInstance } from 'react-test-renderer';\nimport {\n ViewProps,\n TextProps,\n TextInputProps,\n PressableProps,\n ScrollViewProps,\n} from 'react-native';\nimport act from './act';\nimport { isHostElement } from './helpers/component-tree';\nimport { isHostScrollView, isHostTextInput } from './helpers/host-component-names';\nimport { isPointerEventEnabled } from './helpers/pointer-events';\nimport { isTextInputEditable } from './helpers/text-input';\nimport { Point, StringWithAutocomplete } from './types';\nimport { nativeState } from './native-state';\n\ntype EventHandler = (...args: unknown[]) => unknown;\n\nexport function isTouchResponder(element: ReactTestInstance) {\n if (!isHostElement(element)) {\n return false;\n }\n\n return Boolean(element.props.onStartShouldSetResponder) || isHostTextInput(element);\n}\n\n/**\n * List of events affected by `pointerEvents` prop.\n *\n * Note: `fireEvent` is accepting both `press` and `onPress` for event names,\n * so we need cover both forms.\n */\nconst eventsAffectedByPointerEventsProp = new Set(['press', 'onPress']);\n\n/**\n * List of `TextInput` events not affected by `editable` prop.\n *\n * Note: `fireEvent` is accepting both `press` and `onPress` for event names,\n * so we need cover both forms.\n */\nconst textInputEventsIgnoringEditableProp = new Set([\n 'contentSizeChange',\n 'onContentSizeChange',\n 'layout',\n 'onLayout',\n 'scroll',\n 'onScroll',\n]);\n\nexport function isEventEnabled(\n element: ReactTestInstance,\n eventName: string,\n nearestTouchResponder?: ReactTestInstance,\n) {\n if (isHostTextInput(nearestTouchResponder)) {\n return (\n isTextInputEditable(nearestTouchResponder) ||\n textInputEventsIgnoringEditableProp.has(eventName)\n );\n }\n\n if (eventsAffectedByPointerEventsProp.has(eventName) && !isPointerEventEnabled(element)) {\n return false;\n }\n\n const touchStart = nearestTouchResponder?.props.onStartShouldSetResponder?.();\n const touchMove = nearestTouchResponder?.props.onMoveShouldSetResponder?.();\n if (touchStart || touchMove) {\n return true;\n }\n\n return touchStart === undefined && touchMove === undefined;\n}\n\nfunction findEventHandler(\n element: ReactTestInstance,\n eventName: string,\n nearestTouchResponder?: ReactTestInstance,\n): EventHandler | null {\n const touchResponder = isTouchResponder(element) ? element : nearestTouchResponder;\n\n const handler = getEventHandler(element, eventName);\n if (handler && isEventEnabled(element, eventName, touchResponder)) return handler;\n\n // eslint-disable-next-line @typescript-eslint/prefer-optional-chain\n if (element.parent === null || element.parent.parent === null) {\n return null;\n }\n\n return findEventHandler(element.parent, eventName, touchResponder);\n}\n\nfunction getEventHandler(element: ReactTestInstance, eventName: string) {\n const eventHandlerName = getEventHandlerName(eventName);\n if (typeof element.props[eventHandlerName] === 'function') {\n return element.props[eventHandlerName];\n }\n\n if (typeof element.props[eventName] === 'function') {\n return element.props[eventName];\n }\n\n return undefined;\n}\n\nfunction getEventHandlerName(eventName: string) {\n return `on${eventName.charAt(0).toUpperCase()}${eventName.slice(1)}`;\n}\n\n// String union type of keys of T that start with on, stripped of 'on'\ntype EventNameExtractor<T> = keyof {\n [K in keyof T as K extends `on${infer Rest}` ? Uncapitalize<Rest> : never]: T[K];\n};\n\ntype EventName = StringWithAutocomplete<\n | EventNameExtractor<ViewProps>\n | EventNameExtractor<TextProps>\n | EventNameExtractor<TextInputProps>\n | EventNameExtractor<PressableProps>\n | EventNameExtractor<ScrollViewProps>\n>;\n\nfunction fireEvent(element: ReactTestInstance, eventName: EventName, ...data: unknown[]) {\n setNativeStateIfNeeded(element, eventName, data[0]);\n\n const handler = findEventHandler(element, eventName);\n if (!handler) {\n return;\n }\n\n let returnValue;\n void act(() => {\n returnValue = handler(...data);\n });\n\n return returnValue;\n}\n\nfireEvent.press = (element: ReactTestInstance, ...data: unknown[]) =>\n fireEvent(element, 'press', ...data);\n\nfireEvent.changeText = (element: ReactTestInstance, ...data: unknown[]) =>\n fireEvent(element, 'changeText', ...data);\n\nfireEvent.scroll = (element: ReactTestInstance, ...data: unknown[]) =>\n fireEvent(element, 'scroll', ...data);\n\nexport default fireEvent;\n\nconst scrollEventNames = new Set([\n 'scroll',\n 'scrollBeginDrag',\n 'scrollEndDrag',\n 'momentumScrollBegin',\n 'momentumScrollEnd',\n]);\n\nfunction setNativeStateIfNeeded(element: ReactTestInstance, eventName: string, value: unknown) {\n if (\n eventName === 'changeText' &&\n typeof value === 'string' &&\n isHostTextInput(element) &&\n isTextInputEditable(element)\n ) {\n nativeState.valueForElement.set(element, value);\n }\n\n if (scrollEventNames.has(eventName) && isHostScrollView(element)) {\n const contentOffset = tryGetContentOffset(value);\n if (contentOffset) {\n nativeState.contentOffsetForElement.set(element, contentOffset);\n }\n }\n}\n\nfunction tryGetContentOffset(value: unknown): Point | null {\n try {\n // @ts-expect-error: try to extract contentOffset from the event value\n const contentOffset = value?.nativeEvent?.contentOffset;\n const x = contentOffset?.x;\n const y = contentOffset?.y;\n if (typeof x === 'number' || typeof y === 'number') {\n return {\n x: Number.isFinite(x) ? x : 0,\n y: Number.isFinite(y) ? y : 0,\n };\n }\n } catch {\n // Do nothing\n }\n\n return null;\n}\n"],"mappings":";;;;;;;;AAQA,IAAAA,IAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,cAAA,GAAAD,OAAA;AACA,IAAAE,mBAAA,GAAAF,OAAA;AACA,IAAAG,cAAA,GAAAH,OAAA;AACA,IAAAI,UAAA,GAAAJ,OAAA;AAEA,IAAAK,YAAA,GAAAL,OAAA;AAA6C,SAAAD,uBAAAO,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAItC,SAASG,gBAAgBA,CAACC,OAA0B,EAAE;EAC3D,IAAI,CAAC,IAAAC,4BAAa,EAACD,OAAO,CAAC,EAAE;IAC3B,OAAO,KAAK;EACd;EAEA,OAAOE,OAAO,CAACF,OAAO,CAACG,KAAK,CAACC,yBAAyB,CAAC,IAAI,IAAAC,mCAAe,EAACL,OAAO,CAAC;AACrF;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMM,iCAAiC,GAAG,IAAIC,GAAG,CAAC,CAAC,OAAO,EAAE,SAAS,CAAC,CAAC;;AAEvE;AACA;AACA;AACA;AACA;AACA;AACA,MAAMC,mCAAmC,GAAG,IAAID,GAAG,CAAC,CAClD,mBAAmB,EACnB,qBAAqB,EACrB,QAAQ,EACR,UAAU,EACV,QAAQ,EACR,UAAU,CACX,CAAC;AAEK,SAASE,cAAcA,CAC5BT,OAA0B,EAC1BU,SAAiB,EACjBC,qBAAyC,EACzC;EACA,IAAI,IAAAN,mCAAe,EAACM,qBAA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CAAC,GAAG;MAC9B,CAAC;IACH;EACF,CAAC,CAAC,MAAM;IACN;EAAA;EAGF,OAAO,IAAI;AACb","ignoreList":[]}
1
+ {"version":3,"file":"fire-event.js","names":["_act","_interopRequireDefault","require","_componentTree","_hostComponentNames","_pointerEvents","_textInput","_nativeState","e","__esModule","default","isTouchResponder","element","isHostElement","Boolean","props","onStartShouldSetResponder","isHostTextInput","eventsAffectedByPointerEventsProp","Set","textInputEventsIgnoringEditableProp","isEventEnabled","eventName","nearestTouchResponder","isTextInputEditable","has","isPointerEventEnabled","touchStart","touchMove","onMoveShouldSetResponder","undefined","findEventHandler","touchResponder","handler","getEventHandler","parent","eventHandlerName","getEventHandlerName","charAt","toUpperCase","slice","fireEvent","data","setNativeStateIfNeeded","returnValue","act","press","changeText","scroll","_default","exports","scrollEventNames","value","nativeState","valueForElement","set","isHostScrollView","contentOffset","tryGetContentOffset","contentOffsetForElement","event","nativeEvent","x","y","Number","isFinite"],"sources":["../src/fire-event.ts"],"sourcesContent":["import { ReactTestInstance } from 'react-test-renderer';\nimport {\n ViewProps,\n TextProps,\n TextInputProps,\n PressableProps,\n ScrollViewProps,\n} from 'react-native';\nimport act from './act';\nimport { isHostElement } from './helpers/component-tree';\nimport { isHostScrollView, isHostTextInput } from './helpers/host-component-names';\nimport { isPointerEventEnabled } from './helpers/pointer-events';\nimport { isTextInputEditable } from './helpers/text-input';\nimport { Point, StringWithAutocomplete } from './types';\nimport { nativeState } from './native-state';\n\ntype EventHandler = (...args: unknown[]) => unknown;\n\nexport function isTouchResponder(element: ReactTestInstance) {\n if (!isHostElement(element)) {\n return false;\n }\n\n return Boolean(element.props.onStartShouldSetResponder) || isHostTextInput(element);\n}\n\n/**\n * List of events affected by `pointerEvents` prop.\n *\n * Note: `fireEvent` is accepting both `press` and `onPress` for event names,\n * so we need cover both forms.\n */\nconst eventsAffectedByPointerEventsProp = new Set(['press', 'onPress']);\n\n/**\n * List of `TextInput` events not affected by `editable` prop.\n *\n * Note: `fireEvent` is accepting both `press` and `onPress` for event names,\n * so we need cover both forms.\n */\nconst textInputEventsIgnoringEditableProp = new Set([\n 'contentSizeChange',\n 'onContentSizeChange',\n 'layout',\n 'onLayout',\n 'scroll',\n 'onScroll',\n]);\n\nexport function isEventEnabled(\n element: ReactTestInstance,\n eventName: string,\n nearestTouchResponder?: ReactTestInstance,\n) {\n if (isHostTextInput(nearestTouchResponder)) {\n return (\n isTextInputEditable(nearestTouchResponder) ||\n textInputEventsIgnoringEditableProp.has(eventName)\n );\n }\n\n if (eventsAffectedByPointerEventsProp.has(eventName) && !isPointerEventEnabled(element)) {\n return false;\n }\n\n const touchStart = nearestTouchResponder?.props.onStartShouldSetResponder?.();\n const touchMove = nearestTouchResponder?.props.onMoveShouldSetResponder?.();\n if (touchStart || touchMove) {\n return true;\n }\n\n return touchStart === undefined && touchMove === undefined;\n}\n\nfunction findEventHandler(\n element: ReactTestInstance,\n eventName: string,\n nearestTouchResponder?: ReactTestInstance,\n): EventHandler | null {\n const touchResponder = isTouchResponder(element) ? element : nearestTouchResponder;\n\n const handler = getEventHandler(element, eventName);\n if (handler && isEventEnabled(element, eventName, touchResponder)) return handler;\n\n // eslint-disable-next-line @typescript-eslint/prefer-optional-chain\n if (element.parent === null || element.parent.parent === null) {\n return null;\n }\n\n return findEventHandler(element.parent, eventName, touchResponder);\n}\n\nfunction getEventHandler(element: ReactTestInstance, eventName: string) {\n const eventHandlerName = getEventHandlerName(eventName);\n if (typeof element.props[eventHandlerName] === 'function') {\n return element.props[eventHandlerName];\n }\n\n if (typeof element.props[eventName] === 'function') {\n return element.props[eventName];\n }\n\n return undefined;\n}\n\nfunction getEventHandlerName(eventName: string) {\n return `on${eventName.charAt(0).toUpperCase()}${eventName.slice(1)}`;\n}\n\n// String union type of keys of T that start with on, stripped of 'on'\ntype EventNameExtractor<T> = keyof {\n [K in keyof T as K extends `on${infer Rest}` ? Uncapitalize<Rest> : never]: T[K];\n};\n\ntype EventName = StringWithAutocomplete<\n | EventNameExtractor<ViewProps>\n | EventNameExtractor<TextProps>\n | EventNameExtractor<TextInputProps>\n | EventNameExtractor<PressableProps>\n | EventNameExtractor<ScrollViewProps>\n>;\n\nfunction fireEvent(element: ReactTestInstance, eventName: EventName, ...data: unknown[]) {\n setNativeStateIfNeeded(element, eventName, data[0]);\n\n const handler = findEventHandler(element, eventName);\n if (!handler) {\n return;\n }\n\n let returnValue;\n void act(() => {\n returnValue = handler(...data);\n });\n\n return returnValue;\n}\n\nfireEvent.press = (element: ReactTestInstance, ...data: unknown[]) =>\n fireEvent(element, 'press', ...data);\n\nfireEvent.changeText = (element: ReactTestInstance, ...data: unknown[]) =>\n fireEvent(element, 'changeText', ...data);\n\nfireEvent.scroll = (element: ReactTestInstance, ...data: unknown[]) =>\n fireEvent(element, 'scroll', ...data);\n\nexport default fireEvent;\n\nconst scrollEventNames = new Set([\n 'scroll',\n 'scrollBeginDrag',\n 'scrollEndDrag',\n 'momentumScrollBegin',\n 'momentumScrollEnd',\n]);\n\nfunction setNativeStateIfNeeded(element: ReactTestInstance, eventName: string, value: unknown) {\n if (\n eventName === 'changeText' &&\n typeof value === 'string' &&\n isHostTextInput(element) &&\n isTextInputEditable(element)\n ) {\n nativeState.valueForElement.set(element, value);\n }\n\n if (scrollEventNames.has(eventName) && isHostScrollView(element)) {\n const contentOffset = tryGetContentOffset(value);\n if (contentOffset) {\n nativeState.contentOffsetForElement.set(element, contentOffset);\n }\n }\n}\n\nfunction tryGetContentOffset(event: unknown): Point | null {\n try {\n // @ts-expect-error: try to extract contentOffset from the event value\n const contentOffset = event?.nativeEvent?.contentOffset;\n const x = contentOffset?.x;\n const y = contentOffset?.y;\n if (typeof x === 'number' || typeof y === 'number') {\n return {\n x: Number.isFinite(x) ? x : 0,\n y: Number.isFinite(y) ? y : 0,\n };\n }\n } catch {\n // Do nothing\n }\n\n return null;\n}\n"],"mappings":";;;;;;;;AAQA,IAAAA,IAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,cAA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AACL,OAAO,CAAC,IACxB,IAAAY,8BAAmB,EAACZ,OAAO,CAAC,EAC5B;IACAyC,wBAAW,CAACC,eAAe,CAACC,GAAG,CAAC3C,OAAO,EAAEwC,KAAK,CAAC;EACjD;EAEA,IAAID,gBAAgB,CAAC1B,GAAG,CAACH,SAAS,CAAC,IAAI,IAAAkC,oCAAgB,EAAC5C,OAAO,CAAC,EAAE;IAChE,MAAM6C,aAAa,GAAGC,mBAAmB,CAACN,KAAK,CAAC;IAChD,IAAIK,aAAa,EAAE;MACjBJ,wBAAW,CAACM,uBAAuB,CAACJ,GAAG,CAAC3C,OAAO,EAAE6C,aAAa,CAAC;IACjE;EACF;AACF;AAEA,SAASC,mBAAmBA,CAACE,KAAc,EAAgB;EACzD,IAAI;IACF;IACA,MAAMH,aAAa,GAAGG,KAAK,EAAEC,WAAW,EAAEJ,aAAa;IACvD,MAAMK,CAAC,GAAGL,aAAa,EAAEK,CAAC;IAC1B,MAAMC,CAAC,GAAGN,aAAa,EAAEM,CAAC;IAC1B,IAAI,OAAOD,CAAC,KAAK,QAAQ,IAAI,OAAOC,CAAC,KAAK,QAAQ,EAAE;MAClD,OAAO;QACLD,CAAC,EAAEE,MAAM,CAACC,QAAQ,CAACH,CAAC,CAAC,GAAGA,CAAC,GAAG,CAAC;QAC7BC,CAAC,EAAEC,MAAM,CAACC,QAAQ,CAACF,CAAC,CAAC,GAAGA,CAAC,GAAG;MAC9B,CAAC;IACH;EACF,CAAC,CAAC,MAAM;IACN;EAAA;EAGF,OAAO,IAAI;AACb","ignoreList":[]}
@@ -41,7 +41,7 @@ function configureHostComponentNamesIfNeeded() {
41
41
  }
42
42
  function detectHostComponentNames() {
43
43
  try {
44
- const renderer = (0, _renderAct.renderWithAct)( /*#__PURE__*/React.createElement(_reactNative.View, null, /*#__PURE__*/React.createElement(_reactNative.Text, {
44
+ const renderer = (0, _renderAct.renderWithAct)(/*#__PURE__*/React.createElement(_reactNative.View, null, /*#__PURE__*/React.createElement(_reactNative.Text, {
45
45
  testID: "text"
46
46
  }, "Hello"), /*#__PURE__*/React.createElement(_reactNative.TextInput, {
47
47
  testID: "textInput"
@@ -1 +1 @@
1
- {"version":3,"file":"host-component-names.js","names":["React","_interopRequireWildcard","require","_reactNative","_config","_renderAct","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","userConfigErrorMessage","getHostComponentNames","hostComponentNames","getConfig","detectHostComponentNames","configureInternal","configureHostComponentNamesIfNeeded","configHostComponentNames","renderer","renderWithAct","createElement","View","Text","testID","TextInput","Image","Switch","ScrollView","Modal","text","getByTestId","root","type","textInput","image","switch","scrollView","modal","error","errorMessage","message","Error","instance","nodes","findAll","node","props","length","isHostText","element","isHostTextInput","isHostImage","isHostSwitch","isHostScrollView","isHostModal"],"sources":["../../src/helpers/host-component-names.tsx"],"sourcesContent":["import * as React from 'react';\nimport { ReactTestInstance } from 'react-test-renderer';\nimport { Image, Modal, ScrollView, Switch, Text, TextInput, View } from 'react-native';\nimport { configureInternal, getConfig, HostComponentNames } from '../config';\nimport { renderWithAct } from '../render-act';\nimport { HostTestInstance } from './component-tree';\n\nconst userConfigErrorMessage = `There seems to be an issue with your configuration that prevents React Native Testing Library from working correctly.\nPlease check if you are using compatible versions of React Native and React Native Testing Library.`;\n\nexport function getHostComponentNames(): HostComponentNames {\n let hostComponentNames = getConfig().hostComponentNames;\n if (!hostComponentNames) {\n hostComponentNames = detectHostComponentNames();\n configureInternal({ hostComponentNames });\n }\n\n return hostComponentNames;\n}\n\nexport function configureHostComponentNamesIfNeeded() {\n const configHostComponentNames = getConfig().hostComponentNames;\n if (configHostComponentNames) {\n return;\n }\n\n const hostComponentNames = detectHostComponentNames();\n configureInternal({ hostComponentNames });\n}\n\nfunction detectHostComponentNames(): HostComponentNames {\n try {\n const renderer = renderWithAct(\n <View>\n <Text testID=\"text\">Hello</Text>\n <TextInput testID=\"textInput\" />\n <Image testID=\"image\" />\n <Switch testID=\"switch\" />\n <ScrollView testID=\"scrollView\" />\n <Modal testID=\"modal\" />\n </View>,\n );\n\n return {\n text: getByTestId(renderer.root, 'text').type as string,\n textInput: getByTestId(renderer.root, 'textInput').type as string,\n image: getByTestId(renderer.root, 'image').type as string,\n switch: getByTestId(renderer.root, 'switch').type as string,\n scrollView: getByTestId(renderer.root, 'scrollView').type as string,\n modal: getByTestId(renderer.root, 'modal').type as string,\n };\n } catch (error) {\n const errorMessage =\n error && typeof error === 'object' && 'message' in error ? error.message : null;\n\n throw new Error(\n `Trying to detect host component names triggered the following error:\\n\\n${errorMessage}\\n\\n${userConfigErrorMessage}`,\n );\n }\n}\n\nfunction getByTestId(instance: ReactTestInstance, testID: string) {\n const nodes = instance.findAll(\n (node) => typeof node.type === 'string' && node.props.testID === testID,\n );\n\n if (nodes.length === 0) {\n throw new Error(`Unable to find an element with testID: ${testID}`);\n }\n\n return nodes[0];\n}\n\n/**\n * Checks if the given element is a host Text element.\n * @param element The element to check.\n */\nexport function isHostText(element?: ReactTestInstance | null): element is HostTestInstance {\n return element?.type === getHostComponentNames().text;\n}\n\n/**\n * Checks if the given element is a host TextInput element.\n * @param element The element to check.\n */\nexport function isHostTextInput(element?: ReactTestInstance | null): element is HostTestInstance {\n return element?.type === getHostComponentNames().textInput;\n}\n\n/**\n * Checks if the given element is a host Image element.\n * @param element The element to check.\n */\nexport function isHostImage(element?: ReactTestInstance | null): element is HostTestInstance {\n return element?.type === getHostComponentNames().image;\n}\n\n/**\n * Checks if the given element is a host Switch element.\n * @param element The element to check.\n */\nexport function isHostSwitch(element?: ReactTestInstance | null): element is HostTestInstance {\n return element?.type === getHostComponentNames().switch;\n}\n\n/**\n * Checks if the given element is a host ScrollView element.\n * @param element The element to check.\n */\nexport function isHostScrollView(element?: ReactTestInstance | null): element is HostTestInstance {\n return element?.type === getHostComponentNames().scrollView;\n}\n\n/**\n * Checks if the given element is a host Modal element.\n * @param element The element to check.\n */\nexport function isHost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;EAEA,OAAOoB,KAAK,CAAC,CAAC,CAAC;AACjB;;AAEA;AACA;AACA;AACA;AACO,SAASK,UAAUA,CAACC,OAAkC,EAA+B;EAC1F,OAAOA,OAAO,EAAEjB,IAAI,KAAKrB,qBAAqB,CAAC,CAAC,CAACkB,IAAI;AACvD;;AAEA;AACA;AACA;AACA;AACO,SAASqB,eAAeA,CAACD,OAAkC,EAA+B;EAC/F,OAAOA,OAAO,EAAEjB,IAAI,KAAKrB,qBAAqB,CAAC,CAAC,CAACsB,SAAS;AAC5D;;AAEA;AACA;AACA;AACA;AACO,SAASkB,WAAWA,CAACF,OAAkC,EAA+B;EAC3F,OAAOA,OAAO,EAAEjB,IAAI,KAAKrB,qBAAqB,CAAC,CAAC,CAACuB,KAAK;AACxD;;AAEA;AACA;AACA;AACA;AACO,SAASkB,YAAYA,CAACH,OAAkC,EAA+B;EAC5F,OAAOA,OAAO,EAAEjB,IAAI,KAAKrB,qBAAqB,CAAC,CAAC,CAACwB,MAAM;AACzD;;AAEA;AACA;AACA;AACA;AACO,SAASkB,gBAAgBA,CAACJ,OAAkC,EAA+B;EAChG,OAAOA,OAAO,EAAEjB,IAAI,KAAKrB,qBAAqB,CAAC,CAAC,CAACyB,UAAU;AAC7D;;AAEA;AACA;AACA;AACA;AACO,SAASkB,WAAWA,CAACL,OAAkC,EAA+B;EAC3F,OAAOA,OAAO,EAAEjB,IAAI,KAAKrB,qBAAqB,CAAC,CAAC,CAAC0B,KAAK;AACxD","ignoreList":[]}
1
+ {"version":3,"file":"host-component-names.js","names":["React","_interopRequireWildcard","require","_reactNative","_config","_renderAct","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","userConfigErrorMessage","getHostComponentNames","hostComponentNames","getConfig","detectHostComponentNames","configureInternal","configureHostComponentNamesIfNeeded","configHostComponentNames","renderer","renderWithAct","createElement","View","Text","testID","TextInput","Image","Switch","ScrollView","Modal","text","getByTestId","root","type","textInput","image","switch","scrollView","modal","error","errorMessage","message","Error","instance","nodes","findAll","node","props","length","isHostText","element","isHostTextInput","isHostImage","isHostSwitch","isHostScrollView","isHostModal"],"sources":["../../src/helpers/host-component-names.tsx"],"sourcesContent":["import * as React from 'react';\nimport { ReactTestInstance } from 'react-test-renderer';\nimport { Image, Modal, ScrollView, Switch, Text, TextInput, View } from 'react-native';\nimport { configureInternal, getConfig, HostComponentNames } from '../config';\nimport { renderWithAct } from '../render-act';\nimport { HostTestInstance } from './component-tree';\n\nconst userConfigErrorMessage = `There seems to be an issue with your configuration that prevents React Native Testing Library from working correctly.\nPlease check if you are using compatible versions of React Native and React Native Testing Library.`;\n\nexport function getHostComponentNames(): HostComponentNames {\n let hostComponentNames = getConfig().hostComponentNames;\n if (!hostComponentNames) {\n hostComponentNames = detectHostComponentNames();\n configureInternal({ hostComponentNames });\n }\n\n return hostComponentNames;\n}\n\nexport function configureHostComponentNamesIfNeeded() {\n const configHostComponentNames = getConfig().hostComponentNames;\n if (configHostComponentNames) {\n return;\n }\n\n const hostComponentNames = detectHostComponentNames();\n configureInternal({ hostComponentNames });\n}\n\nfunction detectHostComponentNames(): HostComponentNames {\n try {\n const renderer = renderWithAct(\n <View>\n <Text testID=\"text\">Hello</Text>\n <TextInput testID=\"textInput\" />\n <Image testID=\"image\" />\n <Switch testID=\"switch\" />\n <ScrollView testID=\"scrollView\" />\n <Modal testID=\"modal\" />\n </View>,\n );\n\n return {\n text: getByTestId(renderer.root, 'text').type as string,\n textInput: getByTestId(renderer.root, 'textInput').type as string,\n image: getByTestId(renderer.root, 'image').type as string,\n switch: getByTestId(renderer.root, 'switch').type as string,\n scrollView: getByTestId(renderer.root, 'scrollView').type as string,\n modal: getByTestId(renderer.root, 'modal').type as string,\n };\n } catch (error) {\n const errorMessage =\n error && typeof error === 'object' && 'message' in error ? error.message : null;\n\n throw new Error(\n `Trying to detect host component names triggered the following error:\\n\\n${errorMessage}\\n\\n${userConfigErrorMessage}`,\n );\n }\n}\n\nfunction getByTestId(instance: ReactTestInstance, testID: string) {\n const nodes = instance.findAll(\n (node) => typeof node.type === 'string' && node.props.testID === testID,\n );\n\n if (nodes.length === 0) {\n throw new Error(`Unable to find an element with testID: ${testID}`);\n }\n\n return nodes[0];\n}\n\n/**\n * Checks if the given element is a host Text element.\n * @param element The element to check.\n */\nexport function isHostText(element?: ReactTestInstance | null): element is HostTestInstance {\n return element?.type === getHostComponentNames().text;\n}\n\n/**\n * Checks if the given element is a host TextInput element.\n * @param element The element to check.\n */\nexport function isHostTextInput(element?: ReactTestInstance | null): element is HostTestInstance {\n return element?.type === getHostComponentNames().textInput;\n}\n\n/**\n * Checks if the given element is a host Image element.\n * @param element The element to check.\n */\nexport function isHostImage(element?: ReactTestInstance | null): element is HostTestInstance {\n return element?.type === getHostComponentNames().image;\n}\n\n/**\n * Checks if the given element is a host Switch element.\n * @param element The element to check.\n */\nexport function isHostSwitch(element?: ReactTestInstance | null): element is HostTestInstance {\n return element?.type === getHostComponentNames().switch;\n}\n\n/**\n * Checks if the given element is a host ScrollView element.\n * @param element The element to check.\n */\nexport function isHostScrollView(element?: ReactTestInstance | null): element is HostTestInstance {\n return element?.type === getHostComponentNames().scrollView;\n}\n\n/**\n * Checks if the given element is a host Modal element.\n * @param element The element to check.\n */\nexport function isHostModal(element?: ReactTestInstance | null): element is HostTestInstance {\n return element?.type === getHostComponentNames().modal;\n}\n"],"mappings":";;;;;;;;;;;;;AAAA,IAAAA,KAAA,GAAAC,uBAAA,CAAAC,OAAA;AAEA,IAAAC,YAAA,GAAAD,OAAA;AACA,IAAAE,OAAA,GAAAF,OAAA;AACA,IAAAG,UAAA,GAAAH,OAAA;AAA8C,SAAAI,yBAAAC,CAAA,6BAAAC,OAAA,mBAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAF,wBAAA,YAAAA,CAAAC,CAAA,WAAAA,CAAA,GAAAG,CAAA,GAAAD,CAAA,KAA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AOA,OAAO,EAAEjB,IAAI,KAAKrB,qBAAqB,CAAC,CAAC,CAACuB,KAAK;AACxD;;AAEA;AACA;AACA;AACA;AACO,SAASkB,YAAYA,CAACH,OAAkC,EAA+B;EAC5F,OAAOA,OAAO,EAAEjB,IAAI,KAAKrB,qBAAqB,CAAC,CAAC,CAACwB,MAAM;AACzD;;AAEA;AACA;AACA;AACA;AACO,SAASkB,gBAAgBA,CAACJ,OAAkC,EAA+B;EAChG,OAAOA,OAAO,EAAEjB,IAAI,KAAKrB,qBAAqB,CAAC,CAAC,CAACyB,UAAU;AAC7D;;AAEA;AACA;AACA;AACA;AACO,SAASkB,WAAWA,CAACL,OAAkC,EAA+B;EAC3F,OAAOA,OAAO,EAAEjB,IAAI,KAAKrB,qBAAqB,CAAC,CAAC,CAAC0B,KAAK;AACxD","ignoreList":[]}
@@ -203,7 +203,7 @@ export interface JestNativeMatchers<R> {
203
203
  */
204
204
  toHaveAccessibleName(expectedName?: TextMatch, options?: TextMatchOptions): R;
205
205
  /**
206
- * Assert whether a host `TextInput` element has a given display value based on `value` and `defaultValue` props.
206
+ * Assert whether a host `TextInput` element has a given display value based on `value` prop, unmanaged native state, and `defaultValue` prop.
207
207
  *
208
208
  * @see
209
209
  * [Jest Matchers docs](https://callstack.github.io/react-native-testing-library/docs/jest-matchers#tohavedisplayvalue)
@@ -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` and `defaultValue` props.\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-ignore\ndeclare module '@jest/expect' {\n interface Matchers<R extends void | Promise<void>> extends JestNativeMatchers<R> {}\n}\n"],"mappings":"","ignoreList":[]}
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-ignore\ndeclare module '@jest/expect' {\n interface Matchers<R extends void | Promise<void>> extends JestNativeMatchers<R> {}\n}\n"],"mappings":"","ignoreList":[]}
@@ -33,7 +33,7 @@ function renderHook(renderCallback, options) {
33
33
  detectHostComponentNames: false
34
34
  });
35
35
  function rerender(rerenderCallbackProps) {
36
- return baseRerender( /*#__PURE__*/_react.default.createElement(TestComponent, {
36
+ return baseRerender(/*#__PURE__*/_react.default.createElement(TestComponent, {
37
37
  renderCallbackProps: rerenderCallbackProps
38
38
  }));
39
39
  }
@@ -1 +1 @@
1
- {"version":3,"file":"render-hook.js","names":["_react","_interopRequireDefault","require","_render","e","__esModule","default","renderHook","renderCallback","options","initialProps","wrapper","result","React","createRef","TestComponent","renderCallbackProps","renderResult","useEffect","current","rerender","baseRerender","unmount","renderInternal","createElement","detectHostComponentNames","rerenderCallbackProps"],"sources":["../src/render-hook.tsx"],"sourcesContent":["import React from 'react';\nimport type { ComponentType } from 'react';\nimport { renderInternal } from './render';\n\nexport type RenderHookResult<Result, Props> = {\n rerender: (props: Props) => void;\n result: { current: Result };\n unmount: () => void;\n};\n\nexport type RenderHookOptions<Props> = {\n initialProps?: Props;\n wrapper?: ComponentType<any>;\n};\n\nexport function renderHook<Result, Props>(\n renderCallback: (props: Props) => Result,\n options?: RenderHookOptions<Props>,\n): RenderHookResult<Result, Props> {\n const initialProps = options?.initialProps;\n const wrapper = options?.wrapper;\n\n const result: React.MutableRefObject<Result | null> = React.createRef();\n\n function TestComponent({ renderCallbackProps }: { renderCallbackProps: Props }) {\n const renderResult = renderCallback(renderCallbackProps);\n\n React.useEffect(() => {\n result.current = renderResult;\n });\n\n return null;\n }\n\n const { rerender: baseRerender, unmount } = renderInternal(\n // @ts-expect-error since option can be undefined, initialProps can be undefined when it should'nt\n <TestComponent renderCallbackProps={initialProps} />,\n {\n wrapper,\n detectHostComponentNames: false,\n },\n );\n\n function rerender(rerenderCallbackProps: Props) {\n return baseRerender(<TestComponent renderCallbackProps={rerenderCallbackProps} />);\n }\n\n // @ts-expect-error result is ill typed because ref is initialized to null\n return { result, rerender, unmount };\n}\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AAEA,IAAAC,OAAA,GAAAD,OAAA;AAA0C,SAAAD,uBAAAG,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAanC,SAASG,UAAUA,CACxBC,cAAwC,EACxCC,OAAkC,EACD;EACjC,MAAMC,YAAY,GAAGD,OAAO,EAAEC,YAAY;EAC1C,MAAMC,OAAO,GAAGF,OAAO,EAAEE,OAAO;EAEhC,MAAMC,MAA6C,gBAAGC,cAAK,CAACC,SAAS,CAAC,CAAC;EAEvE,SAASC,aAAaA,CAAC;IAAEC;EAAoD,CAAC,EAAE;IAC9E,MAAMC,YAAY,GAAGT,cAAc,CAACQ,mBAAmB,CAAC;IAExDH,cAAK,CAACK,SAAS,CAAC,MAAM;MACpBN,MAAM,CAACO,OAAO,GAAGF,YAAY;IAC/B,CAAC,CAAC;IAEF,OAAO,IAAI;EACb;EAEA,MAAM;IAAEG,QAAQ,EAAEC,YAAY;IAAEC;EAAQ,CAAC,GAAG,IAAAC,sBAAc;EAAA;EACxD;EACAvB,MAAA,CAAAM,OAAA,CAAAkB,aAAA,CAACT,aAAa;IAACC,mBAAmB,EAAEN;EAAa,CAAE,CAAC,EACpD;IACEC,OAAO;IACPc,wBAAwB,EAAE;EAC5B,CACF,CAAC;EAED,SAASL,QAAQA,CAACM,qBAA4B,EAAE;IAC9C,OAAOL,YAAY,eAACrB,MAAA,CAAAM,OAAA,CAAAkB,aAAA,CAACT,aAAa;MAACC,mBAAmB,EAAEU;IAAsB,CAAE,CAAC,CAAC;EACpF;;EAEA;EACA,OAAO;IAAEd,MAAM;IAAEQ,QAAQ;IAAEE;EAAQ,CAAC;AACtC","ignoreList":[]}
1
+ {"version":3,"file":"render-hook.js","names":["_react","_interopRequireDefault","require","_render","e","__esModule","default","renderHook","renderCallback","options","initialProps","wrapper","result","React","createRef","TestComponent","renderCallbackProps","renderResult","useEffect","current","rerender","baseRerender","unmount","renderInternal","createElement","detectHostComponentNames","rerenderCallbackProps"],"sources":["../src/render-hook.tsx"],"sourcesContent":["import React from 'react';\nimport type { ComponentType } from 'react';\nimport { renderInternal } from './render';\n\nexport type RenderHookResult<Result, Props> = {\n rerender: (props: Props) => void;\n result: { current: Result };\n unmount: () => void;\n};\n\nexport type RenderHookOptions<Props> = {\n initialProps?: Props;\n wrapper?: ComponentType<any>;\n};\n\nexport function renderHook<Result, Props>(\n renderCallback: (props: Props) => Result,\n options?: RenderHookOptions<Props>,\n): RenderHookResult<Result, Props> {\n const initialProps = options?.initialProps;\n const wrapper = options?.wrapper;\n\n const result: React.MutableRefObject<Result | null> = React.createRef();\n\n function TestComponent({ renderCallbackProps }: { renderCallbackProps: Props }) {\n const renderResult = renderCallback(renderCallbackProps);\n\n React.useEffect(() => {\n result.current = renderResult;\n });\n\n return null;\n }\n\n const { rerender: baseRerender, unmount } = renderInternal(\n // @ts-expect-error since option can be undefined, initialProps can be undefined when it should'nt\n <TestComponent renderCallbackProps={initialProps} />,\n {\n wrapper,\n detectHostComponentNames: false,\n },\n );\n\n function rerender(rerenderCallbackProps: Props) {\n return baseRerender(<TestComponent renderCallbackProps={rerenderCallbackProps} />);\n }\n\n // @ts-expect-error result is ill typed because ref is initialized to null\n return { result, rerender, unmount };\n}\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AAEA,IAAAC,OAAA,GAAAD,OAAA;AAA0C,SAAAD,uBAAAG,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAanC,SAASG,UAAUA,CACxBC,cAAwC,EACxCC,OAAkC,EACD;EACjC,MAAMC,YAAY,GAAGD,OAAO,EAAEC,YAAY;EAC1C,MAAMC,OAAO,GAAGF,OAAO,EAAEE,OAAO;EAEhC,MAAMC,MAA6C,gBAAGC,cAAK,CAACC,SAAS,CAAC,CAAC;EAEvE,SAASC,aAAaA,CAAC;IAAEC;EAAoD,CAAC,EAAE;IAC9E,MAAMC,YAAY,GAAGT,cAAc,CAACQ,mBAAmB,CAAC;IAExDH,cAAK,CAACK,SAAS,CAAC,MAAM;MACpBN,MAAM,CAACO,OAAO,GAAGF,YAAY;IAC/B,CAAC,CAAC;IAEF,OAAO,IAAI;EACb;EAEA,MAAM;IAAEG,QAAQ,EAAEC,YAAY;IAAEC;EAAQ,CAAC,GAAG,IAAAC,sBAAc;EAAA;EACxD;EACAvB,MAAA,CAAAM,OAAA,CAAAkB,aAAA,CAACT,aAAa;IAACC,mBAAmB,EAAEN;EAAa,CAAE,CAAC,EACpD;IACEC,OAAO;IACPc,wBAAwB,EAAE;EAC5B,CACF,CAAC;EAED,SAASL,QAAQA,CAACM,qBAA4B,EAAE;IAC9C,OAAOL,YAAY,cAACrB,MAAA,CAAAM,OAAA,CAAAkB,aAAA,CAACT,aAAa;MAACC,mBAAmB,EAAEU;IAAsB,CAAE,CAAC,CAAC;EACpF;;EAEA;EACA,OAAO;IAAEd,MAAM;IAAEQ,QAAQ;IAAEE;EAAQ,CAAC;AACtC","ignoreList":[]}
package/build/render.d.ts CHANGED
@@ -2,7 +2,16 @@ import type { ReactTestInstance } from 'react-test-renderer';
2
2
  import * as React from 'react';
3
3
  import { DebugOptions } from './helpers/debug-deep';
4
4
  export interface RenderOptions {
5
+ /**
6
+ * Pass a React Component as the wrapper option to have it rendered around the inner element. This is most useful for creating
7
+ * reusable custom render functions for common data providers.
8
+ */
5
9
  wrapper?: React.ComponentType<any>;
10
+ /**
11
+ * Set to `true` to enable concurrent rendering.
12
+ * Otherwise `render` will default to legacy synchronous rendering.
13
+ */
14
+ concurrentRoot?: boolean | undefined;
6
15
  createNodeMock?: (element: React.ReactElement) => unknown;
7
16
  unstable_validateStringsRenderedWithinText?: boolean;
8
17
  }
package/build/render.js CHANGED
@@ -31,10 +31,16 @@ function render(component, options = {}) {
31
31
  function renderInternal(component, options) {
32
32
  const {
33
33
  wrapper: Wrapper,
34
+ concurrentRoot,
34
35
  detectHostComponentNames = true,
35
36
  unstable_validateStringsRenderedWithinText,
36
- ...testRendererOptions
37
+ ...rest
37
38
  } = options || {};
39
+ const testRendererOptions = {
40
+ ...rest,
41
+ // @ts-expect-error incomplete typing on RTR package
42
+ unstable_isConcurrent: concurrentRoot ?? (0, _config.getConfig)().concurrentRoot
43
+ };
38
44
  if (detectHostComponentNames) {
39
45
  (0, _hostComponentNames.configureHostComponentNamesIfNeeded)();
40
46
  }
@@ -1 +1 @@
1
- {"version":3,"file":"render.js","names":["_react","_interopRequireWildcard","require","React","_act","_interopRequireDefault","_cleanup","_config","_componentTree","_debugDeep","_debugShallow","_hostComponentNames","_stringValidation","_renderAct","_screen","_within","e","__esModule","default","_getRequireWildcardCache","WeakMap","r","t","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","render","component","options","renderInternal","wrapper","Wrapper","detectHostComponentNames","unstable_validateStringsRenderedWithinText","testRendererOptions","configureHostComponentNamesIfNeeded","renderWithStringValidation","wrap","element","createElement","renderer","renderWithAct","buildRenderResult","handleRender","_","phase","validateStringsRenderedWithinText","toJSON","Profiler","id","onRender","update","updateWithAct","instance","root","unmount","act","addToCleanupQueue","result","getQueriesForElement","rerender","debug","getHostChildren","UNSAFE_root","enumerable","Error","setRenderResult","debugImpl","defaultDebugOptions","getConfig","debugOptions","message","console","warn","json","debugDeep","shallow","debugShallow"],"sources":["../src/render.tsx"],"sourcesContent":["import type { ReactTestInstance, ReactTestRenderer } from 'react-test-renderer';\nimport * as React from 'react';\nimport { Profiler } from 'react';\nimport act from './act';\nimport { addToCleanupQueue } from './cleanup';\nimport { getConfig } from './config';\nimport { getHostChildren } from './helpers/component-tree';\nimport debugDeep, { DebugOptions } from './helpers/debug-deep';\nimport debugShallow from './helpers/debug-shallow';\nimport { configureHostComponentNamesIfNeeded } from './helpers/host-component-names';\nimport { validateStringsRenderedWithinText } from './helpers/string-validation';\nimport { renderWithAct } from './render-act';\nimport { setRenderResult } from './screen';\nimport { getQueriesForElement } from './within';\n\nexport interface RenderOptions {\n wrapper?: React.ComponentType<any>;\n createNodeMock?: (element: React.ReactElement) => unknown;\n unstable_validateStringsRenderedWithinText?: boolean;\n}\n\nexport type RenderResult = ReturnType<typeof render>;\n\n/**\n * Renders test component deeply using React Test Renderer and exposes helpers\n * to assert on the output.\n */\nexport default function render<T>(component: React.ReactElement<T>, options: RenderOptions = {}) {\n return renderInternal(component, options);\n}\n\nexport interface RenderInternalOptions extends RenderOptions {\n detectHostComponentNames?: boolean;\n}\n\nexport function renderInternal<T>(\n component: React.ReactElement<T>,\n options?: RenderInternalOptions,\n) {\n const {\n wrapper: Wrapper,\n detectHostComponentNames = true,\n unstable_validateStringsRenderedWithinText,\n ...testRendererOptions\n } = options || {};\n\n if (detectHostComponentNames) {\n configureHostComponentNamesIfNeeded();\n }\n\n if (unstable_validateStringsRenderedWithinText) {\n return renderWithStringValidation(component, {\n wrapper: Wrapper,\n ...testRendererOptions,\n });\n }\n\n const wrap = (element: React.ReactElement) => (Wrapper ? <Wrapper>{element}</Wrapper> : element);\n const renderer = renderWithAct(wrap(component), testRendererOptions);\n return buildRenderResult(renderer, wrap);\n}\n\nfunction renderWithStringValidation<T>(\n component: React.ReactElement<T>,\n options: Omit<RenderOptions, 'unstable_validateStringsRenderedWithinText'> = {},\n) {\n let renderer: ReactTestRenderer;\n const { wrapper: Wrapper, ...testRendererOptions } = options ?? {};\n\n const handleRender: React.ProfilerOnRenderCallback = (_, phase) => {\n if (renderer && phase === 'update') {\n validateStringsRenderedWithinText(renderer.toJSON());\n }\n };\n\n const wrap = (element: React.ReactElement) => (\n <Profiler id=\"renderProfiler\" onRender={handleRender}>\n {Wrapper ? <Wrapper>{element}</Wrapper> : element}\n </Profiler>\n );\n\n renderer = renderWithAct(wrap(component), testRendererOptions);\n\n validateStringsRenderedWithinText(renderer.toJSON());\n\n return buildRenderResult(renderer, wrap);\n}\n\nfunction buildRenderResult(\n renderer: ReactTestRenderer,\n wrap: (element: React.ReactElement) => JSX.Element,\n) {\n const update = updateWithAct(renderer, wrap);\n const instance = renderer.root;\n\n const unmount = () => {\n void act(() => {\n renderer.unmount();\n });\n };\n\n addToCleanupQueue(unmount);\n\n const result = {\n ...getQueriesForElement(instance),\n update,\n unmount,\n rerender: update, // alias for `update`\n toJSON: renderer.toJSON,\n debug: debug(instance, renderer),\n get root(): ReactTestInstance {\n return getHostChildren(instance)[0];\n },\n UNSAFE_root: instance,\n };\n\n // Add as non-enumerable property, so that it's safe to enumerate\n // `render` result, e.g. using destructuring rest syntax.\n Object.defineProperty(result, 'container', {\n enumerable: false,\n get() {\n throw new Error(\n \"'container' property has been renamed to 'UNSAFE_root'.\\n\\n\" +\n \"Consider using 'root' property which returns root host element.\",\n );\n },\n });\n\n setRenderResult(result);\n\n return result;\n}\n\nfunction updateWithAct(\n renderer: ReactTestRenderer,\n wrap: (innerElement: React.ReactElement) => React.ReactElement,\n) {\n return function (component: React.ReactElement) {\n void act(() => {\n renderer.update(wrap(component));\n });\n };\n}\n\nexport interface DebugFunction {\n (options?: DebugOptions | string): void;\n shallow: (message?: string) => void;\n}\n\nfunction debug(instance: ReactTestInstance, renderer: ReactTestRenderer): DebugFunction {\n function debugImpl(options?: DebugOptions | string) {\n const { defaultDebugOptions } = getConfig();\n const debugOptions =\n typeof options === 'string'\n ? { ...defaultDebugOptions, message: options }\n : { ...defaultDebugOptions, ...options };\n\n if (typeof options === 'string') {\n // eslint-disable-next-line no-console\n console.warn(\n 'Using debug(\"message\") is deprecated and will be removed in future release, please use debug({ message; \"message\" }) instead.',\n );\n }\n\n const json = renderer.toJSON();\n if (json) {\n return debugDeep(json, debugOptions);\n }\n }\n debugImpl.shallow = (message?: string) => debugShallow(instance, message);\n return debugImpl;\n}\n"],"mappings":";;;;;;;AACA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AAA+B,IAAAC,KAAA,GAAAH,MAAA;AAE/B,IAAAI,IAAA,GAAAC,sBAAA,CAAAH,OAAA;AACA,IAAAI,QAAA,GAAAJ,OAAA;AACA,IAAAK,OAAA,GAAAL,OAAA;AACA,IAAAM,cAAA,GAAAN,OAAA;AACA,IAAAO,UAAA,GAAAJ,sBAAA,CAAAH,OAAA;AACA,IAAAQ,aAAA,GAAAL,sBAAA,CAAAH,OAAA;AACA,IAAAS,mBAAA,GAAAT,OAAA;AACA,IAAAU,iBAAA,GAAAV,OAAA;AACA,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act","_interopRequireDefault","_cleanup","_config","_componentTree","_debugDeep","_debugShallow","_hostComponentNames","_stringValidation","_renderAct","_screen","_within","e","__esModule","default","_getRequireWildcardCache","WeakMap","r","t","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","render","component","options","renderInternal","wrapper","Wrapper","concurrentRoot","detectHostComponentNames","unstable_validateStringsRenderedWithinText","rest","testRendererOptions","unstable_isConcurrent","getConfig","configureHostComponentNamesIfNeeded","renderWithStringValidation","wrap","element","createElement","renderer","renderWithAct","buildRenderResult","handleRender","_","phase","validateStringsRenderedWithinText","toJSON","Profiler","id","onRender","update","updateWithAct","instance","root","unmount","act","addToCleanupQueue","result","getQueriesForElement","rerender","debug","getHostChildren","UNSAFE_root","enumerable","Error","setRenderResult","debugImpl","defaultDebugOptions","debugOptions","message","console","warn","json","debugDeep","shallow","debugShallow"],"sources":["../src/render.tsx"],"sourcesContent":["import type {\n ReactTestInstance,\n ReactTestRenderer,\n TestRendererOptions,\n} from 'react-test-renderer';\nimport * as React from 'react';\nimport { Profiler } from 'react';\nimport act from './act';\nimport { addToCleanupQueue } from './cleanup';\nimport { getConfig } from './config';\nimport { getHostChildren } from './helpers/component-tree';\nimport debugDeep, { DebugOptions } from './helpers/debug-deep';\nimport debugShallow from './helpers/debug-shallow';\nimport { configureHostComponentNamesIfNeeded } from './helpers/host-component-names';\nimport { validateStringsRenderedWithinText } from './helpers/string-validation';\nimport { renderWithAct } from './render-act';\nimport { setRenderResult } from './screen';\nimport { getQueriesForElement } from './within';\n\nexport interface RenderOptions {\n /**\n * Pass a React Component as the wrapper option to have it rendered around the inner element. This is most useful for creating\n * reusable custom render functions for common data providers.\n */\n wrapper?: React.ComponentType<any>;\n\n /**\n * Set to `true` to enable concurrent rendering.\n * Otherwise `render` will default to legacy synchronous rendering.\n */\n concurrentRoot?: boolean | undefined;\n\n createNodeMock?: (element: React.ReactElement) => unknown;\n unstable_validateStringsRenderedWithinText?: boolean;\n}\n\nexport type RenderResult = ReturnType<typeof render>;\n\n/**\n * Renders test component deeply using React Test Renderer and exposes helpers\n * to assert on the output.\n */\nexport default function render<T>(component: React.ReactElement<T>, options: RenderOptions = {}) {\n return renderInternal(component, options);\n}\n\nexport interface RenderInternalOptions extends RenderOptions {\n detectHostComponentNames?: boolean;\n}\n\nexport function renderInternal<T>(\n component: React.ReactElement<T>,\n options?: RenderInternalOptions,\n) {\n const {\n wrapper: Wrapper,\n concurrentRoot,\n detectHostComponentNames = true,\n unstable_validateStringsRenderedWithinText,\n ...rest\n } = options || {};\n\n const testRendererOptions: TestRendererOptions = {\n ...rest,\n // @ts-expect-error incomplete typing on RTR package\n unstable_isConcurrent: concurrentRoot ?? getConfig().concurrentRoot,\n };\n\n if (detectHostComponentNames) {\n configureHostComponentNamesIfNeeded();\n }\n\n if (unstable_validateStringsRenderedWithinText) {\n return renderWithStringValidation(component, {\n wrapper: Wrapper,\n ...testRendererOptions,\n });\n }\n\n const wrap = (element: React.ReactElement) => (Wrapper ? <Wrapper>{element}</Wrapper> : element);\n const renderer = renderWithAct(wrap(component), testRendererOptions);\n return buildRenderResult(renderer, wrap);\n}\n\nfunction renderWithStringValidation<T>(\n component: React.ReactElement<T>,\n options: Omit<RenderOptions, 'unstable_validateStringsRenderedWithinText'> = {},\n) {\n let renderer: ReactTestRenderer;\n const { wrapper: Wrapper, ...testRendererOptions } = options ?? {};\n\n const handleRender: React.ProfilerOnRenderCallback = (_, phase) => {\n if (renderer && phase === 'update') {\n validateStringsRenderedWithinText(renderer.toJSON());\n }\n };\n\n const wrap = (element: React.ReactElement) => (\n <Profiler id=\"renderProfiler\" onRender={handleRender}>\n {Wrapper ? <Wrapper>{element}</Wrapper> : element}\n </Profiler>\n );\n\n renderer = renderWithAct(wrap(component), testRendererOptions);\n\n validateStringsRenderedWithinText(renderer.toJSON());\n\n return buildRenderResult(renderer, wrap);\n}\n\nfunction buildRenderResult(\n renderer: ReactTestRenderer,\n wrap: (element: React.ReactElement) => JSX.Element,\n) {\n const update = updateWithAct(renderer, wrap);\n const instance = renderer.root;\n\n const unmount = () => {\n void act(() => {\n renderer.unmount();\n });\n };\n\n addToCleanupQueue(unmount);\n\n const result = {\n ...getQueriesForElement(instance),\n update,\n unmount,\n rerender: update, // alias for `update`\n toJSON: renderer.toJSON,\n debug: debug(instance, renderer),\n get root(): ReactTestInstance {\n return getHostChildren(instance)[0];\n },\n UNSAFE_root: instance,\n };\n\n // Add as non-enumerable property, so that it's safe to enumerate\n // `render` result, e.g. using destructuring rest syntax.\n Object.defineProperty(result, 'container', {\n enumerable: false,\n get() {\n throw new Error(\n \"'container' property has been renamed to 'UNSAFE_root'.\\n\\n\" +\n \"Consider using 'root' property which returns root host element.\",\n );\n },\n });\n\n setRenderResult(result);\n\n return result;\n}\n\nfunction updateWithAct(\n renderer: ReactTestRenderer,\n wrap: (innerElement: React.ReactElement) => React.ReactElement,\n) {\n return function (component: React.ReactElement) {\n void act(() => {\n renderer.update(wrap(component));\n });\n };\n}\n\nexport interface DebugFunction {\n (options?: DebugOptions | string): void;\n shallow: (message?: string) => void;\n}\n\nfunction debug(instance: ReactTestInstance, renderer: ReactTestRenderer): DebugFunction {\n function debugImpl(options?: DebugOptions | string) {\n const { defaultDebugOptions } = getConfig();\n const debugOptions =\n typeof options === 'string'\n ? { ...defaultDebugOptions, message: options }\n : { ...defaultDebugOptions, ...options };\n\n if (typeof options === 'string') {\n // eslint-disable-next-line no-console\n console.warn(\n 'Using debug(\"message\") is deprecated and will be removed in future release, please use debug({ message; \"message\" }) instead.',\n );\n }\n\n const json = renderer.toJSON();\n if (json) {\n return debugDeep(json, debugOptions);\n }\n }\n debugImpl.shallow = (message?: string) => debugShallow(instance, message);\n return debugImpl;\n}\n"],"mappings":";;;;;;;AAKA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AAA+B,IAAAC,KAAA,GAAAH,MAAA;AAE/B,IAAAI,IAAA,GAAAC,sBAAA,CAAAH,OAAA;AACA,IA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,QAAQ,EAAE;MAC/B;MACA+C,OAAO,CAACC,IAAI,CACV,+HACF,CAAC;IACH;IAEA,MAAMC,IAAI,GAAGjC,QAAQ,CAACO,MAAM,CAAC,CAAC;IAC9B,IAAI0B,IAAI,EAAE;MACR,OAAO,IAAAC,kBAAS,EAACD,IAAI,EAAEJ,YAAY,CAAC;IACtC;EACF;EACAF,SAAS,CAACQ,OAAO,GAAIL,OAAgB,IAAK,IAAAM,qBAAY,EAACvB,QAAQ,EAAEiB,OAAO,CAAC;EACzE,OAAOH,SAAS;AAClB","ignoreList":[]}
package/build/shallow.js CHANGED
@@ -16,7 +16,7 @@ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e;
16
16
  */
17
17
  function shallowInternal(instance) {
18
18
  const renderer = new _shallow.default();
19
- renderer.render( /*#__PURE__*/React.createElement(instance.type, instance.props));
19
+ renderer.render(/*#__PURE__*/React.createElement(instance.type, instance.props));
20
20
  return {
21
21
  output: renderer.getRenderOutput()
22
22
  };
@@ -1 +1 @@
1
- {"version":3,"file":"shallow.js","names":["React","_interopRequireWildcard","require","_shallow","_interopRequireDefault","e","__esModule","default","_getRequireWildcardCache","WeakMap","r","t","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","shallowInternal","instance","renderer","ShallowRenderer","render","createElement","type","props","output","getRenderOutput"],"sources":["../src/shallow.ts"],"sourcesContent":["import * as React from 'react';\nimport { ReactTestInstance } from 'react-test-renderer';\nimport ShallowRenderer from 'react-test-renderer/shallow'; // eslint-disable-line import/no-extraneous-dependencies\n\n/**\n * Renders test component shallowly using react-test-renderer/shallow\n */\nexport function shallowInternal(instance: ReactTestInstance | React.ReactElement<any>): {\n output: any;\n} {\n const renderer = new (ShallowRenderer as any)();\n\n renderer.render(React.createElement(instance.type, instance.props));\n\n return {\n output: renderer.getRenderOutput(),\n };\n}\n"],"mappings":";;;;;;AAAA,IAAAA,KAAA,GAAAC,uBAAA,CAAAC,OAAA;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;AAE3D;AACA;AACA;AACO,SAASW,eAAeA,CAACC,QAAqD,EAEnF;EACA,MAAMC,QAAQ,GAAG,IAAKC,gBAAe,CAAS,CAAC;EAE/CD,QAAQ,CAACE,MAAM,eAAC7B,KAAK,CAAC8B,aAAa,CAACJ,QAAQ,CAACK,IAAI,EAAEL,QAAQ,CAACM,KAAK,CAAC,CAAC;EAEnE,OAAO;IACLC,MAAM,EAAEN,QAAQ,CAACO,eAAe,CAAC;EACnC,CAAC;AACH","ignoreList":[]}
1
+ {"version":3,"file":"shallow.js","names":["React","_interopRequireWildcard","require","_shallow","_interopRequireDefault","e","__esModule","default","_getRequireWildcardCache","WeakMap","r","t","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","shallowInternal","instance","renderer","ShallowRenderer","render","createElement","type","props","output","getRenderOutput"],"sources":["../src/shallow.ts"],"sourcesContent":["import * as React from 'react';\nimport { ReactTestInstance } from 'react-test-renderer';\nimport ShallowRenderer from 'react-test-renderer/shallow'; // eslint-disable-line import/no-extraneous-dependencies\n\n/**\n * Renders test component shallowly using react-test-renderer/shallow\n */\nexport function shallowInternal(instance: ReactTestInstance | React.ReactElement<any>): {\n output: any;\n} {\n const renderer = new (ShallowRenderer as any)();\n\n renderer.render(React.createElement(instance.type, instance.props));\n\n return {\n output: renderer.getRenderOutput(),\n };\n}\n"],"mappings":";;;;;;AAAA,IAAAA,KAAA,GAAAC,uBAAA,CAAAC,OAAA;AAEA,IAAAC,QAAA,GAAAC,sBAAA,CAAAF,OAAA;AAA0D,SAAAE,uBAAAC,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAAA,SAAAG,yBAAAH,CAAA,6BAAAI,OAAA,mBAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAD,wBAAA,YAAAA,CAAAH,CAAA,WAAAA,CAAA,GAAAM,CAAA,GA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
@@ -0,0 +1 @@
1
+ {"root":["../src/act.ts","../src/cleanup.ts","../src/config.ts","../src/fire-event.ts","../src/flush-micro-tasks.ts","../src/index.ts","../src/matches.ts","../src/native-state.ts","../src/pure.ts","../src/react-versions.ts","../src/render-act.ts","../src/render-hook.tsx","../src/render.tsx","../src/screen.ts","../src/shallow.ts","../src/types.ts","../src/wait-for-element-to-be-removed.ts","../src/wait-for.ts","../src/within.ts","../src/helpers/accessibility.ts","../src/helpers/component-tree.ts","../src/helpers/debug-deep.ts","../src/helpers/debug-shallow.ts","../src/helpers/deprecation.ts","../src/helpers/errors.ts","../src/helpers/find-all.ts","../src/helpers/format-default.ts","../src/helpers/format.ts","../src/helpers/host-component-names.tsx","../src/helpers/object.ts","../src/helpers/pointer-events.ts","../src/helpers/query-name.ts","../src/helpers/string-validation.ts","../src/helpers/text-content.ts","../src/helpers/text-input.ts","../src/helpers/timers.ts","../src/helpers/wrap-async.ts","../src/helpers/matchers/match-accessibility-state.ts","../src/helpers/matchers/match-accessibility-value.ts","../src/helpers/matchers/match-array-prop.ts","../src/helpers/matchers/match-label-text.ts","../src/helpers/matchers/match-object-prop.ts","../src/helpers/matchers/match-string-prop.ts","../src/helpers/matchers/match-text-content.ts","../src/matchers/extend-expect.ts","../src/matchers/index.ts","../src/matchers/to-be-busy.tsx","../src/matchers/to-be-checked.tsx","../src/matchers/to-be-disabled.tsx","../src/matchers/to-be-empty-element.tsx","../src/matchers/to-be-expanded.tsx","../src/matchers/to-be-on-the-screen.tsx","../src/matchers/to-be-partially-checked.tsx","../src/matchers/to-be-selected.ts","../src/matchers/to-be-visible.tsx","../src/matchers/to-contain-element.tsx","../src/matchers/to-have-accessibility-value.tsx","../src/matchers/to-have-accessible-name.tsx","../src/matchers/to-have-display-value.tsx","../src/matchers/to-have-prop.ts","../src/matchers/to-have-style.tsx","../src/matchers/to-have-text-content.tsx","../src/matchers/types.ts","../src/matchers/utils.tsx","../src/queries/accessibility-state.ts","../src/queries/accessibility-value.ts","../src/queries/display-value.ts","../src/queries/hint-text.ts","../src/queries/label-text.ts","../src/queries/make-queries.ts","../src/queries/options.ts","../src/queries/placeholder-text.ts","../src/queries/role.ts","../src/queries/test-id.ts","../src/queries/text.ts","../src/queries/unsafe-props.ts","../src/queries/unsafe-type.ts","../src/test-utils/events.ts","../src/test-utils/index.ts","../src/user-event/clear.ts","../src/user-event/index.ts","../src/user-event/paste.ts","../src/user-event/event-builder/base.ts","../src/user-event/event-builder/common.ts","../src/user-event/event-builder/index.ts","../src/user-event/event-builder/scroll-view.ts","../src/user-event/event-builder/text-input.ts","../src/user-event/press/constants.ts","../src/user-event/press/index.ts","../src/user-event/press/press.ts","../src/user-event/scroll/index.ts","../src/user-event/scroll/scroll-to.ts","../src/user-event/scroll/utils.ts","../src/user-event/setup/index.ts","../src/user-event/setup/setup.ts","../src/user-event/type/index.ts","../src/user-event/type/parse-keys.ts","../src/user-event/type/type.ts","../src/user-event/utils/content-size.ts","../src/user-event/utils/dispatch-event.ts","../src/user-event/utils/index.ts","../src/user-event/utils/text-range.ts","../src/user-event/utils/wait.ts"],"version":"5.6.3"}
@@ -23,7 +23,7 @@ async function clear(element) {
23
23
  (0, _utils.dispatchEvent)(element, 'focus', _eventBuilder.EventBuilder.Common.focus());
24
24
 
25
25
  // 2. Select all
26
- const textToClear = element.props.value ?? element.props.defaultValue ?? '';
26
+ const textToClear = (0, _textInput.getTextInputValue)(element);
27
27
  const selectionRange = {
28
28
  start: 0,
29
29
  end: textToClear.length
@@ -1 +1 @@
1
- {"version":3,"file":"clear.js","names":["_errors","require","_hostComponentNames","_textInput","_pointerEvents","_eventBuilder","_utils","_type","clear","element","isHostTextInput","ErrorWithStack","type","isTextInputEditable","isPointerEventEnabled","dispatchEvent","EventBuilder","Common","focus","textToClear","props","value","defaultValue","selectionRange","start","end","length","TextInput","selectionChange","emptyText","emitTypingEvents","config","key","text","wait","endEditing","blur"],"sources":["../../src/user-event/clear.ts"],"sourcesContent":["import { ReactTestInstance } from 'react-test-renderer';\nimport { ErrorWithStack } from '../helpers/errors';\nimport { isHostTextInput } from '../helpers/host-component-names';\nimport { isTextInputEditable } from '../helpers/text-input';\nimport { isPointerEventEnabled } from '../helpers/pointer-events';\nimport { EventBuilder } from './event-builder';\nimport { UserEventInstance } from './setup';\nimport { dispatchEvent, wait } from './utils';\nimport { emitTypingEvents } from './type/type';\n\nexport async function clear(this: UserEventInstance, element: ReactTestInstance): Promise<void> {\n if (!isHostTextInput(element)) {\n throw new ErrorWithStack(\n `clear() only supports host \"TextInput\" elements. Passed element has type: \"${element.type}\".`,\n clear,\n );\n }\n\n if (!isTextInputEditable(element) || !isPointerEventEnabled(element)) {\n return;\n }\n\n // 1. Enter element\n dispatchEvent(element, 'focus', EventBuilder.Common.focus());\n\n // 2. Select all\n const textToClear = element.props.value ?? element.props.defaultValue ?? '';\n const selectionRange = {\n start: 0,\n end: textToClear.length,\n };\n dispatchEvent(element, 'selectionChange', EventBuilder.TextInput.selectionChange(selectionRange));\n\n // 3. Press backspace with selected text\n const emptyText = '';\n await emitTypingEvents(element, {\n config: this.config,\n key: 'Backspace',\n text: emptyText,\n });\n\n // 4. Exit element\n await wait(this.config);\n dispatchEvent(element, 'endEditing', EventBuilder.TextInput.endEditing(emptyText));\n dispatchEvent(element, 'blur', EventBuilder.Common.blur());\n}\n"],"mappings":";;;;;;AACA,IAAAA,OAAA,GAAAC,OAAA;AACA,IAAAC,mBAAA,GAAAD,OAAA;AACA,IAAAE,UAAA,GAAAF,OAAA;AACA,IAAAG,cAAA,GAAAH,OAAA;AACA,IAAAI,aAAA,GAAAJ,OAAA;AAEA,IAAAK,MAAA,GAAAL,OAAA;AACA,IAAAM,KAAA,GAAAN,OAAA;AAEO,eAAeO,KAAKA,CAA0BC,OAA0B,EAAiB;EAC9F,IAAI,CAAC,IAAAC,mCAAe,EAACD,OAAO,CAAC,EAAE;IAC7B,MAAM,IAAIE,sBAAc,CACtB,8EAA8EF,OAAO,CAACG,IAAI,IAAI,EAC9FJ,KACF,CAAC;EACH;EAEA,IAAI,CAAC,IAAAK,8BAAmB,EAACJ,OAAO,CAAC,IAAI,CAAC,IAAAK,oCAAqB,EAACL,OAAO,CAAC,EAAE;IACpE;EACF;;EAEA;EACA,IAAAM,oBAAa,EAACN,OAAO,EAAE,OAAO,EAAEO,0BAAY,CAACC,MAAM,CAACC,KAAK,CAAC,CAAC,CAAC;;EAE5D;EACA,MAAMC,WAAW,GAAGV,OAAO,CAACW,KAAK,CAACC,KAAK,IAAIZ,OAAO,CAACW,KAAK,CAACE,YAAY,IAAI,EAAE;EAC3E,MAAMC,cAAc,GAAG;IACrBC,KAAK,EAAE,CAAC;IACRC,GAAG,EAAEN,WAAW,CAACO;EACnB,CAAC;EACD,IAAAX,oBAAa,EAACN,OAAO,EAAE,iBAAiB,EAAEO,0BAAY,CAACW,SAAS,CAACC,eAAe,CAACL,cAAc,CAAC,CAAC;;EAEjG;EACA,MAAMM,SAAS,GAAG,EAAE;EACpB,MAAM,IAAAC,sBAAgB,EAACrB,OAAO,EAAE;IAC9BsB,MAAM,EAAE,IAAI,CAACA,MAAM;IACnBC,GAAG,EAAE,WAAW;IAChBC,IAAI,EAAEJ;EACR,CAAC,CAAC;;EAEF;EACA,MAAM,IAAAK,WAAI,EAAC,IAAI,CAACH,MAAM,CAAC;EACvB,IAAAhB,oBAAa,EAACN,OAAO,EAAE,YAAY,EAAEO,0BAAY,CAACW,SAAS,CAACQ,UAAU,CAACN,SAAS,CAAC,CAAC;EAClF,IAAAd,oBAAa,EAACN,OAAO,EAAE,MAAM,EAAEO,0BAAY,CAACC,MAAM,CAACmB,IAAI,CAAC,CAAC,CAAC;AAC5D","ignoreList":[]}
1
+ {"version":3,"file":"clear.js","names":["_errors","require","_hostComponentNames","_textInput","_pointerEvents","_eventBuilder","_utils","_type","clear","element","isHostTextInput","ErrorWithStack","type","isTextInputEditable","isPointerEventEnabled","dispatchEvent","EventBuilder","Common","focus","textToClear","getTextInputValue","selectionRange","start","end","length","TextInput","selectionChange","emptyText","emitTypingEvents","config","key","text","wait","endEditing","blur"],"sources":["../../src/user-event/clear.ts"],"sourcesContent":["import { ReactTestInstance } from 'react-test-renderer';\nimport { ErrorWithStack } from '../helpers/errors';\nimport { isHostTextInput } from '../helpers/host-component-names';\nimport { getTextInputValue, isTextInputEditable } from '../helpers/text-input';\nimport { isPointerEventEnabled } from '../helpers/pointer-events';\nimport { EventBuilder } from './event-builder';\nimport { UserEventInstance } from './setup';\nimport { dispatchEvent, wait } from './utils';\nimport { emitTypingEvents } from './type/type';\n\nexport async function clear(this: UserEventInstance, element: ReactTestInstance): Promise<void> {\n if (!isHostTextInput(element)) {\n throw new ErrorWithStack(\n `clear() only supports host \"TextInput\" elements. Passed element has type: \"${element.type}\".`,\n clear,\n );\n }\n\n if (!isTextInputEditable(element) || !isPointerEventEnabled(element)) {\n return;\n }\n\n // 1. Enter element\n dispatchEvent(element, 'focus', EventBuilder.Common.focus());\n\n // 2. Select all\n const textToClear = getTextInputValue(element);\n const selectionRange = {\n start: 0,\n end: textToClear.length,\n };\n dispatchEvent(element, 'selectionChange', EventBuilder.TextInput.selectionChange(selectionRange));\n\n // 3. Press backspace with selected text\n const emptyText = '';\n await emitTypingEvents(element, {\n config: this.config,\n key: 'Backspace',\n text: emptyText,\n });\n\n // 4. Exit element\n await wait(this.config);\n dispatchEvent(element, 'endEditing', EventBuilder.TextInput.endEditing(emptyText));\n dispatchEvent(element, 'blur', EventBuilder.Common.blur());\n}\n"],"mappings":";;;;;;AACA,IAAAA,OAAA,GAAAC,OAAA;AACA,IAAAC,mBAAA,GAAAD,OAAA;AACA,IAAAE,UAAA,GAAAF,OAAA;AACA,IAAAG,cAAA,GAAAH,OAAA;AACA,IAAAI,aAAA,GAAAJ,OAAA;AAEA,IAAAK,MAAA,GAAAL,OAAA;AACA,IAAAM,KAAA,GAAAN,OAAA;AAEO,eAAeO,KAAKA,CAA0BC,OAA0B,EAAiB;EAC9F,IAAI,CAAC,IAAAC,mCAAe,EAACD,OAAO,CAAC,EAAE;IAC7B,MAAM,IAAIE,sBAAc,CACtB,8EAA8EF,OAAO,CAACG,IAAI,IAAI,EAC9FJ,KACF,CAAC;EACH;EAEA,IAAI,CAAC,IAAAK,8BAAmB,EAACJ,OAAO,CAAC,IAAI,CAAC,IAAAK,oCAAqB,EAACL,OAAO,CAAC,EAAE;IACpE;EACF;;EAEA;EACA,IAAAM,oBAAa,EAACN,OAAO,EAAE,OAAO,EAAEO,0BAAY,CAACC,MAAM,CAACC,KAAK,CAAC,CAAC,CAAC;;EAE5D;EACA,MAAMC,WAAW,GAAG,IAAAC,4BAAiB,EAACX,OAAO,CAAC;EAC9C,MAAMY,cAAc,GAAG;IACrBC,KAAK,EAAE,CAAC;IACRC,GAAG,EAAEJ,WAAW,CAACK;EACnB,CAAC;EACD,IAAAT,oBAAa,EAACN,OAAO,EAAE,iBAAiB,EAAEO,0BAAY,CAACS,SAAS,CAACC,eAAe,CAACL,cAAc,CAAC,CAAC;;EAEjG;EACA,MAAMM,SAAS,GAAG,EAAE;EACpB,MAAM,IAAAC,sBAAgB,EAACnB,OAAO,EAAE;IAC9BoB,MAAM,EAAE,IAAI,CAACA,MAAM;IACnBC,GAAG,EAAE,WAAW;IAChBC,IAAI,EAAEJ;EACR,CAAC,CAAC;;EAEF;EACA,MAAM,IAAAK,WAAI,EAAC,IAAI,CAACH,MAAM,CAAC;EACvB,IAAAd,oBAAa,EAACN,OAAO,EAAE,YAAY,EAAEO,0BAAY,CAACS,SAAS,CAACQ,UAAU,CAACN,SAAS,CAAC,CAAC;EAClF,IAAAZ,oBAAa,EAACN,OAAO,EAAE,MAAM,EAAEO,0BAAY,CAACC,MAAM,CAACiB,IAAI,CAAC,CAAC,CAAC;AAC5D","ignoreList":[]}
@@ -23,7 +23,7 @@ async function paste(element, text) {
23
23
  (0, _utils.dispatchEvent)(element, 'focus', _eventBuilder.EventBuilder.Common.focus());
24
24
 
25
25
  // 2. Select all
26
- const textToClear = element.props.value ?? element.props.defaultValue ?? '';
26
+ const textToClear = (0, _textInput.getTextInputValue)(element);
27
27
  const rangeToClear = {
28
28
  start: 0,
29
29
  end: textToClear.length
@@ -1 +1 @@
1
- {"version":3,"file":"paste.js","names":["_errors","require","_hostComponentNames","_pointerEvents","_textInput","_nativeState","_eventBuilder","_utils","paste","element","text","isHostTextInput","ErrorWithStack","type","isTextInputEditable","isPointerEventEnabled","dispatchEvent","EventBuilder","Common","focus","textToClear","props","value","defaultValue","rangeToClear","start","end","length","TextInput","selectionChange","nativeState","valueForElement","set","change","rangeAfter","isMultiline","multiline","contentSize","getTextContentSize","contentSizeChange","wait","config","endEditing","blur"],"sources":["../../src/user-event/paste.ts"],"sourcesContent":["import { ReactTestInstance } from 'react-test-renderer';\nimport { ErrorWithStack } from '../helpers/errors';\nimport { isHostTextInput } from '../helpers/host-component-names';\nimport { isPointerEventEnabled } from '../helpers/pointer-events';\nimport { isTextInputEditable } from '../helpers/text-input';\nimport { nativeState } from '../native-state';\nimport { EventBuilder } from './event-builder';\nimport { UserEventInstance } from './setup';\nimport { dispatchEvent, getTextContentSize, wait } from './utils';\n\nexport async function paste(\n this: UserEventInstance,\n element: ReactTestInstance,\n text: string,\n): Promise<void> {\n if (!isHostTextInput(element)) {\n throw new ErrorWithStack(\n `paste() only supports host \"TextInput\" elements. Passed element has type: \"${element.type}\".`,\n paste,\n );\n }\n\n if (!isTextInputEditable(element) || !isPointerEventEnabled(element)) {\n return;\n }\n\n // 1. Enter element\n dispatchEvent(element, 'focus', EventBuilder.Common.focus());\n\n // 2. Select all\n const textToClear = element.props.value ?? element.props.defaultValue ?? '';\n const rangeToClear = { start: 0, end: textToClear.length };\n dispatchEvent(element, 'selectionChange', EventBuilder.TextInput.selectionChange(rangeToClear));\n\n // 3. Paste the text\n nativeState.valueForElement.set(element, text);\n dispatchEvent(element, 'change', EventBuilder.TextInput.change(text));\n dispatchEvent(element, 'changeText', text);\n\n const rangeAfter = { start: text.length, end: text.length };\n dispatchEvent(element, 'selectionChange', EventBuilder.TextInput.selectionChange(rangeAfter));\n\n // According to the docs only multiline TextInput emits contentSizeChange event\n // @see: https://reactnative.dev/docs/textinput#oncontentsizechange\n const isMultiline = element.props.multiline === true;\n if (isMultiline) {\n const contentSize = getTextContentSize(text);\n dispatchEvent(\n element,\n 'contentSizeChange',\n EventBuilder.TextInput.contentSizeChange(contentSize),\n );\n }\n\n // 4. Exit element\n await wait(this.config);\n dispatchEvent(element, 'endEditing', EventBuilder.TextInput.endEditing(text));\n dispatchEvent(element, 'blur', EventBuilder.Common.blur());\n}\n"],"mappings":";;;;;;AACA,IAAAA,OAAA,GAAAC,OAAA;AACA,IAAAC,mBAAA,GAAAD,OAAA;AACA,IAAAE,cAAA,GAAAF,OAAA;AACA,IAAAG,UAAA,GAAAH,OAAA;AACA,IAAAI,YAAA,GAAAJ,OAAA;AACA,IAAAK,aAAA,GAAAL,OAAA;AAEA,IAAAM,MAAA,GAAAN,OAAA;AAEO,eAAeO,KAAKA,CAEzBC,OAA0B,EAC1BC,IAAY,EACG;EACf,IAAI,CAAC,IAAAC,mCAAe,EAACF,OAAO,CAAC,EAAE;IAC7B,MAAM,IAAIG,sBAAc,CACtB,8EAA8EH,OAAO,CAACI,IAAI,IAAI,EAC9FL,KACF,CAAC;EACH;EAEA,IAAI,CAAC,IAAAM,8BAAmB,EAACL,OAAO,CAAC,IAAI,CAAC,IAAAM,oCAAqB,EAACN,OAAO,CAAC,EAAE;IACpE;EACF;;EAEA;EACA,IAAAO,oBAAa,EAACP,OAAO,EAAE,OAAO,EAAEQ,0BAAY,CAACC,MAAM,CAACC,KAAK,CAAC,CAAC,CAAC;;EAE5D;EACA,MAAMC,WAAW,GAAGX,OAAO,CAACY,KAAK,CAACC,KAAK,IAAIb,OAAO,CAACY,KAAK,CAACE,YAAY,IAAI,EAAE;EAC3E,MAAMC,YAAY,GAAG;IAAEC,KAAK,EAAE,CAAC;IAAEC,GAAG,EAAEN,WAAW,CAACO;EAAO,CAAC;EAC1D,IAAAX,oBAAa,EAACP,OAAO,EAAE,iBAAiB,EAAEQ,0BAAY,CAACW,SAAS,CAACC,eAAe,CAACL,YAAY,CAAC,CAAC;;EAE/F;EACAM,wBAAW,CAACC,eAAe,CAACC,GAAG,CAACvB,OAAO,EAAEC,IAAI,CAAC;EAC9C,IAAAM,oBAAa,EAACP,OAAO,EAAE,QAAQ,EAAEQ,0BAAY,CAACW,SAAS,CAACK,MAAM,CAACvB,IAAI,CAAC,CAAC;EACrE,IAAAM,oBAAa,EAACP,OAAO,EAAE,YAAY,EAAEC,IAAI,CAAC;EAE1C,MAAMwB,UAAU,GAAG;IAAET,KAAK,EAAEf,IAAI,CAACiB,MAAM;IAAED,GAAG,EAAEhB,IAAI,CAACiB;EAAO,CAAC;EAC3D,IAAAX,oBAAa,EAACP,OAAO,EAAE,iBAAiB,EAAEQ,0BAAY,CAACW,SAAS,CAACC,eAAe,CAACK,UAAU,CAAC,CAAC;;EAE7F;EACA;EACA,MAAMC,WAAW,GAAG1B,OAAO,CAACY,KAAK,CAACe,SAAS,KAAK,IAAI;EACpD,IAAID,WAAW,EAAE;IACf,MAAME,WAAW,GAAG,IAAAC,yBAAkB,EAAC5B,IAAI,CAAC;IAC5C,IAAAM,oBAAa,EACXP,OAAO,EACP,mBAAmB,EACnBQ,0BAAY,CAACW,SAAS,CAACW,iBAAiB,CAACF,WAAW,CACtD,CAAC;EACH;;EAEA;EACA,MAAM,IAAAG,WAAI,EAAC,IAAI,CAACC,MAAM,CAAC;EACvB,IAAAzB,oBAAa,EAACP,OAAO,EAAE,YAAY,EAAEQ,0BAAY,CAACW,SAAS,CAACc,UAAU,CAAChC,IAAI,CAAC,CAAC;EAC7E,IAAAM,oBAAa,EAACP,OAAO,EAAE,MAAM,EAAEQ,0BAAY,CAACC,MAAM,CAACyB,IAAI,CAAC,CAAC,CAAC;AAC5D","ignoreList":[]}
1
+ {"version":3,"file":"paste.js","names":["_errors","require","_hostComponentNames","_pointerEvents","_textInput","_nativeState","_eventBuilder","_utils","paste","element","text","isHostTextInput","ErrorWithStack","type","isTextInputEditable","isPointerEventEnabled","dispatchEvent","EventBuilder","Common","focus","textToClear","getTextInputValue","rangeToClear","start","end","length","TextInput","selectionChange","nativeState","valueForElement","set","change","rangeAfter","isMultiline","props","multiline","contentSize","getTextContentSize","contentSizeChange","wait","config","endEditing","blur"],"sources":["../../src/user-event/paste.ts"],"sourcesContent":["import { ReactTestInstance } from 'react-test-renderer';\nimport { ErrorWithStack } from '../helpers/errors';\nimport { isHostTextInput } from '../helpers/host-component-names';\nimport { isPointerEventEnabled } from '../helpers/pointer-events';\nimport { getTextInputValue, isTextInputEditable } from '../helpers/text-input';\nimport { nativeState } from '../native-state';\nimport { EventBuilder } from './event-builder';\nimport { UserEventInstance } from './setup';\nimport { dispatchEvent, getTextContentSize, wait } from './utils';\n\nexport async function paste(\n this: UserEventInstance,\n element: ReactTestInstance,\n text: string,\n): Promise<void> {\n if (!isHostTextInput(element)) {\n throw new ErrorWithStack(\n `paste() only supports host \"TextInput\" elements. Passed element has type: \"${element.type}\".`,\n paste,\n );\n }\n\n if (!isTextInputEditable(element) || !isPointerEventEnabled(element)) {\n return;\n }\n\n // 1. Enter element\n dispatchEvent(element, 'focus', EventBuilder.Common.focus());\n\n // 2. Select all\n const textToClear = getTextInputValue(element);\n const rangeToClear = { start: 0, end: textToClear.length };\n dispatchEvent(element, 'selectionChange', EventBuilder.TextInput.selectionChange(rangeToClear));\n\n // 3. Paste the text\n nativeState.valueForElement.set(element, text);\n dispatchEvent(element, 'change', EventBuilder.TextInput.change(text));\n dispatchEvent(element, 'changeText', text);\n\n const rangeAfter = { start: text.length, end: text.length };\n dispatchEvent(element, 'selectionChange', EventBuilder.TextInput.selectionChange(rangeAfter));\n\n // According to the docs only multiline TextInput emits contentSizeChange event\n // @see: https://reactnative.dev/docs/textinput#oncontentsizechange\n const isMultiline = element.props.multiline === true;\n if (isMultiline) {\n const contentSize = getTextContentSize(text);\n dispatchEvent(\n element,\n 'contentSizeChange',\n EventBuilder.TextInput.contentSizeChange(contentSize),\n );\n }\n\n // 4. Exit element\n await wait(this.config);\n dispatchEvent(element, 'endEditing', EventBuilder.TextInput.endEditing(text));\n dispatchEvent(element, 'blur', EventBuilder.Common.blur());\n}\n"],"mappings":";;;;;;AACA,IAAAA,OAAA,GAAAC,OAAA;AACA,IAAAC,mBAAA,GAAAD,OAAA;AACA,IAAAE,cAAA,GAAAF,OAAA;AACA,IAAAG,UAAA,GAAAH,OAAA;AACA,IAAAI,YAAA,GAAAJ,OAAA;AACA,IAAAK,aAAA,GAAAL,OAAA;AAEA,IAAAM,MAAA,GAAAN,OAAA;AAEO,eAAeO,KAAKA,CAEzBC,OAA0B,EAC1BC,IAAY,EACG;EACf,IAAI,CAAC,IAAAC,mCAAe,EAACF,OAAO,CAAC,EAAE;IAC7B,MAAM,IAAIG,sBAAc,CACtB,8EAA8EH,OAAO,CAACI,IAAI,IAAI,EAC9FL,KACF,CAAC;EACH;EAEA,IAAI,CAAC,IAAAM,8BAAmB,EAACL,OAAO,CAAC,IAAI,CAAC,IAAAM,oCAAqB,EAACN,OAAO,CAAC,EAAE;IACpE;EACF;;EAEA;EACA,IAAAO,oBAAa,EAACP,OAAO,EAAE,OAAO,EAAEQ,0BAAY,CAACC,MAAM,CAACC,KAAK,CAAC,CAAC,CAAC;;EAE5D;EACA,MAAMC,WAAW,GAAG,IAAAC,4BAAiB,EAACZ,OAAO,CAAC;EAC9C,MAAMa,YAAY,GAAG;IAAEC,KAAK,EAAE,CAAC;IAAEC,GAAG,EAAEJ,WAAW,CAACK;EAAO,CAAC;EAC1D,IAAAT,oBAAa,EAACP,OAAO,EAAE,iBAAiB,EAAEQ,0BAAY,CAACS,SAAS,CAACC,eAAe,CAACL,YAAY,CAAC,CAAC;;EAE/F;EACAM,wBAAW,CAACC,eAAe,CAACC,GAAG,CAACrB,OAAO,EAAEC,IAAI,CAAC;EAC9C,IAAAM,oBAAa,EAACP,OAAO,EAAE,QAAQ,EAAEQ,0BAAY,CAACS,SAAS,CAACK,MAAM,CAACrB,IAAI,CAAC,CAAC;EACrE,IAAAM,oBAAa,EAACP,OAAO,EAAE,YAAY,EAAEC,IAAI,CAAC;EAE1C,MAAMsB,UAAU,GAAG;IAAET,KAAK,EAAEb,IAAI,CAACe,MAAM;IAAED,GAAG,EAAEd,IAAI,CAACe;EAAO,CAAC;EAC3D,IAAAT,oBAAa,EAACP,OAAO,EAAE,iBAAiB,EAAEQ,0BAAY,CAACS,SAAS,CAACC,eAAe,CAACK,UAAU,CAAC,CAAC;;EAE7F;EACA;EACA,MAAMC,WAAW,GAAGxB,OAAO,CAACyB,KAAK,CAACC,SAAS,KAAK,IAAI;EACpD,IAAIF,WAAW,EAAE;IACf,MAAMG,WAAW,GAAG,IAAAC,yBAAkB,EAAC3B,IAAI,CAAC;IAC5C,IAAAM,oBAAa,EACXP,OAAO,EACP,mBAAmB,EACnBQ,0BAAY,CAACS,SAAS,CAACY,iBAAiB,CAACF,WAAW,CACtD,CAAC;EACH;;EAEA;EACA,MAAM,IAAAG,WAAI,EAAC,IAAI,CAACC,MAAM,CAAC;EACvB,IAAAxB,oBAAa,EAACP,OAAO,EAAE,YAAY,EAAEQ,0BAAY,CAACS,SAAS,CAACe,UAAU,CAAC/B,IAAI,CAAC,CAAC;EAC7E,IAAAM,oBAAa,EAACP,OAAO,EAAE,MAAM,EAAEQ,0BAAY,CAACC,MAAM,CAACwB,IAAI,CAAC,CAAC,CAAC;AAC5D","ignoreList":[]}
@@ -56,7 +56,7 @@ export interface UserEventInstance {
56
56
  * input.
57
57
  *
58
58
  * The exact events sent depend on the props of the TextInput (`editable`,
59
- * `multiline`, value, defaultValue, etc) and passed options.
59
+ * `multiline`, etc) and passed options.
60
60
  *
61
61
  * @param element TextInput element to type on
62
62
  * @param text Text to type
@@ -1 +1 @@
1
- {"version":3,"file":"setup.js","names":["_timers","require","_wrapAsync","_clear","_paste","_press","_scroll","_type","_utils","universalJestAdvanceTimersBy","ms","jestFakeTimersAreEnabled","jest","advanceTimersByTime","Promise","resolve","defaultOptions","delay","advanceTimers","setup","options","config","createConfig","instance","createInstance","api","press","wrapAndBindImpl","longPress","type","clear","paste","scrollTo","Object","assign","impl","method","args","wrapAsync","apply","then","result","wait","defineProperty","get","name"],"sources":["../../../src/user-event/setup/setup.ts"],"sourcesContent":["import { ReactTestInstance } from 'react-test-renderer';\nimport { jestFakeTimersAreEnabled } from '../../helpers/timers';\nimport { wrapAsync } from '../../helpers/wrap-async';\nimport { clear } from '../clear';\nimport { paste } from '../paste';\nimport { PressOptions, press, longPress } from '../press';\nimport { ScrollToOptions, scrollTo } from '../scroll';\nimport { TypeOptions, type } from '../type';\nimport { wait } from '../utils';\n\nexport interface UserEventSetupOptions {\n /**\n * Between some subsequent inputs like typing a series of characters\n * the code execution is delayed per `setTimeout` for (at least) `delay` seconds.\n * This moves the next changes at least to next macro task\n * and allows other (asynchronous) code to run between events.\n *\n * `null` prevents `setTimeout` from being called.\n *\n * @default 0\n */\n delay?: number;\n\n /**\n * Function to be called to advance fake timers. Setting it is necessary for\n * fake timers to work.\n *\n * @example jest.advanceTimersByTime\n */\n advanceTimers?: (delay: number) => Promise<void> | void;\n}\n\n/**\n * This functions allow wait to work correctly under both real and fake Jest timers.\n */\nfunction universalJestAdvanceTimersBy(ms: number) {\n if (jestFakeTimersAreEnabled()) {\n return jest.advanceTimersByTime(ms);\n } else {\n return Promise.resolve();\n }\n}\n\nconst defaultOptions: Required<UserEventSetupOptions> = {\n delay: 0,\n advanceTimers: universalJestAdvanceTimersBy,\n};\n\n/**\n * Creates a new instance of user event instance with the given options.\n *\n * @param options\n * @returns UserEvent instance\n */\nexport function setup(options?: UserEventSetupOptions) {\n const config = createConfig(options);\n const instance = createInstance(config);\n return instance;\n}\n\n/**\n * Options affecting all user event interactions.\n *\n * @param delay between some subsequent inputs like typing a series of characters\n * @param advanceTimers function to be called to advance fake timers\n */\nexport interface UserEventConfig {\n delay: number;\n advanceTimers: (delay: number) => Promise<void> | void;\n}\n\nfunction createConfig(options?: UserEventSetupOptions): UserEventConfig {\n return {\n ...defaultOptions,\n ...options,\n };\n}\n\n/**\n * UserEvent instance used to invoke user interaction functions.\n */\nexport interface UserEventInstance {\n config: UserEventConfig;\n\n press: (element: ReactTestInstance) => Promise<void>;\n longPress: (element: ReactTestInstance, options?: PressOptions) => Promise<void>;\n\n /**\n * Simulate user pressing on a given `TextInput` element and typing given text.\n *\n * This method will trigger the events for each character of the text:\n * `keyPress`, `change`, `changeText`, `endEditing`, etc.\n *\n * It will also trigger events connected with entering and leaving the text\n * input.\n *\n * The exact events sent depend on the props of the TextInput (`editable`,\n * `multiline`, value, defaultValue, etc) and passed options.\n *\n * @param element TextInput element to type on\n * @param text Text to type\n * @param options Options affecting typing behavior:\n * - `skipPress` - if true, `pressIn` and `pressOut` events will not be\n * triggered.\n * - `submitEditing` - if true, `submitEditing` event will be triggered after\n * typing the text.\n */\n type: (element: ReactTestInstance, text: string, options?: TypeOptions) => Promise<void>;\n\n /**\n * Simulate user clearing the text of a given `TextInput` element.\n *\n * This method will simulate:\n * 1. entering TextInput\n * 2. selecting all text\n * 3. pressing backspace to delete all text\n * 4. leaving TextInput\n *\n * @param element TextInput element to clear\n */\n clear: (element: ReactTestInstance) => Promise<void>;\n\n /**\n * Simulate user pasting the text to a given `TextInput` element.\n *\n * This method will simulate:\n * 1. entering TextInput\n * 2. selecting all text\n * 3. paste the text\n * 4. leaving TextInput\n *\n * @param element TextInput element to paste to\n */\n paste: (element: ReactTestInstance, text: string) => Promise<void>;\n\n /**\n * Simlate user scorlling a ScrollView element.\n *\n * @param element ScrollView element\n * @returns\n */\n scrollTo: (element: ReactTestInstance, options: ScrollToOptions) => Promise<void>;\n}\n\nfunction createInstance(config: UserEventConfig): UserEventInstance {\n const instance = {\n config,\n } as UserEventInstance;\n\n // Bind interactions to given User Event instance.\n const api = {\n press: wrapAndBindImpl(instance, press),\n longPress: wrapAndBindImpl(instance, longPress),\n type: wrapAndBindImpl(instance, type),\n clear: wrapAndBindImpl(instance, clear),\n paste: wrapAndBindImpl(instance, paste),\n scrollTo: wrapAndBindImpl(instance, scrollTo),\n };\n\n Object.assign(instance, api);\n return instance;\n}\n\n/**\n * Wraps user interaction with `wrapAsync` (temporarily disable `act` environment while\n * calling & resolving the async callback, then flush the microtask queue)\n *\n * This implementation is sourced from `testing-library/user-event`\n * @see https://github.com/testing-library/user-event/blob/7a305dee9ab833d6f338d567fc2e862b4838b76a/src/setup/setup.ts#L121\n */\nfunction wrapAndBindImpl<\n Args extends any[],\n Impl extends (this: UserEventInstance, ...args: Args) => Promise<unknown>,\n>(instance: UserEventInstance, impl: Impl) {\n function method(...args: Args) {\n return wrapAsync(() =>\n // eslint-disable-next-line promise/prefer-await-to-then\n impl.apply(instance, args).then(async (result) => {\n await wait(instance.config);\n return result;\n }),\n );\n }\n\n // Copy implementation name to the returned function\n Object.defineProperty(method, 'name', { get: () => impl.name });\n\n return method as Impl;\n}\n"],"mappings":";;;;;;AACA,IAAAA,OAAA,GAAAC,OAAA;AACA,IAAAC,UAAA,GAAAD,OAAA;AACA,IAAAE,MAAA,GAAAF,OAAA;AACA,IAAAG,MAAA,GAAAH,OAAA;AACA,IAAAI,MAAA,GAAAJ,OAAA;AACA,IAAAK,OAAA,GAAAL,OAAA;AACA,IAAAM,KAAA,GAAAN,OAAA;AACA,IAAAO,MAAA,GAAAP,OAAA;AAwBA;AACA;AACA;AACA,SAASQ,4BAA4BA,CAACC,EAAU,EAAE;EAChD,IAAI,IAAAC,gCAAwB,EAAC,CAAC,EAAE;IAC9B,OAAOC,IAAI,CAACC,mBAAmB,CAACH,EAAE,CAAC;EACrC,CAAC,MAAM;IACL,OAAOI,OAAO,CAACC,OAAO,CAAC,CAAC;EAC1B;AACF;AAEA,MAAMC,cAA+C,GAAG;EACtDC,KAAK,EAAE,CAAC;EACRC,aAAa,EAAET;AACjB,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACO,SAASU,KAAKA,CAACC,OAA+B,EAAE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AEA;EACAR,MAAM,CAACU,cAAc,CAACP,MAAM,EAAE,MAAM,EAAE;IAAEQ,GAAG,EAAEA,CAAA,KAAMT,IAAI,CAACU;EAAK,CAAC,CAAC;EAE/D,OAAOT,MAAM;AACf","ignoreList":[]}
1
+ {"version":3,"file":"setup.js","names":["_timers","require","_wrapAsync","_clear","_paste","_press","_scroll","_type","_utils","universalJestAdvanceTimersBy","ms","jestFakeTimersAreEnabled","jest","advanceTimersByTime","Promise","resolve","defaultOptions","delay","advanceTimers","setup","options","config","createConfig","instance","createInstance","api","press","wrapAndBindImpl","longPress","type","clear","paste","scrollTo","Object","assign","impl","method","args","wrapAsync","apply","then","result","wait","defineProperty","get","name"],"sources":["../../../src/user-event/setup/setup.ts"],"sourcesContent":["import { ReactTestInstance } from 'react-test-renderer';\nimport { jestFakeTimersAreEnabled } from '../../helpers/timers';\nimport { wrapAsync } from '../../helpers/wrap-async';\nimport { clear } from '../clear';\nimport { paste } from '../paste';\nimport { PressOptions, press, longPress } from '../press';\nimport { ScrollToOptions, scrollTo } from '../scroll';\nimport { TypeOptions, type } from '../type';\nimport { wait } from '../utils';\n\nexport interface UserEventSetupOptions {\n /**\n * Between some subsequent inputs like typing a series of characters\n * the code execution is delayed per `setTimeout` for (at least) `delay` seconds.\n * This moves the next changes at least to next macro task\n * and allows other (asynchronous) code to run between events.\n *\n * `null` prevents `setTimeout` from being called.\n *\n * @default 0\n */\n delay?: number;\n\n /**\n * Function to be called to advance fake timers. Setting it is necessary for\n * fake timers to work.\n *\n * @example jest.advanceTimersByTime\n */\n advanceTimers?: (delay: number) => Promise<void> | void;\n}\n\n/**\n * This functions allow wait to work correctly under both real and fake Jest timers.\n */\nfunction universalJestAdvanceTimersBy(ms: number) {\n if (jestFakeTimersAreEnabled()) {\n return jest.advanceTimersByTime(ms);\n } else {\n return Promise.resolve();\n }\n}\n\nconst defaultOptions: Required<UserEventSetupOptions> = {\n delay: 0,\n advanceTimers: universalJestAdvanceTimersBy,\n};\n\n/**\n * Creates a new instance of user event instance with the given options.\n *\n * @param options\n * @returns UserEvent instance\n */\nexport function setup(options?: UserEventSetupOptions) {\n const config = createConfig(options);\n const instance = createInstance(config);\n return instance;\n}\n\n/**\n * Options affecting all user event interactions.\n *\n * @param delay between some subsequent inputs like typing a series of characters\n * @param advanceTimers function to be called to advance fake timers\n */\nexport interface UserEventConfig {\n delay: number;\n advanceTimers: (delay: number) => Promise<void> | void;\n}\n\nfunction createConfig(options?: UserEventSetupOptions): UserEventConfig {\n return {\n ...defaultOptions,\n ...options,\n };\n}\n\n/**\n * UserEvent instance used to invoke user interaction functions.\n */\nexport interface UserEventInstance {\n config: UserEventConfig;\n\n press: (element: ReactTestInstance) => Promise<void>;\n longPress: (element: ReactTestInstance, options?: PressOptions) => Promise<void>;\n\n /**\n * Simulate user pressing on a given `TextInput` element and typing given text.\n *\n * This method will trigger the events for each character of the text:\n * `keyPress`, `change`, `changeText`, `endEditing`, etc.\n *\n * It will also trigger events connected with entering and leaving the text\n * input.\n *\n * The exact events sent depend on the props of the TextInput (`editable`,\n * `multiline`, etc) and passed options.\n *\n * @param element TextInput element to type on\n * @param text Text to type\n * @param options Options affecting typing behavior:\n * - `skipPress` - if true, `pressIn` and `pressOut` events will not be\n * triggered.\n * - `submitEditing` - if true, `submitEditing` event will be triggered after\n * typing the text.\n */\n type: (element: ReactTestInstance, text: string, options?: TypeOptions) => Promise<void>;\n\n /**\n * Simulate user clearing the text of a given `TextInput` element.\n *\n * This method will simulate:\n * 1. entering TextInput\n * 2. selecting all text\n * 3. pressing backspace to delete all text\n * 4. leaving TextInput\n *\n * @param element TextInput element to clear\n */\n clear: (element: ReactTestInstance) => Promise<void>;\n\n /**\n * Simulate user pasting the text to a given `TextInput` element.\n *\n * This method will simulate:\n * 1. entering TextInput\n * 2. selecting all text\n * 3. paste the text\n * 4. leaving TextInput\n *\n * @param element TextInput element to paste to\n */\n paste: (element: ReactTestInstance, text: string) => Promise<void>;\n\n /**\n * Simlate user scorlling a ScrollView element.\n *\n * @param element ScrollView element\n * @returns\n */\n scrollTo: (element: ReactTestInstance, options: ScrollToOptions) => Promise<void>;\n}\n\nfunction createInstance(config: UserEventConfig): UserEventInstance {\n const instance = {\n config,\n } as UserEventInstance;\n\n // Bind interactions to given User Event instance.\n const api = {\n press: wrapAndBindImpl(instance, press),\n longPress: wrapAndBindImpl(instance, longPress),\n type: wrapAndBindImpl(instance, type),\n clear: wrapAndBindImpl(instance, clear),\n paste: wrapAndBindImpl(instance, paste),\n scrollTo: wrapAndBindImpl(instance, scrollTo),\n };\n\n Object.assign(instance, api);\n return instance;\n}\n\n/**\n * Wraps user interaction with `wrapAsync` (temporarily disable `act` environment while\n * calling & resolving the async callback, then flush the microtask queue)\n *\n * This implementation is sourced from `testing-library/user-event`\n * @see https://github.com/testing-library/user-event/blob/7a305dee9ab833d6f338d567fc2e862b4838b76a/src/setup/setup.ts#L121\n */\nfunction wrapAndBindImpl<\n Args extends any[],\n Impl extends (this: UserEventInstance, ...args: Args) => Promise<unknown>,\n>(instance: UserEventInstance, impl: Impl) {\n function method(...args: Args) {\n return wrapAsync(() =>\n // eslint-disable-next-line promise/prefer-await-to-then\n impl.apply(instance, args).then(async (result) => {\n await wait(instance.config);\n return result;\n }),\n );\n }\n\n // Copy implementation name to the returned function\n Object.defineProperty(method, 'name', { get: () => impl.name });\n\n return method as Impl;\n}\n"],"mappings":";;;;;;AACA,IAAAA,OAAA,GAAAC,OAAA;AACA,IAAAC,UAAA,GAAAD,OAAA;AACA,IAAAE,MAAA,GAAAF,OAAA;AACA,IAAAG,MAAA,GAAAH,OAAA;AACA,IAAAI,MAAA,GAAAJ,OAAA;AACA,IAAAK,OAAA,GAAAL,OAAA;AACA,IAAAM,KAAA,GAAAN,OAAA;AACA,IAAAO,MAAA,GAAAP,OAAA;AAwBA;AACA;AACA;AACA,SAASQ,4BAA4BA,CAACC,EAAU,EAAE;EAChD,IAAI,IAAAC,gCAAwB,EAAC,CAAC,EAAE;IAC9B,OAAOC,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AGC,IAAU,EAAE;IAC7B,OAAO,IAAAC,oBAAS,EAAC;IACf;IACAH,IAAI,CAACI,KAAK,CAAChB,QAAQ,EAAEc,IAAI,CAAC,CAACG,IAAI,CAAC,MAAOC,MAAM,IAAK;MAChD,MAAM,IAAAC,WAAI,EAACnB,QAAQ,CAACF,MAAM,CAAC;MAC3B,OAAOoB,MAAM;IACf,CAAC,CACH,CAAC;EACH;;EAEA;EACAR,MAAM,CAACU,cAAc,CAACP,MAAM,EAAE,MAAM,EAAE;IAAEQ,GAAG,EAAEA,CAAA,KAAMT,IAAI,CAACU;EAAK,CAAC,CAAC;EAE/D,OAAOT,MAAM;AACf","ignoreList":[]}
@@ -31,9 +31,9 @@ async function type(element, text, options) {
31
31
  await (0, _utils.wait)(this.config);
32
32
  (0, _utils.dispatchEvent)(element, 'pressOut', _eventBuilder.EventBuilder.Common.touch());
33
33
  }
34
- let currentText = element.props.value ?? element.props.defaultValue ?? '';
34
+ let currentText = (0, _textInput.getTextInputValue)(element);
35
35
  for (const key of keys) {
36
- const previousText = element.props.value ?? currentText;
36
+ const previousText = (0, _textInput.getTextInputValue)(element);
37
37
  const proposedText = applyKey(previousText, key);
38
38
  const isAccepted = isTextChangeAccepted(element, proposedText);
39
39
  currentText = isAccepted ? proposedText : previousText;
@@ -44,7 +44,7 @@ async function type(element, text, options) {
44
44
  isAccepted
45
45
  });
46
46
  }
47
- const finalText = element.props.value ?? currentText;
47
+ const finalText = (0, _textInput.getTextInputValue)(element);
48
48
  await (0, _utils.wait)(this.config);
49
49
  if (options?.submitEditing) {
50
50
  (0, _utils.dispatchEvent)(element, 'submitEditing', _eventBuilder.EventBuilder.TextInput.submitEditing(finalText));
@@ -1 +1 @@
1
- {"version":3,"file":"type.js","names":["_hostComponentNames","require","_nativeState","_eventBuilder","_errors","_textInput","_pointerEvents","_utils","_parseKeys","type","element","text","options","isHostTextInput","ErrorWithStack","isTextInputEditable","isPointerEventEnabled","keys","parseKeys","skipPress","dispatchEvent","EventBuilder","Common","touch","focus","wait","config","currentText","props","value","defaultValue","key","previousText","proposedText","applyKey","isAccepted","isTextChangeAccepted","emitTypingEvents","finalText","submitEditing","TextInput","endEditing","blur","isMultiline","multiline","keyPress","nativeState","valueForElement","set","change","selectionRange","start","length","end","selectionChange","contentSize","getTextContentSize","contentSizeChange","slice","maxLength","undefined"],"sources":["../../../src/user-event/type/type.ts"],"sourcesContent":["import { ReactTestInstance } from 'react-test-renderer';\nimport { isHostTextInput } from '../../helpers/host-component-names';\nimport { nativeState } from '../../native-state';\nimport { EventBuilder } from '../event-builder';\nimport { ErrorWithStack } from '../../helpers/errors';\nimport { isTextInputEditable } from '../../helpers/text-input';\nimport { isPointerEventEnabled } from '../../helpers/pointer-events';\nimport { UserEventConfig, UserEventInstance } from '../setup';\nimport { dispatchEvent, wait, getTextContentSize } from '../utils';\nimport { parseKeys } from './parse-keys';\n\nexport interface TypeOptions {\n skipPress?: boolean;\n submitEditing?: boolean;\n}\n\nexport async function type(\n this: UserEventInstance,\n element: ReactTestInstance,\n text: string,\n options?: TypeOptions,\n): Promise<void> {\n if (!isHostTextInput(element)) {\n throw new ErrorWithStack(\n `type() works only with host \"TextInput\" elements. Passed element has type \"${element.type}\".`,\n type,\n );\n }\n\n // Skip events if the element is disabled\n if (!isTextInputEditable(element) || !isPointerEventEnabled(element)) {\n return;\n }\n\n const keys = parseKeys(text);\n\n if (!options?.skipPress) {\n dispatchEvent(element, 'pressIn', EventBuilder.Common.touch());\n }\n\n dispatchEvent(element, 'focus', EventBuilder.Common.focus());\n\n if (!options?.skipPress) {\n await wait(this.config);\n dispatchEvent(element, 'pressOut', EventBuilder.Common.touch());\n }\n\n let currentText = element.props.value ?? element.props.defaultValue ?? '';\n for (const key of keys) {\n const previousText = element.props.value ?? currentText;\n const proposedText = applyKey(previousText, key);\n const isAccepted = isTextChangeAccepted(element, proposedText);\n currentText = isAccepted ? proposedText : previousText;\n\n await emitTypingEvents(element, {\n config: this.config,\n key,\n text: currentText,\n isAccepted,\n });\n }\n\n const finalText = element.props.value ?? currentText;\n await wait(this.config);\n\n if (options?.submitEditing) {\n dispatchEvent(element, 'submitEditing', EventBuilder.TextInput.submitEditing(finalText));\n }\n\n dispatchEvent(element, 'endEditing', EventBuilder.TextInput.endEditing(finalText));\n\n dispatchEvent(element, 'blur', EventBuilder.Common.blur());\n}\n\ntype EmitTypingEventsContext = {\n config: UserEventConfig;\n key: string;\n text: string;\n isAccepted?: boolean;\n};\n\nexport async function emitTypingEvents(\n element: ReactTestInstance,\n { config, key, text, isAccepted }: EmitTypingEventsContext,\n) {\n const isMultiline = element.props.multiline === true;\n\n await wait(config);\n dispatchEvent(element, 'keyPress', EventBuilder.TextInput.keyPress(key));\n\n // Platform difference (based on experiments):\n // - iOS and RN Web: TextInput emits only `keyPress` event when max length has been reached\n // - Android: TextInputs does not emit any events\n if (isAccepted === false) {\n return;\n }\n\n nativeState.valueForElement.set(element, text);\n dispatchEvent(element, 'change', EventBuilder.TextInput.change(text));\n dispatchEvent(element, 'changeText', text);\n\n const selectionRange = {\n start: text.length,\n end: text.length,\n };\n dispatchEvent(element, 'selectionChange', EventBuilder.TextInput.selectionChange(selectionRange));\n\n // According to the docs only multiline TextInput emits contentSizeChange event\n // @see: https://reactnative.dev/docs/textinput#oncontentsizechange\n if (isMultiline) {\n const contentSize = getTextContentSize(text);\n dispatchEvent(\n element,\n 'contentSizeChange',\n EventBuilder.TextInput.contentSizeChange(contentSize),\n );\n }\n}\n\nfunction applyKey(text: string, key: string) {\n if (key === 'Enter') {\n return `${text}\\n`;\n }\n\n if (key === 'Backspace') {\n return text.slice(0, -1);\n }\n\n return text + key;\n}\n\nfunction isTextChangeAccepted(element: ReactTestInstance, text: string) {\n const maxLength = element.props.maxLength;\n return maxLength === undefined || text.length <= maxLength;\n}\n"],"mappings":";;;;;;;AACA,IAAAA,mBAAA,GAAAC,OAAA;AACA,IAAAC,YAAA,GAAAD,OAAA;AACA,IAAAE,aAAA,GAAAF,OAAA;AACA,IAA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.js","names":["_hostComponentNames","require","_nativeState","_eventBuilder","_errors","_textInput","_pointerEvents","_utils","_parseKeys","type","element","text","options","isHostTextInput","ErrorWithStack","isTextInputEditable","isPointerEventEnabled","keys","parseKeys","skipPress","dispatchEvent","EventBuilder","Common","touch","focus","wait","config","currentText","getTextInputValue","key","previousText","proposedText","applyKey","isAccepted","isTextChangeAccepted","emitTypingEvents","finalText","submitEditing","TextInput","endEditing","blur","isMultiline","props","multiline","keyPress","nativeState","valueForElement","set","change","selectionRange","start","length","end","selectionChange","contentSize","getTextContentSize","contentSizeChange","slice","maxLength","undefined"],"sources":["../../../src/user-event/type/type.ts"],"sourcesContent":["import { ReactTestInstance } from 'react-test-renderer';\nimport { isHostTextInput } from '../../helpers/host-component-names';\nimport { nativeState } from '../../native-state';\nimport { EventBuilder } from '../event-builder';\nimport { ErrorWithStack } from '../../helpers/errors';\nimport { getTextInputValue, isTextInputEditable } from '../../helpers/text-input';\nimport { isPointerEventEnabled } from '../../helpers/pointer-events';\nimport { UserEventConfig, UserEventInstance } from '../setup';\nimport { dispatchEvent, wait, getTextContentSize } from '../utils';\nimport { parseKeys } from './parse-keys';\n\nexport interface TypeOptions {\n skipPress?: boolean;\n submitEditing?: boolean;\n}\n\nexport async function type(\n this: UserEventInstance,\n element: ReactTestInstance,\n text: string,\n options?: TypeOptions,\n): Promise<void> {\n if (!isHostTextInput(element)) {\n throw new ErrorWithStack(\n `type() works only with host \"TextInput\" elements. Passed element has type \"${element.type}\".`,\n type,\n );\n }\n\n // Skip events if the element is disabled\n if (!isTextInputEditable(element) || !isPointerEventEnabled(element)) {\n return;\n }\n\n const keys = parseKeys(text);\n\n if (!options?.skipPress) {\n dispatchEvent(element, 'pressIn', EventBuilder.Common.touch());\n }\n\n dispatchEvent(element, 'focus', EventBuilder.Common.focus());\n\n if (!options?.skipPress) {\n await wait(this.config);\n dispatchEvent(element, 'pressOut', EventBuilder.Common.touch());\n }\n\n let currentText = getTextInputValue(element);\n for (const key of keys) {\n const previousText = getTextInputValue(element);\n const proposedText = applyKey(previousText, key);\n const isAccepted = isTextChangeAccepted(element, proposedText);\n currentText = isAccepted ? proposedText : previousText;\n\n await emitTypingEvents(element, {\n config: this.config,\n key,\n text: currentText,\n isAccepted,\n });\n }\n\n const finalText = getTextInputValue(element);\n await wait(this.config);\n\n if (options?.submitEditing) {\n dispatchEvent(element, 'submitEditing', EventBuilder.TextInput.submitEditing(finalText));\n }\n\n dispatchEvent(element, 'endEditing', EventBuilder.TextInput.endEditing(finalText));\n\n dispatchEvent(element, 'blur', EventBuilder.Common.blur());\n}\n\ntype EmitTypingEventsContext = {\n config: UserEventConfig;\n key: string;\n text: string;\n isAccepted?: boolean;\n};\n\nexport async function emitTypingEvents(\n element: ReactTestInstance,\n { config, key, text, isAccepted }: EmitTypingEventsContext,\n) {\n const isMultiline = element.props.multiline === true;\n\n await wait(config);\n dispatchEvent(element, 'keyPress', EventBuilder.TextInput.keyPress(key));\n\n // Platform difference (based on experiments):\n // - iOS and RN Web: TextInput emits only `keyPress` event when max length has been reached\n // - Android: TextInputs does not emit any events\n if (isAccepted === false) {\n return;\n }\n\n nativeState.valueForElement.set(element, text);\n dispatchEvent(element, 'change', EventBuilder.TextInput.change(text));\n dispatchEvent(element, 'changeText', text);\n\n const selectionRange = {\n start: text.length,\n end: text.length,\n };\n dispatchEvent(element, 'selectionChange', EventBuilder.TextInput.selectionChange(selectionRange));\n\n // According to the docs only multiline TextInput emits contentSizeChange event\n // @see: https://reactnative.dev/docs/textinput#oncontentsizechange\n if (isMultiline) {\n const contentSize = getTextContentSize(text);\n dispatchEvent(\n element,\n 'contentSizeChange',\n EventBuilder.TextInput.contentSizeChange(contentSize),\n );\n }\n}\n\nfunction applyKey(text: string, key: string) {\n if (key === 'Enter') {\n return `${text}\\n`;\n }\n\n if (key === 'Backspace') {\n return text.slice(0, -1);\n }\n\n return text + key;\n}\n\nfunction isTextChangeAccepted(element: ReactTestInstance, text: string) {\n const maxLength = element.props.maxLength;\n return max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IhD,IAAI,CAACwC,MAAM,IAAIO,SAAS;AAC5D","ignoreList":[]}
package/build/within.d.ts CHANGED
@@ -12,10 +12,10 @@ export declare function within(instance: ReactTestInstance): {
12
12
  UNSAFE_queryAllByProps: (props: {
13
13
  [key: string]: any;
14
14
  }) => Array<ReactTestInstance>;
15
- UNSAFE_getByType: <P>(type: import("react").ComponentType<P>) => ReactTestInstance;
16
- UNSAFE_getAllByType: <P>(type: import("react").ComponentType<P>) => Array<ReactTestInstance>;
17
- UNSAFE_queryByType: <P>(type: import("react").ComponentType<P>) => ReactTestInstance | null;
18
- UNSAFE_queryAllByType: <P>(type: import("react").ComponentType<P>) => Array<ReactTestInstance>;
15
+ UNSAFE_getByType: <P>(type: React.ComponentType<P>) => ReactTestInstance;
16
+ UNSAFE_getAllByType: <P>(type: React.ComponentType<P>) => Array<ReactTestInstance>;
17
+ UNSAFE_queryByType: <P>(type: React.ComponentType<P>) => ReactTestInstance | null;
18
+ UNSAFE_queryAllByType: <P>(type: React.ComponentType<P>) => Array<ReactTestInstance>;
19
19
  getByA11yValue: import("./queries/make-queries").GetByQuery<import("./helpers/matchers/match-accessibility-value").AccessibilityValueMatcher, import("./queries/options").CommonQueryOptions>;
20
20
  getAllByA11yValue: import("./queries/make-queries").GetAllByQuery<import("./helpers/matchers/match-accessibility-value").AccessibilityValueMatcher, import("./queries/options").CommonQueryOptions>;
21
21
  queryByA11yValue: import("./queries/make-queries").QueryByQuery<import("./helpers/matchers/match-accessibility-value").AccessibilityValueMatcher, import("./queries/options").CommonQueryOptions>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@testing-library/react-native",
3
- "version": "12.7.1",
3
+ "version": "12.8.0",
4
4
  "description": "Simple and complete React Native testing utilities that encourage good testing practices.",
5
5
  "main": "build/index.js",
6
6
  "types": "build/index.d.ts",
@@ -25,7 +25,8 @@
25
25
  "scripts": {
26
26
  "clean": "del build",
27
27
  "test": "jest",
28
- "test:ci": "jest --maxWorkers=2 --collectCoverage=true --coverage-provider=v8",
28
+ "test:ci": "jest --maxWorkers=2",
29
+ "test:ci:coverage": "jest --maxWorkers=2 --collectCoverage=true --coverage-provider=v8",
29
30
  "typecheck": "tsc",
30
31
  "copy-flowtypes": "cp typings/index.flow.js build",
31
32
  "lint": "eslint src --cache",
@@ -33,7 +34,7 @@
33
34
  "build:js": "babel src --out-dir build --extensions \".js,.ts,.jsx,.tsx\" --source-maps --ignore \"**/__tests__/**\"",
34
35
  "build:ts": "tsc --build tsconfig.release.json",
35
36
  "build": "yarn clean && yarn build:js && yarn build:ts && yarn copy-flowtypes",
36
- "publish": "yarn build && release-it"
37
+ "release": "release-it"
37
38
  },
38
39
  "files": [
39
40
  "build/",
@@ -62,31 +63,31 @@
62
63
  }
63
64
  },
64
65
  "devDependencies": {
65
- "@babel/cli": "^7.24.8",
66
- "@babel/core": "^7.25.2",
67
- "@babel/plugin-transform-flow-strip-types": "^7.25.2",
68
- "@babel/preset-env": "^7.25.3",
69
- "@babel/preset-flow": "^7.24.7",
70
- "@babel/preset-react": "^7.24.7",
71
- "@babel/preset-typescript": "^7.24.7",
66
+ "@babel/cli": "^7.25.9",
67
+ "@babel/core": "^7.25.9",
68
+ "@babel/plugin-transform-flow-strip-types": "^7.25.9",
69
+ "@babel/preset-env": "^7.25.9",
70
+ "@babel/preset-flow": "^7.25.9",
71
+ "@babel/preset-react": "^7.25.9",
72
+ "@babel/preset-typescript": "^7.25.9",
72
73
  "@callstack/eslint-config": "^15.0.0",
73
- "@release-it/conventional-changelog": "^8.0.1",
74
+ "@release-it/conventional-changelog": "^9.0.1",
74
75
  "@relmify/jest-serializer-strip-ansi": "^1.0.2",
75
- "@types/jest": "^29.5.12",
76
- "@types/react": "^18.3.3",
76
+ "@types/jest": "^29.5.14",
77
+ "@types/react": "^18.3.12",
77
78
  "@types/react-test-renderer": "^18.3.0",
78
79
  "babel-jest": "^29.7.0",
79
- "del-cli": "^5.1.0",
80
- "eslint": "^8.57.0",
80
+ "del-cli": "^6.0.0",
81
+ "eslint": "^8.57.1",
81
82
  "eslint-plugin-flowtype": "^8.0.3",
82
83
  "eslint-plugin-prettier": "^4.2.1",
83
84
  "flow-bin": "~0.170.0",
84
85
  "jest": "^29.7.0",
85
86
  "prettier": "^2.8.8",
86
87
  "react": "18.3.1",
87
- "react-native": "0.75.1",
88
+ "react-native": "0.76.0",
88
89
  "react-test-renderer": "18.3.1",
89
- "release-it": "^17.6.0",
90
+ "release-it": "^17.10.0",
90
91
  "strip-ansi": "^6.0.1",
91
92
  "typescript": "^5.5.4"
92
93
  },