Skip to content

Commit

Permalink
Merge pull request #73 from hpcc-systems/fix-validations-apply
Browse files Browse the repository at this point in the history
chore: Fixed a bug related to JSON apply
  • Loading branch information
martdo02 authored Sep 24, 2024
2 parents 01e4239 + a31ee7f commit ff4c835
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
11 changes: 11 additions & 0 deletions packages/validations/features/json.feature
Original file line number Diff line number Diff line change
Expand Up @@ -320,3 +320,14 @@ Feature: Validations: JSON manipulation
Then "${myJSON[0].mno.convertToString}" is equal to "123"
And "${myJSON[1].mno.convertToString}" is equal to "456"

Scenario: JSON Apply Example
Given set "body" to:
"""
{
"alpha": "string",
"beta": "1234567"
}
"""
And "1111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111115467" is applied to item "body" on JSON path "$.beta"
Then "${body.alpha}" is equal to "string"
And "${body.beta}" is equal to "1111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111115467"
4 changes: 3 additions & 1 deletion packages/validations/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,9 @@ When('{string} is applied to item {string} on JSON path {string}', function (val
if (value.trim() !== '') {
try {
const tmp = JSON.parse(value)
value = tmp
if (typeof tmp === 'object') {
value = tmp
}
} catch (e) { }
}
jp.apply(fileContents, jsonPath, function () { return value })
Expand Down
2 changes: 1 addition & 1 deletion packages/validations/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"publishConfig": {
"access": "public"
},
"version": "2.0.5",
"version": "2.0.6",
"description": "",
"main": "index.js",
"scripts": {
Expand Down

0 comments on commit ff4c835

Please sign in to comment.