-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: adding unit tests for ProgressIndicatorSkeleton (#17829)
* test: add unit tests for ProgressIndicatorSkeleton component Signed-off-by: Mariat Sebastian <[email protected]> * test: adding unit tests for ProgressIndicatorSkeleton --------- Signed-off-by: Mariat Sebastian <[email protected]>
- Loading branch information
Showing
1 changed file
with
50 additions
and
0 deletions.
There are no files selected for viewing
50 changes: 50 additions & 0 deletions
50
packages/react/src/components/ProgressIndicator/__tests__/ProgressIndicatorSkeleton-test.js
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,50 @@ | ||
/** | ||
* Copyright IBM Corp. 2024 | ||
* | ||
* This source code is licensed under the Apache-2.0 license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
|
||
import { ProgressIndicatorSkeleton } from '../ProgressIndicator.Skeleton'; | ||
import React from 'react'; | ||
import { render } from '@testing-library/react'; | ||
|
||
jest.mock('@carbon/icons-react', () => ({ | ||
CircleDash: () => <div>CircleDash</div>, | ||
})); | ||
|
||
describe('ProgressIndicatorSkeleton', () => { | ||
test('renders correctly with default properties', () => { | ||
const { container } = render(<ProgressIndicatorSkeleton />); | ||
|
||
expect(container.firstChild).toHaveClass('cds--progress cds--skeleton'); | ||
expect(container.firstChild).not.toHaveClass('cds--progress--vertical'); | ||
|
||
const steps = container.querySelectorAll('li'); | ||
expect(steps.length).toBe(4); | ||
|
||
steps.forEach((step) => { | ||
expect(step).toHaveClass( | ||
'cds--progress-step cds--progress-step--incomplete' | ||
); | ||
}); | ||
|
||
const circleDashComponents = container.querySelectorAll( | ||
'div.cds--progress-step-button' | ||
); | ||
expect(circleDashComponents.length).toBe(4); | ||
expect(circleDashComponents[0]).toHaveTextContent('CircleDash'); | ||
}); | ||
|
||
test('renders vertically when vertical prop is true', () => { | ||
const { container } = render(<ProgressIndicatorSkeleton vertical={true} />); | ||
expect(container.firstChild).toHaveClass('cds--progress--vertical'); | ||
}); | ||
|
||
test('applies custom className when provided', () => { | ||
const { container } = render( | ||
<ProgressIndicatorSkeleton className="custom-class" /> | ||
); | ||
expect(container.firstChild).toHaveClass('custom-class'); | ||
}); | ||
}); |