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

Commit

Permalink
Merge pull request #140 from shrikster/master
Browse files Browse the repository at this point in the history
Added backward support for params in post data
  • Loading branch information
jgroom33 authored Apr 2, 2019
2 parents 46a2904 + 9c6e910 commit cda14b5
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 cda14b5

Please sign in to comment.