From 706c84a1ae86af4c0220f5733455dd91486110f1 Mon Sep 17 00:00:00 2001 From: Mariat Date: Mon, 28 Oct 2024 18:40:20 +0530 Subject: [PATCH] test: adding unit tests for ProgressIndicatorSkeleton (#17829) * test: add unit tests for ProgressIndicatorSkeleton component Signed-off-by: Mariat Sebastian * test: adding unit tests for ProgressIndicatorSkeleton --------- Signed-off-by: Mariat Sebastian --- .../ProgressIndicatorSkeleton-test.js | 50 +++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 packages/react/src/components/ProgressIndicator/__tests__/ProgressIndicatorSkeleton-test.js diff --git a/packages/react/src/components/ProgressIndicator/__tests__/ProgressIndicatorSkeleton-test.js b/packages/react/src/components/ProgressIndicator/__tests__/ProgressIndicatorSkeleton-test.js new file mode 100644 index 000000000000..9c41f95d78c6 --- /dev/null +++ b/packages/react/src/components/ProgressIndicator/__tests__/ProgressIndicatorSkeleton-test.js @@ -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: () =>
CircleDash
, +})); + +describe('ProgressIndicatorSkeleton', () => { + test('renders correctly with default properties', () => { + const { container } = render(); + + 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(); + expect(container.firstChild).toHaveClass('cds--progress--vertical'); + }); + + test('applies custom className when provided', () => { + const { container } = render( + + ); + expect(container.firstChild).toHaveClass('custom-class'); + }); +});