Skip to content
This repository has been archived by the owner on Mar 26, 2021. It is now read-only.

Commit

Permalink
added backward support for params in post data
Browse files Browse the repository at this point in the history
  • Loading branch information
shrikster committed Mar 30, 2019
1 parent 46a2904 commit 9c6e910
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 1 deletion.
1 change: 1 addition & 0 deletions SCHEMA.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
- [`postData`](#postdata)
- [`mimeType`](#mimetype)
- [`text`](#text)
- [`params`](#params)
- [`queryString`](#querystring)
- [`headers`](#headers)
- [`auth`](#auth)
Expand Down
6 changes: 5 additions & 1 deletion src/configSchema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,10 +137,14 @@ interface cookiesObjectSchema {
name: string,
value: string,
}
interface paramsObjectSchema {
name: string,
value: string,
}

interface postDataObjectSchema {
mimeType: string,
params: object,
params: Array<paramsObjectSchema>,
text : string,
comment: string,
}
Expand Down
5 changes: 5 additions & 0 deletions src/test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -405,6 +405,11 @@ const performRequest = async (requestObject: requestsObjectSchema, requestName:
if (requestObject.request.postData.text) {
axiosObject.data = requestObject.request.postData.text;
}
if (requestObject.request.postData.params) {
const searchParams = new URLSearchParams()
requestObject.request.postData.params.forEach(item=>{searchParams.append(item.name,item.value)})
axiosObject.data = searchParams.toString();
}
}

try {
Expand Down
19 changes: 19 additions & 0 deletions tests/success/params/post.strest.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
version: 2

requests:
postwithparams:
request:
url: https://postman-echo.com/post
method: POST
postData:
mimeType: application/x-www-form-urlencoded
params:
- name: title
value: foo
- name: body
value: bar
- name: userId
value: "1"
validate:
- jsonpath: content.json.title
expect: foo

0 comments on commit 9c6e910

Please sign in to comment.