Skip to content
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

Write about propsData #3

Closed
lmiller1990 opened this issue Jul 2, 2018 · 0 comments
Closed

Write about propsData #3

lmiller1990 opened this issue Jul 2, 2018 · 0 comments
Labels
english good first issue Good for newcomers

Comments

@lmiller1990
Copy link
Owner

https://github.com/lmiller1990/vue-testing-handbook/blob/master/docs/components-with-props.md

Write about propsData. Some ideas:

  • component receives and renders a prop. Show how to test that. Better yet, write the test first, and then the component, using the error messages to guide your development
  • factory functions. Often you end up with tests like this:
describe("Foo", () => {
  it("something", () => {
    const wrapper = mount(Foo, {
      propsData: {
        shouldShow: true,
        bar: 'foo'
    })
  })

 it("another thing", () => {
    const wrapper = mount(Foo, {
      propsData: {
        shouldShow: false,
        bar: 'foo'
    })
  })
})

We can introduce a factory function:

const factory = (propsData) => {
  return mount(Foo, {
    propsData: {
      bar: "foo",
      ...propsData
    }
  })
}

const wrapper = factory({ shouldShow: false })

const wrapper = factory({ shouldShow: true })
@lmiller1990 lmiller1990 changed the title English: Write about propsData Write about propsData Jul 2, 2018
@lmiller1990 lmiller1990 added english good first issue Good for newcomers labels Jul 2, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
english good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

1 participant