fix(block-dev): Render props when mocking Link and Icon in stubBlockProps.

This commit is contained in:
Gervwyk 2022-03-03 11:18:49 +02:00
parent 0d285347cd
commit b6b50c842a

View File

@ -22,12 +22,20 @@ import schemaTest from './schemaTest.js';
const validate = {};
const Icons = {
AiIcon: (props) => <svg {...props} data-testid="AiIcon"></svg>,
AiOutlineExclamationCircle: (props) => (
<svg {...props} data-testid="AiOutlineExclamationCircle"></svg>
AiIcon: ({ onClick, ...props }) => (
<svg data-testid="AiIcon" onClick={onClick}>
ICON PROPS: {JSON.stringify(props)}
</svg>
),
AiOutlineLoading3Quarters: (props) => (
<svg {...props} data-testid="AiOutlineLoading3Quarters"></svg>
AiOutlineExclamationCircle: ({ onClick, ...props }) => (
<svg data-testid="AiOutlineExclamationCircle" onClick={onClick}>
ICON PROPS: {JSON.stringify(props)}
</svg>
),
AiOutlineLoading3Quarters: ({ onClick, ...props }) => (
<svg data-testid="AiOutlineLoading3Quarters" onClick={onClick}>
ICON PROPS: {JSON.stringify(props)}
</svg>
),
ErrorIcon: () => {
throw new Error('ErrorIcon');
@ -64,9 +72,9 @@ const stubBlockProps = ({ block, meta, logger = () => null, initialValue, schema
block.eventLog = [];
block.components = {
Icon: IconComponent,
Link: (props) => (
<a data-testid={`link-${props.href}`} {...props}>
{props.children}
Link: ({ id, children, onClick, ...props }) => (
<a data-testid={id} onClick={onClick}>
LINK PROPS:{JSON.stringify(props)} - CHILDREN: {children('default_title')}
</a>
),
};