Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Fixed a bug related to JSON apply #73

Merged
merged 1 commit into from
Sep 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading