Skip to content

Commit

Permalink
test: adding unit tests for ProgressIndicatorSkeleton (#17829)
Browse files Browse the repository at this point in the history
* 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
mariat189 authored Oct 28, 2024
1 parent 03805a5 commit 706c84a
Showing 1 changed file with 50 additions and 0 deletions.
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');
});
});

0 comments on commit 706c84a

Please sign in to comment.