data(key)
Returns the value of the data.
Arguments
key
(String
): The name of the key inside the data object.
Returns
(Mixed
): Returns the content of the data value or undefined
(if key inside the data object does not exist).
Example
import { mount, mountAsChild } from '@jasoeight/vue-testing';
import { expect } from 'chai';
import Example from './path/to/Example.vue';
describe('Example.vue', () => {
it('has data values (tested with mount())', () => {
const wrapper = mount(Example);
expect(wrapper.data('boolValue')).to.be.false;
expect(wrapper.data('stringValue')).to.equal('example');
expect(wrapper.data('notExisting')).to.be.undefined;
});
it('has data values (tested with mountAsChild())', () => {
const wrapper = mountAsChild(Example);
expect(wrapper.data('boolValue')).to.be.false;
expect(wrapper.data('stringValue')).to.equal('example');
expect(wrapper.data('notExisting')).to.be.undefined;
});
});