From 1a904c4d8e19c0e4e7f5f74b1a242c0ab171f531 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rub=C3=A9n=20Norte?= Date: Thu, 2 Jan 2025 02:22:22 -0800 Subject: [PATCH] Add a few more tests to ReactNativeElement Summary: Changelog: [internal] Adding a few more tests for `ReactNativeElement` for symmetry with future tests for when it implements `EventTarget`. Differential Revision: D67738147 --- .../__tests__/ReactNativeElement-itest.js | 58 ++++++++++++++++++- 1 file changed, 57 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 e7d71390e426e7..e93dee1d0f2cf3 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 @@ -21,6 +21,7 @@ import { 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'; @@ -56,6 +57,24 @@ describe('ReactNativeElement', () => { }); describe('extends `ReadOnlyNode`', () => { + it('should be an instance of `ReadOnlyNode`', () => { + let lastNode; + + // Initial render with 3 children + const root = Fantom.createRoot(); + Fantom.runTask(() => { + root.render( + { + lastNode = node; + }} + />, + ); + }); + + expect(lastNode).toBeInstanceOf(ReadOnlyNode); + }); + describe('nodeType', () => { it('returns ReadOnlyNode.ELEMENT_NODE', () => { let lastParentNode; @@ -590,6 +609,24 @@ describe('ReactNativeElement', () => { }); describe('extends `ReadOnlyElement`', () => { + it('should be an instance of `ReadOnlyElement`', () => { + let lastNode; + + // Initial render with 3 children + 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; @@ -1104,7 +1141,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;