我的react组件上有一个处理程序。 DatabaseReference rootRef = FirebaseDatabase.getInstance().getReference();
DatabaseReference destinationRef = rootRef.child("Destination");
ValueEventListener valueEventListener = new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot dataSnapshot) {
for(DataSnapshot ds : dataSnapshot.getChildren()) {
YourClass yourClass = ds.getValue(YourClass.class);
Log.d(TAG, yourClass.getName());
}
}
@Override
public void onCancelled(@NonNull DatabaseError databaseError) {
Log.d(TAG, databaseError.getMessage());
}
};
destinationRef.addListenerForSingleValueEvent(valueEventListener);
,这是代码。
handleInputChange
我编写了一些通过的测试,但是我想编写测试以涵盖handleInputChange = (e, roomCapacity = 0) => {
const { name, value } = e.target;
this.setState({ [name]: value }, () => {
const { location, search, office } = this.state;
this.props.data.fetchMore({
variables: {
page: 1,
perPage: 5,
capacity: roomCapacity,
location: search || location,
office,
},
updateQuery: (prev, { fetchMoreResult }) => {
return { ...fetchMoreResult }
},
}).catch((err) => {
notification(toastr, 'error', err.graphQLErrors[0].message)();
});
});
};
函数。请参阅下面的图片,其中我要编写测试内容。 See screenshot here
请有人帮助我,我已经在网上搜索,但似乎找不到。谢谢