(root, expectedJSX)
| 67 | } |
| 68 | |
| 69 | export function unstable_toMatchRenderedOutput(root, expectedJSX) { |
| 70 | assertYieldsWereCleared(root); |
| 71 | const actualJSON = root.toJSON(); |
| 72 | |
| 73 | let actualJSX; |
| 74 | if (actualJSON === null || typeof actualJSON === 'string') { |
| 75 | actualJSX = actualJSON; |
| 76 | } else if (isArray(actualJSON)) { |
| 77 | if (actualJSON.length === 0) { |
| 78 | actualJSX = null; |
| 79 | } else if (actualJSON.length === 1) { |
| 80 | actualJSX = jsonChildToJSXChild(actualJSON[0]); |
| 81 | } else { |
| 82 | const actualJSXChildren = jsonChildrenToJSXChildren(actualJSON); |
| 83 | if (actualJSXChildren === null || typeof actualJSXChildren === 'string') { |
| 84 | actualJSX = actualJSXChildren; |
| 85 | } else { |
| 86 | actualJSX = createJSXElementForTestComparison(REACT_FRAGMENT_TYPE, { |
| 87 | children: actualJSXChildren, |
| 88 | }); |
| 89 | } |
| 90 | } |
| 91 | } else { |
| 92 | actualJSX = jsonChildToJSXChild(actualJSON); |
| 93 | } |
| 94 | |
| 95 | return captureAssertion(() => { |
| 96 | expect(actualJSX).toEqual(expectedJSX); |
| 97 | }); |
| 98 | } |
| 99 | |
| 100 | function jsonChildToJSXChild(jsonChild) { |
| 101 | if (jsonChild === null || typeof jsonChild === 'string') { |
nothing calls this directly
no test coverage detected