[英]How to test React component using jest
I have such react stateless component. 我有这样的反应无状态组件。 I need to check if lowbandwidth icon exist when isSmallVideoView is true
当isSmallVideoView为true时,我需要检查是否存在低带宽图标
export const UnmountableVideoLayout: React.StatelessComponent<VideoLayoutProps> = ({
isSmallVideoView,
videoComponent,
videoOverlayComponent,
}: VideoLayoutProps) => (
<div className={vStyles.topCenterSeparate}>
<div className={svStyles.box}>
{isSmallVideoView && (
<div className={svStyles.lowBandwidthIcon}>
<LowBandwidthConnected />
</div>
)}
</div>
</div>
);
How I can test LowBandwidthConnected? 如何测试LowBandwidthConnected? My test doesn't work
我的测试无效
it("should render lowBandwidthIcon if isSmallVideoView is true", () => {
const props = {
isSmallVideoView: true,
videoComponent: dummyVideo,
};
const wrapper = shallow(<UnmountableVideoLayout {...props} />);
expect(wrapper.find(svStyles.lowBandwidthIcon).length).toBe(1);
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.