Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add tel TextFieldTextType #1918

Merged
merged 2 commits into from
Jan 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/components/TextField/TextFieldConstants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ export enum TextFieldTextType {
DATE = "date",
DATE_TIME = "datetime-local",
NUMBER = "number",
TEL = "tel",
URL = "url",
EMAIL = "email"
}
Expand Down
11 changes: 11 additions & 0 deletions src/components/TextField/__tests__/TextField.jest.js
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,17 @@ describe("TextField Tests", () => {
expect(input.type).toBe(TextField.types.PASSWORD);
});

it("type should be tel", () => {
const { rerender } = inputComponent;
act(() => {
inputComponent = rerender(
<TextField placeholder={defaultPlaceHolder} onChange={onChangeStub} id="test" type={TextField.types.TEL} />
);
});
const input = screen.getByPlaceholderText(defaultPlaceHolder);
expect(input.type).toBe(TextField.types.TEL);
});

it("type should be url", () => {
const { rerender } = inputComponent;
act(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1236,6 +1236,68 @@ exports[`TextField renders correctly with showCharCount 1`] = `
</div>
`;

exports[`TextField renders correctly with tel type 1`] = `
<div
aria-busy={false}
className="textField"
role=""
>
<div
className="labelWrapper"
>
<div
className="inputWrapper wrapperSizeSmall"
>
<input
aria-activedescendant=""
aria-invalid={null}
aria-label=""
aria-owns=""
autoComplete="off"
className="input"
data-testid="text-field_input"
disabled={false}
id="input"
maxLength={null}
onBlur={[Function]}
onChange={[Function]}
onFocus={[Function]}
onKeyDown={[Function]}
onWheel={[Function]}
placeholder=""
readOnly={false}
required={false}
role=""
type="tel"
value=""
/>
<div
className="clickable iconContainer iconContainerActive disableTextSelection"
data-testid="clickable"
onClick={[Function]}
onKeyDown={[Function]}
onMouseDown={[Function]}
onMouseEnter={[Function]}
onMouseLeave={[Function]}
role="button"
tabIndex={-1}
/>
<div
className="clickable iconContainer iconContainerActive disableTextSelection"
data-testid="text-field-secondary-button_input"
onClick={[Function]}
onKeyDown={[Function]}
onMouseDown={[Function]}
onMouseEnter={[Function]}
onMouseLeave={[Function]}
role="button"
tabIndex={-1}
/>
</div>
</div>
</div>
`;

exports[`TextField renders correctly with url type 1`] = `
<div
aria-busy={false}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,11 @@ describe("TextField renders correctly", () => {
expect(tree).toMatchSnapshot();
});

it("with tel type", () => {
const tree = renderer.create(<TextField type={TextField.types.TEL} />).toJSON();
expect(tree).toMatchSnapshot();
});

it("with url type", () => {
const tree = renderer.create(<TextField type={TextField.types.URL} />).toJSON();
expect(tree).toMatchSnapshot();
Expand Down
Loading