prop(key)

Returns the value of the property.

Arguments

key (String): The name of the property.

Returns

(Mixed): Returns the content of the property value or undefined (if key inside the property object does not exist).

Example

Example Component

import { mount, mountAsChild } from '@jasoeight/vue-testing';
import { expect } from 'chai';
import Example from './path/to/Example.vue';

describe('Example.vue', () => {
    it('has default props (tested with mount())', () => {
        const wrapper = mount(Example);
        expect(wrapper.prop('firstname')).to.equal('');
        expect(wrapper.prop('lastname')).to.equal('');
    });

    it('mounts with set properties (tested with mount())', () => {
        const wrapper = mount(Example, {
            propsData: {
                firstname: 'John',
                lastname: 'Doe'
            }
        });
        expect(wrapper.prop('firstname')).to.equal('John');
        expect(wrapper.prop('lastname')).to.equal('Doe');
    });

    it('has default props (tested with mountAsChild())', () => {
        const wrapper = mountAsChild(Example);
        expect(wrapper.prop('firstname')).to.equal('');
        expect(wrapper.prop('lastname')).to.equal('');
    });

    it('mounts with set properties (tested with mount())', () => {
        const wrapper = mountAsChild(Example, {
            props: {
                firstname: 'John',
                lastname: 'Doe'
            }
        });
        expect(wrapper.prop('firstname')).to.equal('John');
        expect(wrapper.prop('lastname')).to.equal('Doe');
    });
});

results matching ""

    No results matching ""