From 8be6b693e22823970454fede55d1a573dfffe26c Mon Sep 17 00:00:00 2001 From: nzambello Date: Thu, 6 Jun 2024 13:24:02 +0300 Subject: [PATCH] fix: fixup --- jest.setup.js | 1 + src/components/ChatBubble/ChatBubble.tsx | 10 +++++----- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/jest.setup.js b/jest.setup.js index 6ca0ff10..84862540 100644 --- a/jest.setup.js +++ b/jest.setup.js @@ -83,3 +83,4 @@ Object.defineProperty(window, 'MathJax', { }); jest.spyOn(window, 'MathJax', 'typesetPromise').mockResolvedValue(); +jest.spyOn(global.MathJax, 'typesetPromise').mockResolvedValue(); diff --git a/src/components/ChatBubble/ChatBubble.tsx b/src/components/ChatBubble/ChatBubble.tsx index 53e953e4..c18a7be8 100644 --- a/src/components/ChatBubble/ChatBubble.tsx +++ b/src/components/ChatBubble/ChatBubble.tsx @@ -26,9 +26,6 @@ import markedLinkifyIt from 'marked-linkify-it'; import markedKatex from 'marked-katex-extension'; import markedExtendedTables from '../../helpers/markedExtendedTables'; -// eslint-disable-next-line no-undef -const isTest = process?.env.NODE_ENV === 'test'; - export interface Props { message: Message; memori: Memori; @@ -116,10 +113,13 @@ const ChatBubble: React.FC = ({ .replace(/(
)+/g, '
'); useLayoutEffect(() => { - if (!isTest && typeof window !== 'undefined' && !message.fromUser) { + if (typeof window !== 'undefined' && !message.fromUser) { // @ts-ignore // eslint-disable-next-line no-undef - MathJax.typesetPromise(); + if ('MathJax' in window && window.MathJax.typesetPromise) + // @ts-ignore + // eslint-disable-next-line no-undef + window.MathJax.typesetPromise(); } }, [message.text, message.fromUser]);