MCPcopy
hub / github.com/react/react / testDOMNodeStructure

Function testDOMNodeStructure

packages/react-art/src/__tests__/ReactART-test.js:44–64  ·  view source on GitHub ↗
(domNode, expectedStructure)

Source from the content-addressed store, hash-verified

42const Missing = {};
43
44function testDOMNodeStructure(domNode, expectedStructure) {
45 expect(domNode).toBeDefined();
46 expect(domNode.nodeName).toBe(expectedStructure.nodeName);
47 for (const prop in expectedStructure) {
48 if (!expectedStructure.hasOwnProperty(prop)) {
49 continue;
50 }
51 if (prop !== 'nodeName' && prop !== 'children') {
52 if (expectedStructure[prop] === Missing) {
53 expect(domNode.hasAttribute(prop)).toBe(false);
54 } else {
55 expect(domNode.getAttribute(prop)).toBe(expectedStructure[prop]);
56 }
57 }
58 }
59 if (expectedStructure.children) {
60 expectedStructure.children.forEach(function (subTree, index) {
61 testDOMNodeStructure(domNode.childNodes[index], subTree);
62 });
63 }
64}
65
66describe('ReactART', () => {
67 let container;

Callers 1

ReactART-test.jsFile · 0.85

Calls 3

toBeDefinedMethod · 0.65
toBeMethod · 0.65
forEachMethod · 0.65

Tested by

no test coverage detected