@zohodesk/testinglibrary 0.1.8-bdd-29 → 0.1.8-bdd-30.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -11,6 +11,7 @@ const Given = Step;
11
11
  const Then = Step;
12
12
  const When = Step;
13
13
  const And = Step;
14
+ const But = Step;
14
15
  function createBdd() {
15
16
  return {
16
17
  Given,
@@ -41,7 +41,7 @@ function filterTestData(description, argument) {
41
41
  /** Scenario Table Passed */
42
42
 
43
43
  if (stepArguments.scenarioTable) {
44
- return getScenarioTable(stepArguments, argument);
44
+ return getScenarioTable(stepArguments, description, argument);
45
45
  // var exceedParam = stepArguments.inputParameter[0];
46
46
  // const extracted = argument.map(element => {
47
47
  // return exceedParam[element.trim()];
@@ -61,12 +61,12 @@ function getInputs(stepArguments) {
61
61
  function getStepTable(stepArguments) {
62
62
  const dataTable = {
63
63
  raw: () => {
64
- return stepArguments.stepArguments || [];
64
+ return stepArguments.dataTableStep || [];
65
65
  }
66
66
  };
67
67
  return [dataTable];
68
68
  }
69
- function getScenarioTable(stepArguments, argument) {
69
+ function getScenarioTable(stepArguments, description, argument) {
70
70
  var exceedParam = stepArguments.inputParameter[0];
71
71
  const extracted = argument.map(element => {
72
72
  return exceedParam[element.trim()];
@@ -85,12 +85,14 @@ const $Given = $And;
85
85
  const $Step = $And;
86
86
  const $Then = $And;
87
87
  const $When = $And;
88
+ const $But = $And;
88
89
  function createNativeBDD() {
89
90
  return {
90
91
  $Given,
91
92
  $When,
92
93
  $And,
93
94
  $Then,
94
- $Step
95
+ $Step,
96
+ $But
95
97
  };
96
98
  }
@@ -76,7 +76,7 @@ function testDataExtraction(tableHeader, tableBody) {
76
76
  tableBody.forEach(tableCells => {
77
77
  const InputObject = {};
78
78
  tableCells.forEach((item, index) => {
79
- InputObject[`<${tableHeader[index]}>`] = item;
79
+ InputObject[`${tableHeader[index].trim()}`] = item;
80
80
  });
81
81
  result.push(InputObject);
82
82
  });
@@ -108,4 +108,88 @@ function createTestDataMap() {
108
108
  // handle length of example
109
109
  // if($scenario?.background){
110
110
  // $scenario.scenario = $scenario.background
111
+ // }
112
+
113
+ // function createDataDriven($scenario){
114
+ // var body, header;
115
+ // return new Promise((resolve) => {
116
+ // if ($scenario?.background) {
117
+ // $scenario.scenario = { ...$scenario.background, examples: [] };
118
+ // }
119
+ // if ($scenario?.scenario?.steps) {
120
+ // $scenario.scenario?.steps.forEach(step => {
121
+ // var $currentStep = {
122
+ // currentArgument: '',
123
+ // dataTableStep: '',
124
+ // inputParameter: '',
125
+ // input: false,
126
+ // steptable: false,
127
+ // scenarioTable: false
128
+ // };
129
+ // const { convertedStep, currentArgument } = extractStepArgument(
130
+ // step.text
131
+ // );
132
+ // if (
133
+ // Object.values(currentArgument).length &&
134
+ // !$scenario.scenario.examples.length
135
+ // ) {
136
+ // $currentStep.currentArgument = currentArgument;
137
+ // $currentStep.input = true;
138
+ // } else {
139
+ // $currentStep.currentArgument = [];
140
+ // $currentStep.input = false;
141
+ // }
142
+ // var dataTableStep;
143
+ // step?.dataTable?.rows.forEach(cell => {
144
+ // const Table = cell.cells.map(element => element.value);
145
+ // dataTableStep = Table;
146
+ // });
147
+ // if (step?.dataTable) {
148
+ // $currentStep.dataTableStep = dataTableStep;
149
+ // $currentStep.steptable = true;
150
+ // }
151
+
152
+ // $globalTestdata.set(convertedStep, Object.assign({}, $currentStep));
153
+ // });
154
+ // }
155
+
156
+ // if ($scenario.background && typeof $scenario.background === Object) {
157
+ // return;
158
+ // }
159
+
160
+ // if (!$scenario.scenario?.examples?.length) {
161
+ // return;
162
+ // }
163
+
164
+ // if ($scenario.scenario?.examples?.length) {
165
+ // var $currentExampleSteps = {
166
+ // currentArgument: '',
167
+ // dataTableStep: '',
168
+ // inputParameter: '',
169
+ // input: false,
170
+ // steptable: false,
171
+ // scenarioTable: false
172
+ // };
173
+ // exampleSteps = $scenario.scenario.steps.map(
174
+ // element => extractStepArgument(element.text).convertedStep
175
+ // );
176
+ // $scenario.scenario?.examples.map(example => {
177
+ // body = example?.tableBody.map(cell => {
178
+ // return cell?.cells.map(example => example.value);
179
+ // });
180
+ // header = example?.tableHeader?.cells.map(exampleHead => {
181
+ // return exampleHead.value;
182
+ // });
183
+ // });
184
+ // const inputParameter = testDataExtraction(header, body);
185
+ // exampleSteps.forEach(step => {
186
+ // $currentExampleSteps.inputParameter = Object.assign(
187
+ // [],
188
+ // inputParameter
189
+ // );
190
+ // $currentExampleSteps.scenarioTable = true;
191
+ // $globalTestdata.set(step, Object.assign({}, $currentExampleSteps));
192
+ // });
193
+ // }
194
+ // });
111
195
  // }
@@ -13,7 +13,7 @@ function stepReportHandle(Steps, Example) {
13
13
  const medium = Math.random();
14
14
  resultSteps = _steps.join(medium);
15
15
  Object.keys(Example).forEach(keys => {
16
- const newRegex = new RegExp(keys, 'g');
16
+ const newRegex = new RegExp(`<${keys}>`, 'g');
17
17
  resultSteps = resultSteps.replace(newRegex, Example[keys]);
18
18
  });
19
19
  return [...resultSteps.split(medium)];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zohodesk/testinglibrary",
3
- "version": "0.1.8-bdd-29",
3
+ "version": "0.1.8-bdd-30.1",
4
4
  "description": "",
5
5
  "main": "./build/index.js",
6
6
  "scripts": {