'use strict';

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.getStepMessage = getStepMessage;

var _error_helpers = require('./error_helpers');

var _status = require('../../status');

var _status2 = _interopRequireDefault(_status);

var _indentString = require('indent-string');

var _indentString2 = _interopRequireDefault(_indentString);

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

function getAmbiguousStepResultMessage(_ref) {
  var colorFns = _ref.colorFns,
      testStep = _ref.testStep;

  return colorFns.ambiguous(testStep.result.exception);
}

function getFailedStepResultMessage(_ref2) {
  var colorFns = _ref2.colorFns,
      testStep = _ref2.testStep;

  return (0, _error_helpers.formatError)(testStep.result.exception, colorFns);
}

function getPendingStepResultMessage(_ref3) {
  var colorFns = _ref3.colorFns;

  return colorFns.pending('Pending');
}

function getStepMessage(_ref4) {
  var colorFns = _ref4.colorFns,
      keywordType = _ref4.keywordType,
      snippetBuilder = _ref4.snippetBuilder,
      testStep = _ref4.testStep,
      pickleStep = _ref4.pickleStep;

  switch (testStep.result.status) {
    case _status2.default.AMBIGUOUS:
      return getAmbiguousStepResultMessage({ colorFns: colorFns, testStep: testStep });
    case _status2.default.FAILED:
      return getFailedStepResultMessage({ colorFns: colorFns, testStep: testStep });
    case _status2.default.UNDEFINED:
      return getUndefinedStepResultMessage({
        colorFns: colorFns,
        keywordType: keywordType,
        snippetBuilder: snippetBuilder,
        pickleStep: pickleStep
      });
    case _status2.default.PENDING:
      return getPendingStepResultMessage({ colorFns: colorFns });
  }
}

function getUndefinedStepResultMessage(_ref5) {
  var colorFns = _ref5.colorFns,
      keywordType = _ref5.keywordType,
      snippetBuilder = _ref5.snippetBuilder,
      pickleStep = _ref5.pickleStep;

  var snippet = snippetBuilder.build({ keywordType: keywordType, pickleStep: pickleStep });
  var message = '' + ('Undefined. Implement with the following snippet:' + '\n\n') + (0, _indentString2.default)(snippet, 2) + '\n';
  return colorFns.undefined(message);
}
//# sourceMappingURL=data:application/json;charset=utf-8;base64,[encoded data, 4268 characters]