Skip to content

Commit

Permalink
fix(Password): 更新隐藏/显示Icons (#2084)
Browse files Browse the repository at this point in the history
* fix(Password): 更新隐藏/显示Icons

* test(Password): update Password UT

Co-authored-by: Zhang Rui <zhangrui@growingio.com>
  • Loading branch information
Ryan Zhang and Zhang Rui committed Jul 28, 2022
1 parent edc525b commit 9f22b2b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 12 deletions.
4 changes: 2 additions & 2 deletions src/input/Password.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ const Password = React.forwardRef<HTMLInputElement, PasswordProps>((props, ref)
const passwordSuffix = useMemo(
() =>
visible ? (
<EyeSlashOutlined className={passwordSuffixIconCls} onClick={toggleVisible} />
) : (
<EyeOutlined className={passwordSuffixIconCls} onClick={toggleVisible} />
) : (
<EyeSlashOutlined className={passwordSuffixIconCls} onClick={toggleVisible} />
),
[passwordSuffixIconCls, toggleVisible, visible]
);
Expand Down
19 changes: 9 additions & 10 deletions src/input/__tests__/Password.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,22 @@ describe('testing password', () => {
const { container } = render(<Password defaultValue="111" />);
expect(screen.getByTestId('input-password')).toBeTruthy();
expect(container.querySelector('input[type="password"]')).toBeTruthy();
expect(container.querySelector('input[type="password"]').getAttribute('value')).toBe('111')
expect(container.querySelector('input[type="password"]').getAttribute('value')).toBe('111');
});
it('should change type when click password Suffix icon ', () => {
const { container } = render(<Password defaultValue="111" />);
expect(container.querySelector('span[aria-label="eye-outlined"]')).toBeTruthy();
expect(container.querySelector('span[aria-label="eye-slash-outlined"]')).toBeFalsy();
expect(container.querySelector('span[aria-label="eye-slash-outlined"]')).toBeTruthy();
expect(container.querySelector('span[aria-label="eye-outlined"]')).toBeFalsy();
expect(container.querySelector('input[type="password"]')).toBeTruthy();
fireEvent.click(container.querySelector('span[aria-label="eye-outlined"]'));
fireEvent.click(container.querySelector('span[aria-label="eye-slash-outlined"]'));
expect(container.querySelector('input[type="password"]')).toBeFalsy();
expect(container.querySelector('span[aria-label="eye-outlined"]')).toBeFalsy();
expect(container.querySelector('span[aria-label="eye-slash-outlined"]')).toBeTruthy();
expect(container.querySelector('span[aria-label="eye-slash-outlined"]')).toBeFalsy();
expect(container.querySelector('span[aria-label="eye-outlined"]')).toBeTruthy();
});
it('should not change type when password set disabled ', () => {
const { container } = render(<Password defaultValue="111" disabled />);

fireEvent.click(container.querySelector('span[aria-label="eye-outlined"]'));
fireEvent.click(container.querySelector('span[aria-label="eye-slash-outlined"]'));
expect(container.querySelector('input[type="password"]')).toBeTruthy();

})
})
});
});

1 comment on commit 9f22b2b

@vercel
Copy link

@vercel vercel bot commented on 9f22b2b Jul 28, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

gio-design – ./

gio-design.vercel.app
gio-design-growingio.vercel.app
gio-design-git-master-growingio.vercel.app

Please sign in to comment.