From f4f3dfe031937c743336176ad3f7598eb528a110 Mon Sep 17 00:00:00 2001 From: IRFAD KP Date: Sat, 26 Oct 2024 00:13:27 +0530 Subject: [PATCH] Fluid number input skeleton unit test (#17819) * test: add unit test for FluidNumberInputSkeleton * test: updated contributor list * fix: rename FluidNumberInputSkeleton-test.js for correct file name Signed-off-by: IRFAD K P * fix: corrected .all-contributorsrc --------- Signed-off-by: IRFAD K P Co-authored-by: IRFAD K P Co-authored-by: Alison Joseph --- .all-contributorsrc | 9 ++++ README.md | 3 +- .../FluidNumberInputSkeleton-test.js | 43 +++++++++++++++++++ 3 files changed, 54 insertions(+), 1 deletion(-) create mode 100644 packages/react/src/components/FluidNumberInput/__tests__/FluidNumberInputSkeleton-test.js diff --git a/.all-contributorsrc b/.all-contributorsrc index 1fdc5a0bf7db..1ce696a1c242 100644 --- a/.all-contributorsrc +++ b/.all-contributorsrc @@ -1653,6 +1653,15 @@ "code" ] }, + { + "login": "irfadkp", + "name": "IRFAD KP", + "avatar_url": "https://avatars.githubusercontent.com/u/54243898?v=4", + "profile": "https://irfadkp.github.io/", + "contributions": [ + "code" + ] + }, { "login": "ziyadzulfikar", "name": "ziyadzulfikar", diff --git a/README.md b/README.md index 122a92b21652..1a17c19745c6 100644 --- a/README.md +++ b/README.md @@ -309,10 +309,11 @@ check out our [Contributing Guide](/.github/CONTRIBUTING.md) and our
Noah Sgorbati

💻 📖
Divya G

💻
Soumya Raju

💻 -
ziyadzulfikar

💻
IRFAD KP

💻 +
Ziyad Bin Sulfi

💻 +
IRFAD KP

💻
Mariat

💻 diff --git a/packages/react/src/components/FluidNumberInput/__tests__/FluidNumberInputSkeleton-test.js b/packages/react/src/components/FluidNumberInput/__tests__/FluidNumberInputSkeleton-test.js new file mode 100644 index 000000000000..11cdcb166830 --- /dev/null +++ b/packages/react/src/components/FluidNumberInput/__tests__/FluidNumberInputSkeleton-test.js @@ -0,0 +1,43 @@ +/** + * 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 { render, screen } from '@testing-library/react'; + +import FluidNumberInputSkeleton from '../FluidNumberInput.Skeleton'; +import React from 'react'; + +describe('FluidNumberInputSkeleton', () => { + it('should render with the appropriate skeleton classes', () => { + const { container } = render(); + + const skeletonWrapper = container.firstChild; + expect(skeletonWrapper).toHaveClass( + 'cds--form-item', + 'cds--text-input--fluid__skeleton' + ); + + const labelSkeleton = container.querySelector('.cds--label.cds--skeleton'); + expect(labelSkeleton).toBeInTheDocument(); + + const inputSkeleton = container.querySelector( + '.cds--skeleton.cds--text-input' + ); + expect(inputSkeleton).toBeInTheDocument(); + }); + + it('should apply custom className to the outermost element', () => { + const { container } = render( + + ); + expect(container.firstChild).toHaveClass('custom-class'); + }); + + it('should spread extra props onto the outermost element', () => { + render(); + expect(screen.getByTestId('test-skeleton')).toBeInTheDocument(); + }); +});