Skip to content

Commit

Permalink
feat(http_api): allow patch method
Browse files Browse the repository at this point in the history
Co-authored-by: Mike Nishizawa <michael@fortitude-solutions.com>
  • Loading branch information
Crow-EH and mnishizawa committed Aug 6, 2021
1 parent 824c435 commit a6b3423
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 4 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -740,7 +740,7 @@ Given:

When:
- /^(?:I )?reset http client$/
- /^(?:I )?(GET|POST|PUT|DELETE) (.+)$/
- /^(?:I )?(GET|POST|PUT|DELETE|PATCH) (.+)$/
- /^(?:I )?dump response body$/
- /^(?:I )?dump response headers$/
- /^(?:I )?dump response cookies$/
Expand Down
2 changes: 1 addition & 1 deletion src/extensions/http_api/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const BODY_TYPE_JSON = 'json'
const BODY_TYPE_FORM = 'form'
const BODY_TYPE_MULTIPART = 'form-data'

const verbsAcceptingBody = ['POST', 'PUT', 'DELETE']
const verbsAcceptingBody = ['POST', 'PUT', 'DELETE', 'PATCH']

/**
* Http Api Client extension.
Expand Down
2 changes: 1 addition & 1 deletion src/extensions/http_api/definitions.js
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ exports.install = ({ baseUrl = '' } = {}) => {
/**
* Performing a request
*/
When(/^(?:I )?(GET|POST|PUT|DELETE) (.+)$/, function (method, path) {
When(/^(?:I )?(GET|POST|PUT|DELETE|PATCH) (.+)$/, function (method, path) {
return this.httpApiClient.makeRequest(method, this.state.populate(path), baseUrl)
})

Expand Down
4 changes: 3 additions & 1 deletion tests/extensions/http_api/definitions.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -466,16 +466,18 @@ test('reset http client', () => {
test('perform a request', () => {
const context = helper.getContext() // Extension context

const def = context.getDefinitionByMatcher('GET|POST|PUT|DELETE')
const def = context.getDefinitionByMatcher('GET|POST|PUT|DELETE|PATCH')
def.shouldNotMatch('I GET ')
def.shouldMatch('I GET /', ['GET', '/'])
def.shouldMatch('I POST /create', ['POST', '/create'])
def.shouldMatch('I PUT /update', ['PUT', '/update'])
def.shouldMatch('I DELETE /delete', ['DELETE', '/delete'])
def.shouldMatch('I PATCH /updatePartial', ['PATCH', '/updatePartial'])
def.shouldMatch('GET /', ['GET', '/'])
def.shouldMatch('POST /create', ['POST', '/create'])
def.shouldMatch('PUT /update', ['PUT', '/update'])
def.shouldMatch('DELETE /delete', ['DELETE', '/delete'])
def.shouldMatch('PATCH /updatePartial', ['PATCH', '/updatePartial'])
})

test('dump response body', () => {
Expand Down

0 comments on commit a6b3423

Please sign in to comment.