aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Vitaly Takmazov2018-06-21 10:30:17 +0300
committerGravatar Vitaly Takmazov2023-01-13 10:37:53 +0300
commit7a7292c1dedd434352183ddd9fda5f808f1e0daa (patch)
treea7edaba57fb4e7fdc8404cde4233d6fdaf34b61e
parent114792eeff9a9887214eadd2224386e314438cd6 (diff)
update message input tests
-rw-r--r--vnext/src/components/__tests__/MessageInput-test.js18
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 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(<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('');
})