From b3e348ba233034ff71e7b97351082d0297b69bd6 Mon Sep 17 00:00:00 2001 From: Mariat Date: Wed, 23 Oct 2024 23:21:43 +0530 Subject: [PATCH] test(FluidSearchSkeleton): add test file for component (#17826) * test(FluidSearchSkeleton): add test file for component * fix(FluidSearchSkeleton): corrected contributor file Signed-off-by: Mariat Sebastian --------- Signed-off-by: Mariat Sebastian Co-authored-by: Alison Joseph --- .all-contributorsrc | 9 ++++ README.md | 3 ++ .../__tests__/FluidSearchSkeleton-test.js | 53 +++++++++++++++++++ 3 files changed, 65 insertions(+) create mode 100644 packages/react/src/components/FluidSearch/__tests__/FluidSearchSkeleton-test.js diff --git a/.all-contributorsrc b/.all-contributorsrc index 426ad0ba76c7..076e56e06ff7 100644 --- a/.all-contributorsrc +++ b/.all-contributorsrc @@ -1662,6 +1662,15 @@ "code" ] }, + { + "login": "mariat189", + "name": "Mariat", + "avatar_url": "https://avatars.githubusercontent.com/u/74430463?v=4", + "profile": "https://github.com/mariat189", + "contributions": [ + "code" + ] + } ], "commitConvention": "none" } diff --git a/README.md b/README.md index 0e8c0a950c9a..8110558a92cb 100644 --- a/README.md +++ b/README.md @@ -311,6 +311,9 @@ check out our [Contributing Guide](/.github/CONTRIBUTING.md) and our
Soumya Raju

💻
Ziyad Bin Sulfi

💻 + +
Mariat

💻 + diff --git a/packages/react/src/components/FluidSearch/__tests__/FluidSearchSkeleton-test.js b/packages/react/src/components/FluidSearch/__tests__/FluidSearchSkeleton-test.js new file mode 100644 index 000000000000..5c4bed44ab3a --- /dev/null +++ b/packages/react/src/components/FluidSearch/__tests__/FluidSearchSkeleton-test.js @@ -0,0 +1,53 @@ +/** + * 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 FluidSearchSkeleton from '../FluidSearch.Skeleton'; +import { FormContext } from '../../FluidForm/FormContext'; +import React from 'react'; +import { render } from '@testing-library/react'; + +const prefix = 'cds'; + +describe('FluidSearchSkeleton', () => { + it('should render as expected', () => { + const { container } = render( + + ); + + expect(container.firstChild).toHaveClass( + `${prefix}--text-input--fluid__skeleton ${prefix}--form-item` + ); + }); + + it('should apply additional custom class names if provided', () => { + const customClass = 'test-class'; + const { container } = render( + + ); + + expect(container.firstChild).toHaveClass( + `${prefix}--form-item ${prefix}--text-input--fluid__skeleton` + ); + expect(container.firstChild).toHaveClass(customClass); + }); + it('provides "isFluid" context value as true', () => { + let contextValue; + + render( + + + + {(value) => { + contextValue = value; + return null; + }} + + + ); + expect(contextValue.isFluid).toBe(true); + }); +});