Skip to content

add createStub function #678

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

Closed
wants to merge 2 commits into from
Closed

add createStub function #678

wants to merge 2 commits into from

Conversation

lmiller1990
Copy link
Member

Regarding #651

This PR adds a createStub method, which creates a component as such:

const MyComp = createStub("MyComp")

MyComp //=>{ name: "MyComp", render: h => h("div") }

Useful for making it clear what is going on when you call find and findAll.

})
```

Where `Child` is a component with `name: 'Child'`.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think the component needs to have the name child. It should use the constructor. Can you check if the example works for a component without a name?

@@ -0,0 +1,7 @@
export default function createStub (name) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that it is better to add flow type as below.

export default function createStub (name: string): Component {

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, and add // @flow to the top of the file

@lmiller1990
Copy link
Member Author

Got caught up, hopefully by tomorrow can get this done. For TODO:

@eddyerburgh
Copy link
Member

Yes the slot default is a good idea. If you'd like you could also add this feature to the default stub rendered in the add-stubs file, so that all default stubs render $slots.

@38elements
Copy link
Contributor

38elements commented Jun 4, 2018

Would you please tell me difference between this feature and a string value in stubs mounting options when the default stub become supporting $slot.default?

@eddyerburgh
Copy link
Member

@38elements You can use these stubs for unnamed components without importing the component:

const SomeStub = createStub()
const wrapper = mount(TestComponent, {
  SomeComponent: SomeStub
})

wrapper.find(SomeStub)

Although this will become irrelevant with #651 🤔

@lmiller1990
Copy link
Member Author

Should we just close this since it is more or less super-seeded by #651 ?

@eddyerburgh eddyerburgh closed this Jun 5, 2018
@lmiller1990 lmiller1990 deleted the add_stub_function branch July 15, 2018 18:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants