Skip to content

Commit

Permalink
Add specification files and snapshots (#647)
Browse files Browse the repository at this point in the history
  • Loading branch information
niksonax authored Nov 5, 2021
1 parent f888c21 commit 2765279
Show file tree
Hide file tree
Showing 4 changed files with 89 additions and 0 deletions.
19 changes: 19 additions & 0 deletions src/old/lib/components/Loading/LoadingContainer.spec.tsx
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();
});
});
30 changes: 30 additions & 0 deletions src/old/lib/components/Loading/LoadingInfo.spec.tsx
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();
});
});
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>
`;
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>
`;

0 comments on commit 2765279

Please sign in to comment.