Skip to content

Commit b017060

Browse files
authored
fix MdxCodeBlock.test.jsx (#244)
1 parent b7ea2b5 commit b017060

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

src/components/InteractiveTutorial/MdxComponents/MdxCodeBlock.test.jsx

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,19 @@ describe('CodeBlock', () => {
3232
</TutorialProvider>
3333
);
3434

35-
expect(screen.getByTestId('code-block')).toBeInTheDocument();
35+
const codeBlock = screen.getByTestId('code-block');
36+
37+
expect(codeBlock).toBeInTheDocument();
3638
expect(screen.getByTestId('code-block-pre')).toBeInTheDocument();
3739
expect(screen.getByTestId('code-block-run')).toBeInTheDocument();
40+
41+
const textContent = codeBlock.textContent;
42+
const occurrences = (textContent.match(/"name": "test"/g) || []).length;
43+
3844
expect(screen.getAllByText(/{/).length).toBe(2);
39-
expect(screen.getAllByText(/"name": "test"/).length).toBe(2);
45+
expect(occurrences).toBe(2);
4046
expect(screen.getAllByText(/}/).length).toBe(2);
47+
4148
expect(screen.getByText(/Run/)).toBeInTheDocument();
4249
});
4350

0 commit comments

Comments
 (0)