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 email TextFieldTextType #1916

Merged
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
3 changes: 2 additions & 1 deletion src/components/TextField/TextFieldConstants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ export enum TextFieldTextType {
SEARCH = "search",
DATE = "date",
DATE_TIME = "datetime-local",
NUMBER = "number"
NUMBER = "number",
EMAIL = "email"
}

export enum TextFieldFeedbackState {
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 @@ -226,6 +226,17 @@ describe("TextField Tests", () => {
const input = screen.getByPlaceholderText(defaultPlaceHolder);
expect(input.type).toBe(TextField.types.PASSWORD);
});

it("type should be email", () => {
const { rerender } = inputComponent;
act(() => {
inputComponent = rerender(
<TextField placeholder={defaultPlaceHolder} onChange={onChangeStub} id="test" type={TextField.types.EMAIL} />
);
});
const input = screen.getByPlaceholderText(defaultPlaceHolder);
expect(input.type).toBe(TextField.types.EMAIL);
});
});
describe("autocomplete", () => {
it("should add autocomplete attr and set it to on", () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -587,6 +587,68 @@ exports[`TextField renders correctly with date-time type 1`] = `
</div>
`;

exports[`TextField renders correctly with email 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="email"
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 icon 1`] = `
<div
aria-busy={false}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,4 +109,9 @@ describe("TextField renders correctly", () => {
const tree = renderer.create(<TextField type={TextField.types.DATE_TIME} />).toJSON();
expect(tree).toMatchSnapshot();
});

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