Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a few more tests to ReactNativeElement #48428

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
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';
Expand Down Expand Up @@ -51,6 +52,23 @@
});

describe('extends `ReadOnlyNode`', () => {
it('should be an instance of `ReadOnlyNode`', () => {
let lastNode;

const root = Fantom.createRoot();
Fantom.runTask(() => {
root.render(
<View
ref={node => {
lastNode = node;
}}
/>,
);
});

expect(lastNode).toBeInstanceOf(ReadOnlyNode);
});

describe('nodeType', () => {
it('returns ReadOnlyNode.ELEMENT_NODE', () => {
let lastParentNode;
Expand Down Expand Up @@ -236,7 +254,7 @@

describe('getRootNode()', () => {
// This is the desired implementation (not implemented yet).
it.skip('returns a root node representing the document', () => {

Check warning on line 257 in packages/react-native/src/private/webapis/dom/nodes/__tests__/ReactNativeElement-itest.js

View workflow job for this annotation

GitHub Actions / test_js (20)

Disabled test

Check warning on line 257 in packages/react-native/src/private/webapis/dom/nodes/__tests__/ReactNativeElement-itest.js

View workflow job for this annotation

GitHub Actions / test_js (18)

Disabled test
let lastParentANode;
let lastParentBNode;
let lastChildANode;
Expand Down Expand Up @@ -773,6 +791,23 @@
});

describe('extends `ReadOnlyElement`', () => {
it('should be an instance of `ReadOnlyElement`', () => {
let lastNode;

const root = Fantom.createRoot();
Fantom.runTask(() => {
root.render(
<View
ref={node => {
lastNode = node;
}}
/>,
);
});

expect(lastNode).toBeInstanceOf(ReadOnlyElement);
});

describe('children / childElementCount', () => {
it('return updated element children information', () => {
let lastParentElement;
Expand Down Expand Up @@ -1287,7 +1322,26 @@
});
});

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(
<View
ref={node => {
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;
Expand Down
Loading