-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor(web-react): Remove useValidationText hook
- Removed useValidationText hook and implement ValidationText same way as HelperText component - Connected ValidationText with its input by aria-describedby
- Loading branch information
1 parent
7302bfd
commit f1d1d9e
Showing
10 changed files
with
93 additions
and
103 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
packages/web-react/src/components/Field/__tests__/HelperText.test.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import React from 'react'; | ||
import { render } from '@testing-library/react'; | ||
import '@testing-library/jest-dom'; | ||
import HelperText from '../HelperText'; | ||
|
||
describe('HelperText', () => { | ||
it('should render helper text', () => { | ||
const dom = render(<HelperText className="HelperText__helperText">Helper Text</HelperText>); | ||
|
||
const element = dom.container.querySelector('div') as HTMLElement; | ||
expect(element).not.toBeNull(); | ||
expect(element.textContent).toBe('Helper Text'); | ||
}); | ||
|
||
it('should render with custom element type', () => { | ||
const { container } = render(<HelperText elementType="span">Helper Text</HelperText>); | ||
|
||
const element = container.querySelector('span') as HTMLElement; | ||
expect(element).not.toBeNull(); | ||
expect(element.textContent).toBe('Helper Text'); | ||
}); | ||
|
||
it('should render with className and id', () => { | ||
const { container } = render( | ||
<HelperText className="test__helperText" id="test__helperTextId"> | ||
Helper Text | ||
</HelperText>, | ||
); | ||
|
||
const element = container.querySelector('.test__helperText') as HTMLElement; | ||
expect(element).not.toBeNull(); | ||
expect(element.getAttribute('id')).toBe('test__helperTextId'); | ||
expect(element.textContent).toBe('Helper Text'); | ||
}); | ||
}); |
28 changes: 0 additions & 28 deletions
28
packages/web-react/src/components/Field/__tests__/useValidationText.test.ts
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,5 @@ | ||
export * from './ValidationText'; | ||
export * from './HelperText'; | ||
export * from './useValidationText'; | ||
export * from './useAriaDescribedBy'; | ||
export { default as ValidationText } from './ValidationText'; | ||
export { default as HelperText } from './HelperText'; |
27 changes: 0 additions & 27 deletions
27
packages/web-react/src/components/Field/useValidationText.tsx
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters