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

Added backward support for params in post data #140

Merged
merged 1 commit into from
Apr 2, 2019
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
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