From 114792eeff9a9887214eadd2224386e314438cd6 Mon Sep 17 00:00:00 2001 From: Vitaly Takmazov Date: Thu, 21 Jun 2018 10:13:12 +0300 Subject: Clear message input on send --- vnext/src/components/MessageInput.js | 4 ++++ vnext/src/components/__tests__/MessageInput-test.js | 9 ++++++++- 2 files changed, 12 insertions(+), 1 deletion(-) (limited to 'vnext/src/components') diff --git a/vnext/src/components/MessageInput.js b/vnext/src/components/MessageInput.js index 57ee8f3c..e8e4c99a 100644 --- a/vnext/src/components/MessageInput.js +++ b/vnext/src/components/MessageInput.js @@ -40,6 +40,10 @@ export default class MessageInput extends React.Component { body: this.state.body, attach: this.state.attach ? input.files[0] : '' }) + this.setState({ + body: '', + attach: '' + }) } componentDidMount() { diff --git a/vnext/src/components/__tests__/MessageInput-test.js b/vnext/src/components/__tests__/MessageInput-test.js index f6a452d8..a348a639 100644 --- a/vnext/src/components/__tests__/MessageInput-test.js +++ b/vnext/src/components/__tests__/MessageInput-test.js @@ -44,4 +44,11 @@ it('Submits on ctrl-enter', () => { ctrlKey: true }); expect(onSend).toHaveBeenCalledTimes(1); -}); \ No newline at end of file +}); + +it('Clears template on submit', () => { + const messageInput = mount( {}} />); + messageInput.setState({'body': 'yoyo'}); + messageInput.find('.msg-comment .badge').simulate('click'); + expect(messageInput.state().body).toEqual(''); +}) -- cgit v1.2.3