File tree 2 files changed +17
-1
lines changed
packages/styleguide/src/components/Preview
2 files changed +17
-1
lines changed Original file line number Diff line number Diff line change @@ -211,6 +211,7 @@ export default class CodeExample extends React.Component {
211
211
< Code
212
212
inline = { false }
213
213
ref = { this . codeBlockRef }
214
+ data-testid = { this . state . codePreviewType }
214
215
language = {
215
216
this . state . codePreviewType === 'html'
216
217
? 'markup'
Original file line number Diff line number Diff line change 1
1
import React from 'react' ;
2
- import { render } from '@testing-library/react' ;
2
+ import { render , fireEvent } from '@testing-library/react' ;
3
3
4
4
import Preview from '.' ;
5
5
@@ -8,4 +8,19 @@ describe('rendering', () => {
8
8
const { getByText } = render ( < Preview > Preview</ Preview > ) ;
9
9
expect ( getByText ( 'Preview' ) ) . toBeInTheDocument ( ) ;
10
10
} ) ;
11
+
12
+ it ( 'HTML preview renders more than 1 child' , ( ) => {
13
+ const { getByText, getByTestId } = render (
14
+ < Preview >
15
+ < p > Paragraph 1</ p >
16
+ < p > Paragraph 2</ p >
17
+ </ Preview >
18
+ ) ;
19
+
20
+ fireEvent . click ( getByText ( 'SHOW CODE' ) ) ;
21
+
22
+ fireEvent . click ( getByText ( 'HTML' ) ) ;
23
+
24
+ expect ( getByTestId ( 'html' ) ) . toBeInTheDocument ( ) ;
25
+ } ) ;
11
26
} ) ;
You can’t perform that action at this time.
0 commit comments