Skip to content

Commit

Permalink
added test
Browse files Browse the repository at this point in the history
  • Loading branch information
PatrikMatiasko committed Apr 20, 2024
1 parent 08d08ef commit f3f4764
Show file tree
Hide file tree
Showing 22 changed files with 725 additions and 2 deletions.
10 changes: 10 additions & 0 deletions src/components/Atomic/FloatingPanel/FloatingPanel.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { render } from '@testing-library/react'
import FloatingPanel from './FloatingPanel'

describe('<FloatingPanel>', () => {
it('renders without crashing', () => {
const { container, asFragment } = render(<FloatingPanel reference={<div>Reference</div>}>Test</FloatingPanel>)
expect(container).toBeInTheDocument()
expect(asFragment()).toMatchSnapshot()
})
})
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`<FloatingPanel> renders without crashing 1`] = `
<DocumentFragment>
.emotion-0 {
display: -webkit-box;
display: -webkit-flex;
display: -ms-flexbox;
display: flex;
-webkit-align-items: center;
-webkit-box-align: center;
-ms-flex-align: center;
align-items: center;
-webkit-transition: all 0.3s;
transition: all 0.3s;
cursor: pointer;
}
<div>
<span
class="emotion-0"
data-block-outside-click="true"
>
<div>
Reference
</div>
</span>
</div>
</DocumentFragment>
`;
20 changes: 20 additions & 0 deletions src/components/Atomic/FullPageLoader/FullPageLoader.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { render } from '@testing-library/react'
import FullPageLoader from './FullPageLoader'

describe('<FullPageLoader>', () => {
it('renders without crashing', () => {
const { container } = render(<FullPageLoader i18n={{ loading: 'Loading' }} />)
expect(container).toBeInTheDocument()
})

it('displays loading text', () => {
const { getByText } = render(<FullPageLoader i18n={{ loading: 'Loading' }} />)
expect(getByText('Loading...')).toBeInTheDocument()
})

it('applies auth-loader class to PageLoader', () => {
const { container } = render(<FullPageLoader i18n={{ loading: 'Loading' }} />)
const pageLoader = container.querySelector('.auth-loader')
expect(pageLoader).not.toBeNull()
})
})
17 changes: 17 additions & 0 deletions src/components/Atomic/Headline/Headline.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,21 @@ describe('<Headline>', () => {

expect(asFragment()).toMatchSnapshot()
})

it('renders correct text', () => {
const { getByText } = render(<Headline type='h1'>Test</Headline>)
expect(getByText('Test')).toBeInTheDocument()
})

it('applies correct class based on type', () => {
const { container } = render(<Headline type='h1'>Test</Headline>)
const headline = container.querySelector('h1')
expect(headline).toHaveClass('h1')
})

it('applies h6 style when type is h6', () => {
const { container } = render(<Headline type='h2'>Test</Headline>)
const headline = container.querySelector('h2')
expect(headline).toHaveClass('h2')
})
})
18 changes: 18 additions & 0 deletions src/components/Atomic/Icon/Icon.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { render, waitFor } from '@testing-library/react'
import Icon, { IconsRaw } from '../Icon'

describe('<Icon>', () => {
it('render correctly - snapshot', async () => {
const { asFragment } = render(
<div>
{IconsRaw.map((icon, index) => (
<Icon icon={icon} key={index} />
))}
</div>
)

await waitFor(() => {
expect(asFragment()).toMatchSnapshot()
})
})
})
Loading

0 comments on commit f3f4764

Please sign in to comment.