From 7a7292c1dedd434352183ddd9fda5f808f1e0daa Mon Sep 17 00:00:00 2001 From: Vitaly Takmazov Date: Thu, 21 Jun 2018 10:30:17 +0300 Subject: update message input tests --- vnext/src/components/__tests__/MessageInput-test.js | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) (limited to 'vnext/src/components/__tests__') diff --git a/vnext/src/components/__tests__/MessageInput-test.js b/vnext/src/components/__tests__/MessageInput-test.js index a348a639..7e222beb 100644 --- a/vnext/src/components/__tests__/MessageInput-test.js +++ b/vnext/src/components/__tests__/MessageInput-test.js @@ -15,7 +15,7 @@ const testMessage = { }; it('Gives immediate focus on to textarea on load', () => { - const wrapper = mount( {}} />); + const wrapper = mount( { }} />); const textareaRef = wrapper.instance().textarea; jest.spyOn(textareaRef.current, 'focus'); @@ -30,13 +30,12 @@ it('Submits on ctrl-enter', () => { let textarea = messageInput.find('textarea'); textarea.simulate('keypress', { - charCode: 32, - which: 32, - keyCode: 32, + charCode: 13, + which: 13, + keyCode: 13, ctrlKey: false }); expect(onSend).toHaveBeenCalledTimes(0); - // TODO: test for body change textarea.simulate('keypress', { charCode: 13, which: 13, @@ -47,8 +46,13 @@ it('Submits on ctrl-enter', () => { }); it('Clears template on submit', () => { - const messageInput = mount( {}} />); - messageInput.setState({'body': 'yoyo'}); + const messageInput = mount( { }} />); + messageInput.find('textarea').simulate('change', { + target: { + value: ' ' + } + }); + expect(messageInput.state().body).toEqual(' '); messageInput.find('.msg-comment .badge').simulate('click'); expect(messageInput.state().body).toEqual(''); }) -- cgit v1.2.3