(domNode, expectedStructure)
| 42 | const Missing = {}; |
| 43 | |
| 44 | function 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 | |
| 66 | describe('ReactART', () => { |
| 67 | let container; |
no test coverage detected