Provides utility functions for formatting 2D arrays of strings (such as the raw data loaded from a Gherkin feature file) into a more useful format such as an array of objects or a single object. Also handles normalization of the raw strings.
Node | Description |
---|---|
sap.ui.test.gherkin.dataTableUtils.normalization |
A simple object containing a series of normalization functions that change a string according to a particular strategy. |
Method | Description |
---|---|
sap.ui.test.gherkin.dataTableUtils.toObject |
Takes the inputed 2D array "aData" and returns an equivalent object. Each row of data is expected to be a property-value pair. To create nested objects, add extra columns to the data. E.g. [ ["Name", "Alice"], ["Mass", "135 lbs"], ["Telephone Number", "Home", "123-456-7890"], ["Telephone Number", "Work", "123-456-0987"] ]For each data row, the right-most element becomes a property value, and everything else is a property name. The property names get normalized according to the strategy defined by the parameter "vNorm". E.g. using camelCase strategy { name: "Alice", mass: "135 lbs", telephoneNumber: { home: "123-456-7890", work: "123-456-0987" } } |
sap.ui.test.gherkin.dataTableUtils.toTable |
Takes the inputed 2D array "aData" and returns an equivalent array of objects. The data is expected to have a header row, with each subsequent row being an entity, and each column being a property of that entity. E.g. [ ["Their Name", "Their Age"], ["Alice", "16"], ["Bob", "22"] ] The data's column headers become the returned objects' property names. The property names get normalized according to the strategy defined by the parameter "vNorm". E.g. using hyphenation strategy this is returned: [ {their-name: "Alice", their-age: "16"}, {their-name: "Bob", their-age: "22"} ] |
Takes the inputed 2D array "aData" and returns an equivalent object. Each row of data is expected to be a property-value pair. To create nested objects, add extra columns to the data. E.g.
[ ["Name", "Alice"], ["Mass", "135 lbs"], ["Telephone Number", "Home", "123-456-7890"], ["Telephone Number", "Work", "123-456-0987"] ]For each data row, the right-most element becomes a property value, and everything else is a property name. The property names get normalized according to the strategy defined by the parameter "vNorm". E.g. using camelCase strategy
{ name: "Alice", mass: "135 lbs", telephoneNumber: { home: "123-456-7890", work: "123-456-0987" } }
Param | Type | DefaultValue | Description |
---|---|---|---|
aData | string[] |
the 2D array of strings to be converted |
|
vNorm | string function | "none" |
the normalization function to use to normalize property names. Can also be a string with values "titleCase", "pascalCase", "camelCase", "hyphenated" or "none". |
Takes the inputed 2D array "aData" and returns an equivalent array of objects. The data is expected to have a header row, with each subsequent row being an entity, and each column being a property of that entity. E.g.
[ ["Their Name", "Their Age"], ["Alice", "16"], ["Bob", "22"] ]
The data's column headers become the returned objects' property names. The property names get normalized according to the strategy defined by the parameter "vNorm". E.g. using hyphenation strategy this is returned:
[ {their-name: "Alice", their-age: "16"}, {their-name: "Bob", their-age: "22"} ]
Param | Type | DefaultValue | Description |
---|---|---|---|
aData | string[] |
the 2D array of strings to be converted, with a header row |
|
vNorm | string function | "none" |
the normalization function to use to normalize property names. Can also be a String with values "titleCase", "pascalCase", "camelCase", "hyphenated" or "none". |