diff options
Diffstat (limited to 'vnext')
-rw-r--r-- | vnext/src/components/__tests__/MessageInput-test.js | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/vnext/src/components/__tests__/MessageInput-test.js b/vnext/src/components/__tests__/MessageInput-test.js index a348a6399..7e222beb4 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(<MessageInput data={testMessage} onSend={() => {}} />); + const wrapper = mount(<MessageInput data={testMessage} onSend={() => { }} />); 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 data={testMessage} onSend={() => {}} />); - messageInput.setState({'body': 'yoyo'}); + const messageInput = mount(<MessageInput data={testMessage} onSend={() => { }} />); + messageInput.find('textarea').simulate('change', { + target: { + value: ' ' + } + }); + expect(messageInput.state().body).toEqual(' '); messageInput.find('.msg-comment .badge').simulate('click'); expect(messageInput.state().body).toEqual(''); }) |