Skip to content

Commit

Permalink
fix: fixup
Browse files Browse the repository at this point in the history
  • Loading branch information
nzambello committed Jun 6, 2024
1 parent 8eee08a commit 8be6b69
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
1 change: 1 addition & 0 deletions jest.setup.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,3 +83,4 @@ Object.defineProperty(window, 'MathJax', {
});

jest.spyOn(window, 'MathJax', 'typesetPromise').mockResolvedValue();
jest.spyOn(global.MathJax, 'typesetPromise').mockResolvedValue();
10 changes: 5 additions & 5 deletions src/components/ChatBubble/ChatBubble.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -116,10 +113,13 @@ const ChatBubble: React.FC<Props> = ({
.replace(/(<br>)+/g, '<br>');

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]);

Expand Down

0 comments on commit 8be6b69

Please sign in to comment.