in src/utils/testing.tsx [210:236]
export function behavesAsComponent({Component, toRender, options}: BehavesAsComponent) {
options = options || {}
const getElement = () => (toRender ? toRender() : <Component />)
if (!options.skipSx) {
it('implements sx prop behavior', () => {
expect(getElement()).toImplementSxBehavior()
})
}
if (!options.skipAs) {
it('respects the as prop', () => {
const As = React.forwardRef<HTMLDivElement>((_props, ref) => <div className="as-component" ref={ref} />)
const elem = React.cloneElement(getElement(), {as: As})
expect(render(elem)).toEqual(render(<As />))
})
}
it('sets a valid displayName', () => {
expect(Component.displayName).toMatch(COMPONENT_DISPLAY_NAME_REGEX)
})
it('renders consistently', () => {
expect(render(getElement())).toMatchSnapshot()
})
}