All files / tests/unit/tester workflow.js

100% Statements 12/12
100% Branches 0/0
100% Functions 5/5
100% Lines 12/12
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          7x 7x       5x 5x 5x 6x             5x       2x 2x 2x 2x             2x        
import { cloneDeep } from 'lodash';
 
export class WorkflowTester {
 
    constructor() {
        this.states = [];
        this.transitions = [];
    }
 
    withStates(states) {
        const workflow = cloneDeep(this);
        let i = 1;
        workflow.states = states.map(stateLabel => {
            return {
                id: `state_id${i++}`,
                label: stateLabel,
                width: 20,
                height: 10,
            };
        });
        return workflow;
    }
 
    andTransitions(transitions) {
        const workflow = new cloneDeep(this);
        workflow.transitions = transitions.map(transition => {
            let i = 1;
            return {
                id: `transition_id${i++}`,
                width: 20,
                height: 10,
                ...transition,
            };
        });
        return workflow;
    }
}