From b01706053d7570fdb561187c9b1da848c4951181 Mon Sep 17 00:00:00 2001 From: trean Date: Thu, 10 Oct 2024 19:18:31 +0200 Subject: [PATCH] fix MdxCodeBlock.test.jsx (#244) --- .../MdxComponents/MdxCodeBlock.test.jsx | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/components/InteractiveTutorial/MdxComponents/MdxCodeBlock.test.jsx b/src/components/InteractiveTutorial/MdxComponents/MdxCodeBlock.test.jsx index d472f21e..26c1c1af 100644 --- a/src/components/InteractiveTutorial/MdxComponents/MdxCodeBlock.test.jsx +++ b/src/components/InteractiveTutorial/MdxComponents/MdxCodeBlock.test.jsx @@ -32,12 +32,19 @@ describe('CodeBlock', () => { ); - expect(screen.getByTestId('code-block')).toBeInTheDocument(); + const codeBlock = screen.getByTestId('code-block'); + + expect(codeBlock).toBeInTheDocument(); expect(screen.getByTestId('code-block-pre')).toBeInTheDocument(); expect(screen.getByTestId('code-block-run')).toBeInTheDocument(); + + const textContent = codeBlock.textContent; + const occurrences = (textContent.match(/"name": "test"/g) || []).length; + expect(screen.getAllByText(/{/).length).toBe(2); - expect(screen.getAllByText(/"name": "test"/).length).toBe(2); + expect(occurrences).toBe(2); expect(screen.getAllByText(/}/).length).toBe(2); + expect(screen.getByText(/Run/)).toBeInTheDocument(); });