From f470636a70943a8ecad8bddc791a1c2dddd28e1e Mon Sep 17 00:00:00 2001 From: Vitaly Takmazov Date: Sat, 4 May 2019 21:13:12 +0300 Subject: Components -> UI --- vnext/src/components/__tests__/Avatar.test.js | 15 -- vnext/src/components/__tests__/LoginButton.test.js | 21 --- .../src/components/__tests__/MessageInput-test.js | 95 ----------- vnext/src/components/__tests__/UserLink.test.js | 20 --- .../__tests__/__snapshots__/Avatar.test.js.snap | 41 ----- .../__snapshots__/LoginButton.test.js.snap | 178 --------------------- .../__tests__/__snapshots__/UserLink.test.js.snap | 33 ---- 7 files changed, 403 deletions(-) delete mode 100644 vnext/src/components/__tests__/Avatar.test.js delete mode 100644 vnext/src/components/__tests__/LoginButton.test.js delete mode 100644 vnext/src/components/__tests__/MessageInput-test.js delete mode 100644 vnext/src/components/__tests__/UserLink.test.js delete mode 100644 vnext/src/components/__tests__/__snapshots__/Avatar.test.js.snap delete mode 100644 vnext/src/components/__tests__/__snapshots__/LoginButton.test.js.snap delete mode 100644 vnext/src/components/__tests__/__snapshots__/UserLink.test.js.snap (limited to 'vnext/src/components/__tests__') diff --git a/vnext/src/components/__tests__/Avatar.test.js b/vnext/src/components/__tests__/Avatar.test.js deleted file mode 100644 index e7221871..00000000 --- a/vnext/src/components/__tests__/Avatar.test.js +++ /dev/null @@ -1,15 +0,0 @@ -import React from 'react'; -import { MemoryRouter } from 'react-router-dom'; - -import Avatar from '../Avatar'; -import renderer from 'react-test-renderer'; - -test('Avatar renders correctly', () => { - const component = renderer.create( - - - - ); - let tree = component.toJSON(); - expect(tree).toMatchSnapshot(); -}); diff --git a/vnext/src/components/__tests__/LoginButton.test.js b/vnext/src/components/__tests__/LoginButton.test.js deleted file mode 100644 index da80abb0..00000000 --- a/vnext/src/components/__tests__/LoginButton.test.js +++ /dev/null @@ -1,21 +0,0 @@ -import React from 'react'; - -import LoginButton from '../LoginButton'; -import { create, act } from 'react-test-renderer'; - -test('Login button and form are renders correctly', () => { - var button = null; - act(() => { - button = create( - { }} /> - ); - }); - let link = button.toJSON(); - expect(link).toMatchSnapshot(); - - act(() => { - button.root.findByType('a').props.onClick(); - }); - let modal = button.toJSON(); - expect(modal).toMatchSnapshot(); -}); diff --git a/vnext/src/components/__tests__/MessageInput-test.js b/vnext/src/components/__tests__/MessageInput-test.js deleted file mode 100644 index 7ac69ed0..00000000 --- a/vnext/src/components/__tests__/MessageInput-test.js +++ /dev/null @@ -1,95 +0,0 @@ -import React from 'react'; -import { create, act } from 'react-test-renderer'; - -import MessageInput from '../MessageInput'; - -const testMessage = { - mid: 1, - rid: 0, - body: 'test message', - timestamp: new Date().toISOString(), - attach: '', - to: {} -}; - -window.matchMedia = window.matchMedia || function () { - return { - matches: true, - addListener: function () { }, - removeListener: function () { } - }; -}; - -it('Gives immediate focus on to textarea on load', () => { - let focused = false; - act(() => { - create( { }} />, { - createNodeMock: (element) => { - if (element.type === 'textarea') { - // mock a focus function - return { - focus: () => { - focused = true; - }, - style: {} - }; - } - return null; - } - }); - }); - expect(focused).toEqual(true, 'textarea was not focused'); -}); - - -it('Submits on ctrl-enter', () => { - const onSend = jest.fn(); - var messageInput = null; - act(() => { - messageInput = create(, { - createNodeMock: (element) => { - if (element.type === 'textarea') { - return { - focus: () => { }, - style: {} - }; - } - return null; - } - }); - }); - let textarea = messageInput.root.findByType('textarea'); - act(() => { - - textarea.props.onKeyPress({ - charCode: 13, - which: 13, - keyCode: 13, - ctrlKey: false - }); - }); - expect(onSend).toHaveBeenCalledTimes(0); - act(() => { - textarea.props.onKeyPress({ - charCode: 13, - which: 13, - keyCode: 13, - ctrlKey: true - }); - }); - expect(onSend).toHaveBeenCalledTimes(1); - expect(textarea.props.value).toEqual(''); - act(() => { - textarea.props.onChange({ - target: { - value: ' ', - validity: {} - } - }); - }); - expect(textarea.props.value).toEqual(' '); - act(() => { - messageInput.root.findByType('form').props.onSubmit({ event: {} }); - }); - expect(textarea.props.value).toEqual('', 'Value should be cleared after submit'); -}); diff --git a/vnext/src/components/__tests__/UserLink.test.js b/vnext/src/components/__tests__/UserLink.test.js deleted file mode 100644 index a75344b0..00000000 --- a/vnext/src/components/__tests__/UserLink.test.js +++ /dev/null @@ -1,20 +0,0 @@ -import React from 'react'; -import { MemoryRouter, Switch, Route } from 'react-router-dom'; - -import { UserLink } from '../UserInfo'; -import renderer from 'react-test-renderer'; - -test('UserLink renders correctly', async () => { - const component = renderer.create( - - <> - - - - - - ); - await Promise.resolve(); - let tree = component.toJSON(); - expect(tree).toMatchSnapshot(); -}); diff --git a/vnext/src/components/__tests__/__snapshots__/Avatar.test.js.snap b/vnext/src/components/__tests__/__snapshots__/Avatar.test.js.snap deleted file mode 100644 index 47614f5a..00000000 --- a/vnext/src/components/__tests__/__snapshots__/Avatar.test.js.snap +++ /dev/null @@ -1,41 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`Avatar renders correctly 1`] = ` -
-
- - ugnich - -
-
- - - - ugnich - - - -
-
-`; diff --git a/vnext/src/components/__tests__/__snapshots__/LoginButton.test.js.snap b/vnext/src/components/__tests__/__snapshots__/LoginButton.test.js.snap deleted file mode 100644 index cd08b1b4..00000000 --- a/vnext/src/components/__tests__/__snapshots__/LoginButton.test.js.snap +++ /dev/null @@ -1,178 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`Login button and form are renders correctly 1`] = ` - -
- ", - } - } - /> -
- - Log in - -
-`; - -exports[`Login button and form are renders correctly 2`] = ` -Array [ - -
- ", - } - } - /> -
- - Log in - -
, -
-
-
-
-
- ", - } - } - /> -
-
-
-
-

- Please, introduce yourself: -

- -

- Already registered? -

-
- -
- -
- -
-
-
-
, -] -`; diff --git a/vnext/src/components/__tests__/__snapshots__/UserLink.test.js.snap b/vnext/src/components/__tests__/__snapshots__/UserLink.test.js.snap deleted file mode 100644 index 15e25367..00000000 --- a/vnext/src/components/__tests__/__snapshots__/UserLink.test.js.snap +++ /dev/null @@ -1,33 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`UserLink renders correctly 1`] = ` -Array [ - - - ugnich - , - - - ugnich - , - - - - , -] -`; -- cgit v1.2.3