-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #136 from yaswanth-deriv/yaswanth/FEQ-1972_Added_t…
…est_for_loader_component [FEQ]Yaswanth/FEQ-1972 Added Test cases for Loader component
- Loading branch information
Showing
1 changed file
with
38 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,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'); | ||
}); | ||
}); |