Skip to content

Commit d6b79c8

Browse files
authored
Updated router link stub to match actual router-link interface (#1840)
* Added new router link property, and updated docs * added exactPathActiveClass property to a router link stub
1 parent 085bac2 commit d6b79c8

File tree

6 files changed

+14
-6
lines changed

6 files changed

+14
-6
lines changed

docs/api/components/RouterLinkStub.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,5 @@ const wrapper = mount(Component, {
1616
RouterLink: RouterLinkStub
1717
}
1818
})
19-
expect(wrapper.find(RouterLinkStub).props().to).toBe('/some/path')
19+
expect(wrapper.findComponent(RouterLinkStub).props().to).toBe('/some/path')
2020
```

docs/ja/api/components/RouterLinkStub.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,5 @@ const wrapper = mount(Component, {
1616
RouterLink: RouterLinkStub
1717
}
1818
})
19-
expect(wrapper.find(RouterLinkStub).props().to).toBe('/some/path')
19+
expect(wrapper.findComponent(RouterLinkStub).props().to).toBe('/some/path')
2020
```

docs/ru/api/components/RouterLinkStub.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,5 @@ const wrapper = mount(Component, {
1616
RouterLink: RouterLinkStub
1717
}
1818
})
19-
expect(wrapper.find(RouterLinkStub).props().to).toBe('/some/path')
19+
expect(wrapper.findComponent(RouterLinkStub).props().to).toBe('/some/path')
2020
```

docs/zh/api/components/RouterLinkStub.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,5 @@ const wrapper = mount(Component, {
1616
RouterLink: RouterLinkStub
1717
}
1818
})
19-
expect(wrapper.find(RouterLinkStub).props().to).toBe('/some/path')
19+
expect(wrapper.findComponent(RouterLinkStub).props().to).toBe('/some/path')
2020
```

packages/test-utils/src/components/RouterLinkStub.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,12 @@ export default {
1414
default: 'a'
1515
},
1616
exact: Boolean,
17+
exactPath: Boolean,
1718
append: Boolean,
1819
replace: Boolean,
1920
activeClass: String,
2021
exactActiveClass: String,
22+
exactPathActiveClass: String,
2123
event: {
2224
type: eventTypes,
2325
default: 'click'

test/specs/components/RouterLink.spec.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,9 @@ describeWithShallowAndMount('RouterLinkStub', mountingMethod => {
1212
activeClass="activeClass1"
1313
exactActiveClass="exactActiveClass1"
1414
event="event1"
15+
exact-path-active-class="exact-path-active-class"
1516
exact
17+
exact-path
1618
append
1719
replace
1820
/>
@@ -25,14 +27,18 @@ describeWithShallowAndMount('RouterLinkStub', mountingMethod => {
2527
}
2628
})
2729

28-
const routerLink = wrapper.find(RouterLinkStub)
30+
const routerLink = wrapper.getComponent(RouterLinkStub)
2931
expect(routerLink.props().to).toEqual('to1')
3032
expect(routerLink.props().tag).toEqual('a')
3133
expect(routerLink.props().exact).toEqual(true)
34+
expect(routerLink.props().exactPath).toEqual(true)
3235
expect(routerLink.props().append).toEqual(true)
3336
expect(routerLink.props().replace).toEqual(true)
3437
expect(routerLink.props().activeClass).toEqual('activeClass1')
3538
expect(routerLink.props().exactActiveClass).toEqual('exactActiveClass1')
39+
expect(routerLink.props().exactPathActiveClass).toEqual(
40+
'exact-path-active-class'
41+
)
3642
expect(routerLink.props().event).toEqual('event1')
3743
})
3844

@@ -49,6 +55,6 @@ describeWithShallowAndMount('RouterLinkStub', mountingMethod => {
4955
RouterLink: RouterLinkStub
5056
}
5157
})
52-
expect(wrapper.find(RouterLinkStub).text()).toEqual('some text')
58+
expect(wrapper.getComponent(RouterLinkStub).text()).toEqual('some text')
5359
})
5460
})

0 commit comments

Comments
 (0)