All files / tests/unit/tester layout.js

100% Statements 16/16
100% Branches 0/0
100% Functions 8/8
100% Lines 16/16
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        8x 8x       6x       3x       6x 6x 9x         6x       3x 3x 3x         3x       8x 8x 8x 8x      
import Layout from '../../../src/lib/layout';
 
export class LayoutBuilder {
    constructor() {
        this._states = [];
        this._transitions = [];
    }
 
    get with() {
        return this;
    }
 
    get and() {
        return this;
    }
 
    states(states) {
        let i = 1;
        this._states = states.map(stateLabel => {
            return {
                id: `state_id${i++}`,
                label: stateLabel,
            };
        });
        return this;
    }
 
    transitions(transitions) {
        this._transitions = transitions.map(transition => {
            let i = 1;
            return {
                id: `transition_id${i++}`,
                ...transition,
            };
        });
        return this;
    }
 
    build() {
        const layout = new Layout();
        layout.setStates(this._states);
        layout.setTransitions(this._transitions);
        return layout;
    }
}