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

setProps and setData should return this #115

Open
hauleth opened this issue Aug 20, 2017 · 2 comments
Open

setProps and setData should return this #115

hauleth opened this issue Aug 20, 2017 · 2 comments

Comments

@hauleth
Copy link

hauleth commented Aug 20, 2017

This would allow chaining methods in tests and in future would simplify migration to immutable VueWrapper.

Example:

  it('contains value of `greeting` prop', () => {
    const wrapper = mount(Hello)

    wrapper.setProps({greeting: 'Yay!'})

    expect(wrapper.text()).toBe('Yay!')
  })

Could be written as:

  it('contains value of `greeting` prop', () => {
    const wrapper = mount(Hello)

    expect(wrapper.setProps({greeting: 'Yay!'}).text()).toBe('Yay!')
  })
@eddyerburgh
Copy link
Owner

Hi @hauleth .

Personally I'm not a fan of chaining methods, but I can be convinced. If other users would benefit from this feature, then I would be happy to accept a PR implementing the changes

@hauleth
Copy link
Author

hauleth commented Aug 31, 2017

The whole point is to have immutable wrappers in future that would allow writing code like:

const wrapper = mount(Hello)

it('contains default greeting', () => {
  expect(wrapper.text()).toBe('Hello World!')
})

it('contains value of `greeting` prop', () => {
  expect(wrapper.setProps({greeting: 'Witaj Świecie!'}).text()).toBe('Witaj Świecie!')
})

Instead of creating new wrapper inside each test.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants