Skip to content

Commit

Permalink
Updated router link stub to match actual router-link interface (#1840)
Browse files Browse the repository at this point in the history
* Added new router link property, and updated docs

* added exactPathActiveClass property to a router link stub
  • Loading branch information
Th3Un1q3 committed May 9, 2021
1 parent 085bac2 commit d6b79c8
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 6 deletions.
2 changes: 1 addition & 1 deletion docs/api/components/RouterLinkStub.md
Expand Up @@ -16,5 +16,5 @@ const wrapper = mount(Component, {
RouterLink: RouterLinkStub
}
})
expect(wrapper.find(RouterLinkStub).props().to).toBe('/some/path')
expect(wrapper.findComponent(RouterLinkStub).props().to).toBe('/some/path')
```
2 changes: 1 addition & 1 deletion docs/ja/api/components/RouterLinkStub.md
Expand Up @@ -16,5 +16,5 @@ const wrapper = mount(Component, {
RouterLink: RouterLinkStub
}
})
expect(wrapper.find(RouterLinkStub).props().to).toBe('/some/path')
expect(wrapper.findComponent(RouterLinkStub).props().to).toBe('/some/path')
```
2 changes: 1 addition & 1 deletion docs/ru/api/components/RouterLinkStub.md
Expand Up @@ -16,5 +16,5 @@ const wrapper = mount(Component, {
RouterLink: RouterLinkStub
}
})
expect(wrapper.find(RouterLinkStub).props().to).toBe('/some/path')
expect(wrapper.findComponent(RouterLinkStub).props().to).toBe('/some/path')
```
2 changes: 1 addition & 1 deletion docs/zh/api/components/RouterLinkStub.md
Expand Up @@ -16,5 +16,5 @@ const wrapper = mount(Component, {
RouterLink: RouterLinkStub
}
})
expect(wrapper.find(RouterLinkStub).props().to).toBe('/some/path')
expect(wrapper.findComponent(RouterLinkStub).props().to).toBe('/some/path')
```
2 changes: 2 additions & 0 deletions packages/test-utils/src/components/RouterLinkStub.js
Expand Up @@ -14,10 +14,12 @@ export default {
default: 'a'
},
exact: Boolean,
exactPath: Boolean,
append: Boolean,
replace: Boolean,
activeClass: String,
exactActiveClass: String,
exactPathActiveClass: String,
event: {
type: eventTypes,
default: 'click'
Expand Down
10 changes: 8 additions & 2 deletions test/specs/components/RouterLink.spec.js
Expand Up @@ -12,7 +12,9 @@ describeWithShallowAndMount('RouterLinkStub', mountingMethod => {
activeClass="activeClass1"
exactActiveClass="exactActiveClass1"
event="event1"
exact-path-active-class="exact-path-active-class"
exact
exact-path
append
replace
/>
Expand All @@ -25,14 +27,18 @@ describeWithShallowAndMount('RouterLinkStub', mountingMethod => {
}
})

const routerLink = wrapper.find(RouterLinkStub)
const routerLink = wrapper.getComponent(RouterLinkStub)
expect(routerLink.props().to).toEqual('to1')
expect(routerLink.props().tag).toEqual('a')
expect(routerLink.props().exact).toEqual(true)
expect(routerLink.props().exactPath).toEqual(true)
expect(routerLink.props().append).toEqual(true)
expect(routerLink.props().replace).toEqual(true)
expect(routerLink.props().activeClass).toEqual('activeClass1')
expect(routerLink.props().exactActiveClass).toEqual('exactActiveClass1')
expect(routerLink.props().exactPathActiveClass).toEqual(
'exact-path-active-class'
)
expect(routerLink.props().event).toEqual('event1')
})

Expand All @@ -49,6 +55,6 @@ describeWithShallowAndMount('RouterLinkStub', mountingMethod => {
RouterLink: RouterLinkStub
}
})
expect(wrapper.find(RouterLinkStub).text()).toEqual('some text')
expect(wrapper.getComponent(RouterLinkStub).text()).toEqual('some text')
})
})

0 comments on commit d6b79c8

Please sign in to comment.