All files / tests/unit ComponentBuilder.js

100% Statements 18/18
100% Branches 0/0
100% Functions 8/8
100% Lines 18/18
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55        23x         19x     15x           23x 23x 23x 23x 23x 23x       13x 13x       23x 23x       26x 26x       23x   23x           23x        
import { createLocalVue, mount, shallowMount } from '@vue/test-utils';
 
 
export function build(component) {
    return component.build();
}
 
class BaseComponent {
    get with() {
        return this;
    }
    get and() {
        return this;
    }
}
 
export class Component extends BaseComponent {
    constructor(vueComponent) {
        super();
        this._component = vueComponent;
        this._options = {};
        this._props = {};
        this._data = undefined;
        this.shallowMount();
    }
 
    mount() {
        this._mountFunction = mount;
        return this;
    }
 
    shallowMount() {
        this._mountFunction = shallowMount;
        return this;
    }
 
    props(props) {
        Object.assign(this._props, props);
        return this;
    }
 
    build() {
        const localVue = createLocalVue();
 
        const buildComponent = this._mountFunction(this._component, {
            localVue,
            ...this._options,
            propsData: this._props,
        });
 
        return buildComponent;
    }
}