computed(key)

Returns the value of a computed method.

Arguments

key (String): The name of the computed function

Returns

(Mixed): Returns the content of the computed function or undefined (if computed function 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('returns the fullname (tested with mount())', () => {
        const wrapper = mount(Example, {
            propsData: {
                firstname: 'John',
                lastname: 'Doe'
            }
        });

        expect(wrapper.computed('fullname')).to.equal('John Doe');
    });

    it('returns the fullname (tested with mountAsChild())', () => {
        const wrapper = mountAsChild(Example, {
            props: {
                firstname: 'John',
                lastname: 'Doe'
            }
        });

        expect(wrapper.computed('fullname')).to.equal('John Doe');
    });
});

results matching ""

    No results matching ""