All files / botbuilder-unit/src/messages CustomMessage.js

100% Statements 13/13
100% Branches 2/2
100% Functions 3/3
100% Lines 13/13
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    2x     6x   6x 6x     2x 2x   2x   6x   6x 6x 2x   4x     2x
'use strict';
 
const BaseScriptStep = require('./BaseScriptStep');
 
function CustomMessage(step, config, bot, logReporter, prevStepPromise ) {
  BaseScriptStep.call(this,step,config,bot,logReporter,prevStepPromise);
 
  this.stepFinishedPromise = Promise.all([prevStepPromise] ).then(() => {
    return this.send();
  });
}
CustomMessage.prototype = Object.create(BaseScriptStep.prototype);
CustomMessage.prototype.constructor = CustomMessage;
 
CustomMessage.prototype.send = function () {
 
  this.logReporter.customStep(this.step, this.config);
 
  let result = this.config['custom'].call(this);
  if ( !(result instanceof Promise )) {
    throw new Error('Custom step should return a Promise');
  }
  return result;
}
 
module.exports = CustomMessage;