setData(params = {})
Updates the component and waiting for the next update of the vue component lifecycle. Sets property or data values.
Arguments
params
(Objects
): A key list with the new values.
Returns
(Promise
): Returns a promise which resolves after the next update of the vue component lifecycle.
Example
import { mount } from '@jasoeight/vue-testing';
import { expect } from 'chai';
import Example from './path/to/Example.vue';
describe('Example.vue', () => {
it('updates properties (tested with mount())', done => {
const wrapper = mount(Example);
wrapper.setData({
firstname: 'John',
lastname: 'Doe',
stringValue: 'example new',
boolValue: true
})
.then(() => {
expect(wrapper.prop('firstname')).to.equal('John');
expect(wrapper.prop('lastname')).to.equal('Doe');
expect(wrapper.computed('fullname')).to.equal('John Doe');
expect(wrapper.data('stringValue')).to.equal('example new');
expect(wrapper.data('boolValue')).to.be.true;
done();
})
.catch(result => {
done(result);
});
});
});