I am trying to write the test for the function with an inner call in enzyme and Sinon, but I encounter some issues about the inner call.
Here is my code:
Chat.js
sendMssage = text => {
const { user } = this.props;
let message = this.messageModel.normalize(text);
this.socketClient.onSendMessage(message, user);
this.addMessage(message);
};
test.js
it('should call sendMessage function', () => {
const wrapper = shallow(<ChatWindow />);
const instance = wrapper.instance();
sinon.spy(instance.socketClient(
message,
user,
));
socketClicent.onSendMessage(message, user);
Instance.sendMessage(message);
});
It throws an error:
instance.socketClient is not a function
Can anybody help me out understand what am I doing wrong?
Aucun commentaire:
Enregistrer un commentaire