From e62a015d13337e0d33dea81e52727ba2523df7f7 Mon Sep 17 00:00:00 2001 From: Anton Arnautov Date: Wed, 24 Aug 2022 17:10:28 +0200 Subject: [PATCH 1/2] fix(Vite): add emoji-mart (emoji, picker) re-export --- src/context/DefaultEmoji.ts | 4 ++++ src/context/DefaultEmojiPicker.ts | 4 ++++ src/context/EmojiContext.tsx | 14 +++----------- 3 files changed, 11 insertions(+), 11 deletions(-) create mode 100644 src/context/DefaultEmoji.ts create mode 100644 src/context/DefaultEmojiPicker.ts diff --git a/src/context/DefaultEmoji.ts b/src/context/DefaultEmoji.ts new file mode 100644 index 0000000000..718b040d4f --- /dev/null +++ b/src/context/DefaultEmoji.ts @@ -0,0 +1,4 @@ +// @ts-expect-error +import NimbleEmoji from 'emoji-mart/dist/components/emoji/nimble-emoji'; + +export { NimbleEmoji as default }; diff --git a/src/context/DefaultEmojiPicker.ts b/src/context/DefaultEmojiPicker.ts new file mode 100644 index 0000000000..fbb22604ff --- /dev/null +++ b/src/context/DefaultEmojiPicker.ts @@ -0,0 +1,4 @@ +// @ts-expect-error +import NimblePicker from 'emoji-mart/dist/components/picker/nimble-picker'; + +export { NimblePicker as default }; diff --git a/src/context/EmojiContext.tsx b/src/context/EmojiContext.tsx index f1cc337068..838e40f4e1 100644 --- a/src/context/EmojiContext.tsx +++ b/src/context/EmojiContext.tsx @@ -49,17 +49,9 @@ export type EmojiContextValue = { EmojiPicker?: React.ComponentType; }; -const DefaultEmoji = React.lazy(async () => { - //@ts-expect-error - const emoji = await import('emoji-mart/dist/components/emoji/nimble-emoji.js'); - return { default: emoji.default }; -}); - -const DefaultEmojiPicker = React.lazy(async () => { - // @ts-expect-error - const emojiPicker = await import('emoji-mart/dist/components/picker/nimble-picker.js'); - return { default: emojiPicker.default }; -}); +const DefaultEmoji = React.lazy(() => import('./DefaultEmoji')); + +const DefaultEmojiPicker = React.lazy(() => import('./DefaultEmojiPicker')); export const EmojiContext = React.createContext(undefined); From a31e625daa15014d6081481695ee166263de33b0 Mon Sep 17 00:00:00 2001 From: Anton Arnautov Date: Wed, 24 Aug 2022 18:37:55 +0200 Subject: [PATCH 2/2] test(MessageInput): remove unused React.Suspense mock --- .../__tests__/MessageInput.test.js | 27 ------------------- 1 file changed, 27 deletions(-) diff --git a/src/components/MessageInput/__tests__/MessageInput.test.js b/src/components/MessageInput/__tests__/MessageInput.test.js index 4b79245d8e..ae3745ba43 100644 --- a/src/components/MessageInput/__tests__/MessageInput.test.js +++ b/src/components/MessageInput/__tests__/MessageInput.test.js @@ -31,33 +31,6 @@ import { expect.extend(toHaveNoViolations); -jest.mock('react', () => { - const React = jest.requireActual('react'); - const Suspense = ({ children }) => children; - - const lazy = jest.fn().mockImplementation((fn) => { - const Component = (props) => { - const [C, setC] = React.useState(); - - React.useEffect(() => { - fn().then((v) => { - setC(v); - }); - }, []); - - return C ? : null; - }; - - return Component; - }); - - return { - ...React, - lazy, - Suspense, - }; -}); - jest.mock('../../Channel/utils', () => ({ makeAddNotifications: jest.fn })); let chatClient;