Стек технологий: Typescript, React, Jest, React Testing Library У меня есть компонент:
const Button: FunctionComponent<ButtonProps> = ({
size = 'default',
type = 'default',
htmlType = 'button',
icon,
children,
...otherProps
}) => {
let Component;
if (type === 'primary') {
Component = PrimaryButton;
} else if (type === 'outline') {
Component = OutlineButton;
} else if (type === 'danger') {
Component = DangerButton;
} else if (type === 'dark') {
Component = DarkButton;
} else {
Component = DefaultButton;
}
let layout: StyledButtonProps['layout'] = size;
if (icon) {
if (size !== 'large') {
layout = !!children ? 'medium' : 'icon';
}
}
return (
<Component type={htmlType} {...otherProps} layout={layout}>
{icon ? <Icon>{icon}</Icon> : null}
{children}
</Component>
);
};
Как мне протестировать, что в случае переданного свойства type='primary'
отрисуется правильный компонент PrimaryButton?
Спасибо.