Skip to content

Commit

Permalink
test: Achieve 100% Test Coverage and Fix Uncovered Lines
Browse files Browse the repository at this point in the history
- Improved the test coverage for the Loader component, addressing the previously uncovered lines and ensuring that all tests pass successfully.
- Added a test to ensure that the component renders correctly with a custom 'sm' size. I verified that both the spinner-wrapper and
  spinner elements are present and that the correct class is applied.
- Added a test to ensure that the component renders correctly with a 'lg' size. I verified that the spinner element has the appropriate class.
- Added a test to ensure that the component renders correctly with an 'xl' size. I verified that the spinner element has the correct class.

With these new tests, I now have 100% test coverage, and there are no more uncovered lines. The Loader component is thoroughly tested for
different size scenarios, and all tests pass successfully.

Signed-off-by: Akhilender <[email protected]>
  • Loading branch information
akhilender-bongirwar committed Nov 6, 2023
1 parent 0980326 commit fabde73
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions src/components/Loader/Loader.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,35 @@ describe('Testing Loader component', () => {
expect(screen.getByTestId('spinner-wrapper')).toBeInTheDocument();
expect(screen.getByTestId('spinner')).toBeInTheDocument();
});

test('Component should render on custom sizes', () => {
render(
<BrowserRouter>
<Loader size="sm" />
</BrowserRouter>
);

expect(screen.getByTestId('spinner-wrapper')).toBeInTheDocument();
expect(screen.getByTestId('spinner')).toBeInTheDocument();
expect(screen.getByTestId('spinner')).toHaveClass(
'_spinnerSm_1vy2z_21 spinner-border text-primary'
);
});

test('Component should render with large size', () => {
render(<Loader size="lg" />);
const spinner = screen.getByTestId('spinner');
expect(spinner).toHaveClass(
'_spinnerLg_1vy2z_15 spinner-border text-primary'
);
});

test('renders with extra-large size', () => {
render(<Loader size="xl" />);
const spinner = screen.getByTestId('spinner');

expect(spinner).toHaveClass(
'_spinnerXl_1vy2z_9 spinner-border text-primary'
);
});
});

0 comments on commit fabde73

Please sign in to comment.