chore(components): link tests added

This commit is contained in:
Junior Garcia 2022-10-03 11:59:58 -03:00
parent dfb2134caa
commit 7dd99944cf
3 changed files with 19 additions and 3 deletions

View File

@ -11,9 +11,25 @@ describe("Link", () => {
});
it("ref should be forwarded", () => {
const ref = React.createRef<HTMLDivElement>();
const ref = React.createRef<HTMLAnchorElement>();
render(<Link ref={ref} />);
expect(ref.current).not.toBeNull();
});
it("should be no errors when href missing", () => {
const wrapper = render(<Link>Link</Link>);
expect(() => wrapper.unmount()).not.toThrow();
});
it('should show a link icon when "isExternal" is true', () => {
const wrapper = render(
<Link isExternal href="#">
Link
</Link>,
);
expect(wrapper.container.querySelector("svg")).not.toBeNull();
});
});

View File

@ -32,7 +32,7 @@ export const StyledLink = styled(
},
animated: {
true: {
transition: "opacity 0.25s ease 0s, background 0.25s ease 0s",
transition: "opacity 0.2s ease 0s, background 0.2s ease 0s",
},
},
},

View File

@ -18,7 +18,7 @@ interface ILinkAria {
isPressed: boolean;
}
const Link = forwardRef<LinkProps, "div">((props, ref) => {
const Link = forwardRef<LinkProps, "a">((props, ref) => {
const {children, as, css, linkCss, isExternal, focusProps, className, ...otherProps} =
useLink(props);