Skip to content

Commit

Permalink
test(FluidSearchSkeleton): add test file for component (#17826)
Browse files Browse the repository at this point in the history
* test(FluidSearchSkeleton): add test file for component

* fix(FluidSearchSkeleton): corrected contributor file

Signed-off-by: Mariat Sebastian <[email protected]>

---------

Signed-off-by: Mariat Sebastian <[email protected]>
Co-authored-by: Alison Joseph <[email protected]>
  • Loading branch information
mariat189 and alisonjoseph authored Oct 23, 2024
1 parent b667bba commit b3e348b
Show file tree
Hide file tree
Showing 3 changed files with 65 additions and 0 deletions.
9 changes: 9 additions & 0 deletions .all-contributorsrc
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,9 @@ check out our [Contributing Guide](/.github/CONTRIBUTING.md) and our
<td align="center"><a href="https://github.com/soumyaraju"><img src="https://avatars.githubusercontent.com/u/41182657?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Soumya Raju</b></sub></a><br /><a href="https://github.com/carbon-design-system/carbon/commits?author=soumyaraju" title="Code">💻</a></td>
<td align="center"><a href="https://github.com/ziyadzulfikar"><img src="https://avatars.githubusercontent.com/u/56788667?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Ziyad Bin Sulfi</b></sub></a><br /><a href="https://github.com/carbon-design-system/carbon/commits?author=ziyadzulfikar" title="Code">💻</a></td>
</tr>
<tr>
<td align="center"><a href="https://github.com/mariat189"><img src="https://avatars.githubusercontent.com/u/74430463?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Mariat</b></sub></a><br /><a href="https://github.com/carbon-design-system/carbon/commits?author=mariat189" title="Code">💻</a></td>
</tr>
</table>

<!-- markdownlint-restore -->
Expand Down
Original file line number Diff line number Diff line change
@@ -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(
<FluidSearchSkeleton className="test-class" />
);

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(
<FluidSearchSkeleton className={customClass} />
);

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(
<FormContext.Provider value={{ isFluid: true }}>
<FluidSearchSkeleton />
<FormContext.Consumer>
{(value) => {
contextValue = value;
return null;
}}
</FormContext.Consumer>
</FormContext.Provider>
);
expect(contextValue.isFluid).toBe(true);
});
});

0 comments on commit b3e348b

Please sign in to comment.