Skip to content

Commit 14b9049

Browse files
committed
update deps
1 parent 703ad44 commit 14b9049

10 files changed

Lines changed: 39 additions & 52 deletions

File tree

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@
9797
"react-native": "0.85.0",
9898
"react-native-gesture-handler": "^2.31.1",
9999
"release-it": "^19.2.4",
100-
"test-renderer": "0.14.0",
100+
"test-renderer": "0.15.0",
101101
"typescript": "^6.0.2",
102102
"typescript-eslint": "^8.58.1"
103103
},

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: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3018,7 +3018,7 @@ __metadata:
30183018
react-native-gesture-handler: "npm:^2.31.1"
30193019
redent: "npm:^3.0.0"
30203020
release-it: "npm:^19.2.4"
3021-
test-renderer: "npm:0.14.0"
3021+
test-renderer: "npm:0.15.0"
30223022
typescript: "npm:^6.0.2"
30233023
typescript-eslint: "npm:^8.58.1"
30243024
peerDependencies:
@@ -4101,7 +4101,7 @@ __metadata:
41014101
languageName: node
41024102
linkType: hard
41034103

4104-
"brace-expansion@npm:^2.0.1, brace-expansion@npm:^2.0.2":
4104+
"brace-expansion@npm:^2.0.1":
41054105
version: 2.0.3
41064106
resolution: "brace-expansion@npm:2.0.3"
41074107
dependencies:
@@ -8250,11 +8250,11 @@ __metadata:
82508250
linkType: hard
82518251

82528252
"minimatch@npm:^9.0.4":
8253-
version: 9.0.9
8254-
resolution: "minimatch@npm:9.0.9"
8253+
version: 9.0.5
8254+
resolution: "minimatch@npm:9.0.5"
82558255
dependencies:
8256-
brace-expansion: "npm:^2.0.2"
8257-
checksum: 10c0/0b6a58530dbb00361745aa6c8cffaba4c90f551afe7c734830bd95fd88ebf469dd7355a027824ea1d09e37181cfeb0a797fb17df60c15ac174303ac110eb7e86
8256+
brace-expansion: "npm:^2.0.1"
8257+
checksum: 10c0/de96cf5e35bdf0eab3e2c853522f98ffbe9a36c37797778d2665231ec1f20a9447a7e567cb640901f89e4daaa95ae5d70c65a9e8aa2bb0019b6facbc3c0575ed
82588258
languageName: node
82598259
linkType: hard
82608260

@@ -10343,15 +10343,15 @@ __metadata:
1034310343
languageName: node
1034410344
linkType: hard
1034510345

10346-
"test-renderer@npm:0.14.0":
10347-
version: 0.14.0
10348-
resolution: "test-renderer@npm:0.14.0"
10346+
"test-renderer@npm:0.15.0":
10347+
version: 0.15.0
10348+
resolution: "test-renderer@npm:0.15.0"
1034910349
dependencies:
1035010350
"@types/react-reconciler": "npm:~0.31.0"
1035110351
react-reconciler: "npm:~0.31.0"
1035210352
peerDependencies:
1035310353
react: ^19.0.0
10354-
checksum: 10c0/d259f5d146f57bb6689cb828de73cd95a559bc3203f1a21824b027a6b43143447bbf60eed5d2f8ea18b806ee15002aa6ba1d023e01669fa9945ca8278391667d
10354+
checksum: 10c0/80a81a042dfe803afffbb391bf6ca802e534e235e6361dc121ad848a8acd3ab97c857f04da4f77ad884df01e5f005f197100dbac5906ad901dac29a3c27f24b4
1035510355
languageName: node
1035610356
linkType: hard
1035710357

0 commit comments

Comments
 (0)