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

setData with an empty object doesn't get set #1704

Closed
Haroenv opened this issue Oct 1, 2020 · 2 comments
Closed

setData with an empty object doesn't get set #1704

Haroenv opened this issue Oct 1, 2020 · 2 comments

Comments

@Haroenv
Copy link
Contributor

Haroenv commented Oct 1, 2020

Subject of the issue

If you call wrapper.setData({ someKey: {} }), it doesn't set the someKey to {}

Steps to reproduce

this test doesn't pass

const wrapper = mount({
  data() {
    return {
      someKey: { someValue: true },
    };
  },
  render(h) {
    return h('span');
  },
});

expect(wrapper.vm.$data).toEqual({ someKey: { someValue: true } });

wrapper.setData({ someKey: {} });

expect(wrapper.vm.$data).toEqual({ someKey: {} });

Expected behaviour

This test passes

Actual behaviour

The test doesn't pass, it still has the previous

Possible Solution

In here: https://github.com/vuejs/vue-test-utils/blob/dev/packages/test-utils/src/recursively-set-data.js I think it might make sense to see if the object has keys at all, if it doesn't have keys, you could set the value.

Haroenv added a commit to Haroenv/vue-test-utils that referenced this issue Oct 1, 2020
fixes vuejs#1704 

This is a tentative fix to show one possible solution, I can clean it up if you think it makes sense
@Ivan-dev-RED
Copy link

Why this issue closed??
I have the same trouble and this solution is bullshit

@lmiller1990
Copy link
Member

Does #1705 not fix? That was the intention: Haroenv@cda6e4b

If you want to fork this repo and add a minimal repro, we can take a look.

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

No branches or pull requests

3 participants