generated from ita-social-projects/DevTemplate
-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add specification files and snapshots (#647)
- Loading branch information
Showing
4 changed files
with
89 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import React from 'react'; | ||
import { render } from '@testing-library/react'; | ||
import { ILoadingContainerProps, LoadingContainer } from './LoadingContainer'; | ||
import { LoadingStatusEnum } from '../../types'; | ||
|
||
const PROPS_MOCK: ILoadingContainerProps = { | ||
loading: LoadingStatusEnum.idle, | ||
expand: false, | ||
}; | ||
|
||
describe('LoadingContainer', () => { | ||
it('should render correctly', () => { | ||
const { asFragment } = render( | ||
<LoadingContainer loading={PROPS_MOCK.loading} />, | ||
); | ||
|
||
expect(asFragment()).toMatchSnapshot(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import React from 'react'; | ||
import { render, screen } from '@testing-library/react'; | ||
import { LoadingInfo } from './LoadingInfo'; | ||
import { LoadingStatusEnum } from '../../types'; | ||
|
||
describe('LoadingInfo', () => { | ||
it('should render correctly when loading status is pending', () => { | ||
const { asFragment } = render( | ||
<LoadingInfo loading={LoadingStatusEnum.pending} />, | ||
); | ||
|
||
expect(asFragment()).toMatchSnapshot(); | ||
}); | ||
|
||
it('should display error message when loading status is failed', () => { | ||
render( | ||
<LoadingInfo loading={LoadingStatusEnum.failed} errorMsg="Test Error" />, | ||
); | ||
|
||
expect(screen.getByText('Test Error')).toMatchSnapshot(); | ||
}); | ||
|
||
it('should be empty when loading status is succeeded', () => { | ||
const { container } = render( | ||
<LoadingInfo loading={LoadingStatusEnum.succeeded} />, | ||
); | ||
|
||
expect(container).toBeEmptyDOMElement(); | ||
}); | ||
}); |
9 changes: 9 additions & 0 deletions
9
src/old/lib/components/Loading/__snapshots__/LoadingContainer.spec.tsx.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`LoadingContainer should render correctly 1`] = ` | ||
<DocumentFragment> | ||
<div | ||
class="MuiGrid-root LoadingContainer-container-2 MuiGrid-container" | ||
/> | ||
</DocumentFragment> | ||
`; |
31 changes: 31 additions & 0 deletions
31
src/old/lib/components/Loading/__snapshots__/LoadingInfo.spec.tsx.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`LoadingInfo should display error message when loading status is failed 1`] = ` | ||
<span> | ||
Test Error | ||
</span> | ||
`; | ||
|
||
exports[`LoadingInfo should render correctly when loading status is pending 1`] = ` | ||
<DocumentFragment> | ||
<div | ||
class="MuiCircularProgress-root MuiCircularProgress-colorPrimary MuiCircularProgress-indeterminate" | ||
role="progressbar" | ||
style="width: 40px; height: 40px;" | ||
> | ||
<svg | ||
class="MuiCircularProgress-svg" | ||
viewBox="22 22 44 44" | ||
> | ||
<circle | ||
class="MuiCircularProgress-circle MuiCircularProgress-circleIndeterminate" | ||
cx="44" | ||
cy="44" | ||
fill="none" | ||
r="20.2" | ||
stroke-width="3.6" | ||
/> | ||
</svg> | ||
</div> | ||
</DocumentFragment> | ||
`; |