Skip to content

Commit

Permalink
add test
Browse files Browse the repository at this point in the history
  • Loading branch information
jurajk committed Mar 3, 2020
1 parent 2050bf8 commit d177dde
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
1 change: 1 addition & 0 deletions packages/styleguide/src/components/Preview/CodeExample.js
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,7 @@ export default class CodeExample extends React.Component {
<Code
inline={false}
ref={this.codeBlockRef}
data-testid={this.state.codePreviewType}
language={
this.state.codePreviewType === 'html'
? 'markup'
Expand Down
17 changes: 16 additions & 1 deletion packages/styleguide/src/components/Preview/Preview.test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from 'react';
import { render } from '@testing-library/react';
import { render, fireEvent } from '@testing-library/react';

import Preview from '.';

Expand All @@ -8,4 +8,19 @@ describe('rendering', () => {
const { getByText } = render(<Preview>Preview</Preview>);
expect(getByText('Preview')).toBeInTheDocument();
});

it('HTML preview renders more than 1 child', () => {
const { getByText, getByTestId } = render(
<Preview>
<p>Paragraph 1</p>
<p>Paragraph 2</p>
</Preview>
);

fireEvent.click(getByText('SHOW CODE'));

fireEvent.click(getByText('HTML'));

expect(getByTestId('html')).toBeInTheDocument();
});
});

0 comments on commit d177dde

Please sign in to comment.