无法运行以下测试:
file2.test.js都列出了这两种方法,但是我正在尝试测试deleteAxisByid方法。第一种方法我已经有一个测试用例
addNewAxis = (obj) => {
let localState = Object.assign({}, this.state)
localState.axis[obj.id] = obj
let updateObj = {
0: {
pipe: 'chart',
action: 'transform',
transformType: 'replaceElement',
matchValue: 'axes',
axes: localState.axis
}
}
this.props.addAxisList(updateObj)
this.setState(localState)
}
it ('Testing deleteAxisByID method: ',() => {
const wrapper = shallow(<AxisList {...baseProps } />);
let id = {test : 'test'}
wrapper.instance().deleteAxisByID(id)
expect(wrapper.instance().state.axis).toHaveProperty('test')
});
这是主要代码:file.js
deleteAxisByID = (id) => {
delete this.state.axis[id]
let updateObj = {
0: {
pipe: 'chart',
action: 'transform',
matchValue: 'axes',
axes: this.state.axis
}
}
this.props.addAxisList(updateObj)
}