这些测试之间有什么区别?单元测试React JS-开玩笑/酶

时间:2019-01-29 20:35:21

标签: javascript reactjs unit-testing

无法运行以下测试:

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)

}

0 个答案:

没有答案