Skip to content

Commit 4d78825

Browse files
committed
update deps
1 parent 3e8bc07 commit 4d78825

10 files changed

Lines changed: 34 additions & 47 deletions

File tree

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@
9292
"react-native": "0.84.0",
9393
"react-native-gesture-handler": "^2.30.0",
9494
"release-it": "^19.0.6",
95-
"test-renderer": "0.14.0",
95+
"test-renderer": "0.15.0",
9696
"typescript": "^5.9.3",
9797
"typescript-eslint": "^8.47.0"
9898
},

src/__tests__/render.test.tsx

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ test('does not warn when only valid options are passed', async () => {
3737
const TestComponent = () => <Text testID="test">Test</Text>;
3838
const Wrapper = ({ children }: { children: React.ReactNode }) => <View>{children}</View>;
3939

40-
await render(<TestComponent />, { wrapper: Wrapper, createNodeMock: jest.fn() });
40+
await render(<TestComponent />, { wrapper: Wrapper });
4141

4242
expect(_console.warn).not.toHaveBeenCalled();
4343
});
@@ -66,16 +66,6 @@ describe('render options', () => {
6666
expect(screen.getByTestId('inner')).toBeOnTheScreen();
6767
expect(screen.getByText('Inner Content')).toBeOnTheScreen();
6868
});
69-
70-
test('createNodeMock option is passed to renderer', async () => {
71-
const TestComponent = () => <View testID="test" />;
72-
const mockNode = { testProperty: 'testValue' };
73-
const createNodeMock = jest.fn(() => mockNode);
74-
75-
await render(<TestComponent />, { createNodeMock });
76-
77-
expect(screen.getByTestId('test')).toBeOnTheScreen();
78-
});
7969
});
8070

8171
describe('component rendering', () => {

src/helpers/__tests__/component-tree.test.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import React from 'react';
22
import { View } from 'react-native';
33

44
import { render, screen } from '../..';
5-
import { getContainerElement, getHostSiblings } from '../component-tree';
5+
import { getContainerElement, getInstanceSiblings } from '../component-tree';
66

77
function MultipleHostChildren() {
88
return (
@@ -27,7 +27,7 @@ describe('getHostSiblings()', () => {
2727
</View>,
2828
);
2929

30-
const hostSiblings = getHostSiblings(screen.getByTestId('subject'));
30+
const hostSiblings = getInstanceSiblings(screen.getByTestId('subject'));
3131
expect(hostSiblings).toEqual([
3232
screen.getByTestId('siblingBefore'),
3333
screen.getByTestId('siblingAfter'),

src/helpers/accessibility.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import type { AccessibilityRole, AccessibilityState, AccessibilityValue, Role }
22
import { StyleSheet } from 'react-native';
33
import type { HostElement } from 'test-renderer';
44

5-
import { getContainerElement, getHostSiblings, isHostElement } from './component-tree';
5+
import { getContainerElement, getInstanceSiblings, isTestInstance } from './component-tree';
66
import { findAll } from './find-all';
77
import { isHostImage, isHostSwitch, isHostText, isHostTextInput } from './host-component-names';
88
import { getTextContent } from './text-content';
@@ -76,7 +76,7 @@ function isSubtreeInaccessible(element: HostElement): boolean {
7676

7777
// iOS: accessibilityViewIsModal or aria-modal
7878
// See: https://reactnative.dev/docs/accessibility#accessibilityviewismodal-ios
79-
const hostSiblings = getHostSiblings(element);
79+
const hostSiblings = getInstanceSiblings(element);
8080
if (hostSiblings.some((sibling) => computeAriaModal(sibling))) {
8181
return true;
8282
}
@@ -155,7 +155,7 @@ export function computeAriaLabel(element: HostElement): string | undefined {
155155
const container = getContainerElement(element);
156156
const labelElement = findAll(
157157
container,
158-
(node) => isHostElement(node) && node.props.nativeID === labelElementId,
158+
(node) => isTestInstance(node) && node.props.nativeID === labelElementId,
159159
{ includeHiddenElements: true },
160160
);
161161
if (labelElement.length > 0) {

src/helpers/component-tree.ts

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,43 @@
1-
import type { HostElement, HostNode } from 'test-renderer';
1+
import type { TestInstance, TestNode } from 'test-renderer';
22

33
import { screen } from '../screen';
44

55
/**
66
* Checks if the given element is a host element.
7-
* @param element The element to check.
7+
* @param node The element to check.
88
*/
9-
export function isHostElement(element?: HostNode | null): element is HostElement {
10-
return typeof element !== 'string' && typeof element?.type === 'string';
9+
export function isTestInstance(node?: TestNode | null): node is TestInstance {
10+
return typeof node !== 'string' && typeof node?.type === 'string';
1111
}
1212

13-
export function isElementMounted(element: HostElement) {
13+
export function isElementMounted(element: TestInstance) {
1414
return getContainerElement(element) === screen.container;
1515
}
1616

1717
/**
1818
* Returns host siblings for given element.
19-
* @param element The element start traversing from.
19+
* @param instance The element start traversing from.
2020
*/
21-
export function getHostSiblings(element: HostElement): HostElement[] {
21+
export function getInstanceSiblings(instance: TestInstance): TestInstance[] {
2222
// Should not happen
23-
const parent = element.parent;
23+
const parent = instance.parent;
2424
if (!parent) {
2525
return [];
2626
}
2727

2828
return parent.children.filter(
29-
(sibling) => typeof sibling !== 'string' && sibling !== element,
30-
) as HostElement[];
29+
(sibling) => typeof sibling !== 'string' && sibling !== instance,
30+
) as TestInstance[];
3131
}
3232

3333
/**
34-
* Returns the containerelement of the tree.
34+
* Returns the container element of the tree.
3535
*
36-
* @param element The element start traversing from.
36+
* @param instance The element start traversing from.
3737
* @returns The container element of the tree.
3838
*/
39-
export function getContainerElement(element: HostElement) {
40-
let current = element;
39+
export function getContainerElement(instance: TestInstance) {
40+
let current = instance;
4141
while (current.parent) {
4242
current = current.parent;
4343
}

src/matchers/to-be-empty-element.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@ import { matcherHint, RECEIVED_COLOR } from 'jest-matcher-utils';
22
import redent from 'redent';
33
import type { HostElement } from 'test-renderer';
44

5-
import { isHostElement } from '../helpers/component-tree';
5+
import { isTestInstance } from '../helpers/component-tree';
66
import { formatElementList } from '../helpers/format-element';
77
import { checkHostElement } from './utils';
88

99
export function toBeEmptyElement(this: jest.MatcherContext, element: HostElement) {
1010
checkHostElement(element, toBeEmptyElement, this);
1111

1212
// TODO check
13-
const children = element.children.filter((child) => isHostElement(child));
13+
const children = element.children.filter((child) => isTestInstance(child));
1414

1515
return {
1616
pass: children.length === 0,

src/matchers/utils.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import {
99
import redent from 'redent';
1010
import type { HostElement } from 'test-renderer';
1111

12-
import { isHostElement } from '../helpers/component-tree';
12+
import { isTestInstance } from '../helpers/component-tree';
1313

1414
class HostElementTypeError extends Error {
1515
constructor(received: unknown, matcherFn: jest.CustomMatcher, context: jest.MatcherContext) {
@@ -49,7 +49,7 @@ export function checkHostElement(
4949
matcherFn: jest.CustomMatcher,
5050
context: jest.MatcherContext,
5151
): asserts element is HostElement {
52-
if (!isHostElement(element)) {
52+
if (!isTestInstance(element)) {
5353
throw new HostElementTypeError(element, matcherFn, context);
5454
}
5555
}

src/render.tsx

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,6 @@ export interface RenderOptions {
2424
*/
2525
// eslint-disable-next-line @typescript-eslint/no-explicit-any
2626
wrapper?: React.ComponentType<any>;
27-
28-
createNodeMock?: (element: React.ReactElement) => object;
2927
}
3028

3129
export type RenderResult = Awaited<ReturnType<typeof render>>;
@@ -35,13 +33,12 @@ export type RenderResult = Awaited<ReturnType<typeof render>>;
3533
* to assert on the output.
3634
*/
3735
export async function render<T>(element: React.ReactElement<T>, options: RenderOptions = {}) {
38-
const { wrapper: Wrapper, createNodeMock, ...rest } = options || {};
36+
const { wrapper: Wrapper, ...rest } = options || {};
3937
validateOptions('render', rest, render);
4038

4139
const rendererOptions: RootOptions = {
4240
textComponentTypes: HOST_TEXT_NAMES,
4341
publicTextComponentTypes: ['Text'],
44-
createNodeMock,
4542
};
4643

4744
const wrap = (element: React.ReactElement) => (Wrapper ? <Wrapper>{element}</Wrapper> : element);

src/user-event/press/press.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import {
77
buildTouchEvent,
88
} from '../../event-builder';
99
import { getEventHandlerFromProps } from '../../event-handler';
10-
import { isHostElement } from '../../helpers/component-tree';
10+
import { isTestInstance } from '../../helpers/component-tree';
1111
import { ErrorWithStack } from '../../helpers/errors';
1212
import { isHostText, isHostTextInput } from '../../helpers/host-component-names';
1313
import { isPointerEventEnabled } from '../../helpers/pointer-events';
@@ -24,7 +24,7 @@ export interface PressOptions {
2424
}
2525

2626
export async function press(this: UserEventInstance, element: HostElement): Promise<void> {
27-
if (!isHostElement(element)) {
27+
if (!isTestInstance(element)) {
2828
throw new ErrorWithStack(`press() works only with host elements.`, press);
2929
}
3030

@@ -38,7 +38,7 @@ export async function longPress(
3838
element: HostElement,
3939
options?: PressOptions,
4040
): Promise<void> {
41-
if (!isHostElement(element)) {
41+
if (!isTestInstance(element)) {
4242
throw new ErrorWithStack(`longPress() works only with host elements.`, longPress);
4343
}
4444

yarn.lock

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3011,7 +3011,7 @@ __metadata:
30113011
react-native-gesture-handler: "npm:^2.30.0"
30123012
redent: "npm:^3.0.0"
30133013
release-it: "npm:^19.0.6"
3014-
test-renderer: "npm:0.14.0"
3014+
test-renderer: "npm:0.15.0"
30153015
typescript: "npm:^5.9.3"
30163016
typescript-eslint: "npm:^8.47.0"
30173017
peerDependencies:
@@ -10416,15 +10416,15 @@ __metadata:
1041610416
languageName: node
1041710417
linkType: hard
1041810418

10419-
"test-renderer@npm:0.14.0":
10420-
version: 0.14.0
10421-
resolution: "test-renderer@npm:0.14.0"
10419+
"test-renderer@npm:0.15.0":
10420+
version: 0.15.0
10421+
resolution: "test-renderer@npm:0.15.0"
1042210422
dependencies:
1042310423
"@types/react-reconciler": "npm:~0.31.0"
1042410424
react-reconciler: "npm:~0.31.0"
1042510425
peerDependencies:
1042610426
react: ^19.0.0
10427-
checksum: 10c0/d259f5d146f57bb6689cb828de73cd95a559bc3203f1a21824b027a6b43143447bbf60eed5d2f8ea18b806ee15002aa6ba1d023e01669fa9945ca8278391667d
10427+
checksum: 10c0/80a81a042dfe803afffbb391bf6ca802e534e235e6361dc121ad848a8acd3ab97c857f04da4f77ad884df01e5f005f197100dbac5906ad901dac29a3c27f24b4
1042810428
languageName: node
1042910429
linkType: hard
1043010430

0 commit comments

Comments
 (0)