Skip to content

Commit 65b0991

Browse files
committed
feat($linktag): Added test case for navigation links with custom tags
1 parent 06c9f3d commit 65b0991

File tree

2 files changed

+54
-0
lines changed

2 files changed

+54
-0
lines changed

__tests__/NavLink.js

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,3 +96,32 @@ test('isActive return false', () => {
9696

9797
expect(tree).toMatchSnapshot()
9898
})
99+
100+
it('supports custom HTML tag name', () => {
101+
const { tree, store } = createNavLink('/first', {
102+
to: '/second',
103+
activeClassName: 'active',
104+
tagName: 'div'
105+
}) /*? $.tree */
106+
107+
expect(tree).toMatchSnapshot()
108+
})
109+
110+
it('supports custom HTML tag name in active mode', () => {
111+
const { tree, store } = createNavLink('/first', {
112+
to: '/first',
113+
activeClassName: 'active',
114+
tagName: 'div'
115+
}) /*? $.tree */
116+
117+
expect(tree).toMatchSnapshot()
118+
})
119+
120+
it('supports custom HTML tag name which is still a link', () => {
121+
const { tree, store } = createNavLink('/first', {
122+
to: 'somewhere',
123+
tagName: 'a'
124+
}) /*? $.tree */
125+
126+
expect(tree).toMatchSnapshot()
127+
})

__tests__/__snapshots__/NavLink.js.snap

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,3 +147,28 @@ exports[`show activeStyle 1`] = `
147147
}
148148
/>
149149
`;
150+
151+
exports[`supports custom HTML tag name 1`] = `
152+
<div
153+
className={undefined}
154+
onClick={[Function]}
155+
style={undefined}
156+
/>
157+
`;
158+
159+
exports[`supports custom HTML tag name in active mode 1`] = `
160+
<div
161+
className="active"
162+
onClick={[Function]}
163+
style={Object {}}
164+
/>
165+
`;
166+
167+
exports[`supports custom HTML tag name which is still a link 1`] = `
168+
<a
169+
className={undefined}
170+
href="somewhere"
171+
onClick={[Function]}
172+
style={undefined}
173+
/>
174+
`;

0 commit comments

Comments
 (0)