From 25bddaf76b21535de2ea3f24816a3c09ea37bd78 Mon Sep 17 00:00:00 2001
From: Vitaly Takmazov
Date: Tue, 8 Jun 2021 00:30:40 +0300
Subject: Fix tests
---
vnext/src/ui/UserInfo.js | 2 ++
vnext/src/ui/__tests__/MessageInput-test.js | 4 ++++
vnext/src/ui/__tests__/UserLink.test.js | 26 ++++++++++++++------------
3 files changed, 20 insertions(+), 12 deletions(-)
(limited to 'vnext/src/ui')
diff --git a/vnext/src/ui/UserInfo.js b/vnext/src/ui/UserInfo.js
index cb6ad792..3890d0bc 100644
--- a/vnext/src/ui/UserInfo.js
+++ b/vnext/src/ui/UserInfo.js
@@ -104,6 +104,8 @@ export function UserLink(props) {
if (isMounted) {
setUser(response.data);
}
+ }).catch(reason => {
+ // TODO: debug logging
});
}
return () => {
diff --git a/vnext/src/ui/__tests__/MessageInput-test.js b/vnext/src/ui/__tests__/MessageInput-test.js
index 261786d0..12b85bca 100644
--- a/vnext/src/ui/__tests__/MessageInput-test.js
+++ b/vnext/src/ui/__tests__/MessageInput-test.js
@@ -1,3 +1,7 @@
+/**
+ * @jest-environment jsdom
+ */
+
import { create, act } from 'react-test-renderer';
import MessageInput from '../MessageInput';
diff --git a/vnext/src/ui/__tests__/UserLink.test.js b/vnext/src/ui/__tests__/UserLink.test.js
index 30c35928..6bb4da29 100644
--- a/vnext/src/ui/__tests__/UserLink.test.js
+++ b/vnext/src/ui/__tests__/UserLink.test.js
@@ -1,19 +1,21 @@
-import { MemoryRouter, Switch, Route } from 'react-router-dom';
+import { MemoryRouter } from 'react-router-dom';
import { UserLink } from '../UserInfo';
-import renderer from 'react-test-renderer';
+import renderer, { act } from 'react-test-renderer';
test('UserLink renders correctly', async () => {
- const component = renderer.create(
-
- <>
-
-
-
- >
-
- );
- await Promise.resolve();
+ let component = null;
+ act(() => {
+ component = renderer.create(
+
+ <>
+
+
+
+ >
+
+ );
+ });
let tree = component.toJSON();
expect(tree).toMatchSnapshot();
});
--
cgit v1.2.3