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(); });