主文件:这是具有3种方法的主文件,需要进行测试。我用一些stackoverflow以前的帮助写下了一些代码,但只想仔细检查它是否有意义或是否正确。如果可能,进行更改或改进代码。谢谢
seconds
这是我要测试的内容:目前它们都通过了测试,但是设置常量和Expect.wrapper可能出错。 如果可能的话,在代码上添加一些注释,//应该做些什么,否则纠正会非常有帮助
componentDidMount() {
if (this.props.defaultDataFromViewXML.length != 0 ) {
let localState = Object.assign({}, this.state)
localState.axis = {}
this.props.defaultDataFromViewXML.map(entry => {
let newId = shortid.generate()
localState.axis[newId] = {
axisLabel: entry,
id: newId
}
})
this.setState(localState)
}
}
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)
}
deleteAxisByID = (id) => {
delete this.state.axis[id]
let updateObj = {
0: {
pipe: 'chart',
action: 'transform',
matchValue: 'axes',
axes: this.state.axis
}
}
this.props.addAxisList(updateObj)
}