Skip to content

Commit

Permalink
Merge pull request #136 from yaswanth-deriv/yaswanth/FEQ-1972_Added_t…
Browse files Browse the repository at this point in the history
…est_for_loader_component

[FEQ]Yaswanth/FEQ-1972 Added Test cases for Loader component
  • Loading branch information
shayan-deriv authored Mar 25, 2024
2 parents 39c63cc + 62d9d5c commit 72a545c
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions src/components/Loader/__test__/Loader.spec.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import React from 'react';
import { render } from '@testing-library/react';
import { Loader } from '..';

describe('Loader component', () => {
it('renders with default props', () => {
const { getByTestId } = render(<Loader />);
const loader = getByTestId('dt_derivs-loader');
expect(loader).toBeInTheDocument();
expect(loader).toHaveClass('derivs-loader');
expect(loader).toHaveClass('derivs-loader--fullscreen');
const loaderElements = loader.querySelectorAll('.derivs-loader__element');
loaderElements.forEach(element => {
expect(element).toHaveStyle({ backgroundColor: '#85ACB0' });
});
});

it('renders with custom color', () => {
const { getByTestId } = render(<Loader color="#FF0000" />);
const loader = getByTestId('dt_derivs-loader');
const loaderElements = loader.querySelectorAll('.derivs-loader__element');
loaderElements.forEach(element => {
expect(element).toHaveStyle({ backgroundColor: '#FF0000' });
});
});

it('renders without full screen class when isFullScreen is false', () => {
const { getByTestId } = render(<Loader isFullScreen={false} />);
const loader = getByTestId('dt_derivs-loader');
expect(loader).not.toHaveClass('derivs-loader--fullscreen');
});

it('renders with custom className', () => {
const { getByTestId } = render(<Loader className="custom-loader" />);
const loader = getByTestId('dt_derivs-loader');
expect(loader).toHaveClass('custom-loader');
});
});

0 comments on commit 72a545c

Please sign in to comment.