(element)
| 30 | }, |
| 31 | |
| 32 | toImplementSxBehavior(element) { |
| 33 | const mediaKey = '@media (max-width:123px)' |
| 34 | const sxPropValue = { |
| 35 | [mediaKey]: { |
| 36 | color: 'red.5', |
| 37 | }, |
| 38 | } |
| 39 | |
| 40 | const elem = React.cloneElement(element, {sx: sxPropValue}) |
| 41 | |
| 42 | function checkStylesDeep(rendered: ReactTestRendererJSON): boolean { |
| 43 | const className = rendered.props.className || rendered.props.class |
| 44 | const styles = getComputedStyles(className) |
| 45 | const mediaStyles = styles[mediaKey] as Record<string, string> | null |
| 46 | if (mediaStyles && mediaStyles.color) { |
| 47 | return true |
| 48 | } else if (rendered.children) { |
| 49 | return rendered.children.some((child: ReactTestRendererNode) => checkStylesDeep(child as ReactTestRendererJSON)) |
| 50 | } else { |
| 51 | return false |
| 52 | } |
| 53 | } |
| 54 | |
| 55 | return { |
| 56 | pass: checkStylesDeep(render(elem)), |
| 57 | message: () => 'sx prop values did not change styles of component nor of any sub-components', |
| 58 | } |
| 59 | }, |
| 60 | |
| 61 | toSetExports(mod, expectedExports) { |
| 62 | if (!Object.keys(expectedExports).includes('default')) { |
nothing calls this directly
no test coverage detected