All files step.js

100% Statements 16/16
100% Branches 8/8
100% Functions 2/2
100% Lines 16/16

Press n or j to go to the next uncovered block, b, p or k for the previous block.

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 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78                                                            1x   1x                     14x 14x 14x 14x 14x 14x 14x 14x 14x 14x 14x                 1x 9x                         1x  
"use strict";
 
/**
 * Creates instance of step.
 *
 * @class
 * @name Step
 * @classdesc Step data.
 * @arg {string} name - Step name.
 * @arg {object} income - Income state.
 * @arg {object} outcome - Outcome state.
 * @arg {number} [usage=1] - Usage number.
 * @arg {string[]} [actions=[]] - Step actions.
 * @arg {string[]} [expected=[]] - Step expectations.
 * @arg {?string[]} [complete] - List of completenesses.
 * @arg {?string[]} [incomplete] - List of incompletenesses.
 * @arg {?string} [before] - Name of step, which should be executed after this.
 * @arg {?string} [after] - Name of step, which this step should be executed after.
 * @prop {string} name - Step name.
 * @prop {object} income - Income state.
 * @prop {object} outcome - Outcome state.
 * @prop {number} [usage=1] - Usage number.
 * @prop {number} [actions=[]] - Step actions.
 * @prop {string[]} [expected=[]] - Step expectations.
 * @prop {?string[]} [complete] - List of completenesses.
 * @prop {?string[]} [incomplete] - List of incompletenesses.
 * @prop {?string} [before] - Name of step, which should be executed after this.
 * @prop {?string} [after] - Name of step, which this step should be executed after.
 */
 
var _ = require("lodash");
 
var Step = function (name,
    weight,
    income,
    outcome,
    usage,
    actions,
    expected,
    complete,
    incomplete,
    before,
    after) {
    this.name = name;
    this.weight = weight || 1;
    this.income = income;
    this.outcome = outcome;
    this.usage = usage || 1;
    this.actions = actions || [];
    this.expected = expected || [];
    this.complete = complete;
    this.incomplete = incomplete;
    this.before = before;
    this.after = after;
};
 
/**
 * Clones step.
 *
 * @method
 * @return {Step} New instance of step with the same parameters.
 */
Step.prototype.clone = function () {
    return new this.constructor(this.name,
        this.weight,
        _.cloneDeep(this.income),
        _.cloneDeep(this.outcome),
        this.usage,
        _.clone(this.actions),
        _.clone(this.expected),
        _.clone(this.complete),
        _.clone(this.incomplete),
        this.before,
        this.after);
};
 
module.exports = Step;