Skip to content

Commit

Permalink
feat: add email TextFieldTextType (#1916)
Browse files Browse the repository at this point in the history
  • Loading branch information
or-nuri-monday authored Jan 25, 2024
1 parent 9ae7f00 commit 6bfda79
Show file tree
Hide file tree
Showing 4 changed files with 80 additions and 1 deletion.
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();
});
});

0 comments on commit 6bfda79

Please sign in to comment.