Skip to content

Commit

Permalink
test: add inline snapshot tests for react (#5217)
Browse files Browse the repository at this point in the history
  • Loading branch information
sheremet-va committed Feb 16, 2024
1 parent 1aecd65 commit 2ef5e3f
Show file tree
Hide file tree
Showing 2 changed files with 65 additions and 0 deletions.
36 changes: 36 additions & 0 deletions examples/react-testing-lib/src/components/Spinner.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import React from 'react'
import { render } from '@testing-library/react'
import { Spinner } from './Spinner.js'

test('Spinner renders correctly', () => {
const { container } = render(
<Spinner />,
)
expect(container).toMatchInlineSnapshot(`
<div>
<svg
class="currentColor -ml-1 mr-3 h-5 w-5 animate-spin"
fill="none"
viewBox="0 0 24 24"
xmlns="http://www.w3.org/2000/svg"
>
<title>
Loading spinner
</title>
<circle
class="opacity-25"
cx="12"
cy="12"
r="10"
stroke="currentColor"
stroke-width="4"
/>
<path
class="opacity-75"
d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"
fill="currentColor"
/>
</svg>
</div>
`)
})
29 changes: 29 additions & 0 deletions examples/react-testing-lib/src/components/Spinner.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import React from 'react'

export function Spinner() {
return (
<svg
className="currentColor -ml-1 mr-3 h-5 w-5 animate-spin"
fill="none"
viewBox="0 0 24 24"
xmlns="http://www.w3.org/2000/svg"
>
<title>Loading spinner</title>
<circle
className="opacity-25"
cx="12"
cy="12"
r="10"
stroke="currentColor"
strokeWidth="4"
>
</circle>
<path
className="opacity-75"
d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"
fill="currentColor"
>
</path>
</svg>
)
}

0 comments on commit 2ef5e3f

Please sign in to comment.