From 2765279fa6e91b84bb987afc5a743d9028355369 Mon Sep 17 00:00:00 2001 From: Nikita <47755204+niksonax@users.noreply.github.com> Date: Fri, 5 Nov 2021 18:37:55 +0200 Subject: [PATCH] Add specification files and snapshots (#647) --- .../Loading/LoadingContainer.spec.tsx | 19 ++++++++++++ .../components/Loading/LoadingInfo.spec.tsx | 30 ++++++++++++++++++ .../LoadingContainer.spec.tsx.snap | 9 ++++++ .../__snapshots__/LoadingInfo.spec.tsx.snap | 31 +++++++++++++++++++ 4 files changed, 89 insertions(+) create mode 100644 src/old/lib/components/Loading/LoadingContainer.spec.tsx create mode 100644 src/old/lib/components/Loading/LoadingInfo.spec.tsx create mode 100644 src/old/lib/components/Loading/__snapshots__/LoadingContainer.spec.tsx.snap create mode 100644 src/old/lib/components/Loading/__snapshots__/LoadingInfo.spec.tsx.snap diff --git a/src/old/lib/components/Loading/LoadingContainer.spec.tsx b/src/old/lib/components/Loading/LoadingContainer.spec.tsx new file mode 100644 index 000000000..d9769d3b7 --- /dev/null +++ b/src/old/lib/components/Loading/LoadingContainer.spec.tsx @@ -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( + , + ); + + expect(asFragment()).toMatchSnapshot(); + }); +}); diff --git a/src/old/lib/components/Loading/LoadingInfo.spec.tsx b/src/old/lib/components/Loading/LoadingInfo.spec.tsx new file mode 100644 index 000000000..092efeff2 --- /dev/null +++ b/src/old/lib/components/Loading/LoadingInfo.spec.tsx @@ -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( + , + ); + + expect(asFragment()).toMatchSnapshot(); + }); + + it('should display error message when loading status is failed', () => { + render( + , + ); + + expect(screen.getByText('Test Error')).toMatchSnapshot(); + }); + + it('should be empty when loading status is succeeded', () => { + const { container } = render( + , + ); + + expect(container).toBeEmptyDOMElement(); + }); +}); diff --git a/src/old/lib/components/Loading/__snapshots__/LoadingContainer.spec.tsx.snap b/src/old/lib/components/Loading/__snapshots__/LoadingContainer.spec.tsx.snap new file mode 100644 index 000000000..0919bb3a1 --- /dev/null +++ b/src/old/lib/components/Loading/__snapshots__/LoadingContainer.spec.tsx.snap @@ -0,0 +1,9 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`LoadingContainer should render correctly 1`] = ` + +
+ +`; diff --git a/src/old/lib/components/Loading/__snapshots__/LoadingInfo.spec.tsx.snap b/src/old/lib/components/Loading/__snapshots__/LoadingInfo.spec.tsx.snap new file mode 100644 index 000000000..61aee4806 --- /dev/null +++ b/src/old/lib/components/Loading/__snapshots__/LoadingInfo.spec.tsx.snap @@ -0,0 +1,31 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`LoadingInfo should display error message when loading status is failed 1`] = ` + + Test Error + +`; + +exports[`LoadingInfo should render correctly when loading status is pending 1`] = ` + +
+ + + +
+
+`;