Tôi có một phương thức tĩnh bên trong Thành phần React, như:
class DeliveryAddressScreen extends Component {
static isAddressReady(address) {
return !!(address)
}
sendAddress(address) {
if(this.isAddressReady(address)) {
// DO SOMETHING
}
}
}
Và bài kiểm tra của tôi:
it('sample tests', () => {
const component = shallow(<DeliveryAddressScreen />)
component.instance().sendAddress('Address')
expect(true).toBe(true) // Just a sample
})
phản hồi là:
TypeError : this.isAddressReady không phải là một hàm
Có cách nào đúng để chế giễu phương pháp này hay điều gì đó tương tự không?