Skip to content

Commit 0898ba5

Browse files
PR #2039 adjustments (#2046)
* Added unit tests * Updated CHANGELOG
1 parent 0c0ae9a commit 0898ba5

File tree

3 files changed

+28
-2
lines changed

3 files changed

+28
-2
lines changed

CHANGELOG.md

+5-1
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,13 @@ Our versioning strategy is as follows:
1111

1212
## Unreleased
1313

14+
### 🎉 New Features & Improvements
15+
16+
* `[sitecore-jss-nextjs]` Link component supports prefetch property ([#2039](https://github.com/Sitecore/jss/pull/2039))([#2046](https://github.com/Sitecore/jss/pull/2046))
17+
1418
### 🐛 Bug Fixes
1519

16-
* `[templates/nextjs-sxa]`Fixed unsafe property access by replacing direct calls with optional chaining ([#2035](https://github.com/Sitecore/jss/pull/2035))
20+
* `[templates/nextjs-sxa]` Fixed unsafe property access by replacing direct calls with optional chaining ([#2035](https://github.com/Sitecore/jss/pull/2035))
1721

1822
## 22.5.0
1923

packages/sitecore-jss-nextjs/src/components/Link.test.tsx

+22
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,28 @@ describe('<Link />', () => {
165165
expect(c.find(ReactLink).length).to.equal(0);
166166
});
167167

168+
it('should render with prefetch prop provided', () => {
169+
const field = {
170+
href: '/lorem',
171+
text: 'ipsum',
172+
};
173+
const c = mount(
174+
<Page>
175+
<Link field={field} prefetch={false} />
176+
</Page>
177+
);
178+
179+
const link = c.find('a');
180+
181+
expect(link.html()).to.contain(field.href);
182+
expect(link.html()).to.contain(field.text);
183+
184+
expect(c.find(NextLink).length).to.equal(1);
185+
expect(c.find(ReactLink).length).to.equal(0);
186+
187+
expect(c.find(NextLink).props().prefetch).to.equal(false);
188+
});
189+
168190
it('should render other attributes with other props provided', () => {
169191
const field = {
170192
value: {

packages/sitecore-jss-nextjs/src/components/Link.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ export type LinkProps = ReactLinkProps & {
1818
internalLinkMatcher?: RegExp;
1919

2020
/**
21-
* Support next/link's prefetch prop.
21+
* Next.js Link prefetch.
2222
*/
2323
prefetch?: NextLinkProps['prefetch'];
2424
};

0 commit comments

Comments
 (0)