aboutsummaryrefslogtreecommitdiff
path: root/vnext/src/ui/__tests__
diff options
context:
space:
mode:
Diffstat (limited to 'vnext/src/ui/__tests__')
-rw-r--r--vnext/src/ui/__tests__/Avatar.test.js14
-rw-r--r--vnext/src/ui/__tests__/MessageInput.test.js48
-rw-r--r--vnext/src/ui/__tests__/UserLink.test.js18
3 files changed, 40 insertions, 40 deletions
diff --git a/vnext/src/ui/__tests__/Avatar.test.js b/vnext/src/ui/__tests__/Avatar.test.js
index f454f6c7..7aea804c 100644
--- a/vnext/src/ui/__tests__/Avatar.test.js
+++ b/vnext/src/ui/__tests__/Avatar.test.js
@@ -1,14 +1,14 @@
-import { MemoryRouter } from 'react-router-dom';
+import { MemoryRouter } from 'react-router-dom'
-import Avatar from '../Avatar';
-import renderer from 'react-test-renderer';
+import Avatar from '../Avatar'
+import renderer from 'react-test-renderer'
test('Avatar renders correctly', () => {
const component = renderer.create(
<MemoryRouter>
<Avatar user={{ uid: 1, uname: 'ugnich', avatar: 'https://juick.com/i/a/1-deadbeef.png' }} />
</MemoryRouter>
- );
- let tree = component.toJSON();
- expect(tree).toMatchSnapshot();
-});
+ )
+ let tree = component.toJSON()
+ expect(tree).toMatchSnapshot()
+})
diff --git a/vnext/src/ui/__tests__/MessageInput.test.js b/vnext/src/ui/__tests__/MessageInput.test.js
index 0bfe2569..4af36b71 100644
--- a/vnext/src/ui/__tests__/MessageInput.test.js
+++ b/vnext/src/ui/__tests__/MessageInput.test.js
@@ -1,46 +1,46 @@
-import { render, screen, fireEvent, waitFor } from '@testing-library/react';
+import { render, screen, fireEvent, waitFor } from '@testing-library/react'
-import MessageInput from '../MessageInput';
+import MessageInput from '../MessageInput'
test('Gives immediate focus on to textarea on load', async () => {
- let draft = 'draft';
- render(<MessageInput text={draft} onSend={async () => { return true; }} />);
- expect(screen.getByText(draft)).toHaveFocus();
-});
+ let draft = 'draft'
+ render(<MessageInput text={draft} onSend={async () => { return true }} />)
+ expect(screen.getByText(draft)).toHaveFocus()
+})
test('Submits on ctrl-enter and pass validation', async () => {
- let result = false;
- const onSend = jest.fn(async ({ body }) => { result = body === 'YO'; return result; });
- let draft = 'draft';
- render(<MessageInput onSend={onSend} text={draft} />);
- let textarea = screen.getByText(draft);
- fireEvent.change(textarea, { target: { value: 'HI' } });
+ let result = false
+ const onSend = jest.fn(async ({ body }) => { result = body === 'YO'; return result })
+ let draft = 'draft'
+ render(<MessageInput onSend={onSend} text={draft} />)
+ let textarea = screen.getByText(draft)
+ fireEvent.change(textarea, { target: { value: 'HI' } })
// this event should not submit
fireEvent.keyPress(textarea, {
charCode: 13,
which: 13,
keyCode: 13
- });
+ })
// this event should submit
fireEvent.keyPress(textarea, {
charCode: 13,
which: 13,
keyCode: 13,
ctrlKey: true
- });
- expect(onSend).toHaveBeenCalledTimes(1);
- expect(result).toBe(false);
- fireEvent.change(textarea, { target: { value: 'YO' } });
+ })
+ expect(onSend).toHaveBeenCalledTimes(1)
+ expect(result).toBe(false)
+ fireEvent.change(textarea, { target: { value: 'YO' } })
fireEvent.keyPress(textarea, {
charCode: 13,
which: 13,
keyCode: 13,
ctrlKey: true
- });
- expect(onSend).toHaveBeenCalledTimes(2);
- expect(result).toBe(true);
- await waitFor(() => expect(textarea).toHaveTextContent(''));
- textarea.focus();
- expect(textarea).toHaveFocus();
-});
+ })
+ expect(onSend).toHaveBeenCalledTimes(2)
+ expect(result).toBe(true)
+ await waitFor(() => expect(textarea).toHaveTextContent(''))
+ textarea.focus()
+ expect(textarea).toHaveFocus()
+})
diff --git a/vnext/src/ui/__tests__/UserLink.test.js b/vnext/src/ui/__tests__/UserLink.test.js
index 6bb4da29..99ca42ce 100644
--- a/vnext/src/ui/__tests__/UserLink.test.js
+++ b/vnext/src/ui/__tests__/UserLink.test.js
@@ -1,10 +1,10 @@
-import { MemoryRouter } from 'react-router-dom';
+import { MemoryRouter } from 'react-router-dom'
-import { UserLink } from '../UserInfo';
-import renderer, { act } from 'react-test-renderer';
+import { UserLink } from '../UserInfo'
+import renderer, { act } from 'react-test-renderer'
test('UserLink renders correctly', async () => {
- let component = null;
+ let component = null
act(() => {
component = renderer.create(
<MemoryRouter>
@@ -14,8 +14,8 @@ test('UserLink renders correctly', async () => {
<UserLink user={{ uid: 0, uname: '', uri: 'https://example.com/u/test' }} />
</>
</MemoryRouter>
- );
- });
- let tree = component.toJSON();
- expect(tree).toMatchSnapshot();
-});
+ )
+ })
+ let tree = component.toJSON()
+ expect(tree).toMatchSnapshot()
+})