From 6362b3c5377a6181c576e72a8635d00351a643e7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rub=C3=A9n=20Norte?= Date: Mon, 6 Jan 2025 09:25:38 -0800 Subject: [PATCH] Add a few more tests to ReactNativeElement (#48428) Summary: Changelog: [internal] Adding a few more tests for `ReactNativeElement` for symmetry with future tests for when it implements `EventTarget`. Reviewed By: javache Differential Revision: D67738147 --- .../__tests__/ReactNativeElement-itest.js | 56 ++++++++++++++++++- 1 file changed, 55 insertions(+), 1 deletion(-) diff --git a/packages/react-native/src/private/webapis/dom/nodes/__tests__/ReactNativeElement-itest.js b/packages/react-native/src/private/webapis/dom/nodes/__tests__/ReactNativeElement-itest.js index 8eaf2559a3373e..4e2b2f53a401e1 100644 --- a/packages/react-native/src/private/webapis/dom/nodes/__tests__/ReactNativeElement-itest.js +++ b/packages/react-native/src/private/webapis/dom/nodes/__tests__/ReactNativeElement-itest.js @@ -22,6 +22,7 @@ import ensureInstance from '../../../../utilities/ensureInstance'; import HTMLCollection from '../../oldstylecollections/HTMLCollection'; import NodeList from '../../oldstylecollections/NodeList'; import ReactNativeElement from '../ReactNativeElement'; +import ReadOnlyElement from '../ReadOnlyElement'; import ReadOnlyNode from '../ReadOnlyNode'; import * as Fantom from '@react-native/fantom'; import * as React from 'react'; @@ -51,6 +52,23 @@ describe('ReactNativeElement', () => { }); describe('extends `ReadOnlyNode`', () => { + it('should be an instance of `ReadOnlyNode`', () => { + let lastNode; + + const root = Fantom.createRoot(); + Fantom.runTask(() => { + root.render( + { + lastNode = node; + }} + />, + ); + }); + + expect(lastNode).toBeInstanceOf(ReadOnlyNode); + }); + describe('nodeType', () => { it('returns ReadOnlyNode.ELEMENT_NODE', () => { let lastParentNode; @@ -773,6 +791,23 @@ describe('ReactNativeElement', () => { }); describe('extends `ReadOnlyElement`', () => { + it('should be an instance of `ReadOnlyElement`', () => { + let lastNode; + + const root = Fantom.createRoot(); + Fantom.runTask(() => { + root.render( + { + lastNode = node; + }} + />, + ); + }); + + expect(lastNode).toBeInstanceOf(ReadOnlyElement); + }); + describe('children / childElementCount', () => { it('return updated element children information', () => { let lastParentElement; @@ -1287,7 +1322,26 @@ describe('ReactNativeElement', () => { }); }); - describe('implements specific `ReactNativeElement` methods', () => { + describe('extends `ReactNativeElement`', () => { + it('should be an instance of `ReactNativeElement`', () => { + let lastNode; + + // Initial render with 3 children + const root = Fantom.createRoot(); + Fantom.runTask(() => { + root.render( + { + lastNode = node; + }} + />, + ); + }); + + const node = ensureReactNativeElement(lastNode); + expect(node).toBeInstanceOf(ReactNativeElement); + }); + describe('offsetWidth / offsetHeight', () => { it('return the rounded width and height, or 0 when disconnected', () => { let lastElement;