我正在尝试对以下内容进行单元测试:
handleChange = (e) => {
let localState = Object.assign({}, this.state)
localState[e.target.name] = e.target.value
this.setState(localState)
this.props.addMetaInformation(localState)
}
}
我对大部分文件进行了单元测试,但不确定如何运行上面的代码。我如何根据下面的代码测试上面的方法或函数谢谢
describe('Component', () => {
let tree;
let baseProps;
// let this.props = let mockprops
beforeEach(() => {
// props : mockprops;
}
})
it ('should render without a props ',() => {
baseProps = {
...baseProps,
//props: {},
};
tree = renderer.create(<Component {...baseProps } />)
let treeJson = tree.toJSON();
expect(treeJson).toMatchSnapshot();
tree.unmount()
});