Skip to content

Commit

Permalink
fix MdxCodeBlock.test.jsx (#244)
Browse files Browse the repository at this point in the history
  • Loading branch information
trean authored Oct 10, 2024
1 parent b7ea2b5 commit b017060
Showing 1 changed file with 9 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,19 @@ describe('CodeBlock', () => {
</TutorialProvider>
);

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

Expand Down

0 comments on commit b017060

Please sign in to comment.