var { defineSupportCode } = require('cucumber');

defineSupportCode(function({defineParameterType}) {
  defineParameterType({
    regexp: /should|should not/,
    transformer: transform.shouldToBoolean,
    typeName: 'shouldToBoolean'
  });

  defineParameterType({
    regexp: /[^"]+/,
    transformer: transform.stringToVariableName,
    typeName: 'elementName'
  });

  defineParameterType({
    regexp: / button| checkbox| drop down list| field| link| select| tab|/,
    transformer: transform.elementTypeToVariableName,
    typeName: 'elementType'
  });

  defineParameterType({
    regexp: /[^"]*/,
    typeName: 'captureString'
  });
});

var transform = new Transform();

function Transform() {
  this.shouldToBoolean = function(expectation) {
    return expectation === 'should';
  };

  this.stringToVariableName = function(string) {
    var firstWord, i, len, varName, word, words;

    varName = "";
    string = string.replace('&', 'And');

    words = string.split(' ');
    firstWord = words.shift();
    varName += firstWord.charAt(0).toLowerCase() + firstWord.substring(1);

    words = words.map(function(word) {
      return word.charAt(0).toUpperCase() + word.substring(1);
    });

    for (i = 0; i < words.length; i++) {
      word = words[i];
      varName += word;
    }

    return varName;
  };

  this.elementTypeToVariableName = function(string) {
    string = string.trim();
    if (string === "drop down list") {
      return "Select";
    } else {
      return string.charAt(0).toUpperCase() + string.substring(1);
    }
  };
};

module.exports = Transform;

@@ -95,16 +95,52 @@
 ype%7D) %7B%0A
+  var transform = new Transform();%0A%0A
   define
@@ -232,29 +232,25 @@
 oolean,%0A    
-typeN
+n
 ame: 'should
@@ -357,37 +357,33 @@
 riableName,%0A    
-typeN
+n
 ame: 'elementNam
@@ -546,29 +546,25 @@
 leName,%0A    
-typeN
+n
 ame: 'elemen
@@ -630,13 +630,9 @@
     
-typeN
+n
 ame:
@@ -663,42 +663,8 @@
 );%0A%0A
-var transform = new Transform();%0A%0A
 func

Fix Transform errors and deprecation warnings