File tree Expand file tree Collapse file tree 1 file changed +9
-2
lines changed
src/components/InteractiveTutorial/MdxComponents Expand file tree Collapse file tree 1 file changed +9
-2
lines changed Original file line number Diff line number Diff line change @@ -32,12 +32,19 @@ describe('CodeBlock', () => {
32
32
</ TutorialProvider >
33
33
) ;
34
34
35
- expect ( screen . getByTestId ( 'code-block' ) ) . toBeInTheDocument ( ) ;
35
+ const codeBlock = screen . getByTestId ( 'code-block' ) ;
36
+
37
+ expect ( codeBlock ) . toBeInTheDocument ( ) ;
36
38
expect ( screen . getByTestId ( 'code-block-pre' ) ) . toBeInTheDocument ( ) ;
37
39
expect ( screen . getByTestId ( 'code-block-run' ) ) . toBeInTheDocument ( ) ;
40
+
41
+ const textContent = codeBlock . textContent ;
42
+ const occurrences = ( textContent . match ( / " n a m e " : " t e s t " / g) || [ ] ) . length ;
43
+
38
44
expect ( screen . getAllByText ( / { / ) . length ) . toBe ( 2 ) ;
39
- expect ( screen . getAllByText ( / " n a m e " : " t e s t " / ) . length ) . toBe ( 2 ) ;
45
+ expect ( occurrences ) . toBe ( 2 ) ;
40
46
expect ( screen . getAllByText ( / } / ) . length ) . toBe ( 2 ) ;
47
+
41
48
expect ( screen . getByText ( / R u n / ) ) . toBeInTheDocument ( ) ;
42
49
} ) ;
43
50
You can’t perform that action at this time.
0 commit comments