Skip to content

Commit b56c970

Browse files
Adds NextLink legacyBehavior test (#1959)
1 parent a579f5e commit b56c970

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

packages/button/src/Button/Button.spec.tsx

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,24 @@ describe('packages/button', () => {
146146
test(`renders a when passing in a NextJS Link wrapper`, () => {
147147
// eslint-disable-next-line react/prop-types
148148
const Linker = ({ href, children, ...props }: any) => (
149-
<NextLink href={href}>
149+
<NextLink href={href} {...props}>
150+
{children}
151+
</NextLink>
152+
);
153+
154+
const { container, button } = renderButton({
155+
href: 'https://mongodb.design',
156+
as: Linker,
157+
});
158+
159+
expect(container.querySelector('button')).not.toBeInTheDocument();
160+
expect(button.tagName.toLowerCase()).toBe('a');
161+
});
162+
163+
test(`renders a when passing in a legacy NextJS Link wrapper`, () => {
164+
// eslint-disable-next-line react/prop-types
165+
const Linker = ({ href, children, ...props }: any) => (
166+
<NextLink legacyBehavior href={href}>
150167
<a {...props}>{children}</a>
151168
</NextLink>
152169
);

0 commit comments

Comments
 (0)