您可以使用酶的浅化方法来渲染组件,然后检查path元素上的道具:
// at the top of your test file file:
import { shallow } from 'enzyme';
...
it('should render path element with the expected d attribute', () => {
// shallowly render your component:
const wrapper = shallow(<Component />);
// find the path element using a css selector
const trendline = wrapper.find('path#TrendLine');
// make assertion
expect(trendline.props()).toHaveProperty('d', 'M170,28.76363636363638C170,28.76363636363638,221.46221083573664,189.150059910');
});
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
5235 次 |
| 最近记录: |