Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/prism/src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export interface ThemeUIPrismProps
}
export default function ThemeUIPrism({
children,
className: outerClassName,
className: outerClassName = '',
...props
}: ThemeUIPrismProps) {
const [language] = outerClassName.replace(/language-/, '').split(' ')
Expand Down
17 changes: 17 additions & 0 deletions packages/prism/test/__snapshots__/index.tsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,23 @@ exports[`renders a code block 1`] = `
</pre>
`;

exports[`renders with no className 1`] = `
<pre
className=" prism-code language- emotion-0"
style={Object {}}
>
<div
className="token-line"
>
<span
className="token plain"
>
&lt;h1&gt;Hello&lt;/h1&gt;
</span>
</div>
</pre>
`;

exports[`renders with other languages 1`] = `
<pre
className="language-php prism-code language-php emotion-0"
Expand Down
5 changes: 5 additions & 0 deletions packages/prism/test/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@ test('renders a code block', () => {
expect(result).toMatchSnapshot()
})

test('renders with no className', () => {
const json = render(<Prism children="<h1>Hello</h1>" />)
expect(json).toMatchSnapshot()
})

test('renders with other languages', () => {
const json = render(
<Prism className="language-php" children="<h1>Hello</h1>" />
Expand Down