-
Notifications
You must be signed in to change notification settings - Fork 262
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
issue-249 feat: stub global components #260
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it makes sense to move in that direction, it felt weird to write components: { RouterLink: RouterLinkStub }
in tests 👍
That now leaves the question: do we need to keep components
if we can do the same with stubs
? But maybe we can't and I'm missing something.
|
||
expect(wrapper.html()).toBe( | ||
'<div><router-link-stub></router-link-stub><span></span></div>' | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As I'm a bit unclear on how everything is related, can you maybe add a test where we try to find the component registered as a stub? I'd like to be sure that getComponent
and friends work in that case as well.
I think a real use-case would be to stub RouterLink
with RouterLinkStub
, find it, and check its props to see if the component is creating links with the appropriate values. So I'd like to make sure we cover this 😅
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good idea
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done: 20c7694
Is this what you mean?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perfect, thanks Lachlan!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cool, want to give me a big old ✅
@cexbrayat the global |
@@ -12,6 +12,6 @@ export const RouterLinkStub = defineComponent({ | |||
}, | |||
|
|||
render() { | |||
return h('a', undefined, this.$slots.default()) | |||
return h('a', undefined, this.$slots?.default?.()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is possible to use router-link <router-link />
(however unlikely)
Maybe @cyberb can have some input here too.
This addresses #249
At the moment
stubs
will only work for locally registered components. For global ones (like<router-link>
) you currently must registered a component globally to stub it, eg:Many people expect this to work (I also do)
This PR takes anything from
global.stubs
and registers a global stub.